From 513de9020512b7e270220ea768e1a7332e6a1d3e Mon Sep 17 00:00:00 2001 From: prisis Date: Fri, 17 Jan 2025 23:08:19 +0100 Subject: [PATCH 1/3] feat: add support for multiple package managers like yarn and pnpm, added new --pm option to enable this feature --- packages/cli/package.json | 4 +- packages/cli/src/index.ts | 38 ++++++++++++- packages/cli/test/snapshots.test.ts | 6 ++ .../snapshots/axios@1.4.0.tgz --pm npm.md | 57 +++++++++++++++++++ .../snapshots/axios@1.4.0.tgz --pm pnpm.md | 57 +++++++++++++++++++ .../axios@1.4.0.tgz --pm yarn-classic.md | 57 +++++++++++++++++++ .../test/snapshots/axios@1.4.0.tgz --pm.md | 57 +++++++++++++++++++ pnpm-lock.yaml | 17 ++++++ 8 files changed, 289 insertions(+), 4 deletions(-) create mode 100644 packages/cli/test/snapshots/axios@1.4.0.tgz --pm npm.md create mode 100644 packages/cli/test/snapshots/axios@1.4.0.tgz --pm pnpm.md create mode 100644 packages/cli/test/snapshots/axios@1.4.0.tgz --pm yarn-classic.md create mode 100644 packages/cli/test/snapshots/axios@1.4.0.tgz --pm.md diff --git a/packages/cli/package.json b/packages/cli/package.json index 2879054..5cafd0e 100644 --- a/packages/cli/package.json +++ b/packages/cli/package.json @@ -49,6 +49,7 @@ "@types/marked-terminal": "^3.1.3", "@types/node": "^22.5.0", "@types/semver": "^7.5.3", + "@types/which-pm-runs": "^1.0.2", "ts-expose-internals": "5.6.1-rc" }, "dependencies": { @@ -58,7 +59,8 @@ "commander": "^10.0.1", "marked": "^9.1.2", "marked-terminal": "^7.1.0", - "semver": "^7.5.4" + "semver": "^7.5.4", + "which-pm-runs": "^1.1.0" }, "engines": { "node": ">=18" diff --git a/packages/cli/src/index.ts b/packages/cli/src/index.ts index d62212e..0abe007 100644 --- a/packages/cli/src/index.ts +++ b/packages/cli/src/index.ts @@ -18,6 +18,7 @@ import { getExitCode } from "./getExitCode.js"; import { applyProfile, profiles } from "./profiles.js"; import { write } from "./write.js"; import { Writable } from "stream"; +import detectPackageManager from "which-pm-runs"; const packageJson = createRequire(import.meta.url)("../package.json"); const version = packageJson.version; @@ -43,6 +44,8 @@ interface Opts extends render.RenderOptions { includeEntrypoints?: string[]; excludeEntrypoints?: string[]; entrypointsLegacy?: boolean; + + pm?: string; } program @@ -92,6 +95,11 @@ particularly ESM-related module resolution issues.`, .option("--emoji, --no-emoji", "Whether to use any emojis") .option("--color, --no-color", "Whether to use any colors (the FORCE_COLOR env variable is also available)") .option("--config-path ", "Path to config file (default: ./.attw.json)") + .addOption( + new Option("--pm [package manager]", "Specify the package manager to use for --pack (default: auto)") + .choices(["pnpm", "yarn-classic", "yarn-modern", "npm", "auto"]) + .default("auto"), + ) .action(async (fileOrDirectory = ".") => { const opts = program.opts(); await readConfig(program, opts.configPath); @@ -176,15 +184,35 @@ particularly ESM-related module resolution issues.`, ); } + let packageManager = "npm"; + + switch (opts.pm) { + case "auto": + const pm = detectPackageManager(); + if (pm) { + packageManager = pm.name; + } + break; + case "pnpm": { + packageManager = "pnpm"; + break; + } + case "yarn-modern": + case "yarn-classic": { + packageManager = "yarn"; + break; + } + } + if (!opts.pack) { if (!process.stdout.isTTY) { program.error( - "Specifying a directory requires the --pack option to confirm that running `npm pack` is ok.", + `Specifying a directory requires the --pack option to confirm that running \`${packageManager} pack\` is ok.`, ); } const rl = readline.createInterface(process.stdin, process.stdout); const answer = await new Promise((resolve) => { - rl.question(`Run \`npm pack\`? (Pass -P/--pack to skip) (Y/n) `, resolve); + rl.question(`Run \`${packageManager} pack\`? (Pass -P/--pack to skip) (Y/n) `, resolve); }); rl.close(); if (answer.trim() && !answer.trim().toLowerCase().startsWith("y")) { @@ -198,7 +226,11 @@ particularly ESM-related module resolution issues.`, // https://github.com/npm/cli/blob/f875caa86900122819311dd77cde01c700fd1817/lib/utils/tar.js#L123-L125 `${manifest.name.replace("@", "").replace("/", "-")}-${manifest.version}.tgz`, ); - execSync("npm pack", { cwd: fileOrDirectory, encoding: "utf8", stdio: "ignore" }); + execSync(`${packageManager} pack` + (opts.pm === "yarn-classic" ? ` --filename ` + fileName : opts.pm === "yarn-modern" ? ` --out ` + fileName :""), { + cwd: fileOrDirectory, + encoding: "utf8", + stdio: "ignore", + }); } const file = await readFile(fileName); const data = new Uint8Array(file); diff --git a/packages/cli/test/snapshots.test.ts b/packages/cli/test/snapshots.test.ts index e01816a..e386220 100644 --- a/packages/cli/test/snapshots.test.ts +++ b/packages/cli/test/snapshots.test.ts @@ -60,6 +60,12 @@ const tests = [ ["@fluid-experimental__presence@2.3.0.tgz", "--profile node16 -f table-flipped"], // Profile ignoring node10 and CJS resolution mixed with specific entrypoint - exit code 0 ["@fluid-experimental__presence@2.3.0.tgz", "--profile esm-only -f json --entrypoints ."], + + // package manager test cases + ["axios@1.4.0.tgz", "--pm"], // auto + ["axios@1.4.0.tgz", "--pm npm"], + ["axios@1.4.0.tgz", "--pm pnpm"], + ["axios@1.4.0.tgz", "--pm yarn-classic"], ]; const defaultOpts = "-f table-flipped"; diff --git a/packages/cli/test/snapshots/axios@1.4.0.tgz --pm npm.md b/packages/cli/test/snapshots/axios@1.4.0.tgz --pm npm.md new file mode 100644 index 0000000..42c7b24 --- /dev/null +++ b/packages/cli/test/snapshots/axios@1.4.0.tgz --pm npm.md @@ -0,0 +1,57 @@ +# axios@1.4.0.tgz --pm npm + +``` +$ attw axios@1.4.0.tgz --pm npm + + +axios v1.4.0 + +Build tools: +- typescript@^4.8.4 +- rollup@^2.67.0 + +💀 Import failed to resolve to type declarations or JavaScript files. https://github.com/arethetypeswrong/arethetypeswrong.github.io/blob/main/docs/problems/NoResolution.md + +❌ Import resolved to JavaScript files, but no type declarations were found. https://github.com/arethetypeswrong/arethetypeswrong.github.io/blob/main/docs/problems/UntypedResolution.md + +⚠️ A require call resolved to an ESM JavaScript file, which is an error in Node and some bundlers. CommonJS consumers will need to use a dynamic import. https://github.com/arethetypeswrong/arethetypeswrong.github.io/blob/main/docs/problems/CJSResolvesToESM.md + + +┌─────────────────────────────────────────┬──────────────────────┬──────────────────────────────┬───────────────────┬─────────────┐ +│ │ node10 │ node16 (from CJS) │ node16 (from ESM) │ bundler │ +├─────────────────────────────────────────┼──────────────────────┼──────────────────────────────┼───────────────────┼─────────────┤ +│ "axios" │ 🟢 │ 🟢 (CJS) │ 🟢 (ESM) │ 🟢 │ +├─────────────────────────────────────────┼──────────────────────┼──────────────────────────────┼───────────────────┼─────────────┤ +│ "axios/unsafe/*" │ (wildcard) │ (wildcard) │ (wildcard) │ (wildcard) │ +├─────────────────────────────────────────┼──────────────────────┼──────────────────────────────┼───────────────────┼─────────────┤ +│ "axios/unsafe/core/settle.js" │ 💀 Resolution failed │ ❌ No types │ ❌ No types │ ❌ No types │ +│ │ │ ⚠️ ESM (dynamic import only) │ │ │ +├─────────────────────────────────────────┼──────────────────────┼──────────────────────────────┼───────────────────┼─────────────┤ +│ "axios/unsafe/core/buildFullPath.js" │ 💀 Resolution failed │ ❌ No types │ ❌ No types │ ❌ No types │ +│ │ │ ⚠️ ESM (dynamic import only) │ │ │ +├─────────────────────────────────────────┼──────────────────────┼──────────────────────────────┼───────────────────┼─────────────┤ +│ "axios/unsafe/helpers/isAbsoluteURL.js" │ 💀 Resolution failed │ ❌ No types │ ❌ No types │ ❌ No types │ +│ │ │ ⚠️ ESM (dynamic import only) │ │ │ +├─────────────────────────────────────────┼──────────────────────┼──────────────────────────────┼───────────────────┼─────────────┤ +│ "axios/unsafe/helpers/buildURL.js" │ 💀 Resolution failed │ ❌ No types │ ❌ No types │ ❌ No types │ +│ │ │ ⚠️ ESM (dynamic import only) │ │ │ +├─────────────────────────────────────────┼──────────────────────┼──────────────────────────────┼───────────────────┼─────────────┤ +│ "axios/unsafe/helpers/combineURLs.js" │ 💀 Resolution failed │ ❌ No types │ ❌ No types │ ❌ No types │ +│ │ │ ⚠️ ESM (dynamic import only) │ │ │ +├─────────────────────────────────────────┼──────────────────────┼──────────────────────────────┼───────────────────┼─────────────┤ +│ "axios/unsafe/adapters/http.js" │ 💀 Resolution failed │ ❌ No types │ ❌ No types │ ❌ No types │ +│ │ │ ⚠️ ESM (dynamic import only) │ │ │ +├─────────────────────────────────────────┼──────────────────────┼──────────────────────────────┼───────────────────┼─────────────┤ +│ "axios/unsafe/adapters/xhr.js" │ 💀 Resolution failed │ ❌ No types │ ❌ No types │ ❌ No types │ +│ │ │ ⚠️ ESM (dynamic import only) │ │ │ +├─────────────────────────────────────────┼──────────────────────┼──────────────────────────────┼───────────────────┼─────────────┤ +│ "axios/unsafe/utils.js" │ 💀 Resolution failed │ ❌ No types │ ❌ No types │ ❌ No types │ +│ │ │ ⚠️ ESM (dynamic import only) │ │ │ +├─────────────────────────────────────────┼──────────────────────┼──────────────────────────────┼───────────────────┼─────────────┤ +│ "axios/package.json" │ 🟢 (JSON) │ 🟢 (JSON) │ 🟢 (JSON) │ 🟢 (JSON) │ +└─────────────────────────────────────────┴──────────────────────┴──────────────────────────────┴───────────────────┴─────────────┘ + + +``` + +Exit code: 1 \ No newline at end of file diff --git a/packages/cli/test/snapshots/axios@1.4.0.tgz --pm pnpm.md b/packages/cli/test/snapshots/axios@1.4.0.tgz --pm pnpm.md new file mode 100644 index 0000000..5acc694 --- /dev/null +++ b/packages/cli/test/snapshots/axios@1.4.0.tgz --pm pnpm.md @@ -0,0 +1,57 @@ +# axios@1.4.0.tgz --pm pnpm + +``` +$ attw axios@1.4.0.tgz --pm pnpm + + +axios v1.4.0 + +Build tools: +- typescript@^4.8.4 +- rollup@^2.67.0 + +💀 Import failed to resolve to type declarations or JavaScript files. https://github.com/arethetypeswrong/arethetypeswrong.github.io/blob/main/docs/problems/NoResolution.md + +❌ Import resolved to JavaScript files, but no type declarations were found. https://github.com/arethetypeswrong/arethetypeswrong.github.io/blob/main/docs/problems/UntypedResolution.md + +⚠️ A require call resolved to an ESM JavaScript file, which is an error in Node and some bundlers. CommonJS consumers will need to use a dynamic import. https://github.com/arethetypeswrong/arethetypeswrong.github.io/blob/main/docs/problems/CJSResolvesToESM.md + + +┌─────────────────────────────────────────┬──────────────────────┬──────────────────────────────┬───────────────────┬─────────────┐ +│ │ node10 │ node16 (from CJS) │ node16 (from ESM) │ bundler │ +├─────────────────────────────────────────┼──────────────────────┼──────────────────────────────┼───────────────────┼─────────────┤ +│ "axios" │ 🟢 │ 🟢 (CJS) │ 🟢 (ESM) │ 🟢 │ +├─────────────────────────────────────────┼──────────────────────┼──────────────────────────────┼───────────────────┼─────────────┤ +│ "axios/unsafe/*" │ (wildcard) │ (wildcard) │ (wildcard) │ (wildcard) │ +├─────────────────────────────────────────┼──────────────────────┼──────────────────────────────┼───────────────────┼─────────────┤ +│ "axios/unsafe/core/settle.js" │ 💀 Resolution failed │ ❌ No types │ ❌ No types │ ❌ No types │ +│ │ │ ⚠️ ESM (dynamic import only) │ │ │ +├─────────────────────────────────────────┼──────────────────────┼──────────────────────────────┼───────────────────┼─────────────┤ +│ "axios/unsafe/core/buildFullPath.js" │ 💀 Resolution failed │ ❌ No types │ ❌ No types │ ❌ No types │ +│ │ │ ⚠️ ESM (dynamic import only) │ │ │ +├─────────────────────────────────────────┼──────────────────────┼──────────────────────────────┼───────────────────┼─────────────┤ +│ "axios/unsafe/helpers/isAbsoluteURL.js" │ 💀 Resolution failed │ ❌ No types │ ❌ No types │ ❌ No types │ +│ │ │ ⚠️ ESM (dynamic import only) │ │ │ +├─────────────────────────────────────────┼──────────────────────┼──────────────────────────────┼───────────────────┼─────────────┤ +│ "axios/unsafe/helpers/buildURL.js" │ 💀 Resolution failed │ ❌ No types │ ❌ No types │ ❌ No types │ +│ │ │ ⚠️ ESM (dynamic import only) │ │ │ +├─────────────────────────────────────────┼──────────────────────┼──────────────────────────────┼───────────────────┼─────────────┤ +│ "axios/unsafe/helpers/combineURLs.js" │ 💀 Resolution failed │ ❌ No types │ ❌ No types │ ❌ No types │ +│ │ │ ⚠️ ESM (dynamic import only) │ │ │ +├─────────────────────────────────────────┼──────────────────────┼──────────────────────────────┼───────────────────┼─────────────┤ +│ "axios/unsafe/adapters/http.js" │ 💀 Resolution failed │ ❌ No types │ ❌ No types │ ❌ No types │ +│ │ │ ⚠️ ESM (dynamic import only) │ │ │ +├─────────────────────────────────────────┼──────────────────────┼──────────────────────────────┼───────────────────┼─────────────┤ +│ "axios/unsafe/adapters/xhr.js" │ 💀 Resolution failed │ ❌ No types │ ❌ No types │ ❌ No types │ +│ │ │ ⚠️ ESM (dynamic import only) │ │ │ +├─────────────────────────────────────────┼──────────────────────┼──────────────────────────────┼───────────────────┼─────────────┤ +│ "axios/unsafe/utils.js" │ 💀 Resolution failed │ ❌ No types │ ❌ No types │ ❌ No types │ +│ │ │ ⚠️ ESM (dynamic import only) │ │ │ +├─────────────────────────────────────────┼──────────────────────┼──────────────────────────────┼───────────────────┼─────────────┤ +│ "axios/package.json" │ 🟢 (JSON) │ 🟢 (JSON) │ 🟢 (JSON) │ 🟢 (JSON) │ +└─────────────────────────────────────────┴──────────────────────┴──────────────────────────────┴───────────────────┴─────────────┘ + + +``` + +Exit code: 1 \ No newline at end of file diff --git a/packages/cli/test/snapshots/axios@1.4.0.tgz --pm yarn-classic.md b/packages/cli/test/snapshots/axios@1.4.0.tgz --pm yarn-classic.md new file mode 100644 index 0000000..8950166 --- /dev/null +++ b/packages/cli/test/snapshots/axios@1.4.0.tgz --pm yarn-classic.md @@ -0,0 +1,57 @@ +# axios@1.4.0.tgz --pm yarn-classic + +``` +$ attw axios@1.4.0.tgz --pm yarn-classic + + +axios v1.4.0 + +Build tools: +- typescript@^4.8.4 +- rollup@^2.67.0 + +💀 Import failed to resolve to type declarations or JavaScript files. https://github.com/arethetypeswrong/arethetypeswrong.github.io/blob/main/docs/problems/NoResolution.md + +❌ Import resolved to JavaScript files, but no type declarations were found. https://github.com/arethetypeswrong/arethetypeswrong.github.io/blob/main/docs/problems/UntypedResolution.md + +⚠️ A require call resolved to an ESM JavaScript file, which is an error in Node and some bundlers. CommonJS consumers will need to use a dynamic import. https://github.com/arethetypeswrong/arethetypeswrong.github.io/blob/main/docs/problems/CJSResolvesToESM.md + + +┌─────────────────────────────────────────┬──────────────────────┬──────────────────────────────┬───────────────────┬─────────────┐ +│ │ node10 │ node16 (from CJS) │ node16 (from ESM) │ bundler │ +├─────────────────────────────────────────┼──────────────────────┼──────────────────────────────┼───────────────────┼─────────────┤ +│ "axios" │ 🟢 │ 🟢 (CJS) │ 🟢 (ESM) │ 🟢 │ +├─────────────────────────────────────────┼──────────────────────┼──────────────────────────────┼───────────────────┼─────────────┤ +│ "axios/unsafe/*" │ (wildcard) │ (wildcard) │ (wildcard) │ (wildcard) │ +├─────────────────────────────────────────┼──────────────────────┼──────────────────────────────┼───────────────────┼─────────────┤ +│ "axios/unsafe/core/settle.js" │ 💀 Resolution failed │ ❌ No types │ ❌ No types │ ❌ No types │ +│ │ │ ⚠️ ESM (dynamic import only) │ │ │ +├─────────────────────────────────────────┼──────────────────────┼──────────────────────────────┼───────────────────┼─────────────┤ +│ "axios/unsafe/core/buildFullPath.js" │ 💀 Resolution failed │ ❌ No types │ ❌ No types │ ❌ No types │ +│ │ │ ⚠️ ESM (dynamic import only) │ │ │ +├─────────────────────────────────────────┼──────────────────────┼──────────────────────────────┼───────────────────┼─────────────┤ +│ "axios/unsafe/helpers/isAbsoluteURL.js" │ 💀 Resolution failed │ ❌ No types │ ❌ No types │ ❌ No types │ +│ │ │ ⚠️ ESM (dynamic import only) │ │ │ +├─────────────────────────────────────────┼──────────────────────┼──────────────────────────────┼───────────────────┼─────────────┤ +│ "axios/unsafe/helpers/buildURL.js" │ 💀 Resolution failed │ ❌ No types │ ❌ No types │ ❌ No types │ +│ │ │ ⚠️ ESM (dynamic import only) │ │ │ +├─────────────────────────────────────────┼──────────────────────┼──────────────────────────────┼───────────────────┼─────────────┤ +│ "axios/unsafe/helpers/combineURLs.js" │ 💀 Resolution failed │ ❌ No types │ ❌ No types │ ❌ No types │ +│ │ │ ⚠️ ESM (dynamic import only) │ │ │ +├─────────────────────────────────────────┼──────────────────────┼──────────────────────────────┼───────────────────┼─────────────┤ +│ "axios/unsafe/adapters/http.js" │ 💀 Resolution failed │ ❌ No types │ ❌ No types │ ❌ No types │ +│ │ │ ⚠️ ESM (dynamic import only) │ │ │ +├─────────────────────────────────────────┼──────────────────────┼──────────────────────────────┼───────────────────┼─────────────┤ +│ "axios/unsafe/adapters/xhr.js" │ 💀 Resolution failed │ ❌ No types │ ❌ No types │ ❌ No types │ +│ │ │ ⚠️ ESM (dynamic import only) │ │ │ +├─────────────────────────────────────────┼──────────────────────┼──────────────────────────────┼───────────────────┼─────────────┤ +│ "axios/unsafe/utils.js" │ 💀 Resolution failed │ ❌ No types │ ❌ No types │ ❌ No types │ +│ │ │ ⚠️ ESM (dynamic import only) │ │ │ +├─────────────────────────────────────────┼──────────────────────┼──────────────────────────────┼───────────────────┼─────────────┤ +│ "axios/package.json" │ 🟢 (JSON) │ 🟢 (JSON) │ 🟢 (JSON) │ 🟢 (JSON) │ +└─────────────────────────────────────────┴──────────────────────┴──────────────────────────────┴───────────────────┴─────────────┘ + + +``` + +Exit code: 1 \ No newline at end of file diff --git a/packages/cli/test/snapshots/axios@1.4.0.tgz --pm.md b/packages/cli/test/snapshots/axios@1.4.0.tgz --pm.md new file mode 100644 index 0000000..8731780 --- /dev/null +++ b/packages/cli/test/snapshots/axios@1.4.0.tgz --pm.md @@ -0,0 +1,57 @@ +# axios@1.4.0.tgz --pm + +``` +$ attw axios@1.4.0.tgz --pm + + +axios v1.4.0 + +Build tools: +- typescript@^4.8.4 +- rollup@^2.67.0 + +💀 Import failed to resolve to type declarations or JavaScript files. https://github.com/arethetypeswrong/arethetypeswrong.github.io/blob/main/docs/problems/NoResolution.md + +❌ Import resolved to JavaScript files, but no type declarations were found. https://github.com/arethetypeswrong/arethetypeswrong.github.io/blob/main/docs/problems/UntypedResolution.md + +⚠️ A require call resolved to an ESM JavaScript file, which is an error in Node and some bundlers. CommonJS consumers will need to use a dynamic import. https://github.com/arethetypeswrong/arethetypeswrong.github.io/blob/main/docs/problems/CJSResolvesToESM.md + + +┌─────────────────────────────────────────┬──────────────────────┬──────────────────────────────┬───────────────────┬─────────────┐ +│ │ node10 │ node16 (from CJS) │ node16 (from ESM) │ bundler │ +├─────────────────────────────────────────┼──────────────────────┼──────────────────────────────┼───────────────────┼─────────────┤ +│ "axios" │ 🟢 │ 🟢 (CJS) │ 🟢 (ESM) │ 🟢 │ +├─────────────────────────────────────────┼──────────────────────┼──────────────────────────────┼───────────────────┼─────────────┤ +│ "axios/unsafe/*" │ (wildcard) │ (wildcard) │ (wildcard) │ (wildcard) │ +├─────────────────────────────────────────┼──────────────────────┼──────────────────────────────┼───────────────────┼─────────────┤ +│ "axios/unsafe/core/settle.js" │ 💀 Resolution failed │ ❌ No types │ ❌ No types │ ❌ No types │ +│ │ │ ⚠️ ESM (dynamic import only) │ │ │ +├─────────────────────────────────────────┼──────────────────────┼──────────────────────────────┼───────────────────┼─────────────┤ +│ "axios/unsafe/core/buildFullPath.js" │ 💀 Resolution failed │ ❌ No types │ ❌ No types │ ❌ No types │ +│ │ │ ⚠️ ESM (dynamic import only) │ │ │ +├─────────────────────────────────────────┼──────────────────────┼──────────────────────────────┼───────────────────┼─────────────┤ +│ "axios/unsafe/helpers/isAbsoluteURL.js" │ 💀 Resolution failed │ ❌ No types │ ❌ No types │ ❌ No types │ +│ │ │ ⚠️ ESM (dynamic import only) │ │ │ +├─────────────────────────────────────────┼──────────────────────┼──────────────────────────────┼───────────────────┼─────────────┤ +│ "axios/unsafe/helpers/buildURL.js" │ 💀 Resolution failed │ ❌ No types │ ❌ No types │ ❌ No types │ +│ │ │ ⚠️ ESM (dynamic import only) │ │ │ +├─────────────────────────────────────────┼──────────────────────┼──────────────────────────────┼───────────────────┼─────────────┤ +│ "axios/unsafe/helpers/combineURLs.js" │ 💀 Resolution failed │ ❌ No types │ ❌ No types │ ❌ No types │ +│ │ │ ⚠️ ESM (dynamic import only) │ │ │ +├─────────────────────────────────────────┼──────────────────────┼──────────────────────────────┼───────────────────┼─────────────┤ +│ "axios/unsafe/adapters/http.js" │ 💀 Resolution failed │ ❌ No types │ ❌ No types │ ❌ No types │ +│ │ │ ⚠️ ESM (dynamic import only) │ │ │ +├─────────────────────────────────────────┼──────────────────────┼──────────────────────────────┼───────────────────┼─────────────┤ +│ "axios/unsafe/adapters/xhr.js" │ 💀 Resolution failed │ ❌ No types │ ❌ No types │ ❌ No types │ +│ │ │ ⚠️ ESM (dynamic import only) │ │ │ +├─────────────────────────────────────────┼──────────────────────┼──────────────────────────────┼───────────────────┼─────────────┤ +│ "axios/unsafe/utils.js" │ 💀 Resolution failed │ ❌ No types │ ❌ No types │ ❌ No types │ +│ │ │ ⚠️ ESM (dynamic import only) │ │ │ +├─────────────────────────────────────────┼──────────────────────┼──────────────────────────────┼───────────────────┼─────────────┤ +│ "axios/package.json" │ 🟢 (JSON) │ 🟢 (JSON) │ 🟢 (JSON) │ 🟢 (JSON) │ +└─────────────────────────────────────────┴──────────────────────┴──────────────────────────────┴───────────────────┴─────────────┘ + + +``` + +Exit code: 1 \ No newline at end of file diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 3a30830..cae3033 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -49,6 +49,9 @@ importers: semver: specifier: ^7.5.4 version: 7.5.4 + which-pm-runs: + specifier: ^1.1.0 + version: 1.1.0 devDependencies: '@types/marked': specifier: ^5.0.0 @@ -62,6 +65,9 @@ importers: '@types/semver': specifier: ^7.5.3 version: 7.5.3 + '@types/which-pm-runs': + specifier: ^1.0.2 + version: 1.0.2 ts-expose-internals: specifier: 5.6.1-rc version: 5.6.1-rc @@ -683,6 +689,9 @@ packages: '@types/validate-npm-package-name@4.0.0': resolution: {integrity: sha512-RpO62vB2lkjEkyLbwTheA2+uwYmtVMWTr/kWRI++UAgVdZqNqdAuIQl/SxBCGeMKfdjWaXPbyhZbiCc4PAj+KA==} + '@types/which-pm-runs@1.0.2': + resolution: {integrity: sha512-M0ZefeDApctHbjqtATOiixiwafG7pXD3exxnjku4XmX9+2DmONGghv5Z8Pnm0lNLBZKvDQyuG+4pLkH2UkP5gg==} + abbrev@1.1.1: resolution: {integrity: sha512-nne9/IiQ/hzIhY6pdDnbBtz7DjPTKrY00P/zvPSm5pOFkl6xuGrGnXn/VtTNNfNtAfZ9/1RtehkszU9qcTii0Q==} @@ -1805,6 +1814,10 @@ packages: whatwg-url@5.0.0: resolution: {integrity: sha512-saE57nupxk6v3HY35+jzBwYa0rKSy0XR8JSxZPwgLr7ys0IBzhGviA1/TUGJLmSVqs8pb9AnvICXEuOHLprYTw==} + which-pm-runs@1.1.0: + resolution: {integrity: sha512-n1brCuqClxfFfq/Rb0ICg9giSZqCS+pLtccdag6C2HyufBrh3fBOiy9nb6ggRMvWOVH5GrdJskj5iGTZNxd7SA==} + engines: {node: '>=4'} + which@1.3.1: resolution: {integrity: sha512-HxJdYWq1MTIQbJ3nw0cqssHoTNU267KlrDuGZ1WYlxDStUtKUhOaJmh112/TZmHxxUfuJqPXSOm7tDyas0OSIQ==} hasBin: true @@ -2382,6 +2395,8 @@ snapshots: '@types/validate-npm-package-name@4.0.0': {} + '@types/which-pm-runs@1.0.2': {} + abbrev@1.1.1: {} agent-base@6.0.2: @@ -3510,6 +3525,8 @@ snapshots: tr46: 0.0.3 webidl-conversions: 3.0.1 + which-pm-runs@1.1.0: {} + which@1.3.1: dependencies: isexe: 2.0.0 From 3ead827cbf12c2deceebec43a81179263a77cd20 Mon Sep 17 00:00:00 2001 From: prisis Date: Fri, 17 Jan 2025 23:10:39 +0100 Subject: [PATCH 2/3] chore: add changeset --- .changeset/green-waves-beam.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/green-waves-beam.md diff --git a/.changeset/green-waves-beam.md b/.changeset/green-waves-beam.md new file mode 100644 index 0000000..3c578fe --- /dev/null +++ b/.changeset/green-waves-beam.md @@ -0,0 +1,5 @@ +--- +"@arethetypeswrong/cli": minor +--- + +Add support for multiple package managers like [pnpm](https://pnpm.io/) and [yarn](https://yarnpkg.com/) From c2209d17a266facc702eee1c015b87a86f61aa8c Mon Sep 17 00:00:00 2001 From: prisis Date: Fri, 17 Jan 2025 23:17:08 +0100 Subject: [PATCH 3/3] fix: check on auto mode for the yarn version --- packages/cli/src/index.ts | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/packages/cli/src/index.ts b/packages/cli/src/index.ts index 0abe007..6e6bb36 100644 --- a/packages/cli/src/index.ts +++ b/packages/cli/src/index.ts @@ -191,6 +191,11 @@ particularly ESM-related module resolution issues.`, const pm = detectPackageManager(); if (pm) { packageManager = pm.name; + + if (pm.name === "yarn") { + const yarnVersion = pm.version.split(".")[0]; + opts.pm = yarnVersion === "1" ? "yarn-classic" : "yarn-modern"; + } } break; case "pnpm": {