Add prepublish script to prune devDependencies from shrinkwrap
MODIFY
docs/en/contributing-to-appium/developers-overview.md
docs/en/contributing-to-appium/developers-overview.md
@@ -195,7 +195,7 @@ converted into the `npm-shrinkwrap.json` file.
1. Determine whether we have a `patch` (bugfix), `minor` (feature), or `major` (breaking) release according to the principles of SemVer.
1. Update `package.json` with the appropriate new version.
1. Update the CHANGELOG/README with appropriate changes and submit for review as a PR, along with shrinkwrap and `package.json` changes. Wait for it to be merged, then pull it into the release branch.
-1. Run `npm run shrinkwrap:prod`. This script removes `node_modules`, installs node production dependencies, creates `npm-shrinkwrap.json` (which only shrinkwrap prod dependencies) and then re-installs the dev dependencies by doing `npm install --no-shrinkwrap`.
+1. Run `npm shrinkwrap` to generate the `npm-shrinkwrap.json`
1. Create a tag of the form `v<version>` on the release branch (usually a minor branch like `1.5` or `1.4`), with: `git tag -a v<version>`, e.g., `git tag -a v1.5.0`. This is not necessary for beta versions.
1. Push the tag to upstream: `git push --tags <remote> <branch>`
1. Run `npm publish` (with `--tag beta` if this isn't an official release).

MODIFY
gulpfile.js
gulpfile.js
@@ -12,9 +12,9 @@ const path = require('path');
const fs = require('fs');
const log = require('fancy-log');
-
// remove 'fsevents' from shrinkwrap, since it causes errors on non-Mac hosts
// see https://github.com/npm/npm/issues/2679
+
gulp.task('fixShrinkwrap', function (done) {
let shrinkwrap;
try {
@@ -24,6 +24,7 @@ gulp.task('fixShrinkwrap', function (done) {
`(Original error: ${err.message})`);
return done();
}
+
delete shrinkwrap.dependencies.fsevents;
const shrinkwrapString = JSON.stringify(shrinkwrap, null, ' ') + '\n';
fs.writeFile('./npm-shrinkwrap.json', shrinkwrapString, done);
@@ -42,7 +43,6 @@ boilerplate({
test: {
files: ['${testDir}/**/*-specs.js']
},
- extraPrepublishTasks: ['fixShrinkwrap'],
preCommitTasks: ['eslint', 'once'],
});

MODIFY
package.json
package.json
"firefoxos",
"testing"
],
- "version": "1.11.0-beta.3",
+ "version": "1.11.1",
"author": "https://github.com/appium",
"license": "Apache-2.0",
"repository": {
},
"scripts": {
"clean": "rm -rf node_modules && rm -f package-lock.json && npm install",
- "prepare": "gulp prepublish",
- "publish": "gulp prepublish",
+ "prepublish": "gulp prepublish",
+ "prepublishOnly": "npm run prune-shrinkwrap && gulp fixShrinkwrap",
+ "postpublish": "npm run restore-shrinkwrap",
+ "prune-shrinkwrap": "npm ci --production --ignore-scripts && npm shrinkwrap && npm install --only=dev --no-shrinkwrap",
+ "restore-shrinkwrap": "git checkout HEAD -- npm-shrinkwrap.json",
"test": "gulp once",
"e2e-test": "gulp e2e-test",
"watch": "gulp watch",
"lint:fix": "gulp eslint --fix",
"coverage": "gulp coveralls",
"generate-docs": "node ./build/commands-yml/parse.js",
- "shrinkwrap:prod": "rimraf package-lock.json && rimraf node_modules && npm install --production && npm shrinkwrap && node ./check-npm-pack-files && npm install --no-shrinkwrap",
"zip": "zip -qr appium.zip .",
"upload": "gulp github-upload",
"zip-and-upload": "npm run zip && npm run upload",

Add prepublish script to prune devDependencies from shrinkwrap (#12194)