@farris/cli 1.0.13 → 1.0.17
Sign up to get free protection for your applications and to get access to all the features.
- package/ci/cli.js +15 -25
- package/package.json +1 -1
package/ci/cli.js
CHANGED
@@ -81,10 +81,10 @@ cli
|
|
81
81
|
*/
|
82
82
|
function getLastCommit() {
|
83
83
|
if (hasTags()) {
|
84
|
-
log
|
84
|
+
console.log("getLastTagInBranch");
|
85
85
|
return childProcess.execSync("git", ["describe", "--tags", "--abbrev=0"]);
|
86
86
|
}
|
87
|
-
log
|
87
|
+
console.log("getFirstCommit");
|
88
88
|
return childProcess.execSync("git", ["rev-list", "--max-parents=0", "HEAD"]);
|
89
89
|
}
|
90
90
|
|
@@ -111,6 +111,7 @@ function hasTags() {
|
|
111
111
|
*/
|
112
112
|
function checkProjectChanges(projectPath) {
|
113
113
|
const lastCommit = getLastCommit();
|
114
|
+
console.log(`last commit ${lastCommit}`);
|
114
115
|
return childProcess
|
115
116
|
// 使用 git diff 命令查询自上传提交以来,目标工程路径下是否有变更的文件
|
116
117
|
.exec("git", ["diff", "--name-only", lastCommit, projectPath])
|
@@ -161,29 +162,16 @@ function builderVersionChangeMessage(prefix, updatedVersions, suffix = '') {
|
|
161
162
|
return latestMessage = latestMessage + message;
|
162
163
|
}, `${prefix} `)
|
163
164
|
return `${versionMessage} ${suffix}`;
|
164
|
-
// const versionMessage = updatedVersions.reduce((latestMessage, updateVersion, index, originalArray) => {
|
165
|
-
// if (Object.keys(updateVersion).length) {
|
166
|
-
// const packageName = Object.keys(updateVersion)[0];
|
167
|
-
// const version = updateVersion[packageName];
|
168
|
-
// let message = `${packageName} to ${version}`;
|
169
|
-
// if (index <= originalArray.length - 2) {
|
170
|
-
// message = message + ', ';
|
171
|
-
// }
|
172
|
-
// latestMessage = latestMessage + message;
|
173
|
-
// }
|
174
|
-
// return latestMessage;
|
175
|
-
// }, `${prefix} `);
|
176
|
-
// return `${versionMessage} ${suffix}`;
|
177
165
|
}
|
178
166
|
|
179
167
|
function commitChanges(updatedVersions, commitUrl) {
|
180
|
-
const commitMessage = builderVersionChangeMessage('Update', updatedVersions, '.');
|
168
|
+
const commitMessage = builderVersionChangeMessage('Update', updatedVersions, '. [skip ci]');
|
181
169
|
|
182
170
|
if (commitMessage) {
|
183
171
|
// 向git缓冲区中添加变更
|
184
172
|
childProcess.execSync('git', ['add', '.']);
|
185
173
|
// // 提交变更记录
|
186
|
-
childProcess.execSync('git', ['commit', '-m', `${commitMessage}
|
174
|
+
childProcess.execSync('git', ['commit', '-m', `${commitMessage}`]);
|
187
175
|
|
188
176
|
console.log(commitMessage);
|
189
177
|
|
@@ -191,9 +179,9 @@ function commitChanges(updatedVersions, commitUrl) {
|
|
191
179
|
console.log(`executing git push ${branch}`);
|
192
180
|
// 提交变更集
|
193
181
|
if (commitUrl) {
|
194
|
-
return childProcess.exec("git", ["push",
|
182
|
+
return childProcess.exec("git", ["push", commitUrl]);
|
195
183
|
} else {
|
196
|
-
return childProcess.exec('git', ['push'
|
184
|
+
return childProcess.exec('git', ['push']);
|
197
185
|
}
|
198
186
|
}
|
199
187
|
}
|
@@ -207,13 +195,15 @@ function buildWorkspace(workspace) {
|
|
207
195
|
function tagMonoWorkspace(monoWorkspace, commitUrl) {
|
208
196
|
// const tagMessage = builderVersionChangeMessage('Publish npm packages ', monoWorkspace.updateResult, '.');
|
209
197
|
const date = moment(new Date());
|
210
|
-
const tagVersion = `v${date.format('
|
211
|
-
childProcess.execSync('git', ['tag', tagVersion, '-m',
|
198
|
+
const tagVersion = `v${date.format('YYYYMMDDHHmmss')}`;
|
199
|
+
childProcess.execSync('git', ['tag', tagVersion, '-m', 'Publish npm packages. [skip ci]']);
|
212
200
|
// 提交变更集
|
213
201
|
if (commitUrl) {
|
214
|
-
|
202
|
+
console.log(`git push --tags ${commitUrl}`);
|
203
|
+
return childProcess.exec("git", ["push", '--tags', commitUrl]);
|
215
204
|
} else {
|
216
|
-
|
205
|
+
console.log(`git push --tags`);
|
206
|
+
return childProcess.exec('git', ['push', '--tags',]);
|
217
207
|
}
|
218
208
|
}
|
219
209
|
|
@@ -270,8 +260,8 @@ function publishAll(commitUrl) {
|
|
270
260
|
return changedPromise;
|
271
261
|
});
|
272
262
|
return Promise.all(checkProjects)
|
273
|
-
.then(
|
274
|
-
monoWorkspace.changedProjects =
|
263
|
+
.then((checkResults) => {
|
264
|
+
monoWorkspace.changedProjects = checkResults.filter((projectInfo) => projectInfo.hasChanged);
|
275
265
|
return Promise.resolve(monoWorkspace);
|
276
266
|
});
|
277
267
|
});
|