@farris/cli 1.0.12 → 1.0.13

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.
Files changed (2) hide show
  1. package/ci/cli.js +8 -33
  2. 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
- console.log("getLastTagInBranch");
84
+ log.silly("getLastTagInBranch");
85
85
  return childProcess.execSync("git", ["describe", "--tags", "--abbrev=0"]);
86
86
  }
87
- console.log("getFirstCommit");
87
+ log.silly("getFirstCommit");
88
88
  return childProcess.execSync("git", ["rev-list", "--max-parents=0", "HEAD"]);
89
89
  }
90
90
 
@@ -205,18 +205,15 @@ function buildWorkspace(workspace) {
205
205
  }
206
206
 
207
207
  function tagMonoWorkspace(monoWorkspace, commitUrl) {
208
- const tagMessage = builderVersionChangeMessage('Publish npm packages ', monoWorkspace.updateResult, '.');
208
+ // const tagMessage = builderVersionChangeMessage('Publish npm packages ', monoWorkspace.updateResult, '.');
209
209
  const date = moment(new Date());
210
- const tagVersion = `v${date.format('yyyyMMddhhmmss')}`;
211
- console.log(`git tag ${tagVersion} -m ${tagMessage}`);
212
- childProcess.execSync('git', ['tag', tagVersion, '-m', tagMessage]);
210
+ const tagVersion = `v${date.format('YYYMMDDHHmmss')}`;
211
+ childProcess.execSync('git', ['tag', tagVersion, '-m', "publish npm package"]);
213
212
  // 提交变更集
214
213
  if (commitUrl) {
215
- console.log(`git push -o ci.skip ${commitUrl}`);
216
- return childProcess.exec("git", ["push", '-o', 'ci.skip', commitUrl]);
214
+ return childProcess.exec("git", ["push", '--tags', '-o', 'ci.skip', commitUrl]);
217
215
  } else {
218
- console.log(`git push -o ci.skip`);
219
- return childProcess.exec('git', ['push', '-o', 'ci.skip']);
216
+ return childProcess.exec('git', ['push', '--tags', '-o', 'ci.skip']);
220
217
  }
221
218
  }
222
219
 
@@ -232,55 +229,36 @@ function publish(projectPath) {
232
229
  const dest = ngPackageConfig.dest;
233
230
  const packagePath = path.normalize(`${projectPath}/${dest}`);
234
231
  // 调用 npm publish 发布指定路径下的npm包
235
- console.log(`npm publish ${packagePath}`);
236
232
  return childProcess.exec('npm', ['publish', packagePath])
237
233
  }
238
234
 
239
- /**
240
- * 将所有变更发布为新的npm包
241
- * @param {string} commitUrl commit api 地址
242
- */
243
235
  function publishAll(commitUrl) {
244
- // 初始化当前工作目录下的多代码仓库项目
245
236
  const monoRepoProject = new Project(process.cwd());
246
237
  let chain = Promise.resolve();
247
- // 1. 提取当前多代码仓库中的所有子项目,创建多项目工作区
248
238
  chain = chain.then(() => {
249
- // 提取所有子项目
250
239
  return monoRepoProject.getPackages()
251
240
  .then(packages => {
252
- // 创建并返回多项目工作区
253
241
  const monoWorkspace = { packages };
254
242
  return monoWorkspace;
255
243
  })
256
244
  });
257
- // 2. 读取多项目工作区下的Angular工作区和所有Angular项目
258
245
  chain = chain.then((monoWorkspace) => {
259
- // 提取所有子仓库项目
260
246
  const packages = monoWorkspace.packages;
261
- // 初始化Angular工作区集合
262
247
  monoWorkspace.workspaces = [];
263
- // 初始化Angular工程集合
264
248
  monoWorkspace.projects = [];
265
- // 遍历所有子仓库
266
249
  packages.forEach(packageJson => {
267
- // 读取Angular工作区路径
268
250
  const workspacePath = packageJson.location;
269
- // 读取Angular工作区下的angular.json文件内容
270
251
  const angularJson = readAngularJson(workspacePath)
271
- // 构造Angular工作区
272
252
  const workspace = readWorkspace(angularJson, packageJson);
273
- // 记录Angular工作区对象
274
253
  monoWorkspace.workspaces.push(workspace);
275
- // 遍历Angular工作区下的Angular项目,归集到根工作区中
276
254
  workspace.projects.reduce((monoWorkspace, projectInfo) => {
277
255
  monoWorkspace.projects.push(projectInfo);
278
256
  return monoWorkspace;
279
257
  }, monoWorkspace);
258
+ // .forEach((projectInfo) => monoWorkspace.projects.push(projectInfo));
280
259
  });
281
260
  return monoWorkspace;
282
261
  });
283
- // 3. 检查代码提交记录,获取自上次发布以来所有发生变化的Angular工程
284
262
  chain = chain.then(monoWorkspace => {
285
263
  const projects = monoWorkspace.projects;
286
264
  const checkProjects = projects.map((projectInfo) => {
@@ -297,7 +275,6 @@ function publishAll(commitUrl) {
297
275
  return Promise.resolve(monoWorkspace);
298
276
  });
299
277
  });
300
- // 4. 更新所有变更项目预发布版本,提交代码仓库,供发布时使用
301
278
  chain = chain.then(monoWorkspace => {
302
279
  const changedProjects = monoWorkspace.changedProjects;
303
280
  const prereleasePromise = changedProjects.map(projectInfo => updateProjectPrereleaseVersion(projectInfo.project.path, monoWorkspace));
@@ -313,7 +290,6 @@ function publishAll(commitUrl) {
313
290
  return Promise.resolve(monoWorkspace);
314
291
  });
315
292
  });
316
- // 5. 编译所有Angular工作区
317
293
  chain = chain.then(monoWorkspace => {
318
294
  const buildPromises = monoWorkspace.workspaces.map((workspace) => buildWorkspace(workspace));
319
295
  return Promise.all(buildPromises)
@@ -321,7 +297,6 @@ function publishAll(commitUrl) {
321
297
  return Promise.resolve(monoWorkspace);
322
298
  });
323
299
  });
324
- // 6. 将变更项目的内容发布为npm包,并增加发布Tag标签
325
300
  chain = chain.then(monoWorkspace => {
326
301
  const changedProjects = monoWorkspace.changedProjects;
327
302
  const publishPromises = changedProjects.map(projectInfo => publish(projectInfo.project.path));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@farris/cli",
3
- "version": "1.0.12",
3
+ "version": "1.0.13",
4
4
  "description": "Farris command line interface",
5
5
  "main": "index.js",
6
6
  "scripts": {