From aee7d2a0cfd96e8a549951f6c20ecf240052953d Mon Sep 17 00:00:00 2001 From: Filip Maj Date: Wed, 12 Jun 2024 08:50:57 -0400 Subject: [PATCH] use imports in deno.jsonc, move away from deps/devdeps.ts --- deno.jsonc | 16 +++++++++++----- src/deps.ts | 1 - src/dev_deps.ts | 11 ----------- src/mock.ts | 2 +- src/mod.ts | 8 ++++---- src/tests.ts | 10 ++++++---- 6 files changed, 22 insertions(+), 26 deletions(-) delete mode 100644 src/deps.ts delete mode 100644 src/dev_deps.ts diff --git a/deno.jsonc b/deno.jsonc index 70ca682..c88e58c 100644 --- a/deno.jsonc +++ b/deno.jsonc @@ -1,7 +1,7 @@ { "$schema": "https://deno.land/x/deno/cli/schemas/config-file.v1.json", "name": "@slack/protocols", - "version": "0.0.2", + "version": "0.0.2-pre.1", "exports": "./src/mod.ts", "fmt": { "include": ["src", "docs", "README.md"], @@ -12,15 +12,21 @@ "singleQuote": false, "useTabs": false }, + "imports": { + "@std/assert": "jsr:@std/assert@^0.226.0", + "@std/cli": "jsr:@std/cli@^0.224.6", + "@std/testing": "jsr:@std/testing@^0.225.1" + }, "lint": { "include": ["src"] }, - "test": { - "include": ["src/tests.ts"] - }, + "lock": false, "tasks": { "test": "deno fmt --check && deno lint && deno test --allow-read --allow-net", - "generate-lcov": "rm -rf .coverage && deno test --reporter=dot --allow-read --allow-net --coverage=.coverage && deno coverage --exclude=fixtures --exclude=test --lcov --output=lcov.info .coverage", + "generate-lcov": "rm -rf .coverage && deno test --allow-read --allow-net --coverage=.coverage && deno coverage --exclude=fixtures --exclude=test --lcov --output=lcov.info .coverage", "test:coverage": "deno task generate-lcov && deno coverage --detailed --exclude=fixtures --exclude=test .coverage src" + }, + "test": { + "include": ["src/tests.ts"] } } diff --git a/src/deps.ts b/src/deps.ts deleted file mode 100644 index 5aad7db..0000000 --- a/src/deps.ts +++ /dev/null @@ -1 +0,0 @@ -export { parse } from "https://deno.land/std@0.134.0/flags/mod.ts"; diff --git a/src/dev_deps.ts b/src/dev_deps.ts deleted file mode 100644 index d03534a..0000000 --- a/src/dev_deps.ts +++ /dev/null @@ -1,11 +0,0 @@ -export { - assertSpyCall, - spy, -} from "https://deno.land/std@0.177.0/testing/mock.ts"; -export type { Spy } from "https://deno.land/std@0.177.0/testing/mock.ts"; -export { - assertEquals, - assertMatch, - assertNotEquals, - assertThrows, -} from "https://deno.land/std@0.177.0/testing/asserts.ts"; diff --git a/src/mock.ts b/src/mock.ts index 7806916..6b81e8e 100644 --- a/src/mock.ts +++ b/src/mock.ts @@ -1,5 +1,5 @@ import type { Protocol } from "./types.ts"; -import { spy } from "./dev_deps.ts"; +import { spy } from "@std/testing/mock"; export const MockProtocol = function (): Protocol { return { diff --git a/src/mod.ts b/src/mod.ts index b22d722..d3ef3ac 100644 --- a/src/mod.ts +++ b/src/mod.ts @@ -1,4 +1,4 @@ -import { parse } from "./deps.ts"; +import { parseArgs } from "@std/cli/parse-args"; import type { Protocol } from "./types.ts"; // List of slack-cli communication protocols supported @@ -16,7 +16,7 @@ const SUPPORTED_NAMED_PROTOCOLS = [ * @returns {Protocol} */ export const BaseProtocol = function (args: string[]): Protocol { - const { manifest: manifestOnly = false } = parse(args); + const { manifest: manifestOnly = false } = parseArgs(args); // If the particular hook invocation is requesting for manifest generation, we ensure any logging is a no-op, // so as to not litter stdout with logging - and confuse the CLI's manifest JSON payload parsing. const loggerMethod = manifestOnly ? () => {} : console.log; @@ -38,7 +38,7 @@ export const BaseProtocol = function (args: string[]): Protocol { export const MessageBoundaryProtocol = function ( args: string[], ): Required> & Protocol { - const { boundary } = parse( + const { boundary } = parseArgs( args, ); if (!boundary) throw new Error("no boundary argument provided!"); @@ -69,7 +69,7 @@ const PROTOCOL_MAP = { * @returns {Protocol} An object implementing the Protocol interface */ export const getProtocolInterface = function (args: string[]): Protocol { - const { protocol: protocolRequestedByCLI } = parse( + const { protocol: protocolRequestedByCLI } = parseArgs( args, ); if (protocolRequestedByCLI) { diff --git a/src/tests.ts b/src/tests.ts index e31c721..cc47bc7 100644 --- a/src/tests.ts +++ b/src/tests.ts @@ -1,12 +1,14 @@ +import { + assertSpyCall, + type Spy, + spy, +} from "@std/testing/mock"; import { assertEquals, assertMatch, assertNotEquals, - assertSpyCall, assertThrows, - type Spy, - spy, -} from "./dev_deps.ts"; +} from "@std/assert"; import { BaseProtocol, getProtocolInterface,