Created
October 13, 2016 19:40
-
-
Save jameswomack/d180b0ce0d258531dde487b3a6459be9 to your computer and use it in GitHub Desktop.
Building an npm update string generator
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function makeObjectIterable (foo) { | |
foo[Symbol.iterator] = function* () { | |
yield* Object.keys(foo).map(function (name) { | |
return [name, foo[name]] | |
}) | |
} | |
return foo | |
} | |
const outdatedPackages = makeObjectIterable({ | |
"abacus-filter-panel-component": { | |
"current": "1.0.12", | |
"wanted": "1.0.12", | |
"latest": "1.7.0", | |
"location": "node_modules/abacus-filter-panel-component" | |
}, | |
"abacus-meechum-plugin": { | |
"current": "2.0.0-alpha.9", | |
"wanted": "2.0.0-alpha.9", | |
"latest": "2.0.0", | |
"location": "node_modules/abacus-meechum-plugin" | |
}, | |
"abacus-notes-component": { | |
"current": "1.0.0", | |
"wanted": "1.0.0", | |
"latest": "1.1.0", | |
"location": "node_modules/abacus-notes-component" | |
}, | |
"abacus-promise-dispatcher": { | |
"current": "1.1.0", | |
"wanted": "1.1.0", | |
"latest": "2.0.0-alpha.21", | |
"location": "node_modules/abacus-promise-dispatcher" | |
}, | |
"abacus-request": { | |
"current": "2.0.0-alpha.8", | |
"wanted": "2.0.0-alpha.8", | |
"latest": "2.0.3", | |
"location": "node_modules/abacus-request" | |
}, | |
"alloyeditor": { | |
"current": "1.0.1", | |
"wanted": "1.0.1", | |
"latest": "1.2.4", | |
"location": "node_modules/alloyeditor" | |
}, | |
"async": { | |
"current": "0.9.2", | |
"wanted": "0.9.2", | |
"latest": "2.1.1", | |
"location": "node_modules/async" | |
}, | |
"babel-cli": { | |
"current": "6.4.0", | |
"wanted": "6.4.0", | |
"latest": "6.16.0", | |
"location": "node_modules/babel-cli" | |
}, | |
"babel-core": { | |
"current": "6.11.4", | |
"wanted": "6.11.4", | |
"latest": "6.17.0", | |
"location": "node_modules/babel-core" | |
}, | |
"babel-eslint": { | |
"current": "6.0.4", | |
"wanted": "6.0.4", | |
"latest": "7.0.0", | |
"location": "node_modules/babel-eslint" | |
}, | |
"babel-loader": { | |
"current": "6.2.1", | |
"wanted": "6.2.1", | |
"latest": "6.2.5", | |
"location": "node_modules/babel-loader" | |
}, | |
"babel-plugin-add-module-exports": { | |
"current": "0.1.2", | |
"wanted": "0.1.2", | |
"latest": "0.2.1", | |
"location": "node_modules/babel-plugin-add-module-exports" | |
}, | |
"babel-plugin-react-transform": { | |
"current": "2.0.0-beta1", | |
"wanted": "2.0.0-beta1", | |
"latest": "2.0.2", | |
"location": "node_modules/babel-plugin-react-transform" | |
}, | |
"babel-plugin-rewire": { | |
"current": "1.0.0-rc-4", | |
"wanted": "1.0.0-rc-4", | |
"latest": "1.0.0", | |
"location": "node_modules/babel-plugin-rewire" | |
}, | |
"babel-plugin-transform-object-assign": { | |
"current": "6.3.13", | |
"wanted": "6.3.13", | |
"latest": "6.8.0", | |
"location": "node_modules/babel-plugin-transform-object-assign" | |
}, | |
"babel-plugin-transform-react-remove-prop-types": { | |
"current": "0.2.3", | |
"wanted": "0.2.3", | |
"latest": "0.2.9", | |
"location": "node_modules/babel-plugin-transform-react-remove-prop-types" | |
}, | |
"babel-preset-es2015": { | |
"current": "6.3.13", | |
"wanted": "6.3.13", | |
"latest": "6.16.0", | |
"location": "node_modules/babel-preset-es2015" | |
}, | |
"babel-preset-react": { | |
"current": "6.3.13", | |
"wanted": "6.3.13", | |
"latest": "6.16.0", | |
"location": "node_modules/babel-preset-react" | |
}, | |
"body-parser": { | |
"current": "1.13.2", | |
"wanted": "1.13.2", | |
"latest": "1.15.2", | |
"location": "node_modules/body-parser" | |
}, | |
"cassandra-driver": { | |
"current": "3.0.0", | |
"wanted": "3.0.0", | |
"latest": "3.1.5", | |
"location": "node_modules/cassandra-driver" | |
}, | |
"classnames": { | |
"current": "2.1.3", | |
"wanted": "2.1.3", | |
"latest": "2.2.5", | |
"location": "node_modules/classnames" | |
}, | |
"compression": { | |
"current": "1.6.1", | |
"wanted": "1.6.1", | |
"latest": "1.6.2", | |
"location": "node_modules/compression" | |
}, | |
"config": { | |
"current": "1.17.1", | |
"wanted": "1.17.1", | |
"latest": "1.21.0", | |
"location": "node_modules/config" | |
}, | |
"css-loader": { | |
"current": "0.19.0", | |
"wanted": "0.19.0", | |
"latest": "0.25.0", | |
"location": "node_modules/css-loader" | |
}, | |
"d3": { | |
"current": "3.5.5", | |
"wanted": "3.5.5", | |
"latest": "4.2.7", | |
"location": "node_modules/d3" | |
}, | |
"d3-svg-legend": { | |
"current": "1.5.0", | |
"wanted": "1.5.0", | |
"latest": "2.10.0", | |
"location": "node_modules/d3-svg-legend" | |
}, | |
"druid-query": { | |
"current": "1.0.0", | |
"wanted": "1.0.0", | |
"latest": "2.0.0", | |
"location": "node_modules/druid-query" | |
}, | |
"enzyme": { | |
"current": "2.2.0", | |
"wanted": "2.2.0", | |
"latest": "2.4.1", | |
"location": "node_modules/enzyme" | |
}, | |
"eslint": { | |
"current": "2.11.1", | |
"wanted": "2.11.1", | |
"latest": "3.7.1", | |
"location": "node_modules/eslint" | |
}, | |
"eslint-config-netflix-dea": { | |
"current": "2.0.0", | |
"wanted": "2.0.0", | |
"latest": "2.0.5", | |
"location": "node_modules/eslint-config-netflix-dea" | |
}, | |
"eslint-loader": { | |
"current": "1.3.0", | |
"wanted": "1.3.0", | |
"latest": "1.5.0", | |
"location": "node_modules/eslint-loader" | |
}, | |
"eslint-plugin-react": { | |
"current": "3.13.1", | |
"wanted": "3.13.1", | |
"latest": "6.4.1", | |
"location": "node_modules/eslint-plugin-react" | |
}, | |
"express": { | |
"current": "4.13.4", | |
"wanted": "4.13.4", | |
"latest": "4.14.0", | |
"location": "node_modules/express" | |
}, | |
"express-mysql-session": { | |
"current": "1.0.0-rc.0", | |
"wanted": "1.0.0-rc.0", | |
"latest": "1.2.0", | |
"location": "node_modules/express-mysql-session" | |
}, | |
"express-session": { | |
"current": "1.13.0", | |
"wanted": "1.13.0", | |
"latest": "1.14.1", | |
"location": "node_modules/express-session" | |
}, | |
"frontail": { | |
"current": "3.0.0", | |
"wanted": "3.0.0", | |
"latest": "4.0.1", | |
"location": "node_modules/frontail" | |
}, | |
"i": { | |
"current": "0.3.4", | |
"wanted": "0.3.4", | |
"latest": "0.3.5", | |
"location": "node_modules/i" | |
}, | |
"immutable": { | |
"current": "3.7.5", | |
"wanted": "3.7.5", | |
"latest": "3.8.1", | |
"location": "node_modules/immutable" | |
}, | |
"isomorphic-fetch": { | |
"current": "2.1.1", | |
"wanted": "2.1.1", | |
"latest": "2.2.1", | |
"location": "node_modules/isomorphic-fetch" | |
}, | |
"istanbul": { | |
"current": "1.1.0-alpha.1", | |
"wanted": "1.1.0-alpha.1", | |
"latest": "0.4.5", | |
"location": "node_modules/istanbul" | |
}, | |
"jsdom": { | |
"current": "7.2.2", | |
"wanted": "7.2.2", | |
"latest": "9.6.0", | |
"location": "node_modules/jsdom" | |
}, | |
"lodash": { | |
"current": "3.10.1", | |
"wanted": "3.10.1", | |
"latest": "4.16.4", | |
"location": "node_modules/lodash" | |
}, | |
"lodash.merge": { | |
"current": "4.3.4", | |
"wanted": "4.3.4", | |
"latest": "4.6.0", | |
"location": "node_modules/lodash.merge" | |
}, | |
"memoizee": { | |
"current": "0.4.0", | |
"wanted": "0.4.0", | |
"latest": "0.4.1", | |
"location": "node_modules/memoizee" | |
}, | |
"minilog": { | |
"current": "3.0.0", | |
"wanted": "3.0.0", | |
"latest": "3.0.1", | |
"location": "node_modules/minilog" | |
}, | |
"moment": { | |
"current": "2.10.6", | |
"wanted": "2.10.6", | |
"latest": "2.15.1", | |
"location": "node_modules/moment" | |
}, | |
"morgan": { | |
"current": "1.6.1", | |
"wanted": "1.6.1", | |
"latest": "1.7.0", | |
"location": "node_modules/morgan" | |
}, | |
"mysql": { | |
"current": "2.9.0", | |
"wanted": "2.9.0", | |
"latest": "2.11.1", | |
"location": "node_modules/mysql" | |
}, | |
"nf-atlas-client": { | |
"current": "2.1.0", | |
"wanted": "2.1.0", | |
"latest": "2.4.1", | |
"location": "node_modules/nf-atlas-client" | |
}, | |
"node-cache": { | |
"current": "2.1.1", | |
"wanted": "2.1.1", | |
"latest": "4.1.0", | |
"location": "node_modules/node-cache" | |
}, | |
"node-uuid": { | |
"current": "1.4.3", | |
"wanted": "1.4.3", | |
"latest": "1.4.7", | |
"location": "node_modules/node-uuid" | |
}, | |
"nodemon": { | |
"current": "1.8.1", | |
"wanted": "1.8.1", | |
"latest": "1.11.0", | |
"location": "node_modules/nodemon" | |
}, | |
"pg": { | |
"current": "4.4.3", | |
"wanted": "4.4.3", | |
"latest": "6.1.0", | |
"location": "node_modules/pg" | |
}, | |
"react": { | |
"current": "0.14.7", | |
"wanted": "0.14.7", | |
"latest": "15.3.2", | |
"location": "node_modules/react" | |
}, | |
"react-addons-create-fragment": { | |
"current": "0.14.7", | |
"wanted": "0.14.7", | |
"latest": "15.3.2", | |
"location": "node_modules/react-addons-create-fragment" | |
}, | |
"react-addons-perf": { | |
"current": "0.14.1", | |
"wanted": "0.14.1", | |
"latest": "15.3.2", | |
"location": "node_modules/react-addons-perf" | |
}, | |
"react-addons-test-utils": { | |
"current": "0.14.7", | |
"wanted": "0.14.7", | |
"latest": "15.3.2", | |
"location": "node_modules/react-addons-test-utils" | |
}, | |
"react-bootstrap": { | |
"current": "0.27.3", | |
"wanted": "0.27.3", | |
"latest": "0.30.5", | |
"location": "node_modules/react-bootstrap" | |
}, | |
"react-dnd": { | |
"current": "2.0.2", | |
"wanted": "2.0.2", | |
"latest": "2.1.4", | |
"location": "node_modules/react-dnd" | |
}, | |
"react-dnd-html5-backend": { | |
"current": "2.0.0", | |
"wanted": "2.0.0", | |
"latest": "2.1.2", | |
"location": "node_modules/react-dnd-html5-backend" | |
}, | |
"react-dom": { | |
"current": "0.14.7", | |
"wanted": "0.14.7", | |
"latest": "15.3.2", | |
"location": "node_modules/react-dom" | |
}, | |
"react-json-pretty": { | |
"current": "1.2.0", | |
"wanted": "1.2.0", | |
"latest": "1.2.1", | |
"location": "node_modules/react-json-pretty" | |
}, | |
"react-redux": { | |
"current": "3.0.0", | |
"wanted": "3.0.0", | |
"latest": "4.4.5", | |
"location": "node_modules/react-redux" | |
}, | |
"react-select": { | |
"current": "0.7.0", | |
"wanted": "git", | |
"latest": "git", | |
"location": "node_modules/react-select" | |
}, | |
"react-transform-catch-errors": { | |
"current": "1.0.1", | |
"wanted": "1.0.1", | |
"latest": "1.0.2", | |
"location": "node_modules/react-transform-catch-errors" | |
}, | |
"react-transform-hmr": { | |
"current": "1.0.1", | |
"wanted": "1.0.1", | |
"latest": "1.0.4", | |
"location": "node_modules/react-transform-hmr" | |
}, | |
"redux": { | |
"current": "3.0.0", | |
"wanted": "3.0.0", | |
"latest": "3.6.0", | |
"location": "node_modules/redux" | |
}, | |
"redux-immutablejs": { | |
"current": "0.0.6", | |
"wanted": "0.0.6", | |
"latest": "0.0.8", | |
"location": "node_modules/redux-immutablejs" | |
}, | |
"redux-logger": { | |
"current": "1.0.9", | |
"wanted": "1.0.9", | |
"latest": "2.7.0", | |
"location": "node_modules/redux-logger" | |
}, | |
"redux-thunk": { | |
"current": "1.0.0", | |
"wanted": "1.0.0", | |
"latest": "2.1.0", | |
"location": "node_modules/redux-thunk" | |
}, | |
"request": { | |
"current": "2.58.0", | |
"wanted": "2.58.0", | |
"latest": "2.75.0", | |
"location": "node_modules/request" | |
}, | |
"request-promise": { | |
"current": "0.4.2", | |
"wanted": "0.4.2", | |
"latest": "4.1.1", | |
"location": "node_modules/request-promise" | |
}, | |
"rewire": { | |
"current": "2.5.1", | |
"wanted": "2.5.1", | |
"latest": "2.5.2", | |
"location": "node_modules/rewire" | |
}, | |
"serve-static": { | |
"current": "1.10.2", | |
"wanted": "1.10.2", | |
"latest": "1.11.1", | |
"location": "node_modules/serve-static" | |
}, | |
"sinon": { | |
"current": "1.17.2", | |
"wanted": "1.17.2", | |
"latest": "1.17.6", | |
"location": "node_modules/sinon" | |
}, | |
"style-loader": { | |
"current": "0.12.4", | |
"wanted": "0.12.4", | |
"latest": "0.13.1", | |
"location": "node_modules/style-loader" | |
}, | |
"superagent": { | |
"current": "1.2.0", | |
"wanted": "1.2.0", | |
"latest": "2.3.0", | |
"location": "node_modules/superagent" | |
}, | |
"tap-difflet": { | |
"current": "0.4.0", | |
"wanted": "0.4.0", | |
"latest": "0.7.0", | |
"location": "node_modules/tap-difflet" | |
}, | |
"tape": { | |
"current": "4.6.0", | |
"wanted": "4.6.0", | |
"latest": "4.6.2", | |
"location": "node_modules/tape" | |
}, | |
"verror": { | |
"current": "1.6.1", | |
"wanted": "1.6.1", | |
"latest": "1.8.1", | |
"location": "node_modules/verror" | |
}, | |
"webpack": { | |
"current": "1.13.0", | |
"wanted": "1.13.0", | |
"latest": "1.13.2", | |
"location": "node_modules/webpack" | |
}, | |
"webpack-dev-middleware": { | |
"current": "1.4.0", | |
"wanted": "1.4.0", | |
"latest": "1.8.4", | |
"location": "node_modules/webpack-dev-middleware" | |
}, | |
"webpack-hot-middleware": { | |
"current": "2.6.0", | |
"wanted": "2.6.0", | |
"latest": "2.13.0", | |
"location": "node_modules/webpack-hot-middleware" | |
} | |
}) | |
function getVersionParts (semanticVersion : string) { | |
const [ major, minor, patch ] = semanticVersion.split('.') | |
return { major, minor, patch } | |
} | |
const packageNamesToUpdate = [ ] | |
for (const [packageName, packageInfo] of outdatedPackages) { | |
const { wanted, latest } = packageInfo | |
const wantedVersionParts = getVersionParts(wanted) | |
const latestVersionParts = getVersionParts(latest) | |
if (latestVersionParts.major === wantedVersionParts.major) | |
packageNamesToUpdate.push(packageName) | |
} | |
// packageNamesToUpdate.map(addLatestToPackageName) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment