cloudcc-cli 1.2.5 → 1.2.7

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,19 @@
1
+ # ReleaseV1.2.7
2
+ #### 发布日期:2022-12-5
3
+ #### 发布范围:全量
4
+ #### 发布内容
5
+ * 迭代
6
+ * 打包项目增加详细日志输出
7
+ * 优化
8
+
9
+ # ReleaseV1.2.6
10
+ #### 发布日期:2022-11-21
11
+ #### 发布范围:全量
12
+ #### 发布内容
13
+ * 迭代
14
+ * 替换组件开发模板
15
+ * 优化
16
+
1
17
  # ReleaseV1.2.5
2
18
  #### 发布日期:2022-11-17
3
19
  #### 发布范围:全量
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cloudcc-cli",
3
- "version": "1.2.5",
3
+ "version": "1.2.7",
4
4
  "description": "cloudcc-cli",
5
5
  "keywords": [
6
6
  "cloudcc",
@@ -1,4 +1,4 @@
1
- const exec = require('child_process').execSync;
1
+ const { execSync, exec } = require('child_process');
2
2
  const chalk = require("chalk")
3
3
  // 文件编辑对象
4
4
  const fs = require("fs")
@@ -41,7 +41,7 @@ class Publish {
41
41
  let arr = item.split("=");
42
42
  this.args.set(arr[0], arr[1]);
43
43
  });
44
- this.user = this.args.get("user") || exec("git config user.name").toString("utf8").trim();
44
+ this.user = this.args.get("user") || execSync("git config user.name").toString("utf8").trim();
45
45
  }
46
46
  /**
47
47
  * 初始化
@@ -77,7 +77,7 @@ class Publish {
77
77
  }
78
78
  // 2:如果命令行包含了分支信息,那么git切换到命令行的分支
79
79
  if (this.args.get("branch")) {
80
- exec(`git checkout ${this.args.get("branch")}`);
80
+ execSync(`git checkout ${this.args.get("branch")}`);
81
81
  console.log(chalk.green("切换分支:" + this.args.get("branch")))
82
82
  console.log()
83
83
  }
@@ -112,40 +112,43 @@ class Publish {
112
112
  }
113
113
 
114
114
  // 5:开始打包
115
- if (await this.build()) {
116
- // 6:将readme生成为html,并复制到dist中
117
- let outPath = "dist"
118
- // 读取配置,是否改变了输出路径
119
- if (projectConfig.config && projectConfig.config["doc-path"]) {
120
- outPath = projectConfig.config["doc-path"];
121
- }
122
- try {
123
- // 设置readme文件位置
124
- change("README", outPath);
125
- } catch (error) {
126
- console.log(chalk.red("README写入异常:" + error))
127
- }
115
+ this.build(condition, version)
116
+ }
117
+ }
118
+ /**
119
+ * 编译成功回调
120
+ */
121
+ buildSucess(condition, version) {
122
+ // 6:将readme生成为html,并复制到dist中
123
+ let outPath = "dist"
124
+ // 读取配置,是否改变了输出路径
125
+ if (projectConfig.config && projectConfig.config["doc-path"]) {
126
+ outPath = projectConfig.config["doc-path"];
127
+ }
128
+ try {
129
+ // 设置readme文件位置
130
+ change("README", outPath);
131
+ } catch (error) {
132
+ console.log(chalk.red("README写入异常:" + error))
133
+ }
128
134
 
129
- try {
130
- // 7:写入版本信息
131
- this.writeVersion(version);
132
- } catch (error) {
133
- console.log(chalk.red("版本信息写入异常:" + error))
134
- }
135
+ try {
136
+ // 7:写入版本信息
137
+ this.writeVersion(version);
138
+ } catch (error) {
139
+ console.log(chalk.red("版本信息写入异常:" + error))
140
+ }
135
141
 
136
- // 8:发布代码并设置tags,触发发布,飞书提醒
137
- if (pushCodeAndTags([condition.type], this.args.get("update"))) {
138
- if (projectConfig && projectConfig.config) {
139
- jenkins(projectConfig.config["jenkins-" + condition.type])
140
- }
141
- notifyFeishu(condition.type, version, projectConfig, this.user)
142
- notifyDingDing(condition.type, version, projectConfig, this.user)
143
- console.log();
144
- console.log(chalk.green('发布完成'));
145
- console.log();
146
- }
142
+ // 8:发布代码并设置tags,触发发布,飞书提醒
143
+ if (pushCodeAndTags([condition.type], this.args.get("update"))) {
144
+ if (projectConfig && projectConfig.config) {
145
+ jenkins(projectConfig.config["jenkins-" + condition.type])
147
146
  }
148
-
147
+ notifyFeishu(condition.type, version, projectConfig, this.user)
148
+ notifyDingDing(condition.type, version, projectConfig, this.user)
149
+ console.log();
150
+ console.log(chalk.green('发布完成'));
151
+ console.log();
149
152
  }
150
153
  }
151
154
  /**
@@ -154,26 +157,29 @@ class Publish {
154
157
  * @param {发布版本} versions:V12.0.0
155
158
  * @returns
156
159
  */
