@farris/cli 1.0.21 → 1.0.24
Sign up to get free protection for your applications and to get access to all the features.
- package/ci/cli.js +21 -12
- package/package.json +1 -1
package/ci/cli.js
CHANGED
@@ -218,7 +218,7 @@ function updateProjectVersion(projectInfo, updateVersionType) {
|
|
218
218
|
})
|
219
219
|
}
|
220
220
|
|
221
|
-
function updateMonoWorkspaceVersion(monoWorkspace, updateVersionType) {
|
221
|
+
function updateMonoWorkspaceVersion(monoWorkspace, updateVersionType, commitUrl) {
|
222
222
|
let npmCommandArray = [];
|
223
223
|
switch (updateVersionType) {
|
224
224
|
case 'prerelease':
|
@@ -234,11 +234,24 @@ function updateMonoWorkspaceVersion(monoWorkspace, updateVersionType) {
|
|
234
234
|
npmCommandArray = ['version', 'major'];
|
235
235
|
break;
|
236
236
|
}
|
237
|
+
console.log(`executing npm version --${updateVersionType} in root directory.`)
|
237
238
|
childProcess.execSync('npm', npmCommandArray);
|
238
239
|
const packageJsonFilePath = `./package.json`;
|
239
240
|
const packageConfig = JSON.parse(fs.readFileSync(packageJsonFilePath, 'utf-8'));
|
240
|
-
console.log(`update MonoWorkspace version to v${packageConfig.version}`);
|
241
241
|
monoWorkspace.version = packageConfig.version;
|
242
|
+
// 向git缓冲区中添加变更
|
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
|
+
const branch = childProcess.execSync("git", ["rev-parse", "--abbrev-ref", "HEAD"]);
|
248
|
+
console.log(`executing git push ${branch}`);
|
249
|
+
// 提交变更集
|
250
|
+
if (commitUrl) {
|
251
|
+
childProcess.execSync("git", ["push", commitUrl]);
|
252
|
+
} else {
|
253
|
+
childProcess.execSync('git', ['push']);
|
254
|
+
}
|
242
255
|
}
|
243
256
|
|
244
257
|
function builderVersionChangeMessage(prefix, updatedVersions, suffix = '') {
|
@@ -253,7 +266,7 @@ function builderVersionChangeMessage(prefix, updatedVersions, suffix = '') {
|
|
253
266
|
return `${versionMessage} ${suffix}`;
|
254
267
|
}
|
255
268
|
|
256
|
-
function
|
269
|
+
function commitVersionChanges(updatedVersions, commitUrl) {
|
257
270
|
const commitMessage = builderVersionChangeMessage('Update', updatedVersions, '. [skip ci]');
|
258
271
|
|
259
272
|
if (commitMessage) {
|
@@ -268,9 +281,9 @@ function commitChanges(updatedVersions, commitUrl) {
|
|
268
281
|
console.log(`executing git push ${branch}`);
|
269
282
|
// 提交变更集
|
270
283
|
if (commitUrl) {
|
271
|
-
|
284
|
+
childProcess.execSync("git", ["push", commitUrl]);
|
272
285
|
} else {
|
273
|
-
|
286
|
+
childProcess.execSync('git', ['push']);
|
274
287
|
}
|
275
288
|
}
|
276
289
|
}
|
@@ -278,7 +291,6 @@ function commitChanges(updatedVersions, commitUrl) {
|
|
278
291
|
function buildWorkspace(workspace) {
|
279
292
|
console.log(`executing lerna run build --scope=${workspace.packageName}`)
|
280
293
|
return childProcess.exec('lerna', ['run', 'build', `--scope=${workspace.packageName}`]);
|
281
|
-
// lerna run build --scope=@farris/ide-framework
|
282
294
|
}
|
283
295
|
|
284
296
|
function addTagToMonoWorkspace(monoWorkspace, commitUrl) {
|
@@ -361,7 +373,7 @@ function publish(commitUrl, updateVersionType) {
|
|
361
373
|
const projects = monoWorkspace.projects;
|
362
374
|
const checkProjects = projects.map((projectInfo) => {
|
363
375
|
const lastCommit = getLastCommit();
|
364
|
-
console.log(`last commit ${lastCommit}`);
|
376
|
+
console.log(`last commit ${lastCommit}`);
|
365
377
|
let checkPromise = checkProjectChanges(projectInfo, lastCommit);
|
366
378
|
let changedPromise = checkPromise.then(hasChanged => {
|
367
379
|
projectInfo.hasChanged = hasChanged;
|
@@ -379,9 +391,6 @@ function publish(commitUrl, updateVersionType) {
|
|
379
391
|
chain = chain.then(monoWorkspace => {
|
380
392
|
const changedProjects = monoWorkspace.changedProjects;
|
381
393
|
const prereleasePromise = changedProjects.map(projectInfo => updateProjectVersion(projectInfo, updateVersionType));
|
382
|
-
if (changedProjects) {
|
383
|
-
|
384
|
-
}
|
385
394
|
return Promise.all(prereleasePromise)
|
386
395
|
.then((results) => {
|
387
396
|
results.reduce((workspace, updateResult) => {
|
@@ -389,9 +398,9 @@ function publish(commitUrl, updateVersionType) {
|
|
389
398
|
Object.assign(workspace.updateResult, updateResult);
|
390
399
|
return workspace;
|
391
400
|
}, monoWorkspace);
|
392
|
-
updateMonoWorkspaceVersion(monoWorkspace, updateVersionType);
|
393
401
|
const updatedVersions = monoWorkspace.updateResult;
|
394
|
-
|
402
|
+
commitVersionChanges(updatedVersions, commitUrl);
|
403
|
+
updateMonoWorkspaceVersion(monoWorkspace, updateVersionType, commitUrl);
|
395
404
|
return Promise.resolve(monoWorkspace);
|
396
405
|
});
|
397
406
|
});
|