cloudcc-cli 1.1.8 → 1.2.1
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 +21 -0
- package/bin/buildtag.js +7 -0
- package/bin/publishh5.js +7 -0
- package/package.json +4 -2
- package/src/buildTag.js +75 -0
- package/src/creatorTemProject.js +2 -1
- package/src/publishProject.js +4 -3
- package/src/publishProjectH5.js +179 -0
- package/template/httpjs +4 -4
- package/template/index.js +4 -0
- package/template/package-lockjson +12168 -0
- package/template/packagejson +1 -0
- package/utils/askTool.js +14 -0
- package/utils/pushCode.js +7 -0
package/README.md
CHANGED
|
@@ -1,3 +1,24 @@
|
|
|
1
|
+
# ReleaseV1.2.1
|
|
2
|
+
#### 发布日期:2022-9-9
|
|
3
|
+
#### 发布范围:全量
|
|
4
|
+
#### 发布内容
|
|
5
|
+
* 修复
|
|
6
|
+
* 添加cloudcc-ccdk
|
|
7
|
+
|
|
8
|
+
# ReleaseV1.2.0
|
|
9
|
+
#### 发布日期:2022-8-24
|
|
10
|
+
#### 发布范围:全量
|
|
11
|
+
#### 发布内容
|
|
12
|
+
* 修复
|
|
13
|
+
* 增加创建tag功能
|
|
14
|
+
|
|
15
|
+
# ReleaseV1.1.9
|
|
16
|
+
#### 发布日期:2022-8-23
|
|
17
|
+
#### 发布范围:全量
|
|
18
|
+
#### 发布内容
|
|
19
|
+
* 修复
|
|
20
|
+
* 增加h5打包逻辑
|
|
21
|
+
|
|
1
22
|
# ReleaseV1.1.8
|
|
2
23
|
#### 发布日期:2022-7-20
|
|
3
24
|
#### 发布范围:全量
|
package/bin/buildtag.js
ADDED
package/bin/publishh5.js
ADDED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "cloudcc-cli",
|
|
3
|
-
"version": "1.1
|
|
3
|
+
"version": "1.2.1",
|
|
4
4
|
"description": "cloudcc-cli",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"cloudcc",
|
|
@@ -13,8 +13,10 @@
|
|
|
13
13
|
"cloudccCreate": "bin/create.js",
|
|
14
14
|
"cloudccBuild": "bin/build.js",
|
|
15
15
|
"cloudccPublic": "bin/publish.js",
|
|
16
|
+
"cloudccPublicH5": "bin/publishh5.js",
|
|
16
17
|
"cloudccBuildCCSDK": "bin/buildccsdk.js",
|
|
17
|
-
"cloudccBuildCCBaseSDK": "bin/buildccbasesdk.js"
|
|
18
|
+
"cloudccBuildCCBaseSDK": "bin/buildccbasesdk.js",
|
|
19
|
+
"cloudccBuildTag": "bin/buildtag.js"
|
|
18
20
|
},
|
|
19
21
|
"scripts": {
|
|
20
22
|
"publish-lib": "npm publish --registry https://registry.npmjs.org"
|
package/src/buildTag.js
ADDED
|
@@ -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;
|
package/src/creatorTemProject.js
CHANGED
|
@@ -25,7 +25,8 @@ class Creator {
|
|
|
25
25
|
let res = await checkUpdate();
|
|
26
26
|
if (!res) {
|
|
27
27
|
console.log()
|
|
28
|
-
console.log(chalk.green('欢迎使用
|
|
28
|
+
console.log(chalk.green('欢迎使用CloudCC-CLI'));
|
|
29
|
+
console.log()
|
|
29
30
|
this.ask().then(answers => {
|
|
30
31
|
this.options = Object.assign({}, this.options, answers);
|
|
31
32
|
console.log(this.options);
|
package/src/publishProject.js
CHANGED
|
@@ -48,7 +48,9 @@ class Publish {
|
|
|
48
48
|
*/
|
|
49
49
|
async init() {
|
|
50
50
|
// 检查cli版本,提示用户更新:false:不更新,true:更新
|
|
51
|
-
let update =
|
|
51
|
+
// let update = false
|
|
52
|
+
let update = false;
|
|
53
|
+
// let update = await checkUpdate();
|
|
52
54
|
if (!update) {
|
|
53
55
|
// 1:版本发布信息,包含发布版本类型信息
|
|
54
56
|
let condition = {};
|
|
@@ -87,10 +89,9 @@ class Publish {
|
|
|
87
89
|
console.log();
|
|
88
90
|
console.log(chalk.green('待发布版本:' + version));
|
|
89
91
|
console.log();
|
|
90
|
-
|
|
91
92
|
// 3.1:将版本信息写入env文件中,公其他业务使用
|
|
92
93
|
try {
|
|
93
|
-
fs.writeFileSync(".env.production", "VUE_APP_PROJECT_VERSION = " + condition.type, 'utf-8')
|
|
94
|
+
fs.writeFileSync(".env.production", "VUE_APP_PROJECT_VERSION = " + condition.type + "-" + version, 'utf-8')
|
|
94
95
|
} catch (error) {
|
|
95
96
|
}
|
|
96
97
|
|
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
const exec = require('child_process').execSync;
|
|
2
|
+
const chalk = require("chalk")
|
|
3
|
+
// 文件编辑对象
|
|
4
|
+
const fs = require("fs")
|
|
5
|
+
// 配置信息
|
|
6
|
+
const projectConfig = JSON.parse(fs.readFileSync('package.json', 'utf8'))
|
|
7
|
+
// 网页转换器
|
|
8
|
+
const { change } = require("../utils/md2html")
|
|
9
|
+
// 检查版本更新
|
|
10
|
+
const { checkUpdate } = require("../utils/checkVersion")
|
|
11
|
+
// 控制台交互
|
|
12
|
+
const { askType, askTypeOther, askBuildType } = require("../utils/askTool")
|
|
13
|
+
// 提交代码,设置Tag
|
|
14
|
+
const { getNewVersionName, pushCodeAndTags } = require("../utils/pushCode")
|
|
15
|
+
// 触发构建器
|
|
16
|
+
const { jenkins } = require("../utils/trigger")
|
|
17
|
+
// 通知飞书
|
|
18
|
+
const { notifyFeishu, notifyDingDing } = require("../utils/notifyIM")
|
|
19
|
+
// 时间库
|
|
20
|
+
const dayjs = require("dayjs")
|
|
21
|
+
/**
|
|
22
|
+
* H5项目打包发布脚本
|
|
23
|
+
*/
|
|
24
|
+
class Publish {
|
|
25
|
+
constructor() {
|
|
26
|
+
/**
|
|
27
|
+
* 控制台参数:key=value
|
|
28
|
+
* type:发布的tag
|
|
29
|
+
* branch:使用的分支
|
|
30
|
+
* language:是否更新多语言,'1'更新,'0'不更新
|
|
31
|
+
* buildType:打包方式,online-云打包,local-本地打包
|
|
32
|
+
* user:打包用户
|
|
33
|
+
* update:代码不同步的时候,是否强制更新代码
|
|
34
|
+
*/
|
|
35
|
+
this.args = new Map();
|
|
36
|
+
this.arguments = process.argv.splice(2).map((item) => {
|
|
37
|
+
let arr = item.split("=");
|
|
38
|
+
this.args.set(arr[0], arr[1]);
|
|
39
|
+
});
|
|
40
|
+
this.user = this.args.get("user") || exec("git config user.name").toString("utf8").trim();
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* 初始化
|
|
44
|
+
*/
|
|
45
|
+
async init() {
|
|
46
|
+
// 检查cli版本,提示用户更新:false:不更新,true:更新
|
|
47
|
+
// let update = false
|
|
48
|
+
let update = await checkUpdate();
|
|
49
|
+
if (!update) {
|
|
50
|
+
// 1:版本发布信息,包含发布版本类型信息
|
|
51
|
+
let condition = {};
|
|
52
|
+
// 2:检查命令行是否输入了发布版本信息,如果没有包含,那么询问发布类型
|
|
53
|
+
if (this.args.get("type")) {
|
|
54
|
+
condition.type = this.args.get("type")
|
|
55
|
+
} else {
|
|
56
|
+
// 询问发布类型
|
|
57
|
+
condition = await askType();
|
|
58
|
+
if ("other" == condition.type) {
|
|
59
|
+
condition = await askTypeOther();
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
// 3:获取新的发布版本号
|
|
63
|
+
let version = getNewVersionName([condition.type])
|
|
64
|
+
console.log();
|
|
65
|
+
console.log(chalk.green('待发布版本:' + version));
|
|
66
|
+
console.log();
|
|
67
|
+
// 4:开始打包
|
|
68
|
+
if (await this.build()) {
|
|
69
|
+
// 5:将readme生成为html,并复制到dist中
|
|
70
|
+
let outPath = "dist"
|
|
71
|
+
// 读取配置,是否改变了输出路径
|
|
72
|
+
if (projectConfig.config && projectConfig.config["doc-path"]) {
|
|
73
|
+
outPath = projectConfig.config["doc-path"];
|
|
74
|
+
}
|
|
75
|
+
try {
|
|
76
|
+
// 设置readme文件位置
|
|
77
|
+
change("README", outPath);
|
|
78
|
+
} catch (error) {
|
|
79
|
+
console.log(chalk.red("README写入异常:" + error))
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
try {
|
|
83
|
+
// 6:写入版本信息
|
|
84
|
+
this.writeVersion(version, outPath);
|
|
85
|
+
} catch (error) {
|
|
86
|
+
console.log(chalk.red("版本信息写入异常:" + error))
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
// 7:发布代码并设置tags,触发发布,飞书提醒
|
|
90
|
+
if (pushCodeAndTags([condition.type], this.args.get("update"))) {
|
|
91
|
+
if (projectConfig && projectConfig.config) {
|
|
92
|
+
jenkins(projectConfig.config["jenkins-" + condition.type])
|
|
93
|
+
}
|
|
94
|
+
notifyDingDing(condition.type, version, projectConfig, this.user)
|
|
95
|
+
console.log();
|
|
96
|
+
console.log(chalk.green('发布完成'));
|
|
97
|
+
console.log();
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* 编译代码
|
|
105
|
+
* @param {发布类型} types:Dev,uat,Release,GA,RC
|
|
106
|
+
* @param {发布版本} versions:V12.0.0
|
|
107
|
+
* @returns
|
|
108
|
+
*/
|
|
109
|
+
async build() {
|
|
110
|
+
console.log(chalk.green('开始编译,请稍后...'));
|
|
111
|
+
console.log();
|
|
112
|
+
// 打包命令
|
|
113
|
+
try {
|
|
114
|
+
// /Applications/HBuilderX.app/Contents/MacOS/cli macos路径
|
|
115
|
+
exec('cli.exe publish --platform h5 --project ' + projectConfig.name);
|
|
116
|
+
console.log(chalk.green('编译成功!'));
|
|
117
|
+
console.log();
|
|
118
|
+
return true;
|
|
119
|
+
} catch (error) {
|
|
120
|
+
console.log(chalk.red('编译失败!' + error.toString()));
|
|
121
|
+
return false
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
}
|
|
125
|
+
/**
|
|
126
|
+
* 将版本信息写入文件
|
|
127
|
+
* @param {版本信息} version
|
|
128
|
+
* @param {输出路径} outPath
|
|
129
|
+
*/
|
|
130
|
+
writeVersion(version, outPath = "dist") {
|
|
131
|
+
try {
|
|
132
|
+
// 获得分支信息
|
|
133
|
+
let branch = exec('git rev-parse --abbrev-ref HEAD');
|
|
134
|
+
branch = branch.toString("utf8").trim();
|
|
135
|
+
// 获得提交版本信息
|
|
136
|
+
var gitHEAD = fs.readFileSync('.git/HEAD', 'utf-8').trim()
|
|
137
|
+
var ref = gitHEAD.split(': ')[1]
|
|
138
|
+
var develop = gitHEAD.split('/')[2]
|
|
139
|
+
var gitVersion = fs.readFileSync('.git/' + ref, 'utf-8').trim()
|
|
140
|
+
var gitCommitVersion = '"' + develop + ': ' + gitVersion + '"'
|
|
141
|
+
|
|
142
|
+
let versionInfo =
|
|
143
|
+
`
|
|
144
|
+
<!DOCTYPE html>
|
|
145
|
+
<html lang="en">
|
|
146
|
+
|
|
147
|
+
<head>
|
|
148
|
+
<meta charset="UTF-8">
|
|
149
|
+
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
|
150
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
151
|
+
<title>版本信息</title>
|
|
152
|
+
</head>
|
|
153
|
+
|
|
154
|
+
<body>
|
|
155
|
+
<div style="font-size: 20px">
|
|
156
|
+
<div>${projectConfig.name}</div>
|
|
157
|
+
<div style="margin-left:48px">
|
|
158
|
+
<div>分支:${branch}</div>
|
|
159
|
+
<div>版本号:${version}</div>
|
|
160
|
+
<div>提交Hash:${gitCommitVersion}</div>
|
|
161
|
+
<div>发布时间:${dayjs().format('YYYY-MM-DD HH:mm:ss')}</div>
|
|
162
|
+
<div>发布人员:${this.user}</div>
|
|
163
|
+
</div>
|
|
164
|
+
</div>
|
|
165
|
+
</body>
|
|
166
|
+
|
|
167
|
+
</html>
|
|
168
|
+
`
|
|
169
|
+
fs.writeFileSync(outPath + "/version.html", versionInfo, 'utf-8');
|
|
170
|
+
return true
|
|
171
|
+
} catch (error) {
|
|
172
|
+
return false
|
|
173
|
+
}
|
|
174
|
+
};
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
module.exports = Publish;
|
|
178
|
+
|
|
179
|
+
|
package/template/httpjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import VueCookies from "vue-cookies";
|
|
2
1
|
import axios from 'axios'
|
|
3
2
|
import packageJson from '../package.json'
|
|
3
|
+
import * as CCDK from "cloudcc-ccdk/lib/ccdk.min.js";
|
|
4
4
|
const service = axios.create({
|
|
5
5
|
timeout: 60000, // request timeout
|
|
6
6
|
headers: {
|
|
@@ -8,10 +8,10 @@ const service = axios.create({
|
|
|
8
8
|
},
|
|
9
9
|
})
|
|
10
10
|
|
|
11
|
-
// request interceptor
|
|
11
|
+
// request interceptor
|
|
12
12
|
service.interceptors.request.use(
|
|
13
13
|
config => {
|
|
14
|
-
config.headers.accessToken =
|
|
14
|
+
config.headers.accessToken = CCDK.CCToken.getToken()
|
|
15
15
|
return config
|
|
16
16
|
},
|
|
17
17
|
error => {
|
|
@@ -39,7 +39,7 @@ const formateData = data => {
|
|
|
39
39
|
head: {
|
|
40
40
|
appType: packageJson.name,
|
|
41
41
|
appVersion: packageJson.version,
|
|
42
|
-
accessToken:
|
|
42
|
+
accessToken: CCDK.CCToken.getToken()
|
|
43
43
|
},
|
|
44
44
|
body: {
|
|
45
45
|
...data
|
package/template/index.js
CHANGED
|
@@ -24,6 +24,10 @@ module.exports = function (creator, options, callback) {
|
|
|
24
24
|
name, description
|
|
25
25
|
})
|
|
26
26
|
|
|
27
|
+
creator.copyTpl('package-lockjson', path.join(projectPath, "package-lock.json"), {
|
|
28
|
+
name, description
|
|
29
|
+
})
|
|
30
|
+
|
|
27
31
|
creator.copyTpl('vueconfigjs', path.join(projectPath, "vue.config.js"))
|
|
28
32
|
|
|
29
33
|
creator.copyTpl('babelconfigjs', path.join(projectPath, "babel.config.js"))
|