cloudcc-cli 1.1.9 → 1.2.0

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,10 @@
1
+ # ReleaseV1.2.0
2
+ #### 发布日期:2022-8-24
3
+ #### 发布范围:全量
4
+ #### 发布内容
5
+ * 修复
6
+ * 增加创建tag功能
7
+
1
8
  # ReleaseV1.1.9
2
9
  #### 发布日期:2022-8-23
3
10
  #### 发布范围:全量
@@ -0,0 +1,7 @@
1
+ #!/usr/bin/env node
2
+
3
+ const Creator = require("../src/buildTag.js");
4
+
5
+ const project = new Creator();
6
+
7
+ project.init();
package/bin/publishh5.js CHANGED
@@ -1,4 +1,4 @@
1
- #!/usr/bin/env node
1
+ #!/usr/bin/env node
2
2
 
3
3
  const Publish = require("../src/publishProjectH5.js");
4
4
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cloudcc-cli",
3
- "version": "1.1.9",
3
+ "version": "1.2.0",
4
4
  "description": "cloudcc-cli",
5
5
  "keywords": [
6
6
  "cloudcc",
@@ -15,7 +15,8 @@
15
15
  "cloudccPublic": "bin/publish.js",
16
16
  "cloudccPublicH5": "bin/publishh5.js",
17
17
  "cloudccBuildCCSDK": "bin/buildccsdk.js",
18
- "cloudccBuildCCBaseSDK": "bin/buildccbasesdk.js"
18
+ "cloudccBuildCCBaseSDK": "bin/buildccbasesdk.js",
19
+ "cloudccBuildTag": "bin/buildtag.js"
19
20
  },
20
21
  "scripts": {
21
22
  "publish-lib": "npm publish --registry https://registry.npmjs.org"
@@ -0,0 +1,75 @@
1
+ // 同步执行exe命令
2
+ const exec = require('child_process').execSync;
3
+ // 文件管理器
4
+ const fs = require('fs');
5
+ // 控制台输出样式控件
6
+ const chalk = require("chalk")
7
+ // 检查版本更新
8
+ const { checkUpdate } = require("../utils/checkVersion")
9
+ // 配置信息
10
+ const projectConfig = JSON.parse(fs.readFileSync('package.json', 'utf8'))
11
+ // 控制台交互
12
+ const { askTag } = require("../utils/askTool")
13
+ // 通知IM
14
+ const { notifyDingDing } = require("../utils/NotifyIM")
15
+ /**
16
+ * 打包基础SDK,并发布到NPM
17
+ */
18
+ class Builder {
19
+ constructor() {
20
+ this.user = exec("git config user.name").toString("utf8").trim();
21
+ }
22
+ async init() {
23
+ let res = await checkUpdate();
24
+ if (!res) {
25
+ let toTag = await askTag('请选择要创建的Tag:');
26
+ let fromTag = await askTag('基于哪个Tag创建:');
27
+ if (toTag.type == fromTag.type) {
28
+ console.log()
29
+ console.log(chalk.red("无法创建Tag:\n\n" + "from:" + fromTag.type + "\n" + "to:" + toTag.type))
30
+ console.log()
31
+ } else {
32
+ if (this.setTag(toTag.type, fromTag.type)) {
33
+ let version = exec(`git log ${fromTag.type} -1 --oneline`).toString("utf-8").split(" ")[1];
34
+ notifyDingDing(toTag.type, version, projectConfig, this.user)
35
+ }
36
+
37
+ }
38
+ }
39
+ }
40
+ /**
41
+ * 设置Tags
42
+ */
43
+ setTag(toTag, fromTag) {
44
+ console.log(chalk.green('开始创建Tag,请稍后...'));
45
+ try {
46
+ // 更新tag
47
+ exec("git fetch --tags -f")
48
+ } catch (error) {
49
+ return false;
50
+ }
51
+
52
+ try {
53
+ // 删除本地Tag
54
+ exec("git tag -d " + toTag)
55
+ } catch (error) {
56
+ }
57
+
58
+ try {
59
+ // 删除远程Tag
60
+ exec("git push origin :refs/tags/" + toTag)
61
+ } catch (error) {
62
+ }
63
+
64
+ // 添加tag
65
+ exec("git tag " + toTag + " " + fromTag + " -f")
66
+
67
+ // 推送tag
68
+ exec("git push --tags")
69
+
70
+ console.log(chalk.green('Tag设置成功!'));
71
+ console.log();
72
+ return true;
73
+ }
74
+ }
75
+ module.exports = Builder;
@@ -111,7 +111,7 @@ class Publish {
111
111
  console.log();
112
112
  // 打包命令
113
113
  try {
114
- exec('cli.exe publish --platform h5 --project lightning-h5');
114
+ exec('cli.exe publish --platform h5 --project ' + projectConfig.name);
115
115
  console.log(chalk.green('编译成功!'));
116
116
  console.log();
117
117
  return true;
package/utils/askTool.js CHANGED
@@ -18,6 +18,20 @@ let choices = [
18
18
  ]
19
19
 
20
20
  module.exports = {
21
+ /**
22
+ * 询问要创建的tag名称
23
+ * @returns 结果
24
+ */
25
+ askTag: (message) => {
26
+ const prompt = [{
27
+ type: 'list',
28
+ message,
29
+ name: 'type',
30
+ choices: choices,
31
+ }
32
+ ];
33
+ return inquirer.prompt(prompt)
34
+ },
21
35
  /**
22
36
  * 请求版本信息
23
37
  * @returns 结果