cloudcc-cli 1.7.2 → 1.7.4

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.
Files changed (55) hide show
  1. package/README.md +1219 -1204
  2. package/bin/cc.js +49 -49
  3. package/bin/plugin.js +6 -6
  4. package/bin/project.js +6 -6
  5. package/core/core/ServiceResult.java +35 -35
  6. package/core/core/UserInfo.java +45 -45
  7. package/package.json +34 -34
  8. package/src/classes/create.js +40 -40
  9. package/src/classes/index.js +8 -8
  10. package/src/classes/publish.js +43 -43
  11. package/src/config/get.js +20 -20
  12. package/src/config/index.js +8 -8
  13. package/src/config/use.js +14 -14
  14. package/src/object/get.js +14 -14
  15. package/src/object/index.js +7 -7
  16. package/src/plugin/create.js +70 -70
  17. package/src/plugin/create1.js +58 -58
  18. package/src/plugin/index.js +8 -8
  19. package/src/plugin/publish.js +262 -262
  20. package/src/plugin/publish1.js +256 -256
  21. package/src/project/create.js +87 -87
  22. package/src/project/create1.js +109 -109
  23. package/src/project/index.js +7 -7
  24. package/src/recordType/get.js +13 -13
  25. package/src/recordType/index.js +7 -7
  26. package/src/script/create.js +29 -29
  27. package/src/script/index.js +8 -8
  28. package/src/script/publish.js +62 -62
  29. package/src/timer/create.js +26 -26
  30. package/src/timer/index.js +8 -8
  31. package/src/timer/publish.js +43 -43
  32. package/src/token/get.js +11 -11
  33. package/src/token/index.js +7 -7
  34. package/src/triggers/create.js +27 -27
  35. package/src/triggers/index.js +8 -8
  36. package/src/triggers/publish.js +48 -48
  37. package/template/Appvue +24 -24
  38. package/template/babelconfigjs +5 -5
  39. package/template/demojava +14 -14
  40. package/template/gitignore +11 -11
  41. package/template/index.js +57 -57
  42. package/template/indexhtml +21 -21
  43. package/template/indexvue +29 -29
  44. package/template/javaconfigjson +2 -2
  45. package/template/mainjs +13 -13
  46. package/template/package-lockjson +13952 -13952
  47. package/template/packagejson +42 -42
  48. package/template/vueconfigjs +21 -21
  49. package/tool/branch/index.js +25 -25
  50. package/tool/checkLange/checkLang.js +68 -68
  51. package/tool/checkLange/clearLang.js +85 -85
  52. package/utils/checkVersion.js +90 -94
  53. package/utils/config.js +18 -0
  54. package/utils/http.js +123 -123
  55. package/utils/utils.js +40 -58
