@farris/cli 1.0.26 → 1.0.27
Sign up to get free protection for your applications and to get access to all the features.
- package/ci/cli.js +47 -23
- package/package.json +1 -1
package/ci/cli.js
CHANGED
@@ -240,10 +240,10 @@ function updateMonoWorkspaceVersion(monoWorkspace, updateVersionType, commitUrl)
|
|
240
240
|
const packageConfig = JSON.parse(fs.readFileSync(packageJsonFilePath, 'utf-8'));
|
241
241
|
monoWorkspace.version = packageConfig.version;
|
242
242
|
// 向git缓冲区中添加变更
|
243
|
-
|
244
|
-
//
|
245
|
-
|
246
|
-
|
243
|
+
childProcess.execSync('git', ['add', '.']);
|
244
|
+
// 提交变更记录
|
245
|
+
childProcess.execSync('git', ['commit', '-m', `Update MonoWorkspace version to v${packageConfig.version}. [skip ci]`]);
|
246
|
+
console.log(`Update MonoWorkspace version to v${packageConfig.version}`);
|
247
247
|
const branch = childProcess.execSync("git", ["rev-parse", "--abbrev-ref", "HEAD"]);
|
248
248
|
// 提交变更集
|
249
249
|
if (commitUrl) {
|
@@ -267,17 +267,44 @@ function builderVersionChangeMessage(prefix, updatedVersions, suffix = '') {
|
|
267
267
|
return `${versionMessage} ${suffix}`;
|
268
268
|
}
|
269
269
|
|
270
|
-
function commitVersionChanges(updatedVersions, commitUrl) {
|
271
|
-
const commitMessage = builderVersionChangeMessage('
|
272
|
-
|
270
|
+
function commitVersionChanges(updatedVersions, commitUrl, monoWorkspace, updateVersionType) {
|
271
|
+
const commitMessage = builderVersionChangeMessage('update', updatedVersions, '');
|
273
272
|
if (commitMessage) {
|
273
|
+
const updateWorkspaceVersion = ['version', '--force', '--no-git-tag-version', updateVersionType];
|
274
|
+
if (updateVersionType === 'prerelease') {
|
275
|
+
updateWorkspaceVersion.push('--preid=beta');
|
276
|
+
}
|
277
|
+
// switch (updateVersionType) {
|
278
|
+
// case 'prerelease':
|
279
|
+
// updateWorkspaceVersion = ['version', 'prerelease', '--preid=beta', '--force', '--no-git-tag-version'];
|
280
|
+
// break;
|
281
|
+
// case 'patch':
|
282
|
+
// updateWorkspaceVersion = ['version', 'patch', '--force', '--no-git-tag-version'];
|
283
|
+
// break;
|
284
|
+
// case 'minor':
|
285
|
+
// updateWorkspaceVersion = ['version', 'minor', '--force', '--no-git-tag-version'];
|
286
|
+
// break;
|
287
|
+
// case 'major':
|
288
|
+
// updateWorkspaceVersion = ['version', 'major', '--force', '--no-git-tag-version'];
|
289
|
+
// break;
|
290
|
+
// }
|
291
|
+
console.log(`executing npm ${updateWorkspaceVersion.join(' ')} in root directory.`)
|
292
|
+
childProcess.execSync('npm', updateWorkspaceVersion);
|
293
|
+
|
294
|
+
const packageJsonFilePath = `./package.json`;
|
295
|
+
const packageConfig = JSON.parse(fs.readFileSync(packageJsonFilePath, 'utf-8'));
|
296
|
+
monoWorkspace.version = packageConfig.version;
|
297
|
+
|
274
298
|
// 向git缓冲区中添加变更
|
275
299
|
childProcess.execSync('git', ['add', '.']);
|
276
|
-
//
|
277
|
-
childProcess.execSync('git', ['commit', '-m',
|
300
|
+
// 提交变更记录
|
301
|
+
childProcess.execSync('git', ['commit', '-m', `Update workspace version to v${packageConfig.version} for ${commitMessage}. [skip ci]`]);
|
278
302
|
|
303
|
+
// // 向git缓冲区中添加变更
|
304
|
+
// childProcess.execSync('git', ['add', '.']);
|
305
|
+
// // // 提交变更记录
|
306
|
+
// childProcess.execSync('git', ['commit', '-m', `${commitMessage}`]);
|
279
307
|
const branch = childProcess.execSync("git", ["rev-parse", "--abbrev-ref", "HEAD"]);
|
280
|
-
|
281
308
|
// 提交变更集
|
282
309
|
if (commitUrl) {
|
283
310
|
console.log(`executing git push ${branch} to ${commitUrl}`);
|
@@ -295,9 +322,6 @@ function buildWorkspace(workspace) {
|
|
295
322
|
}
|
296
323
|
|
297
324
|
function addTagToMonoWorkspace(monoWorkspace, commitUrl) {
|
298
|
-
// const tagMessage = builderVersionChangeMessage('Publish npm packages ', monoWorkspace.updateResult, '.');
|
299
|
-
// const date = moment(new Date());
|
300
|
-
// const tagVersion = `v${date.format('YYYYMMDDHHmmss')}`;
|
301
325
|
const monoWorkspaceVersion = monoWorkspace.version;
|
302
326
|
childProcess.execSync('git', ['tag', monoWorkspaceVersion, '-m', 'Publish npm packages. [skip ci]']);
|
303
327
|
// 提交变更集
|
@@ -401,16 +425,16 @@ function publish(commitUrl, updateVersionType) {
|
|
401
425
|
}, monoWorkspace);
|
402
426
|
const updatedVersions = monoWorkspace.updateResult;
|
403
427
|
if (updatedVersions) {
|
404
|
-
return commitVersionChanges(updatedVersions, commitUrl)
|
405
|
-
.then((result) => {
|
406
|
-
|
407
|
-
|
408
|
-
|
409
|
-
|
410
|
-
|
411
|
-
|
412
|
-
|
413
|
-
})
|
428
|
+
return commitVersionChanges(updatedVersions, commitUrl, monoWorkspace, updateVersionType)
|
429
|
+
// .then((result) => {
|
430
|
+
// if (result.stderr) {
|
431
|
+
// console.log(result.stderr);
|
432
|
+
// }
|
433
|
+
// if (result.stdout) {
|
434
|
+
// console.log(result.stdout);
|
435
|
+
// }
|
436
|
+
// return updateMonoWorkspaceVersion(monoWorkspace, updateVersionType, commitUrl);
|
437
|
+
// })
|
414
438
|
.then((result) => {
|
415
439
|
if (result.stderr) {
|
416
440
|
console.log(result.stderr);
|