Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions src/deps.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
// TODO: latest version of std does not have a io/utils.ts
export { readAll } from "https://deno.land/std@0.99.0/io/util.ts";
export { BaseSlackAPIClient } from "https://deno.land/x/deno_slack_api@0.0.2/base-client.ts";
// TODO: Update to import from `deno-slack-hooks` instead
export { createManifest } from "https://deno.land/x/deno_slack_builder@0.0.14/manifest.ts";
export { getManifest } from "https://deno.land/x/deno_slack_hooks@1.4.0/get_manifest.ts";
export { parse } from "https://deno.land/std@0.99.0/flags/mod.ts";
export { getProtocolInterface } from "https://deno.land/x/deno_slack_protocols@0.0.2/mod.ts";
export type { Protocol } from "https://deno.land/x/deno_slack_protocols@0.0.2/types.ts";
12 changes: 4 additions & 8 deletions src/local-run-function.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {
createManifest,
getManifest,
getProtocolInterface,
Protocol,
readAll,
Expand All @@ -11,18 +11,14 @@ import { DispatchPayload } from "./dispatch-payload.ts";
* @description Runs an application function locally by dispatching a payload to it after loading it.
*/
export const runLocally = async function (
create: typeof createManifest,
create: typeof getManifest,
parse: typeof ParsePayload,
readStdin: typeof readAll,
dispatch: typeof DispatchPayload,
hookCLI: Protocol,
): Promise<void> {
const workingDirectory = Deno.cwd();
const manifest = await create({
manifestOnly: true,
log: () => {},
workingDirectory,
});
const manifest = await create(workingDirectory);
if (!manifest.functions) {
throw new Error(
`No function definitions were found in the manifest! manifest.functions: ${manifest.functions}`,
Expand Down Expand Up @@ -53,7 +49,7 @@ export const runLocally = async function (
if (import.meta.main) {
const hookCLI = getProtocolInterface(Deno.args);
await runLocally(
createManifest,
getManifest,
ParsePayload,
readAll,
DispatchPayload,
Expand Down
17 changes: 4 additions & 13 deletions src/local-run.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,4 @@
import {
createManifest,
getProtocolInterface,
parse,
Protocol,
} from "./deps.ts";
import { getManifest, getProtocolInterface, parse, Protocol } from "./deps.ts";

const SLACK_DEV_DOMAIN_FLAG = "sdk-slack-dev-domain";

Expand Down Expand Up @@ -95,16 +90,12 @@ export const getCommandline = function (
* @description Runs an application locally by calling `deno run` with appropriate flags.
*/
export const runWithOutgoingDomains = async function (
create: typeof createManifest,
create: typeof getManifest,
devDomain: string,
hookCLI: Protocol,
): Promise<void> {
const workingDirectory = Deno.cwd();
const manifest = await create({
manifestOnly: true,
log: () => {},
workingDirectory,
});
const manifest = await create(workingDirectory);

if (!manifest.functions) {
throw new Error(
Expand Down Expand Up @@ -141,7 +132,7 @@ export const runWithOutgoingDomains = async function (
if (import.meta.main) {
const hookCLI = getProtocolInterface(Deno.args);
await runWithOutgoingDomains(
createManifest,
getManifest,
parseDevDomain(Deno.args),
hookCLI,
);
Expand Down
Loading