@@ -1,88 +1,88 @@
1
- const chalk = require("chalk")
2
- const inquirer = require("inquirer")
3
- const memFs = require("mem-fs")
4
- const memFsEditor = require("mem-fs-editor")
5
- const fs = require("fs")
6
- const path = require("path")
7
- const { checkUpdate } = require("../../utils/checkVersion")
8
-
9
- class Creator {
10
- constructor() {
11
- this.fs = memFsEditor.create(memFs.create());
12
- this.options = {
13
- name: "",
14
- description: ""
15
- }
16
-
17
- this.rootPath = path.resolve(__dirname, "../../");
18
-
19
- this.tplDirPath = path.join(this.rootPath, "template");
20
- }
21
-
22
- async init(name) {
23
- let res = await checkUpdate();
24
- if (!res) {
25
- console.log()
26
- console.log(chalk.green('Welcome CloudCC-CLI'));
27
- console.log()
28
- if (!name) {
29
- this.ask().then(answers => {
30
- this.options = Object.assign({}, this.options, answers);
31
- console.log(this.options);
32
- this.write();
33
- })
34
- } else {
35
- this.options = { name }
36
- this.write();
37
- }
38
- }
39
- }
40
-
41
- ask() {
42
- const prompt = [];
43
-
44
- prompt.push({
45
- type: "input",
46
- name: "name",
47
- message: "Please enter the project name",
48
- validate(input) {
49
- if (!input) {
50
- return "Please enter the project name"
51
- }
52
-
53
- if (fs.existsSync(input)) {
54
- return "Project name already exists"
55
- }
56
-
57
- return true;
58
- }
59
- });
60
- return inquirer.prompt(prompt)
61
- }
62
-
63
- write() {
64
- console.log();
65
- console.log(chalk.green("Starting construction, please wait"));
66
- const tplBuilder = require("../../template/index");
67
- tplBuilder(this, this.options, () => {
68
- console.log();
69
- console.log(chalk.green('Build completed, please install dependencies before running'))
70
- console.log();
71
- })
72
- }
73
-
74
- getTplPath(file) {
75
- return path.join(this.tplDirPath, file);
76
- }
77
-
78
- copyTpl(file, to, data = {}) {
79
- const tplPath = this.getTplPath(file);
80
- this.fs.copyTpl(tplPath, to, data);
81
- }
82
-
83
- copy(file, to) {
84
- const tplPath = this.getTplPath(file);
85
- this.fs.copy(tplPath, to)
86
- }
87
- }
1
+ const chalk = require("chalk")
2
+ const inquirer = require("inquirer")
3
+ const memFs = require("mem-fs")
4
+ const memFsEditor = require("mem-fs-editor")
5
+ const fs = require("fs")
6
+ const path = require("path")
7
+ const { checkUpdate } = require("../../utils/checkVersion")
8
+
9
+ class Creator {
10
+ constructor() {
11
+ this.fs = memFsEditor.create(memFs.create());
12
+ this.options = {
13
+ name: "",
14
+ description: ""
15
+ }
16
+
17
+ this.rootPath = path.resolve(__dirname, "../../");
18
+
19
+ this.tplDirPath = path.join(this.rootPath, "template");
20
+ }
21
+
22
+ async init(name) {
23
+ let res = await checkUpdate();
24
+ if (!res) {
25
+ console.log()
26
+ console.log(chalk.green('Welcome CloudCC-CLI'));
27
+ console.log()
28
+ if (!name) {
29
+ this.ask().then(answers => {
30
+ this.options = Object.assign({}, this.options, answers);
31
+ console.log(this.options);
32
+ this.write();
33
+ })
34
+ } else {
35
+ this.options = { name }
36
+ this.write();
37
+ }
38
+ }
39
+ }
40
+
41
+ ask() {
42
+ const prompt = [];
43
+
44
+ prompt.push({
45
+ type: "input",
46
+ name: "name",
47
+ message: "Please enter the project name",
48
+ validate(input) {
49
+ if (!input) {
50
+ return "Please enter the project name"
51
+ }
52
+
53
+ if (fs.existsSync(input)) {
54
+ return "Project name already exists"
55
+ }
56
+
57
+ return true;
58
+ }
59
+ });
60
+ return inquirer.prompt(prompt)
61
+ }
62
+
63
+ write() {
64
+ console.log();
65
+ console.log(chalk.green("Starting construction, please wait"));
66
+ const tplBuilder = require("../../template/index");
67
+ tplBuilder(this, this.options, () => {
68
+ console.log();
69
+ console.log(chalk.green('Build completed, please install dependencies before running'))
70
+ console.log();
71
+ })
72
+ }
73
+
74
+ getTplPath(file) {
75
+ return path.join(this.tplDirPath, file);
76
+ }
77
+
78
+ copyTpl(file, to, data = {}) {
79
+ const tplPath = this.getTplPath(file);
80
+ this.fs.copyTpl(tplPath, to, data);
81
+ }
82
+
83
+ copy(file, to) {
84
+ const tplPath = this.getTplPath(file);
85
+ this.fs.copy(tplPath, to)
86
+ }
87
+ }
88
88
  module.exports = Creator;
