babel-upgrade
Advanced tools
Comparing version 0.0.8 to 0.0.9
{ | ||
"name": "babel-upgrade", | ||
"version": "0.0.8", | ||
"version": "0.0.9", | ||
"description": "Upgrade tool for Babel", | ||
@@ -15,2 +15,3 @@ "bin": "./bin/babel-upgrade", | ||
"dependencies": { | ||
"globby": "^8.0.1", | ||
"json5": "^0.5.1", | ||
@@ -17,0 +18,0 @@ "pify": "^3.0.0", |
@@ -9,5 +9,4 @@ # babel-upgrade | ||
> Update dependencies, config file, files that require babel directly | ||
> Update dependencies, config files, and maybe JavaScript files that require babel packages directly | ||
- [ ] auto run npm or yarn | ||
- [x] Update `package.json`: `dependencies` and `devDependencies` to the "latest supported" version. | ||
@@ -19,7 +18,10 @@ - This includes doing all package renames | ||
- [x] throw/warn if engines is < node 4 or current node is < 4? | ||
- [x] use `"babel-core": "^7.0.0-bridge-0"` if jest is a dependency | ||
- [x] add new `@babel/node` package if `babel-node` is used | ||
- [ ] log when replacing out preset-es2015,16,17,latest as FYI | ||
- [ ] if `babel-node` is used, import `@babel/node`? | ||
- [ ] Auto run npm or yarn after updating dependencies | ||
- [ ] Update the babel config file(s). | ||
- [x] `.babelrc` | ||
- [ ] `.babelrc.js` | ||
- [ ] `.babelrc.js` and other js files with a config like presets, `webpack.config.js` | ||
- [x] `package.json babel key` | ||
@@ -36,6 +38,7 @@ - [x] handle `env` | ||
- Update the use of the Babel API (plugins, integrations) | ||
- [ ] Misc files as we go (`karma.conf.js`, `mocha.opts`) | ||
- [ ] Modify misc files as we go (`karma.conf.js`, `mocha.opts`) | ||
- [ ] Add to the upgrade guide which parts are autofixable and the command (if we care enough to make this individually runnable too infrastructure wise) | ||
- [ ] May need to add a warning on any 3rd party plugins since they might not be compatible | ||
- [ ] later: work on node 4 | ||
- [ ] Handle the differences in plugins in v7 for default/loose/spec | ||
- [ ] Later: work on node 4 | ||
- [ ] Should certain parts be generic (replace the string `babel-register` with `@babel/register`)? Could be in a Makefile or somewhere else, but it's just find replace. | ||
@@ -42,0 +45,0 @@ |
const { updatePackageJSON } = require('../'); | ||
const upgradeDeps = require('../upgradeDeps'); | ||
const babelCoreFixture = require('../../fixtures/babel-core'); | ||
const jestFixture = require('../../fixtures/jest'); | ||
const depsFixture = require('../../fixtures/deps'); | ||
const depsFixtureEarlierBeta = require('../../fixtures/deps-earlier-beta.json'); | ||
const scriptsFixture = require('../../fixtures/script'); | ||
const scriptsMochaFixture = require('../../fixtures/scripts-mocha'); | ||
const scriptsBabelNodeFixture = require('../../fixtures/scripts-babel-node'); | ||
@@ -13,3 +15,4 @@ test('packages', () => { | ||
test('scripts', () => { | ||
expect(updatePackageJSON(scriptsFixture)).toMatchSnapshot(); | ||
expect(updatePackageJSON(scriptsMochaFixture)).toMatchSnapshot(); | ||
expect(updatePackageJSON(scriptsBabelNodeFixture)).toMatchSnapshot(); | ||
}); | ||
@@ -21,4 +24,8 @@ | ||
test('jest babel-core bridge', () => { | ||
expect(updatePackageJSON(jestFixture)).toMatchSnapshot(); | ||
}); | ||
test('packages - earlier v7', () => { | ||
expect(upgradeDeps(depsFixtureEarlierBeta, "7.0.0-beta.39")).toMatchSnapshot(); | ||
}); |
@@ -38,7 +38,26 @@ const path = require('path'); | ||
if (pkg.scripts) { | ||
pkg.scripts = upgradeScripts(pkg.scripts); | ||
if (Object.values(pkg.scripts).some(s => s.includes('babel-node'))) { | ||
if (pkg.devDependencies) { | ||
pkg.devDependencies["@babel/node"] = getLatestVersion(); | ||
} | ||
} | ||
} | ||
if (pkg.devDependencies) { | ||
pkg.devDependencies = sortKeys(upgradeDeps( | ||
pkg.devDependencies = upgradeDeps( | ||
pkg.devDependencies, | ||
getLatestVersion() | ||
)); | ||
); | ||
const devDeps = Object.keys(pkg.devDependencies); | ||
// use babel-bridge for jest | ||
// maybe should do this for other tools? | ||
if (devDeps.includes("jest") && !devDeps.includes("babel-core")) { | ||
pkg.devDependencies["babel-core"] = "^7.0.0-bridge.0"; | ||
} | ||
pkg.devDependencies = sortKeys(pkg.devDependencies); | ||
} | ||
@@ -53,6 +72,2 @@ | ||
if (pkg.scripts) { | ||
pkg.scripts = upgradeScripts(pkg.scripts); | ||
} | ||
return pkg; | ||
@@ -91,3 +106,3 @@ } | ||
if (json) { | ||
console.log("Updating ./.babelrc config"); | ||
console.log(`Updating .babelrc config at ${configPath}`); | ||
json = upgradeConfig(json); | ||
@@ -94,0 +109,0 @@ await writeJsonFile(configPath, json, { detectIndent: true }); |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
51231
20
731
53
8
+ Addedglobby@^8.0.1
+ Added@mrmlnc/readdir-enhanced@2.2.1(transitive)
+ Added@nodelib/fs.stat@1.1.3(transitive)
+ Addedarr-diff@4.0.0(transitive)
+ Addedarr-flatten@1.1.0(transitive)
+ Addedarr-union@3.1.0(transitive)
+ Addedarray-union@1.0.2(transitive)
+ Addedarray-uniq@1.0.3(transitive)
+ Addedarray-unique@0.3.2(transitive)
+ Addedarrify@1.0.1(transitive)
+ Addedassign-symbols@1.0.0(transitive)
+ Addedatob@2.1.2(transitive)
+ Addedbalanced-match@1.0.2(transitive)
+ Addedbase@0.11.2(transitive)
+ Addedbrace-expansion@1.1.11(transitive)
+ Addedbraces@2.3.2(transitive)
+ Addedcache-base@1.0.1(transitive)
+ Addedcall-me-maybe@1.0.2(transitive)
+ Addedclass-utils@0.3.6(transitive)
+ Addedcollection-visit@1.0.0(transitive)
+ Addedcomponent-emitter@1.3.1(transitive)
+ Addedconcat-map@0.0.1(transitive)
+ Addedcopy-descriptor@0.1.1(transitive)
+ Addeddebug@2.6.9(transitive)
+ Addeddecode-uri-component@0.2.2(transitive)
+ Addeddefine-property@0.2.51.0.02.0.2(transitive)
+ Addeddir-glob@2.0.0(transitive)
+ Addedexpand-brackets@2.1.4(transitive)
+ Addedextend-shallow@2.0.13.0.2(transitive)
+ Addedextglob@2.0.4(transitive)
+ Addedfast-glob@2.2.7(transitive)
+ Addedfill-range@4.0.0(transitive)
+ Addedfor-in@1.0.2(transitive)
+ Addedfragment-cache@0.2.1(transitive)
+ Addedfs.realpath@1.0.0(transitive)
+ Addedget-value@2.0.6(transitive)
+ Addedglob@7.2.3(transitive)
+ Addedglob-parent@3.1.0(transitive)
+ Addedglob-to-regexp@0.3.0(transitive)
+ Addedglobby@8.0.2(transitive)
+ Addedhas-value@0.3.11.0.0(transitive)
+ Addedhas-values@0.1.41.0.0(transitive)
+ Addedignore@3.3.10(transitive)
+ Addedinflight@1.0.6(transitive)
+ Addedinherits@2.0.4(transitive)
+ Addedis-accessor-descriptor@1.0.1(transitive)
+ Addedis-buffer@1.1.6(transitive)
+ Addedis-data-descriptor@1.0.1(transitive)
+ Addedis-descriptor@0.1.71.0.3(transitive)
+ Addedis-extendable@0.1.11.0.1(transitive)
+ Addedis-extglob@2.1.1(transitive)
+ Addedis-glob@3.1.04.0.3(transitive)
+ Addedis-number@3.0.0(transitive)
+ Addedis-plain-object@2.0.4(transitive)
+ Addedis-windows@1.0.2(transitive)
+ Addedisarray@1.0.0(transitive)
+ Addedisobject@2.1.03.0.1(transitive)
+ Addedkind-of@3.2.24.0.06.0.3(transitive)
+ Addedmap-cache@0.2.2(transitive)
+ Addedmap-visit@1.0.0(transitive)
+ Addedmerge2@1.4.1(transitive)
+ Addedmicromatch@3.1.10(transitive)
+ Addedminimatch@3.1.2(transitive)
+ Addedmixin-deep@1.3.2(transitive)
+ Addedms@2.0.0(transitive)
+ Addednanomatch@1.2.13(transitive)
+ Addedobject-copy@0.1.0(transitive)
+ Addedobject-visit@1.0.1(transitive)
+ Addedobject.pick@1.3.0(transitive)
+ Addedonce@1.4.0(transitive)
+ Addedpascalcase@0.1.1(transitive)
+ Addedpath-dirname@1.0.2(transitive)
+ Addedpath-is-absolute@1.0.1(transitive)
+ Addedposix-character-classes@0.1.1(transitive)
+ Addedregex-not@1.0.2(transitive)
+ Addedrepeat-element@1.1.4(transitive)
+ Addedrepeat-string@1.6.1(transitive)
+ Addedresolve-url@0.2.1(transitive)
+ Addedret@0.1.15(transitive)
+ Addedsafe-regex@1.1.0(transitive)
+ Addedset-value@2.0.1(transitive)
+ Addedslash@1.0.0(transitive)
+ Addedsnapdragon@0.8.2(transitive)
+ Addedsnapdragon-node@2.1.1(transitive)
+ Addedsnapdragon-util@3.0.1(transitive)
+ Addedsource-map@0.5.7(transitive)
+ Addedsource-map-resolve@0.5.3(transitive)
+ Addedsource-map-url@0.4.1(transitive)
+ Addedsplit-string@3.1.0(transitive)
+ Addedstatic-extend@0.1.2(transitive)
+ Addedto-object-path@0.3.0(transitive)
+ Addedto-regex@3.0.2(transitive)
+ Addedto-regex-range@2.1.1(transitive)
+ Addedunion-value@1.0.1(transitive)
+ Addedunset-value@1.0.0(transitive)
+ Addedurix@0.1.0(transitive)
+ Addeduse@3.1.1(transitive)
+ Addedwrappy@1.0.2(transitive)