cloudcc-cli 1.6.4 → 1.6.6
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 +1176 -1161
- package/bin/cc.js +49 -49
- package/bin/plugin.js +6 -6
- package/bin/project.js +6 -6
- package/core/core/CCObject.java +48 -0
- package/core/core/CCService.java +806 -0
- package/core/core/CCTrigger.java +23 -0
- package/core/core/CCTriggerHandler.java +15 -0
- package/core/core/DevLogger.java +39 -0
- package/core/core/OperatationEnum.java +5 -0
- package/core/core/PeakInterf.java +6 -0
- package/core/core/PeakSvc.java +8 -0
- package/core/core/ServiceResult.java +35 -0
- package/core/core/TriggerInvoker.java +83 -0
- package/core/core/TriggerMethod.java +9 -0
- package/core/core/TriggerTimeEnum.java +5 -0
- package/core/core/UserInfo.java +45 -0
- package/core.zip +0 -0
- package/package.json +34 -34
- package/src/classes/create.js +40 -43
- package/src/classes/index.js +8 -8
- package/src/classes/publish.js +43 -47
- package/src/config/get.js +20 -22
- package/src/config/index.js +8 -8
- package/src/config/use.js +14 -16
- package/src/object/get.js +14 -16
- package/src/object/index.js +7 -7
- package/src/plugin/create.js +70 -80
- package/src/plugin/create1.js +58 -66
- package/src/plugin/index.js +8 -8
- package/src/plugin/publish.js +265 -298
- package/src/plugin/publish1.js +256 -286
- package/src/project/create.js +87 -89
- package/src/project/create1.js +109 -111
- package/src/project/index.js +7 -7
- package/src/recordType/get.js +13 -16
- package/src/recordType/index.js +7 -7
- package/src/script/create.js +29 -32
- package/src/script/index.js +8 -8
- package/src/script/publish.js +62 -69
- package/src/timer/create.js +26 -29
- package/src/timer/index.js +8 -8
- package/src/timer/publish.js +43 -47
- package/src/token/get.js +11 -13
- package/src/token/index.js +7 -7
- package/src/triggers/create.js +27 -35
- package/src/triggers/index.js +8 -8
- package/src/triggers/publish.js +48 -51
- package/template/Appvue +29 -29
- package/template/babelconfigjs +5 -5
- package/template/demojava +14 -14
- package/template/gitignore +11 -11
- package/template/index.js +57 -57
- package/template/indexhtml +21 -21
- package/template/indexvue +34 -34
- package/template/javaconfigjson +2 -2
- package/template/mainjs +13 -13
- package/template/package-lockjson +12115 -12115
- package/template/packagejson +42 -42
- package/template/vueconfigjs +26 -26
- package/tool/branch/index.js +25 -0
- package/tool/checkLange/checkLang.js +68 -0
- package/tool/checkLange/clearLang.js +85 -0
- package/tool/checkLange/result.txt +0 -0
- package/utils/checkVersion.js +94 -105
- package/utils/http.js +122 -122
- package/utils/utils.js +57 -59
package/template/packagejson
CHANGED
|
@@ -1,43 +1,43 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "cloudcc-plugin",
|
|
3
|
-
"version": "1.0.0",
|
|
4
|
-
"description": "cloudcc-plugin-dev",
|
|
5
|
-
"scripts": {
|
|
6
|
-
"serve": "vue-cli-service serve"
|
|
7
|
-
},
|
|
8
|
-
"dependencies": {
|
|
9
|
-
"element-ui": "2.15.12",
|
|
10
|
-
"vue": "2.6.14",
|
|
11
|
-
"vue-custom-element": "3.3.0"
|
|
12
|
-
},
|
|
13
|
-
"devDependencies": {
|
|
14
|
-
"@vue/cli-plugin-babel": "~4.5.0",
|
|
15
|
-
"@vue/cli-plugin-eslint": "~4.5.0",
|
|
16
|
-
"@vue/cli-service": "~4.5.0",
|
|
17
|
-
"babel-eslint": "^10.1.0",
|
|
18
|
-
"eslint": "^6.7.2",
|
|
19
|
-
"eslint-plugin-vue": "^6.2.2",
|
|
20
|
-
"sass": "1.26.8",
|
|
21
|
-
"sass-loader": "8.0.2",
|
|
22
|
-
"vue-template-compiler": "2.6.14"
|
|
23
|
-
},
|
|
24
|
-
"eslintConfig": {
|
|
25
|
-
"root": true,
|
|
26
|
-
"env": {
|
|
27
|
-
"node": true
|
|
28
|
-
},
|
|
29
|
-
"extends": [
|
|
30
|
-
"plugin:vue/essential",
|
|
31
|
-
"eslint:recommended"
|
|
32
|
-
],
|
|
33
|
-
"parserOptions": {
|
|
34
|
-
"parser": "babel-eslint"
|
|
35
|
-
},
|
|
36
|
-
"rules": {}
|
|
37
|
-
},
|
|
38
|
-
"browserslist": [
|
|
39
|
-
"> 1%",
|
|
40
|
-
"last 2 versions",
|
|
41
|
-
"not dead"
|
|
42
|
-
]
|
|
1
|
+
{
|
|
2
|
+
"name": "cloudcc-plugin",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "cloudcc-plugin-dev",
|
|
5
|
+
"scripts": {
|
|
6
|
+
"serve": "vue-cli-service serve"
|
|
7
|
+
},
|
|
8
|
+
"dependencies": {
|
|
9
|
+
"element-ui": "2.15.12",
|
|
10
|
+
"vue": "2.6.14",
|
|
11
|
+
"vue-custom-element": "3.3.0"
|
|
12
|
+
},
|
|
13
|
+
"devDependencies": {
|
|
14
|
+
"@vue/cli-plugin-babel": "~4.5.0",
|
|
15
|
+
"@vue/cli-plugin-eslint": "~4.5.0",
|
|
16
|
+
"@vue/cli-service": "~4.5.0",
|
|
17
|
+
"babel-eslint": "^10.1.0",
|
|
18
|
+
"eslint": "^6.7.2",
|
|
19
|
+
"eslint-plugin-vue": "^6.2.2",
|
|
20
|
+
"sass": "1.26.8",
|
|
21
|
+
"sass-loader": "8.0.2",
|
|
22
|
+
"vue-template-compiler": "2.6.14"
|
|
23
|
+
},
|
|
24
|
+
"eslintConfig": {
|
|
25
|
+
"root": true,
|
|
26
|
+
"env": {
|
|
27
|
+
"node": true
|
|
28
|
+
},
|
|
29
|
+
"extends": [
|
|
30
|
+
"plugin:vue/essential",
|
|
31
|
+
"eslint:recommended"
|
|
32
|
+
],
|
|
33
|
+
"parserOptions": {
|
|
34
|
+
"parser": "babel-eslint"
|
|
35
|
+
},
|
|
36
|
+
"rules": {}
|
|
37
|
+
},
|
|
38
|
+
"browserslist": [
|
|
39
|
+
"> 1%",
|
|
40
|
+
"last 2 versions",
|
|
41
|
+
"not dead"
|
|
42
|
+
]
|
|
43
43
|
}
|
package/template/vueconfigjs
CHANGED
|
@@ -1,27 +1,27 @@
|
|
|
1
|
-
// 打包排除依赖包
|
|
2
|
-
const external = process.env.NODE_ENV == 'development' ? {} : {
|
|
3
|
-
"vue": 'Vue',
|
|
4
|
-
"vue-router": 'VueRouter',
|
|
5
|
-
'vue-echarts': 'VueECharts',
|
|
6
|
-
'element-ui': 'ELEMENT',
|
|
7
|
-
"axios": 'axios',
|
|
8
|
-
"d3": 'd3',
|
|
9
|
-
'echarts': 'echarts',
|
|
10
|
-
"jschardet": 'jschardet',
|
|
11
|
-
"crypto-js": 'CryptoJS',
|
|
12
|
-
"vue-i18n": 'VueI18n',
|
|
13
|
-
}
|
|
14
|
-
module.exports = {
|
|
15
|
-
publicPath: '/',
|
|
16
|
-
// 关闭生成Map文件
|
|
17
|
-
productionSourceMap: false,
|
|
18
|
-
configureWebpack: {
|
|
19
|
-
},
|
|
20
|
-
// css强制内联在js中
|
|
21
|
-
css: { extract: false },
|
|
22
|
-
// 精细化修改webpack打包逻辑
|
|
23
|
-
chainWebpack: config => {
|
|
24
|
-
// 排除某些包,禁止打包到chunck中
|
|
25
|
-
config.externals(external)
|
|
26
|
-
}
|
|
1
|
+
// 打包排除依赖包
|
|
2
|
+
const external = process.env.NODE_ENV == 'development' ? {} : {
|
|
3
|
+
"vue": 'Vue',
|
|
4
|
+
"vue-router": 'VueRouter',
|
|
5
|
+
'vue-echarts': 'VueECharts',
|
|
6
|
+
'element-ui': 'ELEMENT',
|
|
7
|
+
"axios": 'axios',
|
|
8
|
+
"d3": 'd3',
|
|
9
|
+
'echarts': 'echarts',
|
|
10
|
+
"jschardet": 'jschardet',
|
|
11
|
+
"crypto-js": 'CryptoJS',
|
|
12
|
+
"vue-i18n": 'VueI18n',
|
|
13
|
+
}
|
|
14
|
+
module.exports = {
|
|
15
|
+
publicPath: '/',
|
|
16
|
+
// 关闭生成Map文件
|
|
17
|
+
productionSourceMap: false,
|
|
18
|
+
configureWebpack: {
|
|
19
|
+
},
|
|
20
|
+
// css强制内联在js中
|
|
21
|
+
css: { extract: false },
|
|
22
|
+
// 精细化修改webpack打包逻辑
|
|
23
|
+
chainWebpack: config => {
|
|
24
|
+
// 排除某些包,禁止打包到chunck中
|
|
25
|
+
config.externals(external)
|
|
26
|
+
}
|
|
27
27
|
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
const exec = require('child_process').execSync;
|
|
2
|
+
const fs = require("fs")
|
|
3
|
+
function checkBranch(inBranch, notInBranch, condition = '') {
|
|
4
|
+
exec(`git remote prune origin`)
|
|
5
|
+
let in_branch = exec(`git branch -r --merged origin/${inBranch}`).toString("utf8").trim().split("\n ")
|
|
6
|
+
let guolv = [];
|
|
7
|
+
in_branch.map((branch) => {
|
|
8
|
+
try {
|
|
9
|
+
let containsBranch = ""
|
|
10
|
+
if (branch.indexOf("origin/HEAD") == -1) {
|
|
11
|
+
containsBranch = exec(`git branch -r --contains "${branch}"`).toString("utf8").trim().split("\n ")
|
|
12
|
+
}
|
|
13
|
+
if (branch.indexOf(condition) != -1 && containsBranch.includes("origin/" + inBranch) && !containsBranch.includes("origin/" + notInBranch) && ('origin/' + inBranch) != branch) {
|
|
14
|
+
guolv.push(branch)
|
|
15
|
+
}
|
|
16
|
+
} catch (error) {
|
|
17
|
+
console.log(error)
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
})
|
|
21
|
+
fs.writeFileSync("./tool/branch/" + inBranch + "_" + notInBranch, guolv.join("\n").toString("utf8").trim(), 'utf-8')
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
checkBranch("one-master-B", "one-master-A");
|
|
25
|
+
checkBranch("v17-dev-2024-06-14", "one-master-B");
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
const fs = require("fs")
|
|
2
|
+
const path = require("path")
|
|
3
|
+
|
|
4
|
+
const chineseRegex = /[\u4e00-\u9fa5]/;
|
|
5
|
+
|
|
6
|
+
const folderPath = './';
|
|
7
|
+
|
|
8
|
+
const excludeFolders = ['.git',"node_modules"];
|
|
9
|
+
const excludeFiles = ['checkLang.js',];
|
|
10
|
+
|
|
11
|
+
let length = 0;
|
|
12
|
+
|
|
13
|
+
function checkFilesInFolder(folderPath) {
|
|
14
|
+
fs.readdir(folderPath, (err, files) => {
|
|
15
|
+
if (err) {
|
|
16
|
+
console.error('Error reading directory:', err);
|
|
17
|
+
return;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
files.forEach(file => {
|
|
21
|
+
const filePath = path.join(folderPath, file);
|
|
22
|
+
|
|
23
|
+
fs.stat(filePath, (err, stats) => {
|
|
24
|
+
if (err) {
|
|
25
|
+
console.error('Error stating file:', err);
|
|
26
|
+
return;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
if (stats.isFile() && (file.endsWith('.vue') || file.endsWith('.js')|| file.endsWith('.scss')|| file.endsWith('.css'))) {
|
|
30
|
+
if (!excludeFiles.includes(file)) {
|
|
31
|
+
fs.readFile(filePath, 'utf8', (err, data) => {
|
|
32
|
+
if (err) {
|
|
33
|
+
console.error('Error reading file:', err);
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
if (chineseRegex.test(data)) {
|
|
38
|
+
length++;
|
|
39
|
+
console.log(`have "${filePath}"`);
|
|
40
|
+
}
|
|
41
|
+
});
|
|
42
|
+
} else {
|
|
43
|
+
// console.log(`jump filePath"${filePath}"`);
|
|
44
|
+
}
|
|
45
|
+
} else if (stats.isDirectory()) {
|
|
46
|
+
if (!excludeFolders.includes(file)) {
|
|
47
|
+
checkFilesInFolder(filePath);
|
|
48
|
+
} else {
|
|
49
|
+
// console.log(`jump filePath"${filePath}"`);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
});
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
checkFilesInFolder(folderPath);
|
|
59
|
+
|
|
60
|
+
function getLength() {
|
|
61
|
+
setTimeout(() => {
|
|
62
|
+
console.log(`==============================================================`)
|
|
63
|
+
console.log(`total ${length} files have chinese`);
|
|
64
|
+
console.log(`==============================================================`)
|
|
65
|
+
}, 1000);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
getLength();
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
const fs = require('fs');
|
|
2
|
+
const path = require('path');
|
|
3
|
+
|
|
4
|
+
// /* */
|
|
5
|
+
const reg1 = /\/\*[\s\S]*?\*\//g;
|
|
6
|
+
|
|
7
|
+
// <!-- -->
|
|
8
|
+
const reg2 = /<!--[\s\S]*?-->/gm;
|
|
9
|
+
|
|
10
|
+
// //
|
|
11
|
+
const reg3 =/\/\/(?!.*eslint-disable-next-line).*$/gm;
|
|
12
|
+
|
|
13
|
+
const excludeFolders = ['.git', "node_modules", 'tool', 'public', path.join('src', 'utils', 'i18n')];
|
|
14
|
+
|
|
15
|
+
function readDirectory(directory) {
|
|
16
|
+
fs.readdir(directory, (err, files) => {
|
|
17
|
+
if (err) {
|
|
18
|
+
console.error('can not read dir:', err);
|
|
19
|
+
return;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
files.forEach(file => {
|
|
23
|
+
const filePath = path.join(directory, file);
|
|
24
|
+
|
|
25
|
+
if (excludeFolders.some(folder => filePath.startsWith(folder))) {
|
|
26
|
+
return;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
fs.stat(filePath, (err, stats) => {
|
|
30
|
+
if (err) {
|
|
31
|
+
console.error('can not read file:', err);
|
|
32
|
+
return;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
if (stats.isDirectory()) {
|
|
36
|
+
readDirectory(filePath);
|
|
37
|
+
} else if (stats.isFile() && (file.endsWith('.vue') || file.endsWith('.js')|| file.endsWith('.scss')|| file.endsWith('.css'))) {
|
|
38
|
+
removeChineseComments(filePath);
|
|
39
|
+
}
|
|
40
|
+
});
|
|
41
|
+
});
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
function removeChineseComments(filePath) {
|
|
46
|
+
fs.readFile(filePath, 'utf8', (err, data) => {
|
|
47
|
+
if (err) {
|
|
48
|
+
console.error('can not read file:', err);
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
51
|
+
const newData = data
|
|
52
|
+
.replace(/\/\*\s*eslint-disable no-useless-escape\s*\*\//g, "https_eslint-disable_no-useless-escape")
|
|
53
|
+
.replace(/<!--\s*eslint-disable-next-line\s*-->/g, "https_eslint-disable-next-line")
|
|
54
|
+
.replace(/http:\/\//g, "http_bimo")
|
|
55
|
+
.replace(/https:\/\//g, "https_bimo")
|
|
56
|
+
.replace(reg1, '')
|
|
57
|
+
.replace(reg2, '')
|
|
58
|
+
.replace(reg3, '')
|
|
59
|
+
.replace(/http_bimo/g, "http://")
|
|
60
|
+
.replace(/https_bimo/g, "https://")
|
|
61
|
+
.replace(/https_eslint-disable_no-useless-escape/g, "/* eslint-disable no-useless-escape */")
|
|
62
|
+
.replace(/https_eslint-disable-next-line/g, "<!-- eslint-disable-next-line -->")
|
|
63
|
+
|
|
64
|
+
fs.writeFile(filePath, newData, 'utf8', (err) => {
|
|
65
|
+
if (err) {
|
|
66
|
+
console.error('can not write file:', err);
|
|
67
|
+
return;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
console.log(`done: ${filePath}`);
|
|
71
|
+
});
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
function main() {
|
|
76
|
+
const directory = "./";
|
|
77
|
+
if (!directory) {
|
|
78
|
+
console.error('pls set dir');
|
|
79
|
+
return;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
readDirectory(directory);
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
main();
|
|
File without changes
|
package/utils/checkVersion.js
CHANGED
|
@@ -1,105 +1,94 @@
|
|
|
1
|
-
|
|
2
|
-
const config = require("../package.json")
|
|
3
|
-
const inquirer = require("inquirer")
|
|
4
|
-
const exec = require('child_process').execSync;
|
|
5
|
-
const chalk = require("chalk")
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
let
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
* *
|
|
31
|
-
*
|
|
32
|
-
*
|
|
33
|
-
*
|
|
34
|
-
*
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
let
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
update(onlineVersion)
|
|
96
|
-
return true;
|
|
97
|
-
} else {
|
|
98
|
-
return false
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
return false
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
module.exports = { checkUpdate }
|
|
1
|
+
|
|
2
|
+
const config = require("../package.json")
|
|
3
|
+
const inquirer = require("inquirer")
|
|
4
|
+
const exec = require('child_process').execSync;
|
|
5
|
+
const chalk = require("chalk")
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
function checkNpmVersion() {
|
|
9
|
+
let currentVersion = Number(config.version.replace(/\./g, ""));
|
|
10
|
+
let onlineVersionNum
|
|
11
|
+
let onlineVersion = '0.0.1'
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
onlineVersion = exec(`npm view cloudcc-cli version --registry http://registry.npmmirror.com`)
|
|
15
|
+
onlineVersion = onlineVersion.toString("utf8").trim();
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
onlineVersionNum = Number(onlineVersion.replace(/\./g, ""));
|
|
24
|
+
|
|
25
|
+
console.log(chalk.green(
|
|
26
|
+
`
|
|
27
|
+
********************************************************************************
|
|
28
|
+
* *
|
|
29
|
+
* CloudCC CLI *
|
|
30
|
+
* *
|
|
31
|
+
* Current Version:V${config.version} *
|
|
32
|
+
* Latest Version:V${onlineVersion} *
|
|
33
|
+
* *
|
|
34
|
+
* *
|
|
35
|
+
********************************************************************************
|
|
36
|
+
`
|
|
37
|
+
))
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
if (onlineVersionNum - currentVersion > 0) {
|
|
41
|
+
return onlineVersion;
|
|
42
|
+
}
|
|
43
|
+
return null;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
function askUpdate() {
|
|
48
|
+
console.log();
|
|
49
|
+
const prompt = [{
|
|
50
|
+
type: 'list',
|
|
51
|
+
message: 'Do you want to perform automatic upgrade?',
|
|
52
|
+
name: 'update',
|
|
53
|
+
choices: [
|
|
54
|
+
"Yes", 'No'
|
|
55
|
+
],
|
|
56
|
+
}];
|
|
57
|
+
return inquirer.prompt(prompt)
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
function update(onlineVersion) {
|
|
62
|
+
console.log()
|
|
63
|
+
console.log(chalk.green("Upgrading, estimated to be completed in 3 minutes, please wait..."));
|
|
64
|
+
console.log()
|
|
65
|
+
let os = process.platform
|
|
66
|
+
console.log(chalk.yellow(`If it fails to update automatically, please use the command to update:${'darwin' == os ? 'sudo' : ''} npm install -g cloudcc-cli@${onlineVersion} --registry http://registry.npmmirror.com`));
|
|
67
|
+
exec(`${'darwin' == os ? 'sudo' : ''} npm install -g cloudcc-cli@${onlineVersion} --registry http://registry.npmmirror.com`)
|
|
68
|
+
console.log()
|
|
69
|
+
console.log(chalk.green("Upgrade completed! Please re-run"));
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
async function checkUpdate() {
|
|
74
|
+
let onlineVersion;
|
|
75
|
+
try {
|
|
76
|
+
onlineVersion = checkNpmVersion();
|
|
77
|
+
} catch (error) {
|
|
78
|
+
console.log("error", error)
|
|
79
|
+
onlineVersion = false;
|
|
80
|
+
}
|
|
81
|
+
if (onlineVersion) {
|
|
82
|
+
let res = await askUpdate()
|
|
83
|
+
if ("Yes" == res.update) {
|
|
84
|
+
update(onlineVersion)
|
|
85
|
+
return true;
|
|
86
|
+
} else {
|
|
87
|
+
return false
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
return false
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
|
|
94
|
+
module.exports = { checkUpdate }
|