diff --git a/README.md b/README.md index 446192b..aa637da 100644 --- a/README.md +++ b/README.md @@ -121,6 +121,8 @@ 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 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, 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`: 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);