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

This commit is contained in:
Dan Graham
2019-08-09 12:19:59 -07:00
committed by GitHub
parent 805ecae784
commit bdb118914a
2 changed files with 24 additions and 2 deletions
+20
View File
@@ -0,0 +1,20 @@
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);
}
+4 -2
View File
@@ -77,8 +77,10 @@
"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",