@farris/cli 1.0.25 → 1.0.26
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/ci/cli.js +58 -25
- package/package.json +1 -1
package/ci/cli.js
CHANGED
@@ -168,7 +168,7 @@ function checkProjectChanges(projectInfo, lastCommit) {
|
|
168
168
|
const hasChanges = changedFiles.length > 0;
|
169
169
|
if (hasChanges) {
|
170
170
|
projectInfo.workspace.hasChanged = hasChanges;
|
171
|
-
console.log(`${packageName} has changed
|
171
|
+
console.log(`${packageName} has changed since latest tag ${lastCommit}.`)
|
172
172
|
} else {
|
173
173
|
console.log(`${packageName} has not changed.`)
|
174
174
|
}
|
@@ -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
|
-
childProcess.execSync('git', ['add', '.']);
|
243
|
+
// childProcess.execSync('git', ['add', '.']);
|
244
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}`);
|
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) {
|
@@ -276,8 +276,6 @@ function commitVersionChanges(updatedVersions, commitUrl) {
|
|
276
276
|
// // 提交变更记录
|
277
277
|
childProcess.execSync('git', ['commit', '-m', `${commitMessage}`]);
|
278
278
|
|
279
|
-
console.log(commitMessage);
|
280
|
-
|
281
279
|
const branch = childProcess.execSync("git", ["rev-parse", "--abbrev-ref", "HEAD"]);
|
282
280
|
|
283
281
|
// 提交变更集
|
@@ -374,9 +372,9 @@ function publish(commitUrl, updateVersionType) {
|
|
374
372
|
// 3. 检查代码提交记录,获取自上次发布以来所有发生变化的Angular工程
|
375
373
|
chain = chain.then(monoWorkspace => {
|
376
374
|
const projects = monoWorkspace.projects;
|
375
|
+
const lastCommit = getLastCommit();
|
376
|
+
console.log(`last commit ${lastCommit}`);
|
377
377
|
const checkProjects = projects.map((projectInfo) => {
|
378
|
-
const lastCommit = getLastCommit();
|
379
|
-
console.log(`last commit ${lastCommit}`);
|
380
378
|
let checkPromise = checkProjectChanges(projectInfo, lastCommit);
|
381
379
|
let changedPromise = checkPromise.then(hasChanged => {
|
382
380
|
projectInfo.hasChanged = hasChanged;
|
@@ -402,13 +400,30 @@ function publish(commitUrl, updateVersionType) {
|
|
402
400
|
return workspace;
|
403
401
|
}, monoWorkspace);
|
404
402
|
const updatedVersions = monoWorkspace.updateResult;
|
405
|
-
|
406
|
-
|
407
|
-
|
408
|
-
|
409
|
-
|
410
|
-
|
411
|
-
|
403
|
+
if (updatedVersions) {
|
404
|
+
return commitVersionChanges(updatedVersions, commitUrl)
|
405
|
+
.then((result) => {
|
406
|
+
if (result.stderr) {
|
407
|
+
console.log(result.stderr);
|
408
|
+
}
|
409
|
+
if (result.stdout) {
|
410
|
+
console.log(result.stdout);
|
411
|
+
}
|
412
|
+
return updateMonoWorkspaceVersion(monoWorkspace, updateVersionType, commitUrl);
|
413
|
+
})
|
414
|
+
.then((result) => {
|
415
|
+
if (result.stderr) {
|
416
|
+
console.log(result.stderr);
|
417
|
+
}
|
418
|
+
if (result.stdout) {
|
419
|
+
console.log(result.stdout);
|
420
|
+
}
|
421
|
+
return Promise.resolve(monoWorkspace);
|
422
|
+
});
|
423
|
+
} else {
|
424
|
+
return Promise.resolve(monoWorkspace);
|
425
|
+
}
|
426
|
+
|
412
427
|
});
|
413
428
|
});
|
414
429
|
// 5. 编译所有Angular工作区
|
@@ -416,20 +431,38 @@ function publish(commitUrl, updateVersionType) {
|
|
416
431
|
const buildPromises = monoWorkspace.workspaces
|
417
432
|
.filter(workspace => workspace.hasChanged)
|
418
433
|
.map((workspace) => buildWorkspace(workspace));
|
419
|
-
|
420
|
-
.
|
421
|
-
|
422
|
-
|
423
|
-
|
434
|
+
if (buildPromises.length) {
|
435
|
+
return Promise.all(buildPromises)
|
436
|
+
.then((results) => {
|
437
|
+
if (results) {
|
438
|
+
results.map((result) => {
|
439
|
+
if (result.stderr) {
|
440
|
+
console.log(result.stderr);
|
441
|
+
}
|
442
|
+
if (result.stdout) {
|
443
|
+
console.log(result.stdout);
|
444
|
+
}
|
445
|
+
});
|
446
|
+
}
|
447
|
+
return Promise.resolve(monoWorkspace);
|
448
|
+
});
|
449
|
+
} else {
|
450
|
+
return Promise.resolve(monoWorkspace);
|
451
|
+
}
|
424
452
|
});
|
425
453
|
// 6. 将变更项目的内容发布为npm包,并增加发布Tag标签
|
426
454
|
chain = chain.then(monoWorkspace => {
|
427
455
|
const changedProjects = monoWorkspace.changedProjects;
|
428
|
-
|
429
|
-
|
430
|
-
.
|
431
|
-
|
432
|
-
|
456
|
+
if (changedProjects.length) {
|
457
|
+
const publishPromises = changedProjects.map(projectInfo => publishToNpmRepository(projectInfo.project.path));
|
458
|
+
Promise.all(publishPromises)
|
459
|
+
.then(() => {
|
460
|
+
return addTagToMonoWorkspace(monoWorkspace, commitUrl);
|
461
|
+
});
|
462
|
+
} else {
|
463
|
+
return Promise.resolve(monoWorkspace);
|
464
|
+
}
|
465
|
+
|
433
466
|
});
|
434
467
|
}
|
435
468
|
|