Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 3 commits into from Jan 17, 2020
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 3 additions & 5 deletions scripts/integration-tests/e2e-vue-cli.sh
Expand Up @@ -23,11 +23,9 @@ cd tmp/vue-cli || exit

startLocalRegistry "$PWD"/../../verdaccio-config.yml
yarn install
# Workaround https://github.com/yarnpkg/yarn/issues/7797
yarn add --dev -W @babel/core
# "yarn upgrade --scope @babel --latest" doesn't seem to work.
# a means "all", while \n is the enter needed to confirm the selection.
printf "a\n" | yarn upgrade-interactive --scope @babel --latest
node "$PWD"/../../utils/bump-babel-dependencies.js
yarn lerna exec -- node "$PWD"/../../utils/bump-babel-dependencies.js
yarn install

# Test
CI=true yarn test -p babel,babel-preset-app
Expand Down
29 changes: 29 additions & 0 deletions scripts/integration-tests/utils/bump-babel-dependencies.js
@@ -0,0 +1,29 @@
const fs = require("fs");
Copy link
Contributor Author

@JLHwung JLHwung Jan 16, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@nicolo-ribaudo WDYT replacing yarn-upgrade by this snippet in e2e-create-react-app 🤷‍♂️

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";
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Technically if a downstream project specifies latest for @babel/ in the package.json, this approach will not work at all because yarn will then lock latest to old versions. But practically this scenario should never happen.

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));
}