diff --git a/gulpfile.js b/gulpfile.js index 0656eca08e..45fbd3143f 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -65,7 +65,16 @@ const YAML_FRONT_MATTER = '---\n---\n'; const WATCH_INTERVAL = 1000; // in milliseconds const VERSION_VAR_NAME = 'latest_docs_version'; const LATEST_DOCS_VERSION = fs.readFileSync(VERSION_FILE, 'utf-8').trim(); -const NEXT_DOCS_VERSION = nextversion.getNextVersion(LATEST_DOCS_VERSION); + +// '--bumpCli' flag hat determins if the next version is major CLI or new date release. +const bumpCli = gutil.env.bumpCli || false; +const NEXT_DOCS_VERSION = nextversion.getNextVersion(bumpCli, LATEST_DOCS_VERSION); + +if (fs.existsSync(path.join(DOCS_DIR, 'en', NEXT_DOCS_VERSION))) { + gutil.log(gutil.colors.red('[ERROR] ') + `The targeted docs version ""${NEXT_DOCS_VERSION}"" already exist. Are you trying to update the existing snapshot? Use "npm run update-docs".`); + process.exit(1); +} + const LANGUAGES = util.listdirsSync(DOCS_DIR); const PROD_BY_DEFAULT = false; diff --git a/tools/bin/nextversion.js b/tools/bin/nextversion.js index cd789bd1ba..aee09e3abe 100755 --- a/tools/bin/nextversion.js +++ b/tools/bin/nextversion.js @@ -17,7 +17,9 @@ 'use strict'; -function getNextVersion (previousVersion) { +function getNextVersion (bumpCli, previousVersion) { + bumpCli = bumpCli || false; + // get previous version number // NOTE: // only versions of the form N.x are accepted @@ -28,7 +30,9 @@ function getNextVersion (previousVersion) { // get next major version const previousMajor = previousVersionMatch[1]; - const nextMajor = parseInt(previousMajor) + 1; + const nextMajor = bumpCli + ? parseInt(previousMajor) + 1 + : parseInt(previousMajor); // create next version const currentDate = new Date(); @@ -41,7 +45,9 @@ function getNextVersion (previousVersion) { function main () { // get arg - const previousVersion = process.argv[2]; + const shouldBumpCli = process.argv[2] || false; + const previousVersion = process.argv[3]; + if (!previousVersion) { console.error('no version specified'); process.exit(1); @@ -50,7 +56,7 @@ function main () { // try to get the next version let nextVersion = null; try { - nextVersion = getNextVersion(previousVersion); + nextVersion = getNextVersion(shouldBumpCli, previousVersion); } catch (e) { console.error(e); process.exit(1);