Skip to content

Commit

Permalink
Shrinkwrap fixes (appium#11969)
Browse files Browse the repository at this point in the history
* Reinstall node modules before shrinkwrapping
* Add script to check shrinkwrap will be packaged
  • Loading branch information
dpgraham authored Jan 10, 2019
1 parent 2c644c7 commit 32d5deb
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 3 deletions.
21 changes: 21 additions & 0 deletions check-npm-pack-files.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
const childProcess = require('child_process');
const _ = require('lodash');

const res = JSON.parse(childProcess.execSync('npm pack --dry-run --json --ignore-scripts', {encoding: 'utf8'}))[0];

// List of files we are testing to make sure they are included in package
const testFiles = [
'npm-shrinkwrap.json', // Check that npm-shrinkwrap.json is being packed
'LICENSE', // Check that license is included
'build/lib/appium.js', // Sanity check that build files are being included by testing just one file
];

// Get list of files in `testFiles` that aren't in the list of packaged fileNames
const missingFiles = _.without(testFiles, ..._.map(res.files, 'path'));

if (!_.isEmpty(missingFiles)) {
throw new Error(`Files [${missingFiles.join(', ')}] are not included in package.json "files". ` +
`Please make sure these files are included before publishing.`);
}

process.exit(0);
2 changes: 1 addition & 1 deletion docs/en/contributing-to-appium/developers-overview.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 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`.
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. 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).
Expand Down
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@
"files": [
"bin",
"lib",
"build/lib"
"build/lib",
"npm-shrinkwrap.json"
],
"dependencies": {
"@babel/runtime": "^7.0.0",
Expand Down Expand Up @@ -85,7 +86,7 @@
"lint:fix": "gulp eslint --fix",
"coverage": "gulp coveralls",
"generate-docs": "node ./build/commands-yml/parse.js",
"shrinkwrap-prod": "rimraf package-lock.json && npm prune --production && npm shrinkwrap && npm install --no-shrinkwrap",
"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"
Expand Down

0 comments on commit 32d5deb

Please sign in to comment.