zero-ai 1.0.72 → 1.0.73
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/package.json +1 -1
- package/src/commander-ai/fn.perm.js +28 -8
package/package.json
CHANGED
|
@@ -7,12 +7,13 @@ const REF_ROLE_ID = "e501b47a-c08b-4c83-b12b-95ad82873e96";
|
|
|
7
7
|
const REQUIRED_ENV_KEYS = ["Z_DB_TYPE", "Z_DBS_INSTANCE", "Z_DB_APP_USER", "Z_DB_APP_PASS"];
|
|
8
8
|
|
|
9
9
|
/**
|
|
10
|
-
* 从 pom.xml
|
|
10
|
+
* 从 pom.xml 读取当前项目的 artifactId(排除 <parent> 内的)
|
|
11
11
|
*/
|
|
12
12
|
function getArtifactIdFromPom(cwd) {
|
|
13
13
|
const pomPath = path.resolve(cwd, "pom.xml");
|
|
14
14
|
if (!fs.existsSync(pomPath)) return null;
|
|
15
|
-
|
|
15
|
+
let content = fs.readFileSync(pomPath, "utf-8");
|
|
16
|
+
content = content.replace(/<parent>[\s\S]*?<\/parent>/i, "");
|
|
16
17
|
const m = content.match(/<artifactId>([^<]+)<\/artifactId>/);
|
|
17
18
|
return m ? m[1].trim() : null;
|
|
18
19
|
}
|
|
@@ -34,15 +35,26 @@ function loadAppEnv(filePath) {
|
|
|
34
35
|
}
|
|
35
36
|
|
|
36
37
|
/**
|
|
37
|
-
* 解析 .r2mo/app.env 路径:
|
|
38
|
+
* 解析 .r2mo/app.env 路径:
|
|
39
|
+
* ONE:当前目录 .r2mo/app.env
|
|
40
|
+
* DPA:{id}-api/.r2mo/app.env,id 来自 pom.xml 或当前目录名
|
|
41
|
+
* 支持两种布局:api 在项目内 (cwd/{id}-api) 或 与项目并列 (cwd/../{id}-api)
|
|
38
42
|
*/
|
|
39
43
|
function resolveAppEnvPath(cwd) {
|
|
40
44
|
const primary = path.resolve(cwd, ".r2mo", "app.env");
|
|
41
45
|
if (fs.existsSync(primary)) return primary;
|
|
42
|
-
|
|
46
|
+
|
|
47
|
+
let artifactId = getArtifactIdFromPom(cwd);
|
|
48
|
+
if (!artifactId) {
|
|
49
|
+
const base = path.basename(cwd);
|
|
50
|
+
if (base && base !== ".") artifactId = base;
|
|
51
|
+
}
|
|
43
52
|
if (artifactId) {
|
|
44
|
-
const
|
|
45
|
-
|
|
53
|
+
const apiDir = `${artifactId}-api`;
|
|
54
|
+
const nested = path.resolve(cwd, apiDir, ".r2mo", "app.env");
|
|
55
|
+
if (fs.existsSync(nested)) return nested;
|
|
56
|
+
const sibling = path.resolve(cwd, "..", apiDir, ".r2mo", "app.env");
|
|
57
|
+
if (fs.existsSync(sibling)) return sibling;
|
|
46
58
|
}
|
|
47
59
|
return null;
|
|
48
60
|
}
|
|
@@ -62,8 +74,16 @@ module.exports = async (options) => {
|
|
|
62
74
|
const cwd = process.cwd();
|
|
63
75
|
const appEnvPath = resolveAppEnvPath(cwd);
|
|
64
76
|
if (!appEnvPath) {
|
|
65
|
-
|
|
66
|
-
|
|
77
|
+
const tried = [path.resolve(cwd, ".r2mo", "app.env")];
|
|
78
|
+
const id = getArtifactIdFromPom(cwd) || path.basename(cwd);
|
|
79
|
+
if (id) {
|
|
80
|
+
tried.push(path.resolve(cwd, `${id}-api`, ".r2mo", "app.env"));
|
|
81
|
+
tried.push(path.resolve(cwd, "..", `${id}-api`, ".r2mo", "app.env"));
|
|
82
|
+
}
|
|
83
|
+
Ec.error(".r2mo/app.env 不存在;DPA 下也未找到 {id}-api/.r2mo/app.env");
|
|
84
|
+
Ec.info("已尝试路径(id=" + (id || "未解析") + "):");
|
|
85
|
+
tried.forEach((p) => Ec.info(` - ${p}`));
|
|
86
|
+
Ec.info("请确认:1) 在项目根执行 2) 存在 .r2mo/app.env 或 {id}-api/.r2mo/app.env(嵌套或与项目并列)");
|
|
67
87
|
process.exit(1);
|
|
68
88
|
}
|
|
69
89
|
loadAppEnv(appEnvPath);
|