cloudcc-cli 1.6.5 → 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 +8 -0
- package/bin/cc.js +15 -15
- 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 +1 -1
- package/src/classes/create.js +5 -8
- package/src/classes/publish.js +8 -12
- package/src/config/get.js +1 -3
- package/src/config/use.js +1 -3
- package/src/object/get.js +4 -6
- package/src/plugin/create.js +10 -20
- package/src/plugin/create1.js +8 -16
- package/src/plugin/publish.js +44 -77
- package/src/plugin/publish1.js +42 -72
- package/src/project/create.js +12 -14
- package/src/project/create1.js +15 -17
- package/src/recordType/get.js +3 -6
- package/src/script/create.js +3 -6
- package/src/script/publish.js +10 -17
- package/src/timer/create.js +3 -6
- package/src/timer/publish.js +8 -12
- package/src/token/get.js +1 -3
- package/src/triggers/create.js +8 -16
- package/src/triggers/index.js +1 -1
- package/src/triggers/publish.js +10 -13
- package/template/index.js +10 -10
- package/template/indexvue +3 -3
- 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 +19 -30
- package/utils/http.js +5 -5
- package/utils/utils.js +19 -21
package/src/recordType/get.js
CHANGED
|
@@ -1,13 +1,10 @@
|
|
|
1
1
|
const { getBusToken } = require("../../utils/utils")
|
|
2
2
|
const { postNormal } = require("../../utils/http")
|
|
3
|
-
|
|
4
|
-
* 获取对象的记录类型
|
|
5
|
-
*/
|
|
3
|
+
|
|
6
4
|
async function get(path, prefix) {
|
|
7
|
-
|
|
5
|
+
|
|
8
6
|
if (await getBusToken(path)) {
|
|
9
|
-
let
|
|
10
|
-
let res = await postNormal(url + "/apisvc/api/batch/getRecordType", { prefix: prefix })
|
|
7
|
+
let res = await postNormal(global.apiSvc + "/api/batch/getRecordType", { prefix: prefix })
|
|
11
8
|
console.log(JSON.stringify(res.data.recordTypeList))
|
|
12
9
|
return res.data
|
|
13
10
|
}
|
package/src/script/create.js
CHANGED
|
@@ -2,10 +2,7 @@ const { checkUpdate } = require("../../utils/checkVersion")
|
|
|
2
2
|
const fs = require("fs");
|
|
3
3
|
const path = require("path")
|
|
4
4
|
const chalk = require("chalk")
|
|
5
|
-
|
|
6
|
-
* 创建文件
|
|
7
|
-
* @param {string} name 文件名称
|
|
8
|
-
*/
|
|
5
|
+
|
|
9
6
|
async function create(argvs) {
|
|
10
7
|
let res = await checkUpdate();
|
|
11
8
|
if (!res) {
|
|
@@ -20,11 +17,11 @@ async function create(argvs) {
|
|
|
20
17
|
fs.writeFileSync(path.join(filePath, body.scriptName + ".js"), fileTmp)
|
|
21
18
|
fs.writeFileSync(path.join(filePath, "config.json"), JSON.stringify(body))
|
|
22
19
|
console.log()
|
|
23
|
-
console.log(chalk.green("
|
|
20
|
+
console.log(chalk.green("Successfully Created:" + body.scriptName))
|
|
24
21
|
console.log()
|
|
25
22
|
} catch (e) {
|
|
26
23
|
console.log()
|
|
27
|
-
console.log(chalk.red("
|
|
24
|
+
console.log(chalk.red("Creation Failed:" + e))
|
|
28
25
|
console.log()
|
|
29
26
|
}
|
|
30
27
|
}
|
package/src/script/publish.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
|
|
2
2
|
const { checkUpdate } = require("../../utils/checkVersion")
|
|
3
3
|
const fs = require("fs");
|
|
4
4
|
const path = require("path")
|
|
@@ -6,10 +6,7 @@ const chalk = require("chalk")
|
|
|
6
6
|
const { post } = require("../../utils/http")
|
|
7
7
|
const { getPackageJson } = require("../../utils/utils")
|
|
8
8
|
const BaseUrl = "https://developer.apis.cloudcc.cn"
|
|
9
|
-
|
|
10
|
-
* 发布脚本
|
|
11
|
-
* @param {string} argvs 参数
|
|
12
|
-
*/
|
|
9
|
+
|
|
13
10
|
async function publish(argvs) {
|
|
14
11
|
let name = argvs[2]
|
|
15
12
|
let res = await checkUpdate();
|
|
@@ -21,47 +18,43 @@ async function publish(argvs) {
|
|
|
21
18
|
|
|
22
19
|
if (classContent) {
|
|
23
20
|
let devConsoleConfig = getPackageJson()
|
|
24
|
-
|
|
21
|
+
|
|
25
22
|
if ("private" != devConsoleConfig.version) {
|
|
26
23
|
devConsoleConfig = { "accessToken": await getToken(devConsoleConfig) };
|
|
27
24
|
}
|
|
28
|
-
console.log(chalk.green('
|
|
25
|
+
console.log(chalk.green('Posting, please wait...'));
|
|
29
26
|
configContent.scriptContent = classContent
|
|
30
27
|
let res = await post((devConsoleConfig.baseUrl || BaseUrl) + "/devconsole/script/saveClientScript", configContent, devConsoleConfig)
|
|
31
28
|
if (res.result) {
|
|
32
29
|
console.log();
|
|
33
|
-
console.log(chalk.green('
|
|
30
|
+
console.log(chalk.green('Success!'));
|
|
34
31
|
console.log();
|
|
35
|
-
|
|
32
|
+
|
|
36
33
|
if (!configContentOld.id) {
|
|
37
34
|
configContentOld.id = res.data
|
|
38
35
|
fs.writeFileSync(path.join(srcPath, "config.json"), JSON.stringify(configContentOld))
|
|
39
36
|
}
|
|
40
37
|
} else {
|
|
41
38
|
console.log();
|
|
42
|
-
console.log(chalk.red('
|
|
39
|
+
console.log(chalk.red('Fail:' + res.returnInfo));
|
|
43
40
|
console.log();
|
|
44
41
|
}
|
|
45
42
|
} else {
|
|
46
43
|
console.log();
|
|
47
|
-
console.log(chalk.red('
|
|
44
|
+
console.log(chalk.red('Invalid Script Content'));
|
|
48
45
|
console.log();
|
|
49
46
|
}
|
|
50
47
|
}
|
|
51
48
|
}
|
|
52
49
|
|
|
53
50
|
|
|
54
|
-
|
|
55
|
-
* 请求用户token
|
|
56
|
-
* @param {用户信息} devConsoleConfig
|
|
57
|
-
* @returns token
|
|
58
|
-
*/
|
|
51
|
+
|
|
59
52
|
async function getToken(devConsoleConfig) {
|
|
60
53
|
let res = await post(devConsoleConfig.baseUrl || BaseUrl + "/sysconfig/auth/pc/1.0/post/tokenInfo", devConsoleConfig);
|
|
61
54
|
if (res.returnCode == 200) {
|
|
62
55
|
return res.data.accessToken;
|
|
63
56
|
} else {
|
|
64
|
-
console.error(chalk.red(
|
|
57
|
+
console.error(chalk.red(`Login failed`, JSON.stringify(res)));
|
|
65
58
|
return null;
|
|
66
59
|
}
|
|
67
60
|
}
|
package/src/timer/create.js
CHANGED
|
@@ -2,10 +2,7 @@ const { checkUpdate } = require("../../utils/checkVersion")
|
|
|
2
2
|
const fs = require("fs");
|
|
3
3
|
const path = require("path")
|
|
4
4
|
const chalk = require("chalk")
|
|
5
|
-
|
|
6
|
-
* 创建文件
|
|
7
|
-
* @param {string} name 文件名称
|
|
8
|
-
*/
|
|
5
|
+
|
|
9
6
|
async function create(name) {
|
|
10
7
|
let res = await checkUpdate();
|
|
11
8
|
if (!res) {
|
|
@@ -16,11 +13,11 @@ async function create(name) {
|
|
|
16
13
|
fs.writeFileSync(path.join(timerPath, name + ".java"), javaTmp)
|
|
17
14
|
fs.writeFileSync(path.join(timerPath, "config.json"), `{"name":"${name}","version":"3"}`)
|
|
18
15
|
console.log()
|
|
19
|
-
console.log(chalk.green("
|
|
16
|
+
console.log(chalk.green("Successfully Created:" + name))
|
|
20
17
|
console.log()
|
|
21
18
|
} catch (e) {
|
|
22
19
|
console.log()
|
|
23
|
-
console.log(chalk.red("
|
|
20
|
+
console.log(chalk.red("Creation Failed:" + e))
|
|
24
21
|
console.log()
|
|
25
22
|
}
|
|
26
23
|
}
|
package/src/timer/publish.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
|
|
2
2
|
const { checkUpdate } = require("../../utils/checkVersion")
|
|
3
3
|
const fs = require("fs");
|
|
4
4
|
const path = require("path")
|
|
@@ -6,20 +6,17 @@ const chalk = require("chalk")
|
|
|
6
6
|
const { postNormal } = require("../../utils/http")
|
|
7
7
|
|
|
8
8
|
const { getBusToken } = require("../../utils/utils")
|
|
9
|
-
|
|
10
|
-
* 发布文件
|
|
11
|
-
* @param {string} name 文件名称
|
|
12
|
-
*/
|
|
9
|
+
|
|
13
10
|
async function publish(name) {
|
|
14
11
|
let res = await checkUpdate();
|
|
15
12
|
if (!res) {
|
|
16
13
|
console.log();
|
|
17
|
-
console.log(chalk.green('
|
|
14
|
+
console.log(chalk.green('Posting, please wait...'));
|
|
18
15
|
console.log();
|
|
19
16
|
const timerPath = path.join(process.cwd(), `timer/${name}/`);
|
|
20
17
|
let classContent = fs.readFileSync(timerPath + `${name}.java`, 'utf8');
|
|
21
18
|
let configContent = JSON.parse(fs.readFileSync(timerPath + "config.json", 'utf8'));
|
|
22
|
-
|
|
19
|
+
|
|
23
20
|
if (await getBusToken()) {
|
|
24
21
|
let body = {
|
|
25
22
|
"id": configContent.id,
|
|
@@ -28,18 +25,17 @@ async function publish(name) {
|
|
|
28
25
|
"source": encodeURI(classContent),
|
|
29
26
|
"folderId": "wgd"
|
|
30
27
|
}
|
|
31
|
-
let
|
|
32
|
-
let res = await postNormal(url + "/setup/api/ccPeak/save", body)
|
|
28
|
+
let res = await postNormal(global.setupSvc + "/api/ccPeak/save", body)
|
|
33
29
|
if (res.result) {
|
|
34
|
-
console.log(chalk.green('
|
|
30
|
+
console.log(chalk.green('Success!'));
|
|
35
31
|
console.log();
|
|
36
|
-
|
|
32
|
+
|
|
37
33
|
if (!configContent.id) {
|
|
38
34
|
configContent.id = res.data
|
|
39
35
|
fs.writeFileSync(path.join(timerPath, "config.json"), JSON.stringify(configContent))
|
|
40
36
|
}
|
|
41
37
|
} else {
|
|
42
|
-
console.log(chalk.red('
|
|
38
|
+
console.log(chalk.red('Fail:' + res.returnInfo));
|
|
43
39
|
}
|
|
44
40
|
}
|
|
45
41
|
}
|
package/src/token/get.js
CHANGED
package/src/triggers/create.js
CHANGED
|
@@ -2,31 +2,23 @@ const { checkUpdate } = require("../../utils/checkVersion")
|
|
|
2
2
|
const fs = require("fs");
|
|
3
3
|
const path = require("path")
|
|
4
4
|
const chalk = require("chalk")
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
* @param {string} name 文件名称
|
|
8
|
-
*/
|
|
9
|
-
async function create(name) {
|
|
5
|
+
|
|
6
|
+
async function create(argvs) {
|
|
10
7
|
let res = await checkUpdate();
|
|
11
8
|
if (!res) {
|
|
12
|
-
|
|
9
|
+
let body = JSON.parse(decodeURI(argvs[2]))
|
|
10
|
+
const triggersPath = path.join(process.cwd(), "triggers/" + body.name);
|
|
13
11
|
try {
|
|
14
12
|
fs.mkdirSync(triggersPath, { recursive: true })
|
|
15
13
|
const javaTmp = `System.out.print("hello CloudCC");`
|
|
16
|
-
fs.writeFileSync(path.join(triggersPath, name + ".java"), javaTmp)
|
|
17
|
-
fs.writeFileSync(path.join(triggersPath, "config.json"),
|
|
18
|
-
`{
|
|
19
|
-
"isactive":false,
|
|
20
|
-
"targetObjectId":"account",
|
|
21
|
-
"triggerTime":"beforeInsert",
|
|
22
|
-
"version":"3"
|
|
23
|
-
}`)
|
|
14
|
+
fs.writeFileSync(path.join(triggersPath, body.name + ".java"), javaTmp)
|
|
15
|
+
fs.writeFileSync(path.join(triggersPath, "config.json"), JSON.stringify(body))
|
|
24
16
|
console.log()
|
|
25
|
-
console.log(chalk.green("
|
|
17
|
+
console.log(chalk.green("Successfully Created:" + body.name))
|
|
26
18
|
console.log()
|
|
27
19
|
} catch (e) {
|
|
28
20
|
console.log()
|
|
29
|
-
console.log(chalk.red("
|
|
21
|
+
console.log(chalk.red("Creation Failed:" + e))
|
|
30
22
|
console.log()
|
|
31
23
|
}
|
|
32
24
|
}
|
package/src/triggers/index.js
CHANGED
package/src/triggers/publish.js
CHANGED
|
@@ -1,24 +1,22 @@
|
|
|
1
|
-
|
|
1
|
+
|
|
2
2
|
const { checkUpdate } = require("../../utils/checkVersion")
|
|
3
3
|
const fs = require("fs");
|
|
4
4
|
const path = require("path")
|
|
5
5
|
const chalk = require("chalk")
|
|
6
6
|
const { postNormal } = require("../../utils/http")
|
|
7
7
|
const { getBusToken } = require("../../utils/utils")
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
*/
|
|
12
|
-
async function publish(name) {
|
|
8
|
+
|
|
9
|
+
async function publish(argvs) {
|
|
10
|
+
let name = argvs[2]
|
|
13
11
|
let res = await checkUpdate();
|
|
14
12
|
if (!res) {
|
|
15
13
|
console.log();
|
|
16
|
-
console.log(chalk.green('
|
|
14
|
+
console.log(chalk.green('Posting, please wait...'));
|
|
17
15
|
console.log();
|
|
18
16
|
const triggersPath = path.join(process.cwd(), `triggers/${name}/`);
|
|
19
17
|
let classContent = fs.readFileSync(triggersPath + `${name}.java`, 'utf8');
|
|
20
18
|
let configContent = JSON.parse(fs.readFileSync(triggersPath + "config.json", 'utf8'));
|
|
21
|
-
|
|
19
|
+
|
|
22
20
|
if (await getBusToken()) {
|
|
23
21
|
let body = {
|
|
24
22
|
"id": configContent.id,
|
|
@@ -31,19 +29,18 @@ async function publish(name) {
|
|
|
31
29
|
"triggerSource": encodeURI(classContent),
|
|
32
30
|
"folderId": "wgd"
|
|
33
31
|
}
|
|
34
|
-
let
|
|
35
|
-
let res = await postNormal(url + "/setup/api/triggerSetup/saveTrigger", body)
|
|
32
|
+
let res = await postNormal(global.setupSvc + "/api/triggerSetup/saveTrigger", body)
|
|
36
33
|
if (res.result) {
|
|
37
|
-
console.log(chalk.green('
|
|
34
|
+
console.log(chalk.green('Success!'));
|
|
38
35
|
console.log();
|
|
39
|
-
|
|
36
|
+
|
|
40
37
|
if (!configContent.id) {
|
|
41
38
|
configContent.id = res.data.id
|
|
42
39
|
configContent.apiname = res.data.apiname
|
|
43
40
|
fs.writeFileSync(path.join(triggersPath, "config.json"), JSON.stringify(configContent))
|
|
44
41
|
}
|
|
45
42
|
} else {
|
|
46
|
-
console.log(chalk.red('
|
|
43
|
+
console.log(chalk.red('Fail:' + res.returnInfo));
|
|
47
44
|
}
|
|
48
45
|
}
|
|
49
46
|
}
|
package/template/index.js
CHANGED
|
@@ -40,19 +40,19 @@ module.exports = function (creator, options, callback) {
|
|
|
40
40
|
|
|
41
41
|
creator.fs.commit(() => {
|
|
42
42
|
console.log();
|
|
43
|
-
console.log(`${chalk.grey(
|
|
43
|
+
console.log(`${chalk.grey(`Create project: ${name}`)} ${chalk.green('✔ ')}`);
|
|
44
44
|
|
|
45
|
-
console.log(`${chalk.grey(
|
|
46
|
-
console.log(`${chalk.grey(
|
|
45
|
+
console.log(`${chalk.grey(`Create directory: ${name}/public`)} ${chalk.green('✔ ')}`);
|
|
46
|
+
console.log(`${chalk.grey(`Create file: ${name}/public/index.html`)} ${chalk.green('✔ ')}`);
|
|
47
47
|
|
|
48
|
-
console.log(`${chalk.grey(
|
|
49
|
-
console.log(`${chalk.grey(
|
|
50
|
-
console.log(`${chalk.grey(
|
|
48
|
+
console.log(`${chalk.grey(`Create file: ${name}/src`)} ${chalk.green('✔ ')}`);
|
|
49
|
+
console.log(`${chalk.grey(`Create file: ${name}/src/App.vue`)} ${chalk.green('✔ ')}`);
|
|
50
|
+
console.log(`${chalk.grey(`Create file: ${name}/src/main.js`)} ${chalk.green('✔ ')}`);
|
|
51
51
|
|
|
52
|
-
console.log(`${chalk.grey(
|
|
53
|
-
console.log(`${chalk.grey(
|
|
54
|
-
console.log(`${chalk.grey(
|
|
55
|
-
console.log(`${chalk.grey(
|
|
52
|
+
console.log(`${chalk.grey(`Create file: ${name}/babel.config.js`)} ${chalk.green('✔ ')}`);
|
|
53
|
+
console.log(`${chalk.grey(`Create file: ${name}/package.json`)} ${chalk.green('✔ ')}`);
|
|
54
|
+
console.log(`${chalk.grey(`Create file: ${name}/vue.config.js`)} ${chalk.green('✔ ')}`);
|
|
55
|
+
console.log(`${chalk.grey(`Create file: ${name}/cloudcc-cli.config.js`)} ${chalk.green('✔ ')}`);
|
|
56
56
|
callback();
|
|
57
57
|
});
|
|
58
58
|
}
|
package/template/indexvue
CHANGED
|
@@ -14,12 +14,12 @@ export default {
|
|
|
14
14
|
data() {
|
|
15
15
|
return {
|
|
16
16
|
componentInfo: {
|
|
17
|
-
//
|
|
17
|
+
// Component unique identifier, globally unique
|
|
18
18
|
component: "cloudcc-demo-01",
|
|
19
19
|
// 组件名称,在页面编辑器显示的名字
|
|
20
20
|
compName: "cloudcc-demo-01",
|
|
21
|
-
//
|
|
22
|
-
compDesc: "
|
|
21
|
+
// Component description information
|
|
22
|
+
compDesc: "Component description information",
|
|
23
23
|
},
|
|
24
24
|
isLock: false,
|
|
25
25
|
};
|
|
@@ -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,27 +1,25 @@
|
|
|
1
|
-
|
|
1
|
+
|
|
2
2
|
const config = require("../package.json")
|
|
3
3
|
const inquirer = require("inquirer")
|
|
4
4
|
const exec = require('child_process').execSync;
|
|
5
5
|
const chalk = require("chalk")
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
* 检查cli版本号
|
|
9
|
-
*/
|
|
7
|
+
|
|
10
8
|
function checkNpmVersion() {
|
|
11
9
|
let currentVersion = Number(config.version.replace(/\./g, ""));
|
|
12
10
|
let onlineVersionNum
|
|
13
11
|
let onlineVersion = '0.0.1'
|
|
14
12
|
|
|
15
|
-
|
|
13
|
+
|
|
16
14
|
onlineVersion = exec(`npm view cloudcc-cli version --registry http://registry.npmmirror.com`)
|
|
17
15
|
onlineVersion = onlineVersion.toString("utf8").trim();
|
|
18
16
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
|
|
25
23
|
onlineVersionNum = Number(onlineVersion.replace(/\./g, ""));
|
|
26
24
|
|
|
27
25
|
console.log(chalk.green(
|
|
@@ -30,32 +28,27 @@ function checkNpmVersion() {
|
|
|
30
28
|
* *
|
|
31
29
|
* CloudCC CLI *
|
|
32
30
|
* *
|
|
33
|
-
*
|
|
34
|
-
*
|
|
35
|
-
* 更新内容:https://npmmirror.com/package/cloudcc-cli/home *
|
|
31
|
+
* Current Version:V${config.version} *
|
|
32
|
+
* Latest Version:V${onlineVersion} *
|
|
36
33
|
* *
|
|
37
|
-
* 开发者文档:https://cloudccone.feishu.cn/wiki/JZ7CwcRfriU8taknCKCcwKEmncd *
|
|
38
34
|
* *
|
|
39
35
|
********************************************************************************
|
|
40
36
|
`
|
|
41
37
|
))
|
|
42
38
|
|
|
43
|
-
|
|
39
|
+
|
|
44
40
|
if (onlineVersionNum - currentVersion > 0) {
|
|
45
41
|
return onlineVersion;
|
|
46
42
|
}
|
|
47
43
|
return null;
|
|
48
44
|
}
|
|
49
45
|
|
|
50
|
-
|
|
51
|
-
* 是否升级
|
|
52
|
-
* @returns 对象
|
|
53
|
-
*/
|
|
46
|
+
|
|
54
47
|
function askUpdate() {
|
|
55
48
|
console.log();
|
|
56
49
|
const prompt = [{
|
|
57
50
|
type: 'list',
|
|
58
|
-
message: '
|
|
51
|
+
message: 'Do you want to perform automatic upgrade?',
|
|
59
52
|
name: 'update',
|
|
60
53
|
choices: [
|
|
61
54
|
"Yes", 'No'
|
|
@@ -64,23 +57,19 @@ function askUpdate() {
|
|
|
64
57
|
return inquirer.prompt(prompt)
|
|
65
58
|
}
|
|
66
59
|
|
|
67
|
-
|
|
68
|
-
* 升级cli
|
|
69
|
-
*/
|
|
60
|
+
|
|
70
61
|
function update(onlineVersion) {
|
|
71
62
|
console.log()
|
|
72
|
-
console.log(chalk.green("
|
|
63
|
+
console.log(chalk.green("Upgrading, estimated to be completed in 3 minutes, please wait..."));
|
|
73
64
|
console.log()
|
|
74
65
|
let os = process.platform
|
|
75
|
-
console.log(chalk.yellow(
|
|
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`));
|
|
76
67
|
exec(`${'darwin' == os ? 'sudo' : ''} npm install -g cloudcc-cli@${onlineVersion} --registry http://registry.npmmirror.com`)
|
|
77
68
|
console.log()
|
|
78
|
-
console.log(chalk.green("
|
|
69
|
+
console.log(chalk.green("Upgrade completed! Please re-run"));
|
|
79
70
|
}
|
|
80
71
|
|
|
81
|
-
|
|
82
|
-
* 检查更新
|
|
83
|
-
*/
|
|
72
|
+
|
|
84
73
|
async function checkUpdate() {
|
|
85
74
|
let onlineVersion;
|
|
86
75
|
try {
|