cloudcc-cli 0.6.4 → 0.6.8

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/README.md CHANGED
@@ -1,3 +1,32 @@
1
+ # ReleaseV0.6.8
2
+ #### 发布日期:2021-11-5
3
+ #### 发布范围:全量
4
+ #### 发布内容
5
+ * 迭代
6
+ * 优化npm触发更新逻辑
7
+
8
+ # ReleaseV0.6.7
9
+ #### 发布日期:2021-11-4
10
+ #### 发布范围:全量
11
+ #### 发布内容
12
+ * 迭代
13
+ * 优化更新逻辑判断
14
+
15
+ # ReleaseV0.6.6
16
+ #### 发布日期:2021-11-4
17
+ #### 发布范围:全量
18
+ #### 发布内容
19
+ * 迭代
20
+ * 优化检查更新逻辑
21
+
22
+ # ReleaseV0.6.5
23
+ #### 发布日期:2021-11-4
24
+ #### 发布范围:全量
25
+ #### 发布内容
26
+ * 迭代
27
+ * 优化提示信息
28
+ * 将version放入dist文件夹
29
+
1
30
  # ReleaseV0.6.4
2
31
  #### 发布日期:2021-11-3
3
32
  #### 发布范围:全量
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cloudcc-cli",
3
- "version": "0.6.4",
3
+ "version": "0.6.8",
4
4
  "description": "cloudcc-cli",
