chore: check node and npm version in release workflow (#1454)

* chore: check npm and node version in learn publish

* update error

* distinguished between node and npm
This commit is contained in:
Yongjie Zhao
2021-11-03 11:22:57 +00:00
parent beb4376a2a
commit 4a95b6a48a
3 changed files with 6519 additions and 1859 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -125,6 +125,7 @@
"react-loadable": "^5.5.0",
"react-test-renderer": "^16.13.1",
"rimraf": "^3.0.2",
"semver": "^7.3.5",
"ts-jest": "^26.4.2",
"ts-loader": "^8.0.7",
"typescript": "^4.1.2",

View File

@@ -19,7 +19,27 @@ rootDir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && cd .. && pwd )"
lernaVersionArg="$1"
if [[ -z $lernaVersionArg ]]; then
echo 'Please provide argument for "lerna version".'
echo '[ERROR] Please provide argument for "lerna version".'
exit 1
fi
currentNpm=$(npm --version)
npmVersion=$(node -e "process.stdout.write(require('./package.json').engines.npm)");
isSatisfiedNpm=$(node -e "process.stdout.write(require('semver').satisfies('$currentNpm', '$npmVersion').toString())");
currentNode=$(node --version)
nodeVersion=$(node -e "process.stdout.write(require('./package.json').engines.node)");
isSatisfiedNode=$(node -e "process.stdout.write(require('semver').satisfies('$currentNode', '$nodeVersion').toString())");
# Check node version compatible with package.json
if [[ $isSatisfiedNode != 'true' ]]; then
echo "[ERROR] Your node version($currentNode) is not compatible with package.json($nodeVersion)"
exit 1
fi
# Check npm version compatible with package.json
if [[ $isSatisfiedNpm != 'true' ]]; then
echo "[ERROR] Your npm version($currentNpm) is not compatible with package.json($npmVersion)"
exit 1
fi
@@ -27,7 +47,7 @@ fi
lerna version $1 --no-push --no-git-tag-version --yes
if [[ -z $(git diff --stat) ]]; then
echo 'No changed packages to version.'
echo '[ERROR] No changed packages to version.'
exit 1
fi
@@ -40,7 +60,7 @@ rm "$rootDir/package-lock.json"
npm i --package-lock-only
if [[ $? -ne 0 ]]; then
echo 'Can not update package-lock.json'
echo '[ERROR] Can not update package-lock.json'
exit 1
fi