Updates for handling codemods folder (#6279)
* add codemod folder to gitignore, update build/test scripts to handle codemods, lerna config
This commit is contained in:
parent
5a2a5fb411
commit
c821d3a591
2
.gitignore
vendored
2
.gitignore
vendored
@ -29,3 +29,5 @@ package-lock.json
|
|||||||
/babel.sublime-workspace
|
/babel.sublime-workspace
|
||||||
packages/babel-standalone/babel.js
|
packages/babel-standalone/babel.js
|
||||||
packages/babel-standalone/babel.min.js
|
packages/babel-standalone/babel.min.js
|
||||||
|
/codemods/*/lib
|
||||||
|
/codemods/*/node_modules
|
||||||
|
|||||||
77
Gulpfile.js
77
Gulpfile.js
@ -9,9 +9,9 @@ const watch = require("gulp-watch");
|
|||||||
const gutil = require("gulp-util");
|
const gutil = require("gulp-util");
|
||||||
const gulp = require("gulp");
|
const gulp = require("gulp");
|
||||||
const path = require("path");
|
const path = require("path");
|
||||||
|
const merge = require("merge-stream");
|
||||||
|
|
||||||
const base = path.join(__dirname, "packages");
|
const sources = ["codemods", "packages"];
|
||||||
const scripts = "./packages/*/src/**/*.js";
|
|
||||||
|
|
||||||
function swapSrcWithLib(srcPath) {
|
function swapSrcWithLib(srcPath) {
|
||||||
const parts = srcPath.split(path.sep);
|
const parts = srcPath.split(path.sep);
|
||||||
@ -19,43 +19,54 @@ function swapSrcWithLib(srcPath) {
|
|||||||
return parts.join(path.sep);
|
return parts.join(path.sep);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function getGlobFromSource(source) {
|
||||||
|
return `./${source}/*/src/**/*.js`;
|
||||||
|
}
|
||||||
|
|
||||||
gulp.task("default", ["build"]);
|
gulp.task("default", ["build"]);
|
||||||
|
|
||||||
gulp.task("build", function() {
|
gulp.task("build", function() {
|
||||||
return gulp
|
return merge(
|
||||||
.src(scripts, { base: base })
|
sources.map(source => {
|
||||||
.pipe(
|
const base = path.join(__dirname, source);
|
||||||
plumber({
|
|
||||||
errorHandler: function(err) {
|
return gulp
|
||||||
gutil.log(err.stack);
|
.src(getGlobFromSource(source), { base: base })
|
||||||
},
|
.pipe(
|
||||||
})
|
plumber({
|
||||||
)
|
errorHandler: function(err) {
|
||||||
.pipe(
|
gutil.log(err.stack);
|
||||||
newer({
|
},
|
||||||
dest: base,
|
})
|
||||||
map: swapSrcWithLib,
|
)
|
||||||
})
|
.pipe(
|
||||||
)
|
newer({
|
||||||
.pipe(
|
dest: base,
|
||||||
through.obj(function(file, enc, callback) {
|
map: swapSrcWithLib,
|
||||||
gutil.log("Compiling", "'" + chalk.cyan(file.relative) + "'...");
|
})
|
||||||
callback(null, file);
|
)
|
||||||
})
|
.pipe(
|
||||||
)
|
through.obj(function(file, enc, callback) {
|
||||||
.pipe(babel())
|
gutil.log("Compiling", "'" + chalk.cyan(file.relative) + "'...");
|
||||||
.pipe(
|
callback(null, file);
|
||||||
through.obj(function(file, enc, callback) {
|
})
|
||||||
// Passing 'file.relative' because newer() above uses a relative path and this keeps it consistent.
|
)
|
||||||
file.path = path.resolve(file.base, swapSrcWithLib(file.relative));
|
.pipe(babel())
|
||||||
callback(null, file);
|
.pipe(
|
||||||
})
|
through.obj(function(file, enc, callback) {
|
||||||
)
|
// Passing 'file.relative' because newer() above uses a relative
|
||||||
.pipe(gulp.dest(base));
|
// path and this keeps it consistent.
|
||||||
|
file.path = path.resolve(file.base, swapSrcWithLib(file.relative));
|
||||||
|
callback(null, file);
|
||||||
|
})
|
||||||
|
)
|
||||||
|
.pipe(gulp.dest(base));
|
||||||
|
})
|
||||||
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
gulp.task("watch", ["build"], function() {
|
gulp.task("watch", ["build"], function() {
|
||||||
watch(scripts, { debounceDelay: 200 }, function() {
|
watch(sources.map(getGlobFromSource), { debounceDelay: 200 }, function() {
|
||||||
gulp.start("build");
|
gulp.start("build");
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
55
Makefile
55
Makefile
@ -5,10 +5,12 @@ export NODE_ENV = test
|
|||||||
# Fix color output until TravisCI fixes https://github.com/travis-ci/travis-ci/issues/7967
|
# Fix color output until TravisCI fixes https://github.com/travis-ci/travis-ci/issues/7967
|
||||||
export FORCE_COLOR = true
|
export FORCE_COLOR = true
|
||||||
|
|
||||||
|
SOURCES = packages codemods
|
||||||
|
|
||||||
.PHONY: build build-dist watch lint fix clean test-clean test-only test test-ci publish bootstrap
|
.PHONY: build build-dist watch lint fix clean test-clean test-only test test-ci publish bootstrap
|
||||||
|
|
||||||
build: clean
|
build: clean
|
||||||
rm -rf packages/*/lib
|
make clean-lib
|
||||||
./node_modules/.bin/gulp build
|
./node_modules/.bin/gulp build
|
||||||
ifneq ($(BABEL_ENV), "cov")
|
ifneq ($(BABEL_ENV), "cov")
|
||||||
make build-standalone
|
make build-standalone
|
||||||
@ -25,17 +27,17 @@ build-dist: build
|
|||||||
node scripts/generate-babel-types-docs.js
|
node scripts/generate-babel-types-docs.js
|
||||||
|
|
||||||
watch: clean
|
watch: clean
|
||||||
rm -rf packages/*/lib
|
make clean-lib
|
||||||
BABEL_ENV=development ./node_modules/.bin/gulp watch
|
BABEL_ENV=development ./node_modules/.bin/gulp watch
|
||||||
|
|
||||||
lint:
|
lint:
|
||||||
./node_modules/.bin/eslint scripts packages *.js --format=codeframe --rulesdir="./eslint_rules"
|
./node_modules/.bin/eslint scripts $(SOURCES) *.js --format=codeframe --rulesdir="./eslint_rules"
|
||||||
|
|
||||||
flow:
|
flow:
|
||||||
./node_modules/.bin/flow check --strip-root
|
./node_modules/.bin/flow check --strip-root
|
||||||
|
|
||||||
fix:
|
fix:
|
||||||
./node_modules/.bin/eslint scripts packages *.js --format=codeframe --fix --rulesdir="./eslint_rules"
|
./node_modules/.bin/eslint scripts $(SOURCES) *.js --format=codeframe --fix --rulesdir="./eslint_rules"
|
||||||
|
|
||||||
clean: test-clean
|
clean: test-clean
|
||||||
rm -rf packages/babel-polyfill/browser*
|
rm -rf packages/babel-polyfill/browser*
|
||||||
@ -46,16 +48,8 @@ clean: test-clean
|
|||||||
rm -rf packages/*/npm-debug*
|
rm -rf packages/*/npm-debug*
|
||||||
|
|
||||||
test-clean:
|
test-clean:
|
||||||
rm -rf packages/*/test/tmp
|
$(foreach source, $(SOURCES), \
|
||||||
rm -rf packages/*/test-fixtures.json
|
$(call clean-source-test, $(source)))
|
||||||
|
|
||||||
clean-all:
|
|
||||||
rm -rf packages/*/lib
|
|
||||||
rm -rf node_modules
|
|
||||||
rm -rf packages/*/node_modules
|
|
||||||
rm -rf package-lock.json
|
|
||||||
rm -rf packages/*/package-lock.json
|
|
||||||
make clean
|
|
||||||
|
|
||||||
test-only:
|
test-only:
|
||||||
./scripts/test.sh
|
./scripts/test.sh
|
||||||
@ -75,7 +69,7 @@ test-ci-coverage:
|
|||||||
|
|
||||||
publish:
|
publish:
|
||||||
git pull --rebase
|
git pull --rebase
|
||||||
rm -rf packages/*/lib
|
make clean-lib
|
||||||
BABEL_ENV=production make build-dist
|
BABEL_ENV=production make build-dist
|
||||||
make test
|
make test
|
||||||
# not using lerna independent mode atm, so only update packages that have changed since we use ^
|
# not using lerna independent mode atm, so only update packages that have changed since we use ^
|
||||||
@ -90,3 +84,34 @@ bootstrap:
|
|||||||
make build
|
make build
|
||||||
cd packages/babel-runtime; \
|
cd packages/babel-runtime; \
|
||||||
node scripts/build-dist.js
|
node scripts/build-dist.js
|
||||||
|
|
||||||
|
clean-lib:
|
||||||
|
$(foreach source, $(SOURCES), \
|
||||||
|
$(call clean-source-lib, $(source)))
|
||||||
|
|
||||||
|
clean-all:
|
||||||
|
rm -rf node_modules
|
||||||
|
rm -rf package-lock.json
|
||||||
|
|
||||||
|
$(foreach source, $(SOURCES), \
|
||||||
|
$(call clean-source-all, $(source)))
|
||||||
|
|
||||||
|
make clean
|
||||||
|
|
||||||
|
define clean-source-lib
|
||||||
|
rm -rf $(1)/*/lib
|
||||||
|
|
||||||
|
endef
|
||||||
|
|
||||||
|
define clean-source-test
|
||||||
|
rm -rf $(1)/*/test/tmp
|
||||||
|
rm -rf $(1)/*/test-fixtures.json
|
||||||
|
|
||||||
|
endef
|
||||||
|
|
||||||
|
define clean-source-all
|
||||||
|
rm -rf $(1)/*/lib
|
||||||
|
rm -rf $(1)/*/node_modules
|
||||||
|
rm -rf $(1)/*/package-lock.json
|
||||||
|
|
||||||
|
endef
|
||||||
|
|||||||
@ -1,37 +0,0 @@
|
|||||||
"use strict";
|
|
||||||
|
|
||||||
exports.__esModule = true;
|
|
||||||
|
|
||||||
exports.default = function (babel) {
|
|
||||||
const {
|
|
||||||
types: t
|
|
||||||
} = babel;
|
|
||||||
return {
|
|
||||||
inherits: _babelPluginSyntaxOptionalCatchBinding2.default,
|
|
||||||
visitor: {
|
|
||||||
CatchClause(path) {
|
|
||||||
if (path.node.param === null || !t.isIdentifier(path.node.param)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
const binding = path.scope.getOwnBinding(path.node.param.name);
|
|
||||||
|
|
||||||
if (binding.constantViolations.length > 0) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!binding.referenced) {
|
|
||||||
const paramPath = path.get("param");
|
|
||||||
paramPath.remove();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
var _babelPluginSyntaxOptionalCatchBinding = require("babel-plugin-syntax-optional-catch-binding");
|
|
||||||
|
|
||||||
var _babelPluginSyntaxOptionalCatchBinding2 = _interopRequireDefault(_babelPluginSyntaxOptionalCatchBinding);
|
|
||||||
|
|
||||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
||||||
@ -9,9 +9,9 @@
|
|||||||
"babel-plugin"
|
"babel-plugin"
|
||||||
],
|
],
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"babel-plugin-syntax-optional-catch-binding": "7.0.0-beta.0"
|
"babel-plugin-syntax-optional-catch-binding": "7.0.0-beta.1"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"babel-helper-plugin-test-runner": "7.0.0-beta.0"
|
"babel-helper-plugin-test-runner": "7.0.0-beta.1"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,3 +0,0 @@
|
|||||||
{
|
|
||||||
"plugins": ["transform-remove-unused-catch-binding"]
|
|
||||||
}
|
|
||||||
@ -1,3 +1,4 @@
|
|||||||
{
|
{
|
||||||
|
"plugins": ["../../../../lib"],
|
||||||
"throws": "Duplicate declaration \"e\""
|
"throws": "Duplicate declaration \"e\""
|
||||||
}
|
}
|
||||||
|
|||||||
@ -0,0 +1,3 @@
|
|||||||
|
{
|
||||||
|
"plugins": ["../../../../lib"]
|
||||||
|
}
|
||||||
@ -0,0 +1,3 @@
|
|||||||
|
{
|
||||||
|
"plugins": ["../../../../lib"]
|
||||||
|
}
|
||||||
@ -0,0 +1,3 @@
|
|||||||
|
{
|
||||||
|
"plugins": ["../../../../lib"]
|
||||||
|
}
|
||||||
@ -0,0 +1,3 @@
|
|||||||
|
{
|
||||||
|
"plugins": ["../../../../lib"]
|
||||||
|
}
|
||||||
@ -0,0 +1,3 @@
|
|||||||
|
{
|
||||||
|
"plugins": ["../../../../lib"]
|
||||||
|
}
|
||||||
@ -0,0 +1,3 @@
|
|||||||
|
{
|
||||||
|
"plugins": ["../../../../lib"]
|
||||||
|
}
|
||||||
@ -0,0 +1,3 @@
|
|||||||
|
{
|
||||||
|
"plugins": ["../../../../lib"]
|
||||||
|
}
|
||||||
@ -0,0 +1,3 @@
|
|||||||
|
{
|
||||||
|
"plugins": ["../../../../lib"]
|
||||||
|
}
|
||||||
@ -0,0 +1,3 @@
|
|||||||
|
{
|
||||||
|
"plugins": ["../../../../lib"]
|
||||||
|
}
|
||||||
@ -0,0 +1,3 @@
|
|||||||
|
{
|
||||||
|
"plugins": ["../../../../lib"]
|
||||||
|
}
|
||||||
@ -18,8 +18,13 @@
|
|||||||
"publish": {
|
"publish": {
|
||||||
"ignore": [
|
"ignore": [
|
||||||
"*.md",
|
"*.md",
|
||||||
"test/**"
|
"test/**",
|
||||||
|
"codemods/**"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
|
"packages": [
|
||||||
|
"packages/*",
|
||||||
|
"codemods/*"
|
||||||
|
]
|
||||||
}
|
}
|
||||||
|
|||||||
@ -41,6 +41,7 @@
|
|||||||
"lerna-changelog": "^0.5.0",
|
"lerna-changelog": "^0.5.0",
|
||||||
"lint-staged": "^4.0.4",
|
"lint-staged": "^4.0.4",
|
||||||
"lodash": "^4.2.0",
|
"lodash": "^4.2.0",
|
||||||
|
"merge-stream": "^1.0.1",
|
||||||
"mocha": "^3.0.0",
|
"mocha": "^3.0.0",
|
||||||
"nyc": "^11.0.3",
|
"nyc": "^11.0.3",
|
||||||
"output-file-sync": "^2.0.0",
|
"output-file-sync": "^2.0.0",
|
||||||
|
|||||||
@ -3,18 +3,22 @@ set -e
|
|||||||
|
|
||||||
TEST_DIRS=""
|
TEST_DIRS=""
|
||||||
|
|
||||||
for f in packages/*; do
|
sources=("packages" "codemods")
|
||||||
if [ -n "$TEST_ONLY" ] && [[ `basename $f` != *"$TEST_ONLY"* ]]; then
|
|
||||||
continue
|
|
||||||
fi
|
|
||||||
# Exclude babel-standalone from coverage runs
|
|
||||||
if [ "$TEST_TYPE" = "cov" ] && [ `basename $f` = 'babel-standalone' ]; then
|
|
||||||
continue
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ -d "$f/test" ]; then
|
for source in "${sources[@]}"; do
|
||||||
TEST_DIRS="$f/test $TEST_DIRS"
|
for f in $source/*; do
|
||||||
fi
|
if [ -n "$TEST_ONLY" ] && [[ `basename $f` != *"$TEST_ONLY"* ]]; then
|
||||||
|
continue
|
||||||
|
fi
|
||||||
|
# Exclude babel-standalone from coverage runs
|
||||||
|
if [ "$TEST_TYPE" = "cov" ] && [ `basename $f` = 'babel-standalone' ]; then
|
||||||
|
continue
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -d "$f/test" ]; then
|
||||||
|
TEST_DIRS="$f/test $TEST_DIRS"
|
||||||
|
fi
|
||||||
|
done
|
||||||
done
|
done
|
||||||
|
|
||||||
echo $TEST_DIRS
|
echo $TEST_DIRS
|
||||||
|
|||||||
@ -3952,6 +3952,12 @@ merge-source-map@^1.0.2:
|
|||||||
dependencies:
|
dependencies:
|
||||||
source-map "^0.5.6"
|
source-map "^0.5.6"
|
||||||
|
|
||||||
|
merge-stream@^1.0.1:
|
||||||
|
version "1.0.1"
|
||||||
|
resolved "https://registry.yarnpkg.com/merge-stream/-/merge-stream-1.0.1.tgz#4041202d508a342ba00174008df0c251b8c135e1"
|
||||||
|
dependencies:
|
||||||
|
readable-stream "^2.0.1"
|
||||||
|
|
||||||
micromatch@^2.1.5, micromatch@^2.3.11, micromatch@^2.3.7:
|
micromatch@^2.1.5, micromatch@^2.3.11, micromatch@^2.3.7:
|
||||||
version "2.3.11"
|
version "2.3.11"
|
||||||
resolved "https://registry.yarnpkg.com/micromatch/-/micromatch-2.3.11.tgz#86677c97d1720b363431d04d0d15293bd38c1565"
|
resolved "https://registry.yarnpkg.com/micromatch/-/micromatch-2.3.11.tgz#86677c97d1720b363431d04d0d15293bd38c1565"
|
||||||
@ -4707,7 +4713,7 @@ read-pkg@^2.0.0:
|
|||||||
isarray "0.0.1"
|
isarray "0.0.1"
|
||||||
string_decoder "~0.10.x"
|
string_decoder "~0.10.x"
|
||||||
|
|
||||||
readable-stream@^2.0.2, readable-stream@^2.0.6, readable-stream@^2.1.4, readable-stream@^2.1.5, readable-stream@^2.2.2, readable-stream@^2.2.6:
|
readable-stream@^2.0.1, readable-stream@^2.0.2, readable-stream@^2.0.6, readable-stream@^2.1.4, readable-stream@^2.1.5, readable-stream@^2.2.2, readable-stream@^2.2.6:
|
||||||
version "2.3.3"
|
version "2.3.3"
|
||||||
resolved "https://registry.yarnpkg.com/readable-stream/-/readable-stream-2.3.3.tgz#368f2512d79f9d46fdfc71349ae7878bbc1eb95c"
|
resolved "https://registry.yarnpkg.com/readable-stream/-/readable-stream-2.3.3.tgz#368f2512d79f9d46fdfc71349ae7878bbc1eb95c"
|
||||||
dependencies:
|
dependencies:
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user