Skip to content

Commit f20056a

Browse files
authored
Merge pull request #180 from arethetypeswrong/revert-177-feature/support-multiple-package-managers
Revert "Feature: support multiple package managers"
2 parents 88acb3c + 373fad4 commit f20056a

File tree

4 files changed

+2156
-2718
lines changed

4 files changed

+2156
-2718
lines changed

packages/cli/package.json

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,6 @@
4949
"@types/marked-terminal": "^3.1.3",
5050
"@types/node": "^20.2.5",
5151
"@types/semver": "^7.5.3",
52-
"@types/which-pm-runs": "^1.0.2",
5352
"ts-expose-internals-conditionally": "1.0.0-empty.0",
5453
"typescript": "5.3.3"
5554
},
@@ -60,8 +59,7 @@
6059
"commander": "^10.0.1",
6160
"marked": "^9.1.2",
6261
"marked-terminal": "^6.0.0",
63-
"semver": "^7.5.4",
64-
"which-pm-runs": "^1.1.0"
62+
"semver": "^7.5.4"
6563
},
6664
"engines": {
6765
"node": ">=18"

packages/cli/src/index.ts

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,6 @@ import { readConfig } from "./readConfig.js";
1515
import * as render from "./render/index.js";
1616
import { major, minor } from "semver";
1717
import { getExitCode } from "./getExitCode.js";
18-
import { determinePackCommand, determineTarballFilename } from "./utils.js";
19-
import detectPackageManager from "which-pm-runs";
2018

2119
const packageJson = createRequire(import.meta.url)("../package.json");
2220
const version = packageJson.version;
@@ -76,8 +74,8 @@ particularly ESM-related module resolution issues.`,
7674
.option("--exclude-entrypoints <entrypoints...>", "Specify entrypoints to exclude from checking.")
7775
.option(
7876
"--entrypoints-legacy",
79-
"In packages without the `exports` field, every file is an entry point. Specifying this option " +
80-
"only takes effect when no entrypoints are automatically detected, or explicitly provided with other options.",
77+
'In packages without the `exports` field, every file is an entry point. Specifying this option ' +
78+
'only takes effect when no entrypoints are automatically detected, or explicitly provided with other options.'
8179
)
8280
.addOption(
8381
new Option("--ignore-rules <rules...>", "Specify rules to ignore").choices(Object.values(problemFlags)).default([]),
@@ -161,30 +159,29 @@ particularly ESM-related module resolution issues.`,
161159
);
162160
}
163161

164-
const packageManager = (await detectPackageManager()?.name) ?? "npm";
165-
const packCommand = determinePackCommand(packageManager);
166-
167162
if (!opts.pack) {
168163
if (!process.stdout.isTTY) {
169164
program.error(
170-
`Specifying a directory requires the --pack option to confirm that running \`${packCommand}\` is ok.`,
165+
"Specifying a directory requires the --pack option to confirm that running `npm pack` is ok.",
171166
);
172167
}
173168
const rl = readline.createInterface(process.stdin, process.stdout);
174169
const answer = await new Promise<string>((resolve) => {
175-
rl.question(`Run \`${packCommand}\`? (Pass -P/--pack to skip) (Y/n) `, resolve);
170+
rl.question(`Run \`npm pack\`? (Pass -P/--pack to skip) (Y/n) `, resolve);
176171
});
177172
rl.close();
178173
if (answer.trim() && !answer.trim().toLowerCase().startsWith("y")) {
179174
process.exit(1);
180175
}
181176
}
182177

183-
fileName = deleteTgz = await determineTarballFilename(fileOrDirectory);
184-
185-
const packCommandWithFilename = determinePackCommand(packageManager, fileName);
186-
187-
execSync(packCommandWithFilename, { cwd: fileOrDirectory, encoding: "utf8", stdio: "ignore" });
178+
const manifest = JSON.parse(await readFile(path.join(fileOrDirectory, "package.json"), { encoding: "utf8" }));
179+
fileName = deleteTgz = path.join(
180+
fileOrDirectory,
181+
// https://github.com/npm/cli/blob/f875caa86900122819311dd77cde01c700fd1817/lib/utils/tar.js#L123-L125
182+
`${manifest.name.replace("@", "").replace("/", "-")}-${manifest.version}.tgz`,
183+
);
184+
execSync("npm pack", { cwd: fileOrDirectory, encoding: "utf8", stdio: "ignore" });
188185
}
189186
const file = await readFile(fileName);
190187
const data = new Uint8Array(file);

packages/cli/src/utils.ts

Lines changed: 0 additions & 26 deletions
This file was deleted.

0 commit comments

Comments
 (0)