From e79c45bf52e51de6779d712b8f0a9b4f0f7b17c3 Mon Sep 17 00:00:00 2001 From: Julien Oculi Date: Thu, 29 Feb 2024 11:55:59 +0100 Subject: [PATCH 01/47] chore: :package: add jsr module metadatas --- deno.jsonc | 52 ++++++++++++++++++++++++++++++++-------------------- 1 file changed, 32 insertions(+), 20 deletions(-) diff --git a/deno.jsonc b/deno.jsonc index 17088efa..e28a12ae 100644 --- a/deno.jsonc +++ b/deno.jsonc @@ -1,22 +1,34 @@ { - "lock": false, - "exclude": ["dist"], - "tasks": { - "lint": "deno lint && deno fmt --check", - "fmt": "deno fmt", - "test": "deno test --doc --allow-run=deno --allow-env --allow-read=./ --allow-write=./ --ignore=./CHANGELOG.md --parallel", - "check:examples": "deno check examples/**/*.ts", - "snapshot": "deno task test -- --update", - "coverage": "deno task test --coverage=./dist/coverage/all/result && deno coverage --lcov ./dist/coverage/all/result > ./dist/coverage/all/cov.lcov", - "coverage:ansi": "deno task test ansi --coverage=./dist/coverage/ansi/result && deno coverage --lcov ./dist/coverage/ansi/result > ./dist/coverage/ansi/cov.lcov", - "coverage:command": "deno task test command --coverage=./dist/coverage/command/result && deno coverage --lcov ./dist/coverage/command/result > ./dist/coverage/command/cov.lcov", - "coverage:flags": "deno task test flags --coverage=./dist/coverage/flags/result && deno coverage --lcov ./dist/coverage/flags/result > ./dist/coverage/flags/cov.lcov", - "coverage:keycode": "deno task test keycode --coverage=./dist/coverage/keycode/result && deno coverage --lcov ./dist/coverage/keycode/result > ./dist/coverage/keycode/cov.lcov", - "coverage:keypress": "deno task test keypress --coverage=./dist/coverage/keypress/result && deno coverage --lcov ./dist/coverage/keypress/result > ./dist/coverage/keypress/cov.lcov", - "coverage:prompt": "deno task test prompt --coverage=./dist/coverage/prompt/result && deno coverage --lcov ./dist/coverage/prompt/result > ./dist/coverage/prompt/cov.lcov", - "coverage:table": "deno task test table --coverage=./dist/coverage/table/result && deno coverage --lcov ./dist/coverage/table/result > ./dist/coverage/table/cov.lcov", - "coverage:testing": "deno task test testing --coverage=./dist/coverage/testing/result && deno coverage --lcov ./dist/coverage/testing/result > ./dist/coverage/testing/cov.lcov", - "update": "deno run --allow-read=./ --allow-net --allow-write=./ https://deno.land/x/deno_outdated@0.2.5/cli.ts --ignore README.md CHANGELOG.md CONTRIBUTING.md" - // "update": "deno run --allow-read=./ --allow-write=./ https://deno.land/x/udd@0.8.2/main.ts" globs are a bit weird in tasks: https://github.com/denoland/deno/discussions/15625 - } + "name": "@c4spar/cliffy", + "version": "1.0.0-rc.3", + "exports": { + "ansi": "./ansi/mod.ts", + "command": "./command/mod.ts", + "flags": "./flags/mod.ts", + "keycode": "./keycode/mod.ts", + "keypress": "./keypress/mod.ts", + "prompt": "./prompt/mod.ts", + "table": "./table/mod.ts", + "testing": "./testing/mod.ts" + }, + "lock": false, + "exclude": ["dist"], + "tasks": { + "lint": "deno lint && deno fmt --check", + "fmt": "deno fmt", + "test": "deno test --doc --allow-run=deno --allow-env --allow-read=./ --allow-write=./ --ignore=./CHANGELOG.md --parallel", + "check:examples": "deno check examples/**/*.ts", + "snapshot": "deno task test -- --update", + "coverage": "deno task test --coverage=./dist/coverage/all/result && deno coverage --lcov ./dist/coverage/all/result > ./dist/coverage/all/cov.lcov", + "coverage:ansi": "deno task test ansi --coverage=./dist/coverage/ansi/result && deno coverage --lcov ./dist/coverage/ansi/result > ./dist/coverage/ansi/cov.lcov", + "coverage:command": "deno task test command --coverage=./dist/coverage/command/result && deno coverage --lcov ./dist/coverage/command/result > ./dist/coverage/command/cov.lcov", + "coverage:flags": "deno task test flags --coverage=./dist/coverage/flags/result && deno coverage --lcov ./dist/coverage/flags/result > ./dist/coverage/flags/cov.lcov", + "coverage:keycode": "deno task test keycode --coverage=./dist/coverage/keycode/result && deno coverage --lcov ./dist/coverage/keycode/result > ./dist/coverage/keycode/cov.lcov", + "coverage:keypress": "deno task test keypress --coverage=./dist/coverage/keypress/result && deno coverage --lcov ./dist/coverage/keypress/result > ./dist/coverage/keypress/cov.lcov", + "coverage:prompt": "deno task test prompt --coverage=./dist/coverage/prompt/result && deno coverage --lcov ./dist/coverage/prompt/result > ./dist/coverage/prompt/cov.lcov", + "coverage:table": "deno task test table --coverage=./dist/coverage/table/result && deno coverage --lcov ./dist/coverage/table/result > ./dist/coverage/table/cov.lcov", + "coverage:testing": "deno task test testing --coverage=./dist/coverage/testing/result && deno coverage --lcov ./dist/coverage/testing/result > ./dist/coverage/testing/cov.lcov", + "update": "deno run --allow-read=./ --allow-net --allow-write=./ https://deno.land/x/deno_outdated@0.2.5/cli.ts --ignore README.md CHANGELOG.md CONTRIBUTING.md" + // "update": "deno run --allow-read=./ --allow-write=./ https://deno.land/x/udd@0.8.2/main.ts" globs are a bit weird in tasks: https://github.com/denoland/deno/discussions/15625 + } } From 4e104e5749e1c7d64b0776d060ee78ba80d961cb Mon Sep 17 00:00:00 2001 From: Julien Oculi Date: Thu, 29 Feb 2024 12:25:46 +0100 Subject: [PATCH 02/47] refactor: :package: replace remote url imports by jsr or npm --- ansi/colors.ts | 2 +- ansi/deps.ts | 4 ++-- command/deps.ts | 2 +- command/test/command/generic_types_test.ts | 2 +- command/test/type/file_test.ts | 2 +- deno.jsonc | 17 ++++++++++++++- dev_deps.ts | 24 +++++++++++----------- examples/ansi.ts | 2 +- examples/ansi/custom.ts | 2 +- examples/ansi/demo.ts | 2 +- examples/command.ts | 2 +- examples/command/examples.ts | 2 +- examples/prompt/custom_prompts.ts | 2 +- examples/prompt/prompt_demo.ts | 2 +- examples/table/random_table_demo.ts | 2 +- prompt/deps.ts | 6 +++--- prompt/test/prompt_list_test.ts | 2 +- table/deps.ts | 4 ++-- testing/deps.ts | 8 ++++---- 19 files changed, 52 insertions(+), 37 deletions(-) diff --git a/ansi/colors.ts b/ansi/colors.ts index c813ee08..e67b60bf 100644 --- a/ansi/colors.ts +++ b/ansi/colors.ts @@ -1,4 +1,4 @@ -import * as stdColors from "https://deno.land/std@0.216.0/fmt/colors.ts"; +import * as stdColors from "@std/fmt/colors"; type ExcludedColorMethods = "setColorEnabled" | "getColorEnabled"; type PropertyNames = keyof typeof stdColors; diff --git a/ansi/deps.ts b/ansi/deps.ts index e0311eaf..1af5ec75 100644 --- a/ansi/deps.ts +++ b/ansi/deps.ts @@ -1,5 +1,5 @@ -export { encodeBase64 } from "https://deno.land/std@0.216.0/encoding/base64.ts"; +export { encodeBase64 } from "@std/encoding/base64"; export type { ReaderSync, WriterSync, -} from "https://deno.land/std@0.216.0/io/types.ts"; +} from "@std/io/types"; diff --git a/command/deps.ts b/command/deps.ts index 98cebbd6..e83b3a44 100644 --- a/command/deps.ts +++ b/command/deps.ts @@ -10,4 +10,4 @@ export { red, setColorEnabled, yellow, -} from "https://deno.land/std@0.216.0/fmt/colors.ts"; +} from "@std/fmt/colors"; diff --git a/command/test/command/generic_types_test.ts b/command/test/command/generic_types_test.ts index 0719e2ba..55ffd537 100644 --- a/command/test/command/generic_types_test.ts +++ b/command/test/command/generic_types_test.ts @@ -3,7 +3,7 @@ import { assert, IsAny, IsExact, -} from "https://deno.land/x/conditional_type_checks@1.0.6/mod.ts"; +} from "conditional_type_checks"; // Not required to execute this code, only type check. (() => { diff --git a/command/test/type/file_test.ts b/command/test/type/file_test.ts index 4aad8a6c..935b1810 100644 --- a/command/test/type/file_test.ts +++ b/command/test/type/file_test.ts @@ -1,7 +1,7 @@ import { assert, IsExact, -} from "https://deno.land/x/conditional_type_checks@1.0.6/mod.ts"; +} from "conditional_type_checks"; import { assertEquals } from "../../../dev_deps.ts"; import { Command } from "../../command.ts"; diff --git a/deno.jsonc b/deno.jsonc index e28a12ae..3f22cc4b 100644 --- a/deno.jsonc +++ b/deno.jsonc @@ -30,5 +30,20 @@ "coverage:testing": "deno task test testing --coverage=./dist/coverage/testing/result && deno coverage --lcov ./dist/coverage/testing/result > ./dist/coverage/testing/cov.lcov", "update": "deno run --allow-read=./ --allow-net --allow-write=./ https://deno.land/x/deno_outdated@0.2.5/cli.ts --ignore README.md CHANGELOG.md CONTRIBUTING.md" // "update": "deno run --allow-read=./ --allow-write=./ https://deno.land/x/udd@0.8.2/main.ts" globs are a bit weird in tasks: https://github.com/denoland/deno/discussions/15625 - } + }, + "imports": { + "@std/assert": "jsr:@std/assert@0.216", + "@std/async": "jsr:@std/async@0.216", + "@std/console": "jsr:@std/console@0.216", + "@std/datetime": "jsr:@std/datetime@0.216", + "@std/encoding": "jsr:@std/encoding@0.216", + "@std/fmt": "jsr:@std/fmt@0.216", + "@std/fs": "jsr:@std/fs@0.216", + "@std/http": "jsr:@std/http@0.216", + "@std/io": "jsr:@std/io@0.216", + "@std/path": "jsr:@std/path@0.216", + "@std/testing": "jsr:@std/testing@0.216", + "conditional_type_checks": "npm:conditional-type-checks@1.0.6", + "sinon": "npm:sinon@13.0.2" + } } diff --git a/dev_deps.ts b/dev_deps.ts index bea43d57..b501b0a1 100644 --- a/dev_deps.ts +++ b/dev_deps.ts @@ -6,28 +6,28 @@ export { assertRejects, assertStrictEquals, assertThrows, -} from "https://deno.land/std@0.216.0/assert/mod.ts"; +} from "@std/assert"; export { assertSpyCall, assertSpyCalls, spy, -} from "https://deno.land/std@0.216.0/testing/mock.ts"; -export { assertSnapshot } from "https://deno.land/std@0.216.0/testing/snapshot.ts"; -export { describe, it } from "https://deno.land/std@0.216.0/testing/bdd.ts"; +} from "@std/testing/mock"; +export { assertSnapshot } from "@std/testing/snapshot"; +export { describe, it } from "@std/testing/bdd"; export { assertType, type IsExact, -} from "https://deno.land/std@0.216.0/testing/types.ts"; +} from "@std/testing/types"; export { bold, red, stripColor, -} from "https://deno.land/std@0.216.0/fmt/colors.ts"; -export { dirname } from "https://deno.land/std@0.216.0/path/dirname.ts"; -export { expandGlob } from "https://deno.land/std@0.216.0/fs/expand_glob.ts"; -export type { WalkEntry } from "https://deno.land/std@0.216.0/fs/walk.ts"; -export { copy } from "https://deno.land/std@0.216.0/io/copy.ts"; -export { format } from "https://deno.land/std@0.216.0/datetime/format.ts"; +} from "@std/fmt/colors"; +export { dirname } from "@std/path/dirname"; +export { expandGlob } from "@std/fs/expand_glob"; +export type { WalkEntry } from "@std/fs/walk"; +export { copy } from "@std/io/copy"; +export { format } from "@std/datetime/format"; /* 3rd party */ -export { default as sinon } from "https://cdn.skypack.dev/sinon@v13.0.2?dts"; +export { default as sinon } from "sinon"; diff --git a/examples/ansi.ts b/examples/ansi.ts index 70109ce3..d4b24fc9 100644 --- a/examples/ansi.ts +++ b/examples/ansi.ts @@ -1,7 +1,7 @@ #!/usr/bin/env -S deno run import { colors, tty } from "../ansi/mod.ts"; -import { delay } from "https://deno.land/std@0.216.0/async/delay.ts"; +import { delay } from "@std/async/delay"; const error = colors.bold.red; const warn = colors.bold.yellow; diff --git a/examples/ansi/custom.ts b/examples/ansi/custom.ts index 12c3235e..776caf4a 100755 --- a/examples/ansi/custom.ts +++ b/examples/ansi/custom.ts @@ -1,6 +1,6 @@ #!/usr/bin/env -S deno run --allow-net=deno.land -import { rgb24 } from "https://deno.land/std@0.216.0/fmt/colors.ts"; +import { rgb24 } from "@std/fmt/colors"; import { tty } from "../../ansi/tty.ts"; const response = await fetch("https://deno.land/images/hashrock_simple.png"); diff --git a/examples/ansi/demo.ts b/examples/ansi/demo.ts index 845c4160..9779c1fa 100755 --- a/examples/ansi/demo.ts +++ b/examples/ansi/demo.ts @@ -1,6 +1,6 @@ #!/usr/bin/env -S deno run -import * as stdColors from "https://deno.land/std@0.216.0/fmt/colors.ts"; +import * as stdColors from "@std/fmt/colors"; import * as ansiEscapes from "../../ansi/ansi_escapes.ts"; const ansiEscapeNames1: Array = [ diff --git a/examples/command.ts b/examples/command.ts index 5e515069..447e508e 100644 --- a/examples/command.ts +++ b/examples/command.ts @@ -1,7 +1,7 @@ #!/usr/bin/env -S deno run --allow-net=localhost:8080,deno.land import { Command } from "../command/mod.ts"; -import { serve } from "https://deno.land/std@0.216.0/http/server.ts"; +import { serve } from "@std/http/server"; await new Command() .name("reverse-proxy") diff --git a/examples/command/examples.ts b/examples/command/examples.ts index 67695123..eb3a113b 100755 --- a/examples/command/examples.ts +++ b/examples/command/examples.ts @@ -1,6 +1,6 @@ #!/usr/bin/env -S deno run -import { red } from "https://deno.land/std@0.216.0/fmt/colors.ts"; +import { red } from "@std/fmt/colors"; import { Command } from "../../command/command.ts"; await new Command() diff --git a/examples/prompt/custom_prompts.ts b/examples/prompt/custom_prompts.ts index 7e15462d..13bc1a17 100755 --- a/examples/prompt/custom_prompts.ts +++ b/examples/prompt/custom_prompts.ts @@ -1,6 +1,6 @@ #!/usr/bin/env -S deno run -import { BufReader } from "https://deno.land/std@0.216.0/io/buf_reader.ts"; +import { BufReader } from "@std/io/buf_reader"; import { tty } from "../../ansi/tty.ts"; import { Figures } from "../../prompt/_figures.ts"; import { prompt } from "../../prompt/prompt.ts"; diff --git a/examples/prompt/prompt_demo.ts b/examples/prompt/prompt_demo.ts index 34373e67..f748fae4 100755 --- a/examples/prompt/prompt_demo.ts +++ b/examples/prompt/prompt_demo.ts @@ -1,6 +1,6 @@ #!/usr/bin/env -S deno run -import { rgb24 } from "https://deno.land/std@0.216.0/fmt/colors.ts"; +import { rgb24 } from "@std/fmt/colors"; import { tty } from "../../ansi/tty.ts"; import { prompt } from "../../prompt/prompt.ts"; import { Checkbox } from "../../prompt/checkbox.ts"; diff --git a/examples/table/random_table_demo.ts b/examples/table/random_table_demo.ts index ae0824ed..39889902 100755 --- a/examples/table/random_table_demo.ts +++ b/examples/table/random_table_demo.ts @@ -11,7 +11,7 @@ import { strikethrough, underline, yellow, -} from "https://deno.land/std@0.216.0/fmt/colors.ts"; +} from "@std/fmt/colors"; import { tty } from "../../ansi/tty.ts"; import { Cell, CellType } from "../../table/cell.ts"; import { Table } from "../../table/table.ts"; diff --git a/prompt/deps.ts b/prompt/deps.ts index 2e2131a4..9de1707b 100644 --- a/prompt/deps.ts +++ b/prompt/deps.ts @@ -8,15 +8,15 @@ export { stripColor, underline, yellow, -} from "https://deno.land/std@0.216.0/fmt/colors.ts"; +} from "@std/fmt/colors"; export { dirname, join, normalize, -} from "https://deno.land/std@0.216.0/path/mod.ts"; +} from "@std/path/mod"; export type { Reader, ReaderSync, Writer, WriterSync, -} from "https://deno.land/std@0.216.0/io/types.ts"; +} from "@std/io/types"; diff --git a/prompt/test/prompt_list_test.ts b/prompt/test/prompt_list_test.ts index 21fe3830..c3c9dd2c 100644 --- a/prompt/test/prompt_list_test.ts +++ b/prompt/test/prompt_list_test.ts @@ -1,7 +1,7 @@ import { assert, IsExact, -} from "https://deno.land/x/conditional_type_checks@1.0.6/mod.ts"; +} from "conditional_type_checks"; import { assertEquals, assertRejects } from "../../dev_deps.ts"; import { inject, prompt } from "../prompt.ts"; import { Checkbox } from "../checkbox.ts"; diff --git a/table/deps.ts b/table/deps.ts index 7042b3b9..be3af584 100644 --- a/table/deps.ts +++ b/table/deps.ts @@ -1,2 +1,2 @@ -export { stripColor } from "https://deno.land/std@0.216.0/fmt/colors.ts"; -export { unicodeWidth } from "https://deno.land/std@0.216.0/console/unicode_width.ts"; +export { stripColor } from "@std/fmt/colors"; +export { unicodeWidth } from "@std/console/unicode_width"; diff --git a/testing/deps.ts b/testing/deps.ts index 261ee645..84d3000e 100644 --- a/testing/deps.ts +++ b/testing/deps.ts @@ -1,8 +1,8 @@ -export { AssertionError } from "https://deno.land/std@0.216.0/assert/assertion_error.ts"; -export { assertSnapshot } from "https://deno.land/std@0.216.0/testing/snapshot.ts"; -export { red } from "https://deno.land/std@0.216.0/fmt/colors.ts"; +export { AssertionError } from "@std/assert/assertion_error"; +export { assertSnapshot } from "@std/testing/snapshot"; +export { red } from "@std/fmt/colors"; export { basename, dirname, fromFileUrl, -} from "https://deno.land/std@0.216.0/path/mod.ts"; +} from "@std/path"; From 6daec80df80da5e5fdff2dfe5ca298063469c771 Mon Sep 17 00:00:00 2001 From: Julien Oculi Date: Thu, 29 Feb 2024 12:29:12 +0100 Subject: [PATCH 03/47] fix: :wrench: prefix exports with `./` --- deno.jsonc | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/deno.jsonc b/deno.jsonc index 3f22cc4b..553e5f8b 100644 --- a/deno.jsonc +++ b/deno.jsonc @@ -2,14 +2,14 @@ "name": "@c4spar/cliffy", "version": "1.0.0-rc.3", "exports": { - "ansi": "./ansi/mod.ts", - "command": "./command/mod.ts", - "flags": "./flags/mod.ts", - "keycode": "./keycode/mod.ts", - "keypress": "./keypress/mod.ts", - "prompt": "./prompt/mod.ts", - "table": "./table/mod.ts", - "testing": "./testing/mod.ts" + "./ansi": "./ansi/mod.ts", + "./command": "./command/mod.ts", + "./flags": "./flags/mod.ts", + "./keycode": "./keycode/mod.ts", + "./keypress": "./keypress/mod.ts", + "./prompt": "./prompt/mod.ts", + "./table": "./table/mod.ts", + "./testing": "./testing/mod.ts" }, "lock": false, "exclude": ["dist"], From d6af963b6c5010a57ecec4b8926e7f95f5d7b054 Mon Sep 17 00:00:00 2001 From: Julien Oculi Date: Thu, 29 Feb 2024 12:35:35 +0100 Subject: [PATCH 04/47] fix: :package: remove `/mod` from `@std/path` --- prompt/deps.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/prompt/deps.ts b/prompt/deps.ts index 9de1707b..208e7411 100644 --- a/prompt/deps.ts +++ b/prompt/deps.ts @@ -13,7 +13,7 @@ export { dirname, join, normalize, -} from "@std/path/mod"; +} from "@std/path"; export type { Reader, ReaderSync, From 564d1bf98838673c90fd51bccf3f414a49e0df38 Mon Sep 17 00:00:00 2001 From: Julien Oculi Date: Thu, 29 Feb 2024 12:51:21 +0100 Subject: [PATCH 05/47] refactor: :label: fix all slow types for jsr exports --- ansi/ansi_escapes.ts | 24 ++++++++++++------------ command/command.ts | 6 +++--- prompt/_generic_list.ts | 12 ++++++------ table/cell.ts | 2 +- 4 files changed, 22 insertions(+), 22 deletions(-) diff --git a/ansi/ansi_escapes.ts b/ansi/ansi_escapes.ts index 3bdf9e22..36f86725 100644 --- a/ansi/ansi_escapes.ts +++ b/ansi/ansi_escapes.ts @@ -3,7 +3,7 @@ import { encodeBase64 } from "./deps.ts"; /** Escape sequence: `\x1B` */ const ESC = "\x1B"; /** Control sequence intro: `\x1B[` */ -const CSI = `${ESC}[`; +const CSI: `\x1B[` = `${ESC}[`; /** Operating system command: `\x1B]` */ const OSC = `${ESC}]`; /** Link separator */ @@ -12,7 +12,7 @@ const SEP = ";"; /** Ring audio bell: `\u0007` */ export const bel = "\u0007"; /** Get cursor position. */ -export const cursorPosition = `${CSI}6n`; +export const cursorPosition: `\x1B[6n` = `${CSI}6n`; /** * Move cursor to x, y, counting from the top left corner. @@ -98,15 +98,15 @@ export function cursorPrevLine(count = 1): string { } /** Move cursor to first column of current row. */ -export const cursorLeft = `${CSI}G`; +export const cursorLeft: `\x1B[G` = `${CSI}G`; /** Hide cursor. */ -export const cursorHide = `${CSI}?25l`; +export const cursorHide: `\x1B[?25l` = `${CSI}?25l`; /** Show cursor. */ -export const cursorShow = `${CSI}?25h`; +export const cursorShow: `\x1B[?25h` = `${CSI}?25h`; /** Save cursor. */ -export const cursorSave = `${ESC}7`; +export const cursorSave: `\x1B7` = `${ESC}7`; /** Restore cursor. */ -export const cursorRestore = `${ESC}8`; +export const cursorRestore: `\x1B8` = `${ESC}8`; /** * Scroll window up by n lines. @@ -125,7 +125,7 @@ export function scrollDown(count = 1): string { } /** Clear screen. */ -export const eraseScreen = `${CSI}2J`; +export const eraseScreen: `\x1B[2J` = `${CSI}2J`; /** * Clear screen up by n lines. @@ -144,11 +144,11 @@ export function eraseDown(count = 1): string { } /** Clear current line. */ -export const eraseLine = `${CSI}2K`; +export const eraseLine: `\x1B[2K` = `${CSI}2K`; /** Clear to line end. */ -export const eraseLineEnd = `${CSI}0K`; +export const eraseLineEnd: `\x1B[0K` = `${CSI}0K`; /** Clear to line start. */ -export const eraseLineStart = `${CSI}1K`; +export const eraseLineStart: `\x1B[1K` = `${CSI}1K`; /** * Clear screen and move cursor by n lines up and move cursor to first column. @@ -170,7 +170,7 @@ export const clearScreen = "\u001Bc"; * Clear the whole terminal, including scrollback buffer. * (Not just the visible part of it). */ -export const clearTerminal = Deno.build.os === "windows" +export const clearTerminal: string = Deno.build.os === "windows" ? `${eraseScreen}${CSI}0f` // 1. Erases the screen (Only done in case `2` is not supported) // 2. Erases the whole screen including scrollback buffer diff --git a/command/command.ts b/command/command.ts index 01a667e0..72b7e8e1 100644 --- a/command/command.ts +++ b/command/command.ts @@ -2294,7 +2294,7 @@ export class Command< } /** Check if command has arguments. */ - public hasArguments() { + public hasArguments(): boolean { return !!this.argsDefinition; } @@ -2317,7 +2317,7 @@ export class Command< } /** Get auto generated command usage. */ - public getUsage() { + public getUsage(): string { return this._usage ?? [this.getArgsDefinition(), this.getRequiredOptionsDefinition()] .join(" ") @@ -2798,7 +2798,7 @@ export class Command< } /** Get completions. */ - public getCompletions() { + public getCompletions(): Completion[] { return this.getGlobalCompletions().concat(this.getBaseCompletions()); } diff --git a/prompt/_generic_list.ts b/prompt/_generic_list.ts index 5e1cf1fb..7240729c 100644 --- a/prompt/_generic_list.ts +++ b/prompt/_generic_list.ts @@ -177,7 +177,7 @@ export abstract class GenericList< protected abstract listOffset: number; protected parentOptions: Array = []; - protected get selectedOption() { + protected get selectedOption(): TOption | TGroup | undefined { return this.options.at(this.listIndex); } @@ -440,7 +440,7 @@ export abstract class GenericList< return line; } - protected getListItemIndent(option: TOption | TGroup) { + protected getListItemIndent(option: TOption | TGroup): string { const indentLevel = this.isSearching() ? option.indentLevel : this.hasParent() && !this.isBackButton(option) @@ -450,7 +450,7 @@ export abstract class GenericList< return this.settings.indent + " ".repeat(indentLevel); } - protected getListItemPointer(option: TOption | TGroup, isSelected?: boolean) { + protected getListItemPointer(option: TOption | TGroup, isSelected?: boolean): string { if (!isSelected) { return " "; } @@ -498,7 +498,7 @@ export abstract class GenericList< return label; } - protected getBreadCrumb() { + protected getBreadCrumb(): string { if (!this.parentOptions.length || !this.settings.maxBreadcrumbItems) { return ""; } @@ -518,7 +518,7 @@ export abstract class GenericList< ); } - protected getListIndex(value?: TValue) { + protected getListIndex(value?: TValue): number { return Math.max( 0, typeof value === "undefined" @@ -532,7 +532,7 @@ export abstract class GenericList< ); } - protected getPageOffset(index: number) { + protected getPageOffset(index: number): number { if (index === 0) { return 0; } diff --git a/table/cell.ts b/table/cell.ts index 9e4be43a..56ecf0bd 100644 --- a/table/cell.ts +++ b/table/cell.ts @@ -68,7 +68,7 @@ export class Cell { * Any unterminated ANSI formatting overflowed from previous lines of a * multi-line cell. */ - public get unclosedAnsiRuns() { + public get unclosedAnsiRuns(): string { return this.options.unclosedAnsiRuns ?? ""; } public set unclosedAnsiRuns(val: string) { From 3fe231a631ace3b7b32fde728690de29ddf18845 Mon Sep 17 00:00:00 2001 From: Julien Oculi Date: Thu, 29 Feb 2024 12:58:12 +0100 Subject: [PATCH 06/47] chore(upgrade): :arrow_up: deno/std@0.217 --- deno.jsonc | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/deno.jsonc b/deno.jsonc index 553e5f8b..cc02729c 100644 --- a/deno.jsonc +++ b/deno.jsonc @@ -32,17 +32,17 @@ // "update": "deno run --allow-read=./ --allow-write=./ https://deno.land/x/udd@0.8.2/main.ts" globs are a bit weird in tasks: https://github.com/denoland/deno/discussions/15625 }, "imports": { - "@std/assert": "jsr:@std/assert@0.216", - "@std/async": "jsr:@std/async@0.216", - "@std/console": "jsr:@std/console@0.216", - "@std/datetime": "jsr:@std/datetime@0.216", - "@std/encoding": "jsr:@std/encoding@0.216", - "@std/fmt": "jsr:@std/fmt@0.216", - "@std/fs": "jsr:@std/fs@0.216", - "@std/http": "jsr:@std/http@0.216", - "@std/io": "jsr:@std/io@0.216", - "@std/path": "jsr:@std/path@0.216", - "@std/testing": "jsr:@std/testing@0.216", + "@std/assert": "jsr:@std/assert@0.217", + "@std/async": "jsr:@std/async@0.217", + "@std/console": "jsr:@std/console@0.217", + "@std/datetime": "jsr:@std/datetime@0.217", + "@std/encoding": "jsr:@std/encoding@0.217", + "@std/fmt": "jsr:@std/fmt@0.217", + "@std/fs": "jsr:@std/fs@0.217", + "@std/http": "jsr:@std/http@0.217", + "@std/io": "jsr:@std/io@0.217", + "@std/path": "jsr:@std/path@0.217", + "@std/testing": "jsr:@std/testing@0.217", "conditional_type_checks": "npm:conditional-type-checks@1.0.6", "sinon": "npm:sinon@13.0.2" } From eb72f6bd87d8fa7cb7f582720ebae01eaabf7e3f Mon Sep 17 00:00:00 2001 From: Julien Oculi Date: Thu, 29 Feb 2024 13:14:19 +0100 Subject: [PATCH 07/47] ci: add jsr publish workflow --- .github/workflows/publish.yml | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 .github/workflows/publish.yml diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml new file mode 100644 index 00000000..c9d3c0ae --- /dev/null +++ b/.github/workflows/publish.yml @@ -0,0 +1,17 @@ +name: Publish + +on: + push: + branches: + - main + +jobs: + publish: + runs-on: ubuntu-latest + permissions: + contents: read + id-token: write + steps: + - uses: actions/checkout@v4 + - uses: denoland/setup-deno@v1 + - run: deno publish From 5cec10370b55fa036cecab6e10c4b94aa2f27e48 Mon Sep 17 00:00:00 2001 From: Julien Oculi Date: Fri, 8 Mar 2024 23:22:43 +0100 Subject: [PATCH 08/47] style: run deno fmt on deno.jsonc --- deno.jsonc | 64 +++++++++++++++++++++++++++--------------------------- 1 file changed, 32 insertions(+), 32 deletions(-) diff --git a/deno.jsonc b/deno.jsonc index cc02729c..a4461e54 100644 --- a/deno.jsonc +++ b/deno.jsonc @@ -1,36 +1,36 @@ { - "name": "@c4spar/cliffy", - "version": "1.0.0-rc.3", - "exports": { - "./ansi": "./ansi/mod.ts", - "./command": "./command/mod.ts", - "./flags": "./flags/mod.ts", - "./keycode": "./keycode/mod.ts", - "./keypress": "./keypress/mod.ts", - "./prompt": "./prompt/mod.ts", - "./table": "./table/mod.ts", - "./testing": "./testing/mod.ts" - }, - "lock": false, - "exclude": ["dist"], - "tasks": { - "lint": "deno lint && deno fmt --check", - "fmt": "deno fmt", - "test": "deno test --doc --allow-run=deno --allow-env --allow-read=./ --allow-write=./ --ignore=./CHANGELOG.md --parallel", - "check:examples": "deno check examples/**/*.ts", - "snapshot": "deno task test -- --update", - "coverage": "deno task test --coverage=./dist/coverage/all/result && deno coverage --lcov ./dist/coverage/all/result > ./dist/coverage/all/cov.lcov", - "coverage:ansi": "deno task test ansi --coverage=./dist/coverage/ansi/result && deno coverage --lcov ./dist/coverage/ansi/result > ./dist/coverage/ansi/cov.lcov", - "coverage:command": "deno task test command --coverage=./dist/coverage/command/result && deno coverage --lcov ./dist/coverage/command/result > ./dist/coverage/command/cov.lcov", - "coverage:flags": "deno task test flags --coverage=./dist/coverage/flags/result && deno coverage --lcov ./dist/coverage/flags/result > ./dist/coverage/flags/cov.lcov", - "coverage:keycode": "deno task test keycode --coverage=./dist/coverage/keycode/result && deno coverage --lcov ./dist/coverage/keycode/result > ./dist/coverage/keycode/cov.lcov", - "coverage:keypress": "deno task test keypress --coverage=./dist/coverage/keypress/result && deno coverage --lcov ./dist/coverage/keypress/result > ./dist/coverage/keypress/cov.lcov", - "coverage:prompt": "deno task test prompt --coverage=./dist/coverage/prompt/result && deno coverage --lcov ./dist/coverage/prompt/result > ./dist/coverage/prompt/cov.lcov", - "coverage:table": "deno task test table --coverage=./dist/coverage/table/result && deno coverage --lcov ./dist/coverage/table/result > ./dist/coverage/table/cov.lcov", - "coverage:testing": "deno task test testing --coverage=./dist/coverage/testing/result && deno coverage --lcov ./dist/coverage/testing/result > ./dist/coverage/testing/cov.lcov", - "update": "deno run --allow-read=./ --allow-net --allow-write=./ https://deno.land/x/deno_outdated@0.2.5/cli.ts --ignore README.md CHANGELOG.md CONTRIBUTING.md" - // "update": "deno run --allow-read=./ --allow-write=./ https://deno.land/x/udd@0.8.2/main.ts" globs are a bit weird in tasks: https://github.com/denoland/deno/discussions/15625 - }, + "name": "@c4spar/cliffy", + "version": "1.0.0-rc.3", + "exports": { + "./ansi": "./ansi/mod.ts", + "./command": "./command/mod.ts", + "./flags": "./flags/mod.ts", + "./keycode": "./keycode/mod.ts", + "./keypress": "./keypress/mod.ts", + "./prompt": "./prompt/mod.ts", + "./table": "./table/mod.ts", + "./testing": "./testing/mod.ts" + }, + "lock": false, + "exclude": ["dist"], + "tasks": { + "lint": "deno lint && deno fmt --check", + "fmt": "deno fmt", + "test": "deno test --doc --allow-run=deno --allow-env --allow-read=./ --allow-write=./ --ignore=./CHANGELOG.md --parallel", + "check:examples": "deno check examples/**/*.ts", + "snapshot": "deno task test -- --update", + "coverage": "deno task test --coverage=./dist/coverage/all/result && deno coverage --lcov ./dist/coverage/all/result > ./dist/coverage/all/cov.lcov", + "coverage:ansi": "deno task test ansi --coverage=./dist/coverage/ansi/result && deno coverage --lcov ./dist/coverage/ansi/result > ./dist/coverage/ansi/cov.lcov", + "coverage:command": "deno task test command --coverage=./dist/coverage/command/result && deno coverage --lcov ./dist/coverage/command/result > ./dist/coverage/command/cov.lcov", + "coverage:flags": "deno task test flags --coverage=./dist/coverage/flags/result && deno coverage --lcov ./dist/coverage/flags/result > ./dist/coverage/flags/cov.lcov", + "coverage:keycode": "deno task test keycode --coverage=./dist/coverage/keycode/result && deno coverage --lcov ./dist/coverage/keycode/result > ./dist/coverage/keycode/cov.lcov", + "coverage:keypress": "deno task test keypress --coverage=./dist/coverage/keypress/result && deno coverage --lcov ./dist/coverage/keypress/result > ./dist/coverage/keypress/cov.lcov", + "coverage:prompt": "deno task test prompt --coverage=./dist/coverage/prompt/result && deno coverage --lcov ./dist/coverage/prompt/result > ./dist/coverage/prompt/cov.lcov", + "coverage:table": "deno task test table --coverage=./dist/coverage/table/result && deno coverage --lcov ./dist/coverage/table/result > ./dist/coverage/table/cov.lcov", + "coverage:testing": "deno task test testing --coverage=./dist/coverage/testing/result && deno coverage --lcov ./dist/coverage/testing/result > ./dist/coverage/testing/cov.lcov", + "update": "deno run --allow-read=./ --allow-net --allow-write=./ https://deno.land/x/deno_outdated@0.2.5/cli.ts --ignore README.md CHANGELOG.md CONTRIBUTING.md" + // "update": "deno run --allow-read=./ --allow-write=./ https://deno.land/x/udd@0.8.2/main.ts" globs are a bit weird in tasks: https://github.com/denoland/deno/discussions/15625 + }, "imports": { "@std/assert": "jsr:@std/assert@0.217", "@std/async": "jsr:@std/async@0.217", From ac01ba400e2f64a7b336b3836138decb2260b9ac Mon Sep 17 00:00:00 2001 From: Julien Oculi Date: Fri, 8 Mar 2024 23:39:04 +0100 Subject: [PATCH 09/47] refactor: :truck: rename cliffy scope --- deno.jsonc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/deno.jsonc b/deno.jsonc index a4461e54..aaf37472 100644 --- a/deno.jsonc +++ b/deno.jsonc @@ -1,5 +1,5 @@ { - "name": "@c4spar/cliffy", + "name": "@cliffy/cliffy", "version": "1.0.0-rc.3", "exports": { "./ansi": "./ansi/mod.ts", From cc44644a3604d0681c10fdfe8967752cbc31b398 Mon Sep 17 00:00:00 2001 From: Julien Oculi Date: Fri, 8 Mar 2024 23:44:33 +0100 Subject: [PATCH 10/47] refactor: :recycle: split cliffy in submodules with deno workspaces --- ansi/deno.json | 6 ++++++ command/deno.json | 11 +++++++++++ deno.jsonc | 21 +++++++++++---------- examples/deno.json | 5 +++++ flags/deno.json | 6 ++++++ keycode/deno.json | 6 ++++++ keypress/deno.json | 6 ++++++ prompt/deno.json | 17 +++++++++++++++++ table/deno.json | 6 ++++++ testing/deno.json | 6 ++++++ 10 files changed, 80 insertions(+), 10 deletions(-) create mode 100644 ansi/deno.json create mode 100644 command/deno.json create mode 100644 examples/deno.json create mode 100644 flags/deno.json create mode 100644 keycode/deno.json create mode 100644 keypress/deno.json create mode 100644 prompt/deno.json create mode 100644 table/deno.json create mode 100644 testing/deno.json diff --git a/ansi/deno.json b/ansi/deno.json new file mode 100644 index 00000000..e5570f0c --- /dev/null +++ b/ansi/deno.json @@ -0,0 +1,6 @@ +{ + "name": "@cliffy/ansi", + "version": "1.0.0-rc.3", + "exports": "./mod.ts", + "lock": false +} diff --git a/command/deno.json b/command/deno.json new file mode 100644 index 00000000..ba401458 --- /dev/null +++ b/command/deno.json @@ -0,0 +1,11 @@ +{ + "name": "@cliffy/command", + "version": "1.0.0-rc.3", + "exports": { + ".": "./mod.ts", + "./completions": "./completions/mod.ts", + "./help": "./help/mod.ts", + "./upgrade": "./upgrade/mod.ts" + }, + "lock": false +} diff --git a/deno.jsonc b/deno.jsonc index aaf37472..66f25eba 100644 --- a/deno.jsonc +++ b/deno.jsonc @@ -1,16 +1,17 @@ { "name": "@cliffy/cliffy", "version": "1.0.0-rc.3", - "exports": { - "./ansi": "./ansi/mod.ts", - "./command": "./command/mod.ts", - "./flags": "./flags/mod.ts", - "./keycode": "./keycode/mod.ts", - "./keypress": "./keypress/mod.ts", - "./prompt": "./prompt/mod.ts", - "./table": "./table/mod.ts", - "./testing": "./testing/mod.ts" - }, + "workspaces": [ + "ansi", + "command", + "examples", + "flags", + "keycode", + "keypress", + "prompt", + "table", + "testing" + ], "lock": false, "exclude": ["dist"], "tasks": { diff --git a/examples/deno.json b/examples/deno.json new file mode 100644 index 00000000..16baedc6 --- /dev/null +++ b/examples/deno.json @@ -0,0 +1,5 @@ +{ + "name": "@cliffy/examples", + "version": "1.0.0-rc.3", + "lock": false +} diff --git a/flags/deno.json b/flags/deno.json new file mode 100644 index 00000000..79491c49 --- /dev/null +++ b/flags/deno.json @@ -0,0 +1,6 @@ +{ + "name": "@cliffy/flags", + "version": "1.0.0-rc.3", + "exports": "./mod.ts", + "lock": false +} diff --git a/keycode/deno.json b/keycode/deno.json new file mode 100644 index 00000000..035e8545 --- /dev/null +++ b/keycode/deno.json @@ -0,0 +1,6 @@ +{ + "name": "@cliffy/keycode", + "version": "1.0.0-rc.3", + "exports": "./mod.ts", + "lock": false +} diff --git a/keypress/deno.json b/keypress/deno.json new file mode 100644 index 00000000..9838e558 --- /dev/null +++ b/keypress/deno.json @@ -0,0 +1,6 @@ +{ + "name": "@cliffy/keypress", + "version": "1.0.0-rc.3", + "exports": "./mod.ts", + "lock": false +} diff --git a/prompt/deno.json b/prompt/deno.json new file mode 100644 index 00000000..43f69847 --- /dev/null +++ b/prompt/deno.json @@ -0,0 +1,17 @@ +{ + "name": "@cliffy/prompt", + "version": "1.0.0-rc.3", + "exports": { + ".": "./mod.ts", + "./checkbox": "./checkbox.ts", + "./confirm": "./confirm.ts", + "./input": "./input.ts", + "./list": "./list.ts", + "./number": "./number.ts", + "./prompt": "./prompt.ts", + "./secret": "./secret.ts", + "./select": "./select.ts", + "./toggle": "./toggle.ts" + }, + "lock": false +} diff --git a/table/deno.json b/table/deno.json new file mode 100644 index 00000000..8a9b96d5 --- /dev/null +++ b/table/deno.json @@ -0,0 +1,6 @@ +{ + "name": "@cliffy/table", + "version": "1.0.0-rc.3", + "exports": "./mod.ts", + "lock": false +} diff --git a/testing/deno.json b/testing/deno.json new file mode 100644 index 00000000..e0e5dac8 --- /dev/null +++ b/testing/deno.json @@ -0,0 +1,6 @@ +{ + "name": "@cliffy/testing", + "version": "1.0.0-rc.3", + "exports": "./mod.ts", + "lock": false +} From b7c5a7d82b537cfaab54093942a9c47ccca7ebf5 Mon Sep 17 00:00:00 2001 From: Julien Oculi Date: Fri, 8 Mar 2024 23:49:27 +0100 Subject: [PATCH 11/47] refactor: :label: simplify literals types to string --- ansi/ansi_escapes.ts | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/ansi/ansi_escapes.ts b/ansi/ansi_escapes.ts index 36f86725..af65b056 100644 --- a/ansi/ansi_escapes.ts +++ b/ansi/ansi_escapes.ts @@ -3,7 +3,7 @@ import { encodeBase64 } from "./deps.ts"; /** Escape sequence: `\x1B` */ const ESC = "\x1B"; /** Control sequence intro: `\x1B[` */ -const CSI: `\x1B[` = `${ESC}[`; +const CSI: string = `${ESC}[`; /** Operating system command: `\x1B]` */ const OSC = `${ESC}]`; /** Link separator */ @@ -12,7 +12,7 @@ const SEP = ";"; /** Ring audio bell: `\u0007` */ export const bel = "\u0007"; /** Get cursor position. */ -export const cursorPosition: `\x1B[6n` = `${CSI}6n`; +export const cursorPosition: string = `${CSI}6n`; /** * Move cursor to x, y, counting from the top left corner. @@ -98,15 +98,15 @@ export function cursorPrevLine(count = 1): string { } /** Move cursor to first column of current row. */ -export const cursorLeft: `\x1B[G` = `${CSI}G`; +export const cursorLeft: string = `${CSI}G`; /** Hide cursor. */ -export const cursorHide: `\x1B[?25l` = `${CSI}?25l`; +export const cursorHide: string = `${CSI}?25l`; /** Show cursor. */ -export const cursorShow: `\x1B[?25h` = `${CSI}?25h`; +export const cursorShow: string = `${CSI}?25h`; /** Save cursor. */ -export const cursorSave: `\x1B7` = `${ESC}7`; +export const cursorSave: string = `${ESC}7`; /** Restore cursor. */ -export const cursorRestore: `\x1B8` = `${ESC}8`; +export const cursorRestore: string = `${ESC}8`; /** * Scroll window up by n lines. @@ -125,7 +125,7 @@ export function scrollDown(count = 1): string { } /** Clear screen. */ -export const eraseScreen: `\x1B[2J` = `${CSI}2J`; +export const eraseScreen: string = `${CSI}2J`; /** * Clear screen up by n lines. @@ -144,11 +144,11 @@ export function eraseDown(count = 1): string { } /** Clear current line. */ -export const eraseLine: `\x1B[2K` = `${CSI}2K`; +export const eraseLine: string = `${CSI}2K`; /** Clear to line end. */ -export const eraseLineEnd: `\x1B[0K` = `${CSI}0K`; +export const eraseLineEnd: string = `${CSI}0K`; /** Clear to line start. */ -export const eraseLineStart: `\x1B[1K` = `${CSI}1K`; +export const eraseLineStart: string = `${CSI}1K`; /** * Clear screen and move cursor by n lines up and move cursor to first column. From aebf585a8be8296cc62170cb469074a7a1c63c11 Mon Sep 17 00:00:00 2001 From: Julien Oculi Date: Sat, 9 Mar 2024 00:43:41 +0100 Subject: [PATCH 12/47] refactor: :recycle: replace `deps`/`dev_deps` by direct imports --- ansi/ansi_escapes.ts | 2 +- ansi/ansi_escapes_test.ts | 2 +- ansi/ansi_test.ts | 2 +- ansi/colors_test.ts | 4 +-- ansi/cursor_position.ts | 2 +- ansi/deps.ts | 5 --- ansi/tty.ts | 2 +- ansi/tty_test.ts | 2 +- command/_errors.ts | 2 +- command/command.ts | 2 +- command/completions/bash.ts | 2 +- command/completions/completions_command.ts | 2 +- command/completions/fish.ts | 2 +- command/completions/zsh.ts | 2 +- command/deps.ts | 13 -------- command/test/command/action_test.ts | 8 +++-- command/test/command/alias_test.ts | 2 +- command/test/command/allow_empty_test.ts | 2 +- command/test/command/arguments_test.ts | 4 ++- command/test/command/command_test.ts | 2 +- command/test/command/completion_test.ts | 2 +- command/test/command/default_command_test.ts | 2 +- command/test/command/dotted_options_test.ts | 2 +- command/test/command/env_var_test.ts | 2 +- command/test/command/error_handler_test.ts | 4 ++- command/test/command/example_test.ts | 2 +- command/test/command/global_command_test.ts | 2 +- command/test/command/help_command_test.ts | 2 +- command/test/command/help_test.ts | 2 +- command/test/command/hidden_command_test.ts | 3 +- .../test/command/literal_arguments_test.ts | 2 +- command/test/command/option_test.ts | 3 +- command/test/command/raw_args_test.ts | 2 +- command/test/command/standalone_test.ts | 4 ++- command/test/command/stop_early_test.ts | 2 +- command/test/command/sub_command_test.ts | 2 +- command/test/command/throw_test.ts | 2 +- command/test/command/version_test.ts | 2 +- command/test/integration/utils.ts | 2 +- command/test/option/action_test.ts | 6 ++-- command/test/option/aliases_test.ts | 2 +- command/test/option/conflicts_test.ts | 2 +- command/test/option/default_test.ts | 2 +- command/test/option/depends_test.ts | 2 +- command/test/option/duplicate_test.ts | 2 +- command/test/option/global_test.ts | 2 +- command/test/option/hidden_test.ts | 3 +- command/test/option/list_test.ts | 2 +- command/test/option/negatable_test.ts | 2 +- command/test/option/required_test.ts | 2 +- command/test/option/requires_test.ts | 2 +- command/test/option/standalone_test.ts | 2 +- command/test/option/value_test.ts | 2 +- command/test/option/variadic_test.ts | 2 +- command/test/option/wildcard_test.ts | 2 +- command/test/type/boolean_test.ts | 2 +- command/test/type/custom_test.ts | 2 +- command/test/type/enum_test.ts | 2 +- command/test/type/file_test.ts | 2 +- command/test/type/integer_test.ts | 2 +- command/test/type/no_value_test.ts | 2 +- command/test/type/number_test.ts | 2 +- command/test/type/string_test.ts | 2 +- command/upgrade/_check_version.ts | 2 +- command/upgrade/provider.ts | 2 +- command/upgrade/provider/github.ts | 2 +- dev_deps.ts | 33 ------------------- flags/test/flags/dotted_options_test.ts | 2 +- flags/test/option/aliases_test.ts | 2 +- flags/test/option/collect_test.ts | 2 +- flags/test/option/conflicts_test.ts | 2 +- flags/test/option/default_test.ts | 2 +- flags/test/option/depends_test.ts | 2 +- flags/test/option/equls_sign_test.ts | 2 +- flags/test/option/negatable_test.ts | 2 +- flags/test/option/required_test.ts | 2 +- flags/test/option/requires_test.ts | 2 +- flags/test/option/standalone_test.ts | 2 +- flags/test/option/unknown_test.ts | 2 +- flags/test/option/value_test.ts | 2 +- flags/test/option/variadic_test.ts | 2 +- flags/test/setting/allow_empty_test.ts | 2 +- flags/test/setting/option_test.ts | 2 +- flags/test/setting/stop_early_test.ts | 2 +- flags/test/setting/stop_on_unknown_test.ts | 2 +- flags/test/type/boolean_test.ts | 2 +- flags/test/type/integer_test.ts | 2 +- flags/test/type/no_value_test.ts | 2 +- flags/test/type/number_test.ts | 2 +- flags/test/type/string_test.ts | 2 +- keycode/test/key_code_test.ts | 2 +- keypress/test.ts | 2 +- prompt/_generic_input.ts | 2 +- prompt/_generic_list.ts | 2 +- prompt/_generic_prompt.ts | 7 ++-- prompt/_generic_suggestions.ts | 8 +++-- prompt/checkbox.ts | 2 +- prompt/confirm.ts | 2 +- prompt/deps.ts | 22 ------------- prompt/input.ts | 2 +- prompt/list.ts | 3 +- prompt/secret.ts | 2 +- prompt/select.ts | 2 +- prompt/test/checkbox_test.ts | 3 +- prompt/test/confirm_test.ts | 3 +- prompt/test/input_test.ts | 3 +- prompt/test/integration/prompt_test.ts | 3 +- prompt/test/integration/select_test.ts | 2 +- prompt/test/list_test.ts | 3 +- prompt/test/number_test.ts | 3 +- prompt/test/prompt_list_test.ts | 2 +- prompt/test/secret_test.ts | 3 +- prompt/test/select_test.ts | 3 +- prompt/test/toggle_test.ts | 3 +- prompt/toggle.ts | 2 +- table/_utils.ts | 3 +- table/deps.ts | 2 -- table/test/align_test.ts | 2 +- table/test/ansi_regex_source_test.ts | 2 +- table/test/ansi_wrapping_within_cell_test.ts | 2 +- table/test/border_test.ts | 2 +- table/test/column_test.ts | 3 +- table/test/span_test.ts | 2 +- table/test/special_chars.ts | 2 +- table/test/table_test.ts | 2 +- table/test/utils_test.ts | 2 +- testing/deps.ts | 8 ----- testing/snapshot.ts | 5 ++- testing/snapshot_test.ts | 5 +-- 129 files changed, 163 insertions(+), 216 deletions(-) delete mode 100644 ansi/deps.ts delete mode 100644 command/deps.ts delete mode 100644 dev_deps.ts delete mode 100644 prompt/deps.ts delete mode 100644 table/deps.ts delete mode 100644 testing/deps.ts diff --git a/ansi/ansi_escapes.ts b/ansi/ansi_escapes.ts index af65b056..73282d65 100644 --- a/ansi/ansi_escapes.ts +++ b/ansi/ansi_escapes.ts @@ -1,4 +1,4 @@ -import { encodeBase64 } from "./deps.ts"; +import { encodeBase64 } from "@std/encoding/base64"; /** Escape sequence: `\x1B` */ const ESC = "\x1B"; diff --git a/ansi/ansi_escapes_test.ts b/ansi/ansi_escapes_test.ts index 2d92ea51..1dbe7cac 100644 --- a/ansi/ansi_escapes_test.ts +++ b/ansi/ansi_escapes_test.ts @@ -14,7 +14,7 @@ import { scrollDown, scrollUp, } from "./ansi_escapes.ts"; -import { assertEquals } from "../dev_deps.ts"; +import { assertEquals } from "@std/assert"; Deno.test({ name: "ansi - ansi escapes - cursorTo x", diff --git a/ansi/ansi_test.ts b/ansi/ansi_test.ts index 1fad18ee..9b059137 100644 --- a/ansi/ansi_test.ts +++ b/ansi/ansi_test.ts @@ -1,4 +1,4 @@ -import { assertEquals } from "../dev_deps.ts"; +import { assertEquals } from "@std/assert"; import { ansi } from "./ansi.ts"; Deno.test({ diff --git a/ansi/colors_test.ts b/ansi/colors_test.ts index 4b42bb37..338d608c 100644 --- a/ansi/colors_test.ts +++ b/ansi/colors_test.ts @@ -1,5 +1,5 @@ -import { assertEquals, bold, red } from "../dev_deps.ts"; -import { underline } from "../prompt/deps.ts"; +import { assertEquals } from "@std/assert"; +import { underline, bold, red } from "@std/fmt/colors"; import { colors } from "./colors.ts"; Deno.test({ diff --git a/ansi/cursor_position.ts b/ansi/cursor_position.ts index 741adcc5..96be65dd 100644 --- a/ansi/cursor_position.ts +++ b/ansi/cursor_position.ts @@ -1,5 +1,5 @@ import { cursorPosition } from "./ansi_escapes.ts"; -import type { ReaderSync, WriterSync } from "./deps.ts"; +import type { ReaderSync, WriterSync } from "@std/io/types"; /** Cursor position. */ export interface Cursor { diff --git a/ansi/deps.ts b/ansi/deps.ts deleted file mode 100644 index 1af5ec75..00000000 --- a/ansi/deps.ts +++ /dev/null @@ -1,5 +0,0 @@ -export { encodeBase64 } from "@std/encoding/base64"; -export type { - ReaderSync, - WriterSync, -} from "@std/io/types"; diff --git a/ansi/tty.ts b/ansi/tty.ts index 923ebd18..c19e0b8c 100644 --- a/ansi/tty.ts +++ b/ansi/tty.ts @@ -1,7 +1,7 @@ import * as ansiEscapes from "./ansi_escapes.ts"; import type { Chain } from "./chain.ts"; import { Cursor, getCursorPosition } from "./cursor_position.ts"; -import type { ReaderSync, WriterSync } from "./deps.ts"; +import { ReaderSync, WriterSync } from "@std/io/types"; /** Create new `Ansi` instance. */ export interface TtyOptions { diff --git a/ansi/tty_test.ts b/ansi/tty_test.ts index 98bc6346..1e1fedad 100644 --- a/ansi/tty_test.ts +++ b/ansi/tty_test.ts @@ -1,4 +1,4 @@ -import { assertEquals } from "../dev_deps.ts"; +import { assertEquals } from "@std/assert"; import { tty } from "./tty.ts"; Deno.test({ diff --git a/command/_errors.ts b/command/_errors.ts index f1d486a3..8ea7a947 100644 --- a/command/_errors.ts +++ b/command/_errors.ts @@ -1,7 +1,7 @@ import { didYouMeanCommand } from "./_utils.ts"; import type { Command } from "./command.ts"; import { getFlag } from "../flags/_utils.ts"; -import { bold } from "./deps.ts"; +import { bold } from "@std/fmt/colors"; import { EnvVar } from "./types.ts"; export class CommandError extends Error { diff --git a/command/command.ts b/command/command.ts index 72b7e8e1..8d027f4d 100644 --- a/command/command.ts +++ b/command/command.ts @@ -11,7 +11,7 @@ import { parseArgumentsDefinition, splitArguments, } from "./_utils.ts"; -import { bold, brightBlue, red } from "./deps.ts"; +import { bold, brightBlue, red } from "@std/fmt/colors"; import { CommandExecutableNotFoundError, CommandNotFoundError, diff --git a/command/completions/bash.ts b/command/completions/bash.ts index 9169423d..d2c83131 100644 --- a/command/completions/bash.ts +++ b/command/completions/bash.ts @@ -1,5 +1,5 @@ import { Command } from "../command.ts"; -import { dim, italic } from "../deps.ts"; +import { dim, italic } from "@std/fmt/colors"; import { BashCompletionsGenerator } from "./_bash_completions_generator.ts"; /** Generates bash completions script. */ diff --git a/command/completions/completions_command.ts b/command/completions/completions_command.ts index 3020adbc..d21fa863 100644 --- a/command/completions/completions_command.ts +++ b/command/completions/completions_command.ts @@ -1,4 +1,4 @@ -import { dim, italic } from "../deps.ts"; +import { dim, italic } from "@std/fmt/colors"; import { Command } from "../command.ts"; import { BashCompletionsCommand } from "./bash.ts"; import { CompleteCommand } from "./complete.ts"; diff --git a/command/completions/fish.ts b/command/completions/fish.ts index 417808d9..29d5b38e 100644 --- a/command/completions/fish.ts +++ b/command/completions/fish.ts @@ -1,5 +1,5 @@ import { Command } from "../command.ts"; -import { dim, italic } from "../deps.ts"; +import { dim, italic } from "@std/fmt/colors"; import { FishCompletionsGenerator } from "./_fish_completions_generator.ts"; /** Generates fish completions script. */ diff --git a/command/completions/zsh.ts b/command/completions/zsh.ts index 4eb60aa8..dabcddac 100644 --- a/command/completions/zsh.ts +++ b/command/completions/zsh.ts @@ -1,5 +1,5 @@ import { Command } from "../command.ts"; -import { dim, italic } from "../deps.ts"; +import { dim, italic } from "@std/fmt/colors"; import { ZshCompletionsGenerator } from "./_zsh_completions_generator.ts"; /** Generates zsh completions script. */ diff --git a/command/deps.ts b/command/deps.ts deleted file mode 100644 index e83b3a44..00000000 --- a/command/deps.ts +++ /dev/null @@ -1,13 +0,0 @@ -export { - bold, - brightBlue, - brightMagenta, - cyan, - dim, - getColorEnabled, - green, - italic, - red, - setColorEnabled, - yellow, -} from "@std/fmt/colors"; diff --git a/command/test/command/action_test.ts b/command/test/command/action_test.ts index 1c85aa81..e2a9851f 100644 --- a/command/test/command/action_test.ts +++ b/command/test/command/action_test.ts @@ -1,11 +1,13 @@ +import { assertEquals } from "@std/assert"; import { - assertEquals, assertSpyCall, assertSpyCalls, + spy, +} from "@std/testing/mock"; +import { assertType, IsExact, - spy, -} from "../../../dev_deps.ts"; +} from "@std/testing/types"; import { Command } from "../../command.ts"; interface IStats { diff --git a/command/test/command/alias_test.ts b/command/test/command/alias_test.ts index 334b105d..5caf0a24 100644 --- a/command/test/command/alias_test.ts +++ b/command/test/command/alias_test.ts @@ -1,4 +1,4 @@ -import { assertEquals, assertRejects } from "../../../dev_deps.ts"; +import { assertEquals, assertRejects } from "@std/assert"; import { Command } from "../../command.ts"; Deno.test("command - alias - command with alias 1", async () => { diff --git a/command/test/command/allow_empty_test.ts b/command/test/command/allow_empty_test.ts index 08b8da63..75adf04c 100644 --- a/command/test/command/allow_empty_test.ts +++ b/command/test/command/allow_empty_test.ts @@ -1,4 +1,4 @@ -import { assertEquals, assertRejects } from "../../../dev_deps.ts"; +import { assertEquals, assertRejects } from "@std/assert"; import { Command } from "../../command.ts"; function cmd() { diff --git a/command/test/command/arguments_test.ts b/command/test/command/arguments_test.ts index 46820b49..540de37b 100644 --- a/command/test/command/arguments_test.ts +++ b/command/test/command/arguments_test.ts @@ -1,9 +1,11 @@ import { assertEquals, assertRejects, +} from "@std/assert"; +import { describe, it, -} from "../../../dev_deps.ts"; +} from "@std/testing/bdd"; import type { ArgumentValue } from "../../../flags/types.ts"; import { ValidationError } from "../../_errors.ts"; import { Command } from "../../command.ts"; diff --git a/command/test/command/command_test.ts b/command/test/command/command_test.ts index 14a92c89..6e209fd6 100644 --- a/command/test/command/command_test.ts +++ b/command/test/command/command_test.ts @@ -1,6 +1,6 @@ // deno-fmt-ignore-file -import { assertEquals } from "../../../dev_deps.ts"; +import { assertEquals } from "@std/assert"; import { Command } from "../../command.ts"; function command() { diff --git a/command/test/command/completion_test.ts b/command/test/command/completion_test.ts index e6dff863..85bb821f 100644 --- a/command/test/command/completion_test.ts +++ b/command/test/command/completion_test.ts @@ -1,6 +1,6 @@ // deno-fmt-ignore-file -import { assertEquals } from "../../../dev_deps.ts"; +import { assertEquals } from "@std/assert"; import { Command } from "../../command.ts"; import type { Completion } from "../../types.ts"; diff --git a/command/test/command/default_command_test.ts b/command/test/command/default_command_test.ts index 0e82ddc3..5a30ab9d 100644 --- a/command/test/command/default_command_test.ts +++ b/command/test/command/default_command_test.ts @@ -1,4 +1,4 @@ -import { assertEquals } from "../../../dev_deps.ts"; +import { assertEquals } from "@std/assert"; import { Command } from "../../command.ts"; Deno.test("command - raw args - command with usRawArgs disabled", async () => { diff --git a/command/test/command/dotted_options_test.ts b/command/test/command/dotted_options_test.ts index 4d4c4589..c9987d2a 100644 --- a/command/test/command/dotted_options_test.ts +++ b/command/test/command/dotted_options_test.ts @@ -1,4 +1,4 @@ -import { assertEquals, assertRejects } from "../../../dev_deps.ts"; +import { assertEquals, assertRejects } from "@std/assert"; import { Command } from "../../command.ts"; function cmd() { diff --git a/command/test/command/env_var_test.ts b/command/test/command/env_var_test.ts index fc2c1abf..45af2ce5 100644 --- a/command/test/command/env_var_test.ts +++ b/command/test/command/env_var_test.ts @@ -1,6 +1,6 @@ // deno-fmt-ignore-file -import { assertEquals, assertRejects } from "../../../dev_deps.ts"; +import { assertEquals, assertRejects } from "@std/assert"; import { Command } from "../../command.ts"; import type { EnvVar } from "../../types.ts"; diff --git a/command/test/command/error_handler_test.ts b/command/test/command/error_handler_test.ts index 3e4b277e..d48e9cce 100644 --- a/command/test/command/error_handler_test.ts +++ b/command/test/command/error_handler_test.ts @@ -2,9 +2,11 @@ import { assertEquals, assertInstanceOf, assertRejects, +} from "@std/assert"; +import { assertSpyCalls, spy, -} from "../../../dev_deps.ts"; +} from "@std/testing/mock"; import { Command, ErrorHandler, ValidationError } from "../../mod.ts"; Deno.test("[command] should call error handler on error", async () => { diff --git a/command/test/command/example_test.ts b/command/test/command/example_test.ts index e29957c6..a36fdc9f 100644 --- a/command/test/command/example_test.ts +++ b/command/test/command/example_test.ts @@ -1,6 +1,6 @@ // deno-fmt-ignore-file -import { assertEquals } from "../../../dev_deps.ts"; +import { assertEquals } from "@std/assert"; import { Command } from "../../command.ts"; import type { Example } from "../../types.ts"; diff --git a/command/test/command/global_command_test.ts b/command/test/command/global_command_test.ts index 81c9c373..a7d18804 100644 --- a/command/test/command/global_command_test.ts +++ b/command/test/command/global_command_test.ts @@ -1,4 +1,4 @@ -import { assertEquals, assertRejects } from "../../../dev_deps.ts"; +import { assertEquals, assertRejects } from "@std/assert"; import { Command } from "../../command.ts"; import { ValidationError } from "../../_errors.ts"; import { HelpCommand } from "../../help/help_command.ts"; diff --git a/command/test/command/help_command_test.ts b/command/test/command/help_command_test.ts index 7fb13384..375f60c7 100644 --- a/command/test/command/help_command_test.ts +++ b/command/test/command/help_command_test.ts @@ -1,4 +1,4 @@ -import { assertEquals } from "../../../dev_deps.ts"; +import { assertEquals } from "@std/assert"; import { CompletionsCommand } from "../../completions/completions_command.ts"; import { HelpCommand } from "../../help/help_command.ts"; import { Command } from "../../command.ts"; diff --git a/command/test/command/help_test.ts b/command/test/command/help_test.ts index 84b78262..55c583c2 100644 --- a/command/test/command/help_test.ts +++ b/command/test/command/help_test.ts @@ -1,4 +1,4 @@ -import { assertEquals } from "../../../dev_deps.ts"; +import { assertEquals } from "@std/assert"; import { Command } from "../../command.ts"; Deno.test("[command] help - help string", () => { diff --git a/command/test/command/hidden_command_test.ts b/command/test/command/hidden_command_test.ts index a395714b..3432a78c 100644 --- a/command/test/command/hidden_command_test.ts +++ b/command/test/command/hidden_command_test.ts @@ -1,4 +1,5 @@ -import { assertEquals, stripColor } from "../../../dev_deps.ts"; +import { assertEquals } from "@std/assert"; +import { stripColor } from "@std/fmt/colors"; import { CompletionsCommand } from "../../completions/completions_command.ts"; import { HelpCommand } from "../../help/help_command.ts"; import { Command } from "../../command.ts"; diff --git a/command/test/command/literal_arguments_test.ts b/command/test/command/literal_arguments_test.ts index 64db8c71..554b1f2e 100644 --- a/command/test/command/literal_arguments_test.ts +++ b/command/test/command/literal_arguments_test.ts @@ -1,4 +1,4 @@ -import { assertEquals } from "../../../dev_deps.ts"; +import { assertEquals } from "@std/assert"; import { Command } from "../../command.ts"; Deno.test("command literal arguments", async () => { diff --git a/command/test/command/option_test.ts b/command/test/command/option_test.ts index 012c71f8..400f756f 100644 --- a/command/test/command/option_test.ts +++ b/command/test/command/option_test.ts @@ -1,6 +1,7 @@ // deno-fmt-ignore-file -import { assertEquals, assertThrows, bold } from "../../../dev_deps.ts"; +import { assertEquals, assertThrows } from "@std/assert"; +import { bold } from "@std/fmt/colors"; import { Command } from "../../command.ts"; import type { Option } from "../../types.ts"; diff --git a/command/test/command/raw_args_test.ts b/command/test/command/raw_args_test.ts index 75ac9025..892d2c5c 100644 --- a/command/test/command/raw_args_test.ts +++ b/command/test/command/raw_args_test.ts @@ -1,4 +1,4 @@ -import { assertEquals } from "../../../dev_deps.ts"; +import { assertEquals } from "@std/assert"; import { Command } from "../../command.ts"; Deno.test("command - raw args - command with useRawArgs disabled", async () => { diff --git a/command/test/command/standalone_test.ts b/command/test/command/standalone_test.ts index 071eb759..5aff39f6 100644 --- a/command/test/command/standalone_test.ts +++ b/command/test/command/standalone_test.ts @@ -1,9 +1,11 @@ import { assertEquals, assertRejects, +} from "@std/assert"; +import { assertSpyCalls, spy, -} from "../../../dev_deps.ts"; +} from "@std/testing/mock"; import { Command } from "../../command.ts"; Deno.test("[command] should execute standalone option action", async () => { diff --git a/command/test/command/stop_early_test.ts b/command/test/command/stop_early_test.ts index 9402bbf1..37884977 100644 --- a/command/test/command/stop_early_test.ts +++ b/command/test/command/stop_early_test.ts @@ -1,4 +1,4 @@ -import { assertEquals, assertRejects } from "../../../dev_deps.ts"; +import { assertEquals, assertRejects } from "@std/assert"; import { Command } from "../../command.ts"; Deno.test("command stopEarly disable", async () => { diff --git a/command/test/command/sub_command_test.ts b/command/test/command/sub_command_test.ts index b9a595b1..f9cc086a 100644 --- a/command/test/command/sub_command_test.ts +++ b/command/test/command/sub_command_test.ts @@ -2,7 +2,7 @@ import { assertEquals, assertRejects, assertThrows, -} from "../../../dev_deps.ts"; +} from "@std/assert"; import { Command } from "../../command.ts"; const version = "1.0.0"; diff --git a/command/test/command/throw_test.ts b/command/test/command/throw_test.ts index 1bf26eef..cd70ac87 100644 --- a/command/test/command/throw_test.ts +++ b/command/test/command/throw_test.ts @@ -1,4 +1,4 @@ -import { assertThrows } from "../../../dev_deps.ts"; +import { assertThrows } from "@std/assert"; import { Command, ValidationError } from "../../mod.ts"; Deno.test("[command] should throw error", () => { diff --git a/command/test/command/version_test.ts b/command/test/command/version_test.ts index 57dcd003..d239527a 100644 --- a/command/test/command/version_test.ts +++ b/command/test/command/version_test.ts @@ -1,4 +1,4 @@ -import { assertEquals, assertRejects } from "../../../dev_deps.ts"; +import { assertEquals, assertRejects } from "@std/assert"; import { Command } from "../../command.ts"; Deno.test("command - version - version string", () => { diff --git a/command/test/integration/utils.ts b/command/test/integration/utils.ts index fae8cf4a..f48a3371 100644 --- a/command/test/integration/utils.ts +++ b/command/test/integration/utils.ts @@ -1,4 +1,4 @@ -import { dirname } from "../../../dev_deps.ts"; +import { dirname } from "@std/path"; export const baseDir = `${dirname(import.meta.url).replace("file://", "")}`; diff --git a/command/test/option/action_test.ts b/command/test/option/action_test.ts index 5ba05647..6e893113 100644 --- a/command/test/option/action_test.ts +++ b/command/test/option/action_test.ts @@ -1,11 +1,13 @@ import { assert, assertEquals, +} from "@std/assert"; +import { assertSpyCall, assertSpyCalls, - sinon, spy, -} from "../../../dev_deps.ts"; +} from "@std/testing/mock"; +import sinon from "sinon"; import { Command } from "../../command.ts"; Deno.test("[command] should execute the action from an option", async () => { diff --git a/command/test/option/aliases_test.ts b/command/test/option/aliases_test.ts index 70a7f854..7b244336 100644 --- a/command/test/option/aliases_test.ts +++ b/command/test/option/aliases_test.ts @@ -1,4 +1,4 @@ -import { assertEquals, assertRejects } from "../../../dev_deps.ts"; +import { assertEquals, assertRejects } from "@std/assert"; import { Command } from "../../command.ts"; const cmd = new Command() diff --git a/command/test/option/conflicts_test.ts b/command/test/option/conflicts_test.ts index 5337bce1..e3d57f79 100644 --- a/command/test/option/conflicts_test.ts +++ b/command/test/option/conflicts_test.ts @@ -1,4 +1,4 @@ -import { assertEquals, assertRejects } from "../../../dev_deps.ts"; +import { assertEquals, assertRejects } from "@std/assert"; import { Command } from "../../command.ts"; const cmd = new Command() diff --git a/command/test/option/default_test.ts b/command/test/option/default_test.ts index 82ec2e3c..e4511579 100644 --- a/command/test/option/default_test.ts +++ b/command/test/option/default_test.ts @@ -1,4 +1,4 @@ -import { assertEquals } from "../../../dev_deps.ts"; +import { assertEquals } from "@std/assert"; import { Command } from "../../command.ts"; Deno.test("command: option -> default", async () => { diff --git a/command/test/option/depends_test.ts b/command/test/option/depends_test.ts index 5de939eb..a8c829c3 100644 --- a/command/test/option/depends_test.ts +++ b/command/test/option/depends_test.ts @@ -1,4 +1,4 @@ -import { assertEquals, assertRejects } from "../../../dev_deps.ts"; +import { assertEquals, assertRejects } from "@std/assert"; import { Command } from "../../command.ts"; function command() { diff --git a/command/test/option/duplicate_test.ts b/command/test/option/duplicate_test.ts index f4f6f0f9..30b1f04d 100644 --- a/command/test/option/duplicate_test.ts +++ b/command/test/option/duplicate_test.ts @@ -1,4 +1,4 @@ -import { assert, assertRejects } from "../../../dev_deps.ts"; +import { assert, assertRejects } from "@std/assert"; import { Command } from "../../command.ts"; const cmd = new Command() diff --git a/command/test/option/global_test.ts b/command/test/option/global_test.ts index 06a16431..bfa434a5 100644 --- a/command/test/option/global_test.ts +++ b/command/test/option/global_test.ts @@ -1,4 +1,4 @@ -import { assertEquals, assertRejects } from "../../../dev_deps.ts"; +import { assertEquals, assertRejects } from "@std/assert"; import { Command } from "../../command.ts"; import type { ArgumentValue } from "../../types.ts"; import { ValidationError } from "../../_errors.ts"; diff --git a/command/test/option/hidden_test.ts b/command/test/option/hidden_test.ts index cd67d62d..09914ab1 100644 --- a/command/test/option/hidden_test.ts +++ b/command/test/option/hidden_test.ts @@ -1,4 +1,5 @@ -import { assertEquals, stripColor } from "../../../dev_deps.ts"; +import { assertEquals } from "@std/assert"; +import { stripColor } from "@std/fmt/colors"; import { Command } from "../../command.ts"; function command() { diff --git a/command/test/option/list_test.ts b/command/test/option/list_test.ts index 6df7b067..be474232 100644 --- a/command/test/option/list_test.ts +++ b/command/test/option/list_test.ts @@ -1,4 +1,4 @@ -import { assertEquals } from "../../../dev_deps.ts"; +import { assertEquals } from "@std/assert"; import { Command } from "../../command.ts"; const cmd = new Command() diff --git a/command/test/option/negatable_test.ts b/command/test/option/negatable_test.ts index b9000f8c..fdf52606 100644 --- a/command/test/option/negatable_test.ts +++ b/command/test/option/negatable_test.ts @@ -1,4 +1,4 @@ -import { assertEquals, assertRejects } from "../../../dev_deps.ts"; +import { assertEquals, assertRejects } from "@std/assert"; import { Command } from "../../command.ts"; function command() { diff --git a/command/test/option/required_test.ts b/command/test/option/required_test.ts index 9a9f437b..5a12c568 100644 --- a/command/test/option/required_test.ts +++ b/command/test/option/required_test.ts @@ -1,4 +1,4 @@ -import { assertEquals, assertRejects } from "../../../dev_deps.ts"; +import { assertEquals, assertRejects } from "@std/assert"; import { Command } from "../../command.ts"; const cmd = new Command() diff --git a/command/test/option/requires_test.ts b/command/test/option/requires_test.ts index 0896b7ba..a2bd9a12 100644 --- a/command/test/option/requires_test.ts +++ b/command/test/option/requires_test.ts @@ -1,4 +1,4 @@ -import { assertEquals, assertRejects } from "../../../dev_deps.ts"; +import { assertEquals, assertRejects } from "@std/assert"; import { Command } from "../../command.ts"; const cmd = new Command() diff --git a/command/test/option/standalone_test.ts b/command/test/option/standalone_test.ts index f5d21fb1..90977fc7 100644 --- a/command/test/option/standalone_test.ts +++ b/command/test/option/standalone_test.ts @@ -1,4 +1,4 @@ -import { assertEquals, assertRejects } from "../../../dev_deps.ts"; +import { assertEquals, assertRejects } from "@std/assert"; import { Command } from "../../command.ts"; const cmd = new Command() diff --git a/command/test/option/value_test.ts b/command/test/option/value_test.ts index 93d2d5f9..7179c07d 100644 --- a/command/test/option/value_test.ts +++ b/command/test/option/value_test.ts @@ -1,4 +1,4 @@ -import { assertEquals, assertRejects } from "../../../dev_deps.ts"; +import { assertEquals, assertRejects } from "@std/assert"; import { Command } from "../../command.ts"; function cmd() { diff --git a/command/test/option/variadic_test.ts b/command/test/option/variadic_test.ts index 3bf11bc1..46826873 100644 --- a/command/test/option/variadic_test.ts +++ b/command/test/option/variadic_test.ts @@ -1,4 +1,4 @@ -import { assertEquals, assertRejects } from "../../../dev_deps.ts"; +import { assertEquals, assertRejects } from "@std/assert"; import { Command } from "../../command.ts"; const cmd = new Command() diff --git a/command/test/option/wildcard_test.ts b/command/test/option/wildcard_test.ts index dba61804..f0ef59a6 100644 --- a/command/test/option/wildcard_test.ts +++ b/command/test/option/wildcard_test.ts @@ -1,4 +1,4 @@ -import { assertEquals, assertRejects } from "../../../dev_deps.ts"; +import { assertEquals, assertRejects } from "@std/assert"; import { Command } from "../../command.ts"; function cmd() { diff --git a/command/test/type/boolean_test.ts b/command/test/type/boolean_test.ts index ef7d50b8..0d579ed7 100644 --- a/command/test/type/boolean_test.ts +++ b/command/test/type/boolean_test.ts @@ -1,4 +1,4 @@ -import { assertEquals, assertRejects } from "../../../dev_deps.ts"; +import { assertEquals, assertRejects } from "@std/assert"; import { Command } from "../../command.ts"; const cmd = new Command() diff --git a/command/test/type/custom_test.ts b/command/test/type/custom_test.ts index c7bb4817..128b088e 100644 --- a/command/test/type/custom_test.ts +++ b/command/test/type/custom_test.ts @@ -1,4 +1,4 @@ -import { assertEquals, assertRejects } from "../../../dev_deps.ts"; +import { assertEquals, assertRejects } from "@std/assert"; import { Command } from "../../command.ts"; import type { ArgumentValue, TypeHandler } from "../../types.ts"; import { Type } from "../../type.ts"; diff --git a/command/test/type/enum_test.ts b/command/test/type/enum_test.ts index 09c043b2..830d904a 100644 --- a/command/test/type/enum_test.ts +++ b/command/test/type/enum_test.ts @@ -1,4 +1,4 @@ -import { assertEquals, assertRejects } from "../../../dev_deps.ts"; +import { assertEquals, assertRejects } from "@std/assert"; import { Command } from "../../command.ts"; import { EnumType } from "../../types/enum.ts"; diff --git a/command/test/type/file_test.ts b/command/test/type/file_test.ts index 935b1810..2e65be4c 100644 --- a/command/test/type/file_test.ts +++ b/command/test/type/file_test.ts @@ -2,7 +2,7 @@ import { assert, IsExact, } from "conditional_type_checks"; -import { assertEquals } from "../../../dev_deps.ts"; +import { assertEquals } from "@std/assert"; import { Command } from "../../command.ts"; function cmd() { diff --git a/command/test/type/integer_test.ts b/command/test/type/integer_test.ts index a5b031f2..287fb44a 100644 --- a/command/test/type/integer_test.ts +++ b/command/test/type/integer_test.ts @@ -1,4 +1,4 @@ -import { assertEquals, assertRejects } from "../../../dev_deps.ts"; +import { assertEquals, assertRejects } from "@std/assert"; import { Command } from "../../command.ts"; const cmd = new Command() diff --git a/command/test/type/no_value_test.ts b/command/test/type/no_value_test.ts index 9f5f7d85..350303b4 100644 --- a/command/test/type/no_value_test.ts +++ b/command/test/type/no_value_test.ts @@ -1,4 +1,4 @@ -import { assertEquals, assertRejects } from "../../../dev_deps.ts"; +import { assertEquals, assertRejects } from "@std/assert"; import { Command } from "../../command.ts"; import { HelpCommand } from "../../help/help_command.ts"; diff --git a/command/test/type/number_test.ts b/command/test/type/number_test.ts index d52f9592..6ea7fbb7 100644 --- a/command/test/type/number_test.ts +++ b/command/test/type/number_test.ts @@ -1,4 +1,4 @@ -import { assertEquals, assertRejects } from "../../../dev_deps.ts"; +import { assertEquals, assertRejects } from "@std/assert"; import { Command } from "../../command.ts"; const cmd = new Command() diff --git a/command/test/type/string_test.ts b/command/test/type/string_test.ts index 5a5de63f..e41ed80c 100644 --- a/command/test/type/string_test.ts +++ b/command/test/type/string_test.ts @@ -1,4 +1,4 @@ -import { assertEquals, assertRejects } from "../../../dev_deps.ts"; +import { assertEquals, assertRejects } from "@std/assert"; import { Command } from "../../command.ts"; const cmd = new Command() diff --git a/command/upgrade/_check_version.ts b/command/upgrade/_check_version.ts index f32093bd..bd1fb4b3 100644 --- a/command/upgrade/_check_version.ts +++ b/command/upgrade/_check_version.ts @@ -1,4 +1,4 @@ -import { bold, yellow } from "../deps.ts"; +import { bold, yellow } from "@std/fmt/colors"; import { Command } from "../command.ts"; /** Check if new version is available and add hint to version. */ diff --git a/command/upgrade/provider.ts b/command/upgrade/provider.ts index e7f09192..4dc27642 100644 --- a/command/upgrade/provider.ts +++ b/command/upgrade/provider.ts @@ -1,4 +1,4 @@ -import { bold, brightBlue, cyan, green, red, yellow } from "../deps.ts"; +import { bold, brightBlue, cyan, green, red, yellow } from "@std/fmt/colors"; import { ValidationError } from "../_errors.ts"; import { Table } from "../../table/table.ts"; diff --git a/command/upgrade/provider/github.ts b/command/upgrade/provider/github.ts index 0f086d3b..e5edaa11 100644 --- a/command/upgrade/provider/github.ts +++ b/command/upgrade/provider/github.ts @@ -1,5 +1,5 @@ import { Provider, Versions } from "../provider.ts"; -import { bold, brightBlue } from "../../deps.ts"; +import { bold, brightBlue } from "@std/fmt/colors"; export interface GithubProviderOptions { repository: string; diff --git a/dev_deps.ts b/dev_deps.ts deleted file mode 100644 index b501b0a1..00000000 --- a/dev_deps.ts +++ /dev/null @@ -1,33 +0,0 @@ -/* std */ -export { - assert, - assertEquals, - assertInstanceOf, - assertRejects, - assertStrictEquals, - assertThrows, -} from "@std/assert"; -export { - assertSpyCall, - assertSpyCalls, - spy, -} from "@std/testing/mock"; -export { assertSnapshot } from "@std/testing/snapshot"; -export { describe, it } from "@std/testing/bdd"; -export { - assertType, - type IsExact, -} from "@std/testing/types"; -export { - bold, - red, - stripColor, -} from "@std/fmt/colors"; -export { dirname } from "@std/path/dirname"; -export { expandGlob } from "@std/fs/expand_glob"; -export type { WalkEntry } from "@std/fs/walk"; -export { copy } from "@std/io/copy"; -export { format } from "@std/datetime/format"; - -/* 3rd party */ -export { default as sinon } from "sinon"; diff --git a/flags/test/flags/dotted_options_test.ts b/flags/test/flags/dotted_options_test.ts index 606c4efe..8b53a5b6 100644 --- a/flags/test/flags/dotted_options_test.ts +++ b/flags/test/flags/dotted_options_test.ts @@ -1,4 +1,4 @@ -import { assertEquals, assertThrows } from "../../../dev_deps.ts"; +import { assertEquals, assertThrows } from "@std/assert"; import { ValidationError } from "../../_errors.ts"; import { OptionType } from "../../deprecated.ts"; import { parseFlags } from "../../flags.ts"; diff --git a/flags/test/option/aliases_test.ts b/flags/test/option/aliases_test.ts index 68a40d6c..e161b1ca 100644 --- a/flags/test/option/aliases_test.ts +++ b/flags/test/option/aliases_test.ts @@ -1,4 +1,4 @@ -import { assertEquals, assertThrows } from "../../../dev_deps.ts"; +import { assertEquals, assertThrows } from "@std/assert"; import { OptionType } from "../../deprecated.ts"; import { parseFlags } from "../../flags.ts"; import type { ParseFlagsOptions } from "../../types.ts"; diff --git a/flags/test/option/collect_test.ts b/flags/test/option/collect_test.ts index f2c8fff5..da63167b 100644 --- a/flags/test/option/collect_test.ts +++ b/flags/test/option/collect_test.ts @@ -1,4 +1,4 @@ -import { assertEquals, assertThrows } from "../../../dev_deps.ts"; +import { assertEquals, assertThrows } from "@std/assert"; import { OptionType } from "../../deprecated.ts"; import { parseFlags } from "../../flags.ts"; import type { ParseFlagsOptions } from "../../types.ts"; diff --git a/flags/test/option/conflicts_test.ts b/flags/test/option/conflicts_test.ts index f43161c1..71142d7d 100644 --- a/flags/test/option/conflicts_test.ts +++ b/flags/test/option/conflicts_test.ts @@ -1,4 +1,4 @@ -import { assertEquals, assertThrows } from "../../../dev_deps.ts"; +import { assertEquals, assertThrows } from "@std/assert"; import { OptionType } from "../../deprecated.ts"; import { parseFlags } from "../../flags.ts"; import type { ParseFlagsOptions } from "../../types.ts"; diff --git a/flags/test/option/default_test.ts b/flags/test/option/default_test.ts index c776a6b6..bdae1fee 100644 --- a/flags/test/option/default_test.ts +++ b/flags/test/option/default_test.ts @@ -1,4 +1,4 @@ -import { assertEquals } from "../../../dev_deps.ts"; +import { assertEquals } from "@std/assert"; import { OptionType } from "../../deprecated.ts"; import { parseFlags } from "../../flags.ts"; import type { ParseFlagsOptions } from "../../types.ts"; diff --git a/flags/test/option/depends_test.ts b/flags/test/option/depends_test.ts index 0b612532..b247b53a 100644 --- a/flags/test/option/depends_test.ts +++ b/flags/test/option/depends_test.ts @@ -1,4 +1,4 @@ -import { assertEquals, assertThrows } from "../../../dev_deps.ts"; +import { assertEquals, assertThrows } from "@std/assert"; import { OptionType } from "../../deprecated.ts"; import { parseFlags } from "../../flags.ts"; import type { ParseFlagsOptions } from "../../types.ts"; diff --git a/flags/test/option/equls_sign_test.ts b/flags/test/option/equls_sign_test.ts index bd506b0a..39aec34c 100644 --- a/flags/test/option/equls_sign_test.ts +++ b/flags/test/option/equls_sign_test.ts @@ -1,4 +1,4 @@ -import { assertEquals } from "../../../dev_deps.ts"; +import { assertEquals } from "@std/assert"; import { parseFlags } from "../../flags.ts"; Deno.test("[flags] should parse required value with equals sign", () => { diff --git a/flags/test/option/negatable_test.ts b/flags/test/option/negatable_test.ts index f3aa10bd..f92efa7d 100644 --- a/flags/test/option/negatable_test.ts +++ b/flags/test/option/negatable_test.ts @@ -1,4 +1,4 @@ -import { assertEquals, assertThrows } from "../../../dev_deps.ts"; +import { assertEquals, assertThrows } from "@std/assert"; import { parseFlags } from "../../flags.ts"; import type { ParseFlagsOptions } from "../../types.ts"; diff --git a/flags/test/option/required_test.ts b/flags/test/option/required_test.ts index 51093273..909bff39 100644 --- a/flags/test/option/required_test.ts +++ b/flags/test/option/required_test.ts @@ -1,4 +1,4 @@ -import { assertEquals, assertThrows } from "../../../dev_deps.ts"; +import { assertEquals, assertThrows } from "@std/assert"; import { OptionType } from "../../deprecated.ts"; import { parseFlags } from "../../flags.ts"; import type { ParseFlagsOptions } from "../../types.ts"; diff --git a/flags/test/option/requires_test.ts b/flags/test/option/requires_test.ts index ace707f0..a34ec820 100644 --- a/flags/test/option/requires_test.ts +++ b/flags/test/option/requires_test.ts @@ -1,4 +1,4 @@ -import { assertEquals, assertThrows } from "../../../dev_deps.ts"; +import { assertEquals, assertThrows } from "@std/assert"; import { OptionType } from "../../deprecated.ts"; import { parseFlags } from "../../flags.ts"; import type { ParseFlagsOptions } from "../../types.ts"; diff --git a/flags/test/option/standalone_test.ts b/flags/test/option/standalone_test.ts index daa1b100..5c9142ac 100644 --- a/flags/test/option/standalone_test.ts +++ b/flags/test/option/standalone_test.ts @@ -1,4 +1,4 @@ -import { assertEquals, assertThrows } from "../../../dev_deps.ts"; +import { assertEquals, assertThrows } from "@std/assert"; import { OptionType } from "../../deprecated.ts"; import { parseFlags } from "../../flags.ts"; import type { ParseFlagsOptions } from "../../types.ts"; diff --git a/flags/test/option/unknown_test.ts b/flags/test/option/unknown_test.ts index a49cf661..c0aa73cc 100644 --- a/flags/test/option/unknown_test.ts +++ b/flags/test/option/unknown_test.ts @@ -1,4 +1,4 @@ -import { assertEquals } from "../../../dev_deps.ts"; +import { assertEquals } from "@std/assert"; import { parseFlags } from "../../flags.ts"; import type { ParseFlagsOptions } from "../../types.ts"; diff --git a/flags/test/option/value_test.ts b/flags/test/option/value_test.ts index fd681459..106b79f7 100644 --- a/flags/test/option/value_test.ts +++ b/flags/test/option/value_test.ts @@ -1,4 +1,4 @@ -import { assertEquals, assertThrows } from "../../../dev_deps.ts"; +import { assertEquals, assertThrows } from "@std/assert"; import { OptionType } from "../../deprecated.ts"; import { parseFlags } from "../../flags.ts"; import type { ParseFlagsOptions } from "../../types.ts"; diff --git a/flags/test/option/variadic_test.ts b/flags/test/option/variadic_test.ts index 9955718c..e8bed0a2 100644 --- a/flags/test/option/variadic_test.ts +++ b/flags/test/option/variadic_test.ts @@ -1,4 +1,4 @@ -import { assertEquals, assertThrows } from "../../../dev_deps.ts"; +import { assertEquals, assertThrows } from "@std/assert"; import { OptionType } from "../../deprecated.ts"; import { parseFlags } from "../../flags.ts"; import type { ParseFlagsOptions } from "../../types.ts"; diff --git a/flags/test/setting/allow_empty_test.ts b/flags/test/setting/allow_empty_test.ts index d4f7cb79..b994ad11 100644 --- a/flags/test/setting/allow_empty_test.ts +++ b/flags/test/setting/allow_empty_test.ts @@ -1,4 +1,4 @@ -import { assertEquals, assertThrows } from "../../../dev_deps.ts"; +import { assertEquals, assertThrows } from "@std/assert"; import { parseFlags } from "../../flags.ts"; Deno.test("[flags] should not allow empty by default", () => { diff --git a/flags/test/setting/option_test.ts b/flags/test/setting/option_test.ts index 721dd96f..0619d909 100644 --- a/flags/test/setting/option_test.ts +++ b/flags/test/setting/option_test.ts @@ -1,4 +1,4 @@ -import { assertEquals } from "../../../dev_deps.ts"; +import { assertEquals } from "@std/assert"; import { OptionType } from "../../deprecated.ts"; import { parseFlags } from "../../flags.ts"; import { FlagOptions } from "../../types.ts"; diff --git a/flags/test/setting/stop_early_test.ts b/flags/test/setting/stop_early_test.ts index 4c72c0e3..1ea8c56c 100644 --- a/flags/test/setting/stop_early_test.ts +++ b/flags/test/setting/stop_early_test.ts @@ -1,4 +1,4 @@ -import { assertEquals, assertThrows } from "../../../dev_deps.ts"; +import { assertEquals, assertThrows } from "@std/assert"; import { OptionType } from "../../deprecated.ts"; import { parseFlags } from "../../flags.ts"; diff --git a/flags/test/setting/stop_on_unknown_test.ts b/flags/test/setting/stop_on_unknown_test.ts index ce07ce9e..c638ff75 100644 --- a/flags/test/setting/stop_on_unknown_test.ts +++ b/flags/test/setting/stop_on_unknown_test.ts @@ -1,4 +1,4 @@ -import { assertEquals } from "../../../dev_deps.ts"; +import { assertEquals } from "@std/assert"; import { OptionType } from "../../deprecated.ts"; import { parseFlags } from "../../flags.ts"; diff --git a/flags/test/type/boolean_test.ts b/flags/test/type/boolean_test.ts index d0c0bde2..59642461 100644 --- a/flags/test/type/boolean_test.ts +++ b/flags/test/type/boolean_test.ts @@ -1,4 +1,4 @@ -import { assertEquals, assertThrows } from "../../../dev_deps.ts"; +import { assertEquals, assertThrows } from "@std/assert"; import { OptionType } from "../../deprecated.ts"; import { parseFlags } from "../../flags.ts"; diff --git a/flags/test/type/integer_test.ts b/flags/test/type/integer_test.ts index 16c78ec3..694781c9 100644 --- a/flags/test/type/integer_test.ts +++ b/flags/test/type/integer_test.ts @@ -1,4 +1,4 @@ -import { assertEquals, assertThrows } from "../../../dev_deps.ts"; +import { assertEquals, assertThrows } from "@std/assert"; import { OptionType } from "../../deprecated.ts"; import { parseFlags } from "../../flags.ts"; import type { ParseFlagsOptions } from "../../types.ts"; diff --git a/flags/test/type/no_value_test.ts b/flags/test/type/no_value_test.ts index e0f0727f..0268a9aa 100644 --- a/flags/test/type/no_value_test.ts +++ b/flags/test/type/no_value_test.ts @@ -1,4 +1,4 @@ -import { assertEquals, assertThrows } from "../../../dev_deps.ts"; +import { assertEquals, assertThrows } from "@std/assert"; import { parseFlags } from "../../flags.ts"; import type { ParseFlagsOptions } from "../../types.ts"; diff --git a/flags/test/type/number_test.ts b/flags/test/type/number_test.ts index e0f8dd1c..311645a2 100644 --- a/flags/test/type/number_test.ts +++ b/flags/test/type/number_test.ts @@ -1,4 +1,4 @@ -import { assertEquals, assertThrows } from "../../../dev_deps.ts"; +import { assertEquals, assertThrows } from "@std/assert"; import { OptionType } from "../../deprecated.ts"; import { parseFlags } from "../../flags.ts"; import type { ParseFlagsOptions } from "../../types.ts"; diff --git a/flags/test/type/string_test.ts b/flags/test/type/string_test.ts index 7816d570..7f027b99 100644 --- a/flags/test/type/string_test.ts +++ b/flags/test/type/string_test.ts @@ -1,4 +1,4 @@ -import { assertEquals, assertThrows } from "../../../dev_deps.ts"; +import { assertEquals, assertThrows } from "@std/assert"; import { OptionType } from "../../deprecated.ts"; import { parseFlags } from "../../flags.ts"; import type { ParseFlagsOptions } from "../../types.ts"; diff --git a/keycode/test/key_code_test.ts b/keycode/test/key_code_test.ts index f8741026..1dbbc938 100644 --- a/keycode/test/key_code_test.ts +++ b/keycode/test/key_code_test.ts @@ -1,4 +1,4 @@ -import { assertEquals } from "../../dev_deps.ts"; +import { assertEquals } from "@std/assert"; import { KeyCode, parse } from "../key_code.ts"; import { KeyMap, diff --git a/keypress/test.ts b/keypress/test.ts index 9113ba93..b637b1d0 100644 --- a/keypress/test.ts +++ b/keypress/test.ts @@ -1,4 +1,4 @@ -import { assertEquals } from "../dev_deps.ts"; +import { assertEquals } from "@std/assert"; import { KeyPressEvent } from "./mod.ts"; Deno.test({ diff --git a/prompt/_generic_input.ts b/prompt/_generic_input.ts index 5c8a4ad5..3502e529 100644 --- a/prompt/_generic_input.ts +++ b/prompt/_generic_input.ts @@ -5,7 +5,7 @@ import { GenericPromptOptions, GenericPromptSettings, } from "./_generic_prompt.ts"; -import { brightBlue, dim, stripColor, underline } from "./deps.ts"; +import { brightBlue, dim, stripColor, underline } from "@std/fmt/colors"; /** Generic input prompt options. */ export interface GenericInputPromptOptions diff --git a/prompt/_generic_list.ts b/prompt/_generic_list.ts index 7240729c..55198dee 100644 --- a/prompt/_generic_list.ts +++ b/prompt/_generic_list.ts @@ -6,7 +6,7 @@ import { GenericInputPromptSettings, } from "./_generic_input.ts"; import { WidenType } from "./_utils.ts"; -import { bold, brightBlue, dim, stripColor, yellow } from "./deps.ts"; +import { bold, brightBlue, dim, stripColor, yellow } from "@std/fmt/colors"; import { Figures, getFiguresByKeys } from "./_figures.ts"; import { distance } from "../_utils/distance.ts"; diff --git a/prompt/_generic_prompt.ts b/prompt/_generic_prompt.ts index 246fc4e0..8e3a6a45 100644 --- a/prompt/_generic_prompt.ts +++ b/prompt/_generic_prompt.ts @@ -7,12 +7,11 @@ import { dim, green, italic, - type Reader, red, stripColor, - type WriterSync, - yellow, -} from "./deps.ts"; + yellow +} from "@std/fmt/colors"; +import { Reader, WriterSync } from "@std/io/types"; import { Figures } from "./_figures.ts"; /** Static generic prompt interface. */ diff --git a/prompt/_generic_suggestions.ts b/prompt/_generic_suggestions.ts index b5ff3c47..149eb4cc 100644 --- a/prompt/_generic_suggestions.ts +++ b/prompt/_generic_suggestions.ts @@ -9,12 +9,14 @@ import { bold, brightBlue, dim, + underline, + stripColor, +} from "@std/fmt/colors"; +import { dirname, join, normalize, - stripColor, - underline, -} from "./deps.ts"; +} from "@std/path" import { Figures, getFiguresByKeys } from "./_figures.ts"; import { distance } from "../_utils/distance.ts"; diff --git a/prompt/checkbox.ts b/prompt/checkbox.ts index 0e830ba9..a259e630 100644 --- a/prompt/checkbox.ts +++ b/prompt/checkbox.ts @@ -1,6 +1,6 @@ import type { KeyCode } from "../keycode/mod.ts"; import { WidenType } from "./_utils.ts"; -import { brightBlue, dim, green, red } from "./deps.ts"; +import { brightBlue, dim, green, red } from "@std/fmt/colors"; import { Figures, getFiguresByKeys } from "./_figures.ts"; import { GenericList, diff --git a/prompt/confirm.ts b/prompt/confirm.ts index 0f926fdc..df4a8c34 100644 --- a/prompt/confirm.ts +++ b/prompt/confirm.ts @@ -5,7 +5,7 @@ import { GenericSuggestionsOptions, GenericSuggestionsSettings, } from "./_generic_suggestions.ts"; -import { dim } from "./deps.ts"; +import { dim } from "@std/fmt/colors"; type UnsupportedOptions = | "files" diff --git a/prompt/deps.ts b/prompt/deps.ts deleted file mode 100644 index 208e7411..00000000 --- a/prompt/deps.ts +++ /dev/null @@ -1,22 +0,0 @@ -export { - bold, - brightBlue, - dim, - green, - italic, - red, - stripColor, - underline, - yellow, -} from "@std/fmt/colors"; -export { - dirname, - join, - normalize, -} from "@std/path"; -export type { - Reader, - ReaderSync, - Writer, - WriterSync, -} from "@std/io/types"; diff --git a/prompt/input.ts b/prompt/input.ts index 3d239d91..f1266cae 100644 --- a/prompt/input.ts +++ b/prompt/input.ts @@ -5,7 +5,7 @@ import { GenericSuggestionsOptions, GenericSuggestionsSettings, } from "./_generic_suggestions.ts"; -import { normalize } from "./deps.ts"; +import { normalize } from "@std/path"; /** Input prompt options. */ export interface InputOptions diff --git a/prompt/list.ts b/prompt/list.ts index c73bdb19..47d7d567 100644 --- a/prompt/list.ts +++ b/prompt/list.ts @@ -5,7 +5,8 @@ import { GenericSuggestionsOptions, GenericSuggestionsSettings, } from "./_generic_suggestions.ts"; -import { dim, normalize, underline } from "./deps.ts"; +import { dim, underline } from "@std/fmt/colors"; +import { normalize } from "@std/path"; /** List prompt options. */ export interface ListOptions diff --git a/prompt/secret.ts b/prompt/secret.ts index f61b3b08..9274acf1 100644 --- a/prompt/secret.ts +++ b/prompt/secret.ts @@ -1,5 +1,5 @@ import { GenericPrompt } from "./_generic_prompt.ts"; -import { underline } from "./deps.ts"; +import { underline } from "@std/fmt/colors"; import { GenericInput, GenericInputKeys, diff --git a/prompt/select.ts b/prompt/select.ts index 59cc18cd..84f883ed 100644 --- a/prompt/select.ts +++ b/prompt/select.ts @@ -1,5 +1,5 @@ import { WidenType } from "./_utils.ts"; -import { brightBlue, underline } from "./deps.ts"; +import { brightBlue, underline } from "@std/fmt/colors"; import { GenericList, GenericListKeys, diff --git a/prompt/test/checkbox_test.ts b/prompt/test/checkbox_test.ts index e80f2113..7ea99009 100644 --- a/prompt/test/checkbox_test.ts +++ b/prompt/test/checkbox_test.ts @@ -1,4 +1,5 @@ -import { assertEquals, assertRejects, bold, red } from "../../dev_deps.ts"; +import { assertEquals, assertRejects } from "@std/assert"; +import { bold, red } from "@std/fmt/colors"; import { Checkbox } from "../checkbox.ts"; Deno.test("prompt checkbox: valid value", async () => { diff --git a/prompt/test/confirm_test.ts b/prompt/test/confirm_test.ts index 2de0106f..732dcfdb 100644 --- a/prompt/test/confirm_test.ts +++ b/prompt/test/confirm_test.ts @@ -1,4 +1,5 @@ -import { assertEquals, assertRejects, bold, red } from "../../dev_deps.ts"; +import { assertEquals, assertRejects } from "@std/assert"; +import { bold, red } from "@std/fmt/colors"; import { Confirm } from "../confirm.ts"; Deno.test("prompt confirm: y", async () => { diff --git a/prompt/test/input_test.ts b/prompt/test/input_test.ts index 67cc6642..2b415813 100644 --- a/prompt/test/input_test.ts +++ b/prompt/test/input_test.ts @@ -1,4 +1,5 @@ -import { assertEquals, assertRejects, bold, red } from "../../dev_deps.ts"; +import { assertEquals, assertRejects } from "@std/assert"; +import { bold, red } from "@std/fmt/colors"; import { Input } from "../input.ts"; Deno.test("prompt input: value", async () => { diff --git a/prompt/test/integration/prompt_test.ts b/prompt/test/integration/prompt_test.ts index 7d87bd43..ae31acae 100644 --- a/prompt/test/integration/prompt_test.ts +++ b/prompt/test/integration/prompt_test.ts @@ -1,5 +1,6 @@ import { ansi } from "../../../ansi/ansi.ts"; -import { assertEquals, assertType, IsExact } from "../../../dev_deps.ts"; +import { assertEquals } from "@std/assert"; +import { IsExact, assertType } from "@std/testing/types"; import { Checkbox, CheckboxOptions } from "../../checkbox.ts"; import { Confirm } from "../../confirm.ts"; import { Input } from "../../input.ts"; diff --git a/prompt/test/integration/select_test.ts b/prompt/test/integration/select_test.ts index db88f066..3c348d6b 100644 --- a/prompt/test/integration/select_test.ts +++ b/prompt/test/integration/select_test.ts @@ -1,5 +1,5 @@ import { ansi } from "../../../ansi/ansi.ts"; -import { format } from "../../../dev_deps.ts"; +import { format } from "@std/datetime/format"; import { Select } from "../../select.ts"; import { snapshotTest } from "../../../testing/snapshot.ts"; diff --git a/prompt/test/list_test.ts b/prompt/test/list_test.ts index fa6d77eb..4382ffa1 100644 --- a/prompt/test/list_test.ts +++ b/prompt/test/list_test.ts @@ -1,4 +1,5 @@ -import { assertEquals, assertRejects, bold, red } from "../../dev_deps.ts"; +import { assertEquals, assertRejects } from "@std/assert"; +import { bold, red } from "@std/fmt/colors"; import { List } from "../list.ts"; Deno.test('prompt list: , separator option: ","', async () => { diff --git a/prompt/test/number_test.ts b/prompt/test/number_test.ts index e7e7758f..d8e8e179 100644 --- a/prompt/test/number_test.ts +++ b/prompt/test/number_test.ts @@ -1,4 +1,5 @@ -import { assertEquals, assertRejects, bold, red } from "../../dev_deps.ts"; +import { assertEquals, assertRejects } from "@std/assert"; +import { bold, red } from "@std/fmt/colors"; import { Number } from "../number.ts"; Deno.test("prompt number: value", async () => { diff --git a/prompt/test/prompt_list_test.ts b/prompt/test/prompt_list_test.ts index c3c9dd2c..505b1668 100644 --- a/prompt/test/prompt_list_test.ts +++ b/prompt/test/prompt_list_test.ts @@ -2,7 +2,7 @@ import { assert, IsExact, } from "conditional_type_checks"; -import { assertEquals, assertRejects } from "../../dev_deps.ts"; +import { assertEquals, assertRejects } from "@std/assert"; import { inject, prompt } from "../prompt.ts"; import { Checkbox } from "../checkbox.ts"; import { Confirm } from "../confirm.ts"; diff --git a/prompt/test/secret_test.ts b/prompt/test/secret_test.ts index 13292d81..c6714ae2 100644 --- a/prompt/test/secret_test.ts +++ b/prompt/test/secret_test.ts @@ -1,4 +1,5 @@ -import { assertEquals, assertRejects, bold, red } from "../../dev_deps.ts"; +import { assertEquals, assertRejects } from "@std/assert"; +import { bold, red } from "@std/fmt/colors"; import { Secret } from "../secret.ts"; Deno.test("prompt secret: value", async () => { diff --git a/prompt/test/select_test.ts b/prompt/test/select_test.ts index 5947add2..b533df54 100644 --- a/prompt/test/select_test.ts +++ b/prompt/test/select_test.ts @@ -1,4 +1,5 @@ -import { assertEquals, assertRejects, bold, red } from "../../dev_deps.ts"; +import { assertEquals, assertRejects } from "@std/assert"; +import { bold, red } from "@std/fmt/colors"; import { Select } from "../select.ts"; Deno.test("prompt select: value", async () => { diff --git a/prompt/test/toggle_test.ts b/prompt/test/toggle_test.ts index 3bfe36c6..81d2aed1 100644 --- a/prompt/test/toggle_test.ts +++ b/prompt/test/toggle_test.ts @@ -1,4 +1,5 @@ -import { assertEquals, assertRejects, bold, red } from "../../dev_deps.ts"; +import { assertEquals, assertRejects } from "@std/assert"; +import { bold, red } from "@std/fmt/colors"; import { Toggle } from "../toggle.ts"; Deno.test("prompt toggle: yes", async () => { diff --git a/prompt/toggle.ts b/prompt/toggle.ts index d0e9eacf..a1f72bf1 100644 --- a/prompt/toggle.ts +++ b/prompt/toggle.ts @@ -1,5 +1,5 @@ import type { KeyCode } from "../keycode/key_code.ts"; -import { dim, underline } from "./deps.ts"; +import { dim, underline } from "@std/fmt/colors"; import { GenericPrompt, GenericPromptKeys, diff --git a/table/_utils.ts b/table/_utils.ts index ba723b4d..de1e3cea 100644 --- a/table/_utils.ts +++ b/table/_utils.ts @@ -6,7 +6,8 @@ */ import { Cell, CellType } from "./cell.ts"; import { consumeWords } from "./consume_words.ts"; -import { stripColor, unicodeWidth } from "./deps.ts"; +import { stripColor } from "@std/fmt/colors"; +import { unicodeWidth } from "@std/console/unicode_width"; /** * Get longest cell from given row index. diff --git a/table/deps.ts b/table/deps.ts deleted file mode 100644 index be3af584..00000000 --- a/table/deps.ts +++ /dev/null @@ -1,2 +0,0 @@ -export { stripColor } from "@std/fmt/colors"; -export { unicodeWidth } from "@std/console/unicode_width"; diff --git a/table/test/align_test.ts b/table/test/align_test.ts index 1d0fe286..9b90b9f8 100644 --- a/table/test/align_test.ts +++ b/table/test/align_test.ts @@ -1,5 +1,5 @@ import { Table } from "../table.ts"; -import { assertEquals } from "../../dev_deps.ts"; +import { assertEquals } from "@std/assert"; import { Row } from "../row.ts"; import { Cell } from "../cell.ts"; diff --git a/table/test/ansi_regex_source_test.ts b/table/test/ansi_regex_source_test.ts index d7c0a3b2..afb2c97a 100644 --- a/table/test/ansi_regex_source_test.ts +++ b/table/test/ansi_regex_source_test.ts @@ -1,5 +1,5 @@ import { ansiRegexSource } from "../_utils.ts"; -import { assertEquals } from "../../dev_deps.ts"; +import { assertEquals } from "@std/assert"; Deno.test(`table - ansiRegexSource`, () => { const DIGITS = String.raw`\d+`; diff --git a/table/test/ansi_wrapping_within_cell_test.ts b/table/test/ansi_wrapping_within_cell_test.ts index 62615420..776c5b2e 100644 --- a/table/test/ansi_wrapping_within_cell_test.ts +++ b/table/test/ansi_wrapping_within_cell_test.ts @@ -1,5 +1,5 @@ import { Table } from "../table.ts"; -import { assertEquals } from "../../dev_deps.ts"; +import { assertEquals } from "@std/assert"; const tests: { description: string; diff --git a/table/test/border_test.ts b/table/test/border_test.ts index 1296294f..14152c11 100644 --- a/table/test/border_test.ts +++ b/table/test/border_test.ts @@ -1,6 +1,6 @@ import { border } from "../border.ts"; import { Table } from "../table.ts"; -import { assertEquals } from "../../dev_deps.ts"; +import { assertEquals } from "@std/assert"; Deno.test("default table chars", () => { assertEquals( diff --git a/table/test/column_test.ts b/table/test/column_test.ts index c5175008..efa0082c 100644 --- a/table/test/column_test.ts +++ b/table/test/column_test.ts @@ -1,5 +1,6 @@ import { Table } from "../table.ts"; -import { assertSnapshot, assertType, IsExact } from "../../dev_deps.ts"; +import { assertType, IsExact } from "@std/testing/types"; +import { assertSnapshot } from "@std/testing/snapshot"; import { Row } from "../row.ts"; import { Cell } from "../cell.ts"; diff --git a/table/test/span_test.ts b/table/test/span_test.ts index 56d3086a..6769bdbc 100644 --- a/table/test/span_test.ts +++ b/table/test/span_test.ts @@ -1,6 +1,6 @@ import { Cell } from "../cell.ts"; import { Table } from "../table.ts"; -import { assertEquals } from "../../dev_deps.ts"; +import { assertEquals } from "@std/assert"; Deno.test("should allow undefined cell values", () => { assertEquals( diff --git a/table/test/special_chars.ts b/table/test/special_chars.ts index 3f94a3be..05505546 100644 --- a/table/test/special_chars.ts +++ b/table/test/special_chars.ts @@ -1,5 +1,5 @@ import { Table } from "../table.ts"; -import { assertEquals } from "../../dev_deps.ts"; +import { assertEquals } from "@std/assert"; Deno.test("table - special chars - chinese characters", () => { assertEquals( diff --git a/table/test/table_test.ts b/table/test/table_test.ts index 3af9b3ea..9d16fe11 100644 --- a/table/test/table_test.ts +++ b/table/test/table_test.ts @@ -3,7 +3,7 @@ import { assertEquals, assertStrictEquals, assertThrows, -} from "../../dev_deps.ts"; +} from "@std/assert"; import { Row } from "../row.ts"; Deno.test("simple table", () => { diff --git a/table/test/utils_test.ts b/table/test/utils_test.ts index 5f7939d0..c2ea94a9 100644 --- a/table/test/utils_test.ts +++ b/table/test/utils_test.ts @@ -1,4 +1,4 @@ -import { assertEquals } from "../../dev_deps.ts"; +import { assertEquals } from "@std/assert"; import { consumeWords } from "../consume_words.ts"; const str = diff --git a/testing/deps.ts b/testing/deps.ts deleted file mode 100644 index 84d3000e..00000000 --- a/testing/deps.ts +++ /dev/null @@ -1,8 +0,0 @@ -export { AssertionError } from "@std/assert/assertion_error"; -export { assertSnapshot } from "@std/testing/snapshot"; -export { red } from "@std/fmt/colors"; -export { - basename, - dirname, - fromFileUrl, -} from "@std/path"; diff --git a/testing/snapshot.ts b/testing/snapshot.ts index 282971aa..7d43f836 100644 --- a/testing/snapshot.ts +++ b/testing/snapshot.ts @@ -1,6 +1,9 @@ import { eraseDown } from "../ansi/ansi_escapes.ts"; import { quoteString } from "./_quote_string.ts"; -import { AssertionError, assertSnapshot, basename, red } from "./deps.ts"; +import { basename } from "@std/path"; +import { red } from "@std/fmt/colors"; +import { assertSnapshot } from "@std/testing/snapshot"; +import { AssertionError } from "@std/assert/assertion_error"; /** Snapshot test step options. */ export interface SnapshotTestStep { diff --git a/testing/snapshot_test.ts b/testing/snapshot_test.ts index 715520e8..d928d4e7 100644 --- a/testing/snapshot_test.ts +++ b/testing/snapshot_test.ts @@ -1,6 +1,7 @@ -import { assert, assertSnapshot } from "../dev_deps.ts"; +import { assert } from "@std/assert"; +import { assertSnapshot } from "@std/testing/snapshot"; import { quoteString } from "./_quote_string.ts"; -import { dirname, fromFileUrl } from "./deps.ts"; +import { dirname, fromFileUrl } from "@std/path"; Deno.test({ name: "should run snapshot tests", From be0f0d2841a932a0e75689e83da0fc106c2f8c47 Mon Sep 17 00:00:00 2001 From: Julien Oculi Date: Sat, 9 Mar 2024 00:47:19 +0100 Subject: [PATCH 13/47] ci: publish on release and dry run on main push --- .github/workflows/publish.yml | 40 ++++++++++++++++++++++++----------- 1 file changed, 28 insertions(+), 12 deletions(-) diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index c9d3c0ae..4f689505 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -1,17 +1,33 @@ name: Publish on: - push: - branches: - - main + push: + branches: [main] + release: + types: [published] + +env: + DENO_UNSTABLE_WORKSPACES: true jobs: - publish: - runs-on: ubuntu-latest - permissions: - contents: read - id-token: write - steps: - - uses: actions/checkout@v4 - - uses: denoland/setup-deno@v1 - - run: deno publish + publish: + runs-on: ubuntu-latest + + permissions: + contents: read + id-token: write + + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Set up Deno + uses: denoland/setup-deno@v1 + + - name: Publish (dry run) + if: github.event_name == 'push' + run: deno publish --dry-run + + - name: Publish + if: github.event_name == 'release' + run: deno publish From 587cfd103bec5a166c0e979066426f1e9c85fbb5 Mon Sep 17 00:00:00 2001 From: Julien Oculi Date: Sat, 9 Mar 2024 00:55:44 +0100 Subject: [PATCH 14/47] fix: update missing import --- command/help/_help_generator.ts | 2 +- prompt/test/integration/checkbox_test.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/command/help/_help_generator.ts b/command/help/_help_generator.ts index 2596e5c8..92b74411 100644 --- a/command/help/_help_generator.ts +++ b/command/help/_help_generator.ts @@ -13,7 +13,7 @@ import { red, setColorEnabled, yellow, -} from "../deps.ts"; +} from "@std/fmt/colors"; import { Type } from "../type.ts"; import type { Argument, EnvVar, Example, Option } from "../types.ts"; diff --git a/prompt/test/integration/checkbox_test.ts b/prompt/test/integration/checkbox_test.ts index 25904d8d..28a598f0 100644 --- a/prompt/test/integration/checkbox_test.ts +++ b/prompt/test/integration/checkbox_test.ts @@ -1,5 +1,5 @@ import { ansi } from "../../../ansi/ansi.ts"; -import { format } from "../../../dev_deps.ts"; +import { format } from "@std/datetime/format"; import { Checkbox } from "../../checkbox.ts"; import { snapshotTest } from "../../../testing/snapshot.ts"; From df78f5869833da6ef98c8f94bd7ec6c6b3390506 Mon Sep 17 00:00:00 2001 From: JOTSR <58234376+JOTSR@users.noreply.github.com> Date: Thu, 14 Mar 2024 00:33:26 +0100 Subject: [PATCH 15/47] refactor: dissociate examples imports Co-authored-by: Benjamin Fischer <61995275+c4spar@users.noreply.github.com> --- examples/ansi.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/ansi.ts b/examples/ansi.ts index d4b24fc9..894304d3 100644 --- a/examples/ansi.ts +++ b/examples/ansi.ts @@ -1,7 +1,7 @@ #!/usr/bin/env -S deno run import { colors, tty } from "../ansi/mod.ts"; -import { delay } from "@std/async/delay"; +import { delay } from "jsr:@std/async@0.217/delay"; const error = colors.bold.red; const warn = colors.bold.yellow; From f06d9c1af801fd0f77fa249cfc5d1511ed184053 Mon Sep 17 00:00:00 2001 From: Julien Oculi Date: Thu, 14 Mar 2024 22:31:02 +0100 Subject: [PATCH 16/47] fix: :package: remove `examples` from workspace Remove `examples` directory from workspace to disable `deno publish` for it. --- deno.jsonc | 1 - 1 file changed, 1 deletion(-) diff --git a/deno.jsonc b/deno.jsonc index 66f25eba..da2963ac 100644 --- a/deno.jsonc +++ b/deno.jsonc @@ -4,7 +4,6 @@ "workspaces": [ "ansi", "command", - "examples", "flags", "keycode", "keypress", From 706e2c9e516e9c9fcc433c10533230c31ea91bd4 Mon Sep 17 00:00:00 2001 From: Julien Oculi Date: Thu, 14 Mar 2024 22:32:05 +0100 Subject: [PATCH 17/47] style: :art: apply `deno fmt` to harmonize sources --- ansi/colors_test.ts | 2 +- command/command.ts | 11 ++++++++++- command/test/command/action_test.ts | 11 ++--------- command/test/command/arguments_test.ts | 10 ++-------- command/test/command/error_handler_test.ts | 11 ++--------- command/test/command/generic_types_test.ts | 6 +----- command/test/command/standalone_test.ts | 10 ++-------- command/test/command/sub_command_test.ts | 6 +----- command/test/option/action_test.ts | 11 ++--------- command/test/type/file_test.ts | 5 +---- prompt/_generic_list.ts | 5 ++++- prompt/_generic_prompt.ts | 2 +- prompt/_generic_suggestions.ts | 14 ++------------ prompt/test/integration/prompt_test.ts | 2 +- prompt/test/prompt_list_test.ts | 5 +---- table/test/table_test.ts | 6 +----- 16 files changed, 34 insertions(+), 83 deletions(-) diff --git a/ansi/colors_test.ts b/ansi/colors_test.ts index 338d608c..2932655d 100644 --- a/ansi/colors_test.ts +++ b/ansi/colors_test.ts @@ -1,5 +1,5 @@ import { assertEquals } from "@std/assert"; -import { underline, bold, red } from "@std/fmt/colors"; +import { bold, red, underline } from "@std/fmt/colors"; import { colors } from "./colors.ts"; Deno.test({ diff --git a/command/command.ts b/command/command.ts index 8d027f4d..199d7460 100644 --- a/command/command.ts +++ b/command/command.ts @@ -2798,7 +2798,16 @@ export class Command< } /** Get completions. */ - public getCompletions(): Completion[] { + public getCompletions(): Completion< + any, + any, + any, + any, + any, + any, + any, + any + >[] { return this.getGlobalCompletions().concat(this.getBaseCompletions()); } diff --git a/command/test/command/action_test.ts b/command/test/command/action_test.ts index e2a9851f..5263ee07 100644 --- a/command/test/command/action_test.ts +++ b/command/test/command/action_test.ts @@ -1,13 +1,6 @@ import { assertEquals } from "@std/assert"; -import { - assertSpyCall, - assertSpyCalls, - spy, -} from "@std/testing/mock"; -import { - assertType, - IsExact, -} from "@std/testing/types"; +import { assertSpyCall, assertSpyCalls, spy } from "@std/testing/mock"; +import { assertType, IsExact } from "@std/testing/types"; import { Command } from "../../command.ts"; interface IStats { diff --git a/command/test/command/arguments_test.ts b/command/test/command/arguments_test.ts index 540de37b..d4e9c3d4 100644 --- a/command/test/command/arguments_test.ts +++ b/command/test/command/arguments_test.ts @@ -1,11 +1,5 @@ -import { - assertEquals, - assertRejects, -} from "@std/assert"; -import { - describe, - it, -} from "@std/testing/bdd"; +import { assertEquals, assertRejects } from "@std/assert"; +import { describe, it } from "@std/testing/bdd"; import type { ArgumentValue } from "../../../flags/types.ts"; import { ValidationError } from "../../_errors.ts"; import { Command } from "../../command.ts"; diff --git a/command/test/command/error_handler_test.ts b/command/test/command/error_handler_test.ts index d48e9cce..b58fb0fa 100644 --- a/command/test/command/error_handler_test.ts +++ b/command/test/command/error_handler_test.ts @@ -1,12 +1,5 @@ -import { - assertEquals, - assertInstanceOf, - assertRejects, -} from "@std/assert"; -import { - assertSpyCalls, - spy, -} from "@std/testing/mock"; +import { assertEquals, assertInstanceOf, assertRejects } from "@std/assert"; +import { assertSpyCalls, spy } from "@std/testing/mock"; import { Command, ErrorHandler, ValidationError } from "../../mod.ts"; Deno.test("[command] should call error handler on error", async () => { diff --git a/command/test/command/generic_types_test.ts b/command/test/command/generic_types_test.ts index 55ffd537..d122f544 100644 --- a/command/test/command/generic_types_test.ts +++ b/command/test/command/generic_types_test.ts @@ -1,9 +1,5 @@ import { Command, EnumType } from "../../mod.ts"; -import { - assert, - IsAny, - IsExact, -} from "conditional_type_checks"; +import { assert, IsAny, IsExact } from "conditional_type_checks"; // Not required to execute this code, only type check. (() => { diff --git a/command/test/command/standalone_test.ts b/command/test/command/standalone_test.ts index 5aff39f6..0d43cf4f 100644 --- a/command/test/command/standalone_test.ts +++ b/command/test/command/standalone_test.ts @@ -1,11 +1,5 @@ -import { - assertEquals, - assertRejects, -} from "@std/assert"; -import { - assertSpyCalls, - spy, -} from "@std/testing/mock"; +import { assertEquals, assertRejects } from "@std/assert"; +import { assertSpyCalls, spy } from "@std/testing/mock"; import { Command } from "../../command.ts"; Deno.test("[command] should execute standalone option action", async () => { diff --git a/command/test/command/sub_command_test.ts b/command/test/command/sub_command_test.ts index f9cc086a..33c5d42e 100644 --- a/command/test/command/sub_command_test.ts +++ b/command/test/command/sub_command_test.ts @@ -1,8 +1,4 @@ -import { - assertEquals, - assertRejects, - assertThrows, -} from "@std/assert"; +import { assertEquals, assertRejects, assertThrows } from "@std/assert"; import { Command } from "../../command.ts"; const version = "1.0.0"; diff --git a/command/test/option/action_test.ts b/command/test/option/action_test.ts index 6e893113..6cecac0a 100644 --- a/command/test/option/action_test.ts +++ b/command/test/option/action_test.ts @@ -1,12 +1,5 @@ -import { - assert, - assertEquals, -} from "@std/assert"; -import { - assertSpyCall, - assertSpyCalls, - spy, -} from "@std/testing/mock"; +import { assert, assertEquals } from "@std/assert"; +import { assertSpyCall, assertSpyCalls, spy } from "@std/testing/mock"; import sinon from "sinon"; import { Command } from "../../command.ts"; diff --git a/command/test/type/file_test.ts b/command/test/type/file_test.ts index 2e65be4c..52ed80ab 100644 --- a/command/test/type/file_test.ts +++ b/command/test/type/file_test.ts @@ -1,7 +1,4 @@ -import { - assert, - IsExact, -} from "conditional_type_checks"; +import { assert, IsExact } from "conditional_type_checks"; import { assertEquals } from "@std/assert"; import { Command } from "../../command.ts"; diff --git a/prompt/_generic_list.ts b/prompt/_generic_list.ts index 55198dee..1ada4225 100644 --- a/prompt/_generic_list.ts +++ b/prompt/_generic_list.ts @@ -450,7 +450,10 @@ export abstract class GenericList< return this.settings.indent + " ".repeat(indentLevel); } - protected getListItemPointer(option: TOption | TGroup, isSelected?: boolean): string { + protected getListItemPointer( + option: TOption | TGroup, + isSelected?: boolean, + ): string { if (!isSelected) { return " "; } diff --git a/prompt/_generic_prompt.ts b/prompt/_generic_prompt.ts index 8e3a6a45..b6d2c599 100644 --- a/prompt/_generic_prompt.ts +++ b/prompt/_generic_prompt.ts @@ -9,7 +9,7 @@ import { italic, red, stripColor, - yellow + yellow, } from "@std/fmt/colors"; import { Reader, WriterSync } from "@std/io/types"; import { Figures } from "./_figures.ts"; diff --git a/prompt/_generic_suggestions.ts b/prompt/_generic_suggestions.ts index 149eb4cc..efc41ee4 100644 --- a/prompt/_generic_suggestions.ts +++ b/prompt/_generic_suggestions.ts @@ -5,18 +5,8 @@ import { GenericInputPromptOptions, GenericInputPromptSettings, } from "./_generic_input.ts"; -import { - bold, - brightBlue, - dim, - underline, - stripColor, -} from "@std/fmt/colors"; -import { - dirname, - join, - normalize, -} from "@std/path" +import { bold, brightBlue, dim, stripColor, underline } from "@std/fmt/colors"; +import { dirname, join, normalize } from "@std/path"; import { Figures, getFiguresByKeys } from "./_figures.ts"; import { distance } from "../_utils/distance.ts"; diff --git a/prompt/test/integration/prompt_test.ts b/prompt/test/integration/prompt_test.ts index ae31acae..59f433c4 100644 --- a/prompt/test/integration/prompt_test.ts +++ b/prompt/test/integration/prompt_test.ts @@ -1,6 +1,6 @@ import { ansi } from "../../../ansi/ansi.ts"; import { assertEquals } from "@std/assert"; -import { IsExact, assertType } from "@std/testing/types"; +import { assertType, IsExact } from "@std/testing/types"; import { Checkbox, CheckboxOptions } from "../../checkbox.ts"; import { Confirm } from "../../confirm.ts"; import { Input } from "../../input.ts"; diff --git a/prompt/test/prompt_list_test.ts b/prompt/test/prompt_list_test.ts index 505b1668..4893b564 100644 --- a/prompt/test/prompt_list_test.ts +++ b/prompt/test/prompt_list_test.ts @@ -1,7 +1,4 @@ -import { - assert, - IsExact, -} from "conditional_type_checks"; +import { assert, IsExact } from "conditional_type_checks"; import { assertEquals, assertRejects } from "@std/assert"; import { inject, prompt } from "../prompt.ts"; import { Checkbox } from "../checkbox.ts"; diff --git a/table/test/table_test.ts b/table/test/table_test.ts index 9d16fe11..c2008416 100644 --- a/table/test/table_test.ts +++ b/table/test/table_test.ts @@ -1,9 +1,5 @@ import { Table } from "../table.ts"; -import { - assertEquals, - assertStrictEquals, - assertThrows, -} from "@std/assert"; +import { assertEquals, assertStrictEquals, assertThrows } from "@std/assert"; import { Row } from "../row.ts"; Deno.test("simple table", () => { From 3513bf4b52376b8ab0c281853ffd62335883261a Mon Sep 17 00:00:00 2001 From: Benjamin Fischer Date: Sun, 17 Mar 2024 22:26:58 +0100 Subject: [PATCH 18/47] fix cross package imports --- command/_utils.ts | 2 +- command/command.ts | 3 +-- command/help/_help_generator.ts | 2 +- command/types.ts | 2 +- command/types/boolean.ts | 2 +- command/types/integer.ts | 2 +- command/types/number.ts | 2 +- command/types/string.ts | 2 +- command/upgrade/provider.ts | 2 +- deno.jsonc | 8 ++++++++ keypress/mod.ts | 2 +- prompt/_generic_input.ts | 2 +- prompt/_generic_list.ts | 2 +- prompt/_generic_prompt.ts | 5 ++--- prompt/_generic_suggestions.ts | 2 +- prompt/checkbox.ts | 2 +- prompt/number.ts | 2 +- prompt/prompt.ts | 2 +- prompt/toggle.ts | 2 +- testing/snapshot.ts | 4 ++-- 20 files changed, 29 insertions(+), 23 deletions(-) diff --git a/command/_utils.ts b/command/_utils.ts index 1bab54f4..1e2885de 100644 --- a/command/_utils.ts +++ b/command/_utils.ts @@ -3,7 +3,7 @@ import { UnexpectedRequiredArgumentError, } from "../flags/_errors.ts"; import { didYouMean } from "../flags/_utils.ts"; -import { OptionType } from "../flags/deprecated.ts"; +import { OptionType } from "@cliffy/flags"; import type { Command } from "./command.ts"; import type { Argument } from "./types.ts"; diff --git a/command/command.ts b/command/command.ts index 199d7460..b1f07054 100644 --- a/command/command.ts +++ b/command/command.ts @@ -4,8 +4,7 @@ import { ValidationError as FlagsValidationError, } from "../flags/_errors.ts"; import { underscoreToCamelCase } from "../flags/_utils.ts"; -import { parseFlags } from "../flags/flags.ts"; -import type { ParseFlagsContext } from "../flags/types.ts"; +import { parseFlags, type ParseFlagsContext } from "@cliffy/flags"; import { getDescription, parseArgumentsDefinition, diff --git a/command/help/_help_generator.ts b/command/help/_help_generator.ts index 92b74411..b33f8f22 100644 --- a/command/help/_help_generator.ts +++ b/command/help/_help_generator.ts @@ -1,5 +1,5 @@ import { getDefaultValue, getFlag } from "../../flags/_utils.ts"; -import { Table } from "../../table/table.ts"; +import { Table } from "@cliffy/table"; import { dedent, getDescription, parseArgumentsDefinition } from "../_utils.ts"; import type { Command } from "../command.ts"; import { diff --git a/command/types.ts b/command/types.ts index ed2bd181..d4ae305c 100644 --- a/command/types.ts +++ b/command/types.ts @@ -7,7 +7,7 @@ import type { FlagOptions, TypeHandler, ValueHandler, -} from "../flags/types.ts"; +} from "@cliffy/flags"; import { MapTypes } from "./_argument_types.ts"; import type { ValidationError } from "./_errors.ts"; import type { Command } from "./command.ts"; diff --git a/command/types/boolean.ts b/command/types/boolean.ts index 4e1ff5fa..a0818736 100644 --- a/command/types/boolean.ts +++ b/command/types/boolean.ts @@ -1,4 +1,4 @@ -import { boolean } from "../../flags/types/boolean.ts"; +import { boolean } from "@cliffy/flags"; import type { ArgumentValue } from "../types.ts"; import { Type } from "../type.ts"; diff --git a/command/types/integer.ts b/command/types/integer.ts index b45626a7..4c495cdd 100644 --- a/command/types/integer.ts +++ b/command/types/integer.ts @@ -1,6 +1,6 @@ import { Type } from "../type.ts"; import type { ArgumentValue } from "../types.ts"; -import { integer } from "../../flags/types/integer.ts"; +import { integer } from "@cliffy/flags"; /** Integer type. */ export class IntegerType extends Type { diff --git a/command/types/number.ts b/command/types/number.ts index 72c811ea..0812e211 100644 --- a/command/types/number.ts +++ b/command/types/number.ts @@ -1,4 +1,4 @@ -import { number } from "../../flags/types/number.ts"; +import { number } from "@cliffy/flags"; import { Type } from "../type.ts"; import type { ArgumentValue } from "../types.ts"; diff --git a/command/types/string.ts b/command/types/string.ts index 76126b9b..65e877ef 100644 --- a/command/types/string.ts +++ b/command/types/string.ts @@ -1,4 +1,4 @@ -import { string } from "../../flags/types/string.ts"; +import { string } from "@cliffy/flags"; import { Type } from "../type.ts"; import type { ArgumentValue } from "../types.ts"; diff --git a/command/upgrade/provider.ts b/command/upgrade/provider.ts index 4dc27642..184a4abd 100644 --- a/command/upgrade/provider.ts +++ b/command/upgrade/provider.ts @@ -1,6 +1,6 @@ import { bold, brightBlue, cyan, green, red, yellow } from "@std/fmt/colors"; import { ValidationError } from "../_errors.ts"; -import { Table } from "../../table/table.ts"; +import { Table } from "@cliffy/table"; export interface Versions { latest: string; diff --git a/deno.jsonc b/deno.jsonc index da2963ac..d7e9131e 100644 --- a/deno.jsonc +++ b/deno.jsonc @@ -32,6 +32,14 @@ // "update": "deno run --allow-read=./ --allow-write=./ https://deno.land/x/udd@0.8.2/main.ts" globs are a bit weird in tasks: https://github.com/denoland/deno/discussions/15625 }, "imports": { + "@cliffy/ansi": "jsr:@cliffy/ansi@1.0.0-rc.3", + "@cliffy/command": "jsr:@cliffy/command@1.0.0-rc.3", + "@cliffy/flags": "jsr:@cliffy/flags@1.0.0-rc.3", + "@cliffy/keycode": "jsr:@cliffy/keycode@1.0.0-rc.3", + "@cliffy/keypress": "jsr:@cliffy/keypress@1.0.0-rc.3", + "@cliffy/prompt": "jsr:@cliffy/prompt@1.0.0-rc.3", + "@cliffy/table": "jsr:@cliffy/table@1.0.0-rc.3", + "@cliffy/testing": "jsr:@cliffy/testing@1.0.0-rc.3", "@std/assert": "jsr:@std/assert@0.217", "@std/async": "jsr:@std/async@0.217", "@std/console": "jsr:@std/console@0.217", diff --git a/keypress/mod.ts b/keypress/mod.ts index 842774b2..5f8eacd6 100644 --- a/keypress/mod.ts +++ b/keypress/mod.ts @@ -1,4 +1,4 @@ -import { KeyCode, parse } from "../keycode/mod.ts"; +import { KeyCode, parse } from "@cliffy/keycode"; type KeyPressEventType = "keydown"; diff --git a/prompt/_generic_input.ts b/prompt/_generic_input.ts index 3502e529..7c3b17de 100644 --- a/prompt/_generic_input.ts +++ b/prompt/_generic_input.ts @@ -1,4 +1,4 @@ -import type { KeyCode } from "../keycode/key_code.ts"; +import type { KeyCode } from "@cliffy/keycode"; import { GenericPrompt, GenericPromptKeys, diff --git a/prompt/_generic_list.ts b/prompt/_generic_list.ts index 1ada4225..8a0befd4 100644 --- a/prompt/_generic_list.ts +++ b/prompt/_generic_list.ts @@ -1,4 +1,4 @@ -import type { KeyCode } from "../keycode/key_code.ts"; +import type { KeyCode } from "@cliffy/keycode"; import { GenericInput, GenericInputKeys, diff --git a/prompt/_generic_prompt.ts b/prompt/_generic_prompt.ts index b6d2c599..4efdf02b 100644 --- a/prompt/_generic_prompt.ts +++ b/prompt/_generic_prompt.ts @@ -1,6 +1,5 @@ -import type { Cursor } from "../ansi/cursor_position.ts"; -import { Tty, tty } from "../ansi/tty.ts"; -import { KeyCode, parse } from "../keycode/key_code.ts"; +import { Tty, tty, type Cursor } from "@cliffy/ansi"; +import { KeyCode, parse } from "@cliffy/keycode"; import { bold, brightBlue, diff --git a/prompt/_generic_suggestions.ts b/prompt/_generic_suggestions.ts index efc41ee4..d5624f83 100644 --- a/prompt/_generic_suggestions.ts +++ b/prompt/_generic_suggestions.ts @@ -1,4 +1,4 @@ -import type { KeyCode } from "../keycode/key_code.ts"; +import type { KeyCode } from "@cliffy/keycode"; import { GenericInput, GenericInputKeys, diff --git a/prompt/checkbox.ts b/prompt/checkbox.ts index a259e630..f78b6dd0 100644 --- a/prompt/checkbox.ts +++ b/prompt/checkbox.ts @@ -1,4 +1,4 @@ -import type { KeyCode } from "../keycode/mod.ts"; +import type { KeyCode } from "@cliffy/keycode"; import { WidenType } from "./_utils.ts"; import { brightBlue, dim, green, red } from "@std/fmt/colors"; import { Figures, getFiguresByKeys } from "./_figures.ts"; diff --git a/prompt/number.ts b/prompt/number.ts index 3b1c6160..b3857252 100644 --- a/prompt/number.ts +++ b/prompt/number.ts @@ -1,4 +1,4 @@ -import type { KeyCode } from "../keycode/key_code.ts"; +import type { KeyCode } from "@cliffy/keycode"; import { GenericPrompt } from "./_generic_prompt.ts"; import { GenericSuggestions, diff --git a/prompt/prompt.ts b/prompt/prompt.ts index c3da9391..5d41a725 100644 --- a/prompt/prompt.ts +++ b/prompt/prompt.ts @@ -1,6 +1,6 @@ // deno-lint-ignore-file no-explicit-any ban-types -import { Tty, tty } from "../ansi/tty.ts"; +import { Tty, tty } from "@cliffy/ansi"; import { GenericPrompt, GenericPromptOptions, diff --git a/prompt/toggle.ts b/prompt/toggle.ts index a1f72bf1..f5a2893c 100644 --- a/prompt/toggle.ts +++ b/prompt/toggle.ts @@ -1,4 +1,4 @@ -import type { KeyCode } from "../keycode/key_code.ts"; +import type { KeyCode } from "@cliffy/keycode"; import { dim, underline } from "@std/fmt/colors"; import { GenericPrompt, diff --git a/testing/snapshot.ts b/testing/snapshot.ts index 7d43f836..f86ea822 100644 --- a/testing/snapshot.ts +++ b/testing/snapshot.ts @@ -1,4 +1,4 @@ -import { eraseDown } from "../ansi/ansi_escapes.ts"; +import { eraseDown } from "@cliffy/ansi"; import { quoteString } from "./_quote_string.ts"; import { basename } from "@std/path"; import { red } from "@std/fmt/colors"; @@ -83,7 +83,7 @@ const encoder = new TextEncoder(); * * ```ts * import { snapshotTest } from "./snapshot.ts"; - * import { Input } from "../prompt/input.ts"; + * import { Input } from "@cliffy/prompt/input"; * * await snapshotTest({ * name: "test name", From 2a8f296727c83fe16d02e987c713ad6b0aed55a0 Mon Sep 17 00:00:00 2001 From: Julien Oculi Date: Mon, 18 Mar 2024 16:57:29 +0100 Subject: [PATCH 19/47] fix: :construction_worker: `deno.jsonc` not loaded during tests in `snapshot.ts` --- testing/snapshot.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/testing/snapshot.ts b/testing/snapshot.ts index 7d43f836..2e6864ad 100644 --- a/testing/snapshot.ts +++ b/testing/snapshot.ts @@ -174,6 +174,7 @@ async function runPrompt( stderr: "piped", args: [ "run", + "-c=deno.jsonc", ...options.denoArgs ?? ["--allow-env=SNAPSHOT_TEST_NAME"], options.meta.url, ...options.args ?? [], From 31c9d734b6dfa8af20682934de57204c774986e0 Mon Sep 17 00:00:00 2001 From: Julien Oculi Date: Mon, 18 Mar 2024 17:06:13 +0100 Subject: [PATCH 20/47] style: fix fmt --- prompt/_generic_prompt.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/prompt/_generic_prompt.ts b/prompt/_generic_prompt.ts index 4efdf02b..316e6bfd 100644 --- a/prompt/_generic_prompt.ts +++ b/prompt/_generic_prompt.ts @@ -1,4 +1,4 @@ -import { Tty, tty, type Cursor } from "@cliffy/ansi"; +import { type Cursor, Tty, tty } from "@cliffy/ansi"; import { KeyCode, parse } from "@cliffy/keycode"; import { bold, From 269648c079dfff7e0d62c538c6c5a39356548caf Mon Sep 17 00:00:00 2001 From: Benjamin Fischer Date: Tue, 19 Mar 2024 00:44:29 +0100 Subject: [PATCH 21/47] import ValidationError from @cliffy/flags --- command/command.ts | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/command/command.ts b/command/command.ts index d1cf7f2d..5b0dd04c 100644 --- a/command/command.ts +++ b/command/command.ts @@ -1,9 +1,10 @@ // deno-lint-ignore-file no-explicit-any +import { UnknownTypeError } from "../flags/_errors.ts"; import { - UnknownTypeError, + parseFlags, + type ParseFlagsContext, ValidationError as FlagsValidationError, -} from "../flags/_errors.ts"; -import { parseFlags, type ParseFlagsContext } from "@cliffy/flags"; +} from "@cliffy/flags"; import { getDescription, parseArgumentsDefinition, From 0c34bbdc3208b6cd66494ff3db453cb6202efbe6 Mon Sep 17 00:00:00 2001 From: Julien Oculi Date: Tue, 19 Mar 2024 17:46:17 +0100 Subject: [PATCH 22/47] refactor: :recycle: don't force `deno.jsonc` prefers default options --- testing/snapshot.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/testing/snapshot.ts b/testing/snapshot.ts index b6d4a485..b2582a64 100644 --- a/testing/snapshot.ts +++ b/testing/snapshot.ts @@ -174,8 +174,7 @@ async function runPrompt( stderr: "piped", args: [ "run", - "-c=deno.jsonc", - ...options.denoArgs ?? ["--allow-env=SNAPSHOT_TEST_NAME"], + ...options.denoArgs ?? ["--allow-env=SNAPSHOT_TEST_NAME", "-c=deno.jsonc"], options.meta.url, ...options.args ?? [], ...step?.args ?? [], From 3016d1fd4821d703352f537cc3c618bb479ce880 Mon Sep 17 00:00:00 2001 From: Benjamin Fischer Date: Tue, 19 Mar 2024 19:51:25 +0100 Subject: [PATCH 23/47] remove examples/deno.json --- examples/deno.json | 5 ----- 1 file changed, 5 deletions(-) delete mode 100644 examples/deno.json diff --git a/examples/deno.json b/examples/deno.json deleted file mode 100644 index 16baedc6..00000000 --- a/examples/deno.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "name": "@cliffy/examples", - "version": "1.0.0-rc.3", - "lock": false -} From 87a954bf842650c8c981ac4e2a4f45fecbdbfc82 Mon Sep 17 00:00:00 2001 From: Benjamin Fischer Date: Tue, 19 Mar 2024 21:33:38 +0100 Subject: [PATCH 24/47] fix imports --- command/_utils.ts | 4 ++-- command/command.ts | 2 +- command/types/enum.ts | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/command/_utils.ts b/command/_utils.ts index e73bb546..7b8d2156 100644 --- a/command/_utils.ts +++ b/command/_utils.ts @@ -1,9 +1,9 @@ import { closestString } from "https://deno.land/std@0.216.0/text/closest_string.ts"; import { + OptionType, UnexpectedArgumentAfterVariadicArgumentError, UnexpectedRequiredArgumentError, -} from "../flags/_errors.ts"; -import { OptionType } from "@cliffy/flags"; +} from "@cliffy/flags"; import type { Command } from "./command.ts"; import type { Argument } from "./types.ts"; diff --git a/command/command.ts b/command/command.ts index 5b0dd04c..57970071 100644 --- a/command/command.ts +++ b/command/command.ts @@ -1,8 +1,8 @@ // deno-lint-ignore-file no-explicit-any -import { UnknownTypeError } from "../flags/_errors.ts"; import { parseFlags, type ParseFlagsContext, + UnknownTypeError, ValidationError as FlagsValidationError, } from "@cliffy/flags"; import { diff --git a/command/types/enum.ts b/command/types/enum.ts index d6bc3ed5..e5377a46 100644 --- a/command/types/enum.ts +++ b/command/types/enum.ts @@ -1,6 +1,6 @@ import { Type } from "../type.ts"; import type { ArgumentValue } from "../types.ts"; -import { InvalidTypeError } from "../../flags/_errors.ts"; +import { InvalidTypeError } from "@cliffy/flags"; /** Enum type. Allows only provided values. */ export class EnumType From d7e3de67c98401c2a26b9701885c1e71d8c5c48b Mon Sep 17 00:00:00 2001 From: Benjamin Fischer Date: Tue, 19 Mar 2024 21:45:38 +0100 Subject: [PATCH 25/47] fix test imports --- command/test/command/arguments_test.ts | 2 +- prompt/test/integration/checkbox_group_breadcrumb_test.ts | 4 ++-- prompt/test/integration/checkbox_group_test.ts | 4 ++-- prompt/test/integration/checkbox_test.ts | 4 ++-- prompt/test/integration/checkbox_value_test.ts | 4 ++-- prompt/test/integration/confirm_test.ts | 2 +- prompt/test/integration/input_test.ts | 2 +- prompt/test/integration/list_test.ts | 2 +- prompt/test/integration/number_test.ts | 4 ++-- prompt/test/integration/prompt_test.ts | 4 ++-- prompt/test/integration/secret_test.ts | 2 +- prompt/test/integration/select_group_breadcrumb_test.ts | 4 ++-- prompt/test/integration/select_group_test.ts | 4 ++-- prompt/test/integration/select_test.ts | 4 ++-- prompt/test/integration/toggle_test.ts | 2 +- 15 files changed, 24 insertions(+), 24 deletions(-) diff --git a/command/test/command/arguments_test.ts b/command/test/command/arguments_test.ts index d4e9c3d4..68576a09 100644 --- a/command/test/command/arguments_test.ts +++ b/command/test/command/arguments_test.ts @@ -1,6 +1,6 @@ import { assertEquals, assertRejects } from "@std/assert"; import { describe, it } from "@std/testing/bdd"; -import type { ArgumentValue } from "../../../flags/types.ts"; +import type { ArgumentValue } from "@cliffy/flags"; import { ValidationError } from "../../_errors.ts"; import { Command } from "../../command.ts"; diff --git a/prompt/test/integration/checkbox_group_breadcrumb_test.ts b/prompt/test/integration/checkbox_group_breadcrumb_test.ts index c4565ea1..79407b34 100644 --- a/prompt/test/integration/checkbox_group_breadcrumb_test.ts +++ b/prompt/test/integration/checkbox_group_breadcrumb_test.ts @@ -1,5 +1,5 @@ -import { ansi } from "../../../ansi/ansi.ts"; -import { snapshotTest } from "../../../testing/snapshot.ts"; +import { ansi } from "@cliffy/ansi"; +import { snapshotTest } from "@cliffy/testing"; import { Checkbox } from "../../checkbox.ts"; await snapshotTest({ diff --git a/prompt/test/integration/checkbox_group_test.ts b/prompt/test/integration/checkbox_group_test.ts index 467cb3ba..dea7b99f 100644 --- a/prompt/test/integration/checkbox_group_test.ts +++ b/prompt/test/integration/checkbox_group_test.ts @@ -1,5 +1,5 @@ -import { ansi } from "../../../ansi/ansi.ts"; -import { snapshotTest } from "../../../testing/snapshot.ts"; +import { ansi } from "@cliffy/ansi"; +import { snapshotTest } from "@cliffy/testing"; import { Checkbox } from "../../checkbox.ts"; await snapshotTest({ diff --git a/prompt/test/integration/checkbox_test.ts b/prompt/test/integration/checkbox_test.ts index 28a598f0..1909302d 100644 --- a/prompt/test/integration/checkbox_test.ts +++ b/prompt/test/integration/checkbox_test.ts @@ -1,7 +1,7 @@ -import { ansi } from "../../../ansi/ansi.ts"; +import { ansi } from "@cliffy/ansi"; import { format } from "@std/datetime/format"; import { Checkbox } from "../../checkbox.ts"; -import { snapshotTest } from "../../../testing/snapshot.ts"; +import { snapshotTest } from "@cliffy/testing"; await snapshotTest({ name: "checkbox prompt > should check an option", diff --git a/prompt/test/integration/checkbox_value_test.ts b/prompt/test/integration/checkbox_value_test.ts index 49b1d9a8..5cee2078 100644 --- a/prompt/test/integration/checkbox_value_test.ts +++ b/prompt/test/integration/checkbox_value_test.ts @@ -1,5 +1,5 @@ -import { ansi } from "../../../ansi/ansi.ts"; -import { snapshotTest } from "../../../testing/snapshot.ts"; +import { ansi } from "@cliffy/ansi"; +import { snapshotTest } from "@cliffy/testing"; import { Checkbox } from "../../checkbox.ts"; await snapshotTest({ diff --git a/prompt/test/integration/confirm_test.ts b/prompt/test/integration/confirm_test.ts index 18478c80..71a38173 100644 --- a/prompt/test/integration/confirm_test.ts +++ b/prompt/test/integration/confirm_test.ts @@ -1,5 +1,5 @@ import { Confirm } from "../../confirm.ts"; -import { snapshotTest } from "../../../testing/snapshot.ts"; +import { snapshotTest } from "@cliffy/testing"; await snapshotTest({ name: "confirm prompt", diff --git a/prompt/test/integration/input_test.ts b/prompt/test/integration/input_test.ts index 37ac03a6..e880cda5 100644 --- a/prompt/test/integration/input_test.ts +++ b/prompt/test/integration/input_test.ts @@ -1,5 +1,5 @@ import { Input } from "../../input.ts"; -import { snapshotTest } from "../../../testing/snapshot.ts"; +import { snapshotTest } from "@cliffy/testing"; await snapshotTest({ name: "input prompt", diff --git a/prompt/test/integration/list_test.ts b/prompt/test/integration/list_test.ts index d74fd2ea..c50db175 100644 --- a/prompt/test/integration/list_test.ts +++ b/prompt/test/integration/list_test.ts @@ -1,5 +1,5 @@ import { List } from "../../list.ts"; -import { snapshotTest } from "../../../testing/snapshot.ts"; +import { snapshotTest } from "@cliffy/testing"; await snapshotTest({ name: "list prompt", diff --git a/prompt/test/integration/number_test.ts b/prompt/test/integration/number_test.ts index 011bb9aa..8c5777f4 100644 --- a/prompt/test/integration/number_test.ts +++ b/prompt/test/integration/number_test.ts @@ -1,6 +1,6 @@ -import { ansi } from "../../../ansi/ansi.ts"; +import { ansi } from "@cliffy/ansi"; import { Number } from "../../number.ts"; -import { snapshotTest } from "../../../testing/snapshot.ts"; +import { snapshotTest } from "@cliffy/testing"; await snapshotTest({ name: "number prompt", diff --git a/prompt/test/integration/prompt_test.ts b/prompt/test/integration/prompt_test.ts index 59f433c4..a8052965 100644 --- a/prompt/test/integration/prompt_test.ts +++ b/prompt/test/integration/prompt_test.ts @@ -1,4 +1,4 @@ -import { ansi } from "../../../ansi/ansi.ts"; +import { ansi } from "@cliffy/ansi"; import { assertEquals } from "@std/assert"; import { assertType, IsExact } from "@std/testing/types"; import { Checkbox, CheckboxOptions } from "../../checkbox.ts"; @@ -8,7 +8,7 @@ import { Number } from "../../number.ts"; import { prompt, PromptMiddleware, PromptOptions } from "../../prompt.ts"; import { Select } from "../../select.ts"; import { Toggle } from "../../toggle.ts"; -import { snapshotTest } from "../../../testing/snapshot.ts"; +import { snapshotTest } from "@cliffy/testing"; await snapshotTest({ name: "prompt method", diff --git a/prompt/test/integration/secret_test.ts b/prompt/test/integration/secret_test.ts index ca60375a..09a2c11a 100644 --- a/prompt/test/integration/secret_test.ts +++ b/prompt/test/integration/secret_test.ts @@ -1,5 +1,5 @@ import { Secret } from "../../secret.ts"; -import { snapshotTest } from "../../../testing/snapshot.ts"; +import { snapshotTest } from "@cliffy/testing"; await snapshotTest({ name: "secret prompt", diff --git a/prompt/test/integration/select_group_breadcrumb_test.ts b/prompt/test/integration/select_group_breadcrumb_test.ts index f22746eb..ca2ac148 100644 --- a/prompt/test/integration/select_group_breadcrumb_test.ts +++ b/prompt/test/integration/select_group_breadcrumb_test.ts @@ -1,5 +1,5 @@ -import { ansi } from "../../../ansi/ansi.ts"; -import { snapshotTest } from "../../../testing/snapshot.ts"; +import { ansi } from "@cliffy/ansi"; +import { snapshotTest } from "@cliffy/testing"; import { Select } from "../../select.ts"; await snapshotTest({ diff --git a/prompt/test/integration/select_group_test.ts b/prompt/test/integration/select_group_test.ts index 07448a2f..3ca40f5d 100644 --- a/prompt/test/integration/select_group_test.ts +++ b/prompt/test/integration/select_group_test.ts @@ -1,5 +1,5 @@ -import { ansi } from "../../../ansi/ansi.ts"; -import { snapshotTest } from "../../../testing/snapshot.ts"; +import { ansi } from "@cliffy/ansi"; +import { snapshotTest } from "@cliffy/testing"; import { Select } from "../../select.ts"; await snapshotTest({ diff --git a/prompt/test/integration/select_test.ts b/prompt/test/integration/select_test.ts index 3c348d6b..5992f5d5 100644 --- a/prompt/test/integration/select_test.ts +++ b/prompt/test/integration/select_test.ts @@ -1,7 +1,7 @@ -import { ansi } from "../../../ansi/ansi.ts"; +import { ansi } from "@cliffy/ansi"; import { format } from "@std/datetime/format"; import { Select } from "../../select.ts"; -import { snapshotTest } from "../../../testing/snapshot.ts"; +import { snapshotTest } from "@cliffy/testing"; await snapshotTest({ name: "select prompt > should select an option", diff --git a/prompt/test/integration/toggle_test.ts b/prompt/test/integration/toggle_test.ts index 892e1a83..87e27d18 100644 --- a/prompt/test/integration/toggle_test.ts +++ b/prompt/test/integration/toggle_test.ts @@ -1,5 +1,5 @@ import { Toggle } from "../../toggle.ts"; -import { snapshotTest } from "../../../testing/snapshot.ts"; +import { snapshotTest } from "@cliffy/testing"; await snapshotTest({ name: "toggle prompt", From 0e6ce61139422413227c5b574e22c62c003e6bc5 Mon Sep 17 00:00:00 2001 From: Benjamin Fischer Date: Tue, 19 Mar 2024 21:46:02 +0100 Subject: [PATCH 26/47] remove config option --- testing/snapshot.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/testing/snapshot.ts b/testing/snapshot.ts index b2582a64..f86ea822 100644 --- a/testing/snapshot.ts +++ b/testing/snapshot.ts @@ -174,7 +174,7 @@ async function runPrompt( stderr: "piped", args: [ "run", - ...options.denoArgs ?? ["--allow-env=SNAPSHOT_TEST_NAME", "-c=deno.jsonc"], + ...options.denoArgs ?? ["--allow-env=SNAPSHOT_TEST_NAME"], options.meta.url, ...options.args ?? [], ...step?.args ?? [], From ef3046fa48f8197ea97ac8e8ad8b58d1f69ee2b4 Mon Sep 17 00:00:00 2001 From: Benjamin Fischer Date: Sun, 7 Apr 2024 21:59:04 +0200 Subject: [PATCH 27/47] fmt --- prompt/_generic_suggestions.ts | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/prompt/_generic_suggestions.ts b/prompt/_generic_suggestions.ts index 6fc4727a..da93358b 100644 --- a/prompt/_generic_suggestions.ts +++ b/prompt/_generic_suggestions.ts @@ -5,7 +5,13 @@ import { GenericInputPromptOptions, GenericInputPromptSettings, } from "./_generic_input.ts"; -import { bold, brightBlue, dim, stripAnsiCode, underline } from "@std/fmt/colors"; +import { + bold, + brightBlue, + dim, + stripAnsiCode, + underline, +} from "@std/fmt/colors"; import { levenshteinDistance } from "@std/text/levenshtein_distance"; import { dirname, join, normalize } from "@std/path"; import { Figures, getFiguresByKeys } from "./_figures.ts"; From 6c5bd0839634fd97dd6309bc3499709df04e1250 Mon Sep 17 00:00:00 2001 From: Benjamin Fischer Date: Sun, 7 Apr 2024 22:27:44 +0200 Subject: [PATCH 28/47] fix --- ansi/deno.json | 2 +- command/deno.json | 2 +- flags/_utils.ts | 2 +- flags/deno.json | 2 +- keycode/deno.json | 2 +- keypress/deno.json | 2 +- prompt/_generic_list.ts | 2 +- prompt/_generic_suggestions.ts | 2 +- prompt/deno.json | 2 +- table/_utils.ts | 2 +- table/deno.json | 2 +- testing/deno.json | 2 +- testing/snapshot.ts | 2 +- 13 files changed, 13 insertions(+), 13 deletions(-) diff --git a/ansi/deno.json b/ansi/deno.json index e5570f0c..f5fd7bf9 100644 --- a/ansi/deno.json +++ b/ansi/deno.json @@ -1,6 +1,6 @@ { "name": "@cliffy/ansi", - "version": "1.0.0-rc.3", + "version": "1.0.0-rc.4", "exports": "./mod.ts", "lock": false } diff --git a/command/deno.json b/command/deno.json index ba401458..1f9e0723 100644 --- a/command/deno.json +++ b/command/deno.json @@ -1,6 +1,6 @@ { "name": "@cliffy/command", - "version": "1.0.0-rc.3", + "version": "1.0.0-rc.4", "exports": { ".": "./mod.ts", "./completions": "./completions/mod.ts", diff --git a/flags/_utils.ts b/flags/_utils.ts index 9da7c85b..d8cbc4cc 100644 --- a/flags/_utils.ts +++ b/flags/_utils.ts @@ -1,5 +1,5 @@ import type { FlagOptions } from "./types.ts"; -import { closestString } from "@std/text/closest_string"; +import { closestString } from "@std/text/closest-string"; /** Convert param case string to camel case. */ export function paramCaseToCamelCase(str: string): string { diff --git a/flags/deno.json b/flags/deno.json index 79491c49..a1fe34ab 100644 --- a/flags/deno.json +++ b/flags/deno.json @@ -1,6 +1,6 @@ { "name": "@cliffy/flags", - "version": "1.0.0-rc.3", + "version": "1.0.0-rc.4", "exports": "./mod.ts", "lock": false } diff --git a/keycode/deno.json b/keycode/deno.json index 035e8545..e3253dce 100644 --- a/keycode/deno.json +++ b/keycode/deno.json @@ -1,6 +1,6 @@ { "name": "@cliffy/keycode", - "version": "1.0.0-rc.3", + "version": "1.0.0-rc.4", "exports": "./mod.ts", "lock": false } diff --git a/keypress/deno.json b/keypress/deno.json index 9838e558..99145ba1 100644 --- a/keypress/deno.json +++ b/keypress/deno.json @@ -1,6 +1,6 @@ { "name": "@cliffy/keypress", - "version": "1.0.0-rc.3", + "version": "1.0.0-rc.4", "exports": "./mod.ts", "lock": false } diff --git a/prompt/_generic_list.ts b/prompt/_generic_list.ts index 3450ee75..af60cc49 100644 --- a/prompt/_generic_list.ts +++ b/prompt/_generic_list.ts @@ -7,7 +7,7 @@ import { } from "./_generic_input.ts"; import { WidenType } from "./_utils.ts"; import { bold, brightBlue, dim, stripAnsiCode, yellow } from "@std/fmt/colors"; -import { levenshteinDistance } from "@std/text/levenshtein_distance"; +import { levenshteinDistance } from "@std/text/levenshtein-distance"; import { Figures, getFiguresByKeys } from "./_figures.ts"; type UnsupportedInputOptions = "suggestions" | "list"; diff --git a/prompt/_generic_suggestions.ts b/prompt/_generic_suggestions.ts index da93358b..c529582f 100644 --- a/prompt/_generic_suggestions.ts +++ b/prompt/_generic_suggestions.ts @@ -12,7 +12,7 @@ import { stripAnsiCode, underline, } from "@std/fmt/colors"; -import { levenshteinDistance } from "@std/text/levenshtein_distance"; +import { levenshteinDistance } from "@std/text/levenshtein-distance"; import { dirname, join, normalize } from "@std/path"; import { Figures, getFiguresByKeys } from "./_figures.ts"; diff --git a/prompt/deno.json b/prompt/deno.json index 43f69847..b7a13833 100644 --- a/prompt/deno.json +++ b/prompt/deno.json @@ -1,6 +1,6 @@ { "name": "@cliffy/prompt", - "version": "1.0.0-rc.3", + "version": "1.0.0-rc.4", "exports": { ".": "./mod.ts", "./checkbox": "./checkbox.ts", diff --git a/table/_utils.ts b/table/_utils.ts index 20336f91..55f6dee9 100644 --- a/table/_utils.ts +++ b/table/_utils.ts @@ -7,7 +7,7 @@ import { Cell, CellType } from "./cell.ts"; import { consumeWords } from "./consume_words.ts"; import { stripAnsiCode } from "@std/fmt/colors"; -import { unicodeWidth } from "@std/console/unicode_width"; +import { unicodeWidth } from "@std/console/unicode-width"; /** * Get longest cell from given row index. diff --git a/table/deno.json b/table/deno.json index 8a9b96d5..36abad50 100644 --- a/table/deno.json +++ b/table/deno.json @@ -1,6 +1,6 @@ { "name": "@cliffy/table", - "version": "1.0.0-rc.3", + "version": "1.0.0-rc.4", "exports": "./mod.ts", "lock": false } diff --git a/testing/deno.json b/testing/deno.json index e0e5dac8..ed44a545 100644 --- a/testing/deno.json +++ b/testing/deno.json @@ -1,6 +1,6 @@ { "name": "@cliffy/testing", - "version": "1.0.0-rc.3", + "version": "1.0.0-rc.4", "exports": "./mod.ts", "lock": false } diff --git a/testing/snapshot.ts b/testing/snapshot.ts index f86ea822..b21c46fe 100644 --- a/testing/snapshot.ts +++ b/testing/snapshot.ts @@ -3,7 +3,7 @@ import { quoteString } from "./_quote_string.ts"; import { basename } from "@std/path"; import { red } from "@std/fmt/colors"; import { assertSnapshot } from "@std/testing/snapshot"; -import { AssertionError } from "@std/assert/assertion_error"; +import { AssertionError } from "@std/assert/assertion-error"; /** Snapshot test step options. */ export interface SnapshotTestStep { From bfe0ddea346bb6e836351924fe5f6d4e75b0dca1 Mon Sep 17 00:00:00 2001 From: Benjamin Fischer Date: Sun, 7 Apr 2024 22:57:55 +0200 Subject: [PATCH 29/47] fix import --- command/_utils.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/command/_utils.ts b/command/_utils.ts index 51ccab9b..546e54ab 100644 --- a/command/_utils.ts +++ b/command/_utils.ts @@ -1,4 +1,4 @@ -import { closestString } from "https://deno.land/std@0.221.0/text/closest_string.ts"; +import { closestString } from "@std/text/closest-string"; import { OptionType, UnexpectedArgumentAfterVariadicArgumentError, From 297574f7f2e1f9576c2dacec9b394c2ad932d99e Mon Sep 17 00:00:00 2001 From: Benjamin Fischer Date: Tue, 9 Apr 2024 22:27:08 +0200 Subject: [PATCH 30/47] remove name and version from main deno.jsonc --- deno.jsonc | 2 -- 1 file changed, 2 deletions(-) diff --git a/deno.jsonc b/deno.jsonc index 2147ee9b..a9bf42b8 100644 --- a/deno.jsonc +++ b/deno.jsonc @@ -1,6 +1,4 @@ { - "name": "@cliffy/cliffy", - "version": "1.0.0-rc.4", "workspaces": [ "ansi", "command", From 9a7ebaebe24632da37bb7c146def0768f72d18d6 Mon Sep 17 00:00:00 2001 From: Benjamin Fischer Date: Sun, 5 May 2024 14:52:38 +0200 Subject: [PATCH 31/47] remove submodule exports from command/mod.ts --- command/mod.ts | 3 --- 1 file changed, 3 deletions(-) diff --git a/command/mod.ts b/command/mod.ts index 361e397a..4eeb1e1f 100644 --- a/command/mod.ts +++ b/command/mod.ts @@ -41,7 +41,4 @@ export { NumberType } from "./types/number.ts"; export { StringType } from "./types/string.ts"; export { Type } from "./type.ts"; export { ValidationError, type ValidationErrorOptions } from "./_errors.ts"; -export * from "./help/mod.ts"; -export * from "./upgrade/mod.ts"; -export * from "./completions/mod.ts"; export * from "./deprecated.ts"; From 00397c253dee88e6c237fc892ef068f39e10fbbf Mon Sep 17 00:00:00 2001 From: Benjamin Fischer Date: Sun, 5 May 2024 14:53:01 +0200 Subject: [PATCH 32/47] add exports to ansi/deno.json --- ansi/deno.json | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/ansi/deno.json b/ansi/deno.json index f5fd7bf9..eb10bc82 100644 --- a/ansi/deno.json +++ b/ansi/deno.json @@ -1,6 +1,12 @@ { "name": "@cliffy/ansi", "version": "1.0.0-rc.4", - "exports": "./mod.ts", - "lock": false + "exports": { + ".": "./mod.ts", + "./ansi": "./mod.ts", + "./ansi-escapes": "./ansi_escapes.ts", + "./colors": "./colors.ts", + "./cursor-position": "./cursor_position.ts", + "./tty": "./tty.ts" + } } From ee17e96515e721582cae4ac416a6e1df97ebfa69 Mon Sep 17 00:00:00 2001 From: Benjamin Fischer Date: Sun, 5 May 2024 17:33:40 +0200 Subject: [PATCH 33/47] fix imports --- command/test/integration/test.ts | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/command/test/integration/test.ts b/command/test/integration/test.ts index 80310d43..a76fba26 100644 --- a/command/test/integration/test.ts +++ b/command/test/integration/test.ts @@ -1,11 +1,7 @@ import { snapshotTest } from "../../../testing/snapshot.ts"; -import { - Command, - CompletionsCommand, - EnumType, - HelpCommand, - ValidationError, -} from "../../mod.ts"; +import { CompletionsCommand } from "../../completions/mod.ts"; +import { HelpCommand } from "../../help/mod.ts"; +import { Command, EnumType, ValidationError } from "../../mod.ts"; await snapshotTest({ name: "command integration", From 7e4f76e494d93ceafd4bcc41e38ae0fca4c621ad Mon Sep 17 00:00:00 2001 From: Benjamin Fischer Date: Sun, 5 May 2024 17:35:45 +0200 Subject: [PATCH 34/47] add workaround for workspace issue --- deno.jsonc | 2 +- testing/snapshot.ts | 21 ++++++++++++++++++++- testing/snapshot_test.ts | 8 +++++++- 3 files changed, 28 insertions(+), 3 deletions(-) diff --git a/deno.jsonc b/deno.jsonc index a9bf42b8..865e045c 100644 --- a/deno.jsonc +++ b/deno.jsonc @@ -14,7 +14,7 @@ "tasks": { "lint": "deno lint && deno fmt --check", "fmt": "deno fmt", - "test": "deno test --doc --allow-run=deno --allow-env --allow-read=./ --allow-write=./ --ignore=./CHANGELOG.md --parallel", + "test": "CLIFFY_SNAPSHOT_CONFIG=deno.jsonc deno test --doc --allow-run=deno --allow-env --allow-read=./ --allow-write=./ --ignore=./CHANGELOG.md --parallel", "check:examples": "deno check examples/**/*.ts", "snapshot": "deno task test -- --update", "coverage": "deno task test --coverage=./dist/coverage/all/result && deno coverage --lcov ./dist/coverage/all/result > ./dist/coverage/all/cov.lcov", diff --git a/testing/snapshot.ts b/testing/snapshot.ts index b21c46fe..6e4a269e 100644 --- a/testing/snapshot.ts +++ b/testing/snapshot.ts @@ -21,8 +21,10 @@ export interface SnapshotTestOptions extends SnapshotTestStep { name: string; /** Import meta. Required to determine the import url of the test file. */ meta: ImportMeta; + /** Test function. */ fn(): void | Promise; + /** * Object of test steps. Key is the test name and the value is an array of * input sequences/characters. @@ -168,13 +170,30 @@ async function runPrompt( let stderr: string | undefined; try { + let denoArgs: Array; + + if (options.denoArgs) { + denoArgs = options.denoArgs; + } else { + denoArgs = ["--allow-env=SNAPSHOT_TEST_NAME"]; + + // workaround for https://github.com/denoland/deno/issues/22020 + const { state } = await Deno.permissions.query({ + name: "env", + variable: "CLIFFY_SNAPSHOT_CONFIG", + }); + if (state === "granted" && Deno.env.has("CLIFFY_SNAPSHOT_CONFIG")) { + denoArgs.push("-c=deno.jsonc"); + } + } + const cmd = new Deno.Command("deno", { stdin: "piped", stdout: "piped", stderr: "piped", args: [ "run", - ...options.denoArgs ?? ["--allow-env=SNAPSHOT_TEST_NAME"], + ...denoArgs, options.meta.url, ...options.args ?? [], ...step?.args ?? [], diff --git a/testing/snapshot_test.ts b/testing/snapshot_test.ts index d928d4e7..27a3cb0a 100644 --- a/testing/snapshot_test.ts +++ b/testing/snapshot_test.ts @@ -19,12 +19,18 @@ Deno.test({ "--allow-run=deno", `--allow-read=${testDir}`, `--allow-write=${testDir}`, + `--allow-env=CLIFFY_SNAPSHOT_CONFIG`, "testing/snapshot_test_fixture.ts", "--", "--update", ]; - const cmd = new Deno.Command("deno", { args }); + const cmd = new Deno.Command("deno", { + args, + env: { + CLIFFY_SNAPSHOT_CONFIG: Deno.env.get("CLIFFY_SNAPSHOT_CONFIG"), + }, + }); const { success, stdout, stderr } = await cmd.output(); From c4171e521530a2ec2c87da329a00b92cafd3a593 Mon Sep 17 00:00:00 2001 From: Benjamin Fischer Date: Sun, 5 May 2024 17:39:21 +0200 Subject: [PATCH 35/47] fix examples --- examples/command/upgrade_command.ts | 3 ++- examples/prompt/custom_prompts.ts | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/examples/command/upgrade_command.ts b/examples/command/upgrade_command.ts index bef7b0ce..9d6e6271 100755 --- a/examples/command/upgrade_command.ts +++ b/examples/command/upgrade_command.ts @@ -1,6 +1,7 @@ #!/usr/bin/env -S deno run --allow-net --allow-run --allow-read --no-check -import { Command, CompletionsCommand } from "../../command/mod.ts"; +import { CompletionsCommand } from "../../command/completions/mod.ts"; +import { Command } from "../../command/mod.ts"; import { DenoLandProvider, NestLandProvider, diff --git a/examples/prompt/custom_prompts.ts b/examples/prompt/custom_prompts.ts index 13bc1a17..62a5c5db 100755 --- a/examples/prompt/custom_prompts.ts +++ b/examples/prompt/custom_prompts.ts @@ -1,6 +1,6 @@ #!/usr/bin/env -S deno run -import { BufReader } from "@std/io/buf_reader"; +import { BufReader } from "@std/io/buf-reader"; import { tty } from "../../ansi/tty.ts"; import { Figures } from "../../prompt/_figures.ts"; import { prompt } from "../../prompt/prompt.ts"; From 87b3a956d5f9b49f53bc82501ee4574abcf05afb Mon Sep 17 00:00:00 2001 From: Benjamin Fischer Date: Sun, 5 May 2024 17:55:17 +0200 Subject: [PATCH 36/47] debug --- testing/snapshot.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/testing/snapshot.ts b/testing/snapshot.ts index 6e4a269e..38489eaf 100644 --- a/testing/snapshot.ts +++ b/testing/snapshot.ts @@ -216,7 +216,7 @@ async function runPrompt( await writer.write(encoder.encode(data)); // Ensure all inputs are processed and rendered separately. await new Promise((resolve) => - setTimeout(resolve, options.timeout ?? 700) + setTimeout(resolve, options.timeout ?? 800) ); } } From ae2c9d8f34a40af079cee0e3a5bf020a96aa5720 Mon Sep 17 00:00:00 2001 From: Benjamin Fischer Date: Sun, 5 May 2024 19:46:03 +0200 Subject: [PATCH 37/47] debug --- testing/snapshot.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/testing/snapshot.ts b/testing/snapshot.ts index 38489eaf..a44de3f2 100644 --- a/testing/snapshot.ts +++ b/testing/snapshot.ts @@ -216,7 +216,10 @@ async function runPrompt( await writer.write(encoder.encode(data)); // Ensure all inputs are processed and rendered separately. await new Promise((resolve) => - setTimeout(resolve, options.timeout ?? 800) + setTimeout( + resolve, + options.timeout ?? Deno.build.os === "windows" ? 1000 : 700, + ) ); } } From bd469ec1e39659e42cfaf18e809fd7a0486a1516 Mon Sep 17 00:00:00 2001 From: Benjamin Fischer Date: Sun, 5 May 2024 19:48:04 +0200 Subject: [PATCH 38/47] debug --- testing/snapshot.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/testing/snapshot.ts b/testing/snapshot.ts index a44de3f2..9d66c2b1 100644 --- a/testing/snapshot.ts +++ b/testing/snapshot.ts @@ -218,7 +218,7 @@ async function runPrompt( await new Promise((resolve) => setTimeout( resolve, - options.timeout ?? Deno.build.os === "windows" ? 1000 : 700, + options.timeout ?? Deno.build.os === "windows" ? 1500 : 700, ) ); } From df989de7faa1bfe19b15ed2572a32197977cb158 Mon Sep 17 00:00:00 2001 From: Benjamin Fischer Date: Sun, 5 May 2024 19:51:11 +0200 Subject: [PATCH 39/47] debug --- testing/snapshot.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/testing/snapshot.ts b/testing/snapshot.ts index 9d66c2b1..1bf5eeef 100644 --- a/testing/snapshot.ts +++ b/testing/snapshot.ts @@ -218,7 +218,7 @@ async function runPrompt( await new Promise((resolve) => setTimeout( resolve, - options.timeout ?? Deno.build.os === "windows" ? 1500 : 700, + options.timeout ?? Deno.build.os === "windows" ? 2000 : 700, ) ); } From 2e442fdad70a012d403c4b4ab845f38f7f2e33e0 Mon Sep 17 00:00:00 2001 From: Benjamin Fischer Date: Sun, 5 May 2024 20:07:42 +0200 Subject: [PATCH 40/47] debug --- .../__snapshots__/checkbox_value_test.ts.windows.snap | 3 --- testing/snapshot.ts | 8 ++++---- 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/prompt/test/integration/__snapshots__/checkbox_value_test.ts.windows.snap b/prompt/test/integration/__snapshots__/checkbox_value_test.ts.windows.snap index 49634972..f433c765 100644 --- a/prompt/test/integration/__snapshots__/checkbox_value_test.ts.windows.snap +++ b/prompt/test/integration/__snapshots__/checkbox_value_test.ts.windows.snap @@ -5,9 +5,6 @@ stdout: "? Select an option ❯ × date 1 × date 2\\x1b[2A\\x1b[0G\\x1b[?25l\\x1b[G\\x1b[0J -? Select an option - × date 1 -❯ × date 2\\x1b[2A\\x1b[0G\\x1b[?25l\\x1b[G\\x1b[0J ? Select an option × date 1 ❯ √ date 2\\x1b[2A\\x1b[0G\\x1b[?25l\\x1b[G\\x1b[0J diff --git a/testing/snapshot.ts b/testing/snapshot.ts index 1bf5eeef..ce3f7bff 100644 --- a/testing/snapshot.ts +++ b/testing/snapshot.ts @@ -141,7 +141,7 @@ function registerTest(options: SnapshotTestOptions) { ctx: Deno.TestContext, step?: SnapshotTestStep, ) { - const { stdout, stderr } = await runPrompt(options, step); + const { stdout, stderr } = await executeTest(options, step); const serializer = options.serializer ?? quoteString; const output = `stdout:\n${serializer(stdout)}\nstderr:\n${ @@ -161,7 +161,7 @@ function registerTest(options: SnapshotTestOptions) { } } -async function runPrompt( +async function executeTest( options: SnapshotTestOptions, step?: SnapshotTestStep, ): Promise<{ stdout: string; stderr: string }> { @@ -183,7 +183,7 @@ async function runPrompt( variable: "CLIFFY_SNAPSHOT_CONFIG", }); if (state === "granted" && Deno.env.has("CLIFFY_SNAPSHOT_CONFIG")) { - denoArgs.push("-c=deno.jsonc"); + denoArgs.push(`--config=${Deno.env.get("CLIFFY_SNAPSHOT_CONFIG")}`); } } @@ -218,7 +218,7 @@ async function runPrompt( await new Promise((resolve) => setTimeout( resolve, - options.timeout ?? Deno.build.os === "windows" ? 2000 : 700, + options.timeout ?? Deno.build.os === "windows" ? 800 : 300, ) ); } From 682ccfd4e93544f6bf9e77871b1a37f4d0c3e8fe Mon Sep 17 00:00:00 2001 From: Benjamin Fischer Date: Sun, 5 May 2024 20:09:25 +0200 Subject: [PATCH 41/47] debug --- testing/snapshot.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/testing/snapshot.ts b/testing/snapshot.ts index ce3f7bff..4df0e8d2 100644 --- a/testing/snapshot.ts +++ b/testing/snapshot.ts @@ -218,7 +218,7 @@ async function executeTest( await new Promise((resolve) => setTimeout( resolve, - options.timeout ?? Deno.build.os === "windows" ? 800 : 300, + options.timeout ?? Deno.build.os === "windows" ? 1000 : 300, ) ); } From 058d093184193eb34df01dfcefd9df48815d3ed6 Mon Sep 17 00:00:00 2001 From: Benjamin Fischer Date: Sun, 5 May 2024 20:11:26 +0200 Subject: [PATCH 42/47] debug --- testing/snapshot.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/testing/snapshot.ts b/testing/snapshot.ts index 4df0e8d2..e5ac6359 100644 --- a/testing/snapshot.ts +++ b/testing/snapshot.ts @@ -218,7 +218,7 @@ async function executeTest( await new Promise((resolve) => setTimeout( resolve, - options.timeout ?? Deno.build.os === "windows" ? 1000 : 300, + options.timeout ?? Deno.build.os === "windows" ? 1200 : 300, ) ); } From 463c41eda9006633f01bb5918c3b30edcdd54290 Mon Sep 17 00:00:00 2001 From: Benjamin Fischer Date: Sun, 5 May 2024 20:13:22 +0200 Subject: [PATCH 43/47] debug --- .../__snapshots__/checkbox_value_test.ts.windows.snap | 3 +++ 1 file changed, 3 insertions(+) diff --git a/prompt/test/integration/__snapshots__/checkbox_value_test.ts.windows.snap b/prompt/test/integration/__snapshots__/checkbox_value_test.ts.windows.snap index f433c765..49634972 100644 --- a/prompt/test/integration/__snapshots__/checkbox_value_test.ts.windows.snap +++ b/prompt/test/integration/__snapshots__/checkbox_value_test.ts.windows.snap @@ -5,6 +5,9 @@ stdout: "? Select an option ❯ × date 1 × date 2\\x1b[2A\\x1b[0G\\x1b[?25l\\x1b[G\\x1b[0J +? Select an option + × date 1 +❯ × date 2\\x1b[2A\\x1b[0G\\x1b[?25l\\x1b[G\\x1b[0J ? Select an option × date 1 ❯ √ date 2\\x1b[2A\\x1b[0G\\x1b[?25l\\x1b[G\\x1b[0J From e5d618e30adc7129aca0840c26bcf94dca32eda6 Mon Sep 17 00:00:00 2001 From: Benjamin Fischer Date: Sun, 5 May 2024 21:31:32 +0200 Subject: [PATCH 44/47] adapt ansi exports --- ansi/ansi.ts | 4 +-- ansi/ansi_escapes.ts | 4 +-- ansi/chain.ts | 4 +-- ansi/colors.ts | 4 +-- ansi/cursor_position.ts | 2 +- ansi/deno.json | 3 +-- ansi/mod.ts | 51 --------------------------------------- ansi/tty.ts | 2 +- examples/ansi.ts | 3 ++- prompt/_generic_prompt.ts | 3 ++- prompt/prompt.ts | 2 +- testing/snapshot.ts | 2 +- 12 files changed, 17 insertions(+), 67 deletions(-) delete mode 100644 ansi/mod.ts diff --git a/ansi/ansi.ts b/ansi/ansi.ts index a2f30000..629246b6 100644 --- a/ansi/ansi.ts +++ b/ansi/ansi.ts @@ -32,7 +32,7 @@ export type Ansi = AnsiFactory & AnsiChain; * If invoked as method, a new Ansi instance will be returned. * * ```ts - * import { ansi } from "./mod.ts"; + * import { ansi } from "./ansi.ts"; * * await Deno.stdout.write( * new TextEncoder().encode( @@ -44,7 +44,7 @@ export type Ansi = AnsiFactory & AnsiChain; * Or shorter: * * ```ts - * import { ansi } from "./mod.ts"; + * import { ansi } from "./ansi.ts"; * * await Deno.stdout.write( * ansi.cursorTo(0, 0).eraseScreen.bytes(), diff --git a/ansi/ansi_escapes.ts b/ansi/ansi_escapes.ts index 73282d65..088284dc 100644 --- a/ansi/ansi_escapes.ts +++ b/ansi/ansi_escapes.ts @@ -185,7 +185,7 @@ export const clearTerminal: string = Deno.build.os === "windows" * @param url Link url. * * ```ts - * import { link } from "./mod.ts"; + * import { link } from "./ansi_escapes.ts"; * * console.log( * link("Click me.", "https://deno.land"), @@ -223,7 +223,7 @@ export interface ImageOptions { * @param options Image options. * * ```ts - * import { image } from "./mod.ts"; + * import { image } from "./ansi_escapes.ts"; * * const response = await fetch("https://deno.land/images/hashrock_simple.png"); * const imageBuffer: ArrayBuffer = await response.arrayBuffer(); diff --git a/ansi/chain.ts b/ansi/chain.ts index 514903ce..96ec9abd 100644 --- a/ansi/chain.ts +++ b/ansi/chain.ts @@ -109,7 +109,7 @@ export interface Chain> { * @param url Link url. * * ```ts - * import { ansi } from "./mod.ts"; + * import { ansi } from "./ansi.ts"; * * console.log( * ansi.link("Click me.", "https://deno.land"), @@ -124,7 +124,7 @@ export interface Chain> { * @param options Image options. * * ```ts - * import { ansi } from "./mod.ts"; + * import { ansi } from "./ansi.ts"; * * const response = await fetch("https://deno.land/images/hashrock_simple.png"); * const imageBuffer: ArrayBuffer = await response.arrayBuffer(); diff --git a/ansi/colors.ts b/ansi/colors.ts index e67b60bf..38888c80 100644 --- a/ansi/colors.ts +++ b/ansi/colors.ts @@ -39,7 +39,7 @@ for (const name of methodNames) { * Chainable colors module. * * ```ts - * import { colors } from "./mod.ts"; + * import { colors } from "./colors.ts"; * * console.log(colors.blue.bgRed.bold('Welcome to Deno.Land!')); * ``` @@ -47,7 +47,7 @@ for (const name of methodNames) { * If invoked as method, a new Ansi instance will be returned. * * ```ts - * import { Colors, colors } from "./mod.ts"; + * import { Colors, colors } from "./colors.ts"; * * const myColors: Colors = colors(); * console.log(myColors.blue.bgRed.bold('Welcome to Deno.Land!')); diff --git a/ansi/cursor_position.ts b/ansi/cursor_position.ts index 96be65dd..65ddad24 100644 --- a/ansi/cursor_position.ts +++ b/ansi/cursor_position.ts @@ -25,7 +25,7 @@ const decoder = new TextDecoder(); * @param options Options. * * ```ts - * import { Cursor, getCursorPosition } from "./mod.ts"; + * import { Cursor, getCursorPosition } from "./cursor_position.ts"; * * const cursor: Cursor = getCursorPosition(); * console.log(cursor); // { x: 0, y: 14} diff --git a/ansi/deno.json b/ansi/deno.json index eb10bc82..5dad35ad 100644 --- a/ansi/deno.json +++ b/ansi/deno.json @@ -2,8 +2,7 @@ "name": "@cliffy/ansi", "version": "1.0.0-rc.4", "exports": { - ".": "./mod.ts", - "./ansi": "./mod.ts", + ".": "./ansi.ts", "./ansi-escapes": "./ansi_escapes.ts", "./colors": "./colors.ts", "./cursor-position": "./cursor_position.ts", diff --git a/ansi/mod.ts b/ansi/mod.ts deleted file mode 100644 index 6fc6b92d..00000000 --- a/ansi/mod.ts +++ /dev/null @@ -1,51 +0,0 @@ -export { type Ansi, ansi, type AnsiChain, type AnsiFactory } from "./ansi.ts"; -export { - bel, - clearScreen, - clearTerminal, - cursorBackward, - cursorDown, - cursorForward, - cursorHide, - cursorLeft, - cursorMove, - cursorNextLine, - cursorPosition, - cursorPrevLine, - cursorRestore, - cursorSave, - cursorShow, - cursorTo, - cursorUp, - eraseDown, - eraseLine, - eraseLineEnd, - eraseLines, - eraseLineStart, - eraseScreen, - eraseUp, - image, - type ImageOptions, - link, - scrollDown, - scrollUp, -} from "./ansi_escapes.ts"; -export { type Chain } from "./chain.ts"; -export { - type Colors, - colors, - type ColorsChain, - type ColorsFactory, -} from "./colors.ts"; -export { - type Cursor, - type CursorPositionOptions, - getCursorPosition, -} from "./cursor_position.ts"; -export { - type Tty, - tty, - type TtyChain, - type TtyFactory, - type TtyOptions, -} from "./tty.ts"; diff --git a/ansi/tty.ts b/ansi/tty.ts index c19e0b8c..e141647c 100644 --- a/ansi/tty.ts +++ b/ansi/tty.ts @@ -39,7 +39,7 @@ export type Tty = TtyFactory & TtyChain; * If invoked as method, a new Tty instance will be returned. * * ```ts - * import { tty } from "./mod.ts"; + * import { tty } from "./tty.ts"; * * tty.cursorTo(0, 0).eraseScreen(); * ``` diff --git a/examples/ansi.ts b/examples/ansi.ts index d4b24fc9..55a2c449 100644 --- a/examples/ansi.ts +++ b/examples/ansi.ts @@ -1,7 +1,8 @@ #!/usr/bin/env -S deno run -import { colors, tty } from "../ansi/mod.ts"; import { delay } from "@std/async/delay"; +import { colors } from "../ansi/colors.ts"; +import { tty } from "../ansi/tty.ts"; const error = colors.bold.red; const warn = colors.bold.yellow; diff --git a/prompt/_generic_prompt.ts b/prompt/_generic_prompt.ts index e359904d..b7e2221b 100644 --- a/prompt/_generic_prompt.ts +++ b/prompt/_generic_prompt.ts @@ -1,4 +1,5 @@ -import { type Cursor, Tty, tty } from "@cliffy/ansi"; +import { Tty, tty } from "@cliffy/ansi/tty"; +import { type Cursor } from "@cliffy/ansi/cursor-position"; import { KeyCode, parse } from "@cliffy/keycode"; import { bold, diff --git a/prompt/prompt.ts b/prompt/prompt.ts index 5d41a725..0d1a3550 100644 --- a/prompt/prompt.ts +++ b/prompt/prompt.ts @@ -1,6 +1,6 @@ // deno-lint-ignore-file no-explicit-any ban-types -import { Tty, tty } from "@cliffy/ansi"; +import { Tty, tty } from "@cliffy/ansi/tty"; import { GenericPrompt, GenericPromptOptions, diff --git a/testing/snapshot.ts b/testing/snapshot.ts index e5ac6359..ff3d3132 100644 --- a/testing/snapshot.ts +++ b/testing/snapshot.ts @@ -1,4 +1,4 @@ -import { eraseDown } from "@cliffy/ansi"; +import { eraseDown } from "@cliffy/ansi/ansi-escapes"; import { quoteString } from "./_quote_string.ts"; import { basename } from "@std/path"; import { red } from "@std/fmt/colors"; From 6ac036c247cf1edde94585e60e91a1602a52091f Mon Sep 17 00:00:00 2001 From: Benjamin Fischer Date: Sun, 5 May 2024 21:45:57 +0200 Subject: [PATCH 45/47] adapt publish workflow --- .github/workflows/publish.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 4f689505..093cc58f 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -1,6 +1,7 @@ name: Publish on: + pull_request: push: branches: [main] release: @@ -25,7 +26,7 @@ jobs: uses: denoland/setup-deno@v1 - name: Publish (dry run) - if: github.event_name == 'push' + if: github.event_name != 'release' run: deno publish --dry-run - name: Publish From 1a0a3a4c1d44ea2b5e564eb43d105dedd87134d5 Mon Sep 17 00:00:00 2001 From: Benjamin Fischer Date: Sun, 5 May 2024 22:04:23 +0200 Subject: [PATCH 46/47] cleanup --- ansi/ansi.ts | 4 ++-- ansi/ansi_escapes.ts | 4 ++-- ansi/chain.ts | 4 ++-- ansi/colors.ts | 4 ++-- ansi/cursor_position.ts | 2 +- ansi/tty.ts | 2 +- testing/snapshot.ts | 2 -- 7 files changed, 10 insertions(+), 12 deletions(-) diff --git a/ansi/ansi.ts b/ansi/ansi.ts index 629246b6..614735c1 100644 --- a/ansi/ansi.ts +++ b/ansi/ansi.ts @@ -32,7 +32,7 @@ export type Ansi = AnsiFactory & AnsiChain; * If invoked as method, a new Ansi instance will be returned. * * ```ts - * import { ansi } from "./ansi.ts"; + * import { ansi } from "@cliffy/ansi"; * * await Deno.stdout.write( * new TextEncoder().encode( @@ -44,7 +44,7 @@ export type Ansi = AnsiFactory & AnsiChain; * Or shorter: * * ```ts - * import { ansi } from "./ansi.ts"; + * import { ansi } from "@cliffy/ansi"; * * await Deno.stdout.write( * ansi.cursorTo(0, 0).eraseScreen.bytes(), diff --git a/ansi/ansi_escapes.ts b/ansi/ansi_escapes.ts index 088284dc..14f095d5 100644 --- a/ansi/ansi_escapes.ts +++ b/ansi/ansi_escapes.ts @@ -185,7 +185,7 @@ export const clearTerminal: string = Deno.build.os === "windows" * @param url Link url. * * ```ts - * import { link } from "./ansi_escapes.ts"; + * import { link } from "@cliffy/ansi/ansi-escapes"; * * console.log( * link("Click me.", "https://deno.land"), @@ -223,7 +223,7 @@ export interface ImageOptions { * @param options Image options. * * ```ts - * import { image } from "./ansi_escapes.ts"; + * import { image } from "@cliffy/ansi/ansi-escapes"; * * const response = await fetch("https://deno.land/images/hashrock_simple.png"); * const imageBuffer: ArrayBuffer = await response.arrayBuffer(); diff --git a/ansi/chain.ts b/ansi/chain.ts index 96ec9abd..18dc749d 100644 --- a/ansi/chain.ts +++ b/ansi/chain.ts @@ -109,7 +109,7 @@ export interface Chain> { * @param url Link url. * * ```ts - * import { ansi } from "./ansi.ts"; + * import { ansi } from "@cliffy/ansi"; * * console.log( * ansi.link("Click me.", "https://deno.land"), @@ -124,7 +124,7 @@ export interface Chain> { * @param options Image options. * * ```ts - * import { ansi } from "./ansi.ts"; + * import { ansi } from "@cliffy/ansi"; * * const response = await fetch("https://deno.land/images/hashrock_simple.png"); * const imageBuffer: ArrayBuffer = await response.arrayBuffer(); diff --git a/ansi/colors.ts b/ansi/colors.ts index 38888c80..f97cdb50 100644 --- a/ansi/colors.ts +++ b/ansi/colors.ts @@ -39,7 +39,7 @@ for (const name of methodNames) { * Chainable colors module. * * ```ts - * import { colors } from "./colors.ts"; + * import { colors } from "@cliffy/ansi/colors"; * * console.log(colors.blue.bgRed.bold('Welcome to Deno.Land!')); * ``` @@ -47,7 +47,7 @@ for (const name of methodNames) { * If invoked as method, a new Ansi instance will be returned. * * ```ts - * import { Colors, colors } from "./colors.ts"; + * import { Colors, colors } from "@cliffy/ansi/colors"; * * const myColors: Colors = colors(); * console.log(myColors.blue.bgRed.bold('Welcome to Deno.Land!')); diff --git a/ansi/cursor_position.ts b/ansi/cursor_position.ts index 65ddad24..78e280d6 100644 --- a/ansi/cursor_position.ts +++ b/ansi/cursor_position.ts @@ -25,7 +25,7 @@ const decoder = new TextDecoder(); * @param options Options. * * ```ts - * import { Cursor, getCursorPosition } from "./cursor_position.ts"; + * import { Cursor, getCursorPosition } from "@cliffy/ansi/cursor-position"; * * const cursor: Cursor = getCursorPosition(); * console.log(cursor); // { x: 0, y: 14} diff --git a/ansi/tty.ts b/ansi/tty.ts index e141647c..ff79bb7f 100644 --- a/ansi/tty.ts +++ b/ansi/tty.ts @@ -39,7 +39,7 @@ export type Tty = TtyFactory & TtyChain; * If invoked as method, a new Tty instance will be returned. * * ```ts - * import { tty } from "./tty.ts"; + * import { tty } from "@cliffy/ansi/tty"; * * tty.cursorTo(0, 0).eraseScreen(); * ``` diff --git a/testing/snapshot.ts b/testing/snapshot.ts index ff3d3132..cb69bb5e 100644 --- a/testing/snapshot.ts +++ b/testing/snapshot.ts @@ -21,10 +21,8 @@ export interface SnapshotTestOptions extends SnapshotTestStep { name: string; /** Import meta. Required to determine the import url of the test file. */ meta: ImportMeta; - /** Test function. */ fn(): void | Promise; - /** * Object of test steps. Key is the test name and the value is an array of * input sequences/characters. From 05581e718bdedd24e3e1bc0866488968833a657a Mon Sep 17 00:00:00 2001 From: Julien Oculi Date: Fri, 31 May 2024 12:24:22 +0200 Subject: [PATCH 47/47] feat(command): :sparkles: add `gitea` and `forgejo` upgrade provider --- command/upgrade/provider/gitea.ts | 187 ++++++++++++++++++++++++++++++ 1 file changed, 187 insertions(+) create mode 100644 command/upgrade/provider/gitea.ts diff --git a/command/upgrade/provider/gitea.ts b/command/upgrade/provider/gitea.ts new file mode 100644 index 00000000..7fe424cc --- /dev/null +++ b/command/upgrade/provider/gitea.ts @@ -0,0 +1,187 @@ +import { Provider, type Versions } from "../provider.ts"; +import { bold, brightBlue } from "@std/fmt/colors"; + +export interface GiteaProviderOptions { + registryUrl: string; + repository: string; + branches?: boolean; + token?: string; +} + +export interface GiteaVersions extends Versions { + tags: Array; + branches: Array; +} + +export class GiteaProvider extends Provider { + name = "gitea"; + private readonly registryUrl: string; + private readonly repositoryName: string; + private readonly listBranches?: boolean; + private readonly giteaToken?: string; + + constructor({ registryUrl, repository, branches = true, token }: GiteaProviderOptions) { + super(); + this.registryUrl = registryUrl + this.repositoryName = repository; + this.listBranches = branches; + this.giteaToken = token; + } + + async getVersions( + _name: string, + ): Promise { + //!TODO + const [tags, branches] = await Promise.all([ + this.gitFetch("tags"), + this.gitFetch("branches"), + ]); + + const tagNames = tags.map(tag => tag.name).toReversed() + + const branchNames = branches + .sort((a, b) => + (a.protected === b.protected) ? 0 : (a.protected ? 1 : -1) + ) + .map((tag) => + tag.protected ? `${tag.name} (${bold("Protected")})` : tag.name + ) + .reverse(); + + return { + versions: [ + ...tagNames, + ...branchNames, + ], + latest: tagNames[0], + tags: tagNames, + branches: branchNames, + }; + } + + getRepositoryUrl(_name: string): string { + return new URL(this.repositoryName, this.registryUrl).href; + } + + getRegistryUrl(_name: string, version: string): string { + return new URL(`${this.repositoryName}/src/tag/${version}`, this.registryUrl).href; + } + + async listVersions(name: string, currentVersion?: string): Promise { + //!TODO + const { tags, branches } = await this.getVersions(name); + const showBranches: boolean = !!this.listBranches && branches.length > 0; + const indent = showBranches ? 2 : 0; + if (showBranches) { + console.log("\n" + " ".repeat(indent) + bold(brightBlue("Tags:\n"))); + } + super.printVersions(tags, currentVersion, { indent }); + if (showBranches) { + console.log("\n" + " ".repeat(indent) + bold(brightBlue("Branches:\n"))); + super.printVersions(branches, currentVersion, { maxCols: 5, indent }); + console.log(); + } + } + + private getApiUrl(endpoint: string): string { + return new URL(`api/v1/repos/${this.repositoryName}/${endpoint}`, this.registryUrl).href; + } + + private async gitFetch(endpoint: string): Promise { + const headers = new Headers({ "Content-Type": "application/json" }); + if (this.giteaToken) { + headers.set( + "Authorization", + this.giteaToken ? `token ${this.giteaToken}` : "", + ); + } + const response = await fetch( + this.getApiUrl(endpoint), + { + method: "GET", + cache: "default", + headers, + }, + ); + + if (!response.status) { + throw new Error( + "couldn't fetch versions - try again after sometime", + ); + } + + const data: GiteaResponse & T = await response.json(); + + //!TODO check error message + if ( + typeof data === "object" && "message" in data && + "documentation_url" in data + ) { + throw new Error(data.message + " " + data.documentation_url); + } + + return data; + } +} + +interface GiteaResponse { + //!TODO check response format + message: string; + // deno-lint-ignore camelcase + documentation_url: string; +} + +interface GiteaRepoTag { + //!TODO improve types + name: string + message: string + id: string //sha1 (commit.sha) + commit: { + url: string //url + sha: string //sha1 + created: string //ISO + } + zipball_url: string //url + tarball_url: string //url +} + +interface GiteaRepoBranch { + commit: { + author: { + email: string + name: string + username: string + committer: { + email: string + name: string + username: string + } + id: string //commit sha1 + url: string //url + timestamp: string //ISO + message: string + added: string[] | null + modified: string[] | null + removed: string[] | null + verification: { + payload: string + reason: string + signature: string + verified: boolean + signer: { + email: string + name: string + username: string + } | null + } + } + } + effective_branch_protection_name: string + enable_status_check: boolean + name: string + protected: boolean + required_approvals: number + status_check_contexts: string[] + user_can_merge: boolean + user_can_push: boolean +} \ No newline at end of file