babel-upgrade
Advanced tools
Comparing version 0.0.1 to 0.0.2
{ | ||
"name": "babel-upgrade", | ||
"version": "0.0.1", | ||
"version": "0.0.2", | ||
"description": "Upgrade tool for Babel", | ||
@@ -15,2 +15,3 @@ "bin": "./bin/babel-upgrade", | ||
"golden-fleece": "^1.0.3", | ||
"load-json-file": "^4.0.0", | ||
"read-pkg-up": "^3.0.0", | ||
@@ -17,0 +18,0 @@ "sort-keys": "^2.0.0", |
@@ -11,9 +11,10 @@ # babel-upgrade | ||
- [ ] Update `package.json`: `dependencies` and `devDependencies` to the "latest supported" version. | ||
- [x] Update `package.json`: `dependencies` and `devDependencies` to the "latest supported" version. | ||
- This includes doing all package renames | ||
- This includes upgrading the same package to the latest version | ||
- [ ] Update the babel config file(s). | ||
- [ ] `.babelrc` | ||
- [x] `.babelrc` | ||
- [ ] `.babelrc.js` | ||
- [ ] `package.json babel key` | ||
- [ ] handle `env` | ||
- [ ] Update test files that use babel directly (`babel-types`, `babel-core`) | ||
@@ -20,0 +21,0 @@ - Update all requires/imports |
const path = require('path'); | ||
const readPkgUp = require('read-pkg-up'); | ||
const sortKeys = require('sort-keys'); | ||
const loadJsonFile = require('load-json-file'); | ||
const writeJsonFile = require('write-json-file'); | ||
const upgradeDeps = require('./upgradeDeps'); | ||
const upgradeConfig = require('./upgradeConfig'); | ||
@@ -34,6 +36,25 @@ function getLatestVersion() { | ||
function updateBabelRC(config) { | ||
return upgradeConfig(config); | ||
} | ||
async function writeBabelRC(configPath) { | ||
let json; | ||
try { | ||
json = await loadJsonFile(configPath); | ||
} catch (e) { | ||
throw new Error(`babel-upgrade: ${configPath} does not contain a .babelrc file`); | ||
} | ||
json = updateBabelRC(json); | ||
await writeJsonFile(configPath, json, { detectIndent: true }); | ||
} | ||
module.exports = { | ||
updatePackageJSON, | ||
writePackageJSON, | ||
writeBabelRC, | ||
getLatestVersion | ||
}; |
@@ -230,7 +230,7 @@ const transformPlugins = { | ||
const oldPackages = Object.assign( | ||
const plugins = Object.assign({}, transformPlugins, syntaxPlugins, proposalPlugins); | ||
const packages = Object.assign( | ||
{}, | ||
transformPlugins, | ||
syntaxPlugins, | ||
proposalPlugins, | ||
plugins, | ||
presets, | ||
@@ -241,7 +241,9 @@ helpers, | ||
const latestPackages = Array.from(new Set(Object.values(oldPackages))); | ||
const latestPackages = Array.from(new Set(Object.values(packages))); | ||
module.exports = { | ||
oldPackages, | ||
packages, | ||
presets, | ||
plugins, | ||
latestPackages, | ||
}; |
@@ -1,2 +0,2 @@ | ||
const { oldPackages, latestPackages } = require('./packageData'); | ||
const { packages: oldPackages, latestPackages } = require('./packageData'); | ||
@@ -3,0 +3,0 @@ function upgradeDeps(dependencies, version) { |
Sorry, the diff of this file is not supported yet
39802
13
550
34
5
+ Addedload-json-file@^4.0.0