chore: replace yarn-upgrade by bump-babel-dependencies in e2e tests (#11021)

* chore: pin yarn version in e2e vue tests

* fix: replace yarn-upgrade by bump-babel-dependencies

* chore: update e2e-cra test
This commit is contained in:
Huáng Jùnliàng 2020-01-17 07:55:29 -05:00 committed by GitHub
parent 06dace1cdb
commit 1a1454328b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 35 additions and 8 deletions

View File

@ -23,9 +23,9 @@ cd tmp/create-react-app || exit
startLocalRegistry "$PWD"/../../verdaccio-config.yml startLocalRegistry "$PWD"/../../verdaccio-config.yml
yarn install yarn install
# "yarn upgrade --scope @babel --latest" doesn't seem to work. node "$PWD"/../../utils/bump-babel-dependencies.js
# a means "all", while \n is the enter needed to confirm the selection. yarn lerna exec -- node "$PWD"/../../utils/bump-babel-dependencies.js
printf "a\n" | yarn upgrade-interactive --scope @babel --latest yarn install
# Test # Test
CI=true yarn test CI=true yarn test

View File

@ -23,11 +23,9 @@ cd tmp/vue-cli || exit
startLocalRegistry "$PWD"/../../verdaccio-config.yml startLocalRegistry "$PWD"/../../verdaccio-config.yml
yarn install yarn install
# Workaround https://github.com/yarnpkg/yarn/issues/7797 node "$PWD"/../../utils/bump-babel-dependencies.js
yarn add --dev -W @babel/core yarn lerna exec -- node "$PWD"/../../utils/bump-babel-dependencies.js
# "yarn upgrade --scope @babel --latest" doesn't seem to work. yarn install
# a means "all", while \n is the enter needed to confirm the selection.
printf "a\n" | yarn upgrade-interactive --scope @babel --latest
# Test # Test
CI=true yarn test -p babel,babel-preset-app CI=true yarn test -p babel,babel-preset-app

View File

@ -0,0 +1,29 @@
const fs = require("fs");
const path = require("path");
const cwd = process.cwd();
const packageJSONPath = path.resolve(cwd, "./package.json");
const content = JSON.parse(fs.readFileSync(packageJSONPath));
let bumped = false;
function bumpBabelDependency(dependencies) {
for (const dep of Object.keys(dependencies)) {
if (dep.startsWith("@babel/")) {
dependencies[dep] = "latest";
bumped = true;
}
}
}
if ("peerDependencies" in content) {
bumpBabelDependency(content.peerDependencies);
}
if ("devDependencies" in content) {
bumpBabelDependency(content.devDependencies);
}
if ("dependencies" in content) {
bumpBabelDependency(content.dependencies);
}
if (bumped) {
fs.writeFileSync(packageJSONPath, JSON.stringify(content, undefined, 2));
}