cloudcc-cli 2.2.2 → 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 +47 -0
- package/bin/cc.js +11 -35
- package/bin/index.js +33 -0
- package/bin/mcp-svc.js +13 -0
- package/bin/mcp.js +18 -0
- package/java/com/cloudcc/core/TriggerInvoker.java +17 -1
- package/package.json +16 -7
- 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 +631 -0
- package/src/mcp/readme.md +137 -0
- 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 Publisher/prompt.js +659 -0
- package/src/mcp/tools/Component Puller/handler.js +63 -0
- package/src/mcp/tools/Dev Environment Creator/fetcher.js +500 -0
- package/src/mcp/tools/Dev Environment Creator/handler.js +92 -0
- package/src/mcp/tools/Dev Environment Creator/prompt.js +273 -0
- 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/Developer Key Setup Guide/fetcher.js +278 -0
- package/src/mcp/tools/Developer Key Setup Guide/handler.js +43 -0
- package/src/mcp/tools/Developer Key Setup Guide/prompt.js +71 -0
- 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 +18 -0
- package/src/mcp/tools/ccdk/handler.js +98 -0
- package/src/mcp/tools/ccdk/prompt.js +453 -0
- 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/create.js +1 -2
- package/src/plugin/create1.js +9 -9
- 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 +33 -24
- 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 +452 -12
- 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 +128 -40
- package/java/com/cloudcc/core/CCTriggerDemo.java +0 -25
- package/src/classes/create.js +0 -65
- package/src/classes/get.js +0 -21
- package/src/classes/index.js +0 -11
- package/src/classes/publish.js +0 -50
- package/src/classes/pull.js +0 -54
- package/src/classes/pullList.js +0 -44
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
|
|
|
@@ -21,7 +21,12 @@ const formateData = (data, header = { appVersion: "1.0.0" }) => {
|
|
|
21
21
|
* @param {object} config 配置参数
|
|
22
22
|
*/
|
|
23
23
|
async function getBaseUrl(config) {
|
|
24
|
-
|
|
24
|
+
// 如果已经有apiSvc和setupSvc则直接返回
|
|
25
|
+
if (config.apiSvc && config.setupSvc) {
|
|
26
|
+
return config;
|
|
27
|
+
}
|
|
28
|
+
// 优先使用baseUrl,其次使用orgId获取
|
|
29
|
+
else if (config.baseUrl) {
|
|
25
30
|
config.apiSvc = config.baseUrl + (config.apiSvcPrefix || "/apisvc")
|
|
26
31
|
config.setupSvc = config.baseUrl + (config.setupSvcPrefix || "/setup")
|
|
27
32
|
} else if (config.orgId) {
|
|
@@ -119,7 +124,7 @@ async function getSecretKey(config) {
|
|
|
119
124
|
config.secretKey = response.data.data.secretKey;
|
|
120
125
|
return config;
|
|
121
126
|
} catch (error) {
|
|
122
|
-
console.
|
|
127
|
+
console.error(chalk.red('Get Plugin SecretKey Failed:', error.message));
|
|
123
128
|
process.exit(1)
|
|
124
129
|
}
|
|
125
130
|
}
|
|
@@ -132,7 +137,17 @@ async function getDevConsoleConfig(projectPath = process.cwd(), config) {
|
|
|
132
137
|
config = await getPluginToken(config);
|
|
133
138
|
}
|
|
134
139
|
config.timestamp = Date.now();
|
|
135
|
-
|
|
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
|
+
}
|
|
136
151
|
return config;
|
|
137
152
|
}
|
|
138
153
|
|
|
@@ -183,25 +198,43 @@ try {
|
|
|
183
198
|
*/
|
|
184
199
|
function parseVueDataFunction(vueContent) {
|
|
185
200
|
// if (!babelParser || !babelTraverse) {
|
|
186
|
-
// console.
|
|
187
|
-
// console.
|
|
188
|
-
// console.
|
|
189
|
-
// console.
|
|
190
|
-
// 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..."));
|
|
191
206
|
// return parseVueDataFunctionWithRegex(vueContent);
|
|
192
207
|
// }
|
|
193
208
|
|
|
194
209
|
try {
|
|
195
|
-
// 提取 <script>
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
210
|
+
// 提取 <script> 标签中的内容,排除带 src 属性的外部脚本
|
|
211
|
+
// 匹配所有 script 标签
|
|
212
|
+
const scriptRegex = /<script([^>]*)>([\s\S]*?)<\/script>/g;
|
|
213
|
+
let scriptContent = null;
|
|
214
|
+
let match;
|
|
215
|
+
|
|
216
|
+
while ((match = scriptRegex.exec(vueContent)) !== null) {
|
|
217
|
+
const attributes = match[1];
|
|
218
|
+
const content = match[2];
|
|
219
|
+
|
|
220
|
+
// 跳过带 src 属性的外部脚本标签
|
|
221
|
+
if (attributes && attributes.includes('src=')) {
|
|
222
|
+
continue;
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
// 查找包含 export default 的 script 标签
|
|
226
|
+
if (content && content.includes('export default')) {
|
|
227
|
+
scriptContent = content;
|
|
228
|
+
break;
|
|
229
|
+
}
|
|
202
230
|
}
|
|
203
231
|
|
|
204
|
-
|
|
232
|
+
if (!scriptContent) {
|
|
233
|
+
console.error()
|
|
234
|
+
console.error(chalk.red("Error: Cannot find <script> tag with component code in the vue file."));
|
|
235
|
+
console.error()
|
|
236
|
+
return null;
|
|
237
|
+
}
|
|
205
238
|
|
|
206
239
|
// 使用 Babel 解析 JavaScript 代码
|
|
207
240
|
const ast = babelParser.parse(scriptContent, {
|
|
@@ -215,7 +248,7 @@ function parseVueDataFunction(vueContent) {
|
|
|
215
248
|
babelTraverse(ast, {
|
|
216
249
|
ObjectMethod(path) {
|
|
217
250
|
// 查找名为 data 的方法
|
|
218
|
-
if (path.node.key.name === 'data' && path.node.params.length === 0) {
|
|
251
|
+
if (path.node.key && path.node.key.name === 'data' && path.node.params.length === 0) {
|
|
219
252
|
// 查找 return 语句
|
|
220
253
|
path.traverse({
|
|
221
254
|
ReturnStatement(returnPath) {
|
|
@@ -231,7 +264,7 @@ function parseVueDataFunction(vueContent) {
|
|
|
231
264
|
},
|
|
232
265
|
// 也处理 data: function() {} 的形式
|
|
233
266
|
ObjectProperty(path) {
|
|
234
|
-
if (path.node.key.name === 'data' &&
|
|
267
|
+
if (path.node.key && path.node.key.name === 'data' &&
|
|
235
268
|
(path.node.value.type === 'FunctionExpression' || path.node.value.type === 'ArrowFunctionExpression')) {
|
|
236
269
|
// 查找 return 语句
|
|
237
270
|
path.traverse({
|
|
@@ -248,19 +281,19 @@ function parseVueDataFunction(vueContent) {
|
|
|
248
281
|
});
|
|
249
282
|
|
|
250
283
|
if (!dataObject) {
|
|
251
|
-
console.
|
|
252
|
-
console.
|
|
253
|
-
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()
|
|
254
287
|
return null;
|
|
255
288
|
}
|
|
256
289
|
|
|
257
290
|
return dataObject;
|
|
258
291
|
|
|
259
292
|
} catch (e) {
|
|
260
|
-
console.
|
|
261
|
-
console.
|
|
262
|
-
console.
|
|
263
|
-
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()
|
|
264
297
|
return null;
|
|
265
298
|
}
|
|
266
299
|
}
|
|
@@ -279,7 +312,7 @@ function astToObject(node) {
|
|
|
279
312
|
obj[key] = astToValue(prop.value);
|
|
280
313
|
} else if (prop.type === 'SpreadElement') {
|
|
281
314
|
// 处理展开运算符 {...obj}
|
|
282
|
-
console.
|
|
315
|
+
console.error(chalk.yellow("Warning: Spread operator is not fully supported in data object."));
|
|
283
316
|
}
|
|
284
317
|
}
|
|
285
318
|
return obj;
|
|
@@ -328,9 +361,9 @@ function parseVueDataFunctionWithRegex(vueContent) {
|
|
|
328
361
|
// 匹配 data() 函数,找到开始位置
|
|
329
362
|
const dataStartMatch = vueContent.match(/data\s*\(\s*\)\s*\{[\s\S]*?return\s*\{/);
|
|
330
363
|
if (!dataStartMatch) {
|
|
331
|
-
console.
|
|
332
|
-
console.
|
|
333
|
-
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()
|
|
334
367
|
return null;
|
|
335
368
|
}
|
|
336
369
|
|
|
@@ -351,9 +384,9 @@ function parseVueDataFunctionWithRegex(vueContent) {
|
|
|
351
384
|
}
|
|
352
385
|
|
|
353
386
|
if (braceCount !== 0) {
|
|
354
|
-
console.
|
|
355
|
-
console.
|
|
356
|
-
console.
|
|
387
|
+
console.error()
|
|
388
|
+
console.error(chalk.red("Error: Cannot parse data() function, unmatched braces."));
|
|
389
|
+
console.error()
|
|
357
390
|
return null;
|
|
358
391
|
}
|
|
359
392
|
|
|
@@ -366,10 +399,10 @@ function parseVueDataFunctionWithRegex(vueContent) {
|
|
|
366
399
|
return dataFunc();
|
|
367
400
|
|
|
368
401
|
} catch (e) {
|
|
369
|
-
console.
|
|
370
|
-
console.
|
|
371
|
-
console.
|
|
372
|
-
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()
|
|
373
406
|
return null;
|
|
374
407
|
}
|
|
375
408
|
}
|
|
@@ -515,7 +548,7 @@ function collectDependencies(entryFile, baseDir, visited = new Set()) {
|
|
|
515
548
|
try {
|
|
516
549
|
fileContent = fs.readFileSync(normalizedPath, 'utf8');
|
|
517
550
|
} catch (error) {
|
|
518
|
-
console.
|
|
551
|
+
console.error(chalk.yellow(`Warning: Cannot read file ${normalizedPath}`));
|
|
519
552
|
return dependencies;
|
|
520
553
|
}
|
|
521
554
|
|
|
@@ -540,7 +573,7 @@ function collectDependencies(entryFile, baseDir, visited = new Set()) {
|
|
|
540
573
|
const subDeps = collectDependencies(depPath, baseDir, visited);
|
|
541
574
|
Object.assign(dependencies, subDeps);
|
|
542
575
|
} else {
|
|
543
|
-
console.
|
|
576
|
+
console.error(chalk.yellow(`Warning: Cannot resolve dependency "${dep}" from ${relativePath}`));
|
|
544
577
|
}
|
|
545
578
|
}
|
|
546
579
|
}
|
|
@@ -558,6 +591,60 @@ function collectDependenciesWithTree(entryFile, baseDir) {
|
|
|
558
591
|
return collectDependencies(entryFile, baseDir);
|
|
559
592
|
}
|
|
560
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
|
+
|
|
561
648
|
module.exports = {
|
|
562
649
|
getDevConsoleConfig,
|
|
563
650
|
javaContentRegular,
|
|
@@ -568,5 +655,6 @@ module.exports = {
|
|
|
568
655
|
collectDependenciesWithTree,
|
|
569
656
|
parseDependencies,
|
|
570
657
|
parseJsDependencies,
|
|
571
|
-
parseCssDependencies
|
|
658
|
+
parseCssDependencies,
|
|
659
|
+
labelToSlug
|
|
572
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,65 +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
|
-
}
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
module.exports = create;
|
package/src/classes/get.js
DELETED
|
@@ -1,21 +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
|
-
}
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
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,50 +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
|
-
}
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
module.exports = publish;
|