5
5
  "keywords": [
6
6
  "cloudcc",
@@ -14,6 +14,8 @@ const { askType } = require("../utils/askTool")
14
14
  const { pushCodeAndTags } = require("../utils/pushCode")
15
15
  // 通知飞书
16
16
  const { notifyFeishu } = require("../utils/NotifyIM")
17
+ // 网络请求
18
+ const { postParams } = require("../utils/http")
17
19
  /**
18
20
  * 打包基础SDK,并发布到NPM
19
21
  */
@@ -21,18 +23,20 @@ class Builder {
21
23
  constructor() {
22
24
  }
23
25
  async init() {
24
- checkUpdate();
25
- let condition = await askType();
26
- if (condition && condition.type) {
27
- if (this.buildpush2npm()) {
28
- pushCodeAndTags([condition.type])
29
- notifyFeishu(condition.type, condition.version, projectConfig);
30
- console.log(chalk.green('发布完成'));
26
+ let res = await checkUpdate();
27
+ if (!res) {
28
+ let condition = await askType();
29
+ if (condition && condition.type) {
30
+ if (this.buildpush2npm()) {
31
+ pushCodeAndTags([condition.type])
32
+ notifyFeishu(condition.type, condition.version, projectConfig);
33
+ console.log(chalk.green('发布完成'));
34
+ }
35
+ } else {
36
+ console.log();
37
+ console.log(chalk.red("请至少设置一个有效的Tag"));
38
+ console.log();
31
39
  }
32
- } else {
33
- console.log();
34
- console.log(chalk.red("请至少设置一个有效的Tag"));
35
- console.log();
36
40
  }
37
41
  }
38
42
  /**
@@ -54,7 +58,12 @@ class Builder {
54
58
  try {
55
59
  console.log()
56
60
  console.log(chalk.green("NPM开始发布,请稍后"));
57
- exec(`npm publish --registry https://registry.npmjs.org && curl https://npm.taobao.org/sync/${projectConfig.name}`)
61
+ exec(`npm publish --registry https://registry.npmjs.org`)
62
+ try {
63
+ postParams(`https://npm.taobao.org/sync/${projectConfig.name}`)
64
+ } catch (error) {
65
+
66
+ }
58
67
  console.log()
59
68
  console.log(chalk.green("NPM发布完成"));
60
69
  return true
@@ -18,30 +18,32 @@ class Builder {
18
18
  }
19
19
  }
20
20
  async init() {
21
- checkUpdate();
22
- this.options.devConsoleConfig = this.getPackageJson();
23
- let config = this.options.devConsoleConfig
24
- // 如果不是私有化部署,那么需要获取token
25
- if ("private" != this.options.devConsoleConfig.version) { // private私有化
26
- config = { "accessToken": await this.getToken(config) };
27
- }
28
- // 获得用户输入
29
- let answers = await this.ask();
30
- // 如果输入的是*.vue,那么表示编译全部文件
31
- if ("*.vue" == answers.buildFileName) {
32
- let dirs = fs.readdirSync("plugin")
33
- for (let i = 0; i < dirs.length; i++) {
34
- let item = dirs[i]
35
- let obj = this.getVueValue(item);
36
- this.initPluginFile(item, obj.compName);
21
+ let res = await checkUpdate();
22
+ if (!res) {
23
+ this.options.devConsoleConfig = this.getPackageJson();
24
+ let config = this.options.devConsoleConfig
25
+ // 如果不是私有化部署,那么需要获取token
26
+ if ("private" != this.options.devConsoleConfig.version) { // private私有化
27
+ config = { "accessToken": await this.getToken(config) };
28
+ }
29
+ // 获得用户输入
30
+ let answers = await this.ask();
31
+ // 如果输入的是*.vue,那么表示编译全部文件
32
+ if ("*.vue" == answers.buildFileName) {
33
+ let dirs = fs.readdirSync("plugin")
34
+ for (let i = 0; i < dirs.length; i++) {
35
+ let item = dirs[i]
36
+ let obj = this.getVueValue(item);
37
+ this.initPluginFile(item, obj.compName);
38
+ this.build(obj);
39
+ await this.upload(obj, config)
40
+ }
41
+ } else {
42
+ let obj = this.getVueValue(answers.buildFileName);
43
+ this.initPluginFile(answers.buildFileName, obj.compName);
37
44
  this.build(obj);
38
45
  await this.upload(obj, config)
39
46
  }
40
- } else {
41
- let obj = this.getVueValue(answers.buildFileName);
42
- this.initPluginFile(answers.buildFileName, obj.compName);
43
- this.build(obj);
44
- await this.upload(obj, config)
45
47
  }
46
48
  }
47
49
  /**
package/src/builderSDK.js CHANGED
@@ -17,21 +17,23 @@ class Builder {
17
17
  }
18
18
  }
19
19
  async init() {
20
- checkUpdate();
21
- this.options.devConsoleConfig = this.getPackageJson();
22
- // 获得用户输入
23
- let answers = await this.ask();
24
- if (answers.types.length == 0) {
25
- console.log();
26
- console.error(chalk.red(`请选择一个有效的发布版本!`));
27
- console.log();
28
- return;
20
+ let res = await checkUpdate();
21
+ if (!res) {
22
+ this.options.devConsoleConfig = this.getPackageJson();
23
+ // 获得用户输入
24
+ let answers = await this.ask();
25
+ if (answers.types.length == 0) {
26
+ console.log();
27
+ console.error(chalk.red(`请选择一个有效的发布版本!`));
28
+ console.log();
29
+ return;
30
+ }
31
+ // 获得vue内容
32
+ let obj = this.getSDKName(answers.buildDirName);
33
+ obj.types = answers.types;
34
+ this.build(obj);
35
+ await this.upload(obj)
29
36
  }
30
- // 获得vue内容
31
- let obj = this.getSDKName(answers.buildDirName);
32
- obj.types = answers.types;
33
- this.build(obj);
34
- await this.upload(obj)
35
37
  }
36
38
  /**
37
39
  * 命令行交互
@@ -21,14 +21,17 @@ class Creator {
21
21
  this.tplDirPath = path.join(this.rootPath, "template");
22
22
  }
23
23
  // 初始化
24
- init() {
25
- checkUpdate();
26
- console.log(chalk.green('欢迎使用Cloudcc-CLI'));
27
- this.ask().then(answers => {
28
- this.options = Object.assign({}, this.options, answers);
29
- console.log(this.options);
30
- this.write();
31
- })
24
+ async init() {
25
+ let res = await checkUpdate();
26
+ if (!res) {
27
+ console.log()
28
+ console.log(chalk.green('欢迎使用Cloudcc-CLI'));
29
+ this.ask().then(answers => {
30
+ this.options = Object.assign({}, this.options, answers);
31
+ console.log(this.options);
32
+ this.write();
33
+ })
34
+ }
32
35
  }
33
36
  // 命令行交互
34
37
  ask() {
@@ -26,23 +26,28 @@ class Publish {
26
26
  * 初始化
27
27
  */
28
28
  async init() {
29
- // 检查更新
30
- checkUpdate();
31
- // 询问发布类型
32
- let condition = await askType();
33
- // version写入vue文件,触发编译
34
- let version = getNewVersionName([condition.type])
35
- this.writeVersion(version);
36
- if (this.build()) {
37
- // 将readme生成为html,并复制到dist
38
- let outPath = "dist"
39
- if (projectConfig.config) {
40
- outPath = projectConfig.config["doc-path"] ? projectConfig.config["doc-path"] : "dist";
29
+ let res = await checkUpdate();
30
+ if (!res) {
31
+ // 询问发布类型
32
+ let condition = await askType();
33
+ // 获得version
34
+ let version = getNewVersionName([condition.type])
35
+ if (this.build()) {
36
+ // 将readme生成为html,并复制到dist中
37
+ let outPath = "dist"
38
+ if (projectConfig.config) {
39
+ outPath = projectConfig.config["doc-path"] ? projectConfig.config["doc-path"] : "dist";
40
+ }
41
+ // 设置readme文件位置
42
+ change("README", outPath);
43
+ // 写入版本信息
44
+ this.writeVersion(version);
45
+ // 发布代码并设置tags,触发发布,飞书提醒
46
+ pushCodeAndTags([condition.type]) && jenkins(projectConfig.config["jenkins-" + condition.type]) && notifyFeishu(condition.type, version, projectConfig);
47
+ console.log();
48
+ console.log(chalk.green('发布完成'));
49
+ console.log();
41
50
  }
42
- change("README", outPath);
43
-
44
- // 发布代码并设置tags,触发发布,飞书提醒
45
- pushCodeAndTags([condition.type]) && jenkins(projectConfig.config["jenkins-" + condition.type]) && notifyFeishu(condition.type, version, projectConfig);
46
51
  }
47
52
  }
48
53
  /**
@@ -52,8 +57,8 @@ class Publish {
52
57
  * @returns
53
58
  */
54
59
  async build() {
55
- console.log();
56
60
  console.log(chalk.green('开始编译,请稍后...'));
61
+ console.log();
57
62
  // 打包命令
58
63
  try {
59
64
  exec('npm run build');
@@ -78,8 +83,6 @@ class Publish {
78
83
  */
79
84
  writeVersion(version) {
80
85
  try {
81
-
82
-
83
86
  // 获得分支信息
84
87
  let branch = exec('git rev-parse --abbrev-ref HEAD');
85
88
  branch = branch.toString("utf8").trim();
@@ -91,14 +94,14 @@ class Publish {
91
94
  var gitCommitVersion = '"' + develop + ': ' + gitVersion + '"'
92
95
 
93
96
  let versionInfo =
94
- `<template>
97
+ `
95
98
  <div style="font-size: 20px">
96
99
  <div>分支:${branch}</div>
97
100
  <div>版本号:${version}</div>
98
101
  <div>Commit:${gitCommitVersion}</div>
99
102
  </div>
100
- </template>`
101
- fs.writeFileSync("src/views/version.vue", versionInfo);
103
+ `
104
+ fs.writeFileSync("dist/version.html", versionInfo);
102
105
  return true
103
106
  } catch (error) {
104
107
  return false
@@ -18,7 +18,6 @@ function checkNpmVersion() {
18
18
  console.log();
19
19
  console.log(chalk.green("当前版本:v" + config.version));
20
20
  console.log(chalk.green("最新版本:v" + onlineVersion));
21
- console.log();
22
21
  return true;
23
22
  }
24
23
  return false;
@@ -29,6 +28,7 @@ function checkNpmVersion() {
29
28
  * @returns 对象
30
29
  */
31
30
  function askUpdate() {
31
+ console.log();
32
32
  const prompt = [{
33
33
  type: 'list',
34
34
  message: '是否进行自动升级?',
@@ -44,8 +44,10 @@ function askUpdate() {
44
44
  * 升级cli
45
45
  */
46
46
  function update() {
47
+ console.log()
47
48
  console.log(chalk.green("升级中,请稍后..."));
48
49
  exec(`npm install -g cloudcc-cli --registry https://registry.npmjs.org`)
50
+ console.log()
49
51
  console.log(chalk.green("升级完成!请重新运行"));
50
52
  }
51
53
 
@@ -54,12 +56,15 @@ function update() {
54
56
  */
55
57
  async function checkUpdate() {
56
58
  if (checkNpmVersion()) {
57
- let update = await askUpdate()
58
- if ("Yes" == update.update) {
59
+ let res = await askUpdate()
60
+ if ("Yes" == res.update) {
59
61
  update()
60
- return;
62
+ return true;
63
+ } else {
64
+ return false
61
65
  }
62
66
  }
67
+ return false
63
68
  }
64
69
 
65
70
 
package/utils/notifyIM.js CHANGED
@@ -49,8 +49,8 @@ module.exports = {
49
49
  triggers.map((trigger) => {
50
50
  postParams(trigger, body);
51
51
  })
52
+ console.log(chalk.green('已通知飞书群,请查看。'));
52
53
  }
53
- console.log(chalk.green('已通知飞书群,请查看。'));
54
54
  }
55
55
  }
56
56
  }
package/utils/trigger.js CHANGED
@@ -5,7 +5,11 @@
5
5
  const { get } = require('../utils/http');
6
6
 
7
7
  async function jenkins(url) {
8
- await get(url)
8
+ try {
9
+ await get(url)
10
+ } catch (error) {
11
+ }
12
+ return true
9
13
  }
10
14
 
11
15
  module.exports = { jenkins }