@@ -1,110 +1,110 @@
1
- const chalk = require("chalk")
2
- const inquirer = require("inquirer")
3
- const memFs = require("mem-fs")
4
- const memFsEditor = require("mem-fs-editor")
5
- const fs = require("fs")
6
- const path = require("path")
7
- const { checkUpdate } = require("../../utils/checkVersion")
8
- const tplBuilder = require("../../template/index");
9
- const execSync = require('child_process').execSync;
10
-
11
- class Creator {
12
- constructor() {
13
- this.fs = memFsEditor.create(memFs.create());
14
- this.options = {
15
- name: "",
16
- description: ""
17
- }
18
-
19
- this.rootPath = path.resolve(__dirname, "../../");
20
-
21
- this.tplDirPath = path.join(this.rootPath, "template");
22
- }
23
-
24
- async init(name) {
25
- let res = await checkUpdate();
26
- if (!res) {
27
- console.log()
28
- console.log(chalk.green('Welcome CloudCC-CLI'));
29
- console.log()
30
- if (!name) {
31
- this.ask().then(answers => {
32
- this.options = Object.assign({}, this.options, answers);
33
- console.log(this.options);
34
- this.write();
35
- })
36
- } else {
37
- this.options = { name }
38
- this.write();
39
- }
40
- }
41
- }
42
-
43
- ask() {
44
- const prompt = [];
45
-
46
- prompt.push({
47
- type: "input",
48
- name: "name",
49
- message: "Please enter the project name",
50
- validate(input) {
51
- if (!input) {
52
- return "Please enter the project name"
53
- }
54
-
55
- if (fs.existsSync(input)) {
56
- return "Project name already exists"
57
- }
58
-
59
- return true;
60
- }
61
- });
62
- return inquirer.prompt(prompt)
63
- }
64
-
65
- write() {
66
- console.log();
67
- console.log(chalk.green("Starting construction, please wait"));
68
- tplBuilder(this, this.options, () => {
69
- console.log();
70
- this.initGit(path.join(process.cwd(), this.options.name))
71
- console.log(chalk.green('Build completed, please install dependencies before running'))
72
- console.log();
73
- })
74
- }
75
-
76
- getTplPath(file) {
77
- return path.join(this.tplDirPath, file);
78
- }
79
-
80
- copyTpl(file, to, data = {}) {
81
- const tplPath = this.getTplPath(file);
82
- this.fs.copyTpl(tplPath, to, data);
83
- }
84
-
85
- copy(file, to) {
86
- const tplPath = this.getTplPath(file);
87
- this.fs.copy(tplPath, to)
88
- }
89
-
90
- initGit(path) {
91
- try {
92
- execSync(`git -C ${path} init`)
93
- execSync(`git -C ${path} add .`)
94
- execSync(`git -C ${path} commit -m 'init'`)
95
- console.log(`${chalk.grey(`Git repository initialization completed`)} ${chalk.green('✔ ')}`);
96
- console.log();
97
- console.log(`${chalk.yellow(`Please set the warehouse address: git remote add origin [remote repository address]`)}`);
98
- console.log();
99
- } catch (error) {
100
- console.log();
101
- console.log(chalk.red('git repository initialization exception'))
102
- console.log();
103
- }
104
- }
105
- }
106
- function create(argvs) {
107
- let c = new Creator();
108
- c.init(argvs[2])
109
- }
1
+ const chalk = require("chalk")
2
+ const inquirer = require("inquirer")
3
+ const memFs = require("mem-fs")
4
+ const memFsEditor = require("mem-fs-editor")
5
+ const fs = require("fs")
6
+ const path = require("path")
7
+ const { checkUpdate } = require("../../utils/checkVersion")
8
+ const tplBuilder = require("../../template/index");
9
+ const execSync = require('child_process').execSync;
10
+
11
+ class Creator {
12
+ constructor() {
13
+ this.fs = memFsEditor.create(memFs.create());
14
+ this.options = {
15
+ name: "",
16
+ description: ""
17
+ }
18
+
19
+ this.rootPath = path.resolve(__dirname, "../../");
20
+
21
+ this.tplDirPath = path.join(this.rootPath, "template");
22
+ }
23
+
24
+ async init(name) {
25
+ let res = await checkUpdate();
26
+ if (!res) {
27
+ console.log()
28
+ console.log(chalk.green('Welcome CloudCC-CLI'));
29
+ console.log()
30
+ if (!name) {
31
+ this.ask().then(answers => {
32
+ this.options = Object.assign({}, this.options, answers);
33
+ console.log(this.options);
34
+ this.write();
35
+ })
36
+ } else {
37
+ this.options = { name }
38
+ this.write();
39
+ }
40
+ }
41
+ }
42
+
43
+ ask() {
44
+ const prompt = [];
45
+
46
+ prompt.push({
47
+ type: "input",
48
+ name: "name",
49
+ message: "Please enter the project name",
50
+ validate(input) {
51
+ if (!input) {
52
+ return "Please enter the project name"
53
+ }
54
+
55
+ if (fs.existsSync(input)) {
56
+ return "Project name already exists"
57
+ }
58
+
59
+ return true;
60
+ }
61
+ });
62
+ return inquirer.prompt(prompt)
63
+ }
64
+
65
+ write() {
66
+ console.log();
67
+ console.log(chalk.green("Starting construction, please wait"));
68
+ tplBuilder(this, this.options, () => {
69
+ console.log();
70
+ this.initGit(path.join(process.cwd(), this.options.name))
71
+ console.log(chalk.green('Build completed, please install dependencies before running'))
72
+ console.log();
73
+ })
74
+ }
75
+
76
+ getTplPath(file) {
77
+ return path.join(this.tplDirPath, file);
78
+ }
79
+
80
+ copyTpl(file, to, data = {}) {
81
+ const tplPath = this.getTplPath(file);
82
+ this.fs.copyTpl(tplPath, to, data);
83
+ }
84
+
85
+ copy(file, to) {
86
+ const tplPath = this.getTplPath(file);
87
+ this.fs.copy(tplPath, to)
88
+ }
89
+
90
+ initGit(path) {
91
+ try {
92
+ execSync(`git -C ${path} init`)
93
+ execSync(`git -C ${path} add .`)
94
+ execSync(`git -C ${path} commit -m 'init'`)
95
+ console.log(`${chalk.grey(`Git repository initialization completed`)} ${chalk.green('✔ ')}`);
96
+ console.log();
97
+ console.log(`${chalk.yellow(`Please set the warehouse address: git remote add origin [remote repository address]`)}`);
98
+ console.log();
99
+ } catch (error) {
100
+ console.log();
101
+ console.log(chalk.red('git repository initialization exception'))
102
+ console.log();
103
+ }
104
+ }
105
+ }
106
+ function create(argvs) {
107
+ let c = new Creator();
108
+ c.init(argvs[2])
109
+ }
110
110
  module.exports = create;
