@tmlmobilidade/repo-version 20251006.1128.42 → 20251006.1135.22
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +52 -48
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -3,51 +3,55 @@
|
|
|
3
3
|
import { Dates } from '@tmlmobilidade/utils';
|
|
4
4
|
import fs from 'node:fs';
|
|
5
5
|
/* * */
|
|
6
|
-
|
|
7
|
-
//
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
const
|
|
11
|
-
const
|
|
12
|
-
const
|
|
13
|
-
const
|
|
14
|
-
const
|
|
15
|
-
const
|
|
16
|
-
const
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
//
|
|
21
|
-
|
|
22
|
-
//
|
|
23
|
-
//
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
futurePackageVersion =
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
//
|
|
34
|
-
|
|
35
|
-
console.
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
//
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
//
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
6
|
+
(async function init() {
|
|
7
|
+
//
|
|
8
|
+
//
|
|
9
|
+
// Parse command-line arguments
|
|
10
|
+
const args = process.argv.slice(2);
|
|
11
|
+
const prefixArg = args.find(arg => arg.startsWith('--prefix='));
|
|
12
|
+
const prefix = prefixArg ? prefixArg.split('=')[1] : '';
|
|
13
|
+
const suffixArg = args.find(arg => arg.startsWith('--suffix='));
|
|
14
|
+
const suffix = suffixArg ? suffixArg.split('=')[1] : '';
|
|
15
|
+
const formatArg = args.find(arg => arg.startsWith('--format='));
|
|
16
|
+
const format = formatArg ? formatArg.split('=')[1] : '';
|
|
17
|
+
const outputArg = args.find(arg => arg.startsWith('--output='));
|
|
18
|
+
const output = outputArg ? outputArg.split('=')[1] : '';
|
|
19
|
+
//
|
|
20
|
+
// Generate the new version based on the current date and time
|
|
21
|
+
const dateValue = Dates.now('Europe/Lisbon');
|
|
22
|
+
//
|
|
23
|
+
// Format the version string.
|
|
24
|
+
// For "default" format: [prefix]YYYYMMDD.HHMM.SS
|
|
25
|
+
// For "code" format: YYYYMMDDHHMMSS (as a single number, no prefix)
|
|
26
|
+
let futurePackageVersion = '';
|
|
27
|
+
if (!format || format === 'default') {
|
|
28
|
+
futurePackageVersion = `${prefix}${dateValue.toFormat('yyyyMMdd.HHmm.ss')}${suffix}`;
|
|
29
|
+
}
|
|
30
|
+
if (format === 'code') {
|
|
31
|
+
futurePackageVersion = String(Number(dateValue.toFormat('yyyyMMddHHmmss')));
|
|
32
|
+
}
|
|
33
|
+
//
|
|
34
|
+
// If the ouput is set to "console",
|
|
35
|
+
// just print the version to the console and exit.
|
|
36
|
+
if (output === 'console') {
|
|
37
|
+
console.log(futurePackageVersion);
|
|
38
|
+
process.exit(0);
|
|
39
|
+
}
|
|
40
|
+
//
|
|
41
|
+
// If there is a package.json path argument,
|
|
42
|
+
// read the file and parse its content.
|
|
43
|
+
if (!output) {
|
|
44
|
+
console.error('✘ Error: No path to package.json provided.');
|
|
45
|
+
process.exit(1);
|
|
46
|
+
}
|
|
47
|
+
const packageJsonFile = fs.readFileSync(output, 'utf8');
|
|
48
|
+
const packageJsonData = JSON.parse(packageJsonFile);
|
|
49
|
+
//
|
|
50
|
+
// Update the package.json file with the new version
|
|
51
|
+
// and log the change to the console.
|
|
52
|
+
const currentPackageVersion = packageJsonData.version;
|
|
53
|
+
packageJsonData.version = futurePackageVersion;
|
|
54
|
+
fs.writeFileSync(output, JSON.stringify(packageJsonData, null, '\t'));
|
|
55
|
+
console.log(`✓ Package Version updated from "${currentPackageVersion}" to "${futurePackageVersion}".`);
|
|
56
|
+
//
|
|
57
|
+
}());
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tmlmobilidade/repo-version",
|
|
3
3
|
"description": "A CLI tool to bump the version of a NodeJS package.",
|
|
4
|
-
"version": "20251006.
|
|
4
|
+
"version": "20251006.1135.22",
|
|
5
5
|
"author": "João de Vasconcelos & Jusi Monteiro",
|
|
6
6
|
"license": "AGPL-3.0-or-later",
|
|
7
7
|
"type": "module",
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
],
|
|
11
11
|
"main": "dist/index.js",
|
|
12
12
|
"bin": {
|
|
13
|
-
"repo-version": "
|
|
13
|
+
"repo-version": "dist/index.js"
|
|
14
14
|
},
|
|
15
15
|
"types": "dist/index.d.ts",
|
|
16
16
|
"scripts": {
|