Skip to content

Commit

Permalink
feat: update newversion - require flag --bumpCli to bump major
Browse files Browse the repository at this point in the history
  • Loading branch information
erisu committed Oct 23, 2024
1 parent 22aef92 commit c547189
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 5 deletions.
11 changes: 10 additions & 1 deletion gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
14 changes: 10 additions & 4 deletions tools/bin/nextversion.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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();
Expand All @@ -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);
Expand All @@ -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);
Expand Down

0 comments on commit c547189

Please sign in to comment.