@leverege/build-tools 2.33.1 → 2.33.2-bruno.2
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/.vscode/settings.json +15 -0
- package/lib/server/tag-release.js +64 -16
- package/lib/web/tag-release.js +64 -16
- package/package.json +1 -1
- package/src/tag-release.mjs +74 -15
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
{
|
|
2
|
+
"eslint.alwaysShowStatus": true,
|
|
3
|
+
"[javascript]": {
|
|
4
|
+
"editor.codeActionsOnSave": {
|
|
5
|
+
"source.fixAll.eslint": true,
|
|
6
|
+
"source.organizeImports": false
|
|
7
|
+
}
|
|
8
|
+
},
|
|
9
|
+
"[javascriptreact]": {
|
|
10
|
+
"editor.codeActionsOnSave": {
|
|
11
|
+
"source.fixAll.eslint": true,
|
|
12
|
+
"source.organizeImports": false
|
|
13
|
+
}
|
|
14
|
+
},
|
|
15
|
+
}
|
|
@@ -211,16 +211,26 @@ The tag-release script must run from a npm project.
|
|
|
211
211
|
return packageJson.version;
|
|
212
212
|
};
|
|
213
213
|
const getNextVersions = currentVersion => {
|
|
214
|
-
const
|
|
214
|
+
const regex = /^(\d+)(?:\.(\d+))?(?:\.(\d+))?(?:-(\w+)\.(\d+))?$/i;
|
|
215
|
+
const [, dirtyMajor, dirtyMinor, dirtyPatch, testTag, dirtyTestVersion] = currentVersion.match(regex);
|
|
216
|
+
const major = parseInt(dirtyMajor);
|
|
217
|
+
const minor = parseInt(dirtyMinor) || 0;
|
|
218
|
+
const patch = parseInt(dirtyPatch) || 0;
|
|
219
|
+
const testVersion = parseInt(dirtyTestVersion) || 0;
|
|
215
220
|
const nextMajor = `${major + 1}.0.0`;
|
|
216
221
|
const nextMinor = `${major}.${minor + 1}.0`;
|
|
217
222
|
const nextPatch = `${major}.${minor}.${patch + 1}`;
|
|
218
|
-
const
|
|
223
|
+
const nextAlpha = testTag === 'alpha' ? `${major}.${minor}.${patch}-alpha.${testVersion + 1}` : `${major}.${minor}.${patch + 1}-alpha.1`;
|
|
224
|
+
const nextBeta = testTag === 'beta' ? `${major}.${minor}.${patch}-beta.${testVersion + 1}` : `${major}.${minor}.${patch + 1}-beta.1`;
|
|
225
|
+
const nextTestTag = testTag && !['alpha', 'beta'].includes(testTag) ? `${major}.${minor}.${patch}-${testTag}.${testVersion + 1}` : null;
|
|
219
226
|
return {
|
|
220
227
|
nextMajor,
|
|
221
228
|
nextMinor,
|
|
222
229
|
nextPatch,
|
|
223
|
-
|
|
230
|
+
nextAlpha,
|
|
231
|
+
nextBeta,
|
|
232
|
+
nextTestTag,
|
|
233
|
+
testTag
|
|
224
234
|
};
|
|
225
235
|
};
|
|
226
236
|
const promptForVersion = async currentVersion => {
|
|
@@ -228,7 +238,10 @@ const promptForVersion = async currentVersion => {
|
|
|
228
238
|
nextMajor,
|
|
229
239
|
nextMinor,
|
|
230
240
|
nextPatch,
|
|
231
|
-
|
|
241
|
+
nextAlpha,
|
|
242
|
+
nextBeta,
|
|
243
|
+
nextTestTag,
|
|
244
|
+
testTag
|
|
232
245
|
} = getNextVersions(currentVersion);
|
|
233
246
|
const choices = [{
|
|
234
247
|
hint: '(major release)',
|
|
@@ -239,10 +252,16 @@ const promptForVersion = async currentVersion => {
|
|
|
239
252
|
}, {
|
|
240
253
|
hint: '(patch release)',
|
|
241
254
|
value: nextPatch
|
|
255
|
+
}, {
|
|
256
|
+
hint: '(alpha release)',
|
|
257
|
+
value: nextAlpha
|
|
242
258
|
}, {
|
|
243
259
|
hint: '(beta release)',
|
|
244
260
|
value: nextBeta
|
|
245
|
-
}, {
|
|
261
|
+
}, ...(nextTestTag ? [{
|
|
262
|
+
hint: `(${testTag} release)`,
|
|
263
|
+
value: nextTestTag
|
|
264
|
+
}] : []), {
|
|
246
265
|
hint: '(current version)',
|
|
247
266
|
value: currentVersion
|
|
248
267
|
}, {
|
|
@@ -302,6 +321,19 @@ const getGitTagSuffix = async () => {
|
|
|
302
321
|
});
|
|
303
322
|
return tagSuffix;
|
|
304
323
|
};
|
|
324
|
+
const getGitAnnotationMessage = async ({
|
|
325
|
+
tagName
|
|
326
|
+
}) => {
|
|
327
|
+
const {
|
|
328
|
+
annotationMessage
|
|
329
|
+
} = await prompt({
|
|
330
|
+
type: 'input',
|
|
331
|
+
name: 'annotationMessage',
|
|
332
|
+
message: 'What annotation message would you like to add to git tag?',
|
|
333
|
+
initial: tagName
|
|
334
|
+
});
|
|
335
|
+
return annotationMessage;
|
|
336
|
+
};
|
|
305
337
|
const confirmPushCommit = async buildMessage => {
|
|
306
338
|
const {
|
|
307
339
|
confirm
|
|
@@ -425,19 +457,19 @@ const commitAndPushNewBuild = async config => {
|
|
|
425
457
|
await createNewBuildCommit(config);
|
|
426
458
|
await pushToGitRemote();
|
|
427
459
|
};
|
|
428
|
-
const confirmPushTag = async tagName => {
|
|
460
|
+
const confirmPushTag = async (tagName, annotationMessage) => {
|
|
429
461
|
const {
|
|
430
462
|
confirm
|
|
431
463
|
} = await prompt([{
|
|
432
464
|
type: 'confirm',
|
|
433
465
|
name: 'confirm',
|
|
434
|
-
message: `${_ansiColors.default.bold.red('[Warning]')} Push new tag ${_ansiColors.default.bold.yellow(tagName)} to git remote?`
|
|
466
|
+
message: `${_ansiColors.default.bold.red('[Warning]')} Push new tag ${_ansiColors.default.bold.yellow(tagName)} with annotation message "${_ansiColors.default.bold.yellow(annotationMessage)}" to git remote?`
|
|
435
467
|
}]);
|
|
436
468
|
return confirm;
|
|
437
469
|
};
|
|
438
|
-
const createGitTag = async tagName => {
|
|
470
|
+
const createGitTag = async (tagName, annotationMessage) => {
|
|
439
471
|
try {
|
|
440
|
-
await (0, _zx.$)`git tag ${tagName}`;
|
|
472
|
+
await (0, _zx.$)`git tag -a ${tagName} -m "${annotationMessage}"`;
|
|
441
473
|
} catch (err) {
|
|
442
474
|
console.log(err.stderr || err);
|
|
443
475
|
process.exit(1);
|
|
@@ -453,11 +485,12 @@ const pushGitTag = async tagName => {
|
|
|
453
485
|
};
|
|
454
486
|
const createAndPushGitTag = async ({
|
|
455
487
|
tagName,
|
|
488
|
+
annotationMessage,
|
|
456
489
|
noConfirm
|
|
457
490
|
}) => {
|
|
458
|
-
const confirmAnswer = noConfirm || (await confirmPushTag(tagName));
|
|
491
|
+
const confirmAnswer = noConfirm || (await confirmPushTag(tagName, annotationMessage));
|
|
459
492
|
if (confirmAnswer) {
|
|
460
|
-
await createGitTag(tagName);
|
|
493
|
+
await createGitTag(tagName, annotationMessage);
|
|
461
494
|
await pushGitTag(tagName);
|
|
462
495
|
}
|
|
463
496
|
};
|
|
@@ -497,9 +530,11 @@ const displayReleaseInfo = config => {
|
|
|
497
530
|
packagePath,
|
|
498
531
|
buildMessage,
|
|
499
532
|
tagName,
|
|
533
|
+
annotationMessage,
|
|
500
534
|
publishable,
|
|
501
535
|
npmjsTag,
|
|
502
|
-
isBetaRelease
|
|
536
|
+
isBetaRelease,
|
|
537
|
+
noGitTag
|
|
503
538
|
} = config;
|
|
504
539
|
console.log(`
|
|
505
540
|
|
|
@@ -509,8 +544,9 @@ ${_ansiColors.default.blue('Version:')} ${version}
|
|
|
509
544
|
${_ansiColors.default.blue('Root directory:')} ${repositoryRoot}
|
|
510
545
|
${_ansiColors.default.blue('Package name:')} ${packageName}
|
|
511
546
|
${_ansiColors.default.blue('package.json path:')} ${_path.default.join(packagePath, 'package.json')}${buildMessage ? `
|
|
512
|
-
${_ansiColors.default.blue('Commit message:')} ${buildMessage}` : ''}${isBetaRelease ? '' : `
|
|
513
|
-
${_ansiColors.default.blue('Git tag:')} ${tagName}`}${
|
|
547
|
+
${_ansiColors.default.blue('Commit message:')} ${buildMessage}` : ''}${isBetaRelease || noGitTag ? '' : `
|
|
548
|
+
${_ansiColors.default.blue('Git tag:')} ${tagName}`}${isBetaRelease || noGitTag ? '' : `
|
|
549
|
+
${_ansiColors.default.blue('Git tag annotation:')} ${annotationMessage}`}${publishable ? `
|
|
514
550
|
${_ansiColors.default.blue('Npmjs tag:')} ${npmjsTag}` : ''}
|
|
515
551
|
${_ansiColors.default.bold.green('=============================================')}
|
|
516
552
|
`);
|
|
@@ -551,6 +587,11 @@ const optionList = [{
|
|
|
551
587
|
type: String,
|
|
552
588
|
alias: 't',
|
|
553
589
|
description: 'tag suffix to be appended to the version when pushing to git'
|
|
590
|
+
}, {
|
|
591
|
+
name: 'annotation-message',
|
|
592
|
+
type: String,
|
|
593
|
+
alias: 'm',
|
|
594
|
+
description: 'annotation message that will annotate the git tag'
|
|
554
595
|
}, {
|
|
555
596
|
name: 'branch-filter',
|
|
556
597
|
type: String,
|
|
@@ -560,6 +601,10 @@ const optionList = [{
|
|
|
560
601
|
name: 'no-commit',
|
|
561
602
|
type: Boolean,
|
|
562
603
|
description: 'do not create a new commit on git (in case the goal is just tagging it)'
|
|
604
|
+
}, {
|
|
605
|
+
name: 'no-git-tag',
|
|
606
|
+
type: Boolean,
|
|
607
|
+
description: 'do not create a new tag on git'
|
|
563
608
|
}, {
|
|
564
609
|
name: 'no-confirm',
|
|
565
610
|
type: Boolean,
|
|
@@ -589,6 +634,7 @@ validateArgs(args);
|
|
|
589
634
|
const config = {};
|
|
590
635
|
config.noConfirm = !!args['no-confirm'];
|
|
591
636
|
config.noCommit = !!args['no-commit'];
|
|
637
|
+
config.noGitTag = !!args['no-git-tag'];
|
|
592
638
|
config.repositoryRoot = await getGitRootDirectory();
|
|
593
639
|
config.branch = args.branch || (await getBranch({
|
|
594
640
|
branchFilter: args['branch-filter']
|
|
@@ -601,10 +647,12 @@ config.version = args.version || (await getVersion(config));
|
|
|
601
647
|
config.packageName = await getPackageName(config);
|
|
602
648
|
config.buildMessage = config.noCommit ? '' : getBuildMessage(config);
|
|
603
649
|
config.isBetaRelease = config.version.includes('-beta.');
|
|
604
|
-
if (!config.isBetaRelease) {
|
|
650
|
+
if (!config.isBetaRelease && !config.noGitTag) {
|
|
605
651
|
const tagSuffix = args['tag-suffix'] ?? (await getGitTagSuffix());
|
|
606
652
|
const tagPrefix = config.isPackageInRepositoryRoot ? '' : `${config.packageName}/`;
|
|
607
653
|
config.tagName = `${tagPrefix}v${config.version}${tagSuffix}`;
|
|
654
|
+
const annotationMessage = args['annotation-message'] ?? (await getGitAnnotationMessage(config));
|
|
655
|
+
config.annotationMessage = annotationMessage;
|
|
608
656
|
}
|
|
609
657
|
config.publishable = !!args.publishable;
|
|
610
658
|
if (config.publishable) {
|
|
@@ -624,7 +672,7 @@ if (!config.noConfirm) {
|
|
|
624
672
|
if (!config.noCommit) {
|
|
625
673
|
await commitAndPushNewBuild(config);
|
|
626
674
|
}
|
|
627
|
-
if (!config.isBetaRelease) {
|
|
675
|
+
if (!config.isBetaRelease && !config.noGitTag) {
|
|
628
676
|
await createAndPushGitTag(config);
|
|
629
677
|
}
|
|
630
678
|
if (config.publishable) {
|
package/lib/web/tag-release.js
CHANGED
|
@@ -211,16 +211,26 @@ The tag-release script must run from a npm project.
|
|
|
211
211
|
return packageJson.version;
|
|
212
212
|
};
|
|
213
213
|
const getNextVersions = currentVersion => {
|
|
214
|
-
const
|
|
214
|
+
const regex = /^(\d+)(?:\.(\d+))?(?:\.(\d+))?(?:-(\w+)\.(\d+))?$/i;
|
|
215
|
+
const [, dirtyMajor, dirtyMinor, dirtyPatch, testTag, dirtyTestVersion] = currentVersion.match(regex);
|
|
216
|
+
const major = parseInt(dirtyMajor);
|
|
217
|
+
const minor = parseInt(dirtyMinor) || 0;
|
|
218
|
+
const patch = parseInt(dirtyPatch) || 0;
|
|
219
|
+
const testVersion = parseInt(dirtyTestVersion) || 0;
|
|
215
220
|
const nextMajor = `${major + 1}.0.0`;
|
|
216
221
|
const nextMinor = `${major}.${minor + 1}.0`;
|
|
217
222
|
const nextPatch = `${major}.${minor}.${patch + 1}`;
|
|
218
|
-
const
|
|
223
|
+
const nextAlpha = testTag === 'alpha' ? `${major}.${minor}.${patch}-alpha.${testVersion + 1}` : `${major}.${minor}.${patch + 1}-alpha.1`;
|
|
224
|
+
const nextBeta = testTag === 'beta' ? `${major}.${minor}.${patch}-beta.${testVersion + 1}` : `${major}.${minor}.${patch + 1}-beta.1`;
|
|
225
|
+
const nextTestTag = testTag && !['alpha', 'beta'].includes(testTag) ? `${major}.${minor}.${patch}-${testTag}.${testVersion + 1}` : null;
|
|
219
226
|
return {
|
|
220
227
|
nextMajor,
|
|
221
228
|
nextMinor,
|
|
222
229
|
nextPatch,
|
|
223
|
-
|
|
230
|
+
nextAlpha,
|
|
231
|
+
nextBeta,
|
|
232
|
+
nextTestTag,
|
|
233
|
+
testTag
|
|
224
234
|
};
|
|
225
235
|
};
|
|
226
236
|
const promptForVersion = async currentVersion => {
|
|
@@ -228,7 +238,10 @@ const promptForVersion = async currentVersion => {
|
|
|
228
238
|
nextMajor,
|
|
229
239
|
nextMinor,
|
|
230
240
|
nextPatch,
|
|
231
|
-
|
|
241
|
+
nextAlpha,
|
|
242
|
+
nextBeta,
|
|
243
|
+
nextTestTag,
|
|
244
|
+
testTag
|
|
232
245
|
} = getNextVersions(currentVersion);
|
|
233
246
|
const choices = [{
|
|
234
247
|
hint: '(major release)',
|
|
@@ -239,10 +252,16 @@ const promptForVersion = async currentVersion => {
|
|
|
239
252
|
}, {
|
|
240
253
|
hint: '(patch release)',
|
|
241
254
|
value: nextPatch
|
|
255
|
+
}, {
|
|
256
|
+
hint: '(alpha release)',
|
|
257
|
+
value: nextAlpha
|
|
242
258
|
}, {
|
|
243
259
|
hint: '(beta release)',
|
|
244
260
|
value: nextBeta
|
|
245
|
-
}, {
|
|
261
|
+
}, ...(nextTestTag ? [{
|
|
262
|
+
hint: `(${testTag} release)`,
|
|
263
|
+
value: nextTestTag
|
|
264
|
+
}] : []), {
|
|
246
265
|
hint: '(current version)',
|
|
247
266
|
value: currentVersion
|
|
248
267
|
}, {
|
|
@@ -302,6 +321,19 @@ const getGitTagSuffix = async () => {
|
|
|
302
321
|
});
|
|
303
322
|
return tagSuffix;
|
|
304
323
|
};
|
|
324
|
+
const getGitAnnotationMessage = async ({
|
|
325
|
+
tagName
|
|
326
|
+
}) => {
|
|
327
|
+
const {
|
|
328
|
+
annotationMessage
|
|
329
|
+
} = await prompt({
|
|
330
|
+
type: 'input',
|
|
331
|
+
name: 'annotationMessage',
|
|
332
|
+
message: 'What annotation message would you like to add to git tag?',
|
|
333
|
+
initial: tagName
|
|
334
|
+
});
|
|
335
|
+
return annotationMessage;
|
|
336
|
+
};
|
|
305
337
|
const confirmPushCommit = async buildMessage => {
|
|
306
338
|
const {
|
|
307
339
|
confirm
|
|
@@ -425,19 +457,19 @@ const commitAndPushNewBuild = async config => {
|
|
|
425
457
|
await createNewBuildCommit(config);
|
|
426
458
|
await pushToGitRemote();
|
|
427
459
|
};
|
|
428
|
-
const confirmPushTag = async tagName => {
|
|
460
|
+
const confirmPushTag = async (tagName, annotationMessage) => {
|
|
429
461
|
const {
|
|
430
462
|
confirm
|
|
431
463
|
} = await prompt([{
|
|
432
464
|
type: 'confirm',
|
|
433
465
|
name: 'confirm',
|
|
434
|
-
message: `${_ansiColors.default.bold.red('[Warning]')} Push new tag ${_ansiColors.default.bold.yellow(tagName)} to git remote?`
|
|
466
|
+
message: `${_ansiColors.default.bold.red('[Warning]')} Push new tag ${_ansiColors.default.bold.yellow(tagName)} with annotation message "${_ansiColors.default.bold.yellow(annotationMessage)}" to git remote?`
|
|
435
467
|
}]);
|
|
436
468
|
return confirm;
|
|
437
469
|
};
|
|
438
|
-
const createGitTag = async tagName => {
|
|
470
|
+
const createGitTag = async (tagName, annotationMessage) => {
|
|
439
471
|
try {
|
|
440
|
-
await (0, _zx.$)`git tag ${tagName}`;
|
|
472
|
+
await (0, _zx.$)`git tag -a ${tagName} -m "${annotationMessage}"`;
|
|
441
473
|
} catch (err) {
|
|
442
474
|
console.log(err.stderr || err);
|
|
443
475
|
process.exit(1);
|
|
@@ -453,11 +485,12 @@ const pushGitTag = async tagName => {
|
|
|
453
485
|
};
|
|
454
486
|
const createAndPushGitTag = async ({
|
|
455
487
|
tagName,
|
|
488
|
+
annotationMessage,
|
|
456
489
|
noConfirm
|
|
457
490
|
}) => {
|
|
458
|
-
const confirmAnswer = noConfirm || (await confirmPushTag(tagName));
|
|
491
|
+
const confirmAnswer = noConfirm || (await confirmPushTag(tagName, annotationMessage));
|
|
459
492
|
if (confirmAnswer) {
|
|
460
|
-
await createGitTag(tagName);
|
|
493
|
+
await createGitTag(tagName, annotationMessage);
|
|
461
494
|
await pushGitTag(tagName);
|
|
462
495
|
}
|
|
463
496
|
};
|
|
@@ -497,9 +530,11 @@ const displayReleaseInfo = config => {
|
|
|
497
530
|
packagePath,
|
|
498
531
|
buildMessage,
|
|
499
532
|
tagName,
|
|
533
|
+
annotationMessage,
|
|
500
534
|
publishable,
|
|
501
535
|
npmjsTag,
|
|
502
|
-
isBetaRelease
|
|
536
|
+
isBetaRelease,
|
|
537
|
+
noGitTag
|
|
503
538
|
} = config;
|
|
504
539
|
console.log(`
|
|
505
540
|
|
|
@@ -509,8 +544,9 @@ ${_ansiColors.default.blue('Version:')} ${version}
|
|
|
509
544
|
${_ansiColors.default.blue('Root directory:')} ${repositoryRoot}
|
|
510
545
|
${_ansiColors.default.blue('Package name:')} ${packageName}
|
|
511
546
|
${_ansiColors.default.blue('package.json path:')} ${_path.default.join(packagePath, 'package.json')}${buildMessage ? `
|
|
512
|
-
${_ansiColors.default.blue('Commit message:')} ${buildMessage}` : ''}${isBetaRelease ? '' : `
|
|
513
|
-
${_ansiColors.default.blue('Git tag:')} ${tagName}`}${
|
|
547
|
+
${_ansiColors.default.blue('Commit message:')} ${buildMessage}` : ''}${isBetaRelease || noGitTag ? '' : `
|
|
548
|
+
${_ansiColors.default.blue('Git tag:')} ${tagName}`}${isBetaRelease || noGitTag ? '' : `
|
|
549
|
+
${_ansiColors.default.blue('Git tag annotation:')} ${annotationMessage}`}${publishable ? `
|
|
514
550
|
${_ansiColors.default.blue('Npmjs tag:')} ${npmjsTag}` : ''}
|
|
515
551
|
${_ansiColors.default.bold.green('=============================================')}
|
|
516
552
|
`);
|
|
@@ -551,6 +587,11 @@ const optionList = [{
|
|
|
551
587
|
type: String,
|
|
552
588
|
alias: 't',
|
|
553
589
|
description: 'tag suffix to be appended to the version when pushing to git'
|
|
590
|
+
}, {
|
|
591
|
+
name: 'annotation-message',
|
|
592
|
+
type: String,
|
|
593
|
+
alias: 'm',
|
|
594
|
+
description: 'annotation message that will annotate the git tag'
|
|
554
595
|
}, {
|
|
555
596
|
name: 'branch-filter',
|
|
556
597
|
type: String,
|
|
@@ -560,6 +601,10 @@ const optionList = [{
|
|
|
560
601
|
name: 'no-commit',
|
|
561
602
|
type: Boolean,
|
|
562
603
|
description: 'do not create a new commit on git (in case the goal is just tagging it)'
|
|
604
|
+
}, {
|
|
605
|
+
name: 'no-git-tag',
|
|
606
|
+
type: Boolean,
|
|
607
|
+
description: 'do not create a new tag on git'
|
|
563
608
|
}, {
|
|
564
609
|
name: 'no-confirm',
|
|
565
610
|
type: Boolean,
|
|
@@ -589,6 +634,7 @@ validateArgs(args);
|
|
|
589
634
|
const config = {};
|
|
590
635
|
config.noConfirm = !!args['no-confirm'];
|
|
591
636
|
config.noCommit = !!args['no-commit'];
|
|
637
|
+
config.noGitTag = !!args['no-git-tag'];
|
|
592
638
|
config.repositoryRoot = await getGitRootDirectory();
|
|
593
639
|
config.branch = args.branch || (await getBranch({
|
|
594
640
|
branchFilter: args['branch-filter']
|
|
@@ -601,10 +647,12 @@ config.version = args.version || (await getVersion(config));
|
|
|
601
647
|
config.packageName = await getPackageName(config);
|
|
602
648
|
config.buildMessage = config.noCommit ? '' : getBuildMessage(config);
|
|
603
649
|
config.isBetaRelease = config.version.includes('-beta.');
|
|
604
|
-
if (!config.isBetaRelease) {
|
|
650
|
+
if (!config.isBetaRelease && !config.noGitTag) {
|
|
605
651
|
const tagSuffix = args['tag-suffix'] ?? (await getGitTagSuffix());
|
|
606
652
|
const tagPrefix = config.isPackageInRepositoryRoot ? '' : `${config.packageName}/`;
|
|
607
653
|
config.tagName = `${tagPrefix}v${config.version}${tagSuffix}`;
|
|
654
|
+
const annotationMessage = args['annotation-message'] ?? (await getGitAnnotationMessage(config));
|
|
655
|
+
config.annotationMessage = annotationMessage;
|
|
608
656
|
}
|
|
609
657
|
config.publishable = !!args.publishable;
|
|
610
658
|
if (config.publishable) {
|
|
@@ -624,7 +672,7 @@ if (!config.noConfirm) {
|
|
|
624
672
|
if (!config.noCommit) {
|
|
625
673
|
await commitAndPushNewBuild(config);
|
|
626
674
|
}
|
|
627
|
-
if (!config.isBetaRelease) {
|
|
675
|
+
if (!config.isBetaRelease && !config.noGitTag) {
|
|
628
676
|
await createAndPushGitTag(config);
|
|
629
677
|
}
|
|
630
678
|
if (config.publishable) {
|
package/package.json
CHANGED
package/src/tag-release.mjs
CHANGED
|
@@ -215,28 +215,58 @@ The tag-release script must run from a npm project.
|
|
|
215
215
|
}
|
|
216
216
|
|
|
217
217
|
const getNextVersions = ( currentVersion ) => {
|
|
218
|
-
const
|
|
218
|
+
const regex = /^(\d+)(?:\.(\d+))?(?:\.(\d+))?(?:-(\w+)\.(\d+))?$/i
|
|
219
|
+
const [ , dirtyMajor, dirtyMinor, dirtyPatch, testTag, dirtyTestVersion ] = currentVersion.match( regex )
|
|
220
|
+
const major = parseInt( dirtyMajor )
|
|
221
|
+
const minor = parseInt( dirtyMinor ) || 0
|
|
222
|
+
const patch = parseInt( dirtyPatch ) || 0
|
|
223
|
+
const testVersion = parseInt( dirtyTestVersion ) || 0
|
|
219
224
|
|
|
220
225
|
const nextMajor = `${major + 1}.0.0`
|
|
221
226
|
const nextMinor = `${major}.${minor + 1}.0`
|
|
222
227
|
const nextPatch = `${major}.${minor}.${patch + 1}`
|
|
223
|
-
|
|
228
|
+
|
|
229
|
+
const nextAlpha = testTag === 'alpha' ?
|
|
230
|
+
`${major}.${minor}.${patch}-alpha.${testVersion + 1}` :
|
|
231
|
+
`${major}.${minor}.${patch + 1}-alpha.1`
|
|
232
|
+
|
|
233
|
+
const nextBeta = testTag === 'beta' ?
|
|
234
|
+
`${major}.${minor}.${patch}-beta.${testVersion + 1}` :
|
|
235
|
+
`${major}.${minor}.${patch + 1}-beta.1`
|
|
236
|
+
|
|
237
|
+
const nextTestTag = testTag && ![ 'alpha', 'beta' ].includes( testTag ) ?
|
|
238
|
+
`${major}.${minor}.${patch}-${testTag}.${testVersion + 1}` :
|
|
239
|
+
null
|
|
224
240
|
|
|
225
241
|
return {
|
|
226
242
|
nextMajor,
|
|
227
243
|
nextMinor,
|
|
228
244
|
nextPatch,
|
|
245
|
+
nextAlpha,
|
|
229
246
|
nextBeta,
|
|
247
|
+
nextTestTag,
|
|
248
|
+
testTag,
|
|
230
249
|
}
|
|
231
250
|
}
|
|
232
251
|
|
|
233
252
|
const promptForVersion = async ( currentVersion ) => {
|
|
234
|
-
const {
|
|
253
|
+
const {
|
|
254
|
+
nextMajor,
|
|
255
|
+
nextMinor,
|
|
256
|
+
nextPatch,
|
|
257
|
+
nextAlpha,
|
|
258
|
+
nextBeta,
|
|
259
|
+
nextTestTag,
|
|
260
|
+
testTag
|
|
261
|
+
} = getNextVersions( currentVersion )
|
|
262
|
+
|
|
235
263
|
const choices = [
|
|
236
264
|
{ hint : '(major release)', value : nextMajor },
|
|
237
265
|
{ hint : '(minor release)', value : nextMinor },
|
|
238
266
|
{ hint : '(patch release)', value : nextPatch },
|
|
267
|
+
{ hint : '(alpha release)', value : nextAlpha },
|
|
239
268
|
{ hint : '(beta release)', value : nextBeta },
|
|
269
|
+
...( nextTestTag ? [ { hint : `(${testTag} release)`, value : nextTestTag } ] : [] ),
|
|
240
270
|
{ hint : '(current version)', value : currentVersion },
|
|
241
271
|
{ value : 'custom' },
|
|
242
272
|
]
|
|
@@ -288,6 +318,16 @@ const getGitTagSuffix = async () => {
|
|
|
288
318
|
return tagSuffix
|
|
289
319
|
}
|
|
290
320
|
|
|
321
|
+
const getGitAnnotationMessage = async ( { tagName } ) => {
|
|
322
|
+
const { annotationMessage } = await prompt( {
|
|
323
|
+
type : 'input',
|
|
324
|
+
name : 'annotationMessage',
|
|
325
|
+
message : 'What annotation message would you like to add to git tag?',
|
|
326
|
+
initial : tagName
|
|
327
|
+
} )
|
|
328
|
+
return annotationMessage
|
|
329
|
+
}
|
|
330
|
+
|
|
291
331
|
const confirmPushCommit = async ( buildMessage ) => {
|
|
292
332
|
const { confirm } = await prompt( [ {
|
|
293
333
|
type : 'confirm',
|
|
@@ -406,18 +446,18 @@ const commitAndPushNewBuild = async ( config ) => {
|
|
|
406
446
|
await pushToGitRemote()
|
|
407
447
|
}
|
|
408
448
|
|
|
409
|
-
const confirmPushTag = async ( tagName ) => {
|
|
449
|
+
const confirmPushTag = async ( tagName, annotationMessage ) => {
|
|
410
450
|
const { confirm } = await prompt( [ {
|
|
411
451
|
type : 'confirm',
|
|
412
452
|
name : 'confirm',
|
|
413
|
-
message : `${colors.bold.red( '[Warning]' )} Push new tag ${colors.bold.yellow( tagName )} to git remote?`
|
|
453
|
+
message : `${colors.bold.red( '[Warning]' )} Push new tag ${colors.bold.yellow( tagName )} with annotation message "${colors.bold.yellow( annotationMessage )}" to git remote?`
|
|
414
454
|
} ] )
|
|
415
455
|
return confirm
|
|
416
456
|
}
|
|
417
457
|
|
|
418
|
-
const createGitTag = async ( tagName ) => {
|
|
458
|
+
const createGitTag = async ( tagName, annotationMessage ) => {
|
|
419
459
|
try {
|
|
420
|
-
await $`git tag ${tagName}`
|
|
460
|
+
await $`git tag -a ${tagName} -m "${annotationMessage}"`
|
|
421
461
|
} catch ( err ) {
|
|
422
462
|
console.log( err.stderr || err )
|
|
423
463
|
process.exit( 1 )
|
|
@@ -433,10 +473,10 @@ const pushGitTag = async ( tagName ) => {
|
|
|
433
473
|
}
|
|
434
474
|
}
|
|
435
475
|
|
|
436
|
-
const createAndPushGitTag = async ( { tagName, noConfirm } ) => {
|
|
437
|
-
const confirmAnswer = noConfirm || await confirmPushTag( tagName )
|
|
476
|
+
const createAndPushGitTag = async ( { tagName, annotationMessage, noConfirm } ) => {
|
|
477
|
+
const confirmAnswer = noConfirm || await confirmPushTag( tagName, annotationMessage )
|
|
438
478
|
if ( confirmAnswer ) {
|
|
439
|
-
await createGitTag( tagName )
|
|
479
|
+
await createGitTag( tagName, annotationMessage )
|
|
440
480
|
await pushGitTag( tagName )
|
|
441
481
|
}
|
|
442
482
|
}
|
|
@@ -474,9 +514,11 @@ const displayReleaseInfo = ( config ) => {
|
|
|
474
514
|
packagePath,
|
|
475
515
|
buildMessage,
|
|
476
516
|
tagName,
|
|
517
|
+
annotationMessage,
|
|
477
518
|
publishable,
|
|
478
519
|
npmjsTag,
|
|
479
|
-
isBetaRelease
|
|
520
|
+
isBetaRelease,
|
|
521
|
+
noGitTag,
|
|
480
522
|
} = config
|
|
481
523
|
|
|
482
524
|
console.log( `
|
|
@@ -487,8 +529,9 @@ ${colors.blue( 'Version:' )} ${version}
|
|
|
487
529
|
${colors.blue( 'Root directory:' )} ${repositoryRoot}
|
|
488
530
|
${colors.blue( 'Package name:' )} ${packageName}
|
|
489
531
|
${colors.blue( 'package.json path:' )} ${path.join( packagePath, 'package.json' )}${buildMessage ? `
|
|
490
|
-
${colors.blue( 'Commit message:' )} ${buildMessage}` : ''}${isBetaRelease ? '' : `
|
|
491
|
-
${colors.blue( 'Git tag:' )} ${tagName}`}${
|
|
532
|
+
${colors.blue( 'Commit message:' )} ${buildMessage}` : ''}${isBetaRelease || noGitTag ? '' : `
|
|
533
|
+
${colors.blue( 'Git tag:' )} ${tagName}`}${isBetaRelease || noGitTag ? '' : `
|
|
534
|
+
${colors.blue( 'Git tag annotation:' )} ${annotationMessage}`}${publishable ? `
|
|
492
535
|
${colors.blue( 'Npmjs tag:' )} ${npmjsTag}` : ''}
|
|
493
536
|
${colors.bold.green( '=============================================' )}
|
|
494
537
|
` )
|
|
@@ -536,6 +579,12 @@ const optionList = [
|
|
|
536
579
|
alias : 't',
|
|
537
580
|
description : 'tag suffix to be appended to the version when pushing to git',
|
|
538
581
|
},
|
|
582
|
+
{
|
|
583
|
+
name : 'annotation-message',
|
|
584
|
+
type : String,
|
|
585
|
+
alias : 'm',
|
|
586
|
+
description : 'annotation message that will annotate the git tag',
|
|
587
|
+
},
|
|
539
588
|
{
|
|
540
589
|
name : 'branch-filter',
|
|
541
590
|
type : String,
|
|
@@ -547,6 +596,11 @@ const optionList = [
|
|
|
547
596
|
type : Boolean,
|
|
548
597
|
description : 'do not create a new commit on git (in case the goal is just tagging it)',
|
|
549
598
|
},
|
|
599
|
+
{
|
|
600
|
+
name : 'no-git-tag',
|
|
601
|
+
type : Boolean,
|
|
602
|
+
description : 'do not create a new tag on git',
|
|
603
|
+
},
|
|
550
604
|
{
|
|
551
605
|
name : 'no-confirm',
|
|
552
606
|
type : Boolean,
|
|
@@ -586,6 +640,8 @@ config.noConfirm = !!args['no-confirm']
|
|
|
586
640
|
|
|
587
641
|
config.noCommit = !!args['no-commit']
|
|
588
642
|
|
|
643
|
+
config.noGitTag = !!args['no-git-tag']
|
|
644
|
+
|
|
589
645
|
config.repositoryRoot = await getGitRootDirectory()
|
|
590
646
|
|
|
591
647
|
config.branch = args.branch || await getBranch( { branchFilter : args['branch-filter'] } )
|
|
@@ -605,10 +661,13 @@ config.buildMessage = config.noCommit ? '' : getBuildMessage( config )
|
|
|
605
661
|
|
|
606
662
|
config.isBetaRelease = config.version.includes( '-beta.' )
|
|
607
663
|
|
|
608
|
-
if ( !config.isBetaRelease ) {
|
|
664
|
+
if ( !config.isBetaRelease && !config.noGitTag ) {
|
|
609
665
|
const tagSuffix = args['tag-suffix'] ?? await getGitTagSuffix()
|
|
610
666
|
const tagPrefix = config.isPackageInRepositoryRoot ? '' : `${config.packageName}/`
|
|
611
667
|
config.tagName = `${tagPrefix}v${config.version}${tagSuffix}`
|
|
668
|
+
|
|
669
|
+
const annotationMessage = args['annotation-message'] ?? await getGitAnnotationMessage( config )
|
|
670
|
+
config.annotationMessage = annotationMessage
|
|
612
671
|
}
|
|
613
672
|
|
|
614
673
|
config.publishable = !!args.publishable
|
|
@@ -627,7 +686,7 @@ if ( !config.noConfirm ) {
|
|
|
627
686
|
}
|
|
628
687
|
|
|
629
688
|
if ( !config.noCommit ) { await commitAndPushNewBuild( config ) }
|
|
630
|
-
if ( !config.isBetaRelease ) { await createAndPushGitTag( config ) }
|
|
689
|
+
if ( !config.isBetaRelease && !config.noGitTag ) { await createAndPushGitTag( config ) }
|
|
631
690
|
if ( config.publishable ) { await publishToNpmjs( config ) }
|
|
632
691
|
|
|
633
692
|
process.exit()
|