run402 3.8.1 → 3.8.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/update-check.mjs +22 -8
- package/lib/update-check.test.mjs +22 -0
- package/package.json +1 -1
package/lib/update-check.mjs
CHANGED
|
@@ -393,8 +393,19 @@ export function detectInstallContext({
|
|
|
393
393
|
const executableUnderProject = projectRoot ? isPathInside(executable, projectRoot) : false;
|
|
394
394
|
const localNodeModules = executableUnderProject &&
|
|
395
395
|
(containsPathSegment(executable, "node_modules") || command === "yarn_pnp");
|
|
396
|
-
|
|
397
|
-
|
|
396
|
+
const packageManagerShim = isPackageManagerShim(executable);
|
|
397
|
+
const globalRun402Path = looksLikeGlobalRun402Path(executable, env, platform);
|
|
398
|
+
const explicitNpxCachePath = containsPathSegment(executable, "_npx");
|
|
399
|
+
const packageExecUsesDeclaredRun402 = run402Declared &&
|
|
400
|
+
!globalRun402Path &&
|
|
401
|
+
!explicitNpxCachePath &&
|
|
402
|
+
(localNodeModules ||
|
|
403
|
+
packageManagerShim ||
|
|
404
|
+
command === "npm_exec" ||
|
|
405
|
+
command === "yarn_pnp" ||
|
|
406
|
+
command === "direct");
|
|
407
|
+
|
|
408
|
+
if (!packageExecUsesDeclaredRun402 && (command === "npx" || command === "npm_exec" || command === "bunx")) {
|
|
398
409
|
return {
|
|
399
410
|
kind: "ephemeral_exec",
|
|
400
411
|
confidence: command === "npx" || command === "bunx" ? "high" : "medium",
|
|
@@ -405,22 +416,25 @@ export function detectInstallContext({
|
|
|
405
416
|
};
|
|
406
417
|
}
|
|
407
418
|
|
|
408
|
-
if (
|
|
419
|
+
if (packageExecUsesDeclaredRun402) {
|
|
409
420
|
return {
|
|
410
421
|
kind: "local_project",
|
|
411
|
-
confidence:
|
|
422
|
+
confidence: localNodeModules || packageManagerShim ? "high" : "medium",
|
|
412
423
|
package_manager: packageManager.name,
|
|
413
424
|
cwd: packageInfo?.dir ?? resolvedCwd,
|
|
414
425
|
package_root: packageInfo?.dir ?? nearestPackageInfo?.dir ?? null,
|
|
415
426
|
reasons: [
|
|
416
|
-
localNodeModules ? "project_node_modules" :
|
|
417
|
-
...(
|
|
427
|
+
...(localNodeModules ? ["project_node_modules"] : []),
|
|
428
|
+
...(packageManagerShim ? ["package_manager_shim"] : []),
|
|
429
|
+
...(command === "npm_exec" ? ["package_manager_exec"] : []),
|
|
430
|
+
...(command === "yarn_pnp" ? ["yarn_pnp"] : []),
|
|
431
|
+
"package_declares_run402",
|
|
418
432
|
...(workspacePackageInfo && workspacePackageInfo !== nearestPackageInfo ? ["workspace_root"] : []),
|
|
419
433
|
],
|
|
420
434
|
};
|
|
421
435
|
}
|
|
422
436
|
|
|
423
|
-
if (
|
|
437
|
+
if (globalRun402Path) {
|
|
424
438
|
return {
|
|
425
439
|
kind: "global_npm",
|
|
426
440
|
confidence: "high",
|
|
@@ -442,7 +456,7 @@ export function detectInstallContext({
|
|
|
442
456
|
};
|
|
443
457
|
}
|
|
444
458
|
|
|
445
|
-
if (
|
|
459
|
+
if (packageManagerShim) {
|
|
446
460
|
return {
|
|
447
461
|
kind: "package_manager_shim",
|
|
448
462
|
confidence: "low",
|
|
@@ -222,6 +222,28 @@ describe("CLI install-context detection", () => {
|
|
|
222
222
|
assert.equal(action.mutates_project, true);
|
|
223
223
|
}));
|
|
224
224
|
|
|
225
|
+
it("treats package-declared shims and pnpm exec as local project installs", () => withTemp((dir) => {
|
|
226
|
+
packageJson(dir, { packageManager: "npm@11.0.0", devDependencies: { run402: "3.7.14" } });
|
|
227
|
+
let install = detectInstallContext({
|
|
228
|
+
cwd: dir,
|
|
229
|
+
execPath: "node_modules/.bin/run402",
|
|
230
|
+
env: {},
|
|
231
|
+
});
|
|
232
|
+
assert.equal(install.kind, "local_project");
|
|
233
|
+
assert.equal(install.package_manager, "npm");
|
|
234
|
+
assert.deepEqual(upgradeNextActions({ install })[0].argv, ["npm", "install", "-D", "run402@latest"]);
|
|
235
|
+
|
|
236
|
+
packageJson(dir, { packageManager: "pnpm@10.0.0", devDependencies: { run402: "3.7.14" } });
|
|
237
|
+
install = detectInstallContext({
|
|
238
|
+
cwd: dir,
|
|
239
|
+
execPath: "/opt/pnpm/run402",
|
|
240
|
+
env: { npm_command: "exec", npm_config_user_agent: "pnpm/10.0.0 npm/? node/v22" },
|
|
241
|
+
});
|
|
242
|
+
assert.equal(install.kind, "local_project");
|
|
243
|
+
assert.equal(install.package_manager, "pnpm");
|
|
244
|
+
assert.deepEqual(upgradeNextActions({ install })[0].argv, ["pnpm", "add", "-D", "run402@latest"]);
|
|
245
|
+
}));
|
|
246
|
+
|
|
225
247
|
it("uses packageManager over conflicting lockfiles and gives custom paths low-confidence doctor guidance", () => withTemp((dir) => {
|
|
226
248
|
packageJson(dir, { packageManager: "pnpm@10.0.0" });
|
|
227
249
|
writeFileSync(join(dir, "package-lock.json"), "{}");
|
package/package.json
CHANGED