diff options
author | Nathan Whitaker <17734409+nathanwhit@users.noreply.github.com> | 2024-09-24 12:23:57 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-09-24 19:23:57 +0000 |
commit | 36ebc03f177cc7db5deb93f4d403cafbed756eb5 (patch) | |
tree | c36af6c9b7093d3191de3cd6e60c4ce9dca4151a /tests/specs | |
parent | ba5b8d0213cde2585236098b00beb8a512889626 (diff) |
fix(cli): Warn on not-run lifecycle scripts with global cache (#25786)
Refactors the lifecycle scripts code to extract out the common
functionality and then uses that to provide a warning in the global
resolver.
While ideally we would still support them with the global cache, for now
a warning is at least better than the status quo (where people are
unaware why their packages aren't working).
Diffstat (limited to 'tests/specs')
8 files changed, 43 insertions, 20 deletions
diff --git a/tests/specs/install/install_deprecated_package/install.out b/tests/specs/install/install_deprecated_package/install.out index 34e9010a3..95c075909 100644 --- a/tests/specs/install/install_deprecated_package/install.out +++ b/tests/specs/install/install_deprecated_package/install.out @@ -2,5 +2,5 @@ Add npm:@denotest/deprecated-package@1.0.0 Download http://localhost:4260/@denotest/deprecated-package Download http://localhost:4260/@denotest/deprecated-package/1.0.0.tgz Initialize @denotest/deprecated-package@1.0.0 -Warning Following packages are deprecated: -┗─ npm:@denotest/deprecated-package@1.0.0 (Deprecated version) +Warning The following packages are deprecated: +┖─ npm:@denotest/deprecated-package@1.0.0 (Deprecated version) diff --git a/tests/specs/npm/lifecycle_scripts/__test__.jsonc b/tests/specs/npm/lifecycle_scripts/__test__.jsonc index f7a722a8b..201e42497 100644 --- a/tests/specs/npm/lifecycle_scripts/__test__.jsonc +++ b/tests/specs/npm/lifecycle_scripts/__test__.jsonc @@ -1,7 +1,7 @@ { + "tempDir": true, "tests": { "node_gyp": { - "tempDir": true, "steps": [ { "args": "cache --allow-scripts=npm:@denotest/node-addon main.js", @@ -14,7 +14,6 @@ ] }, "run_without_scripts": { - "tempDir": true, "steps": [ { "args": "run -A main.js", @@ -24,11 +23,9 @@ ] }, "implicit_node_gyp": { - "tempDir": true, "steps": [ { "envs": { - // I don't think this will work on windows "PATH": "" }, "args": "cache --allow-scripts implicit_node_gyp.js", @@ -38,7 +35,6 @@ ] }, "lifecycle_scripts": { - "tempDir": true, "steps": [ { // without running scripts (should warn) @@ -55,8 +51,25 @@ } ] }, + "global_lifecycle_scripts": { + "steps": [ + { + "args": ["eval", "Deno.removeSync('deno.json')"], + "output": "" + }, + { + // without running scripts (should warn) + "args": "install -e all_lifecycles.js", + "output": "all_lifecycles_not_run_global.out" + }, + { + // should not warn + "args": "install -e all_lifecycles.js", + "output": "" + } + ] + }, "only_warns_first": { - "tempDir": true, "steps": [ { // without running scripts (should warn) @@ -96,7 +109,6 @@ ] }, "lifecycle_scripts_conflicting_bin": { - "tempDir": true, "steps": [ { // we import @denotest/says-hello-on-install, which executes `say-hello` from `@denotest/say-hello` in its @@ -110,7 +122,6 @@ ] }, "fsevents_default_install_script": { - "tempDir": true, "steps": [ { "if": "mac", @@ -125,7 +136,6 @@ ] }, "lifecycle_scripts_no_deno_json": { - "tempDir": true, "steps": [ { "args": ["eval", "Deno.removeSync('deno.json')"], @@ -138,7 +148,6 @@ ] }, "lifecycle_scripts_no_deno_json_conflicting_bin": { - "tempDir": true, "steps": [ { "args": ["eval", "Deno.removeSync('deno.json')"], diff --git a/tests/specs/npm/lifecycle_scripts/all_lifecycles_not_run.out b/tests/specs/npm/lifecycle_scripts/all_lifecycles_not_run.out index e63e2d22b..09324c845 100644 --- a/tests/specs/npm/lifecycle_scripts/all_lifecycles_not_run.out +++ b/tests/specs/npm/lifecycle_scripts/all_lifecycles_not_run.out @@ -6,9 +6,9 @@ Download http://localhost:4260/@denotest/bin/1.0.0.tgz Initialize @denotest/node-lifecycle-scripts@1.0.0 Initialize @denotest/bin@1.0.0 [UNORDERED_END] -Warning Following packages contained npm lifecycle scripts (preinstall/install/postinstall) that were not executed: +Warning The following packages contained npm lifecycle scripts (preinstall/install/postinstall) that were not executed: ┠─ npm:@denotest/node-lifecycle-scripts@1.0.0 ┃ ┠─ This may cause the packages to not work correctly. -┗─ To run lifecycle scripts, use the `--allow-scripts` flag with `deno install`: +┖─ To run lifecycle scripts, use the `--allow-scripts` flag with `deno install`: deno install --allow-scripts=npm:@denotest/node-lifecycle-scripts@1.0.0 diff --git a/tests/specs/npm/lifecycle_scripts/all_lifecycles_not_run_global.out b/tests/specs/npm/lifecycle_scripts/all_lifecycles_not_run_global.out new file mode 100644 index 000000000..93b5a14cc --- /dev/null +++ b/tests/specs/npm/lifecycle_scripts/all_lifecycles_not_run_global.out @@ -0,0 +1,13 @@ +[UNORDERED_START] +Download http://localhost:4260/@denotest/node-lifecycle-scripts +Download http://localhost:4260/@denotest/bin +Download http://localhost:4260/@denotest/node-lifecycle-scripts/1.0.0.tgz +Download http://localhost:4260/@denotest/bin/1.0.0.tgz +[UNORDERED_END] +Warning The following packages contained npm lifecycle scripts (preinstall/install/postinstall) that were not executed: +┠─ npm:@denotest/node-lifecycle-scripts@1.0.0 +┃ +┠─ This may cause the packages to not work correctly. +┠─ Lifecycle scripts are only supported when using a `node_modules` directory. +┠─ Enable it in your deno config file: +┖─ "nodeModulesDir": "auto" diff --git a/tests/specs/npm/lifecycle_scripts/future_install_all_lifecycles_not_run.out b/tests/specs/npm/lifecycle_scripts/future_install_all_lifecycles_not_run.out index e63e2d22b..09324c845 100644 --- a/tests/specs/npm/lifecycle_scripts/future_install_all_lifecycles_not_run.out +++ b/tests/specs/npm/lifecycle_scripts/future_install_all_lifecycles_not_run.out @@ -6,9 +6,9 @@ Download http://localhost:4260/@denotest/bin/1.0.0.tgz Initialize @denotest/node-lifecycle-scripts@1.0.0 Initialize @denotest/bin@1.0.0 [UNORDERED_END] -Warning Following packages contained npm lifecycle scripts (preinstall/install/postinstall) that were not executed: +Warning The following packages contained npm lifecycle scripts (preinstall/install/postinstall) that were not executed: ┠─ npm:@denotest/node-lifecycle-scripts@1.0.0 ┃ ┠─ This may cause the packages to not work correctly. -┗─ To run lifecycle scripts, use the `--allow-scripts` flag with `deno install`: +┖─ To run lifecycle scripts, use the `--allow-scripts` flag with `deno install`: deno install --allow-scripts=npm:@denotest/node-lifecycle-scripts@1.0.0 diff --git a/tests/specs/npm/lifecycle_scripts/node_gyp_not_found.out b/tests/specs/npm/lifecycle_scripts/node_gyp_not_found.out index 2f0ff11e2..06c856cd9 100644 --- a/tests/specs/npm/lifecycle_scripts/node_gyp_not_found.out +++ b/tests/specs/npm/lifecycle_scripts/node_gyp_not_found.out @@ -6,3 +6,4 @@ Initialize @denotest/node-addon-implicit-node-gyp@1.0.0 Warning node-gyp was used in a script, but was not listed as a dependency. Either add it as a dependency or install it globally (e.g. `npm install -g node-gyp`) [WILDCARD] error: script 'install' in '@denotest/node-addon-implicit-node-gyp@1.0.0' failed with exit code 1 +error: failed to run scripts for packages: @denotest/node-addon-implicit-node-gyp@1.0.0 diff --git a/tests/specs/npm/lifecycle_scripts/node_gyp_not_run.out b/tests/specs/npm/lifecycle_scripts/node_gyp_not_run.out index 2803bcb4d..e0e51b26c 100644 --- a/tests/specs/npm/lifecycle_scripts/node_gyp_not_run.out +++ b/tests/specs/npm/lifecycle_scripts/node_gyp_not_run.out @@ -1,11 +1,11 @@ Download http://localhost:4260/@denotest/node-addon Download http://localhost:4260/node-gyp [WILDCARD] -Warning Following packages contained npm lifecycle scripts (preinstall/install/postinstall) that were not executed: +Warning The following packages contained npm lifecycle scripts (preinstall/install/postinstall) that were not executed: ┠─ npm:@denotest/node-addon@1.0.0 ┃ ┠─ This may cause the packages to not work correctly. -┗─ To run lifecycle scripts, use the `--allow-scripts` flag with `deno install`: +┖─ To run lifecycle scripts, use the `--allow-scripts` flag with `deno install`: deno install --allow-scripts=npm:@denotest/node-addon@1.0.0 error: Uncaught (in promise) Error: Cannot find module './build/Release/node_addon' [WILDCARD] diff --git a/tests/specs/npm/lifecycle_scripts/only_warns_first1.out b/tests/specs/npm/lifecycle_scripts/only_warns_first1.out index e1985d08c..947777b5b 100644 --- a/tests/specs/npm/lifecycle_scripts/only_warns_first1.out +++ b/tests/specs/npm/lifecycle_scripts/only_warns_first1.out @@ -6,11 +6,11 @@ Download http://localhost:4260/@denotest/bin/1.0.0.tgz Initialize @denotest/node-lifecycle-scripts@1.0.0 Initialize @denotest/bin@1.0.0 [UNORDERED_END] -Warning Following packages contained npm lifecycle scripts (preinstall/install/postinstall) that were not executed: +Warning The following packages contained npm lifecycle scripts (preinstall/install/postinstall) that were not executed: ┠─ npm:@denotest/node-lifecycle-scripts@1.0.0 ┃ ┠─ This may cause the packages to not work correctly. -┗─ To run lifecycle scripts, use the `--allow-scripts` flag with `deno install`: +┖─ To run lifecycle scripts, use the `--allow-scripts` flag with `deno install`: deno install --allow-scripts=npm:@denotest/node-lifecycle-scripts@1.0.0 error: Uncaught SyntaxError: The requested module 'npm:@denotest/node-lifecycle-scripts' does not provide an export named 'value' [WILDCARD] |