cloudcc-cli 1.1.7 → 1.1.8
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 +8 -0
- package/package.json +1 -1
- package/src/publishProject.js +5 -6
- package/utils/pushCode.js +20 -11
package/README.md
CHANGED
package/package.json
CHANGED
package/src/publishProject.js
CHANGED
|
@@ -34,6 +34,7 @@ class Publish {
|
|
|
34
34
|
* language:是否更新多语言,'1'更新,'0'不更新
|
|
35
35
|
* buildType:打包方式,online-云打包,local-本地打包
|
|
36
36
|
* user:打包用户
|
|
37
|
+
* update:代码不同步的时候,是否强制更新代码
|
|
37
38
|
*/
|
|
38
39
|
this.args = new Map();
|
|
39
40
|
this.arguments = process.argv.splice(2).map((item) => {
|
|
@@ -41,8 +42,6 @@ class Publish {
|
|
|
41
42
|
this.args.set(arr[0], arr[1]);
|
|
42
43
|
});
|
|
43
44
|
this.user = this.args.get("user") || exec("git config user.name").toString("utf8").trim();
|
|
44
|
-
console.log(this.args);
|
|
45
|
-
|
|
46
45
|
}
|
|
47
46
|
/**
|
|
48
47
|
* 初始化
|
|
@@ -91,7 +90,7 @@ class Publish {
|
|
|
91
90
|
|
|
92
91
|
// 3.1:将版本信息写入env文件中,公其他业务使用
|
|
93
92
|
try {
|
|
94
|
-
fs.writeFileSync(".env.production", "VUE_APP_PROJECT_VERSION = " +
|
|
93
|
+
fs.writeFileSync(".env.production", "VUE_APP_PROJECT_VERSION = " + condition.type, 'utf-8')
|
|
95
94
|
} catch (error) {
|
|
96
95
|
}
|
|
97
96
|
|
|
@@ -135,7 +134,7 @@ class Publish {
|
|
|
135
134
|
}
|
|
136
135
|
|
|
137
136
|
// 8:发布代码并设置tags,触发发布,飞书提醒
|
|
138
|
-
if (pushCodeAndTags([condition.type])) {
|
|
137
|
+
if (pushCodeAndTags([condition.type], this.args.get("update"))) {
|
|
139
138
|
if (projectConfig && projectConfig.config) {
|
|
140
139
|
jenkins(projectConfig.config["jenkins-" + condition.type])
|
|
141
140
|
}
|
|
@@ -152,7 +151,7 @@ class Publish {
|
|
|
152
151
|
/**
|
|
153
152
|
* 编译代码
|
|
154
153
|
* @param {发布类型} types:Dev,uat,Release,GA,RC
|
|
155
|
-
* @param {发布版本} versions:
|
|
154
|
+
* @param {发布版本} versions:V12.0.0
|
|
156
155
|
* @returns
|
|
157
156
|
*/
|
|
158
157
|
async build() {
|
|
@@ -207,7 +206,7 @@ class Publish {
|
|
|
207
206
|
|
|
208
207
|
<body>
|
|
209
208
|
<div style="font-size: 20px">
|
|
210
|
-
<div
|
|
209
|
+
<div>${projectConfig.name}</div>
|
|
211
210
|
<div style="margin-left:48px">
|
|
212
211
|
<div>分支:${branch}</div>
|
|
213
212
|
<div>版本号:${version}</div>
|
package/utils/pushCode.js
CHANGED
|
@@ -19,20 +19,20 @@ function getNewVersionName(types) {
|
|
|
19
19
|
let versions = version.split("\n");
|
|
20
20
|
// 取出第一个包含-V的版本号
|
|
21
21
|
version = versions.find((item) => {
|
|
22
|
-
return item.includes("
|
|
22
|
+
return item.includes("V");
|
|
23
23
|
})
|
|
24
24
|
if (version) {
|
|
25
25
|
// 取版本号
|
|
26
|
-
version = version.split("
|
|
26
|
+
version = version.split("V")[1]
|
|
27
27
|
// 改变版本号
|
|
28
28
|
version = changeVersion.change(version, item)
|
|
29
29
|
// 生成最后的版本号
|
|
30
|
-
item =
|
|
30
|
+
item = "V" + version
|
|
31
31
|
} else {
|
|
32
|
-
item =
|
|
32
|
+
item = "V0.0.1"
|
|
33
33
|
}
|
|
34
34
|
} else {
|
|
35
|
-
item =
|
|
35
|
+
item = "V0.0.1"
|
|
36
36
|
}
|
|
37
37
|
return item;
|
|
38
38
|
})
|
|
@@ -40,8 +40,11 @@ function getNewVersionName(types) {
|
|
|
40
40
|
|
|
41
41
|
/**
|
|
42
42
|
* 将代码推送至gitlab
|
|
43
|
+
* @param {version} 版本号
|
|
44
|
+
* @param {update} 是否强制更新:1强制更新,0不强制更新
|
|
45
|
+
* @returns true 成功,false 失败
|
|
43
46
|
*/
|
|
44
|
-
function push(version) {
|
|
47
|
+
function push(version, update = "0") {
|
|
45
48
|
try {
|
|
46
49
|
// 添加改变文件
|
|
47
50
|
exec("git add .")
|
|
@@ -64,9 +67,14 @@ function push(version) {
|
|
|
64
67
|
console.log();
|
|
65
68
|
console.log(chalk.green('代码推送成功!'));
|
|
66
69
|
} catch (error) {
|
|
67
|
-
console.log(
|
|
68
|
-
|
|
69
|
-
|
|
70
|
+
console.log("update", update);
|
|
71
|
+
if ("1" == update) {
|
|
72
|
+
exec(`git fetch --tags -f && git pull --force`)
|
|
73
|
+
} else {
|
|
74
|
+
console.log(chalk.red('代码推送失败,本地代码与线上不同步,请先 git pull 同步!'));
|
|
75
|
+
console.log();
|
|
76
|
+
return false;
|
|
77
|
+
}
|
|
70
78
|
}
|
|
71
79
|
return true
|
|
72
80
|
}
|
|
@@ -163,9 +171,10 @@ function deleteDist() {
|
|
|
163
171
|
/**
|
|
164
172
|
* 发布代码同时设置Tags
|
|
165
173
|
* @param {types} 版本集合
|
|
174
|
+
* @param {update} 是否强制更新
|
|
166
175
|
*/
|
|
167
|
-
function pushCodeAndTags(types = []) {
|
|
176
|
+
function pushCodeAndTags(types = [], update = "0") {
|
|
168
177
|
let versions = getNewVersionName(types);
|
|
169
|
-
return push(versions[0]) && setTag(types, versions) && deleteDist(versions[0]);
|
|
178
|
+
return push(versions[0], update) && setTag(types, versions) && deleteDist(versions[0]);
|
|
170
179
|
}
|
|
171
180
|
module.exports = { pushCodeAndTags, push, getNewVersionName, setTag }
|