cloudcc-cli 2.2.3 → 2.2.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.
- package/.vscode/settings.json +3 -0
- package/README.md +35 -0
- package/bin/cc.js +11 -36
- package/bin/index.js +33 -0
- package/bin/mcp-svc.js +13 -0
- package/java/com/cloudcc/core/TriggerInvoker.java +17 -1
- package/package.json +3 -2
- package/pom.xml +1 -0
- package/prompt/DevelopmentEnvironmentConstruction.ts +133 -0
- package/prompt/ccdk.ts +1190 -0
- package/prompt/ccprompt.ts +8 -0
- package/prompt/cloudccdev.ts +109 -0
- package/prompt/index.ts +52 -0
- package/prompt/objectInfo.ts +94 -0
- package/prompt/objectList.ts +25 -0
- package/prompt/openapi.ts +310 -0
- package/prompt/system.ts +14 -0
- package/prompt/vscodeExtension.ts +27 -0
- package/src/approval/approve.js +105 -0
- package/src/approval/get.js +245 -0
- package/src/approval/index.js +11 -0
- package/src/approval/reject.js +105 -0
- package/src/brief/get.js +51 -0
- package/src/brief/index.js +7 -0
- package/src/config/get.js +1 -1
- package/src/fields/create.js +204 -0
- package/src/fields/fields/A.js +23 -0
- package/src/fields/fields/AD.js +25 -0
- package/src/fields/fields/B.js +28 -0
- package/src/fields/fields/C.js +28 -0
- package/src/fields/fields/D.js +27 -0
- package/src/fields/fields/E.js +28 -0
- package/src/fields/fields/ENC.js +28 -0
- package/src/fields/fields/ENCD.js +28 -0
- package/src/fields/fields/F.js +27 -0
- package/src/fields/fields/FL.js +25 -0
- package/src/fields/fields/H.js +27 -0
- package/src/fields/fields/IMG.js +27 -0
- package/src/fields/fields/J.js +26 -0
- package/src/fields/fields/L.js +32 -0
- package/src/fields/fields/LT.js +28 -0
- package/src/fields/fields/M.js +29 -0
- package/src/fields/fields/MR.js +24 -0
- package/src/fields/fields/N.js +30 -0
- package/src/fields/fields/P.js +28 -0
- package/src/fields/fields/Q.js +35 -0
- package/src/fields/fields/S.js +30 -0
- package/src/fields/fields/SCORE.js +24 -0
- package/src/fields/fields/T.js +27 -0
- package/src/fields/fields/U.js +28 -0
- package/src/fields/fields/X.js +28 -0
- package/src/fields/fields/Y.js +33 -0
- package/src/fields/get.js +36 -0
- package/src/fields/index.js +9 -0
- package/src/mcp/MCP/345/234/272/346/231/257/346/250/241/346/213/237.md +8 -0
- package/src/mcp/index-sse-svc.js +126 -0
- package/src/mcp/index-streamable-svc.js +180 -0
- package/src/mcp/index.js +519 -115
- package/src/mcp/readme.md +75 -70
- package/src/mcp/tools/Approval/handler.js +349 -0
- package/src/mcp/tools/Class Creator/handler.js +37 -0
- package/src/mcp/tools/Class Detail Retriever/handler.js +33 -0
- package/src/mcp/tools/Class Detail Retriever/prompt.js +37 -0
- package/src/mcp/tools/Class Editor Guide/handler.js +72 -0
- package/src/mcp/tools/Class Editor Guide/prompt.js +468 -0
- package/src/mcp/tools/Class List Retriever/handler.js +36 -0
- package/src/mcp/tools/Class Publisher/handler.js +29 -0
- package/src/mcp/tools/Class Publisher/prompt.js +40 -0
- package/src/mcp/tools/Class Puller/handler.js +86 -0
- package/src/mcp/tools/Class Puller/prompt.js +49 -0
- package/src/mcp/tools/Client Script Creator/handler.js +179 -0
- package/src/mcp/tools/Client Script Detail Retriever/handler.js +53 -0
- package/src/mcp/tools/Client Script Editor Guide/handler.js +633 -0
- package/src/mcp/tools/Client Script List Retriever/handler.js +68 -0
- package/src/mcp/tools/Client Script Publisher/handler.js +54 -0
- package/src/mcp/tools/Client Script Puller/handler.js +73 -0
- package/src/mcp/tools/CloudCC Development Overview/handler.js +48 -0
- package/src/mcp/tools/CloudCC Development Overview/prompt.js +870 -0
- package/src/mcp/tools/Component Creator/handler.js +44 -0
- package/src/mcp/tools/Component Detail Retriever/handler.js +38 -0
- package/src/mcp/tools/Component Editor Guide/handler.js +76 -0
- package/src/mcp/tools/Component Editor Guide/prompt.js +519 -0
- package/src/mcp/tools/Component List Retriever/handler.js +43 -0
- package/src/mcp/tools/Component Publisher/handler.js +18 -0
- package/src/mcp/tools/Component Puller/handler.js +63 -0
- package/src/mcp/tools/{dev-env/fetcher.js → Dev Environment Creator/fetcher.js } +8 -8
- package/src/mcp/tools/{dev-env/prompt.js → Dev Environment Creator/prompt.js } +19 -2
- package/src/mcp/tools/Dev Environment Validator/handler.js +88 -0
- package/src/mcp/tools/Dev Environment Validator/prompt.js +193 -0
- package/src/mcp/tools/{key-guide/fetcher.js → Developer Key Setup Guide/fetcher.js } +7 -7
- package/src/mcp/tools/{key-guide/prompt.js → Developer Key Setup Guide/prompt.js } +3 -3
- package/src/mcp/tools/Object Creator/handler.js +34 -0
- package/src/mcp/tools/Object Fields Creator/handler.js +64 -0
- package/src/mcp/tools/Object Fields Retriever/handler.js +37 -0
- package/src/mcp/tools/Object Fields Retriever/prompt.js +10 -0
- package/src/mcp/tools/Object List Retriever/handler.js +43 -0
- package/src/mcp/tools/Object List Retriever/prompt.js +10 -0
- package/src/mcp/tools/Scheduled Class Creator/handler.js +37 -0
- package/src/mcp/tools/Scheduled Class Detail Retriever/handler.js +34 -0
- package/src/mcp/tools/Scheduled Class List Retriever/handler.js +52 -0
- package/src/mcp/tools/Scheduled Class Publisher/handler.js +30 -0
- package/src/mcp/tools/Scheduled Class Puller/handler.js +92 -0
- package/src/mcp/tools/Trigger Creator/handler.js +53 -0
- package/src/mcp/tools/Trigger Detail Retriever/handler.js +33 -0
- package/src/mcp/tools/Trigger Editor Guide/handler.js +58 -0
- package/src/mcp/tools/Trigger List Retriever/handler.js +49 -0
- package/src/mcp/tools/Trigger Publisher/handler.js +34 -0
- package/src/mcp/tools/Trigger Puller/handler.js +40 -0
- package/src/mcp/tools/ccdk/fetcher.js +3 -3
- package/src/mcp/tools/ccdk/prompt.js +2 -2
- package/src/mcp/tools/index.js +23 -0
- package/src/object/create.js +105 -0
- package/src/object/get.js +43 -4
- package/src/object/index.js +2 -1
- package/src/plugin/create1.js +8 -7
- package/src/plugin/detail.js +91 -0
- package/src/plugin/get.js +79 -0
- package/src/plugin/index.js +4 -1
- package/src/plugin/publish.js +13 -13
- package/src/plugin/publish1.js +30 -22
- package/src/plugin/pull.js +173 -0
- package/src/project/create.js +9 -9
- package/src/project/create1.js +31 -17
- package/src/recordType/get.js +4 -2
- package/src/script/create.js +7 -7
- package/src/script/detail.js +95 -0
- package/src/script/get.js +4 -2
- package/src/script/index.js +1 -0
- package/src/script/publish.js +14 -14
- package/src/script/pull.js +12 -12
- package/src/script/pullList.js +5 -3
- package/src/timer/create.js +7 -7
- package/src/timer/detail.js +84 -0
- package/src/timer/get.js +6 -3
- package/src/timer/publish.js +7 -7
- package/src/timer/pull.js +8 -8
- package/src/timer/pullList.js +5 -3
- package/src/token/get.js +1 -1
- package/src/triggers/create.js +7 -7
- package/src/triggers/detail.js +90 -0
- package/src/triggers/get.js +4 -2
- package/src/triggers/index.js +1 -0
- package/src/triggers/publish.js +7 -7
- package/src/triggers/pull.js +8 -8
- package/src/triggers/pullList.js +5 -3
- package/src/version/get.js +3 -3
- package/target/ccopenapi-0.0.3-classes.jar +0 -0
- package/target/ccopenapi-0.0.3.jar +0 -0
- package/target/maven-archiver/pom.properties +3 -0
- package/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst +18 -0
- package/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst +19 -0
- package/template/Appvue +2 -2
- package/template/index.js +30 -19
- package/tool/branch/index.js +1 -1
- package/tool/checkLange/checkLang.js +6 -6
- package/tool/checkLange/clearLang.js +1 -1
- package/utils/accessClass.js +23 -0
- package/utils/checkVersion.js +22 -20
- package/utils/config.js +18 -3
- package/utils/http.js +10 -10
- package/utils/utils.js +97 -32
- package/java/com/cloudcc/core/CCTriggerDemo.java +0 -25
- package/src/classes/create.js +0 -66
- package/src/classes/get.js +0 -22
- package/src/classes/index.js +0 -11
- package/src/classes/publish.js +0 -51
- package/src/classes/pull.js +0 -55
- package/src/classes/pullList.js +0 -44
- package/src/mcp/tools/classes/handler.js +0 -358
- package/src/mcp/tools/classes/prompt.js +0 -1261
- package/src/mcp/tools/plugin/handler.js +0 -92
- /package/src/mcp/tools/{plugin → Component Publisher}/prompt.js +0 -0
- /package/src/mcp/tools/{dev-env → Dev Environment Creator}/handler.js +0 -0
- /package/src/mcp/tools/{key-guide → Developer Key Setup Guide}/handler.js +0 -0
|
@@ -36,17 +36,17 @@ function checkFilesInFolder(folderPath) {
|
|
|
36
36
|
|
|
37
37
|
if (chineseRegex.test(data)) {
|
|
38
38
|
length++;
|
|
39
|
-
console.
|
|
39
|
+
console.error(`have "${filePath}"`);
|
|
40
40
|
}
|
|
41
41
|
});
|
|
42
42
|
} else {
|
|
43
|
-
// console.
|
|
43
|
+
// console.error(`jump filePath"${filePath}"`);
|
|
44
44
|
}
|
|
45
45
|
} else if (stats.isDirectory()) {
|
|
46
46
|
if (!excludeFolders.includes(file)) {
|
|
47
47
|
checkFilesInFolder(filePath);
|
|
48
48
|
} else {
|
|
49
|
-
// console.
|
|
49
|
+
// console.error(`jump filePath"${filePath}"`);
|
|
50
50
|
}
|
|
51
51
|
}
|
|
52
52
|
});
|
|
@@ -59,9 +59,9 @@ checkFilesInFolder(folderPath);
|
|
|
59
59
|
|
|
60
60
|
function getLength() {
|
|
61
61
|
setTimeout(() => {
|
|
62
|
-
console.
|
|
63
|
-
console.
|
|
64
|
-
console.
|
|
62
|
+
console.error(`==============================================================`)
|
|
63
|
+
console.error(`total ${length} files have chinese`);
|
|
64
|
+
console.error(`==============================================================`)
|
|
65
65
|
}, 1000);
|
|
66
66
|
}
|
|
67
67
|
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
const postClass = require('./http').postClass;
|
|
2
|
+
const { getPackageJson } = require("./config")
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
async function test() {
|
|
8
|
+
let config = await getPackageJson();
|
|
9
|
+
console.log('Using config:', config);
|
|
10
|
+
// 自定义类名
|
|
11
|
+
let className = "TestDtt"
|
|
12
|
+
// 类中的方法名
|
|
13
|
+
let methodName = "sendEm"
|
|
14
|
+
// 方法入参
|
|
15
|
+
let params = []
|
|
16
|
+
postClass(config.setupSvc + "/api/openCall/common", { className, methodName, params }, config.accessToken).then(res => {
|
|
17
|
+
console.log('Delete success:', res);
|
|
18
|
+
}).catch(err => {
|
|
19
|
+
console.error('Error deleting object:', err);
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
test()
|
package/utils/checkVersion.js
CHANGED
|
@@ -23,15 +23,15 @@ function checkNpmVersion() {
|
|
|
23
23
|
});
|
|
24
24
|
|
|
25
25
|
onlineVersionNum = Number(onlineVersion.replace(/\./g, ""));
|
|
26
|
-
console.
|
|
27
|
-
console.
|
|
28
|
-
console.
|
|
29
|
-
console.
|
|
30
|
-
console.
|
|
31
|
-
console.
|
|
32
|
-
console.
|
|
33
|
-
console.
|
|
34
|
-
console.
|
|
26
|
+
console.error('\n');
|
|
27
|
+
console.error(chalk.bold.cyan(' CloudCC CLI Version\n'));
|
|
28
|
+
console.error(' ' + chalk.gray('━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━'));
|
|
29
|
+
console.error(' ' + chalk.green('★') + ' Current Version : ' + chalk.bold.green('v' + config.version));
|
|
30
|
+
console.error(' ' + chalk.blue('★') + ' Latest Version : ' + chalk.bold.blue('v' + onlineVersion));
|
|
31
|
+
console.error(' ' + chalk.yellow('★') + ' Published At : ' + chalk.gray(formattedTime));
|
|
32
|
+
console.error(' ' + chalk.magenta('★') + ' Developer Docs : ' + chalk.cyan('https://help.cloudcc.cn/'));
|
|
33
|
+
console.error(' ' + chalk.magenta('★') + ' Changelog : ' + chalk.cyan('https://www.npmjs.com/package/cloudcc-cli'));
|
|
34
|
+
console.error(' ' + chalk.gray('━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\n'));
|
|
35
35
|
|
|
36
36
|
if (onlineVersionNum - currentVersion > 0) {
|
|
37
37
|
return onlineVersion;
|
|
@@ -41,7 +41,7 @@ function checkNpmVersion() {
|
|
|
41
41
|
|
|
42
42
|
|
|
43
43
|
function askUpdate() {
|
|
44
|
-
console.
|
|
44
|
+
console.error();
|
|
45
45
|
const prompt = [{
|
|
46
46
|
type: 'list',
|
|
47
47
|
message: 'Do you want to perform automatic upgrade?',
|
|
@@ -55,14 +55,14 @@ function askUpdate() {
|
|
|
55
55
|
|
|
56
56
|
|
|
57
57
|
function update(onlineVersion) {
|
|
58
|
-
console.
|
|
59
|
-
console.
|
|
60
|
-
console.
|
|
58
|
+
console.error()
|
|
59
|
+
console.error(chalk.green("Upgrading, estimated to be completed in 3 minutes, please wait..."));
|
|
60
|
+
console.error()
|
|
61
61
|
let os = process.platform
|
|
62
|
-
console.
|
|
62
|
+
console.error(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`));
|
|
63
63
|
exec(`${'darwin' == os ? 'sudo' : ''} npm install -g cloudcc-cli@${onlineVersion} --registry http://registry.npmmirror.com`)
|
|
64
|
-
console.
|
|
65
|
-
console.
|
|
64
|
+
console.error()
|
|
65
|
+
console.error(chalk.green("Upgrade completed! Please re-run"));
|
|
66
66
|
}
|
|
67
67
|
|
|
68
68
|
|
|
@@ -81,12 +81,14 @@ async function checkUpdate(path = process.cwd()) {
|
|
|
81
81
|
try {
|
|
82
82
|
checkAndReplaceJar();
|
|
83
83
|
onlineVersion = checkNpmVersion();
|
|
84
|
+
// 更新缓存时间戳(因为已经检查过版本了)
|
|
85
|
+
// 注意:这里会更新缓存,但这是合理的,因为缓存已经过期了
|
|
84
86
|
cache[cacheKey] = {
|
|
85
87
|
timestamp: now
|
|
86
88
|
};
|
|
87
89
|
writeCache(path, cache);
|
|
88
90
|
} catch (error) {
|
|
89
|
-
console.
|
|
91
|
+
console.error("error", error)
|
|
90
92
|
onlineVersion = false;
|
|
91
93
|
}
|
|
92
94
|
|
|
@@ -117,19 +119,19 @@ function checkAndReplaceJar(projectPath = process.cwd()) {
|
|
|
117
119
|
|
|
118
120
|
const projectVersion = projectJar.match(/ccopenapi-(\d+\.\d+\.\d+)/)?.[1];
|
|
119
121
|
if (!projectVersion) {
|
|
120
|
-
console.
|
|
122
|
+
console.error(chalk.red('Failed to parse the version of the ccopenapi jar in the project.'));
|
|
121
123
|
return;
|
|
122
124
|
}
|
|
123
125
|
|
|
124
126
|
const templateJar = fs.readdirSync(templateLibPath).find(file => file.startsWith('ccopenapi') && file.endsWith('.jar'));
|
|
125
127
|
if (!templateJar) {
|
|
126
|
-
console.
|
|
128
|
+
console.error(chalk.yellow('No ccopenapi jar found in the template lib folder.'));
|
|
127
129
|
return;
|
|
128
130
|
}
|
|
129
131
|
|
|
130
132
|
const templateVersion = templateJar.match(/ccopenapi-(\d+\.\d+\.\d+)/)?.[1];
|
|
131
133
|
if (!templateVersion) {
|
|
132
|
-
console.
|
|
134
|
+
console.error(chalk.red('Failed to parse the version of the ccopenapi jar in the template.'));
|
|
133
135
|
return;
|
|
134
136
|
}
|
|
135
137
|
|
package/utils/config.js
CHANGED
|
@@ -19,7 +19,12 @@ function getPackageJson_old(projectPath = process.cwd()) {
|
|
|
19
19
|
* @returns
|
|
20
20
|
*/
|
|
21
21
|
async function getPackageJson2(projectPath = process.cwd()) {
|
|
22
|
-
let config
|
|
22
|
+
let config;
|
|
23
|
+
try {
|
|
24
|
+
config = require(path.resolve(projectPath, "cloudcc-cli.config.js"));
|
|
25
|
+
} catch (err) {
|
|
26
|
+
return null;
|
|
27
|
+
}
|
|
23
28
|
config = config[config.use]
|
|
24
29
|
config.CloudCCDev = "";
|
|
25
30
|
config = await getDevConsoleConfig(projectPath, config)
|
|
@@ -32,7 +37,12 @@ async function getPackageJson2(projectPath = process.cwd()) {
|
|
|
32
37
|
* @returns
|
|
33
38
|
*/
|
|
34
39
|
async function getPackageJson3(projectPath = process.cwd()) {
|
|
35
|
-
let config
|
|
40
|
+
let config;
|
|
41
|
+
try {
|
|
42
|
+
config = require(path.resolve(projectPath, "cloudcc-cli.config.js"));
|
|
43
|
+
} catch (err) {
|
|
44
|
+
return null;
|
|
45
|
+
}
|
|
36
46
|
config = config[config.use]
|
|
37
47
|
// 检查并解密CloudCCDev信息
|
|
38
48
|
if (config && config.CloudCCDev) {
|
|
@@ -57,7 +67,12 @@ async function getPackageJson3(projectPath = process.cwd()) {
|
|
|
57
67
|
* @returns 配置参数
|
|
58
68
|
*/
|
|
59
69
|
async function getPackageJsonCache(projectPath = process.cwd()) {
|
|
60
|
-
let config
|
|
70
|
+
let config;
|
|
71
|
+
try {
|
|
72
|
+
config = require(path.resolve(projectPath, "cloudcc-cli.config.js"));
|
|
73
|
+
} catch (err) {
|
|
74
|
+
return null;
|
|
75
|
+
}
|
|
61
76
|
const cacheData = readCache(projectPath)[config[config.use].safetyMark || config[config.use].secretKey];
|
|
62
77
|
if (cacheData && cacheData.timestamp) {
|
|
63
78
|
const oneHour = 60 * 60 * 1000; // 1小时的毫秒数
|
package/utils/http.js
CHANGED
|
@@ -24,9 +24,9 @@ service.interceptors.request.use(
|
|
|
24
24
|
return config
|
|
25
25
|
},
|
|
26
26
|
error => {
|
|
27
|
-
console.
|
|
28
|
-
console.
|
|
29
|
-
console.
|
|
27
|
+
console.error()
|
|
28
|
+
console.error(error)
|
|
29
|
+
console.error()
|
|
30
30
|
}
|
|
31
31
|
)
|
|
32
32
|
|
|
@@ -41,10 +41,10 @@ service.interceptors.response.use(
|
|
|
41
41
|
}
|
|
42
42
|
},
|
|
43
43
|
error => {
|
|
44
|
-
console.
|
|
45
|
-
console.
|
|
46
|
-
console.
|
|
47
|
-
process.exit(1)
|
|
44
|
+
console.error("")
|
|
45
|
+
console.error("error", error)
|
|
46
|
+
console.error("")
|
|
47
|
+
// process.exit(1)
|
|
48
48
|
}
|
|
49
49
|
)
|
|
50
50
|
const formateData = (data, header) => {
|
|
@@ -80,9 +80,9 @@ module.exports = {
|
|
|
80
80
|
data: data
|
|
81
81
|
})
|
|
82
82
|
} else {
|
|
83
|
-
console.
|
|
84
|
-
console.
|
|
85
|
-
console.
|
|
83
|
+
console.error()
|
|
84
|
+
console.error(chalk.red('Failed: \nOpenAPI Token is null. \nPlease check your cloudcc-cli.config file! \nor delete the .cloudcc-cache.json file and re-run the command!'));
|
|
85
|
+
console.error()
|
|
86
86
|
process.exit(1)
|
|
87
87
|
}
|
|
88
88
|
},
|
package/utils/utils.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
const chalk = require("chalk")
|
|
2
|
-
const { writeCache } = require("./cache")
|
|
2
|
+
const { readCache, writeCache } = require("./cache")
|
|
3
3
|
const axios = require("axios")
|
|
4
4
|
const BaseUrl = "https://developer.apis.cloudcc.cn"
|
|
5
5
|
|
|
@@ -124,7 +124,7 @@ async function getSecretKey(config) {
|
|
|
124
124
|
config.secretKey = response.data.data.secretKey;
|
|
125
125
|
return config;
|
|
126
126
|
} catch (error) {
|
|
127
|
-
console.
|
|
127
|
+
console.error(chalk.red('Get Plugin SecretKey Failed:', error.message));
|
|
128
128
|
process.exit(1)
|
|
129
129
|
}
|
|
130
130
|
}
|
|
@@ -137,7 +137,17 @@ async function getDevConsoleConfig(projectPath = process.cwd(), config) {
|
|
|
137
137
|
config = await getPluginToken(config);
|
|
138
138
|
}
|
|
139
139
|
config.timestamp = Date.now();
|
|
140
|
-
|
|
140
|
+
// 读取现有缓存并合并,而不是覆盖整个缓存对象
|
|
141
|
+
const existingCache = readCache(projectPath);
|
|
142
|
+
const cacheKey = config.safetyMark || config.secretKey;
|
|
143
|
+
// 只有当配置确实改变时才更新缓存
|
|
144
|
+
const oldConfig = existingCache[cacheKey];
|
|
145
|
+
const configChanged = !oldConfig ||
|
|
146
|
+
JSON.stringify(oldConfig) !== JSON.stringify(config);
|
|
147
|
+
if (configChanged) {
|
|
148
|
+
existingCache[cacheKey] = config;
|
|
149
|
+
writeCache(projectPath, existingCache);
|
|
150
|
+
}
|
|
141
151
|
return config;
|
|
142
152
|
}
|
|
143
153
|
|
|
@@ -188,11 +198,11 @@ try {
|
|
|
188
198
|
*/
|
|
189
199
|
function parseVueDataFunction(vueContent) {
|
|
190
200
|
// if (!babelParser || !babelTraverse) {
|
|
191
|
-
// console.
|
|
192
|
-
// console.
|
|
193
|
-
// console.
|
|
194
|
-
// console.
|
|
195
|
-
// console.
|
|
201
|
+
// console.error()
|
|
202
|
+
// console.error(chalk.yellow("Warning: @babel/parser and @babel/traverse are not installed. Please run:"));
|
|
203
|
+
// console.error(chalk.cyan("npm install --save @babel/parser @babel/traverse"));
|
|
204
|
+
// console.error()
|
|
205
|
+
// console.error(chalk.yellow("Falling back to regex parsing..."));
|
|
196
206
|
// return parseVueDataFunctionWithRegex(vueContent);
|
|
197
207
|
// }
|
|
198
208
|
|
|
@@ -220,9 +230,9 @@ function parseVueDataFunction(vueContent) {
|
|
|
220
230
|
}
|
|
221
231
|
|
|
222
232
|
if (!scriptContent) {
|
|
223
|
-
console.
|
|
224
|
-
console.
|
|
225
|
-
console.
|
|
233
|
+
console.error()
|
|
234
|
+
console.error(chalk.red("Error: Cannot find <script> tag with component code in the vue file."));
|
|
235
|
+
console.error()
|
|
226
236
|
return null;
|
|
227
237
|
}
|
|
228
238
|
|
|
@@ -271,19 +281,19 @@ function parseVueDataFunction(vueContent) {
|
|
|
271
281
|
});
|
|
272
282
|
|
|
273
283
|
if (!dataObject) {
|
|
274
|
-
console.
|
|
275
|
-
console.
|
|
276
|
-
console.
|
|
284
|
+
console.error()
|
|
285
|
+
console.error(chalk.red("Error: Cannot find data() function or its return statement in the vue file."));
|
|
286
|
+
console.error()
|
|
277
287
|
return null;
|
|
278
288
|
}
|
|
279
289
|
|
|
280
290
|
return dataObject;
|
|
281
291
|
|
|
282
292
|
} catch (e) {
|
|
283
|
-
console.
|
|
284
|
-
console.
|
|
285
|
-
console.
|
|
286
|
-
console.
|
|
293
|
+
console.error()
|
|
294
|
+
console.error(chalk.red("Error: Failed to parse vue file with AST."));
|
|
295
|
+
console.error(chalk.red("Details: " + e.message));
|
|
296
|
+
console.error()
|
|
287
297
|
return null;
|
|
288
298
|
}
|
|
289
299
|
}
|
|
@@ -302,7 +312,7 @@ function astToObject(node) {
|
|
|
302
312
|
obj[key] = astToValue(prop.value);
|
|
303
313
|
} else if (prop.type === 'SpreadElement') {
|
|
304
314
|
// 处理展开运算符 {...obj}
|
|
305
|
-
console.
|
|
315
|
+
console.error(chalk.yellow("Warning: Spread operator is not fully supported in data object."));
|
|
306
316
|
}
|
|
307
317
|
}
|
|
308
318
|
return obj;
|
|
@@ -351,9 +361,9 @@ function parseVueDataFunctionWithRegex(vueContent) {
|
|
|
351
361
|
// 匹配 data() 函数,找到开始位置
|
|
352
362
|
const dataStartMatch = vueContent.match(/data\s*\(\s*\)\s*\{[\s\S]*?return\s*\{/);
|
|
353
363
|
if (!dataStartMatch) {
|
|
354
|
-
console.
|
|
355
|
-
console.
|
|
356
|
-
console.
|
|
364
|
+
console.error()
|
|
365
|
+
console.error(chalk.red("Error: Cannot find data() function or its return statement in the vue file."));
|
|
366
|
+
console.error()
|
|
357
367
|
return null;
|
|
358
368
|
}
|
|
359
369
|
|
|
@@ -374,9 +384,9 @@ function parseVueDataFunctionWithRegex(vueContent) {
|
|
|
374
384
|
}
|
|
375
385
|
|
|
376
386
|
if (braceCount !== 0) {
|
|
377
|
-
console.
|
|
378
|
-
console.
|
|
379
|
-
console.
|
|
387
|
+
console.error()
|
|
388
|
+
console.error(chalk.red("Error: Cannot parse data() function, unmatched braces."));
|
|
389
|
+
console.error()
|
|
380
390
|
return null;
|
|
381
391
|
}
|
|
382
392
|
|
|
@@ -389,10 +399,10 @@ function parseVueDataFunctionWithRegex(vueContent) {
|
|
|
389
399
|
return dataFunc();
|
|
390
400
|
|
|
391
401
|
} catch (e) {
|
|
392
|
-
console.
|
|
393
|
-
console.
|
|
394
|
-
console.
|
|
395
|
-
console.
|
|
402
|
+
console.error()
|
|
403
|
+
console.error(chalk.red("Error: Failed to parse data function with regex."));
|
|
404
|
+
console.error(chalk.red("Details: " + e.message));
|
|
405
|
+
console.error()
|
|
396
406
|
return null;
|
|
397
407
|
}
|
|
398
408
|
}
|
|
@@ -538,7 +548,7 @@ function collectDependencies(entryFile, baseDir, visited = new Set()) {
|
|
|
538
548
|
try {
|
|
539
549
|
fileContent = fs.readFileSync(normalizedPath, 'utf8');
|
|
540
550
|
} catch (error) {
|
|
541
|
-
console.
|
|
551
|
+
console.error(chalk.yellow(`Warning: Cannot read file ${normalizedPath}`));
|
|
542
552
|
return dependencies;
|
|
543
553
|
}
|
|
544
554
|
|
|
@@ -563,7 +573,7 @@ function collectDependencies(entryFile, baseDir, visited = new Set()) {
|
|
|
563
573
|
const subDeps = collectDependencies(depPath, baseDir, visited);
|
|
564
574
|
Object.assign(dependencies, subDeps);
|
|
565
575
|
} else {
|
|
566
|
-
console.
|
|
576
|
+
console.error(chalk.yellow(`Warning: Cannot resolve dependency "${dep}" from ${relativePath}`));
|
|
567
577
|
}
|
|
568
578
|
}
|
|
569
579
|
}
|
|
@@ -581,6 +591,60 @@ function collectDependenciesWithTree(entryFile, baseDir) {
|
|
|
581
591
|
return collectDependencies(entryFile, baseDir);
|
|
582
592
|
}
|
|
583
593
|
|
|
594
|
+
/**
|
|
595
|
+
* 将 label 转换为英文可用的 slug,用于生成 schemetableName
|
|
596
|
+
* 优先尝试使用 pinyin 包(如果安装),否则使用宽松的 ASCII slug 方案
|
|
597
|
+
*/
|
|
598
|
+
function labelToSlug(label) {
|
|
599
|
+
if (!label || typeof label !== 'string') return 'custom_object';
|
|
600
|
+
let s = label.trim();
|
|
601
|
+
const hasChinese = /[\u4E00-\u9FFF]/.test(s);
|
|
602
|
+
try {
|
|
603
|
+
// 如果有安装 pinyin 则优先使用
|
|
604
|
+
const pinyinModule = require('pinyin');
|
|
605
|
+
let pinyinFn = pinyinModule;
|
|
606
|
+
// 兼容不同导出方式(commonjs 或 default)
|
|
607
|
+
if (typeof pinyinFn !== 'function') {
|
|
608
|
+
if (typeof (pinyinModule.pinyin) === 'function') {
|
|
609
|
+
pinyinFn = pinyinModule.pinyin;
|
|
610
|
+
} else if (typeof (pinyinModule.default) === 'function') {
|
|
611
|
+
pinyinFn = pinyinModule.default;
|
|
612
|
+
}
|
|
613
|
+
}
|
|
614
|
+
const styleConsts = typeof pinyinModule === 'object' ? (pinyinModule.STYLE_FIRST_LETTER ? pinyinModule : (pinyinModule.pinyin || pinyinModule.default || {})) : pinyinModule;
|
|
615
|
+
if (hasChinese) {
|
|
616
|
+
// 获取拼音首字母
|
|
617
|
+
const arr = pinyinFn(s, { style: styleConsts.STYLE_FIRST_LETTER });
|
|
618
|
+
// pinyin 返回二维数组,每个中文字符或词的拼音以数组返回,合并为单字符串
|
|
619
|
+
s = arr.flat().join('');
|
|
620
|
+
} else {
|
|
621
|
+
// 非中文,先做 Unicode 正规化并去掉组合音符,这样像 Café 这种会变为 Cafe
|
|
622
|
+
s = s.normalize('NFKD').replace(/[\u0300-\u036f]/g, '');
|
|
623
|
+
// 使用正常拼音或英文分词下划线连接
|
|
624
|
+
const arr = pinyinFn(s, { style: styleConsts.STYLE_NORMAL });
|
|
625
|
+
s = arr.flat().join('_');
|
|
626
|
+
}
|
|
627
|
+
} catch (e) {
|
|
628
|
+
// 没有 pinyin 包,使用宽松的 ASCII slug
|
|
629
|
+
// 先做 Unicode 正规化并去掉组合音符
|
|
630
|
+
s = s.normalize('NFKD').replace(/[\u0300-\u036f]/g, '');
|
|
631
|
+
// 将非 ASCII 字符替换为其 Unicode 十六进制表示,避免 name 为空
|
|
632
|
+
s = s.replace(/[^\x00-\x7F]/g, ch => {
|
|
633
|
+
return '_' + ch.codePointAt(0).toString(16);
|
|
634
|
+
});
|
|
635
|
+
}
|
|
636
|
+
|
|
637
|
+
// 统一替换空白与非法字符为下划线,去重复下划线,去除首尾下划线
|
|
638
|
+
s = s.replace(/\s+/g, '_')
|
|
639
|
+
.replace(/[^a-zA-Z0-9_]/g, '_')
|
|
640
|
+
.replace(/_+/g, '_')
|
|
641
|
+
.replace(/^_+|_+$/g, '')
|
|
642
|
+
.toLowerCase();
|
|
643
|
+
|
|
644
|
+
if (!s) s = 'custom_object';
|
|
645
|
+
return s;
|
|
646
|
+
}
|
|
647
|
+
|
|
584
648
|
module.exports = {
|
|
585
649
|
getDevConsoleConfig,
|
|
586
650
|
javaContentRegular,
|
|
@@ -591,5 +655,6 @@ module.exports = {
|
|
|
591
655
|
collectDependenciesWithTree,
|
|
592
656
|
parseDependencies,
|
|
593
657
|
parseJsDependencies,
|
|
594
|
-
parseCssDependencies
|
|
658
|
+
parseCssDependencies,
|
|
659
|
+
labelToSlug
|
|
595
660
|
}
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
package com.cloudcc.core;
|
|
2
|
-
|
|
3
|
-
public interface CCTriggerDemo {
|
|
4
|
-
public void do_insert_before() throws Exception;
|
|
5
|
-
|
|
6
|
-
public void do_insert_after() throws Exception;
|
|
7
|
-
|
|
8
|
-
public void do_update_before() throws Exception;
|
|
9
|
-
|
|
10
|
-
public void do_update_after() throws Exception;
|
|
11
|
-
|
|
12
|
-
public void do_upsert_before() throws Exception;
|
|
13
|
-
|
|
14
|
-
public void do_upsert_after() throws Exception;
|
|
15
|
-
|
|
16
|
-
public void do_delete_before() throws Exception;
|
|
17
|
-
|
|
18
|
-
public void do_delete_after() throws Exception;
|
|
19
|
-
|
|
20
|
-
public void setRecordOldVal(String id);
|
|
21
|
-
|
|
22
|
-
public void do_approval() throws Exception;
|
|
23
|
-
|
|
24
|
-
public String getObjectApiName();
|
|
25
|
-
}
|
package/src/classes/create.js
DELETED
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
const { checkUpdate } = require("../../utils/checkVersion")
|
|
2
|
-
const fs = require("fs");
|
|
3
|
-
const path = require("path")
|
|
4
|
-
const chalk = require("chalk")
|
|
5
|
-
const { getPackageJson } = require("../../utils/config.js")
|
|
6
|
-
|
|
7
|
-
async function create(name) {
|
|
8
|
-
let res = await checkUpdate();
|
|
9
|
-
if (!res) {
|
|
10
|
-
const classesPath = path.join(process.cwd(), "classes/" + name);
|
|
11
|
-
try {
|
|
12
|
-
fs.mkdirSync(classesPath, { recursive: true })
|
|
13
|
-
const javaTmp =
|
|
14
|
-
`package classes.${name};
|
|
15
|
-
|
|
16
|
-
import com.cloudcc.core.*;
|
|
17
|
-
// @SOURCE_CONTENT_START
|
|
18
|
-
public class ${name}{
|
|
19
|
-
private UserInfo userInfo;
|
|
20
|
-
private CCService cs;
|
|
21
|
-
|
|
22
|
-
public ${name}(UserInfo userInfo){
|
|
23
|
-
this(userInfo,new CCService(userInfo));
|
|
24
|
-
}
|
|
25
|
-
public ${name}(UserInfo userInfo,CCService cs){
|
|
26
|
-
this.userInfo = userInfo;
|
|
27
|
-
this.cs=cs;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
public String getName(String str){
|
|
31
|
-
str = "demo";
|
|
32
|
-
return str;
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
// @SOURCE_CONTENT_END
|
|
36
|
-
`
|
|
37
|
-
const javaTestTmp =
|
|
38
|
-
`package classes.${name};
|
|
39
|
-
|
|
40
|
-
import com.cloudcc.core.*;
|
|
41
|
-
|
|
42
|
-
public class ${name}Test {
|
|
43
|
-
public static void main(String[] args) {
|
|
44
|
-
${name} obj = new ${name}(new UserInfo());
|
|
45
|
-
String name = obj.getName("test");
|
|
46
|
-
System.out.println("name:" + name);
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
`
|
|
50
|
-
fs.writeFileSync(path.join(classesPath, name + ".java"), javaTmp)
|
|
51
|
-
fs.writeFileSync(path.join(classesPath, name + "Test.java"), javaTestTmp)
|
|
52
|
-
let config = await getPackageJson();
|
|
53
|
-
fs.writeFileSync(path.join(classesPath, "config.json"), `{"name":"${name}","version":"${config.extandVersion || '2'}"}`)
|
|
54
|
-
console.log()
|
|
55
|
-
console.log(chalk.green("Successfully Created:" + name))
|
|
56
|
-
console.log()
|
|
57
|
-
} catch (e) {
|
|
58
|
-
console.log()
|
|
59
|
-
console.log(chalk.red("Creation Class Failed:" + e))
|
|
60
|
-
console.log()
|
|
61
|
-
throw new Error("Creation Class Failed: " + e);
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
module.exports = create;
|
package/src/classes/get.js
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
const { getPackageJson } = require("../../utils/config")
|
|
2
|
-
const { postClass } = require("../../utils/http")
|
|
3
|
-
|
|
4
|
-
async function get(arg, path) {
|
|
5
|
-
let body = JSON.parse(decodeURI(arg))
|
|
6
|
-
let config = await getPackageJson(path);
|
|
7
|
-
let res = await postClass(config.setupSvc + "/api/ccfag/list", body, config.accessToken)
|
|
8
|
-
if (res.result) {
|
|
9
|
-
const simpleList = (res.data.list || []).map(item => ({
|
|
10
|
-
apiname: item.apiname,
|
|
11
|
-
id: item.id,
|
|
12
|
-
name: item.name
|
|
13
|
-
}))
|
|
14
|
-
console.log(JSON.stringify(simpleList))
|
|
15
|
-
return res.data.list
|
|
16
|
-
} else {
|
|
17
|
-
console.error('error:', res.message);
|
|
18
|
-
throw new Error('Get Class Failed: ' + res.message);
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
module.exports = get;
|
package/src/classes/index.js
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
const cc = {}
|
|
2
|
-
cc.create = require("./create")
|
|
3
|
-
cc.publish = require("./publish")
|
|
4
|
-
cc.pull = require("./pull")
|
|
5
|
-
cc.get = require("./get")
|
|
6
|
-
cc.pullList = require("./pullList")
|
|
7
|
-
function Classes(action, argvs) {
|
|
8
|
-
cc[action](argvs[2], argvs[3])
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
module.exports = Classes;
|
package/src/classes/publish.js
DELETED
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
const { checkUpdate } = require("../../utils/checkVersion")
|
|
2
|
-
const fs = require("fs");
|
|
3
|
-
const path = require("path")
|
|
4
|
-
const chalk = require("chalk")
|
|
5
|
-
const { postClass } = require("../../utils/http")
|
|
6
|
-
|
|
7
|
-
const { javaContentRegular } = require("../../utils/utils")
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
const { getPackageJson } = require("../../utils/config")
|
|
11
|
-
|
|
12
|
-
async function publish(name) {
|
|
13
|
-
let res = await checkUpdate();
|
|
14
|
-
if (!res) {
|
|
15
|
-
console.log();
|
|
16
|
-
const now = new Date();
|
|
17
|
-
const timeStr = now.getFullYear() + '-' + String(now.getMonth() + 1).padStart(2, '0') + '-' + String(now.getDate()).padStart(2, '0') + ' ' + String(now.getHours()).padStart(2, '0') + ':' + String(now.getMinutes()).padStart(2, '0') + ':' + String(now.getSeconds()).padStart(2, '0');
|
|
18
|
-
console.log(chalk.green(timeStr));
|
|
19
|
-
console.log(chalk.green('Posting, please wait...'));
|
|
20
|
-
console.log();
|
|
21
|
-
const classPath = path.join(process.cwd(), `classes/${name}/`);
|
|
22
|
-
let fullContent = fs.readFileSync(classPath + `${name}.java`, 'utf8');
|
|
23
|
-
|
|
24
|
-
const sourceMatch = fullContent.match(javaContentRegular);
|
|
25
|
-
let classContent = sourceMatch ? sourceMatch[1] : fullContent;
|
|
26
|
-
let configContent = JSON.parse(fs.readFileSync(classPath + "config.json", 'utf8'));
|
|
27
|
-
|
|
28
|
-
let body = {
|
|
29
|
-
"id": configContent.id,
|
|
30
|
-
"name": name,
|
|
31
|
-
"source": encodeURIComponent(classContent.trim()),
|
|
32
|
-
"version": configContent.version || "2",
|
|
33
|
-
"folderId": "wgd"
|
|
34
|
-
}
|
|
35
|
-
let config = await getPackageJson();
|
|
36
|
-
let res = await postClass(config.setupSvc + "/api/ccfag/save", body, config.accessToken)
|
|
37
|
-
if (res.result) {
|
|
38
|
-
console.log(chalk.green('Success!'));
|
|
39
|
-
console.log();
|
|
40
|
-
|
|
41
|
-
if (!configContent.id) {
|
|
42
|
-
configContent.id = res.data
|
|
43
|
-
fs.writeFileSync(path.join(classPath, "config.json"), JSON.stringify(configContent))
|
|
44
|
-
}
|
|
45
|
-
} else {
|
|
46
|
-
console.log(chalk.red('Publish Class Failed:' + res.returnInfo));
|
|
47
|
-
throw new Error('Publish Class Failed: ' + res.returnInfo);
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
module.exports = publish;
|