cloudcc-cli 0.9.6 → 0.9.9

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,25 @@
1
+ # ReleaseV0.9.9
2
+ #### 发布日期:2022-3-9
3
+ #### 发布范围:全量
4
+ #### 发布内容
5
+ * 迭代
6
+ * 增加多语言脚本支持
7
+
8
+ # ReleaseV0.9.8
9
+ #### 发布日期:2022-3-3
10
+ #### 发布范围:全量
11
+ #### 发布内容
12
+ * 优化
13
+ * 删除不必要打印信息
14
+ * 兼容vue@cli5.0
15
+
16
+ # ReleaseV0.9.7
17
+ #### 发布日期:2022-2-15
18
+ #### 发布范围:全量
19
+ #### 发布内容
20
+ * 优化
21
+ * 发布项目,使用服务器功能
22
+
1
23
  # ReleaseV0.9.6
2
24
  #### 发布日期:2022-2-14
3
25
  #### 发布范围:全量
package/bin/build.js CHANGED
@@ -1,4 +1,4 @@
1
- #!/usr/bin/env node
1
+ #!/usr/bin/env node
2
2
 
3
3
  const Builder = require("../src/builderPlugin.js");
4
4
 
@@ -1,4 +1,4 @@
1
- #!/usr/bin/env node
1
+ #!/usr/bin/env node
2
2
 
3
3
  const BuilderBaseSDK = require("../src/builderBaseSDK.js");
4
4
 
package/bin/buildccsdk.js CHANGED
@@ -1,4 +1,4 @@
1
- #!/usr/bin/env node
1
+ #!/usr/bin/env node
2
2
 
3
3
  const BuilderCCSDK = require("../src/builderSDK.js");
4
4
 
package/bin/create.js CHANGED
@@ -1,7 +1,7 @@
1
- #!/usr/bin/env node
2
-
3
- const Creator = require("../src/creatorTemProject.js");
4
-
5
- const project = new Creator();
6
-
1
+ #!/usr/bin/env node
2
+
3
+ const Creator = require("../src/creatorTemProject.js");
4
+
5
+ const project = new Creator();
6
+
7
7
  project.init();
package/bin/publish.js CHANGED
@@ -1,4 +1,4 @@
1
- #!/usr/bin/env node
1
+ #!/usr/bin/env node
2
2
 
3
3
  const Publish = require("../src/publishProject.js");
4
4
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cloudcc-cli",
3
- "version": "0.9.6",
3
+ "version": "0.9.9",
4
4
  "description": "cloudcc-cli",
5
5
  "keywords": [
6
6
  "cloudcc",
@@ -100,7 +100,6 @@ class Builder {
100
100
  let bizType = data.componentInfo.bizType // 组件类型
101
101
  let compDesc = data.componentInfo.compDesc // 组件描述
102
102
  let category = data.componentInfo.category // 组件状态
103
- console.log("vueData", vueData);
104
103
  return { compName, vueContent, vueData, bizType, compDesc, category }
105
104
  };
106
105
  /**
@@ -126,7 +125,7 @@ class Builder {
126
125
  */
127
126
  build(obj) {
128
127
  console.log(chalk.green('编译中,请稍后...'));
129
- let { stdout, stderr, error } = execSync('vue build -t lib -n ' + obj.compName + ' -d build plugin/plugin.js');
128
+ let { stdout, stderr, error } = execSync('npx vue-cli-service build --target lib --name ' + obj.compName + ' --dest build plugin/plugin.js');
130
129
  if (null == error) {
131
130
  console.log(chalk.green('编译成功!'));
132
131
  } else {
@@ -144,6 +143,7 @@ class Builder {
144
143
  jsContent = fs.readFileSync(this.filterFile()[0], 'utf8')
145
144
  } catch (err) {
146
145
  console.error(err)
146
+ return;
147
147
  }
148
148
  let body = {
149
149
  "compUniName": obj.compName,
@@ -69,7 +69,7 @@ class Creator {
69
69
  console.log();
70
70
  console.log(chalk.green('构建完成'));
71
71
  console.log();
72
- console.log(chalk.green(`运行项目: cd ${this.options.name} && npm install`));
72
+ console.log(chalk.green(`运行项目: \n 1:cd ${this.options.name} \n 2:code . \n 3:npm install`));
73
73
  })
74
74
  }
75
75
 
@@ -15,33 +15,77 @@ const { getNewVersionName, pushCodeAndTags } = require("../utils/pushCode")
15
15
  // 触发构建器
16
16
  const { jenkins } = require("../utils/trigger")
17
17
  // 通知飞书
18
- const { notifyFeishu } = require("../utils/NotifyIM")
18
+ const { notifyFeishu } = require("../utils/notifyIM")
19
19
  // 时间库
20
20
  const dayjs = require("dayjs")
21
+ // 多语言更新脚本
22
+ const { updatei18n, askI18n } = require("../utils/updatei18n")
21
23
  /**
22
24
  * 项目打包发布脚本
23
25
  */
24
26
  class Publish {
25
27
  constructor() {
28
+ /**
29
+ * 控制台参数
30
+ * type:发布类型
31
+ * branch:使用的分支
32
+ */
33
+ this.args = new Map();
34
+ this.arguments = process.argv.splice(2).map((item) => {
35
+ let arr = item.split("=");
36
+ this.args.set(arr[0].split("-")[1], arr[1]);
37
+ });
26
38
  }
27
39
  /**
28
40
  * 初始化
29
41
  */
30
42
  async init() {
31
- let res = await checkUpdate();
32
- if (!res) {
33
- // 询问发布类型
34
- let condition = await askType();
35
- // 获得version
43
+ // 检查cli版本,提示用户更新:false:不更新,true:更新
44
+ let update = await checkUpdate();
45
+ if (!update) {
46
+ // 1:版本发布信息,包含发布版本类型信息
47
+ let condition = {};
48
+ // 检查命令行是否输入了发布版本信息,如果没有包含,那么询问发布类型
49
+ if (this.args.get("type")) {
50
+ condition.type = this.args.get("type")
51
+ } else {
52
+ // 询问发布类型
53
+ condition = await askType();
54
+ }
55
+
56
+ // 2:如果命令行包含了分支信息,那么git切换到命令行的分支
57
+ if (this.args.get("branch")) {
58
+ exec(`git checkout ${this.args.get("branch")}`);
59
+ console.log(chalk.green("切换分支:" + this.args.get("branch")))
60
+ console.log()
61
+ }
62
+
63
+ // 3:获取新的发布版本号
36
64
  let version = getNewVersionName([condition.type])
37
65
  console.log();
38
66
  console.log(chalk.green('待发布版本:' + version));
39
67
  console.log();
68
+
69
+ // 4:如果存在多语言配置,则更新多语言
70
+ if (projectConfig.config && projectConfig.config["language-config"]) {
71
+ // 询问是否更新多语言
72
+ let i18n = await askI18n()
73
+ if (i18n.checked === '1') {
74
+ let laguage = projectConfig.config["language-config"]
75
+ // 执行更新多语言文件
76
+ await updatei18n(laguage)
77
+ console.log(chalk.blue("多语言文件更新完毕,准备开始打包"));
78
+ console.log();
79
+ }
80
+ }
81
+
82
+ // 5:开始打包
40
83
  if (await this.build()) {
41
- // readme生成为html,并复制到dist中
84
+ // 6:将readme生成为html,并复制到dist中
42
85
  let outPath = "dist"
43
- if (projectConfig.config) {
44
- outPath = projectConfig.config["doc-path"] ? projectConfig.config["doc-path"] : "dist";
86
+ // 读取配置,是否改变了输出路径
87
+ if (projectConfig.config && projectConfig.config["doc-path"]) {
88
+ outPath = projectConfig.config["doc-path"];
45
89
  }
46
90
  // lightning的Release禁止生成Readme文档
47
91
  if (!(Object.is("CloudCC", projectConfig.name) && Object.is("Release", condition.type))) {
@@ -52,14 +96,15 @@ class Publish {
52
96
  console.log(chalk.red("README写入异常:" + error))
53
97
  }
54
98
  }
99
+
55
100
  try {
56
- // 写入版本信息
101
+ // 7:写入版本信息
57
102
  this.writeVersion(version);
58
103
  } catch (error) {
59
104
  console.log(chalk.red("版本信息写入异常:" + error))
60
105
  }
61
106
 
62
- // 发布代码并设置tags,触发发布,飞书提醒
107
+ // 8:发布代码并设置tags,触发发布,飞书提醒
63
108
  if (pushCodeAndTags([condition.type])) {
64
109
  if (projectConfig && projectConfig.config) {
65
110
  jenkins(projectConfig.config["jenkins-" + condition.type])
@@ -70,6 +115,7 @@ class Publish {
70
115
  console.log();
71
116
  }
72
117
  }
118
+
73
119
  }
74
120
  }
75
121
  /**
package/template/indexvue CHANGED
@@ -40,7 +40,7 @@ export default {
40
40
  * private:私有组件(自己组织可见)
41
41
  * beta:组件测试版本
42
42
  */
43
- category: "public", // public private
43
+ category: "private",
44
44
  },
45
45
  style: {
46
46
  unit: "px",
package/utils/pushCode.js CHANGED
@@ -21,14 +21,11 @@ function getNewVersionName(types) {
21
21
  version = versions.find((item) => {
22
22
  return item.includes("-V");
23
23
  })
24
- console.log("version 1", version);
25
24
  if (version) {
26
25
  // 取版本号
27
26
  version = version.split("-V")[1]
28
- console.log("version 2", version);
29
27
  // 改变版本号
30
28
  version = changeVersion.change(version, item)
31
- console.log("version 3", version);
32
29
  // 生成最后的版本号
33
30
  item = item + "-V" + version
34
31
  } else {
@@ -0,0 +1,127 @@
1
+ //文件下载
2
+ const fs = require("fs");
3
+ const path = require("path");
4
+ const axios = require('axios');
5
+ const chalk = require("chalk")
6
+ const inquirer = require("inquirer")
7
+
8
+
9
+
10
+ // 创建文件夹目录
11
+ const filepath = "src/utils/i18n";
12
+ let dirCache = {};
13
+ /**
14
+ * 创建文件夹
15
+ */
16
+ function mkdir(filepath) {
17
+ const arr = filepath.split('/');
18
+ let dir = arr[0];
19
+ for (let i = 1; i <= arr.length; i++) {
20
+ if (!dirCache[dir] && !fs.existsSync(dir)) {
21
+ dirCache[dir] = true;
22
+ console.log("创建", dir);
23
+ fs.mkdirSync(dir);
24
+ } else {
25
+ // console.log("文件夹" + dir + "已存在");
26
+ }
27
+ dir = dir + '/' + arr[i];
28
+ }
29
+ }
30
+ mkdir(filepath)
31
+ /**
32
+ * 检查多语言文件是否需要更新,如果需要更新,返回要更新的语种集合,否则返回空。
33
+ */
34
+ function checkVersion() {
35
+
36
+ }
37
+ /**
38
+ * 选择要更新的文件集合
39
+ */
40
+ function selectUpdateFiles() {
41
+
42
+ }
43
+
44
+ /**
45
+ *
46
+ * @param {fileUrl} 文件源地址
47
+ * @param {localPath} 保存的地址
48
+ * @param {fileName} 文件名
49
+ */
50
+ function down2save(fileUrl, localPath, fileName) {
51
+ const mypath = path.resolve(localPath, fileName);
52
+ const writer = fs.createWriteStream(mypath);
53
+ console.log(fileName + " 开始下载");
54
+ return axios({
55
+ method: 'get',
56
+ url: fileUrl,
57
+ responseType: 'stream',
58
+ }).then(response => {
59
+ return new Promise((resolve, reject) => {
60
+ response.data.pipe(writer);
61
+ let error = null;
62
+ writer.on('error', err => {
63
+ console.log(fileName + " 下载失败", err);
64
+ error = err;
65
+ writer.close();
66
+ reject(err);
67
+ });
68
+ writer.on('close', () => {
69
+ if (!error) {
70
+ resolve(true);
71
+ console.log(chalk.blue(fileName + " 下载成功"));
72
+ }
73
+ });
74
+ });
75
+ });
76
+ }
77
+
78
+ /**
79
+ * 获取文件名
80
+ * @param {fileUrl} 文件地址
81
+ * @returns 文件名
82
+ */
83
+ function getFileName(fileUrl) {
84
+ const arr = fileUrl.split('/');
85
+ return arr[arr.length - 1];
86
+ }
87
+
88
+ /**
89
+ * 更新多语言
90
+ * @returns 结果
91
+ */
92
+ async function updatei18n(languageList) {
93
+ let promiseArr = []
94
+ languageList.forEach(item => {
95
+ promiseArr.push((async (item) => {
96
+ let fileName = getFileName(item);
97
+ await down2save(item, filepath, fileName)
98
+ })(item))
99
+ })
100
+ return Promise.all(promiseArr).then(function (result) {
101
+ console.log()
102
+ console.log(chalk.blue("所有语言下载完成"));
103
+ })
104
+ }
105
+
106
+ /**
107
+ * 是否更新多语言词库
108
+ * @returns 结果
109
+ */
110
+ function askI18n() {
111
+ const prompt = [{
112
+ type: 'list',
113
+ message: '是否更新多语言词库:',
114
+ name: 'checked',
115
+ choices: [
116
+ { name: "否", value: "0" },
117
+ { name: "是", value: "1" },
118
+ ],
119
+ }
120
+ ];
121
+ return inquirer.prompt(prompt)
122
+ }
123
+
124
+
125
+ module.exports = {
126
+ updatei18n, askI18n
127
+ }