cloudcc-cli 0.9.1 → 0.9.5

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.9.5
2
+ #### 发布日期:2022-2-10
3
+ #### 发布范围:全量
4
+ #### 发布内容
5
+ * 优化
6
+ * 飞书通知增加分支标识
7
+
8
+ # ReleaseV0.9.4
9
+ #### 发布日期:2021-12-10
10
+ #### 发布范围:全量
11
+ #### 发布内容
12
+ * 优化
13
+ * 自动更新版本指定版本号
14
+
15
+ # ReleaseV0.9.3
16
+ #### 发布日期:2021-12-10
17
+ #### 发布范围:全量
18
+ #### 发布内容
19
+ * 优化
20
+ * 更新cc-sdk上传地址
21
+
22
+ # ReleaseV0.9.2
23
+ #### 发布日期:2021-11-30
24
+ #### 发布范围:全量
25
+ #### 发布内容
26
+ * 优化
27
+ * 删除dist文件夹然后提交
28
+
29
+
1
30
  # ReleaseV0.9.1
2
31
  #### 发布日期:2021-11-29
3
32
  #### 发布范围:全量
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cloudcc-cli",
3
- "version": "0.9.1",
3
+ "version": "0.9.5",
4
4
  "description": "cloudcc-cli",
5
5
  "keywords": [
6
6
  "cloudcc",
@@ -88,26 +88,21 @@ class Builder {
88
88
  getVueValue(buildFileName) {
89
89
  let vueContent = fs.readFileSync(this.getVueContent(buildFileName), 'utf8');
90
90
 
91
- let vueData = vueContent + ""
91
+ // 获取componentInfo
92
+ let reg = /componentInfo([\s\S]*?)\}/;
93
+ let componentInfo = vueContent.match(reg)[1].split("{")[1];
94
+ componentInfo = eval(`(${"function getInfo() { return {" + componentInfo + " } }"})`)()
95
+ // 组件名字
96
+ let compName = componentInfo.component
97
+ // 组件类型
98
+ let bizType = componentInfo.bizType
99
+ // 组件描述
100
+ let compDesc = componentInfo.compDesc
101
+ // 组件状态
102
+ let category = componentInfo.category
92
103
 
93
- // 去除空格
94
- // vueData = vueData.replace(/\ +/g, "")
95
- // 去除换行
96
- // vueData =vueData.replace(/[\r\n]/g, "");
97
-
98
- vueData = vueData.split("data()")[1].split("isLock:")[0] + "isLock:false,};}";
99
-
100
- vueData = "function data()" + vueData;
101
-
102
- const data = eval(`(${vueData})`)()
103
-
104
- let compName = data.componentInfo.component // 组件名字
105
-
106
- vueData = JSON.stringify(data);
107
-
108
- let bizType = data.componentInfo.bizType // 组件类型
109
- let compDesc = data.componentInfo.compDesc // 组件描述
110
- let category = data.componentInfo.category // 组件状态
104
+ // 获取vueDate内容
105
+ let vueData = vueContent.split("data()")[1].split("return")[1].split("isLock:")[0] + "isLock:false,}";
111
106
 
112
107
  return { compName, vueContent, vueData, bizType, compDesc, category }
113
108
  };
package/src/builderSDK.js CHANGED
@@ -44,10 +44,10 @@ class Builder {
44
44
  message: '请选择发布版本:',
45
45
  name: 'types',
46
46
  choices: [
47
- { name: "测试环境-Dev", value: "dev" },
48
- { name: "uat环境-Beta", value: "beta" },
49
- { name: "公司环境-GA", value: "ga" },
50
47
  { name: "客户环境-Release", value: "release" },
48
+ { name: "公司环境-GA", value: "ga" },
49
+ { name: "uat环境-Beta", value: "beta" },
50
+ { name: "测试环境-Dev", value: "dev" },
51
51
  ],
52
52
  }, {
53
53
  type: "input",
@@ -125,7 +125,7 @@ class Builder {
125
125
  {
126
126
  "fileName": obj.type + "/" + obj.sdkName + ".umd.min.js",
127
127
  "fileContent": jsContent,
128
- "bucketName": "cc-sdk",
128
+ "bucketName": "cloudcc-sdk",
129
129
  }
130
130
  )
131
131
  let res = await post(this.options.devConsoleConfig.baseUrl + "/devconsole/cdn/uploadFile",
@@ -137,11 +137,10 @@ class Builder {
137
137
  console.error(chalk.red(`发布失败: ${res.returnInfo}`));
138
138
  console.log();
139
139
  }
140
+
140
141
  return res;
141
142
  }
142
143
 
143
-
144
-
145
144
  /**
146
145
  * 过滤出min.js文件
147
146
  * @returns 过滤结果
@@ -18,9 +18,11 @@ function checkNpmVersion() {
18
18
  console.log();
19
19
  console.log(chalk.green("当前版本:v" + config.version));
20
20
  console.log(chalk.green("最新版本:v" + onlineVersion));
21
- return true;
21
+ console.log();
22
+ console.log(chalk.yellow(`如无法自动更新,请使用命令更新:npm install -g cloudcc-cli@${onlineVersion} --registry https://registry.npmjs.org`));
23
+ return onlineVersion;
22
24
  }
23
- return false;
25
+ return null;
24
26
  }
25
27
 
26
28
  /**
@@ -43,10 +45,10 @@ function askUpdate() {
43
45
  /**
44
46
  * 升级cli
45
47
  */
46
- function update() {
48
+ function update(onlineVersion) {
47
49
  console.log()
48
50
  console.log(chalk.green("升级中,请稍后..."));
49
- exec(`npm install -g cloudcc-cli --registry https://registry.npmjs.org`)
51
+ exec(`npm install -g cloudcc-cli@${onlineVersion} --registry https://registry.npmjs.org`)
50
52
  console.log()
51
53
  console.log(chalk.green("升级完成!请重新运行"));
52
54
  }
@@ -55,10 +57,11 @@ function update() {
55
57
  * 检查更新
56
58
  */
57
59
  async function checkUpdate() {
58
- if (checkNpmVersion()) {
60
+ let onlineVersion = checkNpmVersion();
61
+ if (onlineVersion) {
59
62
  let res = await askUpdate()
60
63
  if ("Yes" == res.update) {
61
- update()
64
+ update(onlineVersion)
62
65
  return true;
63
66
  } else {
64
67
  return false
package/utils/notifyIM.js CHANGED
@@ -21,7 +21,7 @@ module.exports = {
21
21
  },
22
22
  "elements": [{
23
23
  "tag": "markdown",
24
- "content": "项目名称:" + projectConfig.name + "\nTag:" + type + "\n版本号:" + version + "\n发布者:" + exec("git config user.name").toString("utf8").trim()
24
+ "content": "项目名称:" + projectConfig.name + "\n分支:" + exec("git rev-parse --abbrev-ref HEAD").toString("utf8").trim() + "\nTag:" + type + "\n版本号:" + version + "\n发布者:" + exec("git config user.name").toString("utf8").trim()
25
25
  }, {
26
26
  "actions": [{
27
27
  "tag": "button",
package/utils/pushCode.js CHANGED
@@ -4,6 +4,42 @@
4
4
  const exec = require('child_process').execSync;
5
5
  const chalk = require("chalk")
6
6
  const changeVersion = require("../utils/changeVersion")
7
+ /**
8
+ * 更改版本version
9
+ * @param {types} 版本类型,如Dev、uat,GA,Release
10
+ */
11
+ function getNewVersionName(types) {
12
+ exec("git fetch --tags -f")
13
+ return types.map((item) => {
14
+ // 更新本地tag
15
+ let version = exec(`git tag --sort=-committerdate`)
16
+ version = version.toString("utf8").trim();
17
+ if (version) {
18
+ // 使用换行分隔下
19
+ let versions = version.split("\n");
20
+ // 取出第一个包含-V的版本号
21
+ version = versions.find((item) => {
22
+ return item.includes("-V");
23
+ })
24
+ console.log("version 1", version);
25
+ if (version) {
26
+ // 取版本号
27
+ version = version.split("-V")[1]
28
+ console.log("version 2", version);
29
+ // 改变版本号
30
+ version = changeVersion.change(version, item)
31
+ console.log("version 3", version);
32
+ // 生成最后的版本号
33
+ item = item + "-V" + version
34
+ } else {
35
+ item = item + "-V0.0.1"
36
+ }
37
+ } else {
38
+ item = item + "-V0.0.1"
39
+ }
40
+ return item;
41
+ })
42
+ }
7
43
 
8
44
  /**
9
45
  * 将代码推送至gitlab
@@ -94,47 +130,45 @@ function setTag(types, versions) {
94
130
  console.log();
95
131
  return true;
96
132
  }
97
-
98
133
  /**
99
- * 更改版本version
100
- * @param {types} 版本类型,如Dev、uat,GA,Release
134
+ * 删除dist文件夹
135
+ * @returns true 成功,false 失败
101
136
  */
102
- function getNewVersionName(types) {
103
- exec("git fetch --tags -f")
104
- return types.map((item) => {
105
- // 更新本地tag
106
- let version = exec(`git tag --sort=-committerdate`)
107
- version = version.toString("utf8").trim();
108
- if (version) {
109
- // 使用换行分隔下
110
- let versions = version.split("\n");
111
- // 取出第一个包含-V的版本号
112
- version = versions.find((item) => {
113
- return item.includes("-V");
114
- })
115
- console.log("version 1", version);
116
- // 取版本号
117
- version = version.split("-V")[1]
118
- console.log("version 2", version);
119
- // 改变版本号
120
- version = changeVersion.change(version, item)
121
- console.log("version 3", version);
122
- // 生成最后的版本号
123
- item = item + "-V" + version
124
- } else {
125
- item = item + "-V0.0.1"
126
- }
127
- return item;
128
- })
129
- }
137
+ function deleteDist() {
138
+
139
+ try {
140
+ // 删除dist文件夹
141
+ exec("git rm -r dist")
142
+ } catch (error) {
143
+
144
+ }
145
+
146
+ try {
147
+ // 添加改变文件
148
+ exec("git add .")
149
+ } catch (error) {
150
+
151
+ }
152
+
153
+ try {
154
+ // 提交到本地
155
+ exec("git commit -m clear-dist")
156
+ } catch (error) {
157
+ }
158
+ try {
159
+ // 推送到服务器
160
+ exec("git push")
161
+ } catch (error) {
130
162
 
163
+ }
164
+ return true;
165
+ }
131
166
  /**
132
167
  * 发布代码同时设置Tags
133
168
  * @param {types} 版本集合
134
169
  */
135
170
  function pushCodeAndTags(types = []) {
136
171
  let versions = getNewVersionName(types);
137
-
138
- return push(versions[0]) && setTag(types, versions)
172
+ return push(versions[0]) && setTag(types, versions) && deleteDist(versions[0]);
139
173
  }
140
174
  module.exports = { pushCodeAndTags, push, getNewVersionName, setTag }