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
|
||||
packages/babel-standalone/babel.js
|
||||
packages/babel-standalone/babel.min.js
|
||||
/codemods/*/lib
|
||||
/codemods/*/node_modules
|
||||
|
||||
21
Gulpfile.js
21
Gulpfile.js
@ -9,9 +9,9 @@ const watch = require("gulp-watch");
|
||||
const gutil = require("gulp-util");
|
||||
const gulp = require("gulp");
|
||||
const path = require("path");
|
||||
const merge = require("merge-stream");
|
||||
|
||||
const base = path.join(__dirname, "packages");
|
||||
const scripts = "./packages/*/src/**/*.js";
|
||||
const sources = ["codemods", "packages"];
|
||||
|
||||
function swapSrcWithLib(srcPath) {
|
||||
const parts = srcPath.split(path.sep);
|
||||
@ -19,11 +19,19 @@ function swapSrcWithLib(srcPath) {
|
||||
return parts.join(path.sep);
|
||||
}
|
||||
|
||||
function getGlobFromSource(source) {
|
||||
return `./${source}/*/src/**/*.js`;
|
||||
}
|
||||
|
||||
gulp.task("default", ["build"]);
|
||||
|
||||
gulp.task("build", function() {
|
||||
return merge(
|
||||
sources.map(source => {
|
||||
const base = path.join(__dirname, source);
|
||||
|
||||
return gulp
|
||||
.src(scripts, { base: base })
|
||||
.src(getGlobFromSource(source), { base: base })
|
||||
.pipe(
|
||||
plumber({
|
||||
errorHandler: function(err) {
|
||||
@ -46,16 +54,19 @@ gulp.task("build", function() {
|
||||
.pipe(babel())
|
||||
.pipe(
|
||||
through.obj(function(file, enc, callback) {
|
||||
// Passing 'file.relative' because newer() above uses a relative path and this keeps it consistent.
|
||||
// Passing 'file.relative' because newer() above uses a relative
|
||||
// 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() {
|
||||
watch(scripts, { debounceDelay: 200 }, function() {
|
||||
watch(sources.map(getGlobFromSource), { debounceDelay: 200 }, function() {
|
||||
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
|
||||
export FORCE_COLOR = true
|
||||
|
||||
SOURCES = packages codemods
|
||||
|
||||
.PHONY: build build-dist watch lint fix clean test-clean test-only test test-ci publish bootstrap
|
||||
|
||||
build: clean
|
||||
rm -rf packages/*/lib
|
||||
make clean-lib
|
||||
./node_modules/.bin/gulp build
|
||||
ifneq ($(BABEL_ENV), "cov")
|
||||
make build-standalone
|
||||
@ -25,17 +27,17 @@ build-dist: build
|
||||
node scripts/generate-babel-types-docs.js
|
||||
|
||||
watch: clean
|
||||
rm -rf packages/*/lib
|
||||
make clean-lib
|
||||
BABEL_ENV=development ./node_modules/.bin/gulp watch
|
||||
|
||||
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:
|
||||
./node_modules/.bin/flow check --strip-root
|
||||
|
||||
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
|
||||
rm -rf packages/babel-polyfill/browser*
|
||||
@ -46,16 +48,8 @@ clean: test-clean
|
||||
rm -rf packages/*/npm-debug*
|
||||
|
||||
test-clean:
|
||||
rm -rf packages/*/test/tmp
|
||||
rm -rf packages/*/test-fixtures.json
|
||||
|
||||
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
|
||||
$(foreach source, $(SOURCES), \
|
||||
$(call clean-source-test, $(source)))
|
||||
|
||||
test-only:
|
||||
./scripts/test.sh
|
||||
@ -75,7 +69,7 @@ test-ci-coverage:
|
||||
|
||||
publish:
|
||||
git pull --rebase
|
||||
rm -rf packages/*/lib
|
||||
make clean-lib
|
||||
BABEL_ENV=production make build-dist
|
||||
make test
|
||||
# not using lerna independent mode atm, so only update packages that have changed since we use ^
|
||||
@ -90,3 +84,34 @@ bootstrap:
|
||||
make build
|
||||
cd packages/babel-runtime; \
|
||||
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"
|
||||
],
|
||||
"dependencies": {
|
||||
"babel-plugin-syntax-optional-catch-binding": "7.0.0-beta.0"
|
||||
"babel-plugin-syntax-optional-catch-binding": "7.0.0-beta.1"
|
||||
},
|
||||
"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\""
|
||||
}
|
||||
|
||||
@ -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": {
|
||||
"ignore": [
|
||||
"*.md",
|
||||
"test/**"
|
||||
"test/**",
|
||||
"codemods/**"
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
"packages": [
|
||||
"packages/*",
|
||||
"codemods/*"
|
||||
]
|
||||
}
|
||||
|
||||
@ -41,6 +41,7 @@
|
||||
"lerna-changelog": "^0.5.0",
|
||||
"lint-staged": "^4.0.4",
|
||||
"lodash": "^4.2.0",
|
||||
"merge-stream": "^1.0.1",
|
||||
"mocha": "^3.0.0",
|
||||
"nyc": "^11.0.3",
|
||||
"output-file-sync": "^2.0.0",
|
||||
|
||||
@ -3,7 +3,10 @@ set -e
|
||||
|
||||
TEST_DIRS=""
|
||||
|
||||
for f in packages/*; do
|
||||
sources=("packages" "codemods")
|
||||
|
||||
for source in "${sources[@]}"; do
|
||||
for f in $source/*; do
|
||||
if [ -n "$TEST_ONLY" ] && [[ `basename $f` != *"$TEST_ONLY"* ]]; then
|
||||
continue
|
||||
fi
|
||||
@ -16,5 +19,6 @@ for f in packages/*; do
|
||||
TEST_DIRS="$f/test $TEST_DIRS"
|
||||
fi
|
||||
done
|
||||
done
|
||||
|
||||
echo $TEST_DIRS
|
||||
|
||||
@ -3952,6 +3952,12 @@ merge-source-map@^1.0.2:
|
||||
dependencies:
|
||||
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:
|
||||
version "2.3.11"
|
||||
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"
|
||||
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"
|
||||
resolved "https://registry.yarnpkg.com/readable-stream/-/readable-stream-2.3.3.tgz#368f2512d79f9d46fdfc71349ae7878bbc1eb95c"
|
||||
dependencies:
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user