Unverified Commit c9a02566 authored by Jeremy Morrell's avatar Jeremy Morrell Committed by GitHub

Deprecate old yarn versions (#520)

Yarn versions lower than 0.19 will crash if passed --frozen-lockfile, but usage of these versions has dropped to near-zero.
parent d16525f1
...@@ -41,6 +41,7 @@ echo "" > "$LOG_FILE" ...@@ -41,6 +41,7 @@ echo "" > "$LOG_FILE"
handle_failure() { handle_failure() {
header "Build failed" header "Build failed"
fail_yarn_outdated "$LOG_FILE"
fail_yarn_lockfile_outdated "$LOG_FILE" fail_yarn_lockfile_outdated "$LOG_FILE"
fail_node_install "$LOG_FILE" fail_node_install "$LOG_FILE"
fail_yarn_install "$LOG_FILE" fail_yarn_install "$LOG_FILE"
......
...@@ -85,27 +85,12 @@ log_build_scripts() { ...@@ -85,27 +85,12 @@ log_build_scripts() {
fi fi
} }
yarn_supports_frozen_lockfile() {
local yarn_version="$(yarn --version)"
# Yarn versions lower than 0.19 will crash if passed --frozen-lockfile
if [[ "$yarn_version" =~ ^0\.(16|17|18).*$ ]]; then
mcount "yarn.doesnt-support-frozen-lockfile"
false
else
true
fi
}
yarn_node_modules() { yarn_node_modules() {
local build_dir=${1:-} local build_dir=${1:-}
echo "Installing node modules (yarn.lock)" echo "Installing node modules (yarn.lock)"
cd "$build_dir" cd "$build_dir"
if yarn_supports_frozen_lockfile; then yarn install --frozen-lockfile --ignore-engines 2>&1
yarn install --frozen-lockfile --ignore-engines 2>&1
else
yarn install --pure-lockfile --ignore-engines 2>&1
fi
} }
npm_node_modules() { npm_node_modules() {
......
...@@ -118,6 +118,29 @@ fail_multiple_lockfiles() { ...@@ -118,6 +118,29 @@ fail_multiple_lockfiles() {
fi fi
} }
fail_yarn_outdated() {
local log_file="$1"
local yarn_engine=$(read_json "$BUILD_DIR/package.json" ".engines.yarn")
if grep -qi 'error: unknown option .--frozen-lockfile' "$log_file"; then
echo "ran"
mcount "failures.outdated-yarn"
echo ""
warn "Outdated Yarn version: $yarn_engine
Your application is specifying a requirement on an old version of Yarn ($yarn_engine)
which does not support the --frozen-lockfile option. Please upgrade to a
newer version, at least 0.19, by updating your requirement in the 'engines'
field in your package.json.
\"engines\": {
\"yarn\": \"1.3.2\"
}
" https://devcenter.heroku.com/articles/nodejs-support#specifying-a-yarn-version
exit 1
fi
}
fail_yarn_lockfile_outdated() { fail_yarn_lockfile_outdated() {
local log_file="$1" local log_file="$1"
if grep -qi 'Your lockfile needs to be updated' "$log_file"; then if grep -qi 'Your lockfile needs to be updated' "$log_file"; then
...@@ -204,7 +227,7 @@ fail_yarn_install() { ...@@ -204,7 +227,7 @@ fail_yarn_install() {
echo "" echo ""
warn "No matching version found for Yarn: $yarn_engine warn "No matching version found for Yarn: $yarn_engine
Heroku supports every version of Yarn published on npm, however you have Heroku supports most versions of Yarn published on npm, however you have
specified a version in package.json ($yarn_engine) that does not correspond specified a version in package.json ($yarn_engine) that does not correspond
to any published version of Yarn. You can see a list of all published to any published version of Yarn. You can see a list of all published
versions of Yarn with the following command: versions of Yarn with the following command:
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
"main": "index.js", "main": "index.js",
"license": "MIT", "license": "MIT",
"engines": { "engines": {
"yarn": "0.16.1" "yarn": "1.4.0"
}, },
"dependencies": { "dependencies": {
"lodash": "^4.16.4" "lodash": "^4.16.4"
......
{
"name": "yarn",
"version": "1.0.0",
"main": "index.js",
"license": "MIT",
"engines": {
"yarn": "~0.16"
},
"dependencies": {
"lodash": "^4.16.4"
}
}
# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
# yarn lockfile v1
lodash:
version "4.16.4"
resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.16.4.tgz#01ce306b9bad1319f2a5528674f88297aeb70127"
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
"main": "index.js", "main": "index.js",
"license": "MIT", "license": "MIT",
"engines": { "engines": {
"yarn": "0.24.5" "yarn": "1.4.0"
}, },
"dependencies": { "dependencies": {
"lodash": "^4.16.4" "lodash": "^4.16.4"
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
"main": "index.js", "main": "index.js",
"license": "MIT", "license": "MIT",
"engines": { "engines": {
"yarn": "~0.17" "yarn": "~0.28"
}, },
"dependencies": { "dependencies": {
"lodash": "^4.16.4" "lodash": "^4.16.4"
......
...@@ -116,11 +116,22 @@ testCacheWithPrebuild() { ...@@ -116,11 +116,22 @@ testCacheWithPrebuild() {
testYarnSemver() { testYarnSemver() {
compile "yarn-semver" compile "yarn-semver"
assertCaptured "Resolving yarn version ~0.17" assertCaptured "Resolving yarn version ~0.28"
assertCaptured "installing yarn (0.17." assertCaptured "installing yarn (0.28."
assertCapturedSuccess assertCapturedSuccess
} }
testOldYarn() {
compile "yarn-old-deprecated-version"
assertCaptured "Resolving yarn version ~0.16"
assertCaptured "installing yarn (0.16."
assertCaptured "error: unknown option \`--frozen-lockfile'"
assertCaptured "Outdated Yarn version"
assertCaptured "Your application is specifying a requirement on an old version of Yarn"
assertCaptured "https://devcenter.heroku.com/articles/nodejs-support#specifying-a-yarn-version"
assertCapturedError
}
testYarnInvalid() { testYarnInvalid() {
compile "yarn-invalid" compile "yarn-invalid"
assertCaptured "Resolving yarn version 0.171" assertCaptured "Resolving yarn version 0.171"
...@@ -148,7 +159,7 @@ testYarnRun() { ...@@ -148,7 +159,7 @@ testYarnRun() {
testYarnEngine() { testYarnEngine() {
compile "yarn-engine" compile "yarn-engine"
assertCaptured "installing yarn (0.16.1)" assertCaptured "installing yarn (1.4.0)"
assertCapturedSuccess assertCapturedSuccess
} }
...@@ -157,7 +168,7 @@ testYarnEngine() { ...@@ -157,7 +168,7 @@ testYarnEngine() {
# though we will only install using yarn if a yarn.lock exists # though we will only install using yarn if a yarn.lock exists
testYarnOnlyEngine() { testYarnOnlyEngine() {
compile "yarn-only-engine" compile "yarn-only-engine"
assertCaptured "installing yarn (0.24.5)" assertCaptured "installing yarn (1.4.0)"
assertCapturedSuccess assertCapturedSuccess
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment