From 7226a0badf1c252c49c30fc924ff14d9759b8bea Mon Sep 17 00:00:00 2001 From: Andrew Walsh Date: Fri, 10 Jun 2022 08:20:14 +0100 Subject: [PATCH 1/3] Disable pruning by default --- lib/spec.js | 2 +- test/fixtures/my-cool-api-7.spec | 1 - test/fixtures/my-cool-api-no-rebuild.spec | 1 - .../{my-cool-api-no-prune.json => my-cool-api-prune.json} | 2 +- .../{my-cool-api-no-prune.spec => my-cool-api-prune.spec} | 3 +++ test/fixtures/my-cool-api-with-buildrequires.spec | 1 - test/fixtures/my-cool-api-with-diff-licence.spec | 1 - test/fixtures/my-cool-api-with-executable.spec | 1 - test/fixtures/my-cool-api-with-hyphenated-version.spec | 1 - test/fixtures/my-cool-api-with-node-version.spec | 1 - test/fixtures/my-cool-api-with-post.spec | 1 - test/fixtures/my-cool-api-with-requires-noescape.spec | 1 - test/fixtures/my-cool-api-with-requires.spec | 1 - ...-cool-api-with-version-hyphens-replaced-underscores.spec | 1 - .../fixtures/my-cool-api-with-version-hyphens-replaced.spec | 1 - test/fixtures/my-cool-api.spec | 1 - test/fixtures/my-super-long-long-long-long-cat-api.spec | 1 - test/spec.js | 6 +++--- 18 files changed, 8 insertions(+), 19 deletions(-) rename test/fixtures/{my-cool-api-no-prune.json => my-cool-api-prune.json} (92%) rename test/fixtures/{my-cool-api-no-prune.spec => my-cool-api-prune.spec} (77%) diff --git a/lib/spec.js b/lib/spec.js index 1fe32bc..4160c38 100644 --- a/lib/spec.js +++ b/lib/spec.js @@ -67,7 +67,7 @@ module.exports = function (pkg, release) { nodeVersion: getValueFromSpec(pkg.spec, 'nodeVersion'), version: getVersionNumber(pkg), license: pkg.license, - prune: getValueFromSpec(pkg.spec, 'prune', true), + prune: getValueFromSpec(pkg.spec, 'prune', false), rebuild: getValueFromSpec(pkg.spec, 'rebuild', true) }, getExecutableFiles(pkg), diff --git a/test/fixtures/my-cool-api-7.spec b/test/fixtures/my-cool-api-7.spec index de1fb8f..e6c6607 100644 --- a/test/fixtures/my-cool-api-7.spec +++ b/test/fixtures/my-cool-api-7.spec @@ -23,7 +23,6 @@ My Cool API %setup -q -c -n %{name} %build -NODE_ENV=production npm prune npm rebuild %pre diff --git a/test/fixtures/my-cool-api-no-rebuild.spec b/test/fixtures/my-cool-api-no-rebuild.spec index 9e8308d..543d29b 100644 --- a/test/fixtures/my-cool-api-no-rebuild.spec +++ b/test/fixtures/my-cool-api-no-rebuild.spec @@ -23,7 +23,6 @@ My Cool API %setup -q -c -n %{name} %build -NODE_ENV=production npm prune %pre getent group my-cool-api >/dev/null || groupadd -r my-cool-api diff --git a/test/fixtures/my-cool-api-no-prune.json b/test/fixtures/my-cool-api-prune.json similarity index 92% rename from test/fixtures/my-cool-api-no-prune.json rename to test/fixtures/my-cool-api-prune.json index 47c1d4b..6662a9e 100644 --- a/test/fixtures/my-cool-api-no-prune.json +++ b/test/fixtures/my-cool-api-prune.json @@ -9,6 +9,6 @@ "author": "bob@example.com", "license": "MIT", "spec": { - "prune": false + "prune": true } } diff --git a/test/fixtures/my-cool-api-no-prune.spec b/test/fixtures/my-cool-api-prune.spec similarity index 77% rename from test/fixtures/my-cool-api-no-prune.spec rename to test/fixtures/my-cool-api-prune.spec index 7a4da30..074a1fd 100644 --- a/test/fixtures/my-cool-api-no-prune.spec +++ b/test/fixtures/my-cool-api-prune.spec @@ -23,6 +23,9 @@ My Cool API %setup -q -c -n %{name} %build +# Setting NODE_ENV is the same as --production or --omit=dev. Using NODE_ENV here as pruning has slightly different behaviour in newer versions. +# See https://docs.npmjs.com/cli/v8/commands/npm-prune compared to https://docs.npmjs.com/cli/v6/commands/npm-prune +NODE_ENV=production npm prune npm rebuild %pre diff --git a/test/fixtures/my-cool-api-with-buildrequires.spec b/test/fixtures/my-cool-api-with-buildrequires.spec index 73a5735..a930978 100644 --- a/test/fixtures/my-cool-api-with-buildrequires.spec +++ b/test/fixtures/my-cool-api-with-buildrequires.spec @@ -24,7 +24,6 @@ My Cool API %setup -q -c -n %{name} %build -NODE_ENV=production npm prune npm rebuild %pre diff --git a/test/fixtures/my-cool-api-with-diff-licence.spec b/test/fixtures/my-cool-api-with-diff-licence.spec index afbd2ed..920df2e 100644 --- a/test/fixtures/my-cool-api-with-diff-licence.spec +++ b/test/fixtures/my-cool-api-with-diff-licence.spec @@ -25,7 +25,6 @@ My Cool API %setup -q -c -n %{name} %build -NODE_ENV=production npm prune npm rebuild %pre diff --git a/test/fixtures/my-cool-api-with-executable.spec b/test/fixtures/my-cool-api-with-executable.spec index b0ee238..0bf5daa 100644 --- a/test/fixtures/my-cool-api-with-executable.spec +++ b/test/fixtures/my-cool-api-with-executable.spec @@ -23,7 +23,6 @@ My Cool API %setup -q -c -n %{name} %build -NODE_ENV=production npm prune npm rebuild %pre diff --git a/test/fixtures/my-cool-api-with-hyphenated-version.spec b/test/fixtures/my-cool-api-with-hyphenated-version.spec index 5ae9b59..fb68201 100644 --- a/test/fixtures/my-cool-api-with-hyphenated-version.spec +++ b/test/fixtures/my-cool-api-with-hyphenated-version.spec @@ -23,7 +23,6 @@ My Cool API %setup -q -c -n %{name} %build -NODE_ENV=production npm prune npm rebuild %pre diff --git a/test/fixtures/my-cool-api-with-node-version.spec b/test/fixtures/my-cool-api-with-node-version.spec index 97491b2..83d9d94 100644 --- a/test/fixtures/my-cool-api-with-node-version.spec +++ b/test/fixtures/my-cool-api-with-node-version.spec @@ -25,7 +25,6 @@ My Cool API %setup -q -c -n %{name} %build -NODE_ENV=production npm prune npm rebuild %pre diff --git a/test/fixtures/my-cool-api-with-post.spec b/test/fixtures/my-cool-api-with-post.spec index af246e3..a64d36e 100644 --- a/test/fixtures/my-cool-api-with-post.spec +++ b/test/fixtures/my-cool-api-with-post.spec @@ -23,7 +23,6 @@ My Cool API %setup -q -c -n %{name} %build -NODE_ENV=production npm prune npm rebuild %pre diff --git a/test/fixtures/my-cool-api-with-requires-noescape.spec b/test/fixtures/my-cool-api-with-requires-noescape.spec index ef68b85..c49b3dd 100644 --- a/test/fixtures/my-cool-api-with-requires-noescape.spec +++ b/test/fixtures/my-cool-api-with-requires-noescape.spec @@ -25,7 +25,6 @@ My Cool API %setup -q -c -n %{name} %build -NODE_ENV=production npm prune npm rebuild %pre diff --git a/test/fixtures/my-cool-api-with-requires.spec b/test/fixtures/my-cool-api-with-requires.spec index 97fe401..6a0bdec 100644 --- a/test/fixtures/my-cool-api-with-requires.spec +++ b/test/fixtures/my-cool-api-with-requires.spec @@ -25,7 +25,6 @@ My Cool API %setup -q -c -n %{name} %build -NODE_ENV=production npm prune npm rebuild %pre diff --git a/test/fixtures/my-cool-api-with-version-hyphens-replaced-underscores.spec b/test/fixtures/my-cool-api-with-version-hyphens-replaced-underscores.spec index 6016a95..69ae49a 100644 --- a/test/fixtures/my-cool-api-with-version-hyphens-replaced-underscores.spec +++ b/test/fixtures/my-cool-api-with-version-hyphens-replaced-underscores.spec @@ -23,7 +23,6 @@ My Cool API %setup -q -c -n %{name} %build -NODE_ENV=production npm prune npm rebuild %pre diff --git a/test/fixtures/my-cool-api-with-version-hyphens-replaced.spec b/test/fixtures/my-cool-api-with-version-hyphens-replaced.spec index 2cc90ac..21707ac 100644 --- a/test/fixtures/my-cool-api-with-version-hyphens-replaced.spec +++ b/test/fixtures/my-cool-api-with-version-hyphens-replaced.spec @@ -23,7 +23,6 @@ My Cool API %setup -q -c -n %{name} %build -NODE_ENV=production npm prune npm rebuild %pre diff --git a/test/fixtures/my-cool-api.spec b/test/fixtures/my-cool-api.spec index 598429e..7a4da30 100644 --- a/test/fixtures/my-cool-api.spec +++ b/test/fixtures/my-cool-api.spec @@ -23,7 +23,6 @@ My Cool API %setup -q -c -n %{name} %build -NODE_ENV=production npm prune npm rebuild %pre diff --git a/test/fixtures/my-super-long-long-long-long-cat-api.spec b/test/fixtures/my-super-long-long-long-long-cat-api.spec index 37bd6aa..3029f6c 100644 --- a/test/fixtures/my-super-long-long-long-long-cat-api.spec +++ b/test/fixtures/my-super-long-long-long-long-cat-api.spec @@ -23,7 +23,6 @@ My Super Long Long Long Long Cat API %setup -q -c -n %{name} %build -NODE_ENV=production npm prune npm rebuild %pre diff --git a/test/spec.js b/test/spec.js index da4939e..379ac77 100644 --- a/test/spec.js +++ b/test/spec.js @@ -21,9 +21,9 @@ describe('spec', () => { assert.equal(spec, expected); }); - it('removes the prune step when specified', () => { - const pkg = require('./fixtures/my-cool-api-no-prune'); - const expected = loadFixture('my-cool-api-no-prune.spec'); + it('adds the prune step when specified', () => { + const pkg = require('./fixtures/my-cool-api-prune'); + const expected = loadFixture('my-cool-api-prune.spec'); const spec = createSpecFile(pkg); assert.equal(spec, expected); From 25475b9c3ac09a41fbcd6603256119bf31999f0b Mon Sep 17 00:00:00 2001 From: Andrew Walsh Date: Fri, 10 Jun 2022 08:27:01 +0100 Subject: [PATCH 2/3] docs update --- README.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 446192b..154ef46 100644 --- a/README.md +++ b/README.md @@ -121,7 +121,9 @@ You can then run `npm run spec` to generate your spec file in an environment whe ### Pruning dependencies -To minimise the final RPM size, your development dependencies (dependencies added with the --save-dev flag) are automatically [pruned](https://docs.npmjs.com/cli/prune) so that they're not shipped with your production code. +> :warning: **DEPRECATION WANRING** Pruning is deprecated in Speulate v4.0.0 and is turned off by default. To enable you must set the following option to `true`. In NPM 8.6+ internet access is required to perform pruning which may not be available in all build environments, in which case the RPM build stage may stall before failing. + +To minimise the final RPM size, you should remove development dependencies (dependencies added with the --save-dev flag) are automatically [pruned](https://docs.npmjs.com/cli/prune) so that they're not shipped with your production code. If for some reason you need to package your dev dependencies with your production code you can explicity tell speculate not to prune by adding the following to your `package.json`: From e96e3630b951a315977e15bf8d7d5d2cf9aa85f0 Mon Sep 17 00:00:00 2001 From: Andrew Walsh Date: Tue, 14 Jun 2022 09:19:53 +0100 Subject: [PATCH 3/3] PR Feedback --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 154ef46..aa637da 100644 --- a/README.md +++ b/README.md @@ -121,9 +121,9 @@ You can then run `npm run spec` to generate your spec file in an environment whe ### Pruning dependencies -> :warning: **DEPRECATION WANRING** Pruning is deprecated in Speulate v4.0.0 and is turned off by default. To enable you must set the following option to `true`. In NPM 8.6+ internet access is required to perform pruning which may not be available in all build environments, in which case the RPM build stage may stall before failing. +> :warning: **DEPRECATION WANRING** Pruning is deprecated in Speculate v4.0.0 and is turned off by default. To enable you must set the `prune` option to `true`. In NPM 8.6+ internet access is required to perform pruning which may not be available in all build environments, in which case the RPM build stage may stall before failing. -To minimise the final RPM size, you should remove development dependencies (dependencies added with the --save-dev flag) are automatically [pruned](https://docs.npmjs.com/cli/prune) so that they're not shipped with your production code. +To minimise the final RPM size, your development dependencies (dependencies added with the --save-dev flag) are automatically [pruned](https://docs.npmjs.com/cli/prune) so that they're not shipped with your production code. If for some reason you need to package your dev dependencies with your production code you can explicity tell speculate not to prune by adding the following to your `package.json`: