Check that pruned shrinkwrap has same dependencies as unpruned shrinkwrap
ADD
check-pruned-shrinkwrap.js
+const _ = require('lodash');
+const { asyncify } = require('asyncbox');
+const { fs, logger } = require('appium-support');
+const path = require('path');
+
+const log = new logger.getLogger('ShrinkwrapValidator');
+
+async function main () {
+ const backupShrinkwrap = JSON.parse(await fs.readFile(path.resolve('npm-shrinkwrap-backup.json')));
+ const shrinkwrap = JSON.parse(await fs.readFile(path.resolve('npm-shrinkwrap.json')));
+ log.info('Checking that pruned shrinkwrap is a subset of primary shrinkwrap');
+ if (!_.isMatch(backupShrinkwrap, shrinkwrap)) {
+ log.errorAndThrow('Pruned shrinkwrap (shrinkwrap with dev dependencies removed) is not a subset of the original npm-shrinkwrap.json');
+ }
+ log.info('Shrinkwrap check passed');
+}
+
+if (require.main === module) {
+ asyncify(main);
+}
\ No newline at end of file

MODIFY
package.json
package.json
"prepare": "gulp prepublish",
"prepublishOnly": "npm run prune-shrinkwrap && gulp fixShrinkwrap",
"postpublish": "npm run restore-shrinkwrap",
- "prune-shrinkwrap": "!(test -e npm-shrinkwrap.json) || (npm ci --production --ignore-scripts && npm shrinkwrap && npm install --only=dev --no-shrinkwrap)",
- "restore-shrinkwrap": "git checkout HEAD -- npm-shrinkwrap.json",
+ "prune-shrinkwrap": "!(test -e npm-shrinkwrap.json) || (npm ci --production --ignore-scripts && npm run backup-shrinkwrap && npm shrinkwrap && npm install --only=dev --no-shrinkwrap) && npm run check-pruned-shrinkwrap",
+ "restore-shrinkwrap": "mv npm-shrinkwrap-backup.json npm-shrinkwrap.json",
+ "backup-shrinkwrap": "mv npm-shrinkwrap.json npm-shrinkwrap-backup.json",
+ "check-pruned-shrinkwrap": "node check-pruned-shrinkwrap.js",
"test": "gulp once",
"e2e-test": "gulp e2e-test",
"watch": "gulp watch",

Check that pruned shrinkwrap has same dependencies as unpruned shrinkwrap (#13053)