|
| 1 | +[[case]] |
| 2 | +name = "npm_lockfile_uses_bundled_version" |
| 3 | +vp = "global" |
| 4 | +steps = [ |
| 5 | + { argv = ["node", "assert-npm.cjs"], comment = "A Node-only devEngines declaration and npm lockfile use bundled npm without querying the registry", envs = [["NPM_CONFIG_REGISTRY", "http://127.0.0.1:9"]] }, |
| 6 | + { argv = ["vp", "pm", "patch", "example"], comment = "Bundled npm retains its version gates for unsupported commands" }, |
| 7 | + { argv = ["vp", "pm", "approve-builds"], comment = "Bundled npm does not invoke approval commands added in later npm releases" }, |
| 8 | + { argv = ["vp", "env", "default", "npm@10.5.0"], snapshot = false }, |
| 9 | + { argv = ["node", "assert-npm.cjs", "10.5.0"], comment = "An npm default overrides the bundled version even when a lockfile exists" }, |
| 10 | + { argv = ["vpt", "json-edit", "package.json", "devEngines.packageManager", "{\"name\":\"npm\",\"version\":\"10.9.4\"}"], snapshot = false }, |
| 11 | + { argv = ["node", "assert-npm.cjs", "10.9.4"], comment = "A devEngines npm version overrides the default" }, |
| 12 | + { argv = ["vpt", "json-edit", "package.json", "packageManager", "npm@10.8.2"], snapshot = false }, |
| 13 | + { argv = ["node", "assert-npm.cjs", "10.8.2"], comment = "A top-level npm pin still has priority" }, |
| 14 | +] |
| 15 | + |
| 16 | +[[case]] |
| 17 | +name = "npm_current_does_not_install_node" |
| 18 | +vp = "global" |
| 19 | +seed-runtime = false |
| 20 | +env = { VP_NODE_VERSION = "22.18.0", VP_NODE_DIST_MIRROR = "http://127.0.0.1:9" } |
| 21 | +steps = [ |
| 22 | + { argv = ["vp", "env", "current", "--json"], comment = "An absent Node runtime and bundled npm are reported without downloading" }, |
| 23 | + { argv = ["vp", "env", "current", "npm", "--json"], comment = "The explicit npm scope also reports an unknown, uninstalled version" }, |
| 24 | + { argv = ["vpt", "stat-file", "$VP_HOME/js_runtime/node/22.18.0", "--assert", "missing"], comment = "Reporting the environment leaves the runtime uninstalled" }, |
| 25 | +] |
| 26 | + |
| 27 | +[[case]] |
| 28 | +name = "npm_bundled_ignores_project_bin" |
| 29 | +vp = "global" |
| 30 | +skip-platforms = ["windows"] |
| 31 | +steps = [ |
| 32 | + { argv = ["vpt", "write-file", "bin/npm", "#!/bin/sh\necho project npm must not run\nexit 1\n"], snapshot = false }, |
| 33 | + { argv = ["vpt", "chmod", "+x", "bin/npm"], snapshot = false }, |
| 34 | + { argv = ["node", "assert-npm.cjs"], comment = "The version probe and actual command both use bundled npm despite an executable project bin/npm" }, |
| 35 | +] |
| 36 | + |
| 37 | +[[case]] |
| 38 | +name = "npm_bundled_env_print" |
| 39 | +vp = "global" |
| 40 | +env = { VP_SHELL = "bash", NPM_CONFIG_REGISTRY = "http://127.0.0.1:9" } |
| 41 | +steps = [ |
| 42 | + { argv = ["vp", "env", "print", "pm"], comment = "The selected package manager uses Node's bundled npm directory" }, |
| 43 | + { argv = ["vp", "env", "print", "npm"], comment = "The explicit npm scope uses the same bundled directory" }, |
| 44 | + { argv = ["vp", "env", "print"], comment = "The combined scope includes the shared directory only once" }, |
| 45 | +] |
| 46 | + |
| 47 | +[[case]] |
| 48 | +name = "npm_bundled_version_probe_ignores_preloads" |
| 49 | +vp = "global" |
| 50 | +env = { NODE_OPTIONS = "--require ./preload.cjs" } |
| 51 | +steps = [ |
| 52 | + { argv = ["vpt", "write-file", "preload.cjs", "console.log('preload start');\n"], snapshot = false }, |
| 53 | + { argv = ["vp", "pm", "patch", "example"], comment = "A noisy preload cannot bypass npm's patch version gate" }, |
| 54 | + { argv = ["vp", "pm", "approve-builds"], comment = "A noisy preload cannot bypass npm's approval version gate" }, |
| 55 | + { argv = ["vp", "pm", "version", "--json"], comment = "The actual npm command still executes the user's preload" }, |
| 56 | +] |
0 commit comments