From 0644d548a69c6cf22f57b6e24a5b325c0b5b1298 Mon Sep 17 00:00:00 2001 From: Gal Schlezinger Date: Thu, 17 Nov 2022 13:35:51 +0200 Subject: [PATCH] migrate js scripts to esm (#852) --- .ci/prepare-version.js | 75 ++- .ci/print-command-docs.js | 91 ++-- .github/workflows/debug.yml | 18 +- e2e/aliases.test.ts | 12 +- e2e/basic.test.ts | 10 +- e2e/current.test.ts | 6 +- e2e/describe.ts | 4 +- e2e/env.test.ts | 8 +- e2e/exec.test.ts | 8 +- e2e/existing-installation.test.ts | 8 +- e2e/latest-lts.test.ts | 6 +- e2e/log-level.test.ts | 8 +- e2e/multishell.test.ts | 8 +- e2e/nvmrc-lts.test.ts | 8 +- e2e/shellcode/script.ts | 42 +- e2e/shellcode/{shells/index.ts => shells.ts} | 14 +- e2e/shellcode/shells/cmdCall.ts | 2 +- e2e/shellcode/shells/cmdEnv.ts | 2 +- e2e/shellcode/shells/expect-command-output.ts | 4 +- e2e/shellcode/shells/output-contains.ts | 2 +- e2e/shellcode/shells/redirect-output.ts | 2 +- e2e/shellcode/shells/sub-shell.ts | 2 +- e2e/shellcode/test-bin-dir.ts | 2 +- e2e/shellcode/test-cwd.ts | 2 +- e2e/shellcode/test-node-version.ts | 6 +- e2e/system-node.test.ts | 10 +- e2e/uninstall.test.ts | 6 +- jest.config.cjs | 22 + package.json | 23 +- pnpm-lock.yaml | 457 +++++------------- tsconfig.json | 4 +- 31 files changed, 335 insertions(+), 537 deletions(-) rename e2e/shellcode/{shells/index.ts => shells.ts} (84%) create mode 100644 jest.config.cjs diff --git a/.ci/prepare-version.js b/.ci/prepare-version.js index 2f91e10..5d6ddb2 100755 --- a/.ci/prepare-version.js +++ b/.ci/prepare-version.js @@ -2,28 +2,27 @@ /// @ts-check -const fs = require("fs"); -const cp = require("child_process"); -const path = require("path"); -const cmd = require("cmd-ts"); -const toml = require("toml"); -const assert = require("assert"); +import fs from "fs" +import cp from "child_process" +import cmd from "cmd-ts" +import toml from "toml" +import assert from "assert" -const CARGO_TOML_PATH = path.join(__dirname, "../Cargo.toml"); +const CARGO_TOML_PATH = new URL("../Cargo.toml", import.meta.url).pathname const command = cmd.command({ name: "prepare-version", description: "Prepare a new fnm version", args: {}, async handler({}) { - updateCargoToml(await getPackageVersion()); - exec("cargo build --release"); - exec("yarn generate-command-docs --binary-path=./target/release/fnm"); - exec("./.ci/record_screen.sh"); + updateCargoToml(await getPackageVersion()) + exec("cargo build --release") + exec("yarn generate-command-docs --binary-path=./target/release/fnm") + exec("./.ci/record_screen.sh") }, -}); +}) -cmd.run(cmd.binary(command), process.argv); +cmd.run(cmd.binary(command), process.argv) ////////////////////// // Helper functions // @@ -34,56 +33,40 @@ cmd.run(cmd.binary(command), process.argv); */ async function getPackageVersion() { const pkgJson = await fs.promises.readFile( - path.join(__dirname, "../package.json"), + new URL("../package.json", import.meta.url), "utf8" - ); - const version = JSON.parse(pkgJson).version; - assert(version, "package.json version is not set"); - return version; + ) + const version = JSON.parse(pkgJson).version + assert(version, "package.json version is not set") + return version } function updateCargoToml(nextVersion) { - const cargoToml = fs.readFileSync(CARGO_TOML_PATH, "utf8"); - const cargoTomlContents = toml.parse(cargoToml); - const currentVersion = cargoTomlContents.package.version; + const cargoToml = fs.readFileSync(CARGO_TOML_PATH, "utf8") + const cargoTomlContents = toml.parse(cargoToml) + const currentVersion = cargoTomlContents.package.version const newToml = cargoToml.replace( `version = "${currentVersion}"`, `version = "${nextVersion}"` - ); + ) if (newToml === cargoToml) { - console.error("Cargo.toml didn't change, error!"); - process.exitCode = 1; - return; + console.error("Cargo.toml didn't change, error!") + process.exitCode = 1 + return } - fs.writeFileSync(CARGO_TOML_PATH, newToml, "utf8"); + fs.writeFileSync(CARGO_TOML_PATH, newToml, "utf8") - return nextVersion; + return nextVersion } function exec(command, env) { - console.log(`$ ${command}`); + console.log(`$ ${command}`) return cp.execSync(command, { - cwd: path.join(__dirname, ".."), // root of repo + cwd: new URL("..", import.meta.url), stdio: "inherit", env: { ...process.env, ...env }, - }); -} - -/** - * @param {"patch" | "minor" | "major"} type - * @param {string} version - */ -function changeVersion(type, version) { - const [major, minor, patch] = version.split(".").map((x) => parseInt(x, 10)); - switch (type) { - case "patch": - return [major, minor, patch + 1].join("."); - case "minor": - return [major, minor + 1, 0].join("."); - case "major": - return [major + 1, 0, 0].join("."); - } + }) } diff --git a/.ci/print-command-docs.js b/.ci/print-command-docs.js index 91b11ba..7b5996a 100755 --- a/.ci/print-command-docs.js +++ b/.ci/print-command-docs.js @@ -2,24 +2,23 @@ /// @ts-check -const execa = require("execa"); -const path = require("path"); -const fs = require("fs"); -const cmd = require("cmd-ts"); -const cmdFs = require("cmd-ts/dist/cjs/batteries/fs"); +import { execa } from "execa" +import fs from "node:fs" +import cmd from "cmd-ts" +import cmdFs from "cmd-ts/dist/cjs/batteries/fs.js" const FnmBinaryPath = { ...cmdFs.ExistingPath, defaultValue() { - const target = path.join(__dirname, "../target/debug/fnm"); + const target = new URL("../target/debug/fnm", import.meta.url) if (!fs.existsSync(target)) { throw new Error( "Can't find debug target, please run `cargo build` or provide a specific binary path" - ); + ) } - return target; + return target.pathname }, -}; +} const command = cmd.command({ name: "print-command-docs", @@ -36,27 +35,27 @@ const command = cmd.command({ }), }, async handler({ checkForDirty, fnmPath }) { - const targetFile = path.join(__dirname, "../docs/commands.md"); - await main(targetFile, fnmPath); + const targetFile = new URL("../docs/commands.md", import.meta.url).pathname + await main(targetFile, fnmPath) if (checkForDirty) { - const gitStatus = await checkGitStatus(targetFile); + const gitStatus = await checkGitStatus(targetFile) if (gitStatus.state === "dirty") { - process.exitCode = 1; + process.exitCode = 1 console.error( "The file has changed. Please re-run `yarn generate-command-docs`." - ); - console.error(`hint: The following diff was found:`); - console.error(); - console.error(gitStatus.diff); + ) + console.error(`hint: The following diff was found:`) + console.error() + console.error(gitStatus.diff) } } }, -}); +}) cmd.run(cmd.binary(command), process.argv).catch((err) => { - console.error(err); - process.exitCode = process.exitCode || 1; -}); + console.error(err) + process.exitCode = process.exitCode || 1 +}) /** * @param {string} targetFile @@ -64,20 +63,20 @@ cmd.run(cmd.binary(command), process.argv).catch((err) => { * @returns {Promise} */ async function main(targetFile, fnmPath) { - const stream = fs.createWriteStream(targetFile); + const stream = fs.createWriteStream(targetFile) - const { subcommands, text: mainText } = await getCommandHelp(fnmPath); + const { subcommands, text: mainText } = await getCommandHelp(fnmPath) - await write(stream, line(`fnm`, mainText)); + await write(stream, line(`fnm`, mainText)) for (const subcommand of subcommands) { - const { text: subcommandText } = await getCommandHelp(fnmPath, subcommand); - await write(stream, "\n" + line(`fnm ${subcommand}`, subcommandText)); + const { text: subcommandText } = await getCommandHelp(fnmPath, subcommand) + await write(stream, "\n" + line(`fnm ${subcommand}`, subcommandText)) } - stream.close(); + stream.close() - await execa(`yarn`, ["prettier", "--write", targetFile]); + await execa(`yarn`, ["prettier", "--write", targetFile]) } /** @@ -87,14 +86,14 @@ async function main(targetFile, fnmPath) { */ function write(stream, content) { return new Promise((resolve, reject) => { - stream.write(content, (err) => (err ? reject(err) : resolve())); - }); + stream.write(content, (err) => (err ? reject(err) : resolve())) + }) } function line(cmd, text) { - const cmdCode = "`" + cmd + "`"; - const textCode = "```\n" + text + "\n```"; - return `# ${cmdCode}\n${textCode}`; + const cmdCode = "`" + cmd + "`" + const textCode = "```\n" + text + "\n```" + return `# ${cmdCode}\n${textCode}` } /** @@ -103,25 +102,25 @@ function line(cmd, text) { * @returns {Promise<{ subcommands: string[], text: string }>} */ async function getCommandHelp(fnmPath, command) { - const cmdArg = command ? [command] : []; - const result = await run(fnmPath, [...cmdArg, "--help"]); - const text = result.stdout; - const rows = text.split("\n"); - const headerIndex = rows.findIndex((x) => x.includes("SUBCOMMANDS")); + const cmdArg = command ? [command] : [] + const result = await run(fnmPath, [...cmdArg, "--help"]) + const text = result.stdout + const rows = text.split("\n") + const headerIndex = rows.findIndex((x) => x.includes("SUBCOMMANDS")) /** @type {string[]} */ - const subcommands = []; + const subcommands = [] if (!command) { for (const row of rows.slice(headerIndex + 1)) { - const [, word] = row.split(/\s+/); + const [, word] = row.split(/\s+/) if (word && word[0].toLowerCase() === word[0]) { - subcommands.push(word); + subcommands.push(word) } } } return { subcommands, text, - }; + } } /** @@ -133,7 +132,7 @@ function run(fnmPath, args) { reject: false, stdout: "pipe", stderr: "pipe", - }); + }) } /** @@ -147,9 +146,9 @@ async function checkGitStatus(targetFile) { { reject: false, } - ); + ) if (exitCode === 0) { - return { state: "clean" }; + return { state: "clean" } } - return { state: "dirty", diff: stdout }; + return { state: "dirty", diff: stdout } } diff --git a/.github/workflows/debug.yml b/.github/workflows/debug.yml index 22f6571..be68e2a 100644 --- a/.github/workflows/debug.yml +++ b/.github/workflows/debug.yml @@ -2,11 +2,6 @@ name: "debug" on: workflow_dispatch: - inputs: - commit_hash: - description: "Commit hash to debug" - required: true - type: string concurrency: group: debug @@ -20,11 +15,24 @@ jobs: - uses: actions/checkout@v3 with: ref: ${{ github.event.inputs.commit_hash }} + - name: Download artifact + id: download-artifact + uses: dawidd6/action-download-artifact@v2 + with: + workflow: rust.yml + workflow_conclusion: "" + branch: ${{ env.GITHUB_REF }} + name: "fnm-windows" + path: "target/release" + if_no_artifact_found: ignore - uses: hecrj/setup-rust-action@v1 + if: steps.download-artifact.outputs.artifact-found == false with: rust-version: stable - uses: Swatinem/rust-cache@v1 + if: steps.download-artifact.outputs.artifact-found == false - name: Build release binary + if: steps.download-artifact.outputs.artifact-found == false run: cargo build --release env: RUSTFLAGS: "-C target-feature=+crt-static" diff --git a/e2e/aliases.test.ts b/e2e/aliases.test.ts index 2cde619..e7dce18 100644 --- a/e2e/aliases.test.ts +++ b/e2e/aliases.test.ts @@ -1,11 +1,11 @@ -import { script } from "./shellcode/script" -import { Bash, Fish, PowerShell, Zsh } from "./shellcode/shells" -import describe from "./describe" +import { script } from "./shellcode/script.js" +import { Bash, Fish, PowerShell, Zsh } from "./shellcode/shells.js" +import describe from "./describe.js" import { writeFile } from "node:fs/promises" import path from "node:path" -import testCwd from "./shellcode/test-cwd" -import getStderr from "./shellcode/get-stderr" -import testNodeVersion from "./shellcode/test-node-version" +import testCwd from "./shellcode/test-cwd.js" +import getStderr from "./shellcode/get-stderr.js" +import testNodeVersion from "./shellcode/test-node-version.js" for (const shell of [Bash, Zsh, Fish, PowerShell]) { describe(shell, () => { diff --git a/e2e/basic.test.ts b/e2e/basic.test.ts index 260a284..d269c5f 100644 --- a/e2e/basic.test.ts +++ b/e2e/basic.test.ts @@ -1,10 +1,10 @@ import { writeFile, mkdir } from "node:fs/promises" import { join } from "node:path" -import { script } from "./shellcode/script" -import { Bash, Fish, PowerShell, WinCmd, Zsh } from "./shellcode/shells" -import testCwd from "./shellcode/test-cwd" -import testNodeVersion from "./shellcode/test-node-version" -import describe from "./describe" +import { script } from "./shellcode/script.js" +import { Bash, Fish, PowerShell, WinCmd, Zsh } from "./shellcode/shells.js" +import testCwd from "./shellcode/test-cwd.js" +import testNodeVersion from "./shellcode/test-node-version.js" +import describe from "./describe.js" for (const shell of [Bash, Zsh, Fish, PowerShell, WinCmd]) { describe(shell, () => { diff --git a/e2e/current.test.ts b/e2e/current.test.ts index e1fc99d..29710c0 100644 --- a/e2e/current.test.ts +++ b/e2e/current.test.ts @@ -1,6 +1,6 @@ -import { script } from "./shellcode/script" -import { Bash, Fish, PowerShell, WinCmd, Zsh } from "./shellcode/shells" -import describe from "./describe" +import { script } from "./shellcode/script.js" +import { Bash, Fish, PowerShell, WinCmd, Zsh } from "./shellcode/shells.js" +import describe from "./describe.js" for (const shell of [Bash, Zsh, Fish, PowerShell, WinCmd]) { describe(shell, () => { diff --git a/e2e/describe.ts b/e2e/describe.ts index 1e3e78a..8058dec 100644 --- a/e2e/describe.ts +++ b/e2e/describe.ts @@ -1,5 +1,5 @@ -import { WinCmd } from "./shellcode/shells" -import { Shell } from "./shellcode/shells/types" +import { WinCmd } from "./shellcode/shells.js" +import { Shell } from "./shellcode/shells/types.js" export default function describe( shell: Pick, diff --git a/e2e/env.test.ts b/e2e/env.test.ts index a66fab5..d07ad6a 100644 --- a/e2e/env.test.ts +++ b/e2e/env.test.ts @@ -1,9 +1,9 @@ import { readFile } from "node:fs/promises" import { join } from "node:path" -import { script } from "./shellcode/script" -import { Bash, Fish, PowerShell, WinCmd, Zsh } from "./shellcode/shells" -import testCwd from "./shellcode/test-cwd" -import describe from "./describe" +import { script } from "./shellcode/script.js" +import { Bash, Fish, PowerShell, WinCmd, Zsh } from "./shellcode/shells.js" +import testCwd from "./shellcode/test-cwd.js" +import describe from "./describe.js" for (const shell of [Bash, Zsh, Fish, PowerShell, WinCmd]) { describe(shell, () => { diff --git a/e2e/exec.test.ts b/e2e/exec.test.ts index 148df60..4babaad 100644 --- a/e2e/exec.test.ts +++ b/e2e/exec.test.ts @@ -1,9 +1,9 @@ -import { script } from "./shellcode/script" -import { Bash, Fish, PowerShell, WinCmd, Zsh } from "./shellcode/shells" -import testCwd from "./shellcode/test-cwd" +import { script } from "./shellcode/script.js" +import { Bash, Fish, PowerShell, WinCmd, Zsh } from "./shellcode/shells.js" +import testCwd from "./shellcode/test-cwd.js" import fs from "node:fs/promises" import path from "node:path" -import describe from "./describe" +import describe from "./describe.js" for (const shell of [Bash, Zsh, Fish, PowerShell, WinCmd]) { describe(shell, () => { diff --git a/e2e/existing-installation.test.ts b/e2e/existing-installation.test.ts index d129d7d..2fb0f90 100644 --- a/e2e/existing-installation.test.ts +++ b/e2e/existing-installation.test.ts @@ -1,7 +1,7 @@ -import getStderr from "./shellcode/get-stderr" -import { script } from "./shellcode/script" -import { Bash, Fish, PowerShell, Zsh } from "./shellcode/shells" -import describe from "./describe" +import getStderr from "./shellcode/get-stderr.js" +import { script } from "./shellcode/script.js" +import { Bash, Fish, PowerShell, Zsh } from "./shellcode/shells.js" +import describe from "./describe.js" for (const shell of [Bash, Zsh, Fish, PowerShell]) { describe(shell, () => { diff --git a/e2e/latest-lts.test.ts b/e2e/latest-lts.test.ts index 75df43a..83bebb0 100644 --- a/e2e/latest-lts.test.ts +++ b/e2e/latest-lts.test.ts @@ -1,6 +1,6 @@ -import { script } from "./shellcode/script" -import { Bash, Fish, PowerShell, Zsh } from "./shellcode/shells" -import describe from "./describe" +import { script } from "./shellcode/script.js" +import { Bash, Fish, PowerShell, Zsh } from "./shellcode/shells.js" +import describe from "./describe.js" for (const shell of [Bash, Zsh, Fish, PowerShell]) { describe(shell, () => { diff --git a/e2e/log-level.test.ts b/e2e/log-level.test.ts index ee658e8..f7329c8 100644 --- a/e2e/log-level.test.ts +++ b/e2e/log-level.test.ts @@ -1,7 +1,7 @@ -import { script } from "./shellcode/script" -import { Bash, Fish, PowerShell, Zsh } from "./shellcode/shells" -import describe from "./describe" -import getStderr from "./shellcode/get-stderr" +import { script } from "./shellcode/script.js" +import { Bash, Fish, PowerShell, Zsh } from "./shellcode/shells.js" +import describe from "./describe.js" +import getStderr from "./shellcode/get-stderr.js" for (const shell of [Bash, Zsh, Fish, PowerShell]) { describe(shell, () => { diff --git a/e2e/multishell.test.ts b/e2e/multishell.test.ts index 89447c8..60f9007 100644 --- a/e2e/multishell.test.ts +++ b/e2e/multishell.test.ts @@ -1,7 +1,7 @@ -import { script } from "./shellcode/script" -import { Bash, Fish, PowerShell, Zsh } from "./shellcode/shells" -import testNodeVersion from "./shellcode/test-node-version" -import describe from "./describe" +import { script } from "./shellcode/script.js" +import { Bash, Fish, PowerShell, Zsh } from "./shellcode/shells.js" +import testNodeVersion from "./shellcode/test-node-version.js" +import describe from "./describe.js" for (const shell of [Bash, Zsh, Fish, PowerShell]) { describe(shell, () => { diff --git a/e2e/nvmrc-lts.test.ts b/e2e/nvmrc-lts.test.ts index 6c38151..be5a18d 100644 --- a/e2e/nvmrc-lts.test.ts +++ b/e2e/nvmrc-lts.test.ts @@ -1,9 +1,9 @@ -import { script } from "./shellcode/script" -import { Bash, Fish, PowerShell, Zsh } from "./shellcode/shells" +import { script } from "./shellcode/script.js" +import { Bash, Fish, PowerShell, Zsh } from "./shellcode/shells.js" import fs from "node:fs/promises" import path from "node:path" -import describe from "./describe" -import testCwd from "./shellcode/test-cwd" +import describe from "./describe.js" +import testCwd from "./shellcode/test-cwd.js" for (const shell of [Bash, Fish, PowerShell, Zsh]) { describe(shell, () => { diff --git a/e2e/shellcode/script.ts b/e2e/shellcode/script.ts index 49912d3..aec7f15 100644 --- a/e2e/shellcode/script.ts +++ b/e2e/shellcode/script.ts @@ -1,13 +1,13 @@ -import { ScriptLine, Shell } from "./shells/types" -import execa from "execa" -import testTmpDir from "./test-tmp-dir" +import { ScriptLine, Shell } from "./shells/types.js" +import { execa, type ExecaChildProcess } from "execa" +import testTmpDir from "./test-tmp-dir.js" import { Writable } from "node:stream" -import dedent from "ts-dedent" -import testCwd from "./test-cwd" +import { dedent } from "ts-dedent" +import testCwd from "./test-cwd.js" import path, { join } from "node:path" import { writeFile } from "node:fs/promises" import chalk from "chalk" -import testBinDir from "./test-bin-dir" +import testBinDir from "./test-bin-dir.js" class Script { constructor( @@ -51,13 +51,18 @@ class Script { const child = execa(shell.binaryName(), args, { stdio: [shell.forceFile ? "ignore" : "pipe", "pipe", "pipe"], cwd: testCwd(), - env: { - ...removeAllFnmEnvVars(process.env), - PATH: [testBinDir(), fnmTargetDir(), process.env.PATH] - .filter(Boolean) - .join(path.delimiter), - FNM_DIR: this.config.fnmDir, - }, + env: (() => { + const newProcessEnv: Record = { + ...removeAllFnmEnvVars(process.env), + PATH: [testBinDir(), fnmTargetDir(), process.env.PATH] + .filter(Boolean) + .join(path.delimiter), + FNM_DIR: this.config.fnmDir, + } + + delete newProcessEnv.NODE_OPTIONS + return newProcessEnv + })(), extendEnv: false, reject: false, }) @@ -102,7 +107,7 @@ class Script { } } -function streamOutputsAndBuffer(child: execa.ExecaChildProcess) { +function streamOutputsAndBuffer(child: ExecaChildProcess) { const stdout: string[] = [] const stderr: string[] = [] const testName = expect.getState().currentTestName ?? "unknown" @@ -151,7 +156,7 @@ function write(writable: Writable, text: string): Promise { } export function script(shell: Pick): Script { - const fnmDir = `${testTmpDir()}/fnm` + const fnmDir = path.join(testTmpDir(), "fnm") return new Script({ fnmDir }, shell.dieOnErrors ? [shell.dieOnErrors()] : []) } @@ -166,8 +171,9 @@ function removeAllFnmEnvVars(obj: NodeJS.ProcessEnv): NodeJS.ProcessEnv { } function fnmTargetDir(): string { - return path.resolve( - __dirname, - `../../target/${process.env.FNM_TARGET_NAME ?? "debug"}` + return path.join( + process.cwd(), + "target", + process.env.FNM_TARGET_NAME ?? "debug" ) } diff --git a/e2e/shellcode/shells/index.ts b/e2e/shellcode/shells.ts similarity index 84% rename from e2e/shellcode/shells/index.ts rename to e2e/shellcode/shells.ts index 7400d7b..10fd0af 100644 --- a/e2e/shellcode/shells/index.ts +++ b/e2e/shellcode/shells.ts @@ -1,10 +1,10 @@ -import { cmdCall } from "./cmdCall" -import { cmdEnv } from "./cmdEnv" -import { cmdExpectCommandOutput } from "./expect-command-output" -import { cmdHasOutputContains } from "./output-contains" -import { redirectOutput } from "./redirect-output" -import { cmdInSubShell } from "./sub-shell" -import { define, Shell } from "./types" +import { cmdCall } from "./shells/cmdCall.js" +import { cmdEnv } from "./shells/cmdEnv.js" +import { cmdExpectCommandOutput } from "./shells/expect-command-output.js" +import { cmdHasOutputContains } from "./shells/output-contains.js" +import { redirectOutput } from "./shells/redirect-output.js" +import { cmdInSubShell } from "./shells/sub-shell.js" +import { define, Shell } from "./shells/types.js" export const Bash = { ...define({ diff --git a/e2e/shellcode/shells/cmdCall.ts b/e2e/shellcode/shells/cmdCall.ts index 2024a1d..921585a 100644 --- a/e2e/shellcode/shells/cmdCall.ts +++ b/e2e/shellcode/shells/cmdCall.ts @@ -1,4 +1,4 @@ -import { define, ScriptLine } from "./types" +import { define, ScriptLine } from "./types.js" export type HasCall = { call: (binary: string, args: string[]) => ScriptLine diff --git a/e2e/shellcode/shells/cmdEnv.ts b/e2e/shellcode/shells/cmdEnv.ts index f196e9f..581965f 100644 --- a/e2e/shellcode/shells/cmdEnv.ts +++ b/e2e/shellcode/shells/cmdEnv.ts @@ -1,4 +1,4 @@ -import { ScriptLine, define } from "./types" +import { ScriptLine, define } from "./types.js" type EnvConfig = { useOnCd: boolean; logLevel: string } export type HasEnv = { env(cfg: Partial): ScriptLine } diff --git a/e2e/shellcode/shells/expect-command-output.ts b/e2e/shellcode/shells/expect-command-output.ts index cf3bfb2..b55363a 100644 --- a/e2e/shellcode/shells/expect-command-output.ts +++ b/e2e/shellcode/shells/expect-command-output.ts @@ -1,5 +1,5 @@ -import dedent from "ts-dedent" -import { define, ScriptLine } from "./types" +import { dedent } from "ts-dedent" +import { define, ScriptLine } from "./types.js" export type HasExpectCommandOutput = { hasCommandOutput( diff --git a/e2e/shellcode/shells/output-contains.ts b/e2e/shellcode/shells/output-contains.ts index ee8bf1c..8823611 100644 --- a/e2e/shellcode/shells/output-contains.ts +++ b/e2e/shellcode/shells/output-contains.ts @@ -1,4 +1,4 @@ -import { define, ScriptLine } from "./types" +import { define, ScriptLine } from "./types.js" export type HasOutputContains = { scriptOutputContains(script: ScriptLine, substring: string): ScriptLine diff --git a/e2e/shellcode/shells/redirect-output.ts b/e2e/shellcode/shells/redirect-output.ts index a6c1cbd..35a2be5 100644 --- a/e2e/shellcode/shells/redirect-output.ts +++ b/e2e/shellcode/shells/redirect-output.ts @@ -1,4 +1,4 @@ -import { ScriptLine, define } from "./types" +import { ScriptLine, define } from "./types.js" type RedirectOutputOpts = { output: string } export type HasRedirectOutput = { diff --git a/e2e/shellcode/shells/sub-shell.ts b/e2e/shellcode/shells/sub-shell.ts index d46da77..988961a 100644 --- a/e2e/shellcode/shells/sub-shell.ts +++ b/e2e/shellcode/shells/sub-shell.ts @@ -1,4 +1,4 @@ -import { ScriptLine, define } from "./types" +import { ScriptLine, define } from "./types.js" import quote from "shell-escape" type HasInSubShell = { inSubShell: (script: ScriptLine) => ScriptLine } diff --git a/e2e/shellcode/test-bin-dir.ts b/e2e/shellcode/test-bin-dir.ts index cd6c505..d2956ba 100644 --- a/e2e/shellcode/test-bin-dir.ts +++ b/e2e/shellcode/test-bin-dir.ts @@ -1,6 +1,6 @@ import { mkdirSync } from "node:fs" import path from "node:path" -import testTmpDir from "./test-tmp-dir" +import testTmpDir from "./test-tmp-dir.js" export default function testBinDir() { const dir = path.join(testTmpDir(), "bin") diff --git a/e2e/shellcode/test-cwd.ts b/e2e/shellcode/test-cwd.ts index 63d881c..16d02a9 100644 --- a/e2e/shellcode/test-cwd.ts +++ b/e2e/shellcode/test-cwd.ts @@ -1,6 +1,6 @@ import { mkdirSync } from "node:fs" import path from "node:path" -import testTmpDir from "./test-tmp-dir" +import testTmpDir from "./test-tmp-dir.js" export default function testCwd() { const dir = path.join(testTmpDir(), "cwd") diff --git a/e2e/shellcode/test-node-version.ts b/e2e/shellcode/test-node-version.ts index 0d4a83e..894f014 100644 --- a/e2e/shellcode/test-node-version.ts +++ b/e2e/shellcode/test-node-version.ts @@ -1,6 +1,6 @@ -import { HasCall } from "./shells/cmdCall" -import { ScriptLine } from "./shells/types" -import { HasExpectCommandOutput } from "./shells/expect-command-output" +import { HasCall } from "./shells/cmdCall.js" +import { ScriptLine } from "./shells/types.js" +import { HasExpectCommandOutput } from "./shells/expect-command-output.js" export default function testNodeVersion< S extends HasCall & HasExpectCommandOutput diff --git a/e2e/system-node.test.ts b/e2e/system-node.test.ts index c92e6d5..43fb0f0 100644 --- a/e2e/system-node.test.ts +++ b/e2e/system-node.test.ts @@ -1,10 +1,10 @@ -import { script } from "./shellcode/script" -import { Bash, Fish, PowerShell, WinCmd, Zsh } from "./shellcode/shells" +import { script } from "./shellcode/script.js" +import { Bash, Fish, PowerShell, WinCmd, Zsh } from "./shellcode/shells.js" import fs from "node:fs/promises" import path from "node:path" -import describe from "./describe" -import testNodeVersion from "./shellcode/test-node-version" -import testBinDir from "./shellcode/test-bin-dir" +import describe from "./describe.js" +import testNodeVersion from "./shellcode/test-node-version.js" +import testBinDir from "./shellcode/test-bin-dir.js" for (const shell of [Bash, Fish, PowerShell, WinCmd, Zsh]) { describe(shell, () => { diff --git a/e2e/uninstall.test.ts b/e2e/uninstall.test.ts index fcee483..6726c3e 100644 --- a/e2e/uninstall.test.ts +++ b/e2e/uninstall.test.ts @@ -1,6 +1,6 @@ -import { script } from "./shellcode/script" -import { Bash, Fish, PowerShell, Zsh } from "./shellcode/shells" -import describe from "./describe" +import { script } from "./shellcode/script.js" +import { Bash, Fish, PowerShell, Zsh } from "./shellcode/shells.js" +import describe from "./describe.js" for (const shell of [Bash, Zsh, Fish, PowerShell]) { describe(shell, () => { diff --git a/jest.config.cjs b/jest.config.cjs new file mode 100644 index 0000000..10e45aa --- /dev/null +++ b/jest.config.cjs @@ -0,0 +1,22 @@ +/** @type {import('ts-jest').JestConfigWithTsJest} */ +module.exports = { + preset: "ts-jest/presets/default-esm", + testEnvironment: "node", + testTimeout: 120000, + extensionsToTreatAsEsm: [".ts"], + moduleNameMapper: { + "^(\\.{1,2}/.*)\\.js$": "$1", + "#ansi-styles": "ansi-styles/index.js", + "#supports-color": "supports-color/index.js", + }, + transform: { + // '^.+\\.[tj]sx?$' to process js/ts with `ts-jest` + // '^.+\\.m?[tj]sx?$' to process js/ts/mjs/mts with `ts-jest` + "^.+\\.tsx?$": [ + "ts-jest", + { + useESM: true, + }, + ], + }, +} diff --git a/package.json b/package.json index 6e0ca34..7987f8e 100644 --- a/package.json +++ b/package.json @@ -4,10 +4,11 @@ "private": true, "repository": "git@github.com:Schniz/fnm.git", "author": "Gal Schlezinger ", + "type": "module", "packageManager": "pnpm@7.13.2", "license": "GPLv3", "scripts": { - "test": "jest", + "test": "cross-env NODE_OPTIONS='--experimental-vm-modules' jest", "version:prepare": "changeset version && ./.ci/prepare-version.js", "generate-command-docs": "./.ci/print-command-docs.js" }, @@ -23,37 +24,25 @@ "devDependencies": { "@changesets/cli": "2.25.0", "@svitejs/changesets-changelog-github-compact": "0.1.1", - "@swc-node/jest": "^1.5.5", - "@swc/core": "^1.3.17", "@types/jest": "^29.2.3", "@types/node": "^18.11.9", "@types/shell-escape": "^0.2.1", - "chalk": "4", + "chalk": "^5.1.2", "cmd-ts": "0.11.0", - "execa": "5.1.1", + "cross-env": "^7.0.3", + "execa": "6.1.0", "jest": "^29.3.1", "lerna-changelog": "2.2.0", - "p-retry": "^4", "prettier": "2.7.1", "pv": "1.0.1", "shell-escape": "^0.2.0", "svg-term-cli": "2.1.1", "toml": "3.0.0", "ts-dedent": "^2.2.0", + "ts-jest": "^29.0.3", "typescript": "^4.8.4" }, "prettier": { "semi": false - }, - "jest": { - "transform": { - "^.+\\.ts$": "@swc-node/jest" - }, - "testEnvironment": "node", - "moduleFileExtensions": [ - "ts", - "js" - ], - "testTimeout": 120000 } } diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 5103d12..be10d13 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -3,45 +3,43 @@ lockfileVersion: 5.4 specifiers: '@changesets/cli': 2.25.0 '@svitejs/changesets-changelog-github-compact': 0.1.1 - '@swc-node/jest': ^1.5.5 - '@swc/core': ^1.3.17 '@types/jest': ^29.2.3 '@types/node': ^18.11.9 '@types/shell-escape': ^0.2.1 - chalk: '4' + chalk: ^5.1.2 cmd-ts: 0.11.0 - execa: 5.1.1 + cross-env: ^7.0.3 + execa: 6.1.0 jest: ^29.3.1 lerna-changelog: 2.2.0 - p-retry: ^4 prettier: 2.7.1 pv: 1.0.1 shell-escape: ^0.2.0 svg-term-cli: 2.1.1 toml: 3.0.0 ts-dedent: ^2.2.0 + ts-jest: ^29.0.3 typescript: ^4.8.4 devDependencies: '@changesets/cli': 2.25.0 '@svitejs/changesets-changelog-github-compact': 0.1.1 - '@swc-node/jest': 1.5.5_ndsvmk6usi2zctqgdwwiwj3k5q - '@swc/core': 1.3.17 '@types/jest': 29.2.3 '@types/node': 18.11.9 '@types/shell-escape': 0.2.1 - chalk: 4.1.2 + chalk: 5.1.2 cmd-ts: 0.11.0 - execa: 5.1.1 + cross-env: 7.0.3 + execa: 6.1.0 jest: 29.3.1_@types+node@18.11.9 lerna-changelog: 2.2.0 - p-retry: 4.6.2 prettier: 2.7.1 pv: 1.0.1 shell-escape: 0.2.0 svg-term-cli: 2.1.1 toml: 3.0.0 ts-dedent: 2.2.0 + ts-jest: 29.0.3_r24ewcothphvclnu77pxb4u4se typescript: 4.8.4 packages: @@ -907,142 +905,6 @@ packages: rimraf: 2.7.1 dev: true - /@node-rs/xxhash-android-arm-eabi/1.2.1: - resolution: {integrity: sha512-wvx3/7zBlsUnwWS9ZHBuPqubKaotMNDcyyroEMt5ZV+28/hF4HjNZQgOk6uHdOdlMKAXThqc6AHzwGOK1XXYmw==} - engines: {node: '>= 12'} - cpu: [arm] - os: [android] - requiresBuild: true - dev: true - optional: true - - /@node-rs/xxhash-android-arm64/1.2.1: - resolution: {integrity: sha512-97Hrljvg+J4VxZH5WBqTwIsWrkNCub4aj2mW878svOVYV1qQFU0D4LuJGX8qE0WFTrmL0ycMEH2WIk4CIV5dMg==} - engines: {node: '>= 12'} - cpu: [arm64] - os: [android] - requiresBuild: true - dev: true - optional: true - - /@node-rs/xxhash-darwin-arm64/1.2.1: - resolution: {integrity: sha512-TtfW7Zo1AYQcIMYBI46VQtNkS6scXRnPp/f+9b7+xzEZ72SIpaDKE/33EjrXBNm2ARYRxCpTtL4jN0IHECYe3g==} - engines: {node: '>= 12'} - cpu: [arm64] - os: [darwin] - requiresBuild: true - dev: true - optional: true - - /@node-rs/xxhash-darwin-x64/1.2.1: - resolution: {integrity: sha512-EEy3bPzvi1TStTMxalvIyNia6j9vlICTjnwRhGpShfIMg6XR6OUzda9JojozF53YhHH4oPAzUtUGA2SM5wU8mg==} - engines: {node: '>= 12'} - cpu: [x64] - os: [darwin] - requiresBuild: true - dev: true - optional: true - - /@node-rs/xxhash-freebsd-x64/1.2.1: - resolution: {integrity: sha512-FYBrXV15HXnDEbzIJ0veY5H0C3NqU8kVJOvX7pAFK2kGqspq92BGfBS8j1BOxEFZ6pyQwMQgfOhRI/bsdrb7Zg==} - engines: {node: '>= 12'} - cpu: [x64] - os: [freebsd] - requiresBuild: true - dev: true - optional: true - - /@node-rs/xxhash-linux-arm-gnueabihf/1.2.1: - resolution: {integrity: sha512-h58lDRP3T+kNjH4GCfnCB50b7d9XuVLogN3+wRWZI0yDE1AlTZBfK/00IwSvREcRjHqc5crsS9Zh3SuxIjID2g==} - engines: {node: '>= 12'} - cpu: [arm] - os: [linux] - requiresBuild: true - dev: true - optional: true - - /@node-rs/xxhash-linux-arm64-gnu/1.2.1: - resolution: {integrity: sha512-OLReGi3amHkIU8zPxmDXyJHsUNR2XOPBwd9bzJcuxNM0wSP0g3EMs9VUHmlhh/DiomTduu6A90WzrmuCGaYUAA==} - engines: {node: '>= 12'} - cpu: [arm64] - os: [linux] - requiresBuild: true - dev: true - optional: true - - /@node-rs/xxhash-linux-arm64-musl/1.2.1: - resolution: {integrity: sha512-Rc22qQALjoTkdY2JnoJZn6bzHQQyNcvysU1kznAqwg9pPOD4bU++of1sS7II8o/ihe1g/qz4RKfyG+qUPjy/WQ==} - engines: {node: '>= 12'} - cpu: [arm64] - os: [linux] - requiresBuild: true - dev: true - optional: true - - /@node-rs/xxhash-linux-x64-gnu/1.2.1: - resolution: {integrity: sha512-MM0dfHxEe4uHuUFyM12pXiuie7fAq2LH7+PrXb8FqaGHqxF4aaIZE0gTMNDmrCsJy91tun85/TCu1vQEJ0g+Bw==} - engines: {node: '>= 12'} - cpu: [x64] - os: [linux] - requiresBuild: true - dev: true - optional: true - - /@node-rs/xxhash-linux-x64-musl/1.2.1: - resolution: {integrity: sha512-mD3DEGqnxi39cMDIi5ZqcEUl4/eOcM4qGY/XFSFpUN7oUG4vnf/8U5mwzvAjU+nHWaq9ubteePA1GOXiATvv6w==} - engines: {node: '>= 12'} - cpu: [x64] - os: [linux] - requiresBuild: true - dev: true - optional: true - - /@node-rs/xxhash-win32-arm64-msvc/1.2.1: - resolution: {integrity: sha512-90A9Ux4ozMSmss3Pn+A3TTYSw8uzGSBIPrRw+mIn/rVKBMfMfkKKNL+xjIXw1lkL9s2kG/1aGMBRTeuOeG9xtA==} - engines: {node: '>= 12'} - cpu: [arm64] - os: [win32] - requiresBuild: true - dev: true - optional: true - - /@node-rs/xxhash-win32-ia32-msvc/1.2.1: - resolution: {integrity: sha512-zhpg4pV71e6vDmOSLwFCNKiodtcNHUg76d5npvkWhJa0T/ykMHGWUbaFnpQzLwGD5Sq4mDHrQ7h6lxYA4j/6eQ==} - engines: {node: '>= 12'} - cpu: [ia32] - os: [win32] - requiresBuild: true - dev: true - optional: true - - /@node-rs/xxhash-win32-x64-msvc/1.2.1: - resolution: {integrity: sha512-KkZKyppIM2HJA3oZQ4nsPLwQ5HbELCZt+epLAH3/0H3QN9zqbzoCn6b140hg0lX+KT6YT0otGMbnlnvD2qpswQ==} - engines: {node: '>= 12'} - cpu: [x64] - os: [win32] - requiresBuild: true - dev: true - optional: true - - /@node-rs/xxhash/1.2.1: - resolution: {integrity: sha512-Yyur0X8LFgzxcRWro1wAGVCZK8kcpDhnRKUUeW21OTpoHzDwN8zZSm43bF76xMQF1SyfWr17aSG6G0o8D1hTJA==} - engines: {node: '>= 12'} - optionalDependencies: - '@node-rs/xxhash-android-arm-eabi': 1.2.1 - '@node-rs/xxhash-android-arm64': 1.2.1 - '@node-rs/xxhash-darwin-arm64': 1.2.1 - '@node-rs/xxhash-darwin-x64': 1.2.1 - '@node-rs/xxhash-freebsd-x64': 1.2.1 - '@node-rs/xxhash-linux-arm-gnueabihf': 1.2.1 - '@node-rs/xxhash-linux-arm64-gnu': 1.2.1 - '@node-rs/xxhash-linux-arm64-musl': 1.2.1 - '@node-rs/xxhash-linux-x64-gnu': 1.2.1 - '@node-rs/xxhash-linux-x64-musl': 1.2.1 - '@node-rs/xxhash-win32-arm64-msvc': 1.2.1 - '@node-rs/xxhash-win32-ia32-msvc': 1.2.1 - '@node-rs/xxhash-win32-x64-msvc': 1.2.1 - dev: true - /@nodelib/fs.scandir/2.1.5: resolution: {integrity: sha512-vq24Bq3ym5HEQm2NKCr3yXDwjc7vTsEThRDnkp2DK9p1uqLR+DHurm/NOTo0KG7HYHU7eppKZj3MyqYuMBf62g==} engines: {node: '>= 8'} @@ -1181,162 +1043,6 @@ packages: - encoding dev: true - /@swc-node/core/1.9.1_@swc+core@1.3.17: - resolution: {integrity: sha512-Mh4T/PmQOpPtqw1BNvU38uWzsXbd5RJji17YBXnj7JDDE5KlTR9sSo2RKxWKDVtHbdcD1S+CtyZXA93aEWlfGQ==} - engines: {node: '>= 10'} - peerDependencies: - '@swc/core': '>= 1.3' - dependencies: - '@swc/core': 1.3.17 - dev: true - - /@swc-node/jest/1.5.5_ndsvmk6usi2zctqgdwwiwj3k5q: - resolution: {integrity: sha512-DUf0XMk5xuwt4x+BiZ++KlPxa0H9lvjhFdXU2c8lsu+UztGRUAUtI5nhNTqjS9PXw0zzf3gEFP7M8hNUo52YhQ==} - peerDependencies: - '@swc/core': '>= 1.3' - dependencies: - '@node-rs/xxhash': 1.2.1 - '@swc-node/core': 1.9.1_@swc+core@1.3.17 - '@swc-node/register': 1.5.4_ndsvmk6usi2zctqgdwwiwj3k5q - '@swc/core': 1.3.17 - transitivePeerDependencies: - - supports-color - - typescript - dev: true - - /@swc-node/register/1.5.4_ndsvmk6usi2zctqgdwwiwj3k5q: - resolution: {integrity: sha512-cM5/A63bO6qLUFC4gcBnOlQO5yd8ObSdFUIp7sXf11Oq5mPVAnJy2DqjbWMUsqUaHuNk+lOIt76ie4DEseUIyA==} - peerDependencies: - '@swc/core': '>= 1.3' - typescript: '>= 4.3' - dependencies: - '@swc-node/core': 1.9.1_@swc+core@1.3.17 - '@swc-node/sourcemap-support': 0.2.2 - '@swc/core': 1.3.17 - colorette: 2.0.19 - debug: 4.3.4 - pirates: 4.0.5 - tslib: 2.4.1 - typescript: 4.8.4 - transitivePeerDependencies: - - supports-color - dev: true - - /@swc-node/sourcemap-support/0.2.2: - resolution: {integrity: sha512-PA4p7nC5LwPdEVcQXFxMTpfvizYPeMoB55nIIx+yC3FiLnyPgC2hcpUitPy5h8RRGdCZ/Mvb2ryEcVYS8nI6YA==} - dependencies: - source-map-support: 0.5.21 - tslib: 2.4.1 - dev: true - - /@swc/core-darwin-arm64/1.3.17: - resolution: {integrity: sha512-l82ub46GSRRpPpvR9NkHqqskPKQAkpRAKMZNzBrY01GLzUj63XH8uAv+3N1Htpq835iekWJjGZXYONCZ1eHlcQ==} - engines: {node: '>=10'} - cpu: [arm64] - os: [darwin] - requiresBuild: true - dev: true - optional: true - - /@swc/core-darwin-x64/1.3.17: - resolution: {integrity: sha512-pBVrF1Ac5t6v9wd5Jqdfve7d0G3ELnjHzaEmCxV0W3ma7/pfHiGv7ZPGnXTclt0+IrMisrVoY5LM+xG1Hv+91Q==} - engines: {node: '>=10'} - cpu: [x64] - os: [darwin] - requiresBuild: true - dev: true - optional: true - - /@swc/core-linux-arm-gnueabihf/1.3.17: - resolution: {integrity: sha512-argIcltgNEssehO7PzXuNYbV7ubVd6YW13FhB9uNWEp/1HGSzIJEnJ4tISbZe9NA9jwI3IALAiE3vDdTdGf/XA==} - engines: {node: '>=10'} - cpu: [arm] - os: [linux] - requiresBuild: true - dev: true - optional: true - - /@swc/core-linux-arm64-gnu/1.3.17: - resolution: {integrity: sha512-bH0YSJd3thV1/kY5lHkeXTEcbx0HYFpIqCGJbeDvzpg38FEFSFiUw9+0VX6Yf3FKPq1DcGK/eAKYC7LeZfAzvg==} - engines: {node: '>=10'} - cpu: [arm64] - os: [linux] - requiresBuild: true - dev: true - optional: true - - /@swc/core-linux-arm64-musl/1.3.17: - resolution: {integrity: sha512-sV5rfpPADmOg5YfTXLLGAzeTUjjgix29kra44EKa25Qyuwu/52OkoW4olF86qwvcQrRySWwga95EeClRhIX/zA==} - engines: {node: '>=10'} - cpu: [arm64] - os: [linux] - requiresBuild: true - dev: true - optional: true - - /@swc/core-linux-x64-gnu/1.3.17: - resolution: {integrity: sha512-KbPdQSLgSjTutFsCGzjTzMCzZBiem4dEByiKxkrQmt87kLX4wLlPCy0Gppcaa6jExRcvy5co/vlf9TknuKcy4A==} - engines: {node: '>=10'} - cpu: [x64] - os: [linux] - requiresBuild: true - dev: true - optional: true - - /@swc/core-linux-x64-musl/1.3.17: - resolution: {integrity: sha512-NDUbaJ0MbklioadPhkzQDOP8eazOn1lJmNmcmg9zNUR7GZsek1CMmJkyJ3ETXZ5gbIfVQ1hPkPm23P9vQBtCdQ==} - engines: {node: '>=10'} - cpu: [x64] - os: [linux] - requiresBuild: true - dev: true - optional: true - - /@swc/core-win32-arm64-msvc/1.3.17: - resolution: {integrity: sha512-fmpGG1iuKcMSDSO2ZHETlYTRel5hTwyuJ4AYbUX3/YzAE4iEnV1PI/n54wrWIdKONsPt3Pcj/UyRD3A6/ZS8rQ==} - engines: {node: '>=10'} - cpu: [arm64] - os: [win32] - requiresBuild: true - dev: true - optional: true - - /@swc/core-win32-ia32-msvc/1.3.17: - resolution: {integrity: sha512-hmQovtwsKnb4D+NAKN2HYjTyNE3iXakBrQNSo1u+/KeMU+D6/+XCSdzrg7ob4olqf4yq52FXPPkLYwyDDHRO/g==} - engines: {node: '>=10'} - cpu: [ia32] - os: [win32] - requiresBuild: true - dev: true - optional: true - - /@swc/core-win32-x64-msvc/1.3.17: - resolution: {integrity: sha512-wl+L7300uFr74WWw+b+mIx9NzMQB8+LCapFc01LqDgFyUFT6HSIIM9/s3zzy5Xh8UpgnkbS0/7rMl+zC1V+nFw==} - engines: {node: '>=10'} - cpu: [x64] - os: [win32] - requiresBuild: true - dev: true - optional: true - - /@swc/core/1.3.17: - resolution: {integrity: sha512-wcjmxJqwpo9mQqnyUChyIIxC3nw2xRK07zGMS2zbcId31J+wer5PMbgy0qEqzZEeIswUmL8lBO4whM+wSAmVqA==} - engines: {node: '>=10'} - hasBin: true - requiresBuild: true - optionalDependencies: - '@swc/core-darwin-arm64': 1.3.17 - '@swc/core-darwin-x64': 1.3.17 - '@swc/core-linux-arm-gnueabihf': 1.3.17 - '@swc/core-linux-arm64-gnu': 1.3.17 - '@swc/core-linux-arm64-musl': 1.3.17 - '@swc/core-linux-x64-gnu': 1.3.17 - '@swc/core-linux-x64-musl': 1.3.17 - '@swc/core-win32-arm64-msvc': 1.3.17 - '@swc/core-win32-ia32-msvc': 1.3.17 - '@swc/core-win32-x64-msvc': 1.3.17 - dev: true - /@tootallnate/once/1.1.2: resolution: {integrity: sha512-RbzJvlNzmRq5c3O09UipeuXno4tA1FE6ikOjxZK0tuxVv3412l64l5t1W5pj4+rJq9vpkm/kwiR07aZXnsKPxw==} engines: {node: '>= 6'} @@ -1463,10 +1169,6 @@ packages: resolution: {integrity: sha512-L28j2FcJfSZOnL1WBjDYp2vUHCeIFlyYI/53EwD/rKUBQ7MtUUfbQWiyKJGpcnv4/WgrhWsFKrcPstcAt/J0tQ==} dev: true - /@types/retry/0.12.0: - resolution: {integrity: sha512-wWKOClTTiizcZhXnPY4wikVAwmdYHp8q6DmC+EJUzAMsycb7HB32Kh9RN4+0gExjmPmZSAQjgURXIGATPegAvA==} - dev: true - /@types/semver/6.2.3: resolution: {integrity: sha512-KQf+QAMWKMrtBMsB8/24w53tEsxllMj6TuA80TT/5igJalLI/zm0L3oXRbIAl4Ohfc85gyHX/jhMwsVkmhLU4A==} dev: true @@ -1758,6 +1460,13 @@ packages: update-browserslist-db: 1.0.10_browserslist@4.21.4 dev: true + /bs-logger/0.2.6: + resolution: {integrity: sha512-pd8DCoxmbgc7hyPKOvxtqNcjYoOsABPQdcCUjGp3d42VR2CX1ORhk2A87oqqu5R1kk+76nsxZupkmyd+MVtCog==} + engines: {node: '>= 6'} + dependencies: + fast-json-stable-stringify: 2.1.0 + dev: true + /bser/2.1.1: resolution: {integrity: sha512-gQxTNE/GAfIIrmHLUE3oJyp5FO6HRBfhjnw4/wMmA63ZGDJnWBmgY/lyQBpnDUkGmAhbSe39tx2d/iTOAfglwQ==} dependencies: @@ -1864,6 +1573,11 @@ packages: supports-color: 7.2.0 dev: true + /chalk/5.1.2: + resolution: {integrity: sha512-E5CkT4jWURs1Vy5qGJye+XwCkNj7Od3Af7CP6SujMetSMkLs8Do2RWJK5yx1wamHV/op8Rz+9rltjaTQWDnEFQ==} + engines: {node: ^12.17.0 || ^14.13 || >=16.0.0} + dev: true + /char-regex/1.0.2: resolution: {integrity: sha512-kWWXztvZ5SBQV+eRgKFeh8q5sLuZY2+8WUIzlxWVTg+oGwY14qylx1KbKzHd8P6ZYkAg0xyIDU9JMHhyJMZ1jw==} engines: {node: '>=10'} @@ -1994,10 +1708,6 @@ packages: color-string: 1.9.1 dev: true - /colorette/2.0.19: - resolution: {integrity: sha512-3tlv/dIP7FWvj3BsbHrGLJ6l/oKh1O3TcgBqMn+yyCagOxc23fyzDS6HypQbgxWbkpDnf52p1LuR4eWDQ/K9WQ==} - dev: true - /command-exists/1.2.9: resolution: {integrity: sha512-LTQ/SGc+s0Xc0Fu5WaKnR0YiygZkm9eKFvyS+fRsU7/ZWFF8ykFM6Pc9aCVf1+xasOOZpO3BAVgVrKvsqKHV7w==} dev: true @@ -2018,6 +1728,14 @@ packages: resolution: {integrity: sha512-ZQBvi1DcpJ4GDqanjucZ2Hj3wEO5pZDS89BWbkcrvdxksJorwUDDZamX9ldFkp9aw2lmBDLgkObEA4DWNJ9FYQ==} dev: true + /cross-env/7.0.3: + resolution: {integrity: sha512-+/HKd6EgcQCJGh2PSjZuUitQBQynKor4wrFbRg4DtAgS1aWO+gU52xpH7M9ScGgXSYmAVS9bIJ8EzuaGw0oNAw==} + engines: {node: '>=10.14', npm: '>=6', yarn: '>=1'} + hasBin: true + dependencies: + cross-spawn: 7.0.3 + dev: true + /cross-spawn-async/2.2.5: resolution: {integrity: sha512-snteb3aVrxYYOX9e8BabYFK9WhCDhTlw1YQktfTthBogxri4/2r9U2nQc0ffY73ZAxezDc+U8gvHAeU1wy1ubQ==} deprecated: cross-spawn no longer requires a build toolchain, use it instead @@ -2378,6 +2096,21 @@ packages: strip-final-newline: 2.0.0 dev: true + /execa/6.1.0: + resolution: {integrity: sha512-QVWlX2e50heYJcCPG0iWtf8r0xjEYfz/OYLGDYH+IyjWezzPNxz63qNFOu0l4YftGWuizFVZHHs8PrLU5p2IDA==} + engines: {node: ^12.20.0 || ^14.13.1 || >=16.0.0} + dependencies: + cross-spawn: 7.0.3 + get-stream: 6.0.1 + human-signals: 3.0.1 + is-stream: 3.0.0 + merge-stream: 2.0.0 + npm-run-path: 5.1.0 + onetime: 6.0.0 + signal-exit: 3.0.7 + strip-final-newline: 3.0.0 + dev: true + /exit/0.1.2: resolution: {integrity: sha512-Zk/eNKV2zbjpKzrsQ+n1G6poVbErQxJ0LBOJXaKZ1EViLzH+hrLu9cdXI4zw9dBQJslwBEpbQ2P1oS7nDxs6jQ==} engines: {node: '>= 0.8.0'} @@ -2728,6 +2461,11 @@ packages: engines: {node: '>=10.17.0'} dev: true + /human-signals/3.0.1: + resolution: {integrity: sha512-rQLskxnM/5OCldHo+wNXbpVgDn5A17CUoKX+7Sokwaknlq7CdSnphy0W39GU8dw59XiCXmFXDg4fRuckQRKewQ==} + engines: {node: '>=12.20.0'} + dev: true + /humanize-ms/1.2.1: resolution: {integrity: sha512-Fl70vYtsAFb/C06PTS9dZBo7ihau+Tu/DNCk/OyHhea07S+aeMWpFFkUaXRa8fI+ScZbEI8dfSxwY7gxZ9SAVQ==} dependencies: @@ -2940,6 +2678,11 @@ packages: engines: {node: '>=8'} dev: true + /is-stream/3.0.0: + resolution: {integrity: sha512-LnQR4bZ9IADDRSkvpqMGvt/tEJWclzklNgSw48V5EAaAeDd6qGvN8ei6k5p0tvxSR171VmGyHuTiAOfxAbr8kA==} + engines: {node: ^12.20.0 || ^14.13.1 || >=16.0.0} + dev: true + /is-string/1.0.7: resolution: {integrity: sha512-tE2UXzivje6ofPW7l23cjDOMa09gb7xlAqG6jG5ej6uPV32TlWP3NKPigtaGeHNu9fohccRYvIiZMfOOnOYUtg==} engines: {node: '>= 0.4'} @@ -3554,6 +3297,10 @@ packages: p-locate: 5.0.0 dev: true + /lodash.memoize/4.1.2: + resolution: {integrity: sha512-t7j+NzmgnQzTAYXcsHYLgimltOV1MXHtlOWf6GjL9Kj8GK5FInw5JotxvbOs+IvV1/Dzo04/fCGfLVs7aXb4Ag==} + dev: true + /lodash.startcase/4.4.0: resolution: {integrity: sha512-+WKqsK294HMSc2jEbNgpHpd0JfIBhp7rEV4aqXWqFr6AlXov+SlcgB1Fv01y2kGe3Gc8nMW7VA0SrGuSkRfIEg==} dev: true @@ -3608,6 +3355,10 @@ packages: semver: 6.3.0 dev: true + /make-error/1.3.6: + resolution: {integrity: sha512-s8UhlNe7vPKomQhC1qFelMokr/Sc3AgNbso3n74mVPA5LTZwkB9NlXf4XPamLxJE8h0gh73rM94xvwRT2CVInw==} + dev: true + /make-fetch-happen/9.1.0: resolution: {integrity: sha512-+zopwDy7DNknmwPQplem5lAZX/eCOzSvSNNcSKm5eVwTkOBzoktEfXsa9L23J/GIRhxRsaxzkPEhrJEpE2F4Gg==} engines: {node: '>= 10'} @@ -3712,6 +3463,11 @@ packages: engines: {node: '>=6'} dev: true + /mimic-fn/4.0.0: + resolution: {integrity: sha512-vqiC06CuhBTUdZH+RYl8sFrL096vA45Ok5ISO6sE/Mr1jRbGH4Csnhi8f3wKVl7x8mO4Au7Ir9D3Oyv1VYMFJw==} + engines: {node: '>=12'} + dev: true + /min-indent/1.0.1: resolution: {integrity: sha512-I9jwMn07Sy/IwOj3zVkVik2JTvgpaykDZEigL6Rx6N9LbMywwUSMtxET+7lVoDLLd3O3IXwJwvuuns8UB/HeAg==} engines: {node: '>=4'} @@ -3895,6 +3651,13 @@ packages: path-key: 3.1.1 dev: true + /npm-run-path/5.1.0: + resolution: {integrity: sha512-sJOdmRGrY2sjNTRMbSvluQqg+8X7ZK61yvzBEIDhz4f8z1TZFYABsqjjCBd/0PUNE9M6QDgHJXQkGUEm7Q+l9Q==} + engines: {node: ^12.20.0 || ^14.13.1 || >=16.0.0} + dependencies: + path-key: 4.0.0 + dev: true + /nth-check/1.0.2: resolution: {integrity: sha512-WeBOdju8SnzPN5vTUJYxYUxLeXpCaVP5i5e0LF8fg7WORF2Wd7wFX/pk0tYZk7s8T+J7VLy0Da6J1+wCT0AtHg==} dependencies: @@ -3962,6 +3725,13 @@ packages: mimic-fn: 2.1.0 dev: true + /onetime/6.0.0: + resolution: {integrity: sha512-1FlR+gjXK7X+AsAHso35MnyN5KqGwJRi/31ft6x0M194ht7S+rWAvd7PHss9xSKMzE0asv1pyIHaJYq+BbacAQ==} + engines: {node: '>=12'} + dependencies: + mimic-fn: 4.0.0 + dev: true + /os-tmpdir/1.0.2: resolution: {integrity: sha512-D2FR03Vir7FIu45XBY20mTb+/ZSWB00sjU9jdQXt83gDrI4Ztz5Fs7/yy74g2N5SVQY4xY1qDr4rNddwYRVX0g==} engines: {node: '>=0.10.0'} @@ -4030,14 +3800,6 @@ packages: aggregate-error: 3.1.0 dev: true - /p-retry/4.6.2: - resolution: {integrity: sha512-312Id396EbJdvRONlngUx0NydfrIQ5lsYu0znKVUzVvArzEIt08V1qhtyESbGVd1FGX7UKtiFp5uwKZdM8wIuQ==} - engines: {node: '>=8'} - dependencies: - '@types/retry': 0.12.0 - retry: 0.13.1 - dev: true - /p-try/2.2.0: resolution: {integrity: sha512-R4nPAVTAU0B9D35/Gk3uJf/7XYbQcyohSKdvAxIRSNghFl4e71hVoGnBNQz9cWaXxO2I10KTC+3jMdvvoKw6dQ==} engines: {node: '>=6'} @@ -4106,6 +3868,11 @@ packages: engines: {node: '>=8'} dev: true + /path-key/4.0.0: + resolution: {integrity: sha512-haREypq7xkM7ErfgIyA0z+Bj4AGKlMSdlQE2jvJo6huWD1EdkKYV+G/T4nq0YEF2vgTT8kqMFKo1uHn950r4SQ==} + engines: {node: '>=12'} + dev: true + /path-parse/1.0.7: resolution: {integrity: sha512-LDJzPVEEEPR+y48z93A0Ed0yXb8pAByGWo/k5YYdYgpY2/2EsOsksJrq7lOHxryrVOn1ejG6oAp8ahvOIQD8sw==} dev: true @@ -4449,11 +4216,6 @@ packages: engines: {node: '>= 4'} dev: true - /retry/0.13.1: - resolution: {integrity: sha512-XQBQ3I8W1Cge0Seh+6gjj03LbmRFWuoszgK9ooCpwYIrhhoO80pfq4cUkU5DkknwfOfFteRwlZ56PYOGYyFWdg==} - engines: {node: '>= 4'} - dev: true - /reusify/1.0.4: resolution: {integrity: sha512-U9nH88a3fc/ekCF1l0/UP1IosiuIjyTh7hBvXVMHYgVcfGvt897Xguj2UOLDeI5BG2m7/uwyaLVT6fbtCwTyzw==} engines: {iojs: '>=1.0.0', node: '>=0.10.0'} @@ -4619,13 +4381,6 @@ packages: source-map: 0.6.1 dev: true - /source-map-support/0.5.21: - resolution: {integrity: sha512-uBHU3L3czsIyYXKX88fdrGovxdSCoTGDRZ6SYXtSRxLZUzHg5P/66Ht6uoUlHu9EZod+inXhKo3qQgwXUT/y1w==} - dependencies: - buffer-from: 1.1.2 - source-map: 0.6.1 - dev: true - /source-map/0.6.1: resolution: {integrity: sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==} engines: {node: '>=0.10.0'} @@ -4766,6 +4521,11 @@ packages: engines: {node: '>=6'} dev: true + /strip-final-newline/3.0.0: + resolution: {integrity: sha512-dOESqjYr96iWYylGObzd39EuNTa5VJxyvVAEm5Jnh7KGo75V43Hk1odPQkNDyXNmUR6k+gEiDVXnjB8HJ3crXw==} + engines: {node: '>=12'} + dev: true + /strip-indent/1.0.1: resolution: {integrity: sha512-I5iQq6aFMM62fBEAIB/hXzwJD6EEZ0xEGCX2t7oXqaKPIRgt4WruAQ285BISgdkP+HLGWyeGmNJcpIwFeRYRUA==} engines: {node: '>=0.10.0'} @@ -5014,12 +4774,41 @@ packages: engines: {node: '>=6.10'} dev: true - /tslib/1.14.1: - resolution: {integrity: sha512-Xni35NKzjgMrwevysHTCArtLDpPvye8zV/0E4EyYn43P7/7qvQwPh9BGkHewbMulVntbigmcT7rdX3BNo9wRJg==} + /ts-jest/29.0.3_r24ewcothphvclnu77pxb4u4se: + resolution: {integrity: sha512-Ibygvmuyq1qp/z3yTh9QTwVVAbFdDy/+4BtIQR2sp6baF2SJU/8CKK/hhnGIDY2L90Az2jIqTwZPnN2p+BweiQ==} + engines: {node: ^14.15.0 || ^16.10.0 || >=18.0.0} + hasBin: true + peerDependencies: + '@babel/core': '>=7.0.0-beta.0 <8' + '@jest/types': ^29.0.0 + babel-jest: ^29.0.0 + esbuild: '*' + jest: ^29.0.0 + typescript: '>=4.3' + peerDependenciesMeta: + '@babel/core': + optional: true + '@jest/types': + optional: true + babel-jest: + optional: true + esbuild: + optional: true + dependencies: + bs-logger: 0.2.6 + fast-json-stable-stringify: 2.1.0 + jest: 29.3.1_@types+node@18.11.9 + jest-util: 29.3.1 + json5: 2.2.1 + lodash.memoize: 4.1.2 + make-error: 1.3.6 + semver: 7.3.7 + typescript: 4.8.4 + yargs-parser: 21.0.1 dev: true - /tslib/2.4.1: - resolution: {integrity: sha512-tGyy4dAjRIEwI7BzsB0lynWgOpfqjUdq91XXAlIWD2OwKBH7oCl/GZG/HT4BOHrTlPMOASlMQ7veyTqpmRcrNA==} + /tslib/1.14.1: + resolution: {integrity: sha512-Xni35NKzjgMrwevysHTCArtLDpPvye8zV/0E4EyYn43P7/7qvQwPh9BGkHewbMulVntbigmcT7rdX3BNo9wRJg==} dev: true /tty-table/4.1.6: diff --git a/tsconfig.json b/tsconfig.json index aeca195..05c6d35 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,7 +1,9 @@ { "compilerOptions": { "target": "esnext", - "module": "commonjs", + "moduleResolution": "NodeNext", + "moduleDetection": "force", + "module": "esnext", "esModuleInterop": true, "forceConsistentCasingInFileNames": true, "strict": true,