157
- async build() {
160
+ build(condition, version) {
158
161
  console.log(chalk.green('开始编译,请稍后...'));
159
162
  console.log();
163
+ let that = this;
160
164
  // 打包命令
161
- try {
162
- exec('npm run build');
163
- console.log(chalk.green('编译成功!'));
164
- console.log();
165
- return true;
166
- } catch (error) {
167
- try {
168
- exec('npx vue-cli-service build');
165
+ exec('npm run build', (error, stdout, stderr) => {
166
+ if (error) {
167
+ exec('npx vue-cli-service build', (error, stdout, stderr) => {
168
+ if (error) {
169
+ console.log('编译失败:', error);
170
+ console.log(chalk.red('编译失败:' + stdout));
171
+ } else {
172
+ console.log(chalk.green('编译成功!'));
173
+ console.log();
174
+ that.buildSucess(condition, version);
175
+ }
176
+ })
177
+ } else {
169
178
  console.log(chalk.green('编译成功!'));
170
179
  console.log();
171
- return true;
172
- } catch (error) {
173
- console.log(chalk.red('编译失败!' + error));
174
- return false
180
+ that.buildSucess(condition, version);
175
181
  }
176
- }
182
+ })
177
183
 
178
184
  }
179
185
  /**
@@ -183,7 +189,7 @@ class Publish {
183
189
  writeVersion(version) {
184
190
  try {
185
191
  // 获得分支信息
186
- let branch = exec('git rev-parse --abbrev-ref HEAD');
192
+ let branch = execSync('git rev-parse --abbrev-ref HEAD');
187
193
  branch = branch.toString("utf8").trim();
188
194
  // 获得提交版本信息
189
195
  var gitHEAD = fs.readFileSync('.git/HEAD', 'utf-8').trim()
@@ -1,4 +1,4 @@
1
- const exec = require('child_process').execSync;
1
+ const { execSync, exec } = require('child_process');
2
2
  const chalk = require("chalk")
3
3
  // 文件编辑对象
4
4
  const fs = require("fs")
@@ -37,7 +37,7 @@ class Publish {
37
37
  let arr = item.split("=");
38
38
  this.args.set(arr[0], arr[1]);
39
39
  });
40
- this.user = this.args.get("user") || exec("git config user.name").toString("utf8").trim();
40
+ this.user = this.args.get("user") || execSync("git config user.name").toString("utf8").trim();
41
41
  }
42
42
  /**
43
43
  * 初始化
@@ -64,39 +64,42 @@ class Publish {
64
64
  console.log(chalk.green('待发布版本:' + version));
65
65
  console.log();
66
66
  // 4:开始打包
67
- if (await this.build()) {
68
- // 5:将readme生成为html,并复制到dist中
69
- let outPath = "dist"
70
- // 读取配置,是否改变了输出路径
71
- if (projectConfig.config && projectConfig.config["doc-path"]) {
72
- outPath = projectConfig.config["doc-path"];
73
- }
74
- try {
75
- // 设置readme文件位置
76
- change("README", outPath);
77
- } catch (error) {
78
- console.log(chalk.red("README写入异常:" + error))
79
- }
67
+ this.build(condition, version)
68
+ }
69
+ }
70
+ /**
71
+ * 编译成功
72
+ */
73
+ buildSucess(condition, version) {
74
+ // 5:将readme生成为html,并复制到dist中
75
+ let outPath = "dist"
76
+ // 读取配置,是否改变了输出路径
77
+ if (projectConfig.config && projectConfig.config["doc-path"]) {
78
+ outPath = projectConfig.config["doc-path"];
79
+ }
80
+ try {
81
+ // 设置readme文件位置
82
+ change("README", outPath);
83
+ } catch (error) {
84
+ console.log(chalk.red("README写入异常:" + error))
85
+ }
80
86
 
81
- try {
82
- // 6:写入版本信息
83
- this.writeVersion(version, outPath);
84
- } catch (error) {
85
- console.log(chalk.red("版本信息写入异常:" + error))
86
- }
87
+ try {
88
+ // 6:写入版本信息
89
+ this.writeVersion(version, outPath);
90
+ } catch (error) {
91
+ console.log(chalk.red("版本信息写入异常:" + error))
92
+ }
87
93
 
88
- // 7:发布代码并设置tags,触发发布,飞书提醒
89
- if (pushCodeAndTags([condition.type], this.args.get("update"))) {
90
- if (projectConfig && projectConfig.config) {
91
- jenkins(projectConfig.config["jenkins-" + condition.type])
92
- }
93
- notifyDingDing(condition.type, version, projectConfig, this.user)
94
- console.log();
95
- console.log(chalk.green('发布完成'));
96
- console.log();
97
- }
94
+ // 7:发布代码并设置tags,触发发布,飞书提醒
95
+ if (pushCodeAndTags([condition.type], this.args.get("update"))) {
96
+ if (projectConfig && projectConfig.config) {
97
+ jenkins(projectConfig.config["jenkins-" + condition.type])
98
98
  }
99
-
99
+ notifyDingDing(condition.type, version, projectConfig, this.user)
100
+ console.log();
101
+ console.log(chalk.green('发布完成'));
102
+ console.log();
100
103
  }
101
104
  }
102
105
  /**
@@ -105,21 +108,20 @@ class Publish {
105
108
  * @param {发布版本} versions:V12.0.0
106
109
  * @returns
107
110
  */
108
- async build() {
111
+ build(condition, version) {
109
112
  console.log(chalk.green('开始编译,请稍后...'));
110
113
  console.log();
111
- // 打包命令
112
- try {
113
- // /Applications/HBuilderX.app/Contents/MacOS/cli macos路径
114
- exec('cli.exe publish --platform h5 --project ' + projectConfig.name);
115
- console.log(chalk.green('编译成功!'));
116
- console.log();
117
- return true;
118
- } catch (error) {
119
- console.log(chalk.red('编译失败!' + error.toString()));
120
- return false
121
- }
122
-
114
+ let that = this;
115
+ exec('cli.exe publish --platform h5 --project ' + projectConfig.name, (error, stdout, stderr) => {
116
+ if (error) {
117
+ console.log('编译失败:', error);
118
+ console.log(chalk.red('编译失败:' + stdout));
119
+ } else {
120
+ console.log(chalk.green('编译成功!'));
121
+ console.log();
122
+ that.buildSucess(condition, version);
123
+ }
124
+ })
123
125
  }
124
126
  /**
125
127
  * 将版本信息写入文件
@@ -129,7 +131,7 @@ class Publish {
129
131
  writeVersion(version, outPath = "dist") {
130
132
  try {
131
133
  // 获得分支信息
132
- let branch = exec('git rev-parse --abbrev-ref HEAD');
134
+ let branch = execSync('git rev-parse --abbrev-ref HEAD');
133
135
  branch = branch.toString("utf8").trim();
134
136
  // 获得提交版本信息
135
137
  var gitHEAD = fs.readFileSync('.git/HEAD', 'utf-8').trim()
package/template/Appvue CHANGED
@@ -1,26 +1,36 @@
1
1
  <template>
2
- <div id="app">
3
- <cloudcc-input />
2
+ <div class="app">
3
+ <div @click="hello">hello CloudCC</div>
4
+ <Plugin />
4
5
  </div>
5
6
  </template>
6
7
 
7
8
  <script>
8
- import CloudccInput from "../plugin/index.vue";
9
- export default {
10
- name: "App",
11
- components: {
12
- CloudccInput,
13
- },
14
- };
9
+ import Plugin from "../plugin/index.vue";
10
+ export default {
11
+ name: "App",
12
+ components: {
13
+ Plugin,
14
+ },
15
+ methods: {
16
+ hello() {
17
+ this.$CCDK.CCMessage.showMessage("Hello CloudCC");
18
+ },
19
+ },
20
+ };
15
21
  </script>
16
22
 
17
- <style>
18
- #app {
19
- font-family: Avenir, Helvetica, Arial, sans-serif;
20
- -webkit-font-smoothing: antialiased;
21
- -moz-osx-font-smoothing: grayscale;
22
- text-align: center;
23
- color: #2c3e50;
24
- margin-top: 60px;
25
- }
26
- </style>
23
+ <style lang="scss">
24
+ html body {
25
+ padding: 0;
26
+ margin: 0;
27
+ height: 100vh;
28
+ width: 100%;
29
+ }
30
+
31
+ .app {
32
+ margin: auto;
33
+ height: 100px;
34
+ width: 200px;
35
+ }
36
+ </style>
package/template/httpjs CHANGED
@@ -1,6 +1,5 @@
1
1
  import axios from 'axios'
2
2
  import packageJson from '../package.json'
3
- import * as CCDK from "cloudcc-ccdk/lib/ccdk.min.js";
4
3
  const service = axios.create({
5
4
  timeout: 60000, // request timeout
6
5
  headers: {
@@ -11,7 +10,7 @@ const service = axios.create({
11
10
  // request interceptor
12
11
  service.interceptors.request.use(
13
12
  config => {
14
- config.headers.accessToken = CCDK.CCToken.getToken()
13
+ config.headers.accessToken = window.$CCDK.CCToken.getToken()
15
14
  return config
16
15
  },
17
16
  error => {
@@ -39,7 +38,7 @@ const formateData = data => {
39
38
  head: {
40
39
  appType: packageJson.name,
41
40
  appVersion: packageJson.version,
42
- accessToken: CCDK.CCToken.getToken()
41
+ accessToken: window.$CCDK.CCToken.getToken()
43
42
  },
44
43
  body: {
45
44
  ...data
package/template/index.js CHANGED
@@ -44,6 +44,7 @@ module.exports = function (creator, options, callback) {
44
44
 
45
45
  creator.copyTpl('indexhtml', path.join(public, "index.html"))
46
46
 
47
+
47
48
  creator.fs.commit(() => {
48
49
  console.log();
49
50
  console.log(`${chalk.grey(`创建项目: ${name}`)} ${chalk.green('✔ ')}`);