yg-team-cli 2.3.2 → 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 +38 -20
- package/dist/cli.js.map +1 -1
- package/dist/index.js +38 -20
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
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"() {
|
|
@@ -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
|
|
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
|
|
2062
|
-
|
|
2063
|
-
|
|
2064
|
-
|
|
2065
|
-
|
|
2066
|
-
|
|
2067
|
-
|
|
2068
|
-
|
|
2069
|
-
|
|
2070
|
-
|
|
2071
|
-
|
|
2072
|
-
|
|
2073
|
-
|
|
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("
|
|
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: "\
|
|
2229
|
+
title: "\u514B\u9686\u524D\u7AEF\u6A21\u677F",
|
|
2217
2230
|
task: async () => {
|
|
2218
|
-
|
|
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 ? [
|