Skip to content

Commit 32d5deb

Browse files
authored
Shrinkwrap fixes (appium#11969)
* Reinstall node modules before shrinkwrapping * Add script to check shrinkwrap will be packaged
1 parent 2c644c7 commit 32d5deb

File tree

3 files changed

+25
-3
lines changed

3 files changed

+25
-3
lines changed

check-npm-pack-files.js

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
const childProcess = require('child_process');
2+
const _ = require('lodash');
3+
4+
const res = JSON.parse(childProcess.execSync('npm pack --dry-run --json --ignore-scripts', {encoding: 'utf8'}))[0];
5+
6+
// List of files we are testing to make sure they are included in package
7+
const testFiles = [
8+
'npm-shrinkwrap.json', // Check that npm-shrinkwrap.json is being packed
9+
'LICENSE', // Check that license is included
10+
'build/lib/appium.js', // Sanity check that build files are being included by testing just one file
11+
];
12+
13+
// Get list of files in `testFiles` that aren't in the list of packaged fileNames
14+
const missingFiles = _.without(testFiles, ..._.map(res.files, 'path'));
15+
16+
if (!_.isEmpty(missingFiles)) {
17+
throw new Error(`Files [${missingFiles.join(', ')}] are not included in package.json "files". ` +
18+
`Please make sure these files are included before publishing.`);
19+
}
20+
21+
process.exit(0);

docs/en/contributing-to-appium/developers-overview.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ converted into the `npm-shrinkwrap.json` file.
195195
1. Determine whether we have a `patch` (bugfix), `minor` (feature), or `major` (breaking) release according to the principles of SemVer.
196196
1. Update `package.json` with the appropriate new version.
197197
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.
198-
1. Run `npm run shrinkwrap-prod`. This script prunes dev dependencies (leaving only production dependencies), creates a production-only `npm-shrinkwrap.json` and then re-installs the dev dependencies by doing `npm install --no-shrinkwrap`.
198+
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`.
199199
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.
200200
1. Push the tag to upstream: `git push --tags <remote> <branch>`
201201
1. Run `npm publish` (with `--tag beta` if this isn't an official release).

package.json

+3-2
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,8 @@
3636
"files": [
3737
"bin",
3838
"lib",
39-
"build/lib"
39+
"build/lib",
40+
"npm-shrinkwrap.json"
4041
],
4142
"dependencies": {
4243
"@babel/runtime": "^7.0.0",
@@ -85,7 +86,7 @@
8586
"lint:fix": "gulp eslint --fix",
8687
"coverage": "gulp coveralls",
8788
"generate-docs": "node ./build/commands-yml/parse.js",
88-
"shrinkwrap-prod": "rimraf package-lock.json && npm prune --production && npm shrinkwrap && npm install --no-shrinkwrap",
89+
"shrinkwrap:prod": "rimraf package-lock.json && rimraf node_modules && npm install --production && npm shrinkwrap && node ./check-npm-pack-files && npm install --no-shrinkwrap",
8990
"zip": "zip -qr appium.zip .",
9091
"upload": "gulp github-upload",
9192
"zip-and-upload": "npm run zip && npm run upload"

0 commit comments

Comments
 (0)