@lark-apaas/fullstack-cli 1.1.47-alpha.0 → 1.1.47-alpha.2

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.
Files changed (2) hide show
  1. package/dist/index.js +57 -36
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -2370,9 +2370,8 @@ import fs7 from "fs";
2370
2370
  import { fileURLToPath as fileURLToPath3 } from "url";
2371
2371
 
2372
2372
  // src/config/sync.ts
2373
- var syncConfig = {
2374
- // 派生规则
2375
- sync: [
2373
+ function buildDefaultRules(opts) {
2374
+ const rules = [
2376
2375
  // 1. 派生 scripts 目录(总是覆盖;递归同步,包含 scripts/hooks/run-precommit.js)
2377
2376
  {
2378
2377
  from: "templates/scripts",
@@ -2471,23 +2470,41 @@ var syncConfig = {
2471
2470
  to: "node ./scripts/lint.js",
2472
2471
  ifStartsWith: "concurrently "
2473
2472
  }
2474
- ],
2475
- // 文件权限设置
2476
- permissions: {
2477
- // 所有 .sh 文件设置为可执行
2478
- // '**/*.sh': 0o755,
2479
- }
2480
- };
2481
- function genSyncConfig(perms = {}) {
2482
- if (!perms.disableGenOpenapi) {
2483
- syncConfig.sync.push({
2473
+ ];
2474
+ if (!opts.disableGenOpenapi) {
2475
+ rules.push({
2484
2476
  from: "templates/helper/gen-openapi.ts",
2485
2477
  to: "scripts/gen-openapi.ts",
2486
2478
  type: "file",
2487
2479
  overwrite: true
2488
2480
  });
2489
2481
  }
2490
- return syncConfig;
2482
+ return rules;
2483
+ }
2484
+ function defaultProfile(opts) {
2485
+ return {
2486
+ sync: buildDefaultRules(opts),
2487
+ // 文件权限设置(所有 .sh 文件设置为可执行:'**/*.sh': 0o755)
2488
+ permissions: {},
2489
+ activateGitHooks: true
2490
+ };
2491
+ }
2492
+ function emptyProfile() {
2493
+ return {
2494
+ sync: [],
2495
+ permissions: {},
2496
+ activateGitHooks: false
2497
+ };
2498
+ }
2499
+ var SYNC_PROFILES = {
2500
+ "design-stack": defaultProfile,
2501
+ "nestjs-react-fullstack": defaultProfile,
2502
+ "vite-react": emptyProfile,
2503
+ html: emptyProfile
2504
+ };
2505
+ function genSyncConfig(stack, opts = {}) {
2506
+ const factory = stack && SYNC_PROFILES[stack] || defaultProfile;
2507
+ return factory(opts);
2491
2508
  }
2492
2509
 
2493
2510
  // src/utils/file-ops.ts
@@ -2612,22 +2629,10 @@ async function run2(options) {
2612
2629
  console.log("[fullstack-cli] Skip syncing (not a valid npm project)");
2613
2630
  process.exit(0);
2614
2631
  }
2615
- const sparkMetaPath = path5.join(userProjectRoot, ".spark", "meta.json");
2616
- if (fs7.existsSync(sparkMetaPath)) {
2617
- try {
2618
- const meta = JSON.parse(fs7.readFileSync(sparkMetaPath, "utf-8"));
2619
- if (Number(meta.archType) === 2) {
2620
- console.log("[fullstack-cli] Skip syncing (.spark/meta.json archType=2)");
2621
- process.exit(0);
2622
- }
2623
- } catch (error) {
2624
- const message = error instanceof Error ? error.message : String(error);
2625
- console.warn(`[fullstack-cli] \u26A0 Failed to read .spark/meta.json, fallback to default sync: ${message}`);
2626
- }
2627
- }
2632
+ const stack = resolveStack(userProjectRoot);
2628
2633
  try {
2629
- console.log("[fullstack-cli] Starting sync...");
2630
- const config = genSyncConfig({
2634
+ console.log(`[fullstack-cli] Starting sync${stack ? ` (stack: ${stack})` : ""}...`);
2635
+ const config = genSyncConfig(stack, {
2631
2636
  disableGenOpenapi: options.disableGenOpenapi ?? false
2632
2637
  });
2633
2638
  if (!config || !config.sync) {
@@ -2640,11 +2645,13 @@ async function run2(options) {
2640
2645
  if (config.permissions) {
2641
2646
  setPermissions(config.permissions, userProjectRoot);
2642
2647
  }
2643
- try {
2644
- activateGitHooks(userProjectRoot);
2645
- } catch (error) {
2646
- const message = error instanceof Error ? error.message : String(error);
2647
- console.warn(`[fullstack-cli] \u26A0 Failed to activate git hooks: ${message}`);
2648
+ if (config.activateGitHooks !== false) {
2649
+ try {
2650
+ activateGitHooks(userProjectRoot);
2651
+ } catch (error) {
2652
+ const message = error instanceof Error ? error.message : String(error);
2653
+ console.warn(`[fullstack-cli] \u26A0 Failed to activate git hooks: ${message}`);
2654
+ }
2648
2655
  }
2649
2656
  console.log("[fullstack-cli] Sync completed successfully \u2705");
2650
2657
  } catch (error) {
@@ -2653,6 +2660,20 @@ async function run2(options) {
2653
2660
  process.exit(1);
2654
2661
  }
2655
2662
  }
2663
+ function resolveStack(userProjectRoot) {
2664
+ const sparkMetaPath = path5.join(userProjectRoot, ".spark", "meta.json");
2665
+ if (!fs7.existsSync(sparkMetaPath)) {
2666
+ return void 0;
2667
+ }
2668
+ try {
2669
+ const meta = JSON.parse(fs7.readFileSync(sparkMetaPath, "utf-8"));
2670
+ return typeof meta.stack === "string" ? meta.stack : void 0;
2671
+ } catch (error) {
2672
+ const message = error instanceof Error ? error.message : String(error);
2673
+ console.warn(`[fullstack-cli] \u26A0 Failed to read .spark/meta.json, fallback to default sync: ${message}`);
2674
+ return void 0;
2675
+ }
2676
+ }
2656
2677
  async function syncRule(rule, pluginRoot, userProjectRoot) {
2657
2678
  if (rule.type === "delete-file" || rule.type === "delete-directory") {
2658
2679
  const destPath2 = path5.join(userProjectRoot, rule.to);
@@ -3142,9 +3163,9 @@ function getCliVersion() {
3142
3163
 
3143
3164
  // src/commands/upgrade/get-upgrade-files.ts
3144
3165
  function getUpgradeFilesToStage(disableGenOpenapi = true) {
3145
- const syncConfig2 = genSyncConfig({ disableGenOpenapi });
3166
+ const syncConfig = genSyncConfig(void 0, { disableGenOpenapi });
3146
3167
  const filesToStage = /* @__PURE__ */ new Set();
3147
- syncConfig2.sync.forEach((rule) => {
3168
+ syncConfig.sync.forEach((rule) => {
3148
3169
  if (rule.type === "file" || rule.type === "directory" || rule.type === "merge-json") {
3149
3170
  filesToStage.add(rule.to);
3150
3171
  } else if (rule.type === "remove-line" || rule.type === "add-line") {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lark-apaas/fullstack-cli",
3
- "version": "1.1.47-alpha.0",
3
+ "version": "1.1.47-alpha.2",
4
4
  "description": "CLI tool for fullstack template management",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",