From bc1f6fad58a4197ec5c2399b0ad2d9febff22668 Mon Sep 17 00:00:00 2001 From: Wendell Date: Mon, 17 Sep 2018 11:01:35 +0800 Subject: [PATCH] fix(publish): add version number validation and rename script (#2117) --- package.json | 2 +- publish_scripts/publish.js | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index ec68e124cf..c2d49db626 100644 --- a/package.json +++ b/package.json @@ -24,7 +24,7 @@ "integration-rollup": "npm run generate && cd integration/rollup && npm run integration", "lint": "tslint -c tslint.json 'components/*/*.ts'", "changelog": "conventional-changelog -p angular -i CHANGELOG.md -s && node site_scripts/replace-scope-prefix.js", - "publish": "node ./publish_scripts/publish.js" + "release": "node ./publish_scripts/publish.js" }, "main": "./bundles/antd.umd.js", "module": "./esm5/antd.js", diff --git a/publish_scripts/publish.js b/publish_scripts/publish.js index 1b841238ff..f42bf44ecc 100644 --- a/publish_scripts/publish.js +++ b/publish_scripts/publish.js @@ -50,6 +50,9 @@ function changeVersion() { let version; function checkVersionNumber(cur, next) { + // Must be numbers and dots. + if (!/^[1-9][0-9.]{1,10}[0-9]$/.test(next)) { return false; } + const curArr = cur.split('.'); const nextArr = next.split('.'); const length = curArr.length; @@ -71,7 +74,7 @@ function changeVersion() { versionNumberValid = true; nextVersion = version; } else { - log.error(`The current version ${currentVersion} is not ahead of your input. Please check it.`); + log.error(`Your input ${version} is not after the current version ${currentVersion} or is unvalid. Please check it.`); } }