@@ -11,3 +11,117 @@ steps = [
1111 { argv = [" vpt" , " stat-file" , " $VP_HOME/bin/npm-global-prefix-cli" ], comment = " Should be gone" , continue-on-failure = true },
1212 { argv = [" vpt" , " rm" , " -rf" , " custom-prefix" ], comment = " Cleanup" , continue-on-failure = true },
1313]
14+
15+ [[case ]]
16+ name = " npm_global_uninstall_dry_run"
17+ vp = " global"
18+ skip-platforms = [" windows" ]
19+ steps = [
20+ { tty = false , argv = [" npm" , " install" , " -g" , " --prefix" , " ./custom-prefix" , " ./npm-global-prefix-pkg" ], comment = " Install a local package and create its Vite+ link" },
21+ { tty = false , argv = [" npm" , " uninstall" , " -g" , " --prefix" , " ./custom-prefix" , " npm-global-prefix-pkg" , " --dry-run" ], comment = " CLI dry-run must preserve the package, npm binary, link, and BinConfig" },
22+ [" vpt" , " stat-file" , " custom-prefix/lib/node_modules/npm-global-prefix-pkg/package.json" , " --assert" , " file" ],
23+ [" vpt" , " stat-file" , " custom-prefix/bin/npm-global-prefix-cli" , " --assert" , " symlink" ],
24+ [" vpt" , " stat-file" , " $VP_HOME/bin/npm-global-prefix-cli" , " --assert" , " symlink" ],
25+ [" vpt" , " stat-file" , " $VP_HOME/bins/npm-global-prefix-cli.json" , " --assert" , " file" ],
26+ [" npm-global-prefix-cli" ],
27+ { tty = false , argv = [" npm" , " uninstall" , " -g" , " --prefix" , " ./custom-prefix" , " npm-global-prefix-pkg" ], envs = [[" npm_config_dry_run" , " true" ]], comment = " Environment-configured dry-run must also preserve installed state" },
28+ [" vpt" , " stat-file" , " custom-prefix/lib/node_modules/npm-global-prefix-pkg/package.json" , " --assert" , " file" ],
29+ [" vpt" , " stat-file" , " custom-prefix/bin/npm-global-prefix-cli" , " --assert" , " symlink" ],
30+ [" vpt" , " stat-file" , " $VP_HOME/bin/npm-global-prefix-cli" , " --assert" , " symlink" ],
31+ [" vpt" , " stat-file" , " $VP_HOME/bins/npm-global-prefix-cli.json" , " --assert" , " file" ],
32+ [" npm-global-prefix-cli" ],
33+ [" vpt" , " write-file" , " dry-run.npmrc" , " dry-run=true\n " ],
34+ { tty = false , argv = [" npm" , " uninstall" , " -g" , " --prefix" , " ./custom-prefix" , " npm-global-prefix-pkg" ], envs = [[" npm_config_userconfig" , " ${workspace}/dry-run.npmrc" ]], comment = " User npmrc dry-run must also preserve installed state" },
35+ [" vpt" , " stat-file" , " custom-prefix/lib/node_modules/npm-global-prefix-pkg/package.json" , " --assert" , " file" ],
36+ [" vpt" , " stat-file" , " custom-prefix/bin/npm-global-prefix-cli" , " --assert" , " symlink" ],
37+ [" vpt" , " stat-file" , " $VP_HOME/bin/npm-global-prefix-cli" , " --assert" , " symlink" ],
38+ [" vpt" , " stat-file" , " $VP_HOME/bins/npm-global-prefix-cli.json" , " --assert" , " file" ],
39+ [" npm-global-prefix-cli" ],
40+ { tty = false , argv = [" npm" , " uninstall" , " -g" , " --prefix" , " ./custom-prefix" , " npm-global-prefix-pkg" ], comment = " A real uninstall must still clean up the package, npm binary, link, and BinConfig" },
41+ [" vpt" , " stat-file" , " custom-prefix/lib/node_modules/npm-global-prefix-pkg" , " --assert" , " missing" ],
42+ [" vpt" , " stat-file" , " custom-prefix/bin/npm-global-prefix-cli" , " --assert" , " missing" ],
43+ [" vpt" , " stat-file" , " $VP_HOME/bin/npm-global-prefix-cli" , " --assert" , " missing" ],
44+ [" vpt" , " stat-file" , " $VP_HOME/bins/npm-global-prefix-cli.json" , " --assert" , " missing" ],
45+ ]
46+
47+ [[case ]]
48+ name = " npm_global_uninstall_preserves_local_copy"
49+ vp = " global"
50+ skip-platforms = [" windows" ]
51+ steps = [
52+ [" vpt" , " mkdir" , " -p" , " custom-prefix" ],
53+ [" vpt" , " write-file" , " custom-prefix/package.json" , " {\" private\" :true}" ],
54+ { tty = false , argv = [" npm" , " install" , " --prefix" , " ./custom-prefix" , " --ignore-scripts" , " --no-save" , " --no-package-lock" , " --no-audit" , " ./npm-global-prefix-pkg" ], comment = " Install a local copy under the same prefix" },
55+ { tty = false , argv = [" npm" , " install" , " -g" , " --prefix" , " ./custom-prefix" , " ./npm-global-prefix-pkg" ], comment = " Install a separate global copy and create its Vite+ link" },
56+ [" vpt" , " stat-file" , " custom-prefix/node_modules/npm-global-prefix-pkg/package.json" , " --assert" , " file" ],
57+ [" vpt" , " stat-file" , " custom-prefix/lib/node_modules/npm-global-prefix-pkg/package.json" , " --assert" , " file" ],
58+ [" vpt" , " stat-file" , " $VP_HOME/bin/npm-global-prefix-cli" , " --assert" , " symlink" ],
59+ [" vpt" , " stat-file" , " $VP_HOME/bins/npm-global-prefix-cli.json" , " --assert" , " file" ],
60+ { tty = false , argv = [" npm" , " uninstall" , " -g" , " --prefix" , " ./custom-prefix" , " npm-global-prefix-pkg" , " --dry-run" ], comment = " Dry-run must preserve the global command even when a local copy also exists" },
61+ [" npm-global-prefix-cli" ],
62+ [" vpt" , " stat-file" , " $VP_HOME/bins/npm-global-prefix-cli.json" , " --assert" , " file" ],
63+ { tty = false , argv = [" npm" , " uninstall" , " -g" , " --prefix" , " ./custom-prefix" , " npm-global-prefix-pkg" ], comment = " Real uninstall must remove the global links without confusing the remaining local copy for the global installation" },
64+ [" vpt" , " stat-file" , " custom-prefix/lib/node_modules/npm-global-prefix-pkg" , " --assert" , " missing" ],
65+ [" vpt" , " stat-file" , " custom-prefix/bin/npm-global-prefix-cli" , " --assert" , " missing" ],
66+ [" vpt" , " stat-file" , " $VP_HOME/bin/npm-global-prefix-cli" , " --assert" , " missing" ],
67+ [" vpt" , " stat-file" , " $VP_HOME/bins/npm-global-prefix-cli.json" , " --assert" , " missing" ],
68+ [" vpt" , " stat-file" , " custom-prefix/node_modules/npm-global-prefix-pkg/package.json" , " --assert" , " file" ],
69+ [" node" , " custom-prefix/node_modules/npm-global-prefix-pkg/cli.js" ],
70+ ]
71+
72+ [[case ]]
73+ name = " npm_global_uninstall_userconfig_fallback"
74+ vp = " global"
75+ skip-platforms = [" windows" ]
76+ # Require the seeded runtime instead of downloading one for this case.
77+ env = { VP_NODE_DIST_MIRROR = " http://127.0.0.1:9" }
78+ unset-env = [" NPM_CONFIG_PREFIX" ]
79+ steps = [
80+ [" node" , " private-runtime.mjs" ],
81+ { tty = false , argv = [" npm" , " install" , " -g" , " ./npm-global-prefix-pkg" ], comment = " Install into a private copy of the selected Node runtime" },
82+ [" vpt" , " stat-file" , " node-prefix/lib/node_modules/npm-global-prefix-pkg/package.json" , " --assert" , " file" ],
83+ [" vpt" , " stat-file" , " $VP_HOME/bin/npm-global-prefix-cli" , " --assert" , " symlink" ],
84+ [" vpt" , " stat-file" , " $VP_HOME/bins/npm-global-prefix-cli.json" , " --assert" , " file" ],
85+ { tty = false , argv = [" npm" , " config" , " set" , " prefix" , " ./other-prefix" , " --location=user" ], comment = " Make the normal user config point to another prefix" },
86+ [" vpt" , " write-file" , " empty.npmrc" , " " ],
87+ { tty = false , argv = [" npm" , " uninstall" , " -g" , " --userconfig=empty.npmrc" , " npm-global-prefix-pkg" , " --dry-run" ], comment = " A config override dry-run must preserve the fallback installation" },
88+ [" npm-global-prefix-cli" ],
89+ [" vpt" , " stat-file" , " $VP_HOME/bins/npm-global-prefix-cli.json" , " --assert" , " file" ],
90+ { tty = false , argv = [" npm" , " uninstall" , " -g" , " npm-global-prefix-pkg" ], comment = " Uninstalling from an empty prefix must not remove links to the surviving fallback package" },
91+ [" npm-global-prefix-cli" ],
92+ [" vpt" , " stat-file" , " $VP_HOME/bins/npm-global-prefix-cli.json" , " --assert" , " file" ],
93+ { tty = false , argv = [" npm" , " uninstall" , " -g" , " --userconfig" , " empty.npmrc" , " npm-global-prefix-pkg" ], comment = " A real uninstall using the override must clean up the fallback package's links" },
94+ [" vpt" , " stat-file" , " node-prefix/lib/node_modules/npm-global-prefix-pkg" , " --assert" , " missing" ],
95+ [" vpt" , " stat-file" , " node-prefix/bin/npm-global-prefix-cli" , " --assert" , " missing" ],
96+ [" vpt" , " stat-file" , " $VP_HOME/bin/npm-global-prefix-cli" , " --assert" , " missing" ],
97+ [" vpt" , " stat-file" , " $VP_HOME/bins/npm-global-prefix-cli.json" , " --assert" , " missing" ],
98+ ]
99+
100+ [[case ]]
101+ name = " npm_global_uninstall_prefix_shorthand"
102+ vp = " global"
103+ skip-platforms = [" windows" ]
104+ unset-env = [" NPM_CONFIG_PREFIX" ]
105+ steps = [
106+ { tty = false , argv = [" npm" , " install" , " -g" , " --prefix" , " ./custom-prefix" , " ./npm-global-prefix-pkg" ] },
107+ [" vpt" , " stat-file" , " $VP_HOME/bin/npm-global-prefix-cli" , " --assert" , " symlink" ],
108+ [" vpt" , " stat-file" , " $VP_HOME/bins/npm-global-prefix-cli.json" , " --assert" , " file" ],
109+ { tty = false , argv = [" npm" , " uninstall" , " -g" , " -C" , " ./custom-prefix" , " npm-global-prefix-pkg" , " --dry-run" ], envs = [[" NPM_CONFIG_PREFIX" , " ${workspace}/other-prefix" ]], comment = " A shorthand prefix override must still preserve links during dry-run" },
110+ [" npm-global-prefix-cli" ],
111+ [" vpt" , " stat-file" , " $VP_HOME/bins/npm-global-prefix-cli.json" , " --assert" , " file" ],
112+ { tty = false , argv = [" npm" , " uninstall" , " -g" , " -C" , " ./custom-prefix" , " npm-global-prefix-pkg" ], envs = [[" NPM_CONFIG_PREFIX" , " ${workspace}/other-prefix" ]], comment = " -C must override the environment prefix for uninstall link cleanup" },
113+ [" vpt" , " stat-file" , " custom-prefix/lib/node_modules/npm-global-prefix-pkg" , " --assert" , " missing" ],
114+ [" vpt" , " stat-file" , " custom-prefix/bin/npm-global-prefix-cli" , " --assert" , " missing" ],
115+ [" vpt" , " stat-file" , " $VP_HOME/bin/npm-global-prefix-cli" , " --assert" , " missing" ],
116+ [" vpt" , " stat-file" , " $VP_HOME/bins/npm-global-prefix-cli.json" , " --assert" , " missing" ],
117+ [" vpt" , " write-file" , " prefix.npmrc" , " prefix=${HOME}/npm-prefix\n " ],
118+ { tty = false , argv = [" npm" , " install" , " -g" , " -C=./custom-prefix" , " ./npm-global-prefix-pkg" ], envs = [[" npm_config_userconfig" , " ${workspace}/prefix.npmrc" ]], comment = " -C= must override the user npmrc prefix when creating links" },
119+ [" vpt" , " stat-file" , " $VP_HOME/bin/npm-global-prefix-cli" , " --assert" , " symlink" ],
120+ [" vpt" , " stat-file" , " $VP_HOME/bins/npm-global-prefix-cli.json" , " --assert" , " file" ],
121+ [" npm-global-prefix-cli" ],
122+ { tty = false , argv = [" npm" , " -C" , " ./custom-prefix" , " uninstall" , " -g" , " npm-global-prefix-pkg" ], envs = [[" npm_config_userconfig" , " ${workspace}/prefix.npmrc" ]], comment = " -C before the subcommand must also override the user npmrc prefix for cleanup" },
123+ [" vpt" , " stat-file" , " custom-prefix/lib/node_modules/npm-global-prefix-pkg" , " --assert" , " missing" ],
124+ [" vpt" , " stat-file" , " custom-prefix/bin/npm-global-prefix-cli" , " --assert" , " missing" ],
125+ [" vpt" , " stat-file" , " $VP_HOME/bin/npm-global-prefix-cli" , " --assert" , " missing" ],
126+ [" vpt" , " stat-file" , " $VP_HOME/bins/npm-global-prefix-cli.json" , " --assert" , " missing" ],
127+ ]
0 commit comments