@massimo-cassandro/minimo 1.24.1 → 1.24.3
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.
|
@@ -17,3 +17,4 @@ Options:
|
|
|
17
17
|
* `--pkg`: Path to the `package.json` file relative to the current directory (default: `./package.json`)
|
|
18
18
|
* `--log-file`: Path to the log file relative to the current directory (default: `./changelog.md`). If the file name ends with `.txt`, the log type is assumed to be the previous version of `update-version`, where each line is in the form `timestamp | version | description`
|
|
19
19
|
* `--log-patch`: If present, patch changes are also recorded in the log.
|
|
20
|
+
* `--noLogv0`: If `true` (default), the log is not written when the major version is `0`, except for the initial log entry created when the changelog file is first initialized. Pass `--noLogv0` to enable it explicitly, or `--noLogv0=false` to disable it from the command line.
|
|
@@ -29,7 +29,7 @@ async function run() {
|
|
|
29
29
|
|
|
30
30
|
// check package.json
|
|
31
31
|
if (!fs.existsSync(params.packageJsonFile)) {
|
|
32
|
-
console.error( styleText(['red'], `
|
|
32
|
+
console.error( styleText(['red'], `Error: ${params.packageJsonFile} not found.` ));
|
|
33
33
|
process.exit(1);
|
|
34
34
|
|
|
35
35
|
}
|
|
@@ -38,10 +38,10 @@ async function run() {
|
|
|
38
38
|
params.oldSemver = params.packageJsonObj.version;
|
|
39
39
|
|
|
40
40
|
if(!params.oldSemver) {
|
|
41
|
-
console.error( styleText(['red'], `
|
|
41
|
+
console.error( styleText(['red'], `Property 'version' of '${params.cfg.packageJsonFile}' not found` ));
|
|
42
42
|
|
|
43
43
|
} else {
|
|
44
|
-
console.log( styleText(['white', 'dim'], `
|
|
44
|
+
console.log( styleText(['white', 'dim'], `Current package.json version: ${params.oldSemver}` ) );
|
|
45
45
|
params.semverArray = params.oldSemver.split('.').map(i => isNaN(i) ? i : +i);
|
|
46
46
|
}
|
|
47
47
|
|
|
@@ -52,11 +52,6 @@ async function run() {
|
|
|
52
52
|
params.updateMode = choice; // modalità scelta (init, major, minor o patch)
|
|
53
53
|
updateSemver();
|
|
54
54
|
|
|
55
|
-
// Se noLogv0 è true e la major version è 0, il log non viene registrato (eccetto per l'inizializzazione)
|
|
56
|
-
if (params.noLogv0 && params.updateMode !== 'init' && params.semverArray[0] === 0) {
|
|
57
|
-
params.addLog = false;
|
|
58
|
-
}
|
|
59
|
-
|
|
60
55
|
params.logRow.vers = params.newSemver;
|
|
61
56
|
|
|
62
57
|
// Scrive il log, se richiesto
|
|
@@ -95,7 +90,7 @@ async function run() {
|
|
|
95
90
|
' '.repeat(rowLength - text.length - 1) +
|
|
96
91
|
styleText(['yellow'], '│'),
|
|
97
92
|
|
|
98
|
-
outputString1 = `👍
|
|
93
|
+
outputString1 = `👍 Version updated: ${params.oldSemver} → ${params.newSemver}`,
|
|
99
94
|
outputString2 = params.logRow.fullText? `Log: ${params.logRow.fullText}` : '',
|
|
100
95
|
outputLenght = Math.max(outputString1.length, outputString2.length ) + 2, // 2 = spazi esterni
|
|
101
96
|
frameLine = '─'.repeat(outputLenght);
|
|
@@ -5,31 +5,37 @@ import { params } from './params.mjs';
|
|
|
5
5
|
|
|
6
6
|
export async function chooser() {
|
|
7
7
|
const choices = [
|
|
8
|
-
{ name: '
|
|
9
|
-
{ name: '
|
|
10
|
-
{ name: '
|
|
8
|
+
{ name: 'Update Patch version', value: 'patch' },
|
|
9
|
+
{ name: 'Update Minor version', value: 'minor' },
|
|
10
|
+
{ name: 'Update Major version', value: 'major' }
|
|
11
11
|
];
|
|
12
12
|
|
|
13
13
|
// Se il file di log non esiste, proponi l'inizializzazione
|
|
14
14
|
if (!fs.existsSync(params.logFile)) {
|
|
15
15
|
choices.unshift({
|
|
16
|
-
name: `
|
|
16
|
+
name: `Initialize Changelog (v${params.oldSemver})`,
|
|
17
17
|
value: 'init'
|
|
18
18
|
});
|
|
19
19
|
}
|
|
20
20
|
|
|
21
|
-
choices.push({ name: '
|
|
21
|
+
choices.push({ name: 'Cancel', value: null });
|
|
22
22
|
|
|
23
23
|
const answer = await select({
|
|
24
|
-
message:
|
|
24
|
+
message: `What do you want to update?${params.oldSemver ? ` (current version ${params.oldSemver})` : ''}`,
|
|
25
25
|
choices: choices
|
|
26
26
|
});
|
|
27
27
|
|
|
28
28
|
params.addLog = params.toLog.indexOf(answer) !== -1 || answer === 'init';
|
|
29
29
|
|
|
30
|
+
// Se noLogv0 è true e la major version (prospettica) è 0, il log non viene registrato (eccetto per l'inizializzazione)
|
|
31
|
+
if (params.addLog && params.noLogv0 && answer !== 'init') {
|
|
32
|
+
const newMajor = answer === 'major' ? params.semverArray[0] + 1 : params.semverArray[0];
|
|
33
|
+
if (newMajor === 0) params.addLog = false;
|
|
34
|
+
}
|
|
35
|
+
|
|
30
36
|
if (answer && params.addLog) {
|
|
31
37
|
const descr = await input({
|
|
32
|
-
message: '
|
|
38
|
+
message: 'Description (optional): ',
|
|
33
39
|
default: answer === 'init'
|
|
34
40
|
? 'Setup'
|
|
35
41
|
: answer === 'patch'
|