yg-team-cli 2.3.1 → 2.3.3

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 CHANGED
@@ -877,6 +877,12 @@ async function updateTemplateVersion(projectPath, type, commit, options) {
877
877
  config[type].lastUpdate = (/* @__PURE__ */ new Date()).toISOString();
878
878
  await saveTemplateConfig(projectPath, config);
879
879
  }
880
+ function getDefaultTemplates() {
881
+ return {
882
+ frontend: { ...DEFAULT_TEMPLATES.frontend },
883
+ backend: { ...DEFAULT_TEMPLATES.backend }
884
+ };
885
+ }
880
886
  var DEFAULT_TEMPLATES;
881
887
  var init_template_version = __esm({
882
888
  "src/lib/template-version.ts"() {
@@ -1391,22 +1397,22 @@ var init_gitlab_api = __esm({
1391
1397
  * 从 Git URL 中提取项目路径
1392
1398
  */
1393
1399
  static parseProjectPath(repository) {
1394
- let path19 = repository;
1395
- if (path19.startsWith("git@")) {
1396
- path19 = path19.replace(/^git@/, "");
1397
- const colonIndex = path19.indexOf(":");
1400
+ let path20 = repository;
1401
+ if (path20.startsWith("git@")) {
1402
+ path20 = path20.replace(/^git@/, "");
1403
+ const colonIndex = path20.indexOf(":");
1398
1404
  if (colonIndex !== -1) {
1399
- path19 = path19.substring(colonIndex + 1);
1405
+ path20 = path20.substring(colonIndex + 1);
1400
1406
  }
1401
1407
  } else {
1402
- path19 = path19.replace(/^https?:\/\//, "");
1403
- const parts = path19.split("/");
1408
+ path20 = path20.replace(/^https?:\/\//, "");
1409
+ const parts = path20.split("/");
1404
1410
  if (parts.length > 1) {
1405
- path19 = parts.slice(1).join("/");
1411
+ path20 = parts.slice(1).join("/");
1406
1412
  }
1407
1413
  }
1408
- path19 = path19.replace(/\.git$/, "");
1409
- return path19;
1414
+ path20 = path20.replace(/\.git$/, "");
1415
+ return path20;
1410
1416
  }
1411
1417
  /**
1412
1418
  * 编码项目路径用于 API 请求
@@ -1462,6 +1468,7 @@ import { Command } from "commander";
1462
1468
  import inquirer from "inquirer";
1463
1469
  import path7 from "path";
1464
1470
  import fs4 from "fs-extra";
1471
+ import os3 from "os";
1465
1472
  import { Listr } from "listr2";
1466
1473
  async function generateTechStack(projectPath) {
1467
1474
  const content = `# \u6280\u672F\u6808
@@ -2055,30 +2062,36 @@ async function cloneBackendTemplate(projectPath, versionOptions) {
2055
2062
  await FileUtils.ensureDir(path7.join(backendPath, "src/test/java"));
2056
2063
  }
2057
2064
  }
2058
- async function generateFrontendScaffold(projectPath) {
2065
+ async function cloneFrontendTemplate(projectPath, versionOptions = {}) {
2059
2066
  const frontendPath = path7.join(projectPath, "frontend");
2067
+ const templates = getDefaultTemplates();
2068
+ const repository = templates.frontend.repository;
2060
2069
  try {
2061
- const prompt = `Read TECH_STACK.md and CONVENTIONS.md.
2062
- Initialize a Next.js 14 frontend in ./frontend with:
2063
- - TypeScript
2064
- - Tailwind CSS
2065
- - App Router structure
2066
- - ESLint and Prettier configured
2067
- - Basic layout and page components
2068
-
2069
- Do not run any servers, just generate the folder structure and configuration files.`;
2070
- await claudeAI.prompt(prompt, {
2071
- contextFiles: [
2072
- path7.join(projectPath, "TECH_STACK.md"),
2073
- path7.join(projectPath, "CONVENTIONS.md")
2074
- ]
2070
+ const { execaCommand } = await import("execa");
2071
+ let latestTag = "";
2072
+ if (!versionOptions.tag && !versionOptions.branch) {
2073
+ latestTag = await getLatestTag(repository);
2074
+ }
2075
+ const targetVersion = versionOptions.branch || versionOptions.tag || latestTag;
2076
+ logger.info(`\u6B63\u5728\u514B\u9686\u524D\u7AEF\u6A21\u677F (${targetVersion || "HEAD"})...`);
2077
+ const tempDir = path7.join(os3.tmpdir(), `team-cli-fe-${Date.now()}`);
2078
+ await FileUtils.ensureDir(tempDir);
2079
+ const cloneCmd = targetVersion ? `git clone --depth 1 --branch ${targetVersion} ${repository} ${tempDir}` : `git clone --depth 1 ${repository} ${tempDir}`;
2080
+ await execaCommand(cloneCmd);
2081
+ const { stdout: commit } = await execaCommand("git rev-parse HEAD", { cwd: tempDir });
2082
+ await fs4.copy(tempDir, frontendPath, {
2083
+ filter: (src) => !src.includes(".git")
2084
+ });
2085
+ await fs4.remove(tempDir);
2086
+ await updateTemplateVersion(projectPath, "frontend", commit.trim(), {
2087
+ tag: versionOptions.tag || latestTag,
2088
+ branch: versionOptions.branch
2075
2089
  });
2090
+ logger.success("\u524D\u7AEF\u6A21\u677F\u514B\u9686\u5B8C\u6210");
2076
2091
  } catch (error) {
2077
- logger.warn("Claude \u751F\u6210\u524D\u7AEF\u5931\u8D25\uFF0C\u5C06\u521B\u5EFA\u57FA\u7840\u7ED3\u6784");
2092
+ logger.warn("\u514B\u9686\u524D\u7AEF\u6A21\u677F\u5931\u8D25\uFF0C\u5C06\u521B\u5EFA\u57FA\u7840\u7ED3\u6784");
2078
2093
  await FileUtils.ensureDir(path7.join(frontendPath, "src/app"));
2079
2094
  await FileUtils.ensureDir(path7.join(frontendPath, "src/components"));
2080
- await FileUtils.ensureDir(path7.join(frontendPath, "src/lib"));
2081
- await FileUtils.ensureDir(path7.join(frontendPath, "public"));
2082
2095
  }
2083
2096
  }
2084
2097
  async function generateDockerFiles() {
@@ -2213,9 +2226,14 @@ var init_init = __esm({
2213
2226
  }
2214
2227
  },
2215
2228
  {
2216
- title: "\u751F\u6210\u524D\u7AEF\u811A\u624B\u67B6",
2229
+ title: "\u514B\u9686\u524D\u7AEF\u6A21\u677F",
2217
2230
  task: async () => {
2218
- await generateFrontendScaffold(projectPath);
2231
+ const frontendTag = options.frontendTag || options.tag;
2232
+ const frontendBranch = options.frontendBranch;
2233
+ await cloneFrontendTemplate(projectPath, {
2234
+ tag: frontendTag,
2235
+ branch: frontendBranch
2236
+ });
2219
2237
  }
2220
2238
  },
2221
2239
  ...options.docker ? [
@@ -4863,15 +4881,15 @@ async function syncTemplateVersions(aiMemoryFile, projectDir) {
4863
4881
  await replaceOrInsertSection(aiMemoryFile, "## \u6A21\u677F\u7248\u672C\u4FE1\u606F", newContent);
4864
4882
  }
4865
4883
  function extractRepoName(repository) {
4866
- let path19 = repository;
4867
- path19 = path19.replace(/^https?:\/\//, "");
4868
- path19 = path19.replace(/^git@/, "");
4869
- const parts = path19.split("/");
4884
+ let path20 = repository;
4885
+ path20 = path20.replace(/^https?:\/\//, "");
4886
+ path20 = path20.replace(/^git@/, "");
4887
+ const parts = path20.split("/");
4870
4888
  if (parts.length > 1) {
4871
- path19 = parts.slice(1).join("/");
4889
+ path20 = parts.slice(1).join("/");
4872
4890
  }
4873
- path19 = path19.replace(/\.git$/, "");
4874
- return path19;
4891
+ path20 = path20.replace(/\.git$/, "");
4892
+ return path20;
4875
4893
  }
4876
4894
  var syncMemoryCommand;
4877
4895
  var init_sync_memory = __esm({
@@ -5163,10 +5181,10 @@ function extractApisFromRegistry(registryContent) {
5163
5181
  let match;
5164
5182
  while ((match = apiRegex.exec(registryContent)) !== null) {
5165
5183
  const method = match[1];
5166
- const path19 = match[2].trim();
5184
+ const path20 = match[2].trim();
5167
5185
  const description = match[3].trim();
5168
- const key = `${method}:${path19}`;
5169
- apis.set(key, { method, path: path19, description });
5186
+ const key = `${method}:${path20}`;
5187
+ apis.set(key, { method, path: path20, description });
5170
5188
  }
5171
5189
  return apis;
5172
5190
  }
@@ -6078,6 +6096,9 @@ var init_diff = __esm({
6078
6096
  var index_exports = {};
6079
6097
  import { Command as Command16 } from "commander";
6080
6098
  import chalk4 from "chalk";
6099
+ import fs6 from "fs-extra";
6100
+ import path19 from "path";
6101
+ import { fileURLToPath as fileURLToPath2 } from "url";
6081
6102
  function showHelp() {
6082
6103
  console.log("");
6083
6104
  logger.header("team-cli - AI-Native \u56E2\u961F\u7814\u53D1\u811A\u624B\u67B6");
@@ -6132,7 +6153,7 @@ function showHelp() {
6132
6153
  console.log(chalk4.gray("\u66F4\u591A\u4FE1\u606F: https://github.com/yungu/team-cli"));
6133
6154
  console.log("");
6134
6155
  }
6135
- var program;
6156
+ var __dirname2, pkg, program;
6136
6157
  var init_index = __esm({
6137
6158
  "src/index.ts"() {
6138
6159
  "use strict";
@@ -6154,8 +6175,10 @@ var init_index = __esm({
6154
6175
  init_update();
6155
6176
  init_config();
6156
6177
  init_diff();
6178
+ __dirname2 = path19.dirname(fileURLToPath2(import.meta.url));
6179
+ pkg = fs6.readJsonSync(path19.join(__dirname2, "../package.json"));
6157
6180
  program = new Command16();
6158
- program.name("team-cli").description("AI-Native \u56E2\u961F\u7814\u53D1\u811A\u624B\u67B6").version("2.1.9");
6181
+ program.name("team-cli").description("AI-Native \u56E2\u961F\u7814\u53D1\u811A\u624B\u67B6").version(pkg.version);
6159
6182
  program.option("-v, --verbose", "\u8BE6\u7EC6\u8F93\u51FA\u6A21\u5F0F").option("--debug", "\u8C03\u8BD5\u6A21\u5F0F");
6160
6183
  program.addCommand(initCommand);
6161
6184
  program.addCommand(splitPrdCommand);