cloudcc-cli 1.8.0 → 1.8.2
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 +950 -933
- package/package.json +1 -1
- package/src/object/get.js +10 -3
- package/src/plugin/publish.js +6 -1
- package/src/plugin/publish1.js +7 -2
- package/src/project/create.js +16 -20
- package/src/project/create1.js +16 -20
- package/src/triggers/create.js +1 -1
- package/utils/cache.js +7 -7
- package/utils/checkVersion.js +3 -3
- package/utils/utils.js +8 -6
package/package.json
CHANGED
package/src/object/get.js
CHANGED
|
@@ -4,9 +4,16 @@ const { postNormal } = require("../../utils/http")
|
|
|
4
4
|
|
|
5
5
|
async function get(path) {
|
|
6
6
|
if (await getBusToken(path)) {
|
|
7
|
-
let res = await postNormal(global.setupSvc + "/api/
|
|
8
|
-
|
|
9
|
-
|
|
7
|
+
let res = await postNormal(global.setupSvc + "/api/trigger/newobjtrigger")
|
|
8
|
+
res = res.data.targetObjList.map((item) => {
|
|
9
|
+
return {
|
|
10
|
+
id: item.id,
|
|
11
|
+
objname: item.label,
|
|
12
|
+
objprefix: item.schemetable_name
|
|
13
|
+
}
|
|
14
|
+
})
|
|
15
|
+
console.log(JSON.stringify(res))
|
|
16
|
+
return res
|
|
10
17
|
}
|
|
11
18
|
}
|
|
12
19
|
|
package/src/plugin/publish.js
CHANGED
|
@@ -26,7 +26,12 @@ class Builder {
|
|
|
26
26
|
let config = this.options.devConsoleConfig
|
|
27
27
|
|
|
28
28
|
if ("private" != this.options.devConsoleConfig.version) {
|
|
29
|
-
|
|
29
|
+
let token = await this.getToken(config);
|
|
30
|
+
if (token) {
|
|
31
|
+
config = { "accessToken": token };
|
|
32
|
+
} else {
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
30
35
|
}
|
|
31
36
|
|
|
32
37
|
let answers;
|
package/src/plugin/publish1.js
CHANGED
|
@@ -29,7 +29,12 @@ class Builder {
|
|
|
29
29
|
let config = this.options.devConsoleConfig
|
|
30
30
|
|
|
31
31
|
if ("private" != this.options.devConsoleConfig.version) {
|
|
32
|
-
|
|
32
|
+
let token = await this.getToken(config);
|
|
33
|
+
if (token) {
|
|
34
|
+
config = { "accessToken": token };
|
|
35
|
+
} else {
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
33
38
|
}
|
|
34
39
|
|
|
35
40
|
let answers = { buildFileName: `${name}/${name}.vue` }
|
|
@@ -75,7 +80,7 @@ class Builder {
|
|
|
75
80
|
token: res.data.accessToken,
|
|
76
81
|
timestamp: now
|
|
77
82
|
};
|
|
78
|
-
writeCache(cache);
|
|
83
|
+
writeCache(process.cwd(), cache);
|
|
79
84
|
return res.data.accessToken;
|
|
80
85
|
} else {
|
|
81
86
|
console.error(chalk.red(`Login failed`, JSON.stringify(res)));
|
package/src/project/create.js
CHANGED
|
@@ -4,7 +4,6 @@ const memFs = require("mem-fs")
|
|
|
4
4
|
const memFsEditor = require("mem-fs-editor")
|
|
5
5
|
const fs = require("fs")
|
|
6
6
|
const path = require("path")
|
|
7
|
-
const { checkUpdate } = require("../../utils/checkVersion")
|
|
8
7
|
|
|
9
8
|
class Creator {
|
|
10
9
|
constructor() {
|
|
@@ -13,31 +12,28 @@ class Creator {
|
|
|
13
12
|
name: "",
|
|
14
13
|
description: ""
|
|
15
14
|
}
|
|
16
|
-
|
|
15
|
+
|
|
17
16
|
this.rootPath = path.resolve(__dirname, "../../");
|
|
18
|
-
|
|
17
|
+
|
|
19
18
|
this.tplDirPath = path.join(this.rootPath, "template");
|
|
20
19
|
}
|
|
21
|
-
|
|
20
|
+
|
|
22
21
|
async init(name) {
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
this.
|
|
30
|
-
this.options = Object.assign({}, this.options, answers);
|
|
31
|
-
console.log(this.options);
|
|
32
|
-
this.write();
|
|
33
|
-
})
|
|
34
|
-
} else {
|
|
35
|
-
this.options = { name }
|
|
22
|
+
console.log()
|
|
23
|
+
console.log(chalk.green('Welcome CloudCC-CLI'));
|
|
24
|
+
console.log()
|
|
25
|
+
if (!name) {
|
|
26
|
+
this.ask().then(answers => {
|
|
27
|
+
this.options = Object.assign({}, this.options, answers);
|
|
28
|
+
console.log(this.options);
|
|
36
29
|
this.write();
|
|
37
|
-
}
|
|
30
|
+
})
|
|
31
|
+
} else {
|
|
32
|
+
this.options = { name }
|
|
33
|
+
this.write();
|
|
38
34
|
}
|
|
39
35
|
}
|
|
40
|
-
|
|
36
|
+
|
|
41
37
|
ask() {
|
|
42
38
|
const prompt = [];
|
|
43
39
|
|
|
@@ -59,7 +55,7 @@ class Creator {
|
|
|
59
55
|
});
|
|
60
56
|
return inquirer.prompt(prompt)
|
|
61
57
|
}
|
|
62
|
-
|
|
58
|
+
|
|
63
59
|
write() {
|
|
64
60
|
console.log();
|
|
65
61
|
console.log(chalk.green("Starting construction, please wait"));
|
package/src/project/create1.js
CHANGED
|
@@ -4,7 +4,6 @@ const memFs = require("mem-fs")
|
|
|
4
4
|
const memFsEditor = require("mem-fs-editor")
|
|
5
5
|
const fs = require("fs")
|
|
6
6
|
const path = require("path")
|
|
7
|
-
const { checkUpdate } = require("../../utils/checkVersion")
|
|
8
7
|
const tplBuilder = require("../../template/index");
|
|
9
8
|
const execSync = require('child_process').execSync;
|
|
10
9
|
|
|
@@ -15,31 +14,28 @@ class Creator {
|
|
|
15
14
|
name: "",
|
|
16
15
|
description: ""
|
|
17
16
|
}
|
|
18
|
-
|
|
17
|
+
|
|
19
18
|
this.rootPath = path.resolve(__dirname, "../../");
|
|
20
|
-
|
|
19
|
+
|
|
21
20
|
this.tplDirPath = path.join(this.rootPath, "template");
|
|
22
21
|
}
|
|
23
|
-
|
|
22
|
+
|
|
24
23
|
async init(name) {
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
this.
|
|
32
|
-
this.options = Object.assign({}, this.options, answers);
|
|
33
|
-
console.log(this.options);
|
|
34
|
-
this.write();
|
|
35
|
-
})
|
|
36
|
-
} else {
|
|
37
|
-
this.options = { name }
|
|
24
|
+
console.log()
|
|
25
|
+
console.log(chalk.green('Welcome CloudCC-CLI'));
|
|
26
|
+
console.log()
|
|
27
|
+
if (!name) {
|
|
28
|
+
this.ask().then(answers => {
|
|
29
|
+
this.options = Object.assign({}, this.options, answers);
|
|
30
|
+
console.log(this.options);
|
|
38
31
|
this.write();
|
|
39
|
-
}
|
|
32
|
+
})
|
|
33
|
+
} else {
|
|
34
|
+
this.options = { name }
|
|
35
|
+
this.write();
|
|
40
36
|
}
|
|
41
37
|
}
|
|
42
|
-
|
|
38
|
+
|
|
43
39
|
ask() {
|
|
44
40
|
const prompt = [];
|
|
45
41
|
|
|
@@ -61,7 +57,7 @@ class Creator {
|
|
|
61
57
|
});
|
|
62
58
|
return inquirer.prompt(prompt)
|
|
63
59
|
}
|
|
64
|
-
|
|
60
|
+
|
|
65
61
|
write() {
|
|
66
62
|
console.log();
|
|
67
63
|
console.log(chalk.green("Starting construction, please wait"));
|
package/src/triggers/create.js
CHANGED
|
@@ -8,7 +8,7 @@ async function create(argvs) {
|
|
|
8
8
|
if (!res) {
|
|
9
9
|
let body = JSON.parse(decodeURI(argvs[2]))
|
|
10
10
|
const baseTriggersPath = path.join(process.cwd(), "triggers");
|
|
11
|
-
const objectFolderPath = path.join(baseTriggersPath, body.
|
|
11
|
+
const objectFolderPath = path.join(baseTriggersPath, `${body.schemetableName.toLowerCase()}`);
|
|
12
12
|
const triggersPath = path.join(objectFolderPath, body.name);
|
|
13
13
|
|
|
14
14
|
try {
|
package/utils/cache.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
const fs = require('fs');
|
|
2
|
-
const
|
|
2
|
+
const pathpath = require('path');
|
|
3
3
|
|
|
4
|
-
function getCachePath() {
|
|
5
|
-
return
|
|
4
|
+
function getCachePath(path = process.cwd()) {
|
|
5
|
+
return pathpath.join(path, '.cloudcc-cache.json');
|
|
6
6
|
}
|
|
7
7
|
|
|
8
|
-
function readCache() {
|
|
8
|
+
function readCache(path = process.cwd()) {
|
|
9
9
|
try {
|
|
10
|
-
const cachePath = getCachePath();
|
|
10
|
+
const cachePath = getCachePath(path);
|
|
11
11
|
if (!fs.existsSync(cachePath)) {
|
|
12
12
|
fs.writeFileSync(cachePath, JSON.stringify({}, null, 2));
|
|
13
13
|
return {};
|
|
@@ -19,9 +19,9 @@ function readCache() {
|
|
|
19
19
|
}
|
|
20
20
|
}
|
|
21
21
|
|
|
22
|
-
function writeCache(data) {
|
|
22
|
+
function writeCache(path = process.cwd(), data) {
|
|
23
23
|
try {
|
|
24
|
-
const cachePath = getCachePath();
|
|
24
|
+
const cachePath = getCachePath(path);
|
|
25
25
|
fs.writeFileSync(cachePath, JSON.stringify(data, null, 2));
|
|
26
26
|
} catch (error) {
|
|
27
27
|
console.error('Failed to write cache:', error);
|
package/utils/checkVersion.js
CHANGED
|
@@ -65,9 +65,9 @@ function update(onlineVersion) {
|
|
|
65
65
|
}
|
|
66
66
|
|
|
67
67
|
|
|
68
|
-
async function checkUpdate() {
|
|
68
|
+
async function checkUpdate(path = process.cwd()) {
|
|
69
69
|
// 检查缓存
|
|
70
|
-
const cache = readCache();
|
|
70
|
+
const cache = readCache(path);
|
|
71
71
|
const cacheKey = 'version_check';
|
|
72
72
|
const now = Date.now();
|
|
73
73
|
const oneHour = 60 * 60 * 1000;
|
|
@@ -86,7 +86,7 @@ async function checkUpdate() {
|
|
|
86
86
|
cache[cacheKey] = {
|
|
87
87
|
timestamp: now
|
|
88
88
|
};
|
|
89
|
-
writeCache(cache);
|
|
89
|
+
writeCache(path, cache);
|
|
90
90
|
} catch (error) {
|
|
91
91
|
console.log("error", error)
|
|
92
92
|
onlineVersion = false;
|
package/utils/utils.js
CHANGED
|
@@ -3,8 +3,8 @@ const chalk = require("chalk")
|
|
|
3
3
|
const { getPackageJson } = require("./config")
|
|
4
4
|
const { readCache, writeCache } = require("./cache")
|
|
5
5
|
|
|
6
|
-
async function getBaseUrl(devConfig) {
|
|
7
|
-
const cache = readCache();
|
|
6
|
+
async function getBaseUrl(path, devConfig) {
|
|
7
|
+
const cache = readCache(path);
|
|
8
8
|
const cacheKey = devConfig.secretKey;
|
|
9
9
|
const now = Date.now();
|
|
10
10
|
const oneHour = 60 * 60 * 1000;
|
|
@@ -37,7 +37,7 @@ async function getBaseUrl(devConfig) {
|
|
|
37
37
|
setupSvc: global.setupSvc,
|
|
38
38
|
timestamp: now
|
|
39
39
|
};
|
|
40
|
-
writeCache(cache);
|
|
40
|
+
writeCache(path, cache);
|
|
41
41
|
}
|
|
42
42
|
|
|
43
43
|
async function getBusToken(path = process.cwd()) {
|
|
@@ -48,7 +48,7 @@ async function getBusToken(path = process.cwd()) {
|
|
|
48
48
|
return false;
|
|
49
49
|
}
|
|
50
50
|
|
|
51
|
-
const cache = readCache();
|
|
51
|
+
const cache = readCache(path);
|
|
52
52
|
const cacheKey = devConfig.secretKey;
|
|
53
53
|
const now = Date.now();
|
|
54
54
|
const oneHour = 60 * 60 * 1000;
|
|
@@ -72,7 +72,8 @@ async function getBusToken(path = process.cwd()) {
|
|
|
72
72
|
secretKey: devConfig.openSecretKey,
|
|
73
73
|
orgId: devConfig.orgId
|
|
74
74
|
}
|
|
75
|
-
await getBaseUrl(devConfig)
|
|
75
|
+
await getBaseUrl(path, devConfig)
|
|
76
|
+
// return path
|
|
76
77
|
let res = await postNormal(global.apiSvc + "/api/cauth/token", body)
|
|
77
78
|
if (res.result) {
|
|
78
79
|
global.accessToken = res.data.accessToken;
|
|
@@ -83,7 +84,8 @@ async function getBusToken(path = process.cwd()) {
|
|
|
83
84
|
setupSvc: global.setupSvc,
|
|
84
85
|
timestamp: now
|
|
85
86
|
};
|
|
86
|
-
|
|
87
|
+
|
|
88
|
+
writeCache(path, cache);
|
|
87
89
|
return res.data.accessToken;
|
|
88
90
|
} else {
|
|
89
91
|
console.log(chalk.red(res.returnInfo));
|