diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml new file mode 100644 index 00000000..093cc58f --- /dev/null +++ b/.github/workflows/publish.yml @@ -0,0 +1,34 @@ +name: Publish + +on: + pull_request: + push: + branches: [main] + release: + types: [published] + +env: + DENO_UNSTABLE_WORKSPACES: true + +jobs: + 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 != 'release' + run: deno publish --dry-run + + - name: Publish + if: github.event_name == 'release' + run: deno publish diff --git a/ansi/ansi.ts b/ansi/ansi.ts index a2f30000..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 "./mod.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 "./mod.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 3bdf9e22..14f095d5 100644 --- a/ansi/ansi_escapes.ts +++ b/ansi/ansi_escapes.ts @@ -1,9 +1,9 @@ -import { encodeBase64 } from "./deps.ts"; +import { encodeBase64 } from "@std/encoding/base64"; /** Escape sequence: `\x1B` */ const ESC = "\x1B"; /** Control sequence intro: `\x1B[` */ -const CSI = `${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 = `${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 = `${CSI}G`; +export const cursorLeft: string = `${CSI}G`; /** Hide cursor. */ -export const cursorHide = `${CSI}?25l`; +export const cursorHide: string = `${CSI}?25l`; /** Show cursor. */ -export const cursorShow = `${CSI}?25h`; +export const cursorShow: string = `${CSI}?25h`; /** Save cursor. */ -export const cursorSave = `${ESC}7`; +export const cursorSave: string = `${ESC}7`; /** Restore cursor. */ -export const cursorRestore = `${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 = `${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 = `${CSI}2K`; +export const eraseLine: string = `${CSI}2K`; /** Clear to line end. */ -export const eraseLineEnd = `${CSI}0K`; +export const eraseLineEnd: string = `${CSI}0K`; /** Clear to line start. */ -export const eraseLineStart = `${CSI}1K`; +export const eraseLineStart: string = `${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 @@ -185,7 +185,7 @@ export const clearTerminal = Deno.build.os === "windows" * @param url Link url. * * ```ts - * import { link } from "./mod.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 "./mod.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/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/chain.ts b/ansi/chain.ts index 514903ce..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 "./mod.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 "./mod.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 266714c9..f97cdb50 100644 --- a/ansi/colors.ts +++ b/ansi/colors.ts @@ -1,4 +1,4 @@ -import * as stdColors from "https://deno.land/std@0.221.0/fmt/colors.ts"; +import * as stdColors from "@std/fmt/colors"; type ExcludedColorMethods = "setColorEnabled" | "getColorEnabled"; type PropertyNames = keyof typeof stdColors; @@ -39,7 +39,7 @@ for (const name of methodNames) { * Chainable colors module. * * ```ts - * import { colors } from "./mod.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 "./mod.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/colors_test.ts b/ansi/colors_test.ts index 4b42bb37..2932655d 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 { bold, red, underline } 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..78e280d6 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 { @@ -25,7 +25,7 @@ const decoder = new TextDecoder(); * @param options Options. * * ```ts - * import { Cursor, getCursorPosition } from "./mod.ts"; + * import { Cursor, getCursorPosition } from "@cliffy/ansi/cursor-position"; * * const cursor: Cursor = getCursorPosition(); * console.log(cursor); // { x: 0, y: 14} diff --git a/ansi/deno.json b/ansi/deno.json new file mode 100644 index 00000000..5dad35ad --- /dev/null +++ b/ansi/deno.json @@ -0,0 +1,11 @@ +{ + "name": "@cliffy/ansi", + "version": "1.0.0-rc.4", + "exports": { + ".": "./ansi.ts", + "./ansi-escapes": "./ansi_escapes.ts", + "./colors": "./colors.ts", + "./cursor-position": "./cursor_position.ts", + "./tty": "./tty.ts" + } +} diff --git a/ansi/deps.ts b/ansi/deps.ts deleted file mode 100644 index 40836af6..00000000 --- a/ansi/deps.ts +++ /dev/null @@ -1,5 +0,0 @@ -export { encodeBase64 } from "https://deno.land/std@0.221.0/encoding/base64.ts"; -export type { - ReaderSync, - WriterSync, -} from "https://deno.land/std@0.221.0/io/types.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 923ebd18..ff79bb7f 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 { @@ -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 "@cliffy/ansi/tty"; * * tty.cursorTo(0, 0).eraseScreen(); * ``` 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 3ca6f9cf..7393afdb 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 "./_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/_utils.ts b/command/_utils.ts index 43823087..546e54ab 100644 --- a/command/_utils.ts +++ b/command/_utils.ts @@ -1,9 +1,9 @@ -import { closestString } from "https://deno.land/std@0.221.0/text/closest_string.ts"; +import { closestString } from "@std/text/closest-string"; import { + OptionType, UnexpectedArgumentAfterVariadicArgumentError, UnexpectedRequiredArgumentError, -} from "../flags/_errors.ts"; -import { OptionType } from "../flags/deprecated.ts"; +} 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 984feed8..57970071 100644 --- a/command/command.ts +++ b/command/command.ts @@ -1,17 +1,17 @@ // deno-lint-ignore-file no-explicit-any import { + parseFlags, + type ParseFlagsContext, UnknownTypeError, ValidationError as FlagsValidationError, -} from "../flags/_errors.ts"; -import { parseFlags } from "../flags/flags.ts"; -import type { ParseFlagsContext } from "../flags/types.ts"; +} from "@cliffy/flags"; import { getDescription, parseArgumentsDefinition, splitArguments, underscoreToCamelCase, } from "./_utils.ts"; -import { bold, brightBlue, red } from "./deps.ts"; +import { bold, brightBlue, red } from "@std/fmt/colors"; import { CommandNotFoundError, DefaultCommandNotFoundError, @@ -2257,7 +2257,7 @@ export class Command< } /** Check if command has arguments. */ - public hasArguments() { + public hasArguments(): boolean { return !!this.argsDefinition; } @@ -2280,7 +2280,7 @@ export class Command< } /** Get auto generated command usage. */ - public getUsage() { + public getUsage(): string { return this._usage ?? [this.getArgsDefinition(), this.getRequiredOptionsDefinition()] .join(" ") @@ -2761,7 +2761,16 @@ export class Command< } /** Get completions. */ - public getCompletions() { + public getCompletions(): Completion< + any, + any, + any, + any, + any, + any, + any, + any + >[] { return this.getGlobalCompletions().concat(this.getBaseCompletions()); } 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/deno.json b/command/deno.json new file mode 100644 index 00000000..1f9e0723 --- /dev/null +++ b/command/deno.json @@ -0,0 +1,11 @@ +{ + "name": "@cliffy/command", + "version": "1.0.0-rc.4", + "exports": { + ".": "./mod.ts", + "./completions": "./completions/mod.ts", + "./help": "./help/mod.ts", + "./upgrade": "./upgrade/mod.ts" + }, + "lock": false +} diff --git a/command/deps.ts b/command/deps.ts deleted file mode 100644 index 6df20532..00000000 --- a/command/deps.ts +++ /dev/null @@ -1,13 +0,0 @@ -export { - bold, - brightBlue, - brightMagenta, - cyan, - dim, - getColorEnabled, - green, - italic, - red, - setColorEnabled, - yellow, -} from "https://deno.land/std@0.221.0/fmt/colors.ts"; diff --git a/command/help/_help_generator.ts b/command/help/_help_generator.ts index 12f878e4..d0e006a2 100644 --- a/command/help/_help_generator.ts +++ b/command/help/_help_generator.ts @@ -1,4 +1,4 @@ -import { Table } from "../../table/table.ts"; +import { Table } from "@cliffy/table"; import { dedent, getDescription, @@ -17,7 +17,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/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"; diff --git a/command/test/command/action_test.ts b/command/test/command/action_test.ts index 1c85aa81..5263ee07 100644 --- a/command/test/command/action_test.ts +++ b/command/test/command/action_test.ts @@ -1,11 +1,6 @@ -import { - assertEquals, - assertSpyCall, - assertSpyCalls, - assertType, - IsExact, - spy, -} from "../../../dev_deps.ts"; +import { assertEquals } from "@std/assert"; +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/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..68576a09 100644 --- a/command/test/command/arguments_test.ts +++ b/command/test/command/arguments_test.ts @@ -1,10 +1,6 @@ -import { - assertEquals, - assertRejects, - describe, - it, -} from "../../../dev_deps.ts"; -import type { ArgumentValue } from "../../../flags/types.ts"; +import { assertEquals, assertRejects } from "@std/assert"; +import { describe, it } from "@std/testing/bdd"; +import type { ArgumentValue } from "@cliffy/flags"; 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 d22c48c0..b5cea0ab 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 { snapshotTest } from "../../../testing/snapshot.ts"; import { Command } from "../../command.ts"; import { CompletionsCommand } from "../../completions/completions_command.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..b58fb0fa 100644 --- a/command/test/command/error_handler_test.ts +++ b/command/test/command/error_handler_test.ts @@ -1,10 +1,5 @@ -import { - assertEquals, - assertInstanceOf, - assertRejects, - assertSpyCalls, - spy, -} from "../../../dev_deps.ts"; +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/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/generic_types_test.ts b/command/test/command/generic_types_test.ts index 0719e2ba..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 "https://deno.land/x/conditional_type_checks@1.0.6/mod.ts"; +import { assert, IsAny, IsExact } from "conditional_type_checks"; // Not required to execute this code, only type check. (() => { 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 945f65c0..6f76e73f 100644 --- a/command/test/command/hidden_command_test.ts +++ b/command/test/command/hidden_command_test.ts @@ -1,4 +1,5 @@ -import { assertEquals, stripAnsiCode } from "../../../dev_deps.ts"; +import { assertEquals } from "@std/assert"; +import { stripAnsiCode } 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..0d43cf4f 100644 --- a/command/test/command/standalone_test.ts +++ b/command/test/command/standalone_test.ts @@ -1,9 +1,5 @@ -import { - assertEquals, - assertRejects, - assertSpyCalls, - spy, -} from "../../../dev_deps.ts"; +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/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..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 "../../../dev_deps.ts"; +import { assertEquals, assertRejects, assertThrows } 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/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", 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..6cecac0a 100644 --- a/command/test/option/action_test.ts +++ b/command/test/option/action_test.ts @@ -1,11 +1,6 @@ -import { - assert, - assertEquals, - assertSpyCall, - assertSpyCalls, - sinon, - spy, -} from "../../../dev_deps.ts"; +import { assert, assertEquals } from "@std/assert"; +import { assertSpyCall, assertSpyCalls, spy } 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 f1e0d3fa..723ea39c 100644 --- a/command/test/option/hidden_test.ts +++ b/command/test/option/hidden_test.ts @@ -1,4 +1,5 @@ -import { assertEquals, stripAnsiCode } from "../../../dev_deps.ts"; +import { assertEquals } from "@std/assert"; +import { stripAnsiCode } 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 4aad8a6c..52ed80ab 100644 --- a/command/test/type/file_test.ts +++ b/command/test/type/file_test.ts @@ -1,8 +1,5 @@ -import { - assert, - IsExact, -} from "https://deno.land/x/conditional_type_checks@1.0.6/mod.ts"; -import { assertEquals } from "../../../dev_deps.ts"; +import { assert, IsExact } from "conditional_type_checks"; +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/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/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 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/_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 38e09d4f..33c897ce 100644 --- a/command/upgrade/provider.ts +++ b/command/upgrade/provider.ts @@ -1,6 +1,6 @@ -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"; +import { Table } from "@cliffy/table"; export interface Versions { latest: string; 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/deno.jsonc b/deno.jsonc index 17088efa..865e045c 100644 --- a/deno.jsonc +++ b/deno.jsonc @@ -1,10 +1,20 @@ { + "workspaces": [ + "ansi", + "command", + "flags", + "keycode", + "keypress", + "prompt", + "table", + "testing" + ], "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", + "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", @@ -18,5 +28,29 @@ "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": { + "@cliffy/ansi": "jsr:@cliffy/ansi@1.0.0-rc.4", + "@cliffy/command": "jsr:@cliffy/command@1.0.0-rc.4", + "@cliffy/flags": "jsr:@cliffy/flags@1.0.0-rc.4", + "@cliffy/keycode": "jsr:@cliffy/keycode@1.0.0-rc.4", + "@cliffy/keypress": "jsr:@cliffy/keypress@1.0.0-rc.4", + "@cliffy/prompt": "jsr:@cliffy/prompt@1.0.0-rc.4", + "@cliffy/table": "jsr:@cliffy/table@1.0.0-rc.4", + "@cliffy/testing": "jsr:@cliffy/testing@1.0.0-rc.4", + "@std/assert": "jsr:@std/assert@0.221", + "@std/async": "jsr:@std/async@0.221", + "@std/console": "jsr:@std/console@0.221", + "@std/datetime": "jsr:@std/datetime@0.221", + "@std/encoding": "jsr:@std/encoding@0.221", + "@std/fmt": "jsr:@std/fmt@0.221", + "@std/fs": "jsr:@std/fs@0.221", + "@std/http": "jsr:@std/http@0.221", + "@std/io": "jsr:@std/io@0.221", + "@std/path": "jsr:@std/path@0.221", + "@std/testing": "jsr:@std/testing@0.221", + "@std/text": "jsr:@std/text@0.221", + "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 deleted file mode 100644 index 02231361..00000000 --- a/dev_deps.ts +++ /dev/null @@ -1,33 +0,0 @@ -/* std */ -export { - assert, - assertEquals, - assertInstanceOf, - assertRejects, - assertStrictEquals, - assertThrows, -} from "https://deno.land/std@0.221.0/assert/mod.ts"; -export { - assertSpyCall, - assertSpyCalls, - spy, -} from "https://deno.land/std@0.221.0/testing/mock.ts"; -export { assertSnapshot } from "https://deno.land/std@0.221.0/testing/snapshot.ts"; -export { describe, it } from "https://deno.land/std@0.221.0/testing/bdd.ts"; -export { - assertType, - type IsExact, -} from "https://deno.land/std@0.221.0/testing/types.ts"; -export { - bold, - red, - stripAnsiCode, -} from "https://deno.land/std@0.221.0/fmt/colors.ts"; -export { dirname } from "https://deno.land/std@0.221.0/path/dirname.ts"; -export { expandGlob } from "https://deno.land/std@0.221.0/fs/expand_glob.ts"; -export type { WalkEntry } from "https://deno.land/std@0.221.0/fs/walk.ts"; -export { copy } from "https://deno.land/std@0.221.0/io/copy.ts"; -export { format } from "https://deno.land/std@0.221.0/datetime/format.ts"; - -/* 3rd party */ -export { default as sinon } from "https://cdn.skypack.dev/sinon@v13.0.2?dts"; diff --git a/examples/ansi.ts b/examples/ansi.ts index ea8e651e..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 "https://deno.land/std@0.221.0/async/delay.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/examples/ansi/custom.ts b/examples/ansi/custom.ts index 7011d0dc..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.221.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 f358e9f3..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.221.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 8a7bc588..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.221.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 910353a1..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.221.0/fmt/colors.ts"; +import { red } from "@std/fmt/colors"; import { Command } from "../../command/command.ts"; await new Command() 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 7b703830..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 "https://deno.land/std@0.221.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 185176a5..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.221.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 9b905744..75d79ac8 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.221.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/flags/_utils.ts b/flags/_utils.ts index c975d0c8..d8cbc4cc 100644 --- a/flags/_utils.ts +++ b/flags/_utils.ts @@ -1,5 +1,5 @@ import type { FlagOptions } from "./types.ts"; -import { closestString } from "./deps.ts"; +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 new file mode 100644 index 00000000..a1fe34ab --- /dev/null +++ b/flags/deno.json @@ -0,0 +1,6 @@ +{ + "name": "@cliffy/flags", + "version": "1.0.0-rc.4", + "exports": "./mod.ts", + "lock": false +} diff --git a/flags/deps.ts b/flags/deps.ts deleted file mode 100644 index 7a3660d6..00000000 --- a/flags/deps.ts +++ /dev/null @@ -1 +0,0 @@ -export { closestString } from "https://deno.land/std@0.221.0/text/closest_string.ts"; 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/deno.json b/keycode/deno.json new file mode 100644 index 00000000..e3253dce --- /dev/null +++ b/keycode/deno.json @@ -0,0 +1,6 @@ +{ + "name": "@cliffy/keycode", + "version": "1.0.0-rc.4", + "exports": "./mod.ts", + "lock": false +} 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/deno.json b/keypress/deno.json new file mode 100644 index 00000000..99145ba1 --- /dev/null +++ b/keypress/deno.json @@ -0,0 +1,6 @@ +{ + "name": "@cliffy/keypress", + "version": "1.0.0-rc.4", + "exports": "./mod.ts", + "lock": false +} 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/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 72e05515..cfdd314f 100644 --- a/prompt/_generic_input.ts +++ b/prompt/_generic_input.ts @@ -1,11 +1,11 @@ -import type { KeyCode } from "../keycode/key_code.ts"; +import type { KeyCode } from "@cliffy/keycode"; import { GenericPrompt, GenericPromptKeys, GenericPromptOptions, GenericPromptSettings, } from "./_generic_prompt.ts"; -import { brightBlue, dim, stripAnsiCode, underline } from "./deps.ts"; +import { brightBlue, dim, stripAnsiCode, 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 752fe484..af60cc49 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, @@ -6,14 +6,8 @@ import { GenericInputPromptSettings, } from "./_generic_input.ts"; import { WidenType } from "./_utils.ts"; -import { - bold, - brightBlue, - dim, - levenshteinDistance, - stripAnsiCode, - yellow, -} from "./deps.ts"; +import { bold, brightBlue, dim, stripAnsiCode, yellow } from "@std/fmt/colors"; +import { levenshteinDistance } from "@std/text/levenshtein-distance"; import { Figures, getFiguresByKeys } from "./_figures.ts"; type UnsupportedInputOptions = "suggestions" | "list"; @@ -183,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); } @@ -446,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) @@ -456,7 +450,10 @@ 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 " "; } @@ -504,7 +501,7 @@ export abstract class GenericList< return label; } - protected getBreadCrumb() { + protected getBreadCrumb(): string { if (!this.parentOptions.length || !this.settings.maxBreadcrumbItems) { return ""; } @@ -524,7 +521,7 @@ export abstract class GenericList< ); } - protected getListIndex(value?: TValue) { + protected getListIndex(value?: TValue): number { return Math.max( 0, typeof value === "undefined" @@ -538,7 +535,7 @@ export abstract class GenericList< ); } - protected getPageOffset(index: number) { + protected getPageOffset(index: number): number { if (index === 0) { return 0; } diff --git a/prompt/_generic_prompt.ts b/prompt/_generic_prompt.ts index a9b2b592..b7e2221b 100644 --- a/prompt/_generic_prompt.ts +++ b/prompt/_generic_prompt.ts @@ -1,18 +1,17 @@ -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 } from "@cliffy/ansi/tty"; +import { type Cursor } from "@cliffy/ansi/cursor-position"; +import { KeyCode, parse } from "@cliffy/keycode"; import { bold, brightBlue, dim, green, italic, - type Reader, red, stripAnsiCode, - type WriterSync, yellow, -} from "./deps.ts"; +} 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 94908627..c529582f 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, @@ -9,13 +9,11 @@ import { bold, brightBlue, dim, - dirname, - join, - levenshteinDistance, - normalize, stripAnsiCode, underline, -} from "./deps.ts"; +} from "@std/fmt/colors"; +import { levenshteinDistance } from "@std/text/levenshtein-distance"; +import { dirname, join, normalize } from "@std/path"; import { Figures, getFiguresByKeys } from "./_figures.ts"; /** Generic input prompt options. */ diff --git a/prompt/checkbox.ts b/prompt/checkbox.ts index 0e830ba9..f78b6dd0 100644 --- a/prompt/checkbox.ts +++ b/prompt/checkbox.ts @@ -1,6 +1,6 @@ -import type { KeyCode } from "../keycode/mod.ts"; +import type { KeyCode } from "@cliffy/keycode"; 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/deno.json b/prompt/deno.json new file mode 100644 index 00000000..b7a13833 --- /dev/null +++ b/prompt/deno.json @@ -0,0 +1,17 @@ +{ + "name": "@cliffy/prompt", + "version": "1.0.0-rc.4", + "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/prompt/deps.ts b/prompt/deps.ts deleted file mode 100644 index 856cf876..00000000 --- a/prompt/deps.ts +++ /dev/null @@ -1,23 +0,0 @@ -export { - bold, - brightBlue, - dim, - green, - italic, - red, - stripAnsiCode, - underline, - yellow, -} from "https://deno.land/std@0.221.0/fmt/colors.ts"; -export { - dirname, - join, - normalize, -} from "https://deno.land/std@0.221.0/path/mod.ts"; -export type { - Reader, - ReaderSync, - Writer, - WriterSync, -} from "https://deno.land/std@0.221.0/io/types.ts"; -export { levenshteinDistance } from "https://deno.land/std@0.221.0/text/levenshtein_distance.ts"; 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/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..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 "../ansi/tty.ts"; +import { Tty, tty } from "@cliffy/ansi/tty"; import { GenericPrompt, GenericPromptOptions, 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/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 25904d8d..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 { format } from "../../../dev_deps.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 7d87bd43..a8052965 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 { ansi } from "@cliffy/ansi"; +import { assertEquals } from "@std/assert"; +import { assertType, IsExact } from "@std/testing/types"; import { Checkbox, CheckboxOptions } from "../../checkbox.ts"; import { Confirm } from "../../confirm.ts"; import { Input } from "../../input.ts"; @@ -7,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 db88f066..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 { format } from "../../../dev_deps.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", 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 21fe3830..4893b564 100644 --- a/prompt/test/prompt_list_test.ts +++ b/prompt/test/prompt_list_test.ts @@ -1,8 +1,5 @@ -import { - assert, - IsExact, -} from "https://deno.land/x/conditional_type_checks@1.0.6/mod.ts"; -import { assertEquals, assertRejects } from "../../dev_deps.ts"; +import { assert, IsExact } from "conditional_type_checks"; +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..f5a2893c 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 type { KeyCode } from "@cliffy/keycode"; +import { dim, underline } from "@std/fmt/colors"; import { GenericPrompt, GenericPromptKeys, diff --git a/table/_utils.ts b/table/_utils.ts index 63c76d95..55f6dee9 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 { stripAnsiCode, unicodeWidth } from "./deps.ts"; +import { stripAnsiCode } from "@std/fmt/colors"; +import { unicodeWidth } from "@std/console/unicode-width"; /** * Get longest cell from given row index. diff --git a/table/cell.ts b/table/cell.ts index 206fc938..96633e4c 100644 --- a/table/cell.ts +++ b/table/cell.ts @@ -52,7 +52,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) { diff --git a/table/deno.json b/table/deno.json new file mode 100644 index 00000000..36abad50 --- /dev/null +++ b/table/deno.json @@ -0,0 +1,6 @@ +{ + "name": "@cliffy/table", + "version": "1.0.0-rc.4", + "exports": "./mod.ts", + "lock": false +} diff --git a/table/deps.ts b/table/deps.ts deleted file mode 100644 index 394c5af1..00000000 --- a/table/deps.ts +++ /dev/null @@ -1,2 +0,0 @@ -export { stripAnsiCode } from "https://deno.land/std@0.221.0/fmt/colors.ts"; -export { unicodeWidth } from "https://deno.land/std@0.221.0/console/unicode_width.ts"; diff --git a/table/test/align_test.ts b/table/test/align_test.ts index e4df8472..2b093523 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 aecc6529..eab09efc 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/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..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 "../../dev_deps.ts"; +import { assertEquals, assertStrictEquals, assertThrows } 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/deno.json b/testing/deno.json new file mode 100644 index 00000000..ed44a545 --- /dev/null +++ b/testing/deno.json @@ -0,0 +1,6 @@ +{ + "name": "@cliffy/testing", + "version": "1.0.0-rc.4", + "exports": "./mod.ts", + "lock": false +} diff --git a/testing/deps.ts b/testing/deps.ts deleted file mode 100644 index b0e0396e..00000000 --- a/testing/deps.ts +++ /dev/null @@ -1,8 +0,0 @@ -export { AssertionError } from "https://deno.land/std@0.221.0/assert/assertion_error.ts"; -export { assertSnapshot } from "https://deno.land/std@0.221.0/testing/snapshot.ts"; -export { red } from "https://deno.land/std@0.221.0/fmt/colors.ts"; -export { - basename, - dirname, - fromFileUrl, -} from "https://deno.land/std@0.221.0/path/mod.ts"; diff --git a/testing/snapshot.ts b/testing/snapshot.ts index 282971aa..cb69bb5e 100644 --- a/testing/snapshot.ts +++ b/testing/snapshot.ts @@ -1,6 +1,9 @@ -import { eraseDown } from "../ansi/ansi_escapes.ts"; +import { eraseDown } from "@cliffy/ansi/ansi-escapes"; 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 { @@ -80,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", @@ -136,7 +139,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${ @@ -156,7 +159,7 @@ function registerTest(options: SnapshotTestOptions) { } } -async function runPrompt( +async function executeTest( options: SnapshotTestOptions, step?: SnapshotTestStep, ): Promise<{ stdout: string; stderr: string }> { @@ -165,13 +168,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(`--config=${Deno.env.get("CLIFFY_SNAPSHOT_CONFIG")}`); + } + } + 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 ?? [], @@ -194,7 +214,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 ?? 700) + setTimeout( + resolve, + options.timeout ?? Deno.build.os === "windows" ? 1200 : 300, + ) ); } } diff --git a/testing/snapshot_test.ts b/testing/snapshot_test.ts index 715520e8..27a3cb0a 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", @@ -18,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();