@@ -1,7 +1,7 @@
1
- const cc = {}
2
- cc.create = require("./create1")
3
- function Plugin(action, argvs) {
4
- cc[action](argvs)
5
- }
6
-
7
- module.exports = Plugin;
1
+ const cc = {}
2
+ cc.create = require("./create1")
3
+ function Plugin(action, argvs) {
4
+ cc[action](argvs)
5
+ }
6
+
7
+ module.exports = Plugin;
@@ -1,13 +1,13 @@
1
- const { getBusToken } = require("../../utils/utils")
2
- const { postNormal } = require("../../utils/http")
3
-
4
- async function get(path, prefix) {
5
-
6
- if (await getBusToken(path)) {
7
- let res = await postNormal(global.apiSvc + "/api/batch/getRecordType", { prefix: prefix })
8
- console.log(JSON.stringify(res.data.recordTypeList))
9
- return res.data
10
- }
11
- }
12
-
13
- module.exports = get;
1
+ const { getBusToken } = require("../../utils/utils")
2
+ const { postNormal } = require("../../utils/http")
3
+
4
+ async function get(path, prefix) {
5
+
6
+ if (await getBusToken(path)) {
7
+ let res = await postNormal(global.apiSvc + "/api/batch/getRecordType", { prefix: prefix })
8
+ console.log(JSON.stringify(res.data.recordTypeList))
9
+ return res.data
10
+ }
11
+ }
12
+
13
+ module.exports = get;
@@ -1,7 +1,7 @@
1
- const cc = {}
2
- cc.get = require("./get")
3
- function main(action, argvs) {
4
- cc[action](argvs[2],argvs[3])
5
- }
6
-
7
- module.exports = main;
1
+ const cc = {}
2
+ cc.get = require("./get")
3
+ function main(action, argvs) {
4
+ cc[action](argvs[2],argvs[3])
5
+ }
6
+
7
+ module.exports = main;
@@ -1,30 +1,30 @@
1
- const { checkUpdate } = require("../../utils/checkVersion")
2
- const fs = require("fs");
3
- const path = require("path")
4
- const chalk = require("chalk")
5
-
6
- async function create(argvs) {
7
- let res = await checkUpdate();
8
- if (!res) {
9
- let body = JSON.parse(decodeURI(argvs[2]))
10
- const filePath = path.join(process.cwd(), "script/" + body.scriptName);
11
- try {
12
- fs.mkdirSync(filePath, { recursive: true })
13
- const fileTmp =
14
- `function main($CCDK, obj){
15
- console.log("Hello CloudCC")
16
- }`
17
- fs.writeFileSync(path.join(filePath, body.scriptName + ".js"), fileTmp)
18
- fs.writeFileSync(path.join(filePath, "config.json"), JSON.stringify(body))
19
- console.log()
20
- console.log(chalk.green("Successfully Created:" + body.scriptName))
21
- console.log()
22
- } catch (e) {
23
- console.log()
24
- console.log(chalk.red("Creation Failed:" + e))
25
- console.log()
26
- }
27
- }
28
- }
29
-
1
+ const { checkUpdate } = require("../../utils/checkVersion")
2
+ const fs = require("fs");
3
+ const path = require("path")
4
+ const chalk = require("chalk")
5
+
6
+ async function create(argvs) {
7
+ let res = await checkUpdate();
8
+ if (!res) {
9
+ let body = JSON.parse(decodeURI(argvs[2]))
10
+ const filePath = path.join(process.cwd(), "script/" + body.scriptName);
11
+ try {
12
+ fs.mkdirSync(filePath, { recursive: true })
13
+ const fileTmp =
14
+ `function main($CCDK, obj){
15
+ console.log("Hello CloudCC")
16
+ }`
17
+ fs.writeFileSync(path.join(filePath, body.scriptName + ".js"), fileTmp)
18
+ fs.writeFileSync(path.join(filePath, "config.json"), JSON.stringify(body))
19
+ console.log()
20
+ console.log(chalk.green("Successfully Created:" + body.scriptName))
21
+ console.log()
22
+ } catch (e) {
23
+ console.log()
24
+ console.log(chalk.red("Creation Failed:" + e))
25
+ console.log()
26
+ }
27
+ }
28
+ }
29
+
30
30
  module.exports = create;
@@ -1,8 +1,8 @@
1
- const cc = {}
2
- cc.create = require("./create")
3
- cc.publish = require("./publish")
4
- function main(action, argvs) {
5
- cc[action](argvs)
6
- }
7
-
8
- module.exports = main;
1
+ const cc = {}
2
+ cc.create = require("./create")
3
+ cc.publish = require("./publish")
4
+ function main(action, argvs) {
5
+ cc[action](argvs)
6
+ }
7
+
8
+ module.exports = main;
@@ -1,62 +1,62 @@
1
-
2
- const { checkUpdate } = require("../../utils/checkVersion")
3
- const fs = require("fs");
4
- const path = require("path")
5
- const chalk = require("chalk")
6
- const { post } = require("../../utils/http")
7
- const { getPackageJson } = require("../../utils/utils")
8
- const BaseUrl = "https://developer.apis.cloudcc.cn"
9
-
10
- async function publish(argvs) {
11
- let name = argvs[2]
12
- let res = await checkUpdate();
13
- if (!res) {
14
- const srcPath = path.join(process.cwd(), `script/${name}/`);
15
- let classContent = fs.readFileSync(srcPath + `${name}.js`, 'utf8').replace(/\s+/g, '').replace(/\n/g, '').match(/\{([\s\S]*?)\}/)[1];
16
- let configContent = JSON.parse(fs.readFileSync(srcPath + "config.json", 'utf8'));
17
- let configContentOld = JSON.parse(JSON.stringify(configContent))
18
-
19
- if (classContent) {
20
- let devConsoleConfig = getPackageJson()
21
-
22
- if ("private" != devConsoleConfig.version) {
23
- devConsoleConfig = { "accessToken": await getToken(devConsoleConfig) };
24
- }
25
- console.log(chalk.green('Posting, please wait...'));
26
- configContent.scriptContent = classContent
27
- let res = await post((devConsoleConfig.baseUrl || BaseUrl) + "/devconsole/script/saveClientScript", configContent, devConsoleConfig)
28
- if (res.result) {
29
- console.log();
30
- console.log(chalk.green('Success!'));
31
- console.log();
32
-
33
- if (!configContentOld.id) {
34
- configContentOld.id = res.data
35
- fs.writeFileSync(path.join(srcPath, "config.json"), JSON.stringify(configContentOld))
36
- }
37
- } else {
38
- console.log();
39
- console.log(chalk.red('Fail:' + res.returnInfo));
40
- console.log();
41
- }
42
- } else {
43
- console.log();
44
- console.log(chalk.red('Invalid Script Content'));
45
- console.log();
46
- }
47
- }
48
- }
49
-
50
-
51
-
52
- async function getToken(devConsoleConfig) {
53
- let res = await post(devConsoleConfig.baseUrl || BaseUrl + "/sysconfig/auth/pc/1.0/post/tokenInfo", devConsoleConfig);
54
- if (res.returnCode == 200) {
55
- return res.data.accessToken;
56
- } else {
57
- console.error(chalk.red(`Login failed`, JSON.stringify(res)));
58
- return null;
59
- }
60
- }
61
-
62
- module.exports = publish;
1
+
2
+ const { checkUpdate } = require("../../utils/checkVersion")
3
+ const fs = require("fs");
4
+ const path = require("path")
5
+ const chalk = require("chalk")
6
+ const { post } = require("../../utils/http")
7
+ const { getPackageJson } = require("../../utils/config.js")
8
+ const BaseUrl = "https://developer.apis.cloudcc.cn"
9
+
10
+ async function publish(argvs) {
11
+ let name = argvs[2]
12
+ let res = await checkUpdate();
13
+ if (!res) {
14
+ const srcPath = path.join(process.cwd(), `script/${name}/`);
15
+ let classContent = fs.readFileSync(srcPath + `${name}.js`, 'utf8').replace(/\s+/g, '').replace(/\n/g, '').match(/\{([\s\S]*?)\}/)[1];
16
+ let configContent = JSON.parse(fs.readFileSync(srcPath + "config.json", 'utf8'));
17
+ let configContentOld = JSON.parse(JSON.stringify(configContent))
18
+
19
+ if (classContent) {
20
+ let devConsoleConfig = getPackageJson()
21
+
22
+ if ("private" != devConsoleConfig.version) {
23
+ devConsoleConfig = { "accessToken": await getToken(devConsoleConfig) };
24
+ }
25
+ console.log(chalk.green('Posting, please wait...'));
26
+ configContent.scriptContent = classContent
27
+ let res = await post((devConsoleConfig.baseUrl || BaseUrl) + "/devconsole/script/saveClientScript", configContent, devConsoleConfig)
28
+ if (res.result) {
29
+ console.log();
30
+ console.log(chalk.green('Success!'));
31
+ console.log();
32
+
33
+ if (!configContentOld.id) {
34
+ configContentOld.id = res.data
35
+ fs.writeFileSync(path.join(srcPath, "config.json"), JSON.stringify(configContentOld))
36
+ }
37
+ } else {
38
+ console.log();
39
+ console.log(chalk.red('Fail:' + res.returnInfo));
40
+ console.log();
41
+ }
42
+ } else {
43
+ console.log();
44
+ console.log(chalk.red('Invalid Script Content'));
45
+ console.log();
46
+ }
47
+ }
48
+ }
49
+
50
+
51
+
52
+ async function getToken(devConsoleConfig) {
53
+ let res = await post(devConsoleConfig.baseUrl || BaseUrl + "/sysconfig/auth/pc/1.0/post/tokenInfo", devConsoleConfig);
54
+ if (res.returnCode == 200) {
55
+ return res.data.accessToken;
56
+ } else {
57
+ console.error(chalk.red(`Login failed`, JSON.stringify(res)));
58
+ return null;
59
+ }
60
+ }
61
+
62
+ module.exports = publish;