Skip to content

Commit 4db7637

Browse files
authored
doc: update version pattern <cli version>-<year>.<month> (#1368)
* feat: update version pattern <cli version>-<year>.<month> * feat: update newversion - require flag --bumpCli to bump major * doc: update working on docs * doc: remove random read more link * doc: check targeted version in newversion task
1 parent 6cb7490 commit 4db7637

File tree

3 files changed

+77
-19
lines changed

3 files changed

+77
-19
lines changed

doc/working-on-docs.md

Lines changed: 53 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,24 +7,66 @@
77
* This can also be executed via `gulpfile.js` task `fetch`, by running `gulp fetch` which pulls in the files to `dev/en/{file dest}`.
88
* Most auto-generated files have a comment tag at the top of the file to indicate that they come from elsewhere.
99

10-
## Update latest (x.y) from `dev`
10+
## Update current docs from `dev`
1111

12-
Normal build doesn't update latest (7.x) from dev version of docs. You will need to do this manually using `gulp snapshot`. Read more [here](https://github.com/apache/cordova-docs/blob/master/gulpfile.js#L212).
12+
The following command can quickly sync the `dev` docs with the current latest docs:
1313

14-
## Create new version of the docs
14+
```bash
15+
npm run update-docs
16+
```
1517

16-
To increment the documentation version (e.g. `X.X.X`, either use the gulp task:
18+
## Create new snapshot from `dev`
1719

18-
gulp newversion --version X.X.X
20+
The following commands can be used to create a new snapshot of `dev` docs:
1921

20-
or manually run the `incrementversion.js` script:
22+
```bash
23+
npx gulp newversion
24+
npx gulp newversion --bumpCli
25+
```
2126

22-
node ./tools/bin/incrementversion.js www/docs X.X.X
27+
Please read the section, [Preparing Doc Release Scenarios](#Preparing-Doc-Release-Scenarios), below to understand which command fits your scenario.
2328

24-
To only run for a specific language (__this should only happen when translation is intentionally left out for a given version__), specify the language to the Gulp task as follows:
29+
## Preparing Doc Release Scenarios
2530

26-
gulp newversion --version X.X.X --language YY
31+
When preparing to release docs, there are two things to be aware of, the version of Cordova CLI and if the changes warrants for a new doc version.
2732

28-
or manually, to the script, as follows:
33+
Here are a few scenarios that will help decide how if we are updating an existing snapshot of creating a new one.
2934

30-
node ./tools/bin/incrementversion.js www/docs X.X.X YY
35+
1. Are we preparing to release new docs because there was a major release of Cordova CLI?
36+
37+
If the answer is **yes**, then we will be creating a new version of docs with the following command:
38+
39+
```bash
40+
npx gulp newversion --bumpCli
41+
```
42+
43+
If the current released docs version is `12.x` and we are preparing for Cordova-CLI 13.x, the above command will create `13.x-2024.10`.
44+
45+
> Notice: The year and month will be appended automatically.
46+
47+
2. Are we preparing to release new docs because there was a minor or patch release of Cordova CLI?
48+
49+
If the answer is **yes**, then we do not need to make a new snapshot. In this case, we can update an existing snapshot with the following command:
50+
51+
```bash
52+
npm run update-docs
53+
```
54+
55+
> Notice: In this scenario we are expecting the version to already exist. If it was missing, then we would have to create a new snapshot but in most cases it should never be missing.
56+
57+
3. Are we preparing docs for a major release to one or more of Cordova's platforms while the CLI version was unchanged?
58+
59+
If the answer is **yes**, then we need to make a new snapshot, but we do not need to bump the CLI major. We can do this with the following command:
60+
61+
```bash
62+
npx gulp newversion
63+
```
64+
65+
If the current doc snapshot is `12.x`, then the above command will create a new snapshot with the same CLI major version but the appended date will be different.
66+
67+
E.g. `12.x-2024.10`
68+
69+
> Notice:
70+
>
71+
> *`12.x` and older does not have date appended. Any newly created snapshots will append the date value.
72+
> * If we already have `12.x-2024.10` and the month is still the same, we should use senario 2. `npm run update-docs`.

gulpfile.js

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,9 +67,11 @@ const YAML_FRONT_MATTER = '---\n---\n';
6767
const WATCH_INTERVAL = 1000; // in milliseconds
6868
const VERSION_VAR_NAME = 'latest_docs_version';
6969
const LATEST_DOCS_VERSION = fs.readFileSync(VERSION_FILE, 'utf-8').trim();
70-
const NEXT_DOCS_VERSION = nextversion.getNextVersion(LATEST_DOCS_VERSION);
71-
const LANGUAGES = listdirsSync(DOCS_DIR);
7270

71+
// '--bumpCli' flag hat determins if the next version is major CLI or new date release.
72+
const bumpCli = argv.bumpCli || false;
73+
const NEXT_DOCS_VERSION = nextversion.getNextVersion(bumpCli, LATEST_DOCS_VERSION);
74+
const LANGUAGES = listdirsSync(DOCS_DIR);
7375
const PROD_BY_DEFAULT = false;
7476

7577
// compute/get/set/adjust passed options
@@ -381,6 +383,11 @@ module.exports.lint = function lint () {
381383
};
382384

383385
module.exports.newversion = gulp.series(fetch, function newVersion (done) {
386+
if (fs.existsSync(path.join(DOCS_DIR, 'en', NEXT_DOCS_VERSION))) {
387+
logger(styleText(['red'], '[ERROR] ') + `The targeted docs version ""${NEXT_DOCS_VERSION}"" already exist. Are you trying to update the existing snapshot? Use "npm run update-docs".`);
388+
process.exit(1);
389+
}
390+
384391
copyDocsVersion('dev', NEXT_DOCS_VERSION, function (error) {
385392
if (error) {
386393
console.error(error);

tools/bin/nextversion.js

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,28 +17,37 @@
1717

1818
'use strict';
1919

20-
function getNextVersion (previousVersion) {
20+
function getNextVersion (bumpCli, previousVersion) {
21+
bumpCli = bumpCli || false;
22+
2123
// get previous version number
2224
// NOTE:
2325
// only versions of the form N.x are accepted
24-
const previousVersionMatch = previousVersion.match(/^(\d+)\.x$/);
26+
const previousVersionMatch = previousVersion.match(/^(\d+)\.x(-\d{4}.\d{2})?$/);
2527
if (!previousVersionMatch) {
2628
throw Error('invalid version');
2729
}
2830

2931
// get next major version
3032
const previousMajor = previousVersionMatch[1];
31-
const nextMajor = parseInt(previousMajor) + 1;
33+
const nextMajor = bumpCli
34+
? parseInt(previousMajor) + 1
35+
: parseInt(previousMajor);
3236

3337
// create next version
34-
const nextVersion = nextMajor + '.x';
38+
const currentDate = new Date();
39+
const currentYear = currentDate.getFullYear();
40+
const currentMonth = (currentDate.getMonth() + 1).toString().padStart(2, '0');
41+
const nextVersion = `${nextMajor}.x-${currentYear}.${currentMonth}`;
3542

3643
return nextVersion;
3744
}
3845

3946
function main () {
4047
// get arg
41-
const previousVersion = process.argv[2];
48+
const shouldBumpCli = process.argv[2] || false;
49+
const previousVersion = process.argv[3];
50+
4251
if (!previousVersion) {
4352
console.error('no version specified');
4453
process.exit(1);
@@ -47,7 +56,7 @@ function main () {
4756
// try to get the next version
4857
let nextVersion = null;
4958
try {
50-
nextVersion = getNextVersion(previousVersion);
59+
nextVersion = getNextVersion(shouldBumpCli, previousVersion);
5160
} catch (e) {
5261
console.error(e);
5362
process.exit(1);

0 commit comments

Comments
 (0)