diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index b910971e..5015943f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -24,7 +24,9 @@ jobs: - name: Setup Deno uses: denoland/setup-deno@v1 with: - deno-version: ${{ matrix.deno == 'old' && '1.41.1' || (matrix.deno == 'stable' && '1.x' || matrix.deno) }} + # Make sure to keep this in sync with the one defined in version.ts. + # Also don't forget to update README.md. + deno-version: ${{ matrix.deno == 'old' && '1.46.0' || (matrix.deno == 'stable' && '2.x' || matrix.deno) }} - run: deno --version @@ -40,10 +42,16 @@ jobs: if: runner.os == 'Linux' && matrix.deno == 'stable' run: deno check deployctl.ts - - name: Run tests - run: deno task test - - name: action/deps.js up-to-date + if: runner.os == 'Linux' && matrix.deno == 'stable' run: | + # @deno/emit doesn't work if JSR modules are not in the cache. + # This is a workaround to cache the JSR modules beforehand. + deno cache ./src/utils/mod.ts deno run --allow-read --allow-env --allow-net ./tools/bundle.ts ./src/utils/mod.ts > ./action/latest.deps.js diff ./action/latest.deps.js ./action/deps.js + + - name: Run tests + # Deno 1.x does not support lockfile v4. To work around this, we append + # `--no-lock` in this case. + run: deno test -A ${{ matrix.deno == 'old' && '--no-lock' || '' }} tests/ src/ diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 78169c9e..82c97780 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -30,21 +30,21 @@ jobs: root: action/tests entrypoint: include_exclude.ts include: include_exclude.ts - - name: Deploy with comma-separated include + - name: Deploy with comma-separated include uses: ./ with: project: happy-rat-64 root: action entrypoint: tests/include_exclude.ts include: foo,tests/include_exclude.ts,bar - - name: Deploy with comma-separated exclude + - name: Deploy with comma-separated exclude uses: ./ with: project: happy-rat-64 root: action/tests entrypoint: include_exclude.ts exclude: import_bomb1,import_bomb2 - - name: Deploy with multiline exclude + - name: Deploy with multiline exclude uses: ./ with: project: happy-rat-64 @@ -74,4 +74,4 @@ jobs: with: project: happy-rat-64 root: action/tests - entrypoint: always_exclude_node_modules/main.ts \ No newline at end of file + entrypoint: always_exclude_node_modules/main.ts diff --git a/README.md b/README.md index d4a470a0..a38811eb 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,7 @@ contains the `denoland/deployctl` GitHub Action. ## Prerequisite -You need to have Deno 1.41.1+ installed (latest version is recommended; just run +You need to have Deno 1.46.0+ installed (latest version is recommended; just run `deno upgrade`) ## Install diff --git a/action/README.md b/action/README.md index 541733ef..24444b9b 100644 --- a/action/README.md +++ b/action/README.md @@ -40,7 +40,7 @@ jobs: id-token: write # required contents: read steps: - # your steps here... +# your steps here... ``` ### Inputs diff --git a/action/deps.js b/action/deps.js index f88bd8e7..c251f645 100644 --- a/action/deps.js +++ b/action/deps.js @@ -718,299 +718,61 @@ new RegExp([ "[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]+)*|[a-zA-Z\\d]+(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?\\u0007)", "(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TXZcf-nq-uy=><~]))" ].join("|"), "g"); -const { hasOwn } = Object; -class TextLineStream extends TransformStream { - #currentLine = ""; - constructor(options = { - allowCR: false - }){ - super({ - transform: (chars, controller)=>{ - chars = this.#currentLine + chars; - while(true){ - const lfIndex = chars.indexOf("\n"); - const crIndex = options.allowCR ? chars.indexOf("\r") : -1; - if (crIndex !== -1 && crIndex !== chars.length - 1 && (lfIndex === -1 || lfIndex - 1 > crIndex)) { - controller.enqueue(chars.slice(0, crIndex)); - chars = chars.slice(crIndex + 1); - continue; - } - if (lfIndex === -1) break; - const endIndex = chars[lfIndex - 1] === "\r" ? lfIndex - 1 : lfIndex; - controller.enqueue(chars.slice(0, endIndex)); - chars = chars.slice(lfIndex + 1); - } - this.#currentLine = chars; - }, - flush: (controller)=>{ - if (this.#currentLine === "") return; - const currentLine = options.allowCR && this.#currentLine.endsWith("\r") ? this.#currentLine.slice(0, -1) : this.#currentLine; - controller.enqueue(currentLine); - } - }); - } -} -const originalJSONParse = globalThis.JSON.parse; -class JSONCParser { - #whitespace = new Set(" \t\r\n"); - #numberEndToken = new Set([ - ..."[]{}:,/", - ...this.#whitespace - ]); - #text; - #length; - #tokenized; - #options; - constructor(text, options){ - this.#text = `${text}`; - this.#length = this.#text.length; - this.#tokenized = this.#tokenize(); - this.#options = options; - } - parse() { - const token = this.#getNext(); - const res = this.#parseJsonValue(token); - const { done, value } = this.#tokenized.next(); - if (!done) { - throw new SyntaxError(buildErrorMessage(value)); - } - return res; - } - #getNext() { - const { done, value } = this.#tokenized.next(); - if (done) { - throw new SyntaxError("Unexpected end of JSONC input"); - } - return value; - } - *#tokenize() { - for(let i = 0; i < this.#length; i++){ - if (this.#whitespace.has(this.#text[i])) { - continue; - } - if (this.#text[i] === "/" && this.#text[i + 1] === "*") { - i += 2; - let hasEndOfComment = false; - for(; i < this.#length; i++){ - if (this.#text[i] === "*" && this.#text[i + 1] === "/") { - hasEndOfComment = true; - break; - } - } - if (!hasEndOfComment) { - throw new SyntaxError("Unexpected end of JSONC input"); - } - i++; - continue; - } - if (this.#text[i] === "/" && this.#text[i + 1] === "/") { - i += 2; - for(; i < this.#length; i++){ - if (this.#text[i] === "\n" || this.#text[i] === "\r") { - break; - } - } - continue; - } - switch(this.#text[i]){ - case "{": - yield { - type: "BeginObject", - position: i - }; - break; - case "}": - yield { - type: "EndObject", - position: i - }; - break; - case "[": - yield { - type: "BeginArray", - position: i - }; - break; - case "]": - yield { - type: "EndArray", - position: i - }; - break; - case ":": - yield { - type: "NameSeparator", - position: i - }; - break; - case ",": - yield { - type: "ValueSeparator", - position: i - }; - break; - case '"': - { - const startIndex = i; - let shouldEscapeNext = false; - i++; - for(; i < this.#length; i++){ - if (this.#text[i] === '"' && !shouldEscapeNext) { - break; - } - shouldEscapeNext = this.#text[i] === "\\" && !shouldEscapeNext; - } - yield { - type: "String", - sourceText: this.#text.substring(startIndex, i + 1), - position: startIndex - }; - break; - } - default: - { - const startIndex = i; - for(; i < this.#length; i++){ - if (this.#numberEndToken.has(this.#text[i])) { - break; - } - } - i--; - yield { - type: "NullOrTrueOrFalseOrNumber", - sourceText: this.#text.substring(startIndex, i + 1), - position: startIndex - }; - } - } - } - } - #parseJsonValue(value) { - switch(value.type){ - case "BeginObject": - return this.#parseObject(); - case "BeginArray": - return this.#parseArray(); - case "NullOrTrueOrFalseOrNumber": - return this.#parseNullOrTrueOrFalseOrNumber(value); - case "String": - return this.#parseString(value); - default: - throw new SyntaxError(buildErrorMessage(value)); +const DEFAULT_STRINGIFY_OPTIONS = { + verbose: false +}; +function stringify(err, options) { + const opts = options === undefined ? DEFAULT_STRINGIFY_OPTIONS : { + ...DEFAULT_STRINGIFY_OPTIONS, + ...options + }; + if (err instanceof Error) { + if (opts.verbose) { + return stringifyErrorLong(err); + } else { + return stringifyErrorShort(err); } } - #parseObject() { - const target = {}; - for(let isFirst = true;; isFirst = false){ - const token1 = this.#getNext(); - if ((isFirst || this.#options.allowTrailingComma) && token1.type === "EndObject") { - return target; - } - if (token1.type !== "String") { - throw new SyntaxError(buildErrorMessage(token1)); - } - const key = this.#parseString(token1); - const token2 = this.#getNext(); - if (token2.type !== "NameSeparator") { - throw new SyntaxError(buildErrorMessage(token2)); - } - const token3 = this.#getNext(); - Object.defineProperty(target, key, { - value: this.#parseJsonValue(token3), - writable: true, - enumerable: true, - configurable: true - }); - const token4 = this.#getNext(); - if (token4.type === "EndObject") { - return target; - } - if (token4.type !== "ValueSeparator") { - throw new SyntaxError(buildErrorMessage(token4)); - } - } + if (typeof err === "string") { + return err; } - #parseArray() { - const target = []; - for(let isFirst = true;; isFirst = false){ - const token1 = this.#getNext(); - if ((isFirst || this.#options.allowTrailingComma) && token1.type === "EndArray") { - return target; - } - target.push(this.#parseJsonValue(token1)); - const token2 = this.#getNext(); - if (token2.type === "EndArray") { - return target; - } - if (token2.type !== "ValueSeparator") { - throw new SyntaxError(buildErrorMessage(token2)); - } - } + return JSON.stringify(err); +} +function stringifyErrorShort(err) { + return `${err.name}: ${err.message}`; +} +function stringifyErrorLong(err) { + const cause = err.cause === undefined ? "" : `\nCaused by ${stringify(err.cause, { + verbose: true + })}`; + if (!err.stack) { + return `${err.name}: ${err.message}${cause}`; } - #parseString(value) { - let parsed; - try { - parsed = originalJSONParse(value.sourceText); - } catch { - throw new SyntaxError(buildErrorMessage(value)); + return `${err.stack}${cause}`; +} +async function parseEntrypoint(entrypoint, root, diagnosticName = "entrypoint") { + let entrypointSpecifier; + try { + if (isURL(entrypoint)) { + entrypointSpecifier = new URL(entrypoint); + } else { + entrypointSpecifier = toFileUrl2(resolve2(root ?? Deno.cwd(), entrypoint)); } - assert(typeof parsed === "string"); - return parsed; + } catch (err) { + throw `Failed to parse ${diagnosticName} specifier '${entrypoint}': ${stringify(err)}`; } - #parseNullOrTrueOrFalseOrNumber(value) { - if (value.sourceText === "null") { - return null; - } - if (value.sourceText === "true") { - return true; - } - if (value.sourceText === "false") { - return false; - } - let parsed; + if (entrypointSpecifier.protocol === "file:") { try { - parsed = originalJSONParse(value.sourceText); - } catch { - throw new SyntaxError(buildErrorMessage(value)); + await Deno.lstat(entrypointSpecifier); + } catch (err) { + throw `Failed to open ${diagnosticName} file at '${entrypointSpecifier}': ${stringify(err)}`; } - assert(typeof parsed === "number"); - return parsed; } + return entrypointSpecifier; } -function buildErrorMessage({ type, sourceText, position }) { - let token = ""; - switch(type){ - case "BeginObject": - token = "{"; - break; - case "EndObject": - token = "}"; - break; - case "BeginArray": - token = "["; - break; - case "EndArray": - token = "]"; - break; - case "NameSeparator": - token = ":"; - break; - case "ValueSeparator": - token = ","; - break; - case "NullOrTrueOrFalseOrNumber": - case "String": - token = 30 < sourceText.length ? `${sourceText.slice(0, 30)}...` : sourceText; - break; - default: - throw new Error("unreachable"); - } - return `Unexpected token ${token} in JSONC at position ${position}`; +function isURL(entrypoint) { + return entrypoint.startsWith("https://") || entrypoint.startsWith("http://") || entrypoint.startsWith("file://"); } -new TextEncoder(); -new TextEncoder().encode("0123456789abcdef"); -new TextEncoder(); -new TextDecoder(); function delay(ms, options = {}) { const { signal, persistent } = options; if (signal?.aborted) return Promise.reject(signal.reason); @@ -1039,194 +801,41 @@ function delay(ms, options = {}) { } }); } -var _computedKey; -_computedKey = Symbol.asyncIterator; -class MuxAsyncIterator { - #iteratorCount = 0; - #yields = []; - #throws = []; - #signal = Promise.withResolvers(); - add(iterable) { - ++this.#iteratorCount; - this.#callIteratorNext(iterable[Symbol.asyncIterator]()); - } - async #callIteratorNext(iterator) { - try { - const { value, done } = await iterator.next(); - if (done) { - --this.#iteratorCount; - } else { - this.#yields.push({ - iterator, - value - }); - } - } catch (e) { - this.#throws.push(e); - } - this.#signal.resolve(); - } - async *iterate() { - while(this.#iteratorCount > 0){ - await this.#signal.promise; - for (const { iterator, value } of this.#yields){ - yield value; - this.#callIteratorNext(iterator); - } - if (this.#throws.length) { - for (const e of this.#throws){ - throw e; +class TextLineStream extends TransformStream { + #currentLine = ""; + constructor(options = { + allowCR: false + }){ + super({ + transform: (chars, controller)=>{ + chars = this.#currentLine + chars; + while(true){ + const lfIndex = chars.indexOf("\n"); + const crIndex = options.allowCR ? chars.indexOf("\r") : -1; + if (crIndex !== -1 && crIndex !== chars.length - 1 && (lfIndex === -1 || lfIndex - 1 > crIndex)) { + controller.enqueue(chars.slice(0, crIndex)); + chars = chars.slice(crIndex + 1); + continue; + } + if (lfIndex === -1) break; + const endIndex = chars[lfIndex - 1] === "\r" ? lfIndex - 1 : lfIndex; + controller.enqueue(chars.slice(0, endIndex)); + chars = chars.slice(lfIndex + 1); } - this.#throws.length = 0; + this.#currentLine = chars; + }, + flush: (controller)=>{ + if (this.#currentLine === "") return; + const currentLine = options.allowCR && this.#currentLine.endsWith("\r") ? this.#currentLine.slice(0, -1) : this.#currentLine; + controller.enqueue(currentLine); } - this.#yields.length = 0; - this.#signal = Promise.withResolvers(); - } - } - [_computedKey]() { - return this.iterate(); - } -} -function compareNumber(a, b) { - if (isNaN(a) || isNaN(b)) throw new Error("Comparison against non-numbers"); - return a === b ? 0 : a < b ? -1 : 1; -} -function checkIdentifier(v1 = [], v2 = []) { - if (v1.length && !v2.length) return -1; - if (!v1.length && v2.length) return 1; - return 0; -} -function compareIdentifier(v1 = [], v2 = []) { - const length = Math.max(v1.length, v2.length); - for(let i = 0; i < length; i++){ - const a = v1[i]; - const b = v2[i]; - if (a === undefined && b === undefined) return 0; - if (b === undefined) return 1; - if (a === undefined) return -1; - if (typeof a === "string" && typeof b === "number") return 1; - if (typeof a === "number" && typeof b === "string") return -1; - if (a < b) return -1; - if (a > b) return 1; - } - return 0; -} -const NUMERIC_IDENTIFIER = "0|[1-9]\\d*"; -const NON_NUMERIC_IDENTIFIER = "\\d*[a-zA-Z-][a-zA-Z0-9-]*"; -const VERSION_CORE = `(?${NUMERIC_IDENTIFIER})\\.(?${NUMERIC_IDENTIFIER})\\.(?${NUMERIC_IDENTIFIER})`; -const PRERELEASE_IDENTIFIER = `(?:${NUMERIC_IDENTIFIER}|${NON_NUMERIC_IDENTIFIER})`; -const PRERELEASE = `(?:-(?${PRERELEASE_IDENTIFIER}(?:\\.${PRERELEASE_IDENTIFIER})*))`; -const BUILD_IDENTIFIER = "[0-9A-Za-z-]+"; -const BUILD = `(?:\\+(?${BUILD_IDENTIFIER}(?:\\.${BUILD_IDENTIFIER})*))`; -const FULL_VERSION = `v?${VERSION_CORE}${PRERELEASE}?${BUILD}?`; -const FULL_REGEXP = new RegExp(`^${FULL_VERSION}$`); -const COMPARATOR = "(?:<|>)?=?"; -const WILDCARD_IDENTIFIER = `x|X|\\*`; -const XRANGE_IDENTIFIER = `${NUMERIC_IDENTIFIER}|${WILDCARD_IDENTIFIER}`; -const XRANGE = `[v=\\s]*(?${XRANGE_IDENTIFIER})(?:\\.(?${XRANGE_IDENTIFIER})(?:\\.(?${XRANGE_IDENTIFIER})${PRERELEASE}?${BUILD}?)?)?`; -new RegExp(`^(?~>?|\\^|${COMPARATOR})\\s*${XRANGE}$`); -new RegExp(`^(?${COMPARATOR})\\s*(${FULL_VERSION})$|^$`); -function isValidNumber(value) { - return typeof value === "number" && !Number.isNaN(value) && (!Number.isFinite(value) || 0 <= value && value <= Number.MAX_SAFE_INTEGER); -} -const NUMERIC_IDENTIFIER_REGEXP = new RegExp(`^${NUMERIC_IDENTIFIER}$`); -function parsePrerelease(prerelease) { - return prerelease.split(".").filter(Boolean).map((id)=>{ - if (NUMERIC_IDENTIFIER_REGEXP.test(id)) { - const number = Number(id); - if (isValidNumber(number)) return number; - } - return id; - }); -} -function parseBuild(buildmetadata) { - return buildmetadata.split(".").filter(Boolean); -} -function parseNumber(input, errorMessage) { - const number = Number(input); - if (!isValidNumber(number)) throw new TypeError(errorMessage); - return number; -} -function compare(s0, s1) { - if (s0 === s1) return 0; - return compareNumber(s0.major, s1.major) || compareNumber(s0.minor, s1.minor) || compareNumber(s0.patch, s1.patch) || checkIdentifier(s0.prerelease, s1.prerelease) || compareIdentifier(s0.prerelease, s1.prerelease); -} -({ - major: Number.POSITIVE_INFINITY, - minor: Number.POSITIVE_INFINITY, - patch: Number.POSITIVE_INFINITY, - prerelease: [], - build: [] -}); -const MIN = { - major: 0, - minor: 0, - patch: 0, - prerelease: [], - build: [] -}; -({ - major: Number.NEGATIVE_INFINITY, - minor: Number.POSITIVE_INFINITY, - patch: Number.POSITIVE_INFINITY, - prerelease: [], - build: [] -}); -const ANY = { - major: Number.NaN, - minor: Number.NaN, - patch: Number.NaN, - prerelease: [], - build: [] -}; -({ - operator: "", - ...ANY, - semver: ANY -}); -({ - operator: "<", - ...MIN, - semver: MIN -}); -function parse(version) { - if (typeof version !== "string") { - throw new TypeError(`version must be a string`); - } - if (version.length > 256) { - throw new TypeError(`version is longer than ${256} characters`); + }); } - version = version.trim(); - const groups = version.match(FULL_REGEXP)?.groups; - if (!groups) throw new TypeError(`Invalid Version: ${version}`); - const major = parseNumber(groups.major, "Invalid major version"); - const minor = parseNumber(groups.minor, "Invalid minor version"); - const patch = parseNumber(groups.patch, "Invalid patch version"); - const prerelease = groups.prerelease ? parsePrerelease(groups.prerelease) : []; - const build = groups.buildmetadata ? parseBuild(groups.buildmetadata) : []; - return { - major, - minor, - patch, - prerelease, - build - }; -} -function greaterOrEqual(s0, s1) { - return compare(s0, s1) >= 0; } +const VERSION = "1.12.0"; const { Deno: Deno2 } = globalThis; -const noColor = typeof Deno2?.noColor === "boolean" ? Deno2.noColor : true; +const noColor = typeof Deno2?.noColor === "boolean" ? Deno2.noColor : false; let enabled = !noColor; -function setColorEnabled(value) { - if (noColor) { - return; - } - enabled = value; -} -function getColorEnabled() { - return enabled; -} function code(open, close) { return { open: `\x1b[${open.join(";")}m`, @@ -1237,46 +846,6 @@ function code(open, close) { function run(str, code) { return enabled ? `${code.open}${str.replace(code.regexp, code.open)}${code.close}` : str; } -function reset(str) { - return run(str, code([ - 0 - ], 0)); -} -function bold(str) { - return run(str, code([ - 1 - ], 22)); -} -function dim(str) { - return run(str, code([ - 2 - ], 22)); -} -function italic(str) { - return run(str, code([ - 3 - ], 23)); -} -function underline(str) { - return run(str, code([ - 4 - ], 24)); -} -function inverse(str) { - return run(str, code([ - 7 - ], 27)); -} -function hidden(str) { - return run(str, code([ - 8 - ], 28)); -} -function strikethrough(str) { - return run(str, code([ - 9 - ], 29)); -} function black(str) { return run(str, code([ 30 @@ -1325,231 +894,10 @@ function brightBlack(str) { 90 ], 39)); } -function brightRed(str) { - return run(str, code([ - 91 - ], 39)); -} -function brightGreen(str) { - return run(str, code([ - 92 - ], 39)); -} -function brightYellow(str) { - return run(str, code([ - 93 - ], 39)); -} -function brightBlue(str) { - return run(str, code([ - 94 - ], 39)); -} -function brightMagenta(str) { - return run(str, code([ - 95 - ], 39)); -} -function brightCyan(str) { - return run(str, code([ - 96 - ], 39)); -} -function brightWhite(str) { - return run(str, code([ - 97 - ], 39)); -} -function bgBlack(str) { - return run(str, code([ - 40 - ], 49)); -} -function bgRed(str) { - return run(str, code([ - 41 - ], 49)); -} -function bgGreen(str) { - return run(str, code([ - 42 - ], 49)); -} -function bgYellow(str) { - return run(str, code([ - 43 - ], 49)); -} -function bgBlue(str) { - return run(str, code([ - 44 - ], 49)); -} -function bgMagenta(str) { - return run(str, code([ - 45 - ], 49)); -} -function bgCyan(str) { - return run(str, code([ - 46 - ], 49)); -} -function bgWhite(str) { - return run(str, code([ - 47 - ], 49)); -} -function bgBrightBlack(str) { - return run(str, code([ - 100 - ], 49)); -} -function bgBrightRed(str) { - return run(str, code([ - 101 - ], 49)); -} -function bgBrightGreen(str) { - return run(str, code([ - 102 - ], 49)); -} -function bgBrightYellow(str) { - return run(str, code([ - 103 - ], 49)); -} -function bgBrightBlue(str) { - return run(str, code([ - 104 - ], 49)); -} -function bgBrightMagenta(str) { - return run(str, code([ - 105 - ], 49)); -} -function bgBrightCyan(str) { - return run(str, code([ - 106 - ], 49)); -} -function bgBrightWhite(str) { - return run(str, code([ - 107 - ], 49)); -} -function clampAndTruncate(n, max = 255, min = 0) { - return Math.trunc(Math.max(Math.min(n, max), min)); -} -function rgb8(str, color) { - return run(str, code([ - 38, - 5, - clampAndTruncate(color) - ], 39)); -} -function bgRgb8(str, color) { - return run(str, code([ - 48, - 5, - clampAndTruncate(color) - ], 49)); -} -function rgb24(str, color) { - if (typeof color === "number") { - return run(str, code([ - 38, - 2, - color >> 16 & 0xff, - color >> 8 & 0xff, - color & 0xff - ], 39)); - } - return run(str, code([ - 38, - 2, - clampAndTruncate(color.r), - clampAndTruncate(color.g), - clampAndTruncate(color.b) - ], 39)); -} -function bgRgb24(str, color) { - if (typeof color === "number") { - return run(str, code([ - 48, - 2, - color >> 16 & 0xff, - color >> 8 & 0xff, - color & 0xff - ], 49)); - } - return run(str, code([ - 48, - 2, - clampAndTruncate(color.r), - clampAndTruncate(color.g), - clampAndTruncate(color.b) - ], 49)); -} -const ANSI_PATTERN = new RegExp([ +new RegExp([ "[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]+)*|[a-zA-Z\\d]+(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?\\u0007)", - "(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-nq-uy=><~]))" + "(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TXZcf-nq-uy=><~]))" ].join("|"), "g"); -function stripColor(string) { - return string.replace(ANSI_PATTERN, ""); -} -const mod = { - setColorEnabled: setColorEnabled, - getColorEnabled: getColorEnabled, - reset: reset, - bold: bold, - dim: dim, - italic: italic, - underline: underline, - inverse: inverse, - hidden: hidden, - strikethrough: strikethrough, - black: black, - red: red, - green: green, - yellow: yellow, - blue: blue, - magenta: magenta, - cyan: cyan, - white: white, - gray: gray, - brightBlack: brightBlack, - brightRed: brightRed, - brightGreen: brightGreen, - brightYellow: brightYellow, - brightBlue: brightBlue, - brightMagenta: brightMagenta, - brightCyan: brightCyan, - brightWhite: brightWhite, - bgBlack: bgBlack, - bgRed: bgRed, - bgGreen: bgGreen, - bgYellow: bgYellow, - bgBlue: bgBlue, - bgMagenta: bgMagenta, - bgCyan: bgCyan, - bgWhite: bgWhite, - bgBrightBlack: bgBrightBlack, - bgBrightRed: bgBrightRed, - bgBrightGreen: bgBrightGreen, - bgBrightYellow: bgBrightYellow, - bgBrightBlue: bgBrightBlue, - bgBrightMagenta: bgBrightMagenta, - bgBrightCyan: bgBrightCyan, - bgBrightWhite: bgBrightWhite, - rgb8: rgb8, - bgRgb8: bgRgb8, - rgb24: rgb24, - bgRgb24: bgRgb24, - stripColor: stripColor -}; const encoder = new TextEncoder(); function encode(input) { return encoder.encode(input); @@ -2164,23 +1512,12 @@ function ansiRegex({ onlyFirst = false } = {}) { ].join("|"); return new RegExp(pattern, onlyFirst ? undefined : "g"); } -async function isInteractiveAsync(stream) { - if (await Deno.permissions.query({ - name: "env" - })) { - return Deno.isatty(stream.rid) && Deno.env.get("TERM") !== "dumb" && !Deno.env.get("CI"); - } - return Deno.isatty(stream.rid); -} function isInteractive(stream) { - return Deno.isatty(stream.rid); + return stream.isTerminal(); } -const mac = (await Deno.permissions.query({ +(await Deno.permissions.query({ name: "env" })).state === "granted" ? Deno.env.get("TERM_PROGRAM") === "Apple_Terminal" : false; -async function write(str, writer) { - await writer.write(encode(str)); -} function writeSync(str, writer) { writer.writeSync(encode(str)); } @@ -2188,230 +1525,29 @@ function stripAnsi(dirty) { return dirty.replace(ansiRegex(), ""); } const ESC = "\u001B["; -const SAVE = mac ? "\u001B7" : ESC + "s"; -const RESTORE = mac ? "\u001B8" : ESC + "u"; -const POSITION = "6n"; const HIDE = "?25l"; const SHOW = "?25h"; -const SCROLL_UP = "T"; -const SCROLL_DOWN = "S"; const UP = "A"; -const DOWN = "B"; const RIGHT = "C"; -const LEFT = "D"; -const CLEAR_RIGHT = "0K"; -const CLEAR_LEFT = "1K"; const CLEAR_LINE = "2K"; -const CLEAR_DOWN = "0J"; -const CLEAR_UP = "1J"; -const CLEAR_SCREEN = "2J"; -const CLEAR = "\u001Bc"; -const NEXT_LINE = "1E"; -const PREV_LINE = "1F"; -const COLUMN = "1G"; -const HOME = "H"; -async function restore(writer = Deno.stdout) { - await write(RESTORE, writer); -} -async function cursor(action, writer = Deno.stdout) { - await write(ESC + action, writer); -} -async function position(writer = Deno.stdout) { - await cursor(POSITION, writer); -} -async function hideCursor(writer = Deno.stdout) { - await cursor(HIDE, writer); -} -async function showCursor(writer = Deno.stdout) { - await cursor(SHOW, writer); -} -async function scrollUp(writer = Deno.stdout) { - await cursor(SCROLL_UP, writer); -} -async function scrollDown(writer = Deno.stdout) { - await cursor(SCROLL_DOWN, writer); -} -async function clearUp(writer = Deno.stdout) { - await cursor(CLEAR_UP, writer); -} -async function clearDown(writer = Deno.stdout) { - await cursor(CLEAR_DOWN, writer); -} -async function clearLeft(writer = Deno.stdout) { - await cursor(CLEAR_LEFT, writer); -} -async function clearRight(writer = Deno.stdout) { - await cursor(CLEAR_RIGHT, writer); -} -async function clearLine(writer = Deno.stdout) { - await cursor(CLEAR_LINE, writer); -} -async function clearScreen(writer = Deno.stdout) { - await cursor(CLEAR_SCREEN, writer); -} -async function nextLine(writer = Deno.stdout) { - await cursor(NEXT_LINE, writer); -} -async function prevLine(writer = Deno.stdout) { - await cursor(PREV_LINE, writer); -} -async function goHome(writer = Deno.stdout) { - await cursor(HOME, writer); -} -async function goUp(y = 1, writer = Deno.stdout) { - await cursor(y + UP, writer); -} -async function goDown(y = 1, writer = Deno.stdout) { - await cursor(y + DOWN, writer); -} -async function goLeft(x = 1, writer = Deno.stdout) { - await cursor(x + LEFT, writer); -} -async function goRight(x = 1, writer = Deno.stdout) { - await cursor(x + RIGHT, writer); -} -async function goTo(x, y, writer = Deno.stdout) { - await write(ESC + y + ";" + x + HOME, writer); -} -function restoreSync(writer = Deno.stdout) { - writeSync(RESTORE, writer); -} function cursorSync(action, writer = Deno.stdout) { writeSync(ESC + action, writer); } -function positionSync(writer = Deno.stdout) { - cursorSync(POSITION, writer); -} function hideCursorSync(writer = Deno.stdout) { cursorSync(HIDE, writer); } function showCursorSync(writer = Deno.stdout) { cursorSync(SHOW, writer); } -function scrollUpSync(writer = Deno.stdout) { - cursorSync(SCROLL_UP, writer); -} -function scrollDownSync(writer = Deno.stdout) { - cursorSync(SCROLL_DOWN, writer); -} -function clearUpSync(writer = Deno.stdout) { - cursorSync(CLEAR_UP, writer); -} -function clearDownSync(writer = Deno.stdout) { - cursorSync(CLEAR_DOWN, writer); -} -function clearLeftSync(writer = Deno.stdout) { - cursorSync(CLEAR_LEFT, writer); -} -function clearRightSync(writer = Deno.stdout) { - cursorSync(CLEAR_RIGHT, writer); -} function clearLineSync(writer = Deno.stdout) { cursorSync(CLEAR_LINE, writer); } -function clearScreenSync(writer = Deno.stdout) { - cursorSync(CLEAR_SCREEN, writer); -} -function nextLineSync(writer = Deno.stdout) { - cursorSync(NEXT_LINE, writer); -} -function prevLineSync(writer = Deno.stdout) { - cursorSync(PREV_LINE, writer); -} -function goHomeSync(writer = Deno.stdout) { - cursorSync(HOME, writer); -} function goUpSync(y = 1, writer = Deno.stdout) { cursorSync(y + UP, writer); } -function goDownSync(y = 1, writer = Deno.stdout) { - cursorSync(y + DOWN, writer); -} -function goLeftSync(x = 1, writer = Deno.stdout) { - cursorSync(x + LEFT, writer); -} function goRightSync(x = 1, writer = Deno.stdout) { cursorSync(`${x}${RIGHT}`, writer); } -function goToSync(x, y, writer = Deno.stdout) { - writeSync(ESC + y + ";" + x + HOME, writer); -} -const mod1 = await async function() { - return { - ESC: ESC, - SAVE: SAVE, - RESTORE: RESTORE, - POSITION: POSITION, - HIDE: HIDE, - SHOW: SHOW, - SCROLL_UP: SCROLL_UP, - SCROLL_DOWN: SCROLL_DOWN, - UP: UP, - DOWN: DOWN, - RIGHT: RIGHT, - LEFT: LEFT, - CLEAR_RIGHT: CLEAR_RIGHT, - CLEAR_LEFT: CLEAR_LEFT, - CLEAR_LINE: CLEAR_LINE, - CLEAR_DOWN: CLEAR_DOWN, - CLEAR_UP: CLEAR_UP, - CLEAR_SCREEN: CLEAR_SCREEN, - CLEAR: CLEAR, - NEXT_LINE: NEXT_LINE, - PREV_LINE: PREV_LINE, - COLUMN: COLUMN, - HOME: HOME, - write, - restore, - cursor, - position, - hideCursor, - showCursor, - scrollUp, - scrollDown, - clearUp, - clearDown, - clearLeft, - clearRight, - clearLine, - clearScreen, - nextLine, - prevLine, - goHome, - goUp, - goDown, - goLeft, - goRight, - goTo, - writeSync, - restoreSync, - cursorSync, - positionSync, - hideCursorSync, - showCursorSync, - scrollUpSync, - scrollDownSync, - clearUpSync, - clearDownSync, - clearLeftSync, - clearRightSync, - clearLineSync, - clearScreenSync, - nextLineSync, - prevLineSync, - goHomeSync, - goUpSync, - goDownSync, - goLeftSync, - goRightSync, - goToSync, - wcswidth, - ansiRegex, - stripAnsi, - isInteractiveAsync, - isInteractive - }; -}(); const __default1 = { dots: { interval: 80, @@ -3701,29 +2837,29 @@ if ((await Deno.permissions.query({ supported = supported && (!!Deno.env.get("CI") || Deno.env.get("TERM") === "xterm-256color"); } const main = { - info: mod.blue("ℹ"), - success: mod.green("✔"), - warning: mod.yellow("⚠"), - error: mod.red("✖") + info: blue("ℹ"), + success: green("✔"), + warning: yellow("⚠"), + error: red("✖") }; const fallbacks = { - info: mod.blue("i"), - success: mod.green("√"), - warning: mod.yellow("‼"), - error: mod.red("×") + info: blue("i"), + success: green("√"), + warning: yellow("‼"), + error: red("×") }; const symbols = supported ? main : fallbacks; const encoder1 = new TextEncoder(); const colormap = { - black: mod.black, - red: mod.red, - green: mod.green, - yellow: mod.yellow, - blue: mod.blue, - magenta: mod.magenta, - cyan: mod.cyan, - white: mod.white, - gray: mod.gray + black: black, + red: red, + green: green, + yellow: yellow, + blue: blue, + magenta: magenta, + cyan: cyan, + white: white, + gray: gray }; function wait(opts) { if (typeof opts === "string") { @@ -3734,7 +2870,7 @@ function wait(opts) { return new Spinner({ text: opts.text, prefix: opts.prefix ?? "", - color: opts.color ?? mod.cyan, + color: opts.color ?? cyan, spinner: opts.spinner ?? "dots", hideCursor: opts.hideCursor ?? true, indent: opts.indent ?? 0, @@ -3769,10 +2905,10 @@ class Spinner { this.#frameIndex = 0; this.#linesToClear = 0; this.#linesCount = 1; - this.#enabled = typeof opts.enabled === "boolean" ? opts.enabled : mod1.isInteractive(this.#stream); + this.#enabled = typeof opts.enabled === "boolean" ? opts.enabled : isInteractive(this.#stream); if (opts.hideCursor) { addEventListener("unload", ()=>{ - mod1.showCursorSync(this.#stream); + showCursorSync(this.#stream); }); } if (opts.interceptConsole) { @@ -3780,26 +2916,33 @@ class Spinner { } } #spinner = __default1.dots; - #color = mod.cyan; + #color = cyan; #text = ""; #prefix = ""; #interceptConsole() { const methods = [ "log", - "warn", - "error", - "info", "debug", - "time", - "timeEnd", - "trace", + "info", "dir", + "dirxml", + "warn", + "error", "assert", "count", "countReset", "table", - "dirxml", - "timeLog" + "time", + "timeLog", + "timeEnd", + "group", + "groupCollapsed", + "groupEnd", + "clear", + "trace", + "profile", + "profileEnd", + "timeStamp" ]; for (const method of methods){ const original = console[method]; @@ -3844,19 +2987,19 @@ class Spinner { get prefix() { return this.#prefix; } - write(data) { + #write(data) { this.#stream.writeSync(encoder1.encode(data)); } start() { if (!this.#enabled) { if (this.text) { - this.write(`- ${this.text}\n`); + this.#write(`- ${this.text}\n`); } return this; } if (this.isSpinning) return this; if (this.#opts.hideCursor) { - mod1.hideCursorSync(this.#stream); + hideCursorSync(this.#stream); } this.isSpinning = true; this.render(); @@ -3865,7 +3008,7 @@ class Spinner { } render() { this.clear(); - this.write(`${this.frame()}\n`); + this.#write(`${this.frame()}\n`); this.updateLines(); this.#linesToClear = this.#linesCount; } @@ -3881,9 +3024,9 @@ class Spinner { clear() { if (!this.#enabled) return; for(let i = 0; i < this.#linesToClear; i++){ - mod1.goUpSync(1, this.#stream); - mod1.clearLineSync(this.#stream); - mod1.goRightSync(this.indent - 1, this.#stream); + goUpSync(1, this.#stream); + clearLineSync(this.#stream); + goRightSync(this.indent - 1, this.#stream); } this.#linesToClear = 0; } @@ -3893,8 +3036,8 @@ class Spinner { columns = Deno.consoleSize().columns ?? columns; } catch {} const fullPrefixText = typeof this.prefix === "string" ? this.prefix + "-" : ""; - this.#linesCount = mod1.stripAnsi(fullPrefixText + "--" + this.text).split("\n").reduce((count, line)=>{ - return count + Math.max(1, Math.ceil(mod1.wcswidth(line) / columns)); + this.#linesCount = stripAnsi(fullPrefixText + "--" + this.text).split("\n").reduce((count, line)=>{ + return count + Math.max(1, Math.ceil(wcswidth(line) / columns)); }, 0); } stop() { @@ -3905,7 +3048,7 @@ class Spinner { this.clear(); this.isSpinning = false; if (this.#opts.hideCursor) { - mod1.showCursorSync(this.#stream); + showCursorSync(this.#stream); } } stopAndPersist(options = {}) { @@ -3914,7 +3057,7 @@ class Spinner { const text = options.text || this.text; const fullText = typeof text === "string" ? " " + text : ""; this.stop(); - this.write(`${fullPrefix}${options.symbol || " "}${fullText}\n`); + this.#write(`${fullPrefix}${options.symbol || " "}${fullText}\n`); } succeed(text) { return this.stopAndPersist({ @@ -3941,30 +3084,6 @@ class Spinner { }); } } -async function parseEntrypoint(entrypoint, root, diagnosticName = "entrypoint") { - let entrypointSpecifier; - try { - if (isURL(entrypoint)) { - entrypointSpecifier = new URL(entrypoint); - } else { - entrypointSpecifier = toFileUrl2(resolve2(root ?? Deno.cwd(), entrypoint)); - } - } catch (err) { - throw `Failed to parse ${diagnosticName} specifier '${entrypoint}': ${err.message}`; - } - if (entrypointSpecifier.protocol == "file:") { - try { - await Deno.lstat(entrypointSpecifier); - } catch (err) { - throw `Failed to open ${diagnosticName} file at '${entrypointSpecifier}': ${err.message}`; - } - } - return entrypointSpecifier; -} -function isURL(entrypoint) { - return entrypoint.startsWith("https://") || entrypoint.startsWith("http://") || entrypoint.startsWith("file://"); -} -const VERSION = "1.12.0"; let current = null; function wait1(param) { if (typeof param === "string") { @@ -4415,12 +3534,4 @@ export { parseEntrypoint as parseEntrypoint }; export { API as API, APIError as APIError }; export { convertPatternToRegExp as convertPatternToRegExp, walk as walk }; export { fromFileUrl2 as fromFileUrl, resolve2 as resolve }; -function isTerminal(stream) { - if (greaterOrEqual(parse(Deno.version.deno), parse("1.40.0"))) { - return stream.isTerminal(); - } else { - return Deno.isatty(stream.rid); - } -} -export { isTerminal as isTerminal }; diff --git a/action/index.js b/action/index.js index 444b45c1..e9ad0c70 100644 --- a/action/index.js +++ b/action/index.js @@ -10,6 +10,7 @@ import { resolve, walk, } from "./deps.js"; +import process from "node:process"; // The origin of the server to make Deploy requests to. const ORIGIN = process.env.DEPLOY_API_ENDPOINT ?? "https://dash.deno.com"; diff --git a/deno.json b/deno.json deleted file mode 100644 index 560e27c7..00000000 --- a/deno.json +++ /dev/null @@ -1,25 +0,0 @@ -{ - "name": "@deno/deployctl", - "version": "1.12.0", - "exports": "./deployctl.ts", - "fmt": { - "files": { - "exclude": ["action/node_modules/", "vendor/"] - } - }, - "lint": { - "files": { - "exclude": ["action/node_modules/", "vendor/"] - } - }, - "tasks": { - "test": "deno test -A --unstable tests/ src/", - "build-action": "deno run --allow-read --allow-env ./tools/bundle.ts ./src/utils/mod.ts > ./action/deps.js", - "version-match": "deno run --allow-read --allow-env ./tools/version_match.ts" - }, - "imports": { - "https://deno.land/std@0.170.0/fmt/colors.ts": "./vendor/deno.land/std@0.170.0/fmt/colors.ts", - "https://deno.land/x/tty@0.1.4/": "./vendor/deno.land/x/tty@0.1.4/", - "https://raw.githubusercontent.com/denosaurs/wait/453df8babdd72c59d865c5a616c5b04ee1154b9f/": "./vendor/wait-deprecated-warnings-pr-head/" - } -} diff --git a/deno.jsonc b/deno.jsonc new file mode 100644 index 00000000..cfbd8275 --- /dev/null +++ b/deno.jsonc @@ -0,0 +1,37 @@ +{ + "name": "@deno/deployctl", + "version": "1.12.0", + "exports": "./deployctl.ts", + "fmt": { + "exclude": ["action/node_modules/"] + }, + "lint": { + "exclude": ["action/node_modules/"] + }, + "tasks": { + "test": "deno test -A --unstable tests/ src/", + "build-action": "deno run --allow-read --allow-write --allow-net=jsr.io:443 --allow-env ./tools/bundle.ts ./src/utils/mod.ts > ./action/deps.js", + "version-match": "deno run --allow-read --allow-env ./tools/version_match.ts" + }, + "imports": { + "@std/fmt": "jsr:@std/fmt@0.217", + "@std/fmt/colors": "jsr:@std/fmt@0.217/colors", + "@std/path": "jsr:@std/path@0.217", + "@std/flags": "jsr:@std/flags@0.217", + "@std/streams": "jsr:@std/streams@0.217", + "@std/streams/text_line_stream": "jsr:@std/streams@0.217/text_line_stream", + "@std/jsonc": "jsr:@std/jsonc@0.217", + "@std/encoding": "jsr:@std/encoding@0.217", + "@std/async": "jsr:@std/async@0.217", + "@std/async/delay": "jsr:@std/async@0.217/delay", + "@std/dotenv": "jsr:@std/dotenv@0.217", + "@std/semver": "jsr:@std/semver@0.217", + "@std/assert": "jsr:@std/assert@0.217", + "@denosaurs/wait": "jsr:@denosaurs/wait@0.2.2", + "@denosaurs/tty": "jsr:@denosaurs/tty@0.2.1", + "@deno/emit": "jsr:@deno/emit@0.45.0", + // To make @deno/emit use the latest version of @deno/cache-dir. + // Needed until https://github.com/denoland/deno_emit/pull/192 lands + "jsr:@deno/cache-dir@0.8": "jsr:@deno/cache-dir@0.13.0" + } +} diff --git a/deno.lock b/deno.lock index 7f7ec61c..7ee5c6fe 100644 --- a/deno.lock +++ b/deno.lock @@ -1,143 +1,186 @@ { - "version": "3", - "packages": { - "specifiers": { - "jsr:@deno/cache-dir@0.8": "jsr:@deno/cache-dir@0.8.0", - "jsr:@deno/emit@0.43.1": "jsr:@deno/emit@0.43.1", - "jsr:@std/assert@0.217": "jsr:@std/assert@0.217.0", - "jsr:@std/assert@^0.217.0": "jsr:@std/assert@0.217.0", - "jsr:@std/assert@^0.218.2": "jsr:@std/assert@0.218.2", - "jsr:@std/assert@^0.223.0": "jsr:@std/assert@0.223.0", - "jsr:@std/async@0.217": "jsr:@std/async@0.217.0", - "jsr:@std/bytes@^0.218.2": "jsr:@std/bytes@0.218.2", - "jsr:@std/dotenv@0.217": "jsr:@std/dotenv@0.217.0", - "jsr:@std/encoding@0.217": "jsr:@std/encoding@0.217.0", - "jsr:@std/flags@0.217": "jsr:@std/flags@0.217.0", - "jsr:@std/flags@0.217.0": "jsr:@std/flags@0.217.0", - "jsr:@std/fmt@0.217": "jsr:@std/fmt@0.217.0", - "jsr:@std/fmt@^0.217.0": "jsr:@std/fmt@0.217.0", - "jsr:@std/fmt@^0.218.2": "jsr:@std/fmt@0.218.2", - "jsr:@std/fs@^0.218.2": "jsr:@std/fs@0.218.2", - "jsr:@std/io@^0.218.2": "jsr:@std/io@0.218.2", - "jsr:@std/json@^0.217.0": "jsr:@std/json@0.217.0", - "jsr:@std/jsonc@0.217": "jsr:@std/jsonc@0.217.0", - "jsr:@std/path@0.217": "jsr:@std/path@0.217.0", - "jsr:@std/path@1.0.1": "jsr:@std/path@1.0.1", - "jsr:@std/path@^0.218.2": "jsr:@std/path@0.218.2", - "jsr:@std/path@^0.223.0": "jsr:@std/path@0.223.0", - "jsr:@std/semver@0.217": "jsr:@std/semver@0.217.0", - "jsr:@std/streams@0.217": "jsr:@std/streams@0.217.0", - "npm:keychain@1.5.0": "npm:keychain@1.5.0" - }, - "jsr": { - "@deno/cache-dir@0.8.0": { - "integrity": "e87e80a404958f6350d903e6238b72afb92468378b0b32111f7a1e4916ac7fe7", - "dependencies": [ - "jsr:@std/fmt@^0.218.2", - "jsr:@std/fs@^0.218.2", - "jsr:@std/io@^0.218.2", - "jsr:@std/path@^0.218.2" - ] - }, - "@deno/emit@0.43.1": { - "integrity": "4abb1a899b0126990f764e545341f3be592cae80a86faac8365d8076a24177ac", - "dependencies": [ - "jsr:@deno/cache-dir@0.8", - "jsr:@std/path@^0.223.0" - ] - }, - "@std/assert@0.217.0": { - "integrity": "c98e279362ca6982d5285c3b89517b757c1e3477ee9f14eb2fdf80a45aaa9642", - "dependencies": [ - "jsr:@std/fmt@^0.217.0" - ] - }, - "@std/assert@0.218.2": { - "integrity": "7f0a5a1a8cf86607cd6c2c030584096e1ffad27fc9271429a8cb48cfbdee5eaf" - }, - "@std/assert@0.223.0": { - "integrity": "eb8d6d879d76e1cc431205bd346ed4d88dc051c6366365b1af47034b0670be24" - }, - "@std/async@0.217.0": { - "integrity": "14dac94f59595e39e519de379c47170d8bbedea253824c4b167108aa943ddb69", - "dependencies": [ - "jsr:@std/assert@^0.217.0" - ] - }, - "@std/bytes@0.218.2": { - "integrity": "91fe54b232dcca73856b79a817247f4a651dbb60d51baafafb6408c137241670" - }, - "@std/dotenv@0.217.0": { - "integrity": "e65cbbf669f482c320b2f94d0a2fc536f1fcd06afdcfa4fde358129a18d1d428" - }, - "@std/encoding@0.217.0": { - "integrity": "b03e8ff94c98d6b6a02c02c5cf8e5d203400155516248964fc4559abc04669dc" - }, - "@std/flags@0.217.0": { - "integrity": "2d67502692d76cfe37fba1c4a92d0a5fe0a6f9601900fd7c510936b0e4e0242e", - "dependencies": [ - "jsr:@std/assert@^0.217.0" - ] - }, - "@std/fmt@0.217.0": { - "integrity": "cb99f82500b8da20202fedfa8bb94dd0222e81f0494ed9087de20ee3d8a39a8d" - }, - "@std/fmt@0.218.2": { - "integrity": "99526449d2505aa758b6cbef81e7dd471d8b28ec0dcb1491d122b284c548788a" - }, - "@std/fs@0.218.2": { - "integrity": "dd9431453f7282e8c577cc22c9e6d036055a9a980b5549f887d6012969fabcca" - }, - "@std/io@0.218.2": { - "integrity": "c64fbfa087b7c9d4d386c5672f291f607d88cb7d44fc299c20c713e345f2785f", - "dependencies": [ - "jsr:@std/assert@^0.218.2", - "jsr:@std/bytes@^0.218.2" - ] - }, - "@std/json@0.217.0": { - "integrity": "173f1156d23d11095b6ff7df6266c80e8f83afcd9a6af1731ec301f485806986" - }, - "@std/jsonc@0.217.0": { - "integrity": "125c47f36ef8160e1b4fd5bff096e8f0ea3f49bea197de5b182eb130bb8a527c", - "dependencies": [ - "jsr:@std/assert@^0.217.0", - "jsr:@std/json@^0.217.0" - ] - }, - "@std/path@0.217.0": { - "integrity": "1217cc25534bca9a2f672d7fe7c6f356e4027df400c0e85c0ef3e4343bc67d11", - "dependencies": [ - "jsr:@std/assert@^0.217.0" - ] - }, - "@std/path@0.218.2": { - "integrity": "b568fd923d9e53ad76d17c513e7310bda8e755a3e825e6289a0ce536404e2662", - "dependencies": [ - "jsr:@std/assert@^0.218.2" - ] - }, - "@std/path@0.223.0": { - "integrity": "593963402d7e6597f5a6e620931661053572c982fc014000459edc1f93cc3989", - "dependencies": [ - "jsr:@std/assert@^0.223.0" - ] - }, - "@std/path@1.0.1": { - "integrity": "e061ff02c28481ca49e3a14981875c345e9fc7e973190672782cd0ac8af70428" - }, - "@std/semver@0.217.0": { - "integrity": "c1ba42cdcaacf610f1a62ec2256ab29765a73fede65120214c3acb9c85ed3d35" - }, - "@std/streams@0.217.0": { - "integrity": "b4a6de703d6aa59c4777f89fc002e82b8401dada44d1e6f7e916664c1e6cfd36" - } - }, - "npm": { - "keychain@1.5.0": { - "integrity": "sha512-liyp4r+93RI7EB2jhwaRd4MWfdgHH6shuldkaPMkELCJjMFvOOVXuTvw1pGqFfhsrgA6OqfykWWPQgBjQakVag==", - "dependencies": {} - } + "version": "4", + "specifiers": { + "jsr:@deno/cache-dir@0.13.0": "0.13.0", + "jsr:@deno/cache-dir@0.8": "0.8.0", + "jsr:@deno/emit@0.45.0": "0.45.0", + "jsr:@denosaurs/tty@0.2.1": "0.2.1", + "jsr:@denosaurs/tty@~0.2.1": "0.2.1", + "jsr:@denosaurs/wait@0.2.2": "0.2.2", + "jsr:@std/assert@0.217": "0.217.0", + "jsr:@std/assert@0.223": "0.223.0", + "jsr:@std/assert@~0.218.2": "0.218.2", + "jsr:@std/async@0.217": "0.217.0", + "jsr:@std/bytes@0.223": "0.223.0", + "jsr:@std/bytes@~0.218.2": "0.218.2", + "jsr:@std/dotenv@0.217": "0.217.0", + "jsr:@std/encoding@0.217": "0.217.0", + "jsr:@std/flags@0.217": "0.217.0", + "jsr:@std/flags@0.217.0": "0.217.0", + "jsr:@std/fmt@0.217": "0.217.0", + "jsr:@std/fmt@0.223": "0.223.0", + "jsr:@std/fmt@1": "1.0.2", + "jsr:@std/fmt@~0.218.2": "0.218.2", + "jsr:@std/fs@0.223": "0.223.0", + "jsr:@std/fs@~0.218.2": "0.218.2", + "jsr:@std/io@0.223": "0.223.0", + "jsr:@std/io@~0.218.2": "0.218.2", + "jsr:@std/json@0.217": "0.217.0", + "jsr:@std/jsonc@0.217": "0.217.0", + "jsr:@std/path@0.217": "0.217.0", + "jsr:@std/path@0.223": "0.223.0", + "jsr:@std/path@1.0.1": "1.0.1", + "jsr:@std/path@~0.218.2": "0.218.2", + "jsr:@std/semver@0.217": "0.217.0", + "jsr:@std/streams@0.217": "0.217.0", + "npm:keychain@1.5.0": "1.5.0" + }, + "jsr": { + "@deno/cache-dir@0.8.0": { + "integrity": "e87e80a404958f6350d903e6238b72afb92468378b0b32111f7a1e4916ac7fe7", + "dependencies": [ + "jsr:@std/fmt@~0.218.2", + "jsr:@std/fs@~0.218.2", + "jsr:@std/io@~0.218.2", + "jsr:@std/path@~0.218.2" + ] + }, + "@deno/cache-dir@0.13.0": { + "integrity": "0501f1a0c0125635a7ddace1da0181cd64ce0ab7a34834bdc3e8ca7986d2dc6a", + "dependencies": [ + "jsr:@std/fmt@0.223", + "jsr:@std/fs@0.223", + "jsr:@std/io@0.223", + "jsr:@std/path@0.223" + ] + }, + "@deno/emit@0.45.0": { + "integrity": "b59d632e61dbe4be7e9e61235f02ad08ff124c714c31deb080c4de778da1894d", + "dependencies": [ + "jsr:@deno/cache-dir@0.13.0", + "jsr:@deno/cache-dir@0.8", + "jsr:@std/path@0.223" + ] + }, + "@denosaurs/tty@0.2.1": { + "integrity": "f1fc651cc9021c90bf230a45c6eb893c26a54fae6a855e9cd26aad0083d772dd" + }, + "@denosaurs/wait@0.2.2": { + "integrity": "5ec0a7e72c57a96c9fdb2f4a52e2ce3b1ad010acc59fefe6f88054a9e27bc33d", + "dependencies": [ + "jsr:@denosaurs/tty@~0.2.1", + "jsr:@std/fmt@1" + ] + }, + "@std/assert@0.217.0": { + "integrity": "c98e279362ca6982d5285c3b89517b757c1e3477ee9f14eb2fdf80a45aaa9642", + "dependencies": [ + "jsr:@std/fmt@0.217" + ] + }, + "@std/assert@0.218.2": { + "integrity": "7f0a5a1a8cf86607cd6c2c030584096e1ffad27fc9271429a8cb48cfbdee5eaf" + }, + "@std/assert@0.223.0": { + "integrity": "eb8d6d879d76e1cc431205bd346ed4d88dc051c6366365b1af47034b0670be24" + }, + "@std/async@0.217.0": { + "integrity": "14dac94f59595e39e519de379c47170d8bbedea253824c4b167108aa943ddb69", + "dependencies": [ + "jsr:@std/assert@0.217" + ] + }, + "@std/bytes@0.218.2": { + "integrity": "91fe54b232dcca73856b79a817247f4a651dbb60d51baafafb6408c137241670" + }, + "@std/bytes@0.223.0": { + "integrity": "84b75052cd8680942c397c2631318772b295019098f40aac5c36cead4cba51a8" + }, + "@std/dotenv@0.217.0": { + "integrity": "e65cbbf669f482c320b2f94d0a2fc536f1fcd06afdcfa4fde358129a18d1d428" + }, + "@std/encoding@0.217.0": { + "integrity": "b03e8ff94c98d6b6a02c02c5cf8e5d203400155516248964fc4559abc04669dc" + }, + "@std/flags@0.217.0": { + "integrity": "2d67502692d76cfe37fba1c4a92d0a5fe0a6f9601900fd7c510936b0e4e0242e", + "dependencies": [ + "jsr:@std/assert@0.217" + ] + }, + "@std/fmt@0.217.0": { + "integrity": "cb99f82500b8da20202fedfa8bb94dd0222e81f0494ed9087de20ee3d8a39a8d" + }, + "@std/fmt@0.218.2": { + "integrity": "99526449d2505aa758b6cbef81e7dd471d8b28ec0dcb1491d122b284c548788a" + }, + "@std/fmt@0.223.0": { + "integrity": "6deb37794127dfc7d7bded2586b9fc6f5d50e62a8134846608baf71ffc1a5208" + }, + "@std/fmt@1.0.2": { + "integrity": "87e9dfcdd3ca7c066e0c3c657c1f987c82888eb8103a3a3baa62684ffeb0f7a7" + }, + "@std/fs@0.218.2": { + "integrity": "dd9431453f7282e8c577cc22c9e6d036055a9a980b5549f887d6012969fabcca" + }, + "@std/fs@0.223.0": { + "integrity": "3b4b0550b2c524cbaaa5a9170c90e96cbb7354e837ad1bdaf15fc9df1ae9c31c" + }, + "@std/io@0.218.2": { + "integrity": "c64fbfa087b7c9d4d386c5672f291f607d88cb7d44fc299c20c713e345f2785f", + "dependencies": [ + "jsr:@std/assert@~0.218.2", + "jsr:@std/bytes@~0.218.2" + ] + }, + "@std/io@0.223.0": { + "integrity": "2d8c3c2ab3a515619b90da2c6ff5ea7b75a94383259ef4d02116b228393f84f1", + "dependencies": [ + "jsr:@std/assert@0.223", + "jsr:@std/bytes@0.223" + ] + }, + "@std/json@0.217.0": { + "integrity": "173f1156d23d11095b6ff7df6266c80e8f83afcd9a6af1731ec301f485806986" + }, + "@std/jsonc@0.217.0": { + "integrity": "125c47f36ef8160e1b4fd5bff096e8f0ea3f49bea197de5b182eb130bb8a527c", + "dependencies": [ + "jsr:@std/assert@0.217", + "jsr:@std/json" + ] + }, + "@std/path@0.217.0": { + "integrity": "1217cc25534bca9a2f672d7fe7c6f356e4027df400c0e85c0ef3e4343bc67d11", + "dependencies": [ + "jsr:@std/assert@0.217" + ] + }, + "@std/path@0.218.2": { + "integrity": "b568fd923d9e53ad76d17c513e7310bda8e755a3e825e6289a0ce536404e2662", + "dependencies": [ + "jsr:@std/assert@~0.218.2" + ] + }, + "@std/path@0.223.0": { + "integrity": "593963402d7e6597f5a6e620931661053572c982fc014000459edc1f93cc3989", + "dependencies": [ + "jsr:@std/assert@0.223" + ] + }, + "@std/path@1.0.1": { + "integrity": "e061ff02c28481ca49e3a14981875c345e9fc7e973190672782cd0ac8af70428" + }, + "@std/semver@0.217.0": { + "integrity": "c1ba42cdcaacf610f1a62ec2256ab29765a73fede65120214c3acb9c85ed3d35" + }, + "@std/streams@0.217.0": { + "integrity": "b4a6de703d6aa59c4777f89fc002e82b8401dada44d1e6f7e916664c1e6cfd36" + } + }, + "npm": { + "keychain@1.5.0": { + "integrity": "sha512-liyp4r+93RI7EB2jhwaRd4MWfdgHH6shuldkaPMkELCJjMFvOOVXuTvw1pGqFfhsrgA6OqfykWWPQgBjQakVag==" } }, "remote": { @@ -145,5 +188,23 @@ "https://raw.githubusercontent.com/denosaurs/wait/453df8babdd72c59d865c5a616c5b04ee1154b9f/log_symbols.ts": "cdf2d0aa44754d10fddd55999e933886a4d753f2acfc1219f629427ccc776ac7", "https://raw.githubusercontent.com/denosaurs/wait/453df8babdd72c59d865c5a616c5b04ee1154b9f/mod.ts": "cfe3274f577013eb17199b9af74bb76cf2cbef225b91b5d2eee651c4906a1fcb", "https://raw.githubusercontent.com/denosaurs/wait/453df8babdd72c59d865c5a616c5b04ee1154b9f/spinners.ts": "289346d54f8d6152a5dcd67b67e47784cf9b7a8a8f6f0b6dc041ebc2ef6bb76c" + }, + "workspace": { + "dependencies": [ + "jsr:@deno/cache-dir@0.13.0", + "jsr:@deno/emit@0.45.0", + "jsr:@denosaurs/tty@0.2.1", + "jsr:@denosaurs/wait@0.2.2", + "jsr:@std/assert@0.217", + "jsr:@std/async@0.217", + "jsr:@std/dotenv@0.217", + "jsr:@std/encoding@0.217", + "jsr:@std/flags@0.217", + "jsr:@std/fmt@0.217", + "jsr:@std/jsonc@0.217", + "jsr:@std/path@0.217", + "jsr:@std/semver@0.217", + "jsr:@std/streams@0.217" + ] } } diff --git a/deployctl.ts b/deployctl.ts index 5ef4583e..58df3363 100755 --- a/deployctl.ts +++ b/deployctl.ts @@ -3,10 +3,10 @@ // Copyright 2021 Deno Land Inc. All rights reserved. MIT license. import { - semverGreaterThanOrEquals, - semverParse, - setColorEnabled, -} from "./deps.ts"; + greaterOrEqual as semverGreaterThanOrEquals, + parse as semverParse, +} from "@std/semver"; +import { setColorEnabled } from "@std/fmt/colors"; import { type Args, parseArgs } from "./src/args.ts"; import { error } from "./src/error.ts"; import deploySubcommand from "./src/subcommands/deploy.ts"; @@ -21,7 +21,6 @@ import { fetchReleases, getConfigPaths } from "./src/utils/info.ts"; import configFile from "./src/config_file.ts"; import inferConfig from "./src/config_inference.ts"; import { wait } from "./src/utils/spinner.ts"; -import { isTerminal } from "./src/utils/mod.ts"; const help = `deployctl ${VERSION} Command line tool for Deno Deploy. @@ -55,7 +54,7 @@ const args = parseArgs(Deno.args); setColoring(args); -if (isTerminal(Deno.stdin)) { +if (Deno.stdin.isTerminal()) { let latestVersion; // Get the path to the update information json file. const { updatePath } = getConfigPaths(); @@ -183,7 +182,7 @@ function setColoring(args: Args) { } function setAutoColoring() { - if (isTerminal(Deno.stdout)) { + if (Deno.stdout.isTerminal()) { setColorEnabled(true); } else { setColorEnabled(false); diff --git a/deps.ts b/deps.ts deleted file mode 100644 index 159061c0..00000000 --- a/deps.ts +++ /dev/null @@ -1,48 +0,0 @@ -// Copyright 2021 Deno Land Inc. All rights reserved. MIT license. - -// std -export { - basename, - dirname, - extname, - fromFileUrl, - globToRegExp, - isGlob, - join, - normalize, - relative, - resolve, - toFileUrl, -} from "jsr:@std/path@0.217"; -export { - bold, - cyan, - green, - magenta, - red, - setColorEnabled, - stripAnsiCode, - yellow, -} from "jsr:@std/fmt@0.217/colors"; -export { parse } from "jsr:@std/flags@0.217"; -export { TextLineStream } from "jsr:@std/streams@0.217/text_line_stream"; -export * as JSONC from "jsr:@std/jsonc@0.217"; -export { encodeHex } from "jsr:@std/encoding@0.217/hex"; -export { delay } from "jsr:@std/async@0.217"; -export * as dotenv from "jsr:@std/dotenv@0.217"; - -// x/semver -export { - canParse as semverValid, - greaterOrEqual as semverGreaterThanOrEquals, - parse as semverParse, -} from "jsr:@std/semver@0.217"; - -// x/wait -export { - Spinner, - type SpinnerOptions, - wait, -} from "https://raw.githubusercontent.com/denosaurs/wait/453df8babdd72c59d865c5a616c5b04ee1154b9f/mod.ts"; - -export * as tty from "https://deno.land/x/tty@0.1.4/mod.ts"; diff --git a/src/args.ts b/src/args.ts index 47063cfa..90b40a00 100644 --- a/src/args.ts +++ b/src/args.ts @@ -1,6 +1,6 @@ // Copyright 2021 Deno Land Inc. All rights reserved. MIT license. -import { parse } from "../deps.ts"; +import { parse } from "@std/flags"; export function parseArgs(args: string[]) { const parsed = parse(args, { diff --git a/src/config_file.ts b/src/config_file.ts index 10fb5e46..34b0392c 100644 --- a/src/config_file.ts +++ b/src/config_file.ts @@ -1,17 +1,8 @@ // Copyright 2021 Deno Land Inc. All rights reserved. MIT license. -import { - cyan, - dirname, - extname, - green, - join, - JSONC, - magenta, - red, - relative, - resolve, -} from "../deps.ts"; +import { cyan, green, magenta, red } from "@std/fmt/colors"; +import * as JSONC from "@std/jsonc"; +import { dirname, extname, join, relative, resolve } from "@std/path"; import { error } from "./error.ts"; import { isURL } from "./utils/entrypoint.ts"; import { wait } from "./utils/spinner.ts"; diff --git a/src/config_inference.ts b/src/config_inference.ts index 03cee4cb..6f04678f 100644 --- a/src/config_inference.ts +++ b/src/config_inference.ts @@ -1,6 +1,7 @@ // Copyright 2021 Deno Land Inc. All rights reserved. MIT license. -import { basename, magenta } from "../deps.ts"; +import { magenta } from "@std/fmt/colors"; +import { basename } from "@std/path/basename"; import { API, APIError, endpoint } from "./utils/api.ts"; import TokenProvisioner from "./utils/access_token.ts"; import { wait } from "./utils/spinner.ts"; diff --git a/src/error.ts b/src/error.ts index 5f9bec32..0cadd69c 100644 --- a/src/error.ts +++ b/src/error.ts @@ -1,10 +1,56 @@ -import { bold, red } from "../deps.ts"; +// Copyright 2024 Deno Land Inc. All rights reserved. MIT license. -export function printError(message: string) { +import { bold, red } from "@std/fmt/colors"; + +export function error(err: unknown): never { + const message = stringify(err); console.error(red(`${bold("error")}: ${message}`)); + Deno.exit(1); } -export function error(message: string): never { - printError(message); - Deno.exit(1); +export type StringifyOptions = { + verbose: boolean; +}; + +const DEFAULT_STRINGIFY_OPTIONS: StringifyOptions = { + verbose: false, +}; + +export function stringify( + err: unknown, + options?: Partial, +): string { + const opts = options === undefined + ? DEFAULT_STRINGIFY_OPTIONS + : { ...DEFAULT_STRINGIFY_OPTIONS, ...options }; + + if (err instanceof Error) { + if (opts.verbose) { + return stringifyErrorLong(err); + } else { + return stringifyErrorShort(err); + } + } + + if (typeof err === "string") { + return err; + } + + return JSON.stringify(err); +} + +function stringifyErrorShort(err: Error): string { + return `${err.name}: ${err.message}`; +} + +function stringifyErrorLong(err: Error): string { + const cause = err.cause === undefined + ? "" + : `\nCaused by ${stringify(err.cause, { verbose: true })}`; + + if (!err.stack) { + return `${err.name}: ${err.message}${cause}`; + } + + return `${err.stack}${cause}`; } diff --git a/src/error_test.ts b/src/error_test.ts new file mode 100644 index 00000000..f695b2fc --- /dev/null +++ b/src/error_test.ts @@ -0,0 +1,66 @@ +// Copyright 2024 Deno Land Inc. All rights reserved. MIT license. + +import { stringify } from "./error.ts"; +import { assert, assertEquals, assertStringIncludes } from "@std/assert"; + +Deno.test("stringify string", () => { + assertEquals(stringify("test"), "test"); +}); + +Deno.test("stringify number", () => { + assertEquals(stringify(42), "42"); +}); + +Deno.test("stringify object", () => { + assertEquals(stringify({ foo: 42 }), '{"foo":42}'); +}); + +Deno.test("stringify Error (verbose: false)", () => { + const got = stringify(new Error("boom")); + assertEquals(got, "Error: boom"); +}); + +Deno.test("stringify Error (verbose: true)", () => { + const got = stringify(new Error("boom"), { verbose: true }); + assert(got.startsWith("Error: boom\n at "), `assert failed: ${got}`); +}); + +Deno.test("stringify Error with cause (cause is also Error) (verbose: false)", () => { + const e1 = new TypeError("e1"); + const e2 = new SyntaxError("e2", { cause: e1 }); + const got = stringify(e2); + assertEquals(got, "SyntaxError: e2"); +}); + +Deno.test("stringify Error with cause (cause is also Error) (verbose: true)", () => { + const e1 = new TypeError("e1"); + const e2 = new SyntaxError("e2", { cause: e1 }); + const got = stringify(e2, { verbose: true }); + + assert( + got.startsWith("SyntaxError: e2\n at "), + `assert failed: ${got}`, + ); + assertStringIncludes(got, "Caused by TypeError: e1\n at "); +}); + +Deno.test("stringify Error with cause (cause is number) (verbose: false)", () => { + const e = new Error("e", { cause: 42 }); + const got = stringify(e); + assertEquals(got, "Error: e"); +}); + +Deno.test("stringify Error with cause (cause is number) (verbose: true)", () => { + const e = new Error("e", { cause: 42 }); + const got = stringify(e, { verbose: true }); + + assert( + got.startsWith("Error: e\n at "), + `assert failed: ${got}`, + ); + + assert( + got.endsWith("Caused by 42"), + `assert failed: ${got}`, + ); +}); diff --git a/src/subcommands/api.ts b/src/subcommands/api.ts index b3a8ca6b..49c8f53d 100644 --- a/src/subcommands/api.ts +++ b/src/subcommands/api.ts @@ -1,5 +1,5 @@ import type { Args } from "../args.ts"; -import { API, isTerminal } from "../utils/mod.ts"; +import { API } from "../utils/mod.ts"; import TokenProvisioner from "../utils/access_token.ts"; import { error } from "../error.ts"; import { wait } from "../utils/spinner.ts"; @@ -49,7 +49,7 @@ export default async function (args: Args): Promise { format = args.format; break; case undefined: - format = isTerminal(Deno.stdout) ? "overview" : "body"; + format = Deno.stdout.isTerminal() ? "overview" : "body"; break; default: error( diff --git a/src/subcommands/deploy.ts b/src/subcommands/deploy.ts index 7bb6659b..a6e02c4c 100644 --- a/src/subcommands/deploy.ts +++ b/src/subcommands/deploy.ts @@ -1,6 +1,7 @@ // Copyright 2021 Deno Land Inc. All rights reserved. MIT license. -import { fromFileUrl, type Spinner } from "../../deps.ts"; +import type { Spinner } from "@denosaurs/wait"; +import { fromFileUrl } from "@std/path/from_file_url"; import { envVarsFromArgs } from "../utils/env_vars.ts"; import { wait } from "../utils/spinner.ts"; import configFile from "../config_file.ts"; @@ -205,7 +206,7 @@ async function deploy(opts: DeployOpts): Promise { try { project = await api.createProject(opts.project, org?.id); } catch (e) { - error(e.message); + error(e); } projectCreationSpinner.succeed(`Created new project '${opts.project}'.`); wait({ text: "", indent: 3 }).start().info( diff --git a/src/subcommands/deployments.ts b/src/subcommands/deployments.ts index fab092b3..d77ea0dd 100644 --- a/src/subcommands/deployments.ts +++ b/src/subcommands/deployments.ts @@ -15,17 +15,16 @@ import type { import { bold, cyan, - fromFileUrl, green, magenta, red, - type Spinner, stripAnsiCode, - tty, yellow, -} from "../../deps.ts"; +} from "@std/fmt/colors"; +import type { Spinner } from "@denosaurs/wait"; +import * as tty from "@denosaurs/tty"; +import { fromFileUrl } from "@std/path/from_file_url"; import { error } from "../error.ts"; -import { isTerminal } from "../utils/mod.ts"; import { renderCron } from "../utils/crons.ts"; import { renderTimeDelta } from "../utils/time.ts"; @@ -206,7 +205,7 @@ async function listDeployments(args: Args): Promise { format = args.format; break; case undefined: - format = isTerminal(Deno.stdout) ? "overview" : "json"; + format = Deno.stdout.isTerminal() ? "overview" : "json"; break; default: error( @@ -341,7 +340,7 @@ async function showDeployment(args: Args): Promise { format = args.format; break; case undefined: - format = isTerminal(Deno.stdout) ? "overview" : "json"; + format = Deno.stdout.isTerminal() ? "overview" : "json"; break; default: error( diff --git a/src/subcommands/logs_test.ts b/src/subcommands/logs_test.ts index 6bf2ffa3..f5eeef77 100644 --- a/src/subcommands/logs_test.ts +++ b/src/subcommands/logs_test.ts @@ -1,9 +1,5 @@ import { parseArgsForLogSubcommand } from "./logs.ts"; -import { - assertEquals, - assertNotEquals, - assertThrows, -} from "jsr:@std/assert@0.217"; +import { assertEquals, assertNotEquals, assertThrows } from "@std/assert"; import { parseArgs } from "../args.ts"; Deno.test("parseArgsForLogSubcommand", async (t) => { diff --git a/src/subcommands/projects.ts b/src/subcommands/projects.ts index c386e2ec..f3a7ba50 100644 --- a/src/subcommands/projects.ts +++ b/src/subcommands/projects.ts @@ -3,10 +3,11 @@ import { API, APIError, endpoint } from "../utils/api.ts"; import TokenProvisioner from "../utils/access_token.ts"; import { wait } from "../utils/spinner.ts"; import type { Organization, Project } from "../utils/api_types.ts"; -import { bold, green, magenta, red } from "../../deps.ts"; +import { bold, green, magenta, red } from "@std/fmt/colors"; import { error } from "../error.ts"; import organization from "../utils/organization.ts"; import { renderCron } from "../utils/crons.ts"; +import { stringify as stringifyError } from "../error.ts"; const help = `Manage projects in Deno Deploy @@ -264,7 +265,9 @@ async function createProject(args: Args): Promise { ); } catch (error) { spinner.fail( - `Cannot create the project '${args.project}': ${error.message}`, + `Cannot create the project '${args.project}': ${ + stringifyError(error, { verbose: true }) + }`, ); } } @@ -313,7 +316,9 @@ async function renameProject(args: Args): Promise { spinner.succeed(`Project '${currentName}' renamed to '${newName}'`); } catch (error) { spinner.fail( - `Cannot rename the project '${currentName}' to '${newName}': ${error.message}`, + `Cannot rename the project '${currentName}' to '${newName}': ${ + stringifyError(error, { verbose: true }) + }`, ); } } diff --git a/src/subcommands/top.ts b/src/subcommands/top.ts index 63f46046..ffe47786 100644 --- a/src/subcommands/top.ts +++ b/src/subcommands/top.ts @@ -4,11 +4,13 @@ import type { Args } from "../args.ts"; import { API } from "../utils/api.ts"; import TokenProvisioner from "../utils/access_token.ts"; import { wait } from "../utils/spinner.ts"; -import { delay, encodeHex, tty } from "../../deps.ts"; +import * as tty from "@denosaurs/tty"; +import { delay } from "@std/async/delay"; +import { encodeHex } from "@std/encoding/hex"; import { error } from "../error.ts"; import type { ProjectStats } from "../utils/api_types.ts"; import { sha256 } from "../utils/hashing_encoding.ts"; -import { isTerminal } from "../utils/mod.ts"; +import { stringify as stringifyError } from "../error.ts"; const help = ` Project monitoring (ALPHA) @@ -59,7 +61,7 @@ export default async function topSubcommand(args: Args) { format = args.format; break; case undefined: - format = isTerminal(Deno.stdout) ? "table" : "json"; + format = Deno.stdout.isTerminal() ? "table" : "json"; break; default: error( @@ -78,7 +80,9 @@ export default async function topSubcommand(args: Args) { stats = await api.streamMetering(args.project!); } catch (err) { spinner.fail( - `Failed to connect to the stats stream of project '${args.project}': ${err.message}`, + `Failed to connect to the stats stream of project '${args.project}': ${ + stringifyError(err, { verbose: true }) + }`, ); return Deno.exit(1); } diff --git a/src/subcommands/upgrade.ts b/src/subcommands/upgrade.ts index 24291ce0..81788c2f 100644 --- a/src/subcommands/upgrade.ts +++ b/src/subcommands/upgrade.ts @@ -2,10 +2,10 @@ import { error } from "../error.ts"; import { - semverGreaterThanOrEquals, - semverParse, - semverValid, -} from "../../deps.ts"; + canParse as semverValid, + greaterOrEqual as semverGreaterThanOrEquals, + parse as semverParse, +} from "@std/semver"; import { VERSION } from "../version.ts"; const help = `deployctl upgrade diff --git a/src/utils/access_token.ts b/src/utils/access_token.ts index b5f3650d..8b5c585e 100644 --- a/src/utils/access_token.ts +++ b/src/utils/access_token.ts @@ -3,6 +3,7 @@ import { error } from "../error.ts"; import { endpoint, USER_AGENT } from "./api.ts"; import tokenStorage from "./token_storage.ts"; import { base64url, sha256 } from "./hashing_encoding.ts"; +import { stringify as stringifyError } from "../error.ts"; export default { get: tokenStorage.get, @@ -76,7 +77,7 @@ async function provision(): Promise { wait("").start().warn( "Unexpected error while trying to open the authorization URL in your default browser. Please report it at https://github.com/denoland/deployctl/issues/new.", ); - wait({ text: "", indent: 3 }).start().fail(error.toString()); + wait({ text: "", indent: 3 }).start().fail(stringifyError(error)); } } if (open == undefined) { diff --git a/src/utils/api.ts b/src/utils/api.ts index 6901876a..3921654b 100644 --- a/src/utils/api.ts +++ b/src/utils/api.ts @@ -1,4 +1,5 @@ -import { delay, TextLineStream } from "../../deps.ts"; +import { delay } from "@std/async/delay"; +import { TextLineStream } from "@std/streams/text_line_stream"; import { VERSION } from "../version.ts"; import type { @@ -36,7 +37,7 @@ export class APIError extends Error { code: string; xDenoRay: string | null; - name = "APIError"; + override name = "APIError"; constructor(code: string, message: string, xDenoRay: string | null) { super(message); @@ -44,7 +45,7 @@ export class APIError extends Error { this.xDenoRay = xDenoRay; } - toString() { + override toString() { let error = `${this.name}: ${this.message}`; if (this.xDenoRay !== null) { error += `\nx-deno-ray: ${this.xDenoRay}`; diff --git a/src/utils/crons.ts b/src/utils/crons.ts index 1c5cfd8b..b9fab5ce 100644 --- a/src/utils/crons.ts +++ b/src/utils/crons.ts @@ -1,4 +1,4 @@ -import { green, red, stripAnsiCode } from "../../deps.ts"; +import { green, red, stripAnsiCode } from "@std/fmt/colors"; import type { Cron, CronExecutionRetry } from "./api_types.ts"; import { renderTimeDelta } from "./time.ts"; export function renderCron(cron: Cron): string { diff --git a/src/utils/entrypoint.ts b/src/utils/entrypoint.ts index 16f2c855..1c1a5138 100644 --- a/src/utils/entrypoint.ts +++ b/src/utils/entrypoint.ts @@ -1,4 +1,5 @@ -import { resolve, toFileUrl } from "../../deps.ts"; +import { resolve, toFileUrl } from "@std/path"; +import { stringify as stringifyError } from "../error.ts"; /** * Parses the entrypoint to a URL. @@ -17,14 +18,18 @@ export async function parseEntrypoint( entrypointSpecifier = toFileUrl(resolve(root ?? Deno.cwd(), entrypoint)); } } catch (err) { - throw `Failed to parse ${diagnosticName} specifier '${entrypoint}': ${err.message}`; + throw `Failed to parse ${diagnosticName} specifier '${entrypoint}': ${ + stringifyError(err) + }`; } - if (entrypointSpecifier.protocol == "file:") { + if (entrypointSpecifier.protocol === "file:") { try { await Deno.lstat(entrypointSpecifier); } catch (err) { - throw `Failed to open ${diagnosticName} file at '${entrypointSpecifier}': ${err.message}`; + throw `Failed to open ${diagnosticName} file at '${entrypointSpecifier}': ${ + stringifyError(err) + }`; } } diff --git a/src/utils/env_vars.ts b/src/utils/env_vars.ts index 584f63b6..b68fdcab 100644 --- a/src/utils/env_vars.ts +++ b/src/utils/env_vars.ts @@ -1,4 +1,4 @@ -import { dotenv } from "../../deps.ts"; +import * as dotenv from "@std/dotenv"; import type { Args } from "../args.ts"; /** diff --git a/src/utils/info.ts b/src/utils/info.ts index 27179c79..37c4c707 100644 --- a/src/utils/info.ts +++ b/src/utils/info.ts @@ -1,4 +1,4 @@ -import { join } from "../../deps.ts"; +import { join } from "@std/path/join"; import { getVersions } from "../subcommands/upgrade.ts"; export function getConfigPaths() { diff --git a/src/utils/mod.ts b/src/utils/mod.ts index 65075ed1..7564b5f5 100644 --- a/src/utils/mod.ts +++ b/src/utils/mod.ts @@ -1,21 +1,4 @@ -import { semverGreaterThanOrEquals, semverParse } from "../../deps.ts"; - export { parseEntrypoint } from "./entrypoint.ts"; export { API, APIError } from "./api.ts"; export { convertPatternToRegExp, walk } from "./walk.ts"; -export { fromFileUrl, resolve } from "../../deps.ts"; - -// deno-lint-ignore no-explicit-any -export function isTerminal(stream: any) { - if ( - semverGreaterThanOrEquals( - semverParse(Deno.version.deno), - semverParse("1.40.0"), - ) - ) { - return stream.isTerminal(); - } else { - // deno-lint-ignore no-deprecated-deno-api - return Deno.isatty(stream.rid); - } -} +export { fromFileUrl, resolve } from "@std/path"; diff --git a/src/utils/organization.ts b/src/utils/organization.ts index 7a682c8c..48097ef9 100644 --- a/src/utils/organization.ts +++ b/src/utils/organization.ts @@ -26,7 +26,7 @@ export default { spinner.stop(); } } catch (e) { - error(e.message); + error(e); } interruptedSpinner.resume(); return org; diff --git a/src/utils/spinner.ts b/src/utils/spinner.ts index b0dc7f3f..e9bfebd5 100644 --- a/src/utils/spinner.ts +++ b/src/utils/spinner.ts @@ -2,7 +2,7 @@ import { type Spinner, type SpinnerOptions, wait as innerWait, -} from "../../deps.ts"; +} from "@denosaurs/wait"; let current: Spinner | null = null; diff --git a/src/utils/time.ts b/src/utils/time.ts index 20315ea6..7c1d5af2 100644 --- a/src/utils/time.ts +++ b/src/utils/time.ts @@ -1,4 +1,4 @@ -import { yellow } from "../../deps.ts"; +import { yellow } from "@std/fmt/colors"; export function renderTimeDelta(delta: number, language?: string): string { const sinces = [delta]; diff --git a/src/utils/time_test.ts b/src/utils/time_test.ts index e62b87c8..92d44d67 100644 --- a/src/utils/time_test.ts +++ b/src/utils/time_test.ts @@ -1,5 +1,5 @@ -import { yellow } from "../../deps.ts"; -import { assertEquals } from "../../tests/deps.ts"; +import { yellow } from "@std/fmt/colors"; +import { assertEquals } from "@std/assert/assert_equals"; import { renderTimeDelta } from "./time.ts"; Deno.test("renderTimeDelta returns time in milliseconds if below 1 second", () => { diff --git a/src/utils/walk.ts b/src/utils/walk.ts index 5bfc458a..4ed12cd7 100644 --- a/src/utils/walk.ts +++ b/src/utils/walk.ts @@ -1,4 +1,4 @@ -import { globToRegExp, isGlob, join, normalize } from "../../deps.ts"; +import { globToRegExp, isGlob, join, normalize } from "@std/path"; import type { ManifestEntry } from "./api_types.ts"; /** Calculate git object hash, like `git hash-object` does. */ diff --git a/src/utils/walk_test.ts b/src/utils/walk_test.ts index 827af2df..a0996547 100644 --- a/src/utils/walk_test.ts +++ b/src/utils/walk_test.ts @@ -1,4 +1,4 @@ -import { assertEquals } from "../../tests/deps.ts"; +import { assertEquals } from "@std/assert/assert_equals"; import { convertPatternToRegExp } from "./walk.ts"; Deno.test({ diff --git a/src/version.ts b/src/version.ts index 7731f4fd..b4c0ec92 100644 --- a/src/version.ts +++ b/src/version.ts @@ -1,3 +1,5 @@ export const VERSION = "1.12.0"; -export const MINIMUM_DENO_VERSION = "1.41.1"; +// Make sure to keep this in sync with the "old" version in `ci.yml` +// Also don't forget to update README.md. +export const MINIMUM_DENO_VERSION = "1.46.0"; diff --git a/tests/config_file_test/config_file_test.ts b/tests/config_file_test/config_file_test.ts index ad435437..c890b4a2 100644 --- a/tests/config_file_test/config_file_test.ts +++ b/tests/config_file_test/config_file_test.ts @@ -1,6 +1,6 @@ -import { fromFileUrl } from "../../deps.ts"; +import { fromFileUrl } from "@std/path/from_file_url"; import configFile from "../../src/config_file.ts"; -import { assert, assertEquals } from "../deps.ts"; +import { assert, assertEquals } from "@std/assert"; Deno.test("ConfigFile.diff returns array with additions and removals", async () => { const config = await configFile.read( diff --git a/tests/deps.ts b/tests/deps.ts deleted file mode 100644 index b584a267..00000000 --- a/tests/deps.ts +++ /dev/null @@ -1 +0,0 @@ -export * from "jsr:@std/assert@0.217"; diff --git a/tests/env_vars_test/env_vars_test.ts b/tests/env_vars_test/env_vars_test.ts index 47547137..129b97ed 100644 --- a/tests/env_vars_test/env_vars_test.ts +++ b/tests/env_vars_test/env_vars_test.ts @@ -1,6 +1,6 @@ import { parseArgs } from "../../src/args.ts"; import { envVarsFromArgs } from "../../src/utils/env_vars.ts"; -import { assert, assertEquals } from "../deps.ts"; +import { assert, assertEquals } from "@std/assert"; Deno.test("envVarsFromArgs gets env variables from multiple --env options", async () => { const args = parseArgs(["--env=FOO=foo", "--env=BAR=bar"]); diff --git a/tests/help_test.ts b/tests/help_test.ts index cb1a4baa..1fe5b5d5 100644 --- a/tests/help_test.ts +++ b/tests/help_test.ts @@ -1,4 +1,4 @@ -import { assert, assertEquals, assertStringIncludes } from "./deps.ts"; +import { assert, assertEquals, assertStringIncludes } from "@std/assert"; import { output, test } from "./utils.ts"; test({ args: [] }, async (proc) => { diff --git a/tests/utils.ts b/tests/utils.ts index be2a34af..3e2de97c 100644 --- a/tests/utils.ts +++ b/tests/utils.ts @@ -1,3 +1,7 @@ +import { lessThan as semverLessThan, parse as semverParse } from "@std/semver"; +import { assert } from "@std/assert/assert"; +import { MINIMUM_DENO_VERSION } from "../src/version.ts"; + export interface Permissions { net: boolean; read: boolean; @@ -32,6 +36,18 @@ export function deployctl( deno.push("--quiet"); + // Deno 1.x does not support lockfile v4. To work around this, we append + // `--no-lock` in this case. + const v2 = semverParse("2.0.0"); + assert( + semverLessThan(semverParse(MINIMUM_DENO_VERSION), v2), + "We do not support Deno 1.x anymore. Please remove the `isDeno1` check below in the source code.", + ); + const isDeno1 = semverLessThan(semverParse(Deno.version.deno), v2); + if (isDeno1) { + deno.push("--no-lock"); + } + deno.push(new URL("../deployctl.ts", import.meta.url).toString()); const cmd = Deno.build.os == "linux" diff --git a/tools/bundle.ts b/tools/bundle.ts index 29f5fbd9..4243c013 100644 --- a/tools/bundle.ts +++ b/tools/bundle.ts @@ -1,11 +1,17 @@ // Copyright 2024 Deno Land Inc. All rights reserved. MIT license. -import { bundle } from "jsr:@deno/emit@0.43.1"; -import { resolve } from "jsr:@std/path@1.0.1/resolve"; +import { bundle, type ImportMap } from "@deno/emit"; +import { resolve } from "@std/path/resolve"; +import { parse as parseJsonc } from "@std/jsonc"; const entrypoint = Deno.args[0]; const resolvedPath = resolve(Deno.cwd(), entrypoint); -const result = await bundle(resolvedPath); + +const configPath = resolve(Deno.cwd(), "deno.jsonc"); +const config = await Deno.readTextFile(configPath); +const result = await bundle(resolvedPath, { + importMap: parseJsonc(config) as ImportMap, +}); console.log(`// deno-fmt-ignore-file // deno-lint-ignore-file // This code was bundled using \`deno task build-action\` and it's not recommended to edit it manually diff --git a/tools/version_match.ts b/tools/version_match.ts index 83423014..501c7cd9 100644 --- a/tools/version_match.ts +++ b/tools/version_match.ts @@ -5,7 +5,7 @@ // Intended to run when a draft release is created on GitHub. import { VERSION } from "../src/version.ts"; -import { assertEquals } from "jsr:@std/assert@0.217"; +import { assertEquals } from "@std/assert/assert_equals"; const releaseTagVersion = Deno.env.get("RELEASE_TAG")!; assertEquals(VERSION, releaseTagVersion); diff --git a/vendor/deno.land/std@0.170.0/fmt/colors.ts b/vendor/deno.land/std@0.170.0/fmt/colors.ts deleted file mode 100644 index 79fe3619..00000000 --- a/vendor/deno.land/std@0.170.0/fmt/colors.ts +++ /dev/null @@ -1,569 +0,0 @@ -// Copyright 2018-2022 the Deno authors. All rights reserved. MIT license. -// A module to print ANSI terminal colors. Inspired by chalk, kleur, and colors -// on npm. - -/** - * String formatters and utilities for dealing with ANSI color codes. - * - * This module is browser compatible. - * - * This module supports `NO_COLOR` environmental variable disabling any coloring - * if `NO_COLOR` is set. - * - * @example - * ```typescript - * import { - * bgBlue, - * bgRgb24, - * bgRgb8, - * bold, - * italic, - * red, - * rgb24, - * rgb8, - * } from "https://deno.land/std@$STD_VERSION/fmt/colors.ts"; - * - * console.log(bgBlue(italic(red(bold("Hello, World!"))))); - * - * // also supports 8bit colors - * - * console.log(rgb8("Hello, World!", 42)); - * - * console.log(bgRgb8("Hello, World!", 42)); - * - * // and 24bit rgb - * - * console.log(rgb24("Hello, World!", { - * r: 41, - * g: 42, - * b: 43, - * })); - * - * console.log(bgRgb24("Hello, World!", { - * r: 41, - * g: 42, - * b: 43, - * })); - * ``` - * - * @module - */ - -// deno-lint-ignore no-explicit-any -const { Deno } = globalThis as any; -const noColor = typeof Deno?.noColor === "boolean" - ? Deno.noColor as boolean - : true; - -interface Code { - open: string; - close: string; - regexp: RegExp; -} - -/** RGB 8-bits per channel. Each in range `0->255` or `0x00->0xff` */ -interface Rgb { - r: number; - g: number; - b: number; -} - -let enabled = !noColor; - -/** - * Set changing text color to enabled or disabled - * @param value - */ -export function setColorEnabled(value: boolean) { - if (noColor) { - return; - } - - enabled = value; -} - -/** Get whether text color change is enabled or disabled. */ -export function getColorEnabled(): boolean { - return enabled; -} - -/** - * Builds color code - * @param open - * @param close - */ -function code(open: number[], close: number): Code { - return { - open: `\x1b[${open.join(";")}m`, - close: `\x1b[${close}m`, - regexp: new RegExp(`\\x1b\\[${close}m`, "g"), - }; -} - -/** - * Applies color and background based on color code and its associated text - * @param str text to apply color settings to - * @param code color code to apply - */ -function run(str: string, code: Code): string { - return enabled - ? `${code.open}${str.replace(code.regexp, code.open)}${code.close}` - : str; -} - -/** - * Reset the text modified - * @param str text to reset - */ -export function reset(str: string): string { - return run(str, code([0], 0)); -} - -/** - * Make the text bold. - * @param str text to make bold - */ -export function bold(str: string): string { - return run(str, code([1], 22)); -} - -/** - * The text emits only a small amount of light. - * @param str text to dim - */ -export function dim(str: string): string { - return run(str, code([2], 22)); -} - -/** - * Make the text italic. - * @param str text to make italic - */ -export function italic(str: string): string { - return run(str, code([3], 23)); -} - -/** - * Make the text underline. - * @param str text to underline - */ -export function underline(str: string): string { - return run(str, code([4], 24)); -} - -/** - * Invert background color and text color. - * @param str text to invert its color - */ -export function inverse(str: string): string { - return run(str, code([7], 27)); -} - -/** - * Make the text hidden. - * @param str text to hide - */ -export function hidden(str: string): string { - return run(str, code([8], 28)); -} - -/** - * Put horizontal line through the center of the text. - * @param str text to strike through - */ -export function strikethrough(str: string): string { - return run(str, code([9], 29)); -} - -/** - * Set text color to black. - * @param str text to make black - */ -export function black(str: string): string { - return run(str, code([30], 39)); -} - -/** - * Set text color to red. - * @param str text to make red - */ -export function red(str: string): string { - return run(str, code([31], 39)); -} - -/** - * Set text color to green. - * @param str text to make green - */ -export function green(str: string): string { - return run(str, code([32], 39)); -} - -/** - * Set text color to yellow. - * @param str text to make yellow - */ -export function yellow(str: string): string { - return run(str, code([33], 39)); -} - -/** - * Set text color to blue. - * @param str text to make blue - */ -export function blue(str: string): string { - return run(str, code([34], 39)); -} - -/** - * Set text color to magenta. - * @param str text to make magenta - */ -export function magenta(str: string): string { - return run(str, code([35], 39)); -} - -/** - * Set text color to cyan. - * @param str text to make cyan - */ -export function cyan(str: string): string { - return run(str, code([36], 39)); -} - -/** - * Set text color to white. - * @param str text to make white - */ -export function white(str: string): string { - return run(str, code([37], 39)); -} - -/** - * Set text color to gray. - * @param str text to make gray - */ -export function gray(str: string): string { - return brightBlack(str); -} - -/** - * Set text color to bright black. - * @param str text to make bright-black - */ -export function brightBlack(str: string): string { - return run(str, code([90], 39)); -} - -/** - * Set text color to bright red. - * @param str text to make bright-red - */ -export function brightRed(str: string): string { - return run(str, code([91], 39)); -} - -/** - * Set text color to bright green. - * @param str text to make bright-green - */ -export function brightGreen(str: string): string { - return run(str, code([92], 39)); -} - -/** - * Set text color to bright yellow. - * @param str text to make bright-yellow - */ -export function brightYellow(str: string): string { - return run(str, code([93], 39)); -} - -/** - * Set text color to bright blue. - * @param str text to make bright-blue - */ -export function brightBlue(str: string): string { - return run(str, code([94], 39)); -} - -/** - * Set text color to bright magenta. - * @param str text to make bright-magenta - */ -export function brightMagenta(str: string): string { - return run(str, code([95], 39)); -} - -/** - * Set text color to bright cyan. - * @param str text to make bright-cyan - */ -export function brightCyan(str: string): string { - return run(str, code([96], 39)); -} - -/** - * Set text color to bright white. - * @param str text to make bright-white - */ -export function brightWhite(str: string): string { - return run(str, code([97], 39)); -} - -/** - * Set background color to black. - * @param str text to make its background black - */ -export function bgBlack(str: string): string { - return run(str, code([40], 49)); -} - -/** - * Set background color to red. - * @param str text to make its background red - */ -export function bgRed(str: string): string { - return run(str, code([41], 49)); -} - -/** - * Set background color to green. - * @param str text to make its background green - */ -export function bgGreen(str: string): string { - return run(str, code([42], 49)); -} - -/** - * Set background color to yellow. - * @param str text to make its background yellow - */ -export function bgYellow(str: string): string { - return run(str, code([43], 49)); -} - -/** - * Set background color to blue. - * @param str text to make its background blue - */ -export function bgBlue(str: string): string { - return run(str, code([44], 49)); -} - -/** - * Set background color to magenta. - * @param str text to make its background magenta - */ -export function bgMagenta(str: string): string { - return run(str, code([45], 49)); -} - -/** - * Set background color to cyan. - * @param str text to make its background cyan - */ -export function bgCyan(str: string): string { - return run(str, code([46], 49)); -} - -/** - * Set background color to white. - * @param str text to make its background white - */ -export function bgWhite(str: string): string { - return run(str, code([47], 49)); -} - -/** - * Set background color to bright black. - * @param str text to make its background bright-black - */ -export function bgBrightBlack(str: string): string { - return run(str, code([100], 49)); -} - -/** - * Set background color to bright red. - * @param str text to make its background bright-red - */ -export function bgBrightRed(str: string): string { - return run(str, code([101], 49)); -} - -/** - * Set background color to bright green. - * @param str text to make its background bright-green - */ -export function bgBrightGreen(str: string): string { - return run(str, code([102], 49)); -} - -/** - * Set background color to bright yellow. - * @param str text to make its background bright-yellow - */ -export function bgBrightYellow(str: string): string { - return run(str, code([103], 49)); -} - -/** - * Set background color to bright blue. - * @param str text to make its background bright-blue - */ -export function bgBrightBlue(str: string): string { - return run(str, code([104], 49)); -} - -/** - * Set background color to bright magenta. - * @param str text to make its background bright-magenta - */ -export function bgBrightMagenta(str: string): string { - return run(str, code([105], 49)); -} - -/** - * Set background color to bright cyan. - * @param str text to make its background bright-cyan - */ -export function bgBrightCyan(str: string): string { - return run(str, code([106], 49)); -} - -/** - * Set background color to bright white. - * @param str text to make its background bright-white - */ -export function bgBrightWhite(str: string): string { - return run(str, code([107], 49)); -} - -/* Special Color Sequences */ - -/** - * Clam and truncate color codes - * @param n - * @param max number to truncate to - * @param min number to truncate from - */ -function clampAndTruncate(n: number, max = 255, min = 0): number { - return Math.trunc(Math.max(Math.min(n, max), min)); -} - -/** - * Set text color using paletted 8bit colors. - * https://en.wikipedia.org/wiki/ANSI_escape_code#8-bit - * @param str text color to apply paletted 8bit colors to - * @param color code - */ -export function rgb8(str: string, color: number): string { - return run(str, code([38, 5, clampAndTruncate(color)], 39)); -} - -/** - * Set background color using paletted 8bit colors. - * https://en.wikipedia.org/wiki/ANSI_escape_code#8-bit - * @param str text color to apply paletted 8bit background colors to - * @param color code - */ -export function bgRgb8(str: string, color: number): string { - return run(str, code([48, 5, clampAndTruncate(color)], 49)); -} - -/** - * Set text color using 24bit rgb. - * `color` can be a number in range `0x000000` to `0xffffff` or - * an `Rgb`. - * - * To produce the color magenta: - * - * ```ts - * import { rgb24 } from "https://deno.land/std@$STD_VERSION/fmt/colors.ts"; - * rgb24("foo", 0xff00ff); - * rgb24("foo", {r: 255, g: 0, b: 255}); - * ``` - * @param str text color to apply 24bit rgb to - * @param color code - */ -export function rgb24(str: string, color: number | Rgb): string { - if (typeof color === "number") { - return run( - str, - code( - [38, 2, (color >> 16) & 0xff, (color >> 8) & 0xff, color & 0xff], - 39, - ), - ); - } - return run( - str, - code( - [ - 38, - 2, - clampAndTruncate(color.r), - clampAndTruncate(color.g), - clampAndTruncate(color.b), - ], - 39, - ), - ); -} - -/** - * Set background color using 24bit rgb. - * `color` can be a number in range `0x000000` to `0xffffff` or - * an `Rgb`. - * - * To produce the color magenta: - * - * ```ts - * import { bgRgb24 } from "https://deno.land/std@$STD_VERSION/fmt/colors.ts"; - * bgRgb24("foo", 0xff00ff); - * bgRgb24("foo", {r: 255, g: 0, b: 255}); - * ``` - * @param str text color to apply 24bit rgb to - * @param color code - */ -export function bgRgb24(str: string, color: number | Rgb): string { - if (typeof color === "number") { - return run( - str, - code( - [48, 2, (color >> 16) & 0xff, (color >> 8) & 0xff, color & 0xff], - 49, - ), - ); - } - return run( - str, - code( - [ - 48, - 2, - clampAndTruncate(color.r), - clampAndTruncate(color.g), - clampAndTruncate(color.b), - ], - 49, - ), - ); -} - -// https://github.com/chalk/ansi-regex/blob/02fa893d619d3da85411acc8fd4e2eea0e95a9d9/index.js -const ANSI_PATTERN = new RegExp( - [ - "[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]+)*|[a-zA-Z\\d]+(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?\\u0007)", - "(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-nq-uy=><~]))", - ].join("|"), - "g", -); - -/** - * Remove ANSI escape codes from the string. - * @param string to remove ANSI escape codes from - */ -export function stripColor(string: string): string { - return string.replace(ANSI_PATTERN, ""); -} diff --git a/vendor/deno.land/x/tty@0.1.4/ansi_regex.ts b/vendor/deno.land/x/tty@0.1.4/ansi_regex.ts deleted file mode 100644 index 52aaf425..00000000 --- a/vendor/deno.land/x/tty@0.1.4/ansi_regex.ts +++ /dev/null @@ -1,7 +0,0 @@ -export function ansiRegex({ onlyFirst = false } = {}): RegExp { - const pattern = [ - "[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:[a-zA-Z\\d]*(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?\\u0007)", - "(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-ntqry=><~]))", - ].join("|"); - return new RegExp(pattern, onlyFirst ? undefined : "g"); -} diff --git a/vendor/deno.land/x/tty@0.1.4/combining.ts b/vendor/deno.land/x/tty@0.1.4/combining.ts deleted file mode 100644 index 32b26bac..00000000 --- a/vendor/deno.land/x/tty@0.1.4/combining.ts +++ /dev/null @@ -1,144 +0,0 @@ -export default [ - [0x0300, 0x036f], - [0x0483, 0x0486], - [0x0488, 0x0489], - [0x0591, 0x05bd], - [0x05bf, 0x05bf], - [0x05c1, 0x05c2], - [0x05c4, 0x05c5], - [0x05c7, 0x05c7], - [0x0600, 0x0603], - [0x0610, 0x0615], - [0x064b, 0x065e], - [0x0670, 0x0670], - [0x06d6, 0x06e4], - [0x06e7, 0x06e8], - [0x06ea, 0x06ed], - [0x070f, 0x070f], - [0x0711, 0x0711], - [0x0730, 0x074a], - [0x07a6, 0x07b0], - [0x07eb, 0x07f3], - [0x0901, 0x0902], - [0x093c, 0x093c], - [0x0941, 0x0948], - [0x094d, 0x094d], - [0x0951, 0x0954], - [0x0962, 0x0963], - [0x0981, 0x0981], - [0x09bc, 0x09bc], - [0x09c1, 0x09c4], - [0x09cd, 0x09cd], - [0x09e2, 0x09e3], - [0x0a01, 0x0a02], - [0x0a3c, 0x0a3c], - [0x0a41, 0x0a42], - [0x0a47, 0x0a48], - [0x0a4b, 0x0a4d], - [0x0a70, 0x0a71], - [0x0a81, 0x0a82], - [0x0abc, 0x0abc], - [0x0ac1, 0x0ac5], - [0x0ac7, 0x0ac8], - [0x0acd, 0x0acd], - [0x0ae2, 0x0ae3], - [0x0b01, 0x0b01], - [0x0b3c, 0x0b3c], - [0x0b3f, 0x0b3f], - [0x0b41, 0x0b43], - [0x0b4d, 0x0b4d], - [0x0b56, 0x0b56], - [0x0b82, 0x0b82], - [0x0bc0, 0x0bc0], - [0x0bcd, 0x0bcd], - [0x0c3e, 0x0c40], - [0x0c46, 0x0c48], - [0x0c4a, 0x0c4d], - [0x0c55, 0x0c56], - [0x0cbc, 0x0cbc], - [0x0cbf, 0x0cbf], - [0x0cc6, 0x0cc6], - [0x0ccc, 0x0ccd], - [0x0ce2, 0x0ce3], - [0x0d41, 0x0d43], - [0x0d4d, 0x0d4d], - [0x0dca, 0x0dca], - [0x0dd2, 0x0dd4], - [0x0dd6, 0x0dd6], - [0x0e31, 0x0e31], - [0x0e34, 0x0e3a], - [0x0e47, 0x0e4e], - [0x0eb1, 0x0eb1], - [0x0eb4, 0x0eb9], - [0x0ebb, 0x0ebc], - [0x0ec8, 0x0ecd], - [0x0f18, 0x0f19], - [0x0f35, 0x0f35], - [0x0f37, 0x0f37], - [0x0f39, 0x0f39], - [0x0f71, 0x0f7e], - [0x0f80, 0x0f84], - [0x0f86, 0x0f87], - [0x0f90, 0x0f97], - [0x0f99, 0x0fbc], - [0x0fc6, 0x0fc6], - [0x102d, 0x1030], - [0x1032, 0x1032], - [0x1036, 0x1037], - [0x1039, 0x1039], - [0x1058, 0x1059], - [0x1160, 0x11ff], - [0x135f, 0x135f], - [0x1712, 0x1714], - [0x1732, 0x1734], - [0x1752, 0x1753], - [0x1772, 0x1773], - [0x17b4, 0x17b5], - [0x17b7, 0x17bd], - [0x17c6, 0x17c6], - [0x17c9, 0x17d3], - [0x17dd, 0x17dd], - [0x180b, 0x180d], - [0x18a9, 0x18a9], - [0x1920, 0x1922], - [0x1927, 0x1928], - [0x1932, 0x1932], - [0x1939, 0x193b], - [0x1a17, 0x1a18], - [0x1b00, 0x1b03], - [0x1b34, 0x1b34], - [0x1b36, 0x1b3a], - [0x1b3c, 0x1b3c], - [0x1b42, 0x1b42], - [0x1b6b, 0x1b73], - [0x1dc0, 0x1dca], - [0x1dfe, 0x1dff], - [0x200b, 0x200f], - [0x202a, 0x202e], - [0x2060, 0x2063], - [0x206a, 0x206f], - [0x20d0, 0x20ef], - [0x302a, 0x302f], - [0x3099, 0x309a], - [0xa806, 0xa806], - [0xa80b, 0xa80b], - [0xa825, 0xa826], - [0xfb1e, 0xfb1e], - [0xfe00, 0xfe0f], - [0xfe20, 0xfe23], - [0xfeff, 0xfeff], - [0xfff9, 0xfffb], - [0x10a01, 0x10a03], - [0x10a05, 0x10a06], - [0x10a0c, 0x10a0f], - [0x10a38, 0x10a3a], - [0x10a3f, 0x10a3f], - [0x1d167, 0x1d169], - [0x1d173, 0x1d182], - [0x1d185, 0x1d18b], - [0x1d1aa, 0x1d1ad], - [0x1d242, 0x1d244], - [0xe0001, 0xe0001], - [0xe0020, 0xe007f], - [0xe0100, 0xe01ef], -]; diff --git a/vendor/deno.land/x/tty@0.1.4/is_interactive.ts b/vendor/deno.land/x/tty@0.1.4/is_interactive.ts deleted file mode 100644 index 152f916b..00000000 --- a/vendor/deno.land/x/tty@0.1.4/is_interactive.ts +++ /dev/null @@ -1,14 +0,0 @@ -export async function isInteractiveAsync(stream: { rid: number }): Promise { - if (await Deno.permissions.query({ name: "env" })) { - return ( - Deno.isatty(stream.rid) && - Deno.env.get("TERM") !== "dumb" && - !Deno.env.get("CI") - ); - } - return Deno.isatty(stream.rid); -} - -export function isInteractive(stream: { rid: number }): boolean { - return Deno.isatty(stream.rid); -} diff --git a/vendor/deno.land/x/tty@0.1.4/mod.ts b/vendor/deno.land/x/tty@0.1.4/mod.ts deleted file mode 100644 index b6c3eeb2..00000000 --- a/vendor/deno.land/x/tty@0.1.4/mod.ts +++ /dev/null @@ -1,42 +0,0 @@ -const mac = (await Deno.permissions.query({ name: "env" })).state === "granted" - ? Deno.env.get("TERM_PROGRAM") === "Apple_Terminal" - : false; - -export const ESC = "\u001B["; - -export const SAVE = mac ? "\u001B7" : ESC + "s"; -export const RESTORE = mac ? "\u001B8" : ESC + "u"; -export const POSITION = "6n"; -export const HIDE = "?25l"; -export const SHOW = "?25h"; -export const SCROLL_UP = "T"; -export const SCROLL_DOWN = "S"; - -export const UP = "A"; -export const DOWN = "B"; -export const RIGHT = "C"; -export const LEFT = "D"; - -export const CLEAR_RIGHT = "0K"; -export const CLEAR_LEFT = "1K"; -export const CLEAR_LINE = "2K"; - -export const CLEAR_DOWN = "0J"; -export const CLEAR_UP = "1J"; -export const CLEAR_SCREEN = "2J"; -export const CLEAR = "\u001Bc"; - -export const NEXT_LINE = "1E"; -export const PREV_LINE = "1F"; -export const COLUMN = "1G"; // left? -export const HOME = "H"; - -export type SyncStream = Deno.WriterSync; -export type AsyncStream = Deno.Writer; - -export * from "./tty_async.ts"; -export * from "./tty_sync.ts"; -export * from "./wcwidth.ts"; -export * from "./ansi_regex.ts"; -export * from "./strip_ansi.ts"; -export * from "./is_interactive.ts"; diff --git a/vendor/deno.land/x/tty@0.1.4/strip_ansi.ts b/vendor/deno.land/x/tty@0.1.4/strip_ansi.ts deleted file mode 100644 index dbe0bc16..00000000 --- a/vendor/deno.land/x/tty@0.1.4/strip_ansi.ts +++ /dev/null @@ -1,5 +0,0 @@ -import { ansiRegex } from "./mod.ts"; - -export function stripAnsi(dirty: string): string { - return dirty.replace(ansiRegex(), ""); -} diff --git a/vendor/deno.land/x/tty@0.1.4/tty_async.ts b/vendor/deno.land/x/tty@0.1.4/tty_async.ts deleted file mode 100644 index 31cf5754..00000000 --- a/vendor/deno.land/x/tty@0.1.4/tty_async.ts +++ /dev/null @@ -1,160 +0,0 @@ -import { encode } from "./util.ts"; - -import { - AsyncStream, - CLEAR_DOWN, - CLEAR_LEFT, - CLEAR_LINE, - CLEAR_RIGHT, - CLEAR_SCREEN, - CLEAR_UP, - DOWN, - ESC, - HIDE, - HOME, - LEFT, - NEXT_LINE, - POSITION, - PREV_LINE, - RESTORE, - RIGHT, - SCROLL_DOWN, - SCROLL_UP, - SHOW, - UP, -} from "./mod.ts"; - -export async function write(str: string, writer: AsyncStream): Promise { - await writer.write(encode(str)); -} - -export async function restore( - writer: AsyncStream = Deno.stdout, -): Promise { - await write(RESTORE, writer); -} - -export async function cursor( - action: string, - writer: AsyncStream = Deno.stdout, -): Promise { - await write(ESC + action, writer); -} - -export async function position( - writer: AsyncStream = Deno.stdout, -): Promise { - await cursor(POSITION, writer); -} - -export async function hideCursor( - writer: AsyncStream = Deno.stdout, -): Promise { - await cursor(HIDE, writer); -} - -export async function showCursor( - writer: AsyncStream = Deno.stdout, -): Promise { - await cursor(SHOW, writer); -} - -export async function scrollUp( - writer: AsyncStream = Deno.stdout, -): Promise { - await cursor(SCROLL_UP, writer); -} - -export async function scrollDown( - writer: AsyncStream = Deno.stdout, -): Promise { - await cursor(SCROLL_DOWN, writer); -} - -export async function clearUp( - writer: AsyncStream = Deno.stdout, -): Promise { - await cursor(CLEAR_UP, writer); -} - -export async function clearDown( - writer: AsyncStream = Deno.stdout, -): Promise { - await cursor(CLEAR_DOWN, writer); -} - -export async function clearLeft( - writer: AsyncStream = Deno.stdout, -): Promise { - await cursor(CLEAR_LEFT, writer); -} - -export async function clearRight( - writer: AsyncStream = Deno.stdout, -): Promise { - await cursor(CLEAR_RIGHT, writer); -} - -export async function clearLine( - writer: AsyncStream = Deno.stdout, -): Promise { - await cursor(CLEAR_LINE, writer); -} - -export async function clearScreen( - writer: AsyncStream = Deno.stdout, -): Promise { - await cursor(CLEAR_SCREEN, writer); -} - -export async function nextLine( - writer: AsyncStream = Deno.stdout, -): Promise { - await cursor(NEXT_LINE, writer); -} - -export async function prevLine( - writer: AsyncStream = Deno.stdout, -): Promise { - await cursor(PREV_LINE, writer); -} - -export async function goHome(writer: AsyncStream = Deno.stdout): Promise { - await cursor(HOME, writer); -} - -export async function goUp( - y = 1, - writer: AsyncStream = Deno.stdout, -): Promise { - await cursor(y + UP, writer); -} - -export async function goDown( - y = 1, - writer: AsyncStream = Deno.stdout, -): Promise { - await cursor(y + DOWN, writer); -} - -export async function goLeft( - x = 1, - writer: AsyncStream = Deno.stdout, -): Promise { - await cursor(x + LEFT, writer); -} - -export async function goRight( - x = 1, - writer: AsyncStream = Deno.stdout, -): Promise { - await cursor(x + RIGHT, writer); -} - -export async function goTo( - x: number, - y: number, - writer: AsyncStream = Deno.stdout, -): Promise { - await write(ESC + y + ";" + x + HOME, writer); -} diff --git a/vendor/deno.land/x/tty@0.1.4/tty_sync.ts b/vendor/deno.land/x/tty@0.1.4/tty_sync.ts deleted file mode 100644 index 98cb0aba..00000000 --- a/vendor/deno.land/x/tty@0.1.4/tty_sync.ts +++ /dev/null @@ -1,120 +0,0 @@ -import { encode } from "./util.ts"; - -import { - CLEAR_DOWN, - CLEAR_LEFT, - CLEAR_LINE, - CLEAR_RIGHT, - CLEAR_SCREEN, - CLEAR_UP, - DOWN, - ESC, - HIDE, - HOME, - LEFT, - NEXT_LINE, - POSITION, - PREV_LINE, - RESTORE, - RIGHT, - SCROLL_DOWN, - SCROLL_UP, - SHOW, - SyncStream, - UP, -} from "./mod.ts"; - -export function writeSync(str: string, writer: SyncStream): void { - writer.writeSync(encode(str)); -} - -export function restoreSync(writer: SyncStream = Deno.stdout): void { - writeSync(RESTORE, writer); -} - -export function cursorSync( - action: string, - writer: SyncStream = Deno.stdout, -): void { - writeSync(ESC + action, writer); -} - -export function positionSync(writer: SyncStream = Deno.stdout): void { - cursorSync(POSITION, writer); -} - -export function hideCursorSync(writer: SyncStream = Deno.stdout): void { - cursorSync(HIDE, writer); -} - -export function showCursorSync(writer: SyncStream = Deno.stdout): void { - cursorSync(SHOW, writer); -} - -export function scrollUpSync(writer: SyncStream = Deno.stdout): void { - cursorSync(SCROLL_UP, writer); -} - -export function scrollDownSync(writer: SyncStream = Deno.stdout): void { - cursorSync(SCROLL_DOWN, writer); -} - -export function clearUpSync(writer: SyncStream = Deno.stdout): void { - cursorSync(CLEAR_UP, writer); -} - -export function clearDownSync(writer: SyncStream = Deno.stdout): void { - cursorSync(CLEAR_DOWN, writer); -} - -export function clearLeftSync(writer: SyncStream = Deno.stdout): void { - cursorSync(CLEAR_LEFT, writer); -} - -export function clearRightSync(writer: SyncStream = Deno.stdout): void { - cursorSync(CLEAR_RIGHT, writer); -} - -export function clearLineSync(writer: SyncStream = Deno.stdout): void { - cursorSync(CLEAR_LINE, writer); -} - -export function clearScreenSync(writer: SyncStream = Deno.stdout): void { - cursorSync(CLEAR_SCREEN, writer); -} - -export function nextLineSync(writer: SyncStream = Deno.stdout): void { - cursorSync(NEXT_LINE, writer); -} - -export function prevLineSync(writer: SyncStream = Deno.stdout): void { - cursorSync(PREV_LINE, writer); -} - -export function goHomeSync(writer: SyncStream = Deno.stdout): void { - cursorSync(HOME, writer); -} - -export function goUpSync(y = 1, writer: SyncStream = Deno.stdout): void { - cursorSync(y + UP, writer); -} - -export function goDownSync(y = 1, writer: SyncStream = Deno.stdout): void { - cursorSync(y + DOWN, writer); -} - -export function goLeftSync(x = 1, writer: SyncStream = Deno.stdout): void { - cursorSync(x + LEFT, writer); -} - -export function goRightSync(x = 1, writer: SyncStream = Deno.stdout): void { - cursorSync(`${x}${RIGHT}`, writer); -} - -export function goToSync( - x: number, - y: number, - writer: SyncStream = Deno.stdout, -): void { - writeSync(ESC + y + ";" + x + HOME, writer); -} diff --git a/vendor/deno.land/x/tty@0.1.4/util.ts b/vendor/deno.land/x/tty@0.1.4/util.ts deleted file mode 100644 index 89415f02..00000000 --- a/vendor/deno.land/x/tty@0.1.4/util.ts +++ /dev/null @@ -1,5 +0,0 @@ -export const encoder = new TextEncoder(); - -export function encode(input?: string): Uint8Array { - return encoder.encode(input); -} diff --git a/vendor/deno.land/x/tty@0.1.4/wcwidth.ts b/vendor/deno.land/x/tty@0.1.4/wcwidth.ts deleted file mode 100644 index 4221830b..00000000 --- a/vendor/deno.land/x/tty@0.1.4/wcwidth.ts +++ /dev/null @@ -1,92 +0,0 @@ -import combining from "./combining.ts"; - -export type Defaults = { - nul?: number; - control?: number; -}; - -/* - * The following functions define the column width of an ISO 10646 - * character as follows: - * - The null character (U+0000) has a column width of 0. - * - Other C0/C1 control characters and DEL will lead to a return value - * of -1. - * - Non-spacing and enclosing combining characters (general category - * code Mn or Me in the - * Unicode database) have a column width of 0. - * - SOFT HYPHEN (U+00AD) has a column width of 1. - * - Other format characters (general category code Cf in the Unicode - * database) and ZERO WIDTH - * SPACE (U+200B) have a column width of 0. - * - Hangul Jamo medial vowels and final consonants (U+1160-U+11FF) - * have a column width of 0. - * - Spacing characters in the East Asian Wide (W) or East Asian - * Full-width (F) category as - * defined in Unicode Technical Report #11 have a column width of 2. - * - All remaining characters (including all printable ISO 8859-1 and - * WGL4 characters, Unicode control characters, etc.) have a column - * width of 1. - * This implementation assumes that characters are encoded in ISO 10646. - */ -export function wcswidth( - str: string, - { nul = 0, control = 0 }: Defaults = {}, -): number { - const opts = { nul, control }; - if (typeof str !== "string") return wcwidth(str, opts); - - let s = 0; - for (let i = 0; i < str.length; i++) { - const n = wcwidth(str.charCodeAt(i), opts); - if (n < 0) return -1; - s += n; - } - - return s; -} - -function wcwidth(ucs: number, { nul = 0, control = 0 }: Defaults = {}): number { - // test for 8-bit control characters - if (ucs === 0) return nul; - if (ucs < 32 || (ucs >= 0x7f && ucs < 0xa0)) return control; - - // binary search in table of non-spacing characters - if (bisearch(ucs)) return 0; - - // if we arrive here, ucs is not a combining or C0/C1 control character - return ( - 1 + - (ucs >= 0x1100 && - (ucs <= 0x115f || // Hangul Jamo init. consonants - ucs == 0x2329 || - ucs == 0x232a || - (ucs >= 0x2e80 && ucs <= 0xa4cf && ucs != 0x303f) || // CJK ... Yi - (ucs >= 0xac00 && ucs <= 0xd7a3) || // Hangul Syllables - (ucs >= 0xf900 && ucs <= 0xfaff) || // CJK Compatibility Ideographs - (ucs >= 0xfe10 && ucs <= 0xfe19) || // Vertical forms - (ucs >= 0xfe30 && ucs <= 0xfe6f) || // CJK Compatibility Forms - (ucs >= 0xff00 && ucs <= 0xff60) || // Fullwidth Forms - (ucs >= 0xffe0 && ucs <= 0xffe6) || - (ucs >= 0x20000 && ucs <= 0x2fffd) || - (ucs >= 0x30000 && ucs <= 0x3fffd)) - ? 1 - : 0) - ); -} - -function bisearch(ucs: number): boolean { - let min = 0; - let max = combining.length - 1; - let mid; - - if (ucs < combining[0][0] || ucs > combining[max][1]) return false; - - while (max >= min) { - mid = Math.floor((min + max) / 2); - if (ucs > combining[mid][1]) min = mid + 1; - else if (ucs < combining[mid][0]) max = mid - 1; - else return true; - } - - return false; -} diff --git a/vendor/wait-deprecated-warnings-pr-head/deps.ts b/vendor/wait-deprecated-warnings-pr-head/deps.ts deleted file mode 100644 index 0df63594..00000000 --- a/vendor/wait-deprecated-warnings-pr-head/deps.ts +++ /dev/null @@ -1,2 +0,0 @@ -export * as colors from "https://deno.land/std@0.170.0/fmt/colors.ts"; -export * as tty from "https://deno.land/x/tty@0.1.4/mod.ts"; diff --git a/vendor/wait-deprecated-warnings-pr-head/log_symbols.ts b/vendor/wait-deprecated-warnings-pr-head/log_symbols.ts deleted file mode 100644 index 68b4e9b0..00000000 --- a/vendor/wait-deprecated-warnings-pr-head/log_symbols.ts +++ /dev/null @@ -1,24 +0,0 @@ -import { colors } from "./deps.ts"; - -let supported = true; - -if ((await Deno.permissions.query({ name: "env" })).state === "granted") { - supported = supported && - (!!Deno.env.get("CI") || Deno.env.get("TERM") === "xterm-256color"); -} - -const main = { - info: colors.blue("ℹ"), - success: colors.green("✔"), - warning: colors.yellow("⚠"), - error: colors.red("✖"), -}; - -const fallbacks = { - info: colors.blue("i"), - success: colors.green("√"), - warning: colors.yellow("‼"), - error: colors.red("×"), -}; - -export const symbols = supported ? main : fallbacks; diff --git a/vendor/wait-deprecated-warnings-pr-head/mod.ts b/vendor/wait-deprecated-warnings-pr-head/mod.ts deleted file mode 100644 index 801773a3..00000000 --- a/vendor/wait-deprecated-warnings-pr-head/mod.ts +++ /dev/null @@ -1,325 +0,0 @@ -import { colors, tty } from "./deps.ts"; - -import spinners from "./spinners.ts"; - -import { symbols } from "./log_symbols.ts"; - -const encoder = new TextEncoder(); - -type ColorFunction = (message: string) => string; -const colormap: { [key: string]: ColorFunction } = { - black: colors.black, - red: colors.red, - green: colors.green, - yellow: colors.yellow, - blue: colors.blue, - magenta: colors.magenta, - cyan: colors.cyan, - white: colors.white, - gray: colors.gray, -}; - -export interface SpinnerAnimation { - interval: number; - frames: string[]; -} - -export interface SpinnerOptions { - text: string; - prefix?: string; - spinner?: string | SpinnerAnimation; - color?: string | ColorFunction; - hideCursor?: boolean; - indent?: number; - interval?: number; - stream?: Deno.WriterSync & { rid: number }; - enabled?: boolean; - discardStdin?: boolean; - interceptConsole?: boolean; -} - -export interface PersistOptions { - prefix?: string; - symbol?: string; - text?: string; -} - -export interface Console { - log: typeof console.log; - warn: typeof console.warn; - error: typeof console.error; - info: typeof console.info; - debug: typeof console.debug; - time: typeof console.time; - timeEnd: typeof console.timeEnd; - trace: typeof console.trace; - dir: typeof console.dir; - assert: typeof console.assert; - count: typeof console.count; - countReset: typeof console.countReset; - table: typeof console.table; - dirxml: typeof console.dirxml; - timeLog: typeof console.timeLog; -} - -export function wait(opts: string | SpinnerOptions) { - if (typeof opts === "string") { - opts = { text: opts }; - } - return new Spinner({ - text: opts.text, - prefix: opts.prefix ?? "", - color: opts.color ?? colors.cyan, - spinner: opts.spinner ?? "dots", - hideCursor: opts.hideCursor ?? true, - indent: opts.indent ?? 0, - interval: opts.interval ?? 100, - stream: opts.stream ?? Deno.stdout, - enabled: true, - discardStdin: true, - interceptConsole: opts.interceptConsole ?? true, - }); -} - -export class Spinner { - #opts: Required; - - isSpinning: boolean; - - #stream: Deno.WriterSync & { rid: number }; - indent: number; - interval: number; - - #id = 0; - - #enabled: boolean; - #frameIndex: number; - #linesToClear: number; - #linesCount: number; - - constructor(opts: Required) { - this.#opts = opts; - - this.#stream = this.#opts.stream; - - this.text = this.#opts.text; - this.prefix = this.#opts.prefix; - - this.color = this.#opts.color; - this.spinner = this.#opts.spinner; - this.indent = this.#opts.indent; - this.interval = this.#opts.interval; - - this.isSpinning = false; - this.#frameIndex = 0; - this.#linesToClear = 0; - this.#linesCount = 1; - - this.#enabled = typeof opts.enabled === "boolean" - ? opts.enabled - : tty.isInteractive(this.#stream); - - if (opts.hideCursor) { - addEventListener("unload", () => { - tty.showCursorSync(this.#stream); - }); - } - - if (opts.interceptConsole) { - this.#interceptConsole(); - } - } - - #spinner: SpinnerAnimation = spinners.dots; - #color: ColorFunction = colors.cyan; - #text = ""; - #prefix = ""; - - #interceptConsole() { - const methods: (keyof Console)[] = [ - "log", - "warn", - "error", - "info", - "debug", - "time", - "timeEnd", - "trace", - "dir", - "assert", - "count", - "countReset", - "table", - "dirxml", - "timeLog", - ]; - for (const method of methods) { - const original = (console as Console)[method]; - (console as Console)[method] = (...args: unknown[]) => { - if (this.isSpinning) { - this.stop(); - this.clear(); - original(...args); - this.start(); - } else { - original(...args); - } - }; - } - } - - set spinner(spin: string | SpinnerAnimation) { - this.#frameIndex = 0; - if (typeof spin === "string") this.#spinner = spinners[spin]; - else this.#spinner = spin; - } - - get spinner() { - return this.#spinner; - } - - set color(color: string | ColorFunction) { - if (typeof color === "string") this.#color = colormap[color]; - else this.#color = color; - } - - get color() { - return this.#color; - } - - set text(value: string) { - this.#text = value; - this.updateLines(); - } - - get text() { - return this.#text; - } - set prefix(value: string) { - this.#prefix = value; - this.updateLines(); - } - - get prefix() { - return this.#prefix; - } - - private write(data: string) { - this.#stream.writeSync(encoder.encode(data)); - } - - start(): Spinner { - if (!this.#enabled) { - if (this.text) { - this.write(`- ${this.text}\n`); - } - return this; - } - - if (this.isSpinning) return this; - - if (this.#opts.hideCursor) { - tty.hideCursorSync(this.#stream); - } - this.isSpinning = true; - this.render(); - this.#id = setInterval(this.render.bind(this), this.interval); - return this; - } - - render(): void { - this.clear(); - this.write(`${this.frame()}\n`); - this.updateLines(); - this.#linesToClear = this.#linesCount; - } - - frame(): string { - const { frames } = this.#spinner; - let frame = frames[this.#frameIndex]; - - frame = this.#color(frame); - - this.#frameIndex = ++this.#frameIndex % frames.length; - const fullPrefixText = typeof this.prefix === "string" && this.prefix !== "" - ? this.prefix + " " - : ""; - const fullText = typeof this.text === "string" ? " " + this.text : ""; - - return fullPrefixText + frame + fullText; - } - - clear(): void { - if (!this.#enabled) return; - - for (let i = 0; i < this.#linesToClear; i++) { - tty.goUpSync(1, this.#stream); - tty.clearLineSync(this.#stream); - tty.goRightSync(this.indent - 1, this.#stream); - } - - this.#linesToClear = 0; - } - - updateLines(): void { - let columns = 80; - try { - //@ts-ignore TS2339 - columns = Deno.consoleSize().columns ?? columns; - } catch { - // Unstable APIs is not enabled, fallback to default - } - - const fullPrefixText = typeof this.prefix === "string" - ? this.prefix + "-" - : ""; - - this.#linesCount = tty - .stripAnsi(fullPrefixText + "--" + this.text) - .split("\n") - .reduce((count, line) => { - return count + Math.max(1, Math.ceil(tty.wcswidth(line) / columns)); - }, 0); - } - - stop() { - if (!this.#enabled) return; - clearInterval(this.#id); - this.#id = -1; - this.#frameIndex = 0; - this.clear(); - this.isSpinning = false; - if (this.#opts.hideCursor) { - tty.showCursorSync(this.#stream); - } - } - - stopAndPersist(options: PersistOptions = {}) { - const prefix = options.prefix || this.prefix; - const fullPrefix = typeof prefix === "string" && prefix !== "" - ? prefix + " " - : ""; - const text = options.text || this.text; - const fullText = typeof text === "string" ? " " + text : ""; - - this.stop(); - // https://github.com/denoland/deno/issues/6001 - this.write(`${fullPrefix}${options.symbol || " "}${fullText}\n`); - } - - succeed(text?: string) { - return this.stopAndPersist({ symbol: symbols.success, text }); - } - - fail(text?: string) { - return this.stopAndPersist({ symbol: symbols.error, text }); - } - - warn(text?: string) { - return this.stopAndPersist({ symbol: symbols.warning, text }); - } - - info(text?: string) { - return this.stopAndPersist({ symbol: symbols.info, text }); - } -} diff --git a/vendor/wait-deprecated-warnings-pr-head/spinners.ts b/vendor/wait-deprecated-warnings-pr-head/spinners.ts deleted file mode 100644 index 9902cf65..00000000 --- a/vendor/wait-deprecated-warnings-pr-head/spinners.ts +++ /dev/null @@ -1,957 +0,0 @@ -import type { SpinnerAnimation } from "./mod.ts"; - -export default <{ [key: string]: SpinnerAnimation }> { - dots: { - interval: 80, - frames: ["⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"], - }, - dots2: { - interval: 80, - frames: ["⣾", "⣽", "⣻", "⢿", "⡿", "⣟", "⣯", "⣷"], - }, - dots3: { - interval: 80, - frames: ["⠋", "⠙", "⠚", "⠞", "⠖", "⠦", "⠴", "⠲", "⠳", "⠓"], - }, - dots4: { - interval: 80, - frames: [ - "⠄", - "⠆", - "⠇", - "⠋", - "⠙", - "⠸", - "⠰", - "⠠", - "⠰", - "⠸", - "⠙", - "⠋", - "⠇", - "⠆", - ], - }, - dots5: { - interval: 80, - frames: [ - "⠋", - "⠙", - "⠚", - "⠒", - "⠂", - "⠂", - "⠒", - "⠲", - "⠴", - "⠦", - "⠖", - "⠒", - "⠐", - "⠐", - "⠒", - "⠓", - "⠋", - ], - }, - dots6: { - interval: 80, - frames: [ - "⠁", - "⠉", - "⠙", - "⠚", - "⠒", - "⠂", - "⠂", - "⠒", - "⠲", - "⠴", - "⠤", - "⠄", - "⠄", - "⠤", - "⠴", - "⠲", - "⠒", - "⠂", - "⠂", - "⠒", - "⠚", - "⠙", - "⠉", - "⠁", - ], - }, - dots7: { - interval: 80, - frames: [ - "⠈", - "⠉", - "⠋", - "⠓", - "⠒", - "⠐", - "⠐", - "⠒", - "⠖", - "⠦", - "⠤", - "⠠", - "⠠", - "⠤", - "⠦", - "⠖", - "⠒", - "⠐", - "⠐", - "⠒", - "⠓", - "⠋", - "⠉", - "⠈", - ], - }, - dots8: { - interval: 80, - frames: [ - "⠁", - "⠁", - "⠉", - "⠙", - "⠚", - "⠒", - "⠂", - "⠂", - "⠒", - "⠲", - "⠴", - "⠤", - "⠄", - "⠄", - "⠤", - "⠠", - "⠠", - "⠤", - "⠦", - "⠖", - "⠒", - "⠐", - "⠐", - "⠒", - "⠓", - "⠋", - "⠉", - "⠈", - "⠈", - ], - }, - dots9: { - interval: 80, - frames: ["⢹", "⢺", "⢼", "⣸", "⣇", "⡧", "⡗", "⡏"], - }, - dots10: { - interval: 80, - frames: ["⢄", "⢂", "⢁", "⡁", "⡈", "⡐", "⡠"], - }, - dots11: { - interval: 100, - frames: ["⠁", "⠂", "⠄", "⡀", "⢀", "⠠", "⠐", "⠈"], - }, - dots12: { - interval: 80, - frames: [ - "⢀⠀", - "⡀⠀", - "⠄⠀", - "⢂⠀", - "⡂⠀", - "⠅⠀", - "⢃⠀", - "⡃⠀", - "⠍⠀", - "⢋⠀", - "⡋⠀", - "⠍⠁", - "⢋⠁", - "⡋⠁", - "⠍⠉", - "⠋⠉", - "⠋⠉", - "⠉⠙", - "⠉⠙", - "⠉⠩", - "⠈⢙", - "⠈⡙", - "⢈⠩", - "⡀⢙", - "⠄⡙", - "⢂⠩", - "⡂⢘", - "⠅⡘", - "⢃⠨", - "⡃⢐", - "⠍⡐", - "⢋⠠", - "⡋⢀", - "⠍⡁", - "⢋⠁", - "⡋⠁", - "⠍⠉", - "⠋⠉", - "⠋⠉", - "⠉⠙", - "⠉⠙", - "⠉⠩", - "⠈⢙", - "⠈⡙", - "⠈⠩", - "⠀⢙", - "⠀⡙", - "⠀⠩", - "⠀⢘", - "⠀⡘", - "⠀⠨", - "⠀⢐", - "⠀⡐", - "⠀⠠", - "⠀⢀", - "⠀⡀", - ], - }, - dots8Bit: { - interval: 80, - frames: [ - "⠀", - "⠁", - "⠂", - "⠃", - "⠄", - "⠅", - "⠆", - "⠇", - "⡀", - "⡁", - "⡂", - "⡃", - "⡄", - "⡅", - "⡆", - "⡇", - "⠈", - "⠉", - "⠊", - "⠋", - "⠌", - "⠍", - "⠎", - "⠏", - "⡈", - "⡉", - "⡊", - "⡋", - "⡌", - "⡍", - "⡎", - "⡏", - "⠐", - "⠑", - "⠒", - "⠓", - "⠔", - "⠕", - "⠖", - "⠗", - "⡐", - "⡑", - "⡒", - "⡓", - "⡔", - "⡕", - "⡖", - "⡗", - "⠘", - "⠙", - "⠚", - "⠛", - "⠜", - "⠝", - "⠞", - "⠟", - "⡘", - "⡙", - "⡚", - "⡛", - "⡜", - "⡝", - "⡞", - "⡟", - "⠠", - "⠡", - "⠢", - "⠣", - "⠤", - "⠥", - "⠦", - "⠧", - "⡠", - "⡡", - "⡢", - "⡣", - "⡤", - "⡥", - "⡦", - "⡧", - "⠨", - "⠩", - "⠪", - "⠫", - "⠬", - "⠭", - "⠮", - "⠯", - "⡨", - "⡩", - "⡪", - "⡫", - "⡬", - "⡭", - "⡮", - "⡯", - "⠰", - "⠱", - "⠲", - "⠳", - "⠴", - "⠵", - "⠶", - "⠷", - "⡰", - "⡱", - "⡲", - "⡳", - "⡴", - "⡵", - "⡶", - "⡷", - "⠸", - "⠹", - "⠺", - "⠻", - "⠼", - "⠽", - "⠾", - "⠿", - "⡸", - "⡹", - "⡺", - "⡻", - "⡼", - "⡽", - "⡾", - "⡿", - "⢀", - "⢁", - "⢂", - "⢃", - "⢄", - "⢅", - "⢆", - "⢇", - "⣀", - "⣁", - "⣂", - "⣃", - "⣄", - "⣅", - "⣆", - "⣇", - "⢈", - "⢉", - "⢊", - "⢋", - "⢌", - "⢍", - "⢎", - "⢏", - "⣈", - "⣉", - "⣊", - "⣋", - "⣌", - "⣍", - "⣎", - "⣏", - "⢐", - "⢑", - "⢒", - "⢓", - "⢔", - "⢕", - "⢖", - "⢗", - "⣐", - "⣑", - "⣒", - "⣓", - "⣔", - "⣕", - "⣖", - "⣗", - "⢘", - "⢙", - "⢚", - "⢛", - "⢜", - "⢝", - "⢞", - "⢟", - "⣘", - "⣙", - "⣚", - "⣛", - "⣜", - "⣝", - "⣞", - "⣟", - "⢠", - "⢡", - "⢢", - "⢣", - "⢤", - "⢥", - "⢦", - "⢧", - "⣠", - "⣡", - "⣢", - "⣣", - "⣤", - "⣥", - "⣦", - "⣧", - "⢨", - "⢩", - "⢪", - "⢫", - "⢬", - "⢭", - "⢮", - "⢯", - "⣨", - "⣩", - "⣪", - "⣫", - "⣬", - "⣭", - "⣮", - "⣯", - "⢰", - "⢱", - "⢲", - "⢳", - "⢴", - "⢵", - "⢶", - "⢷", - "⣰", - "⣱", - "⣲", - "⣳", - "⣴", - "⣵", - "⣶", - "⣷", - "⢸", - "⢹", - "⢺", - "⢻", - "⢼", - "⢽", - "⢾", - "⢿", - "⣸", - "⣹", - "⣺", - "⣻", - "⣼", - "⣽", - "⣾", - "⣿", - ], - }, - line: { - interval: 130, - frames: ["-", "\\", "|", "/"], - }, - line2: { - interval: 100, - frames: ["⠂", "-", "–", "—", "–", "-"], - }, - pipe: { - interval: 100, - frames: ["┤", "┘", "┴", "└", "├", "┌", "┬", "┐"], - }, - simpleDots: { - interval: 400, - frames: [". ", ".. ", "...", " "], - }, - simpleDotsScrolling: { - interval: 200, - frames: [". ", ".. ", "...", " ..", " .", " "], - }, - star: { - interval: 70, - frames: ["✶", "✸", "✹", "✺", "✹", "✷"], - }, - star2: { - interval: 80, - frames: ["+", "x", "*"], - }, - flip: { - interval: 70, - frames: ["_", "_", "_", "-", "`", "`", "'", "´", "-", "_", "_", "_"], - }, - hamburger: { - interval: 100, - frames: ["☱", "☲", "☴"], - }, - growVertical: { - interval: 120, - frames: ["▁", "▃", "▄", "▅", "▆", "▇", "▆", "▅", "▄", "▃"], - }, - growHorizontal: { - interval: 120, - frames: ["▏", "▎", "▍", "▌", "▋", "▊", "▉", "▊", "▋", "▌", "▍", "▎"], - }, - balloon: { - interval: 140, - frames: [" ", ".", "o", "O", "@", "*", " "], - }, - balloon2: { - interval: 120, - frames: [".", "o", "O", "°", "O", "o", "."], - }, - noise: { - interval: 100, - frames: ["▓", "▒", "░"], - }, - bounce: { - interval: 120, - frames: ["⠁", "⠂", "⠄", "⠂"], - }, - boxBounce: { - interval: 120, - frames: ["▖", "▘", "▝", "▗"], - }, - boxBounce2: { - interval: 100, - frames: ["▌", "▀", "▐", "▄"], - }, - triangle: { - interval: 50, - frames: ["◢", "◣", "◤", "◥"], - }, - arc: { - interval: 100, - frames: ["◜", "◠", "◝", "◞", "◡", "◟"], - }, - circle: { - interval: 120, - frames: ["◡", "⊙", "◠"], - }, - squareCorners: { - interval: 180, - frames: ["◰", "◳", "◲", "◱"], - }, - circleQuarters: { - interval: 120, - frames: ["◴", "◷", "◶", "◵"], - }, - circleHalves: { - interval: 50, - frames: ["◐", "◓", "◑", "◒"], - }, - squish: { - interval: 100, - frames: ["╫", "╪"], - }, - toggle: { - interval: 250, - frames: ["⊶", "⊷"], - }, - toggle2: { - interval: 80, - frames: ["▫", "▪"], - }, - toggle3: { - interval: 120, - frames: ["□", "■"], - }, - toggle4: { - interval: 100, - frames: ["■", "□", "▪", "▫"], - }, - toggle5: { - interval: 100, - frames: ["▮", "▯"], - }, - toggle6: { - interval: 300, - frames: ["ဝ", "၀"], - }, - toggle7: { - interval: 80, - frames: ["⦾", "⦿"], - }, - toggle8: { - interval: 100, - frames: ["◍", "◌"], - }, - toggle9: { - interval: 100, - frames: ["◉", "◎"], - }, - toggle10: { - interval: 100, - frames: ["㊂", "㊀", "㊁"], - }, - toggle11: { - interval: 50, - frames: ["⧇", "⧆"], - }, - toggle12: { - interval: 120, - frames: ["☗", "☖"], - }, - toggle13: { - interval: 80, - frames: ["=", "*", "-"], - }, - arrow: { - interval: 100, - frames: ["←", "↖", "↑", "↗", "→", "↘", "↓", "↙"], - }, - arrow2: { - interval: 80, - frames: ["⬆️ ", "↗️ ", "➡️ ", "↘️ ", "⬇️ ", "↙️ ", "⬅️ ", "↖️ "], - }, - arrow3: { - interval: 120, - frames: ["▹▹▹▹▹", "▸▹▹▹▹", "▹▸▹▹▹", "▹▹▸▹▹", "▹▹▹▸▹", "▹▹▹▹▸"], - }, - bouncingBar: { - interval: 80, - frames: [ - "[ ]", - "[= ]", - "[== ]", - "[=== ]", - "[ ===]", - "[ ==]", - "[ =]", - "[ ]", - "[ =]", - "[ ==]", - "[ ===]", - "[====]", - "[=== ]", - "[== ]", - "[= ]", - ], - }, - bouncingBall: { - interval: 80, - frames: [ - "( ● )", - "( ● )", - "( ● )", - "( ● )", - "( ●)", - "( ● )", - "( ● )", - "( ● )", - "( ● )", - "(● )", - ], - }, - smiley: { - interval: 200, - frames: ["😄 ", "😝 "], - }, - monkey: { - interval: 300, - frames: ["🙈 ", "🙈 ", "🙉 ", "🙊 "], - }, - hearts: { - interval: 100, - frames: ["💛 ", "💙 ", "💜 ", "💚 ", "❤️ "], - }, - clock: { - interval: 100, - frames: [ - "🕛 ", - "🕐 ", - "🕑 ", - "🕒 ", - "🕓 ", - "🕔 ", - "🕕 ", - "🕖 ", - "🕗 ", - "🕘 ", - "🕙 ", - "🕚 ", - ], - }, - earth: { - interval: 180, - frames: ["🌍 ", "🌎 ", "🌏 "], - }, - material: { - interval: 17, - frames: [ - "█▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁", - "██▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁", - "███▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁", - "████▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁", - "██████▁▁▁▁▁▁▁▁▁▁▁▁▁▁", - "██████▁▁▁▁▁▁▁▁▁▁▁▁▁▁", - "███████▁▁▁▁▁▁▁▁▁▁▁▁▁", - "████████▁▁▁▁▁▁▁▁▁▁▁▁", - "█████████▁▁▁▁▁▁▁▁▁▁▁", - "█████████▁▁▁▁▁▁▁▁▁▁▁", - "██████████▁▁▁▁▁▁▁▁▁▁", - "███████████▁▁▁▁▁▁▁▁▁", - "█████████████▁▁▁▁▁▁▁", - "██████████████▁▁▁▁▁▁", - "██████████████▁▁▁▁▁▁", - "▁██████████████▁▁▁▁▁", - "▁██████████████▁▁▁▁▁", - "▁██████████████▁▁▁▁▁", - "▁▁██████████████▁▁▁▁", - "▁▁▁██████████████▁▁▁", - "▁▁▁▁█████████████▁▁▁", - "▁▁▁▁██████████████▁▁", - "▁▁▁▁██████████████▁▁", - "▁▁▁▁▁██████████████▁", - "▁▁▁▁▁██████████████▁", - "▁▁▁▁▁██████████████▁", - "▁▁▁▁▁▁██████████████", - "▁▁▁▁▁▁██████████████", - "▁▁▁▁▁▁▁█████████████", - "▁▁▁▁▁▁▁█████████████", - "▁▁▁▁▁▁▁▁████████████", - "▁▁▁▁▁▁▁▁████████████", - "▁▁▁▁▁▁▁▁▁███████████", - "▁▁▁▁▁▁▁▁▁███████████", - "▁▁▁▁▁▁▁▁▁▁██████████", - "▁▁▁▁▁▁▁▁▁▁██████████", - "▁▁▁▁▁▁▁▁▁▁▁▁████████", - "▁▁▁▁▁▁▁▁▁▁▁▁▁███████", - "▁▁▁▁▁▁▁▁▁▁▁▁▁▁██████", - "▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁█████", - "▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁█████", - "█▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁████", - "██▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁███", - "██▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁███", - "███▁▁▁▁▁▁▁▁▁▁▁▁▁▁███", - "████▁▁▁▁▁▁▁▁▁▁▁▁▁▁██", - "█████▁▁▁▁▁▁▁▁▁▁▁▁▁▁█", - "█████▁▁▁▁▁▁▁▁▁▁▁▁▁▁█", - "██████▁▁▁▁▁▁▁▁▁▁▁▁▁█", - "████████▁▁▁▁▁▁▁▁▁▁▁▁", - "█████████▁▁▁▁▁▁▁▁▁▁▁", - "█████████▁▁▁▁▁▁▁▁▁▁▁", - "█████████▁▁▁▁▁▁▁▁▁▁▁", - "█████████▁▁▁▁▁▁▁▁▁▁▁", - "███████████▁▁▁▁▁▁▁▁▁", - "████████████▁▁▁▁▁▁▁▁", - "████████████▁▁▁▁▁▁▁▁", - "██████████████▁▁▁▁▁▁", - "██████████████▁▁▁▁▁▁", - "▁██████████████▁▁▁▁▁", - "▁██████████████▁▁▁▁▁", - "▁▁▁█████████████▁▁▁▁", - "▁▁▁▁▁████████████▁▁▁", - "▁▁▁▁▁████████████▁▁▁", - "▁▁▁▁▁▁███████████▁▁▁", - "▁▁▁▁▁▁▁▁█████████▁▁▁", - "▁▁▁▁▁▁▁▁█████████▁▁▁", - "▁▁▁▁▁▁▁▁▁█████████▁▁", - "▁▁▁▁▁▁▁▁▁█████████▁▁", - "▁▁▁▁▁▁▁▁▁▁█████████▁", - "▁▁▁▁▁▁▁▁▁▁▁████████▁", - "▁▁▁▁▁▁▁▁▁▁▁████████▁", - "▁▁▁▁▁▁▁▁▁▁▁▁███████▁", - "▁▁▁▁▁▁▁▁▁▁▁▁███████▁", - "▁▁▁▁▁▁▁▁▁▁▁▁▁███████", - "▁▁▁▁▁▁▁▁▁▁▁▁▁███████", - "▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁█████", - "▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁████", - "▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁████", - "▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁████", - "▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁███", - "▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁███", - "▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁██", - "▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁██", - "▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁██", - "▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁█", - "▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁█", - "▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁█", - "▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁", - "▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁", - "▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁", - "▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁", - ], - }, - moon: { - interval: 80, - frames: ["🌑 ", "🌒 ", "🌓 ", "🌔 ", "🌕 ", "🌖 ", "🌗 ", "🌘 "], - }, - runner: { - interval: 140, - frames: ["🚶 ", "🏃 "], - }, - pong: { - interval: 80, - frames: [ - "▐⠂ ▌", - "▐⠈ ▌", - "▐ ⠂ ▌", - "▐ ⠠ ▌", - "▐ ⡀ ▌", - "▐ ⠠ ▌", - "▐ ⠂ ▌", - "▐ ⠈ ▌", - "▐ ⠂ ▌", - "▐ ⠠ ▌", - "▐ ⡀ ▌", - "▐ ⠠ ▌", - "▐ ⠂ ▌", - "▐ ⠈ ▌", - "▐ ⠂▌", - "▐ ⠠▌", - "▐ ⡀▌", - "▐ ⠠ ▌", - "▐ ⠂ ▌", - "▐ ⠈ ▌", - "▐ ⠂ ▌", - "▐ ⠠ ▌", - "▐ ⡀ ▌", - "▐ ⠠ ▌", - "▐ ⠂ ▌", - "▐ ⠈ ▌", - "▐ ⠂ ▌", - "▐ ⠠ ▌", - "▐ ⡀ ▌", - "▐⠠ ▌", - ], - }, - shark: { - interval: 120, - frames: [ - "▐|\\____________▌", - "▐_|\\___________▌", - "▐__|\\__________▌", - "▐___|\\_________▌", - "▐____|\\________▌", - "▐_____|\\_______▌", - "▐______|\\______▌", - "▐_______|\\_____▌", - "▐________|\\____▌", - "▐_________|\\___▌", - "▐__________|\\__▌", - "▐___________|\\_▌", - "▐____________|\\▌", - "▐____________/|▌", - "▐___________/|_▌", - "▐__________/|__▌", - "▐_________/|___▌", - "▐________/|____▌", - "▐_______/|_____▌", - "▐______/|______▌", - "▐_____/|_______▌", - "▐____/|________▌", - "▐___/|_________▌", - "▐__/|__________▌", - "▐_/|___________▌", - "▐/|____________▌", - ], - }, - dqpb: { - interval: 100, - frames: ["d", "q", "p", "b"], - }, - weather: { - interval: 100, - frames: [ - "☀️ ", - "☀️ ", - "☀️ ", - "🌤 ", - "⛅️ ", - "🌥 ", - "☁️ ", - "🌧 ", - "🌨 ", - "🌧 ", - "🌨 ", - "🌧 ", - "🌨 ", - "⛈ ", - "🌨 ", - "🌧 ", - "🌨 ", - "☁️ ", - "🌥 ", - "⛅️ ", - "🌤 ", - "☀️ ", - "☀️ ", - ], - }, - christmas: { - interval: 400, - frames: ["🌲", "🎄"], - }, - grenade: { - interval: 80, - frames: [ - "، ", - "′ ", - " ´ ", - " ‾ ", - " ⸌", - " ⸊", - " |", - " ⁎", - " ⁕", - " ෴ ", - " ⁓", - " ", - " ", - " ", - ], - }, - point: { - interval: 125, - frames: ["∙∙∙", "●∙∙", "∙●∙", "∙∙●", "∙∙∙"], - }, - layer: { - interval: 150, - frames: ["-", "=", "≡"], - }, - betaWave: { - interval: 80, - frames: [ - "ρββββββ", - "βρβββββ", - "ββρββββ", - "βββρβββ", - "ββββρββ", - "βββββρβ", - "ββββββρ", - ], - }, -};