yg-team-cli 2.3.9 → 2.3.11
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/dist/cli.js +36 -53
- package/dist/cli.js.map +1 -1
- package/dist/index.js +36 -53
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -903,7 +903,6 @@ var init_template_version = __esm({
|
|
|
903
903
|
|
|
904
904
|
// src/lib/module-registry.ts
|
|
905
905
|
import path5 from "path";
|
|
906
|
-
import fs3 from "fs-extra";
|
|
907
906
|
var ModuleManager;
|
|
908
907
|
var init_module_registry = __esm({
|
|
909
908
|
"src/lib/module-registry.ts"() {
|
|
@@ -976,17 +975,18 @@ var init_module_registry = __esm({
|
|
|
976
975
|
}
|
|
977
976
|
}
|
|
978
977
|
if (module.type === "local" && module.backendFragments) {
|
|
979
|
-
const
|
|
980
|
-
const
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
978
|
+
const backendJavaDir = path5.join(projectPath, "backend/src/main/java");
|
|
979
|
+
const commonBasePath = path5.join(backendJavaDir, "org/yungu/common");
|
|
980
|
+
for (const fragment of module.backendFragments) {
|
|
981
|
+
const sourcePath = path5.join(templatesDir, "modules", fragment.source);
|
|
982
|
+
const targetPath = path5.join(commonBasePath, fragment.target);
|
|
983
|
+
if (await FileUtils.exists(sourcePath)) {
|
|
984
|
+
await FileUtils.ensureDir(path5.dirname(targetPath));
|
|
985
|
+
let content = await FileUtils.read(sourcePath);
|
|
986
|
+
const targetPackage = "org.yungu.common." + path5.dirname(fragment.target).replace(/\//g, ".");
|
|
987
|
+
content = content.replace(/^package\s+[^;]+;/m, `package ${targetPackage};`);
|
|
988
|
+
await FileUtils.write(targetPath, content);
|
|
989
|
+
addedFiles.push(path5.relative(projectPath, targetPath));
|
|
990
990
|
}
|
|
991
991
|
}
|
|
992
992
|
} else if (module.type === "remote") {
|
|
@@ -1009,27 +1009,6 @@ var init_module_registry = __esm({
|
|
|
1009
1009
|
`;
|
|
1010
1010
|
await FileUtils.write(targetPath, content);
|
|
1011
1011
|
}
|
|
1012
|
-
/**
|
|
1013
|
-
* 自动探测项目的 Base Package
|
|
1014
|
-
*/
|
|
1015
|
-
static async findBasePackage(searchDir) {
|
|
1016
|
-
if (!await FileUtils.exists(searchDir)) return null;
|
|
1017
|
-
const files = await FileUtils.findFiles("**/Application.java", searchDir);
|
|
1018
|
-
if (files.length > 0) {
|
|
1019
|
-
return path5.dirname(path5.join(searchDir, files[0]));
|
|
1020
|
-
}
|
|
1021
|
-
let current = searchDir;
|
|
1022
|
-
while (true) {
|
|
1023
|
-
const items = await fs3.readdir(current);
|
|
1024
|
-
const dirs = items.filter((c) => fs3.statSync(path5.join(current, c)).isDirectory());
|
|
1025
|
-
if (dirs.length === 1 && !["model", "controller", "service", "mapper", "config", "common"].includes(dirs[0])) {
|
|
1026
|
-
current = path5.join(current, dirs[0]);
|
|
1027
|
-
} else {
|
|
1028
|
-
break;
|
|
1029
|
-
}
|
|
1030
|
-
}
|
|
1031
|
-
return current;
|
|
1032
|
-
}
|
|
1033
1012
|
};
|
|
1034
1013
|
}
|
|
1035
1014
|
});
|
|
@@ -1472,7 +1451,7 @@ var init_gitlab_api = __esm({
|
|
|
1472
1451
|
import { Command } from "commander";
|
|
1473
1452
|
import inquirer from "inquirer";
|
|
1474
1453
|
import path7 from "path";
|
|
1475
|
-
import
|
|
1454
|
+
import fs3 from "fs-extra";
|
|
1476
1455
|
import os3 from "os";
|
|
1477
1456
|
import { Listr } from "listr2";
|
|
1478
1457
|
async function generateTechStack(projectPath) {
|
|
@@ -2051,10 +2030,10 @@ async function cloneBackendTemplate(projectPath, versionOptions) {
|
|
|
2051
2030
|
stdio: "pipe"
|
|
2052
2031
|
});
|
|
2053
2032
|
const latestTag = tags.split("\n")[0] || void 0;
|
|
2054
|
-
await
|
|
2033
|
+
await fs3.copy(tempDir, backendPath, {
|
|
2055
2034
|
filter: (src) => !src.includes(".git")
|
|
2056
2035
|
});
|
|
2057
|
-
await
|
|
2036
|
+
await fs3.remove(tempDir);
|
|
2058
2037
|
const gitDir = path7.join(backendPath, ".git");
|
|
2059
2038
|
if (await FileUtils.exists(gitDir)) {
|
|
2060
2039
|
await FileUtils.remove(gitDir);
|
|
@@ -2092,10 +2071,10 @@ async function cloneFrontendTemplate(projectPath, versionOptions = {}) {
|
|
|
2092
2071
|
cloneArgs.push(repository, tempDir);
|
|
2093
2072
|
await e("git", cloneArgs);
|
|
2094
2073
|
const { stdout: commit } = await e("git", ["rev-parse", "HEAD"], { cwd: tempDir });
|
|
2095
|
-
await
|
|
2074
|
+
await fs3.copy(tempDir, frontendPath, {
|
|
2096
2075
|
filter: (src) => !src.includes(".git")
|
|
2097
2076
|
});
|
|
2098
|
-
await
|
|
2077
|
+
await fs3.remove(tempDir);
|
|
2099
2078
|
await updateTemplateVersion(projectPath, "frontend", commit.trim(), {
|
|
2100
2079
|
tag: versionOptions.tag || latestTag,
|
|
2101
2080
|
branch: versionOptions.branch
|
|
@@ -2146,9 +2125,9 @@ docker push \${REGISTRY}/\${PROJECT_NAME}:latest
|
|
|
2146
2125
|
|
|
2147
2126
|
echo "\u2705 \u90E8\u7F72\u5B8C\u6210! \u955C\u50CF\u5730\u5740: \${REGISTRY}/\${IMAGE_TAG}"
|
|
2148
2127
|
`;
|
|
2149
|
-
await
|
|
2150
|
-
await
|
|
2151
|
-
await
|
|
2128
|
+
await fs3.writeFile(path7.join(backendPath, "Dockerfile"), dockerfile);
|
|
2129
|
+
await fs3.writeFile(path7.join(backendPath, "deploy.sh"), deploySh);
|
|
2130
|
+
await fs3.chmod(path7.join(backendPath, "deploy.sh"), 493);
|
|
2152
2131
|
}
|
|
2153
2132
|
async function initGit(projectPath, projectName) {
|
|
2154
2133
|
try {
|
|
@@ -2326,10 +2305,14 @@ var init_init = __esm({
|
|
|
2326
2305
|
prompt,
|
|
2327
2306
|
"--add-dir",
|
|
2328
2307
|
projectPath,
|
|
2329
|
-
"--dangerously-skip-permissions"
|
|
2308
|
+
"--dangerously-skip-permissions",
|
|
2309
|
+
"--output-format",
|
|
2310
|
+
"text"
|
|
2330
2311
|
], {
|
|
2331
2312
|
stdio: "inherit",
|
|
2332
|
-
timeout: 6e5
|
|
2313
|
+
timeout: 6e5,
|
|
2314
|
+
env: { ...process.env, FORCE_COLOR: "1" }
|
|
2315
|
+
// 保持颜色输出
|
|
2333
2316
|
});
|
|
2334
2317
|
logger.success(`[${module.name}] \u4EE3\u7801\u751F\u6210\u5B8C\u6210`);
|
|
2335
2318
|
} catch (err) {
|
|
@@ -5440,7 +5423,7 @@ import { Command as Command13 } from "commander";
|
|
|
5440
5423
|
import path18 from "path";
|
|
5441
5424
|
import { execa as execa4 } from "execa";
|
|
5442
5425
|
import inquirer9 from "inquirer";
|
|
5443
|
-
import
|
|
5426
|
+
import fs4 from "fs-extra";
|
|
5444
5427
|
async function performUpdate(projectPath, updates) {
|
|
5445
5428
|
logger.newLine();
|
|
5446
5429
|
logger.info("\u5F00\u59CB\u66F4\u65B0\u6A21\u677F...");
|
|
@@ -5479,7 +5462,7 @@ async function performUpdate(projectPath, updates) {
|
|
|
5479
5462
|
}
|
|
5480
5463
|
const ref = updateOptions?.tag || updateOptions?.branch || "HEAD";
|
|
5481
5464
|
const backupDir = path18.join(projectPath, `.backup-${Date.now()}`);
|
|
5482
|
-
await
|
|
5465
|
+
await fs4.copy(targetPath, path18.join(backupDir, targetDir));
|
|
5483
5466
|
logger.info(`\u5DF2\u521B\u5EFA\u5907\u4EFD: ${backupDir}`);
|
|
5484
5467
|
if (updateOptions?.dryRun) {
|
|
5485
5468
|
logger.info("[Dry Run] \u5C06\u4F1A\u66F4\u65B0\u5230\u4EE5\u4E0B\u7248\u672C:");
|
|
@@ -5508,15 +5491,15 @@ async function performUpdate(projectPath, updates) {
|
|
|
5508
5491
|
if (!keepFiles.includes(file)) {
|
|
5509
5492
|
const filePath = path18.join(targetPath, file);
|
|
5510
5493
|
try {
|
|
5511
|
-
await
|
|
5494
|
+
await fs4.remove(filePath);
|
|
5512
5495
|
} catch {
|
|
5513
5496
|
}
|
|
5514
5497
|
}
|
|
5515
5498
|
}
|
|
5516
|
-
await
|
|
5499
|
+
await fs4.copy(tempDir, targetPath, {
|
|
5517
5500
|
filter: (src) => !src.includes(".git")
|
|
5518
5501
|
});
|
|
5519
|
-
await
|
|
5502
|
+
await fs4.remove(tempDir);
|
|
5520
5503
|
await updateTemplateVersion(projectPath, type, commit.trim(), {
|
|
5521
5504
|
tag: updateOptions?.tag || latestTag,
|
|
5522
5505
|
branch: updateOptions?.branch
|
|
@@ -5527,9 +5510,9 @@ async function performUpdate(projectPath, updates) {
|
|
|
5527
5510
|
} catch (error) {
|
|
5528
5511
|
logger.error(`\u66F4\u65B0\u5931\u8D25: ${error.message}`);
|
|
5529
5512
|
logger.info("\u6B63\u5728\u6062\u590D\u5907\u4EFD...");
|
|
5530
|
-
await
|
|
5531
|
-
await
|
|
5532
|
-
await
|
|
5513
|
+
await fs4.remove(targetPath);
|
|
5514
|
+
await fs4.copy(path18.join(backupDir, targetDir), targetPath);
|
|
5515
|
+
await fs4.remove(backupDir);
|
|
5533
5516
|
logger.info("\u5DF2\u6062\u590D\u5230\u66F4\u65B0\u524D\u7684\u72B6\u6001");
|
|
5534
5517
|
}
|
|
5535
5518
|
}
|
|
@@ -6133,7 +6116,7 @@ var init_diff = __esm({
|
|
|
6133
6116
|
var index_exports = {};
|
|
6134
6117
|
import { Command as Command16 } from "commander";
|
|
6135
6118
|
import chalk4 from "chalk";
|
|
6136
|
-
import
|
|
6119
|
+
import fs5 from "fs-extra";
|
|
6137
6120
|
import path19 from "path";
|
|
6138
6121
|
import { fileURLToPath as fileURLToPath2 } from "url";
|
|
6139
6122
|
function showHelp() {
|
|
@@ -6213,7 +6196,7 @@ var init_index = __esm({
|
|
|
6213
6196
|
init_config();
|
|
6214
6197
|
init_diff();
|
|
6215
6198
|
__dirname2 = path19.dirname(fileURLToPath2(import.meta.url));
|
|
6216
|
-
pkg =
|
|
6199
|
+
pkg = fs5.readJsonSync(path19.join(__dirname2, "../package.json"));
|
|
6217
6200
|
program = new Command16();
|
|
6218
6201
|
program.name("team-cli").description("AI-Native \u56E2\u961F\u7814\u53D1\u811A\u624B\u67B6").version(pkg.version);
|
|
6219
6202
|
program.option("-v, --verbose", "\u8BE6\u7EC6\u8F93\u51FA\u6A21\u5F0F").option("--debug", "\u8C03\u8BD5\u6A21\u5F0F");
|