From c796c4922ddba7e5f72a7526b9f78b5440b3a936 Mon Sep 17 00:00:00 2001 From: Jean-Michel FRANCOIS Date: Mon, 29 May 2017 17:38:49 +0200 Subject: [PATCH 1/2] chore: add script to manage version --- package.json | 1 + version.js | 223 +++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 224 insertions(+) create mode 100755 version.js diff --git a/package.json b/package.json index a6f43e036c4..add22f14d8d 100644 --- a/package.json +++ b/package.json @@ -8,6 +8,7 @@ }, "scripts": { "postinstall": "lerna clean --yes && lerna exec -- yarn --pure-lockfile --no-progress --mutex network && ./copylibs.js", + "update-versions": "./version.js", "build": "lerna exec --ignore=generator-talend -- yarn run prepublish && ./copylibs.js", "build-cmf": "lerna exec --scope=*cmf -- yarn run prepublish && ./copylibs.js --scope=cmf", "build-components": "lerna exec --scope=*components -- yarn run prepublish && ./copylibs.js --scope=components", diff --git a/version.js b/version.js new file mode 100755 index 00000000000..50ba307b2af --- /dev/null +++ b/version.js @@ -0,0 +1,223 @@ +#!/usr/bin/env node + +const fs = require('fs'); +const path = require('path'); +const cpx = require('cpx'); +const program = require('commander'); + +program + .version('0.0.1') + .option('-d, --debug', 'display more info') + .option('-q, --quiet', 'display nothing') + .option('-p, --path [value]', 'path of the package.json to update') + .option('-s, --stack [value]', 'stack version used in combination with -p') + .option('-f, --force') + .parse(process.argv); + +const REACT_VERSION = '15.5.4'; +const JEST_VERSION = '20.0.3'; + +const VERSIONS = { + // deps + 'bootstrap-sass': '3.3.7', + 'bson-objectid': '1.1.5', + classnames: '2.2.5', + keycode: '2.1.9', + lodash: '4.17.4', + immutable: '3.8.1', + invariant: '2.2.2', + react: REACT_VERSION, + 'react-addons-test-utils': '15.5.1', + 'react-addons-css-transition-group': '15.5.2', + 'react-bootstrap': '0.31.0', + 'react-dom': REACT_VERSION, + 'react-i18next': '^1.8.0', + 'react-redux': '5.0.5', + 'react-router': '3.0.5', + 'react-router-redux': '4.0.8', + 'react-test-renderer': REACT_VERSION, + 'react-virtualized': '^9.1.0', + reselect: '^2.5.4', + + redux: '3.6.0', + 'redux-batched-actions': '0.2.0', + 'redux-logger': '3.0.6', + 'redux-mock-store': '1.2.3', + 'redux-thunk': '2.2.0', + uuid: '3.0.1', // prefer bson-objectid + + // dev deps + '@kadira/react-storybook-addon-info': '^3.3.0', + '@kadira/storybook': '^2.35.0', + 'babel-cli': '6.24.1', + 'babel-core': '6.24.1', + 'babel-eslint': '7.2.3', + 'babel-jest': JEST_VERSION, + 'babel-loader': '6.2.5', + 'babel-plugin-transform-class-properties': '6.18.0', + 'babel-plugin-transform-object-rest-spread': '6.16.0', + 'babel-preset-es2015': '6.14.0', + 'babel-preset-react': '6.11.1', + cpx: '1.5.0', + enzyme: '^2.7.1', + eslint: '^3.4.0', + 'eslint-config-airbnb': '^11.0.0', + 'eslint-plugin-import': '^1.14.0', + 'eslint-plugin-jsx-a11y': '^2.2.1', + 'eslint-plugin-react': '^6.2.0', + jest: JEST_VERSION, + 'jest-cli': JEST_VERSION, + 'react-storybook-cmf': '^0.1.3', + 'react-stub-context': '^0.7.0', + rimraf: '^2.6.1', + storyshots: '3.2.2', + + // webpack + 'copy-webpack-plugin': '4.0.1', + 'css-loader': '0.28.2', + 'file-loader': '^0.9.0', + 'node-sass': '4.5.3', + 'postcss-loader': '^1.3.1', + 'sass-loader': '6.0.5', + 'style-loader': '^0.13.1', + 'url-loader': '^0.5.7', + 'webpack-bundle-analyzer': '^2.8.2', + 'webpack-dashboard': '^0.4.0', +}; + +const WEBPACK_2_VERSIONS = { + 'extract-text-webpack-plugin': '2.1.0', + webpack: '^2.5.1', + 'webpack-dev-server': '^2.4.5', +}; + +const WEBPACK_1_VERSIONS = { + 'extract-text-webpack-plugin': '^1.0.1', + webpack: '^1.14.0', + 'webpack-dev-server': '^1.16.5', +}; + +let files = [ + './packages/cmf/package.json', + './packages/components/package.json', + './packages/containers/package.json', + './packages/forms/package.json', + './packages/generator/package.json', + './packages/icons/package.json', + './packages/logging/package.json', + './packages/theme/package.json', +]; + +if (program.path) { + files = [program.path]; + const stack_version = program.stack || require('./lerna.json').version; + if (program.debug) { + console.log(`use stack version ${stack_version}`); + } + const STACK_VERSION = { + 'bootstrap-talend-theme': stack_version, + 'react-cmf': stack_version, + 'react-talend-components': stack_version, + 'react-talend-containers': stack_version, + 'react-talend-forms': stack_version, + 'talend-icons': stack_version, + 'talend-log': stack_version, + }; + Object.assign( + VERSIONS, + STACK_VERSION + ); +} + +if (program.debug) { + console.log(`will update ${files}`); +} + +function getWebpackMajorVersion(source) { + return (source.webpack || '').replace('^', '').split('.')[0]; +} + + +function check(source, dep, version) { + let modified = false; + if (source && source[dep] && source[dep] !== version) { + if (!program.quiet) { + console.log(`update ${dep}: '${version}' from ${source[dep]}`); + } + source[dep] = version; + modified = true; + } + return modified; +} + +function checkAll(source, dep) { + const version = VERSIONS[dep]; + const devDeps = source.devDependencies; + const deps = source.dependencies; + const peer = source.peerDependencies; + const isModDevDeps = check(devDeps, dep, version); + const isModDeps = check(deps, dep, version); + const isModPeers = check(peer, dep, version); + if (isModDevDeps || isModDeps || isModPeers) { + source.modified = true; + } +} + +function save(ppath, data) { + if (!program.quiet) { + console.log(`save ${ppath}`); + } + fs.open(ppath, 'w', function(err, fd) { + if (err) { + throw 'error opening file: ' + err; + } + + fs.write(fd, data, 0, data.length, null, function(err) { + if (err) { + throw 'error writing file: ' + err; + } + fs.close(fd, function() { + if (!program.quiet) { + console.log('file written'); + } + }) + }); + }); +} + +files.forEach((ppath) => { + const packageJSON = require(ppath); + if (!program.quiet) { + console.log(`=== check ${packageJSON.name} ===`); + } + + if (packageJSON.devDependencies && packageJSON.devDependencies.webpack) { + const webpack = getWebpackMajorVersion(packageJSON.devDependencies); + if (webpack === '1') { + Object.assign( + VERSIONS, + WEBPACK_1_VERSIONS + ); + } else { + Object.assign( + VERSIONS, + WEBPACK_2_VERSIONS + ); + } + } + + Object.keys(VERSIONS).forEach((dep) => { + checkAll(packageJSON, dep); + }); + if (packageJSON.modified || program.force) { + delete packageJSON.modified; + save(ppath, JSON.stringify(packageJSON, null, 2) + '\n'); + const yarnLock = path.join(path.dirname(ppath), 'yarn.lock'); + if (fs.existsSync(yarnLock)) { + if (!program.quite) { + console.log(`delete ${yarnLock}`); + } + fs.unlink(yarnLock); + } + } +}); From dd92a7f71f2630091cbeff8d66ad3deb314da7f4 Mon Sep 17 00:00:00 2001 From: travis Date: Mon, 29 May 2017 15:49:01 +0000 Subject: [PATCH 2/2] test(ci): update code style outputs --- output/cmf.eslint.txt | 2 +- output/components.eslint.txt | 2 +- output/components.sasslint.txt | 2 +- output/containers.eslint.txt | 2 +- output/forms.eslint.txt | 2 +- output/forms.sasslint.txt | 2 +- output/logging.eslint.txt | 2 +- output/theme.sasslint.txt | 2 +- 8 files changed, 8 insertions(+), 8 deletions(-) diff --git a/output/cmf.eslint.txt b/output/cmf.eslint.txt index 40820646050..39424628c3a 100644 --- a/output/cmf.eslint.txt +++ b/output/cmf.eslint.txt @@ -1,7 +1,7 @@ Lerna v2.0.0-beta.36 Scoping to packages that match 'react-cmf' -> react-cmf@0.76.0 lint:es /home/travis/build/Talend/ui/packages/cmf +> react-cmf@0.77.0 lint:es /home/travis/build/Talend/ui/packages/cmf > eslint --config .eslintrc --ext .js src The react/require-extension rule is deprecated. Please use the import/extensions rule from eslint-plugin-import instead. diff --git a/output/components.eslint.txt b/output/components.eslint.txt index 927f18c8dac..0e683ca9129 100644 --- a/output/components.eslint.txt +++ b/output/components.eslint.txt @@ -1,7 +1,7 @@ Lerna v2.0.0-beta.36 Scoping to packages that match 'react-talend-components' -> react-talend-components@0.76.0 lint:es /home/travis/build/Talend/ui/packages/components +> react-talend-components@0.77.0 lint:es /home/travis/build/Talend/ui/packages/components > eslint --config .eslintrc src diff --git a/output/components.sasslint.txt b/output/components.sasslint.txt index 22fc9ca63ee..9b5c2130aee 100644 --- a/output/components.sasslint.txt +++ b/output/components.sasslint.txt @@ -1,6 +1,6 @@ Lerna v2.0.0-beta.36 Scoping to packages that match 'react-talend-components' -> react-talend-components@0.76.0 lint:style /home/travis/build/Talend/ui/packages/components +> react-talend-components@0.77.0 lint:style /home/travis/build/Talend/ui/packages/components > sass-lint -v -q diff --git a/output/containers.eslint.txt b/output/containers.eslint.txt index ea776b3bbbd..eb65990763c 100644 --- a/output/containers.eslint.txt +++ b/output/containers.eslint.txt @@ -1,7 +1,7 @@ Lerna v2.0.0-beta.36 Scoping to packages that match 'react-talend-containers' -> react-talend-containers@0.76.0 lint:es /home/travis/build/Talend/ui/packages/containers +> react-talend-containers@0.77.0 lint:es /home/travis/build/Talend/ui/packages/containers > eslint --config .eslintrc src The react/require-extension rule is deprecated. Please use the import/extensions rule from eslint-plugin-import instead. diff --git a/output/forms.eslint.txt b/output/forms.eslint.txt index c34d5fb3743..38f0c97cfc5 100755 --- a/output/forms.eslint.txt +++ b/output/forms.eslint.txt @@ -1,7 +1,7 @@ Lerna v2.0.0-beta.36 Scoping to packages that match 'react-talend-forms' -> react-talend-forms@0.76.0 lint:es /home/travis/build/Talend/ui/packages/forms +> react-talend-forms@0.77.0 lint:es /home/travis/build/Talend/ui/packages/forms > eslint --config .eslintrc src The react/require-extension rule is deprecated. Please use the import/extensions rule from eslint-plugin-import instead. diff --git a/output/forms.sasslint.txt b/output/forms.sasslint.txt index 5fe0b3e1a34..34ff8982d88 100644 --- a/output/forms.sasslint.txt +++ b/output/forms.sasslint.txt @@ -1,6 +1,6 @@ Lerna v2.0.0-beta.36 Scoping to packages that match 'react-talend-forms' -> react-talend-forms@0.76.0 lint:style /home/travis/build/Talend/ui/packages/forms +> react-talend-forms@0.77.0 lint:style /home/travis/build/Talend/ui/packages/forms > sass-lint -v -q diff --git a/output/logging.eslint.txt b/output/logging.eslint.txt index 15a7a97afcc..9b7352cc017 100644 --- a/output/logging.eslint.txt +++ b/output/logging.eslint.txt @@ -1,7 +1,7 @@ Lerna v2.0.0-beta.36 Scoping to packages that match 'talend-log' -> talend-log@0.76.0 lint:es /home/travis/build/Talend/ui/packages/logging +> talend-log@0.77.0 lint:es /home/travis/build/Talend/ui/packages/logging > eslint --config .eslintrc --ext .js src diff --git a/output/theme.sasslint.txt b/output/theme.sasslint.txt index 166237084f6..359011d158e 100644 --- a/output/theme.sasslint.txt +++ b/output/theme.sasslint.txt @@ -1,7 +1,7 @@ Lerna v2.0.0-beta.36 Scoping to packages that match 'bootstrap-talend-theme' -> bootstrap-talend-theme@0.76.0 lint:style /home/travis/build/Talend/ui/packages/theme +> bootstrap-talend-theme@0.77.0 lint:style /home/travis/build/Talend/ui/packages/theme > sass-lint -q -v