/* jshint node:true */ /* eslint-env node */ /* * This will look at the current version of all of your dependencies and update your package.json * with the specific version that you currently have in node_modules. This will save you from the * sadness that is: DEPENDENCY MANAGEMENT * * Place this file at the same level as your package.json and node_modules * Then simply run: node ./package-strict * * * When you're ready to update dependencies, I recommend https://github.com/bahmutov/next-update */ const fs = require('fs'); const path = require('path'); const packageJson = require('./package.json'); strictifyDeps('dependencies'); strictifyDeps('devDependencies'); strictifyDeps('peerDependencies'); console.log('done!'); function strictifyDeps(depsProperty) { const deps = Object.keys(packageJson[depsProperty]); deps.forEach(function(dep) { var depPackageJson = require('./node_modules/' + dep + '/package.json'); packageJson[depsProperty][dep] = depPackageJson.version; }); fs.writeFileSync(path.resolve(__dirname, './package.json'), JSON.stringify(packageJson, null, 2)); }