@lark-apaas/fullstack-cli 1.1.49-alpha.1 → 1.1.49-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.
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",
@@ -2435,23 +2434,13 @@ var syncConfig = {
2435
2434
  to: ".gitignore",
2436
2435
  pattern: "package-lock.json"
2437
2436
  },
2438
- // 5. 注册 postinstall 脚本,自动恢复 action plugins
2439
- // 用 npx -y 形式而不是裸 `fullstack-cli`:用户项目的 deps 没有 fullstack-cli,
2440
- // bare 形式在新机器(PATH 没全局 fullstack-cli)下 npm i 立即 ENOENT。
2437
+ // 5. 注册 postinstall 脚本,自动恢复 action plugins
2441
2438
  {
2442
2439
  type: "add-script",
2443
2440
  name: "postinstall",
2444
- command: "npx -y @lark-apaas/fullstack-cli action-plugin init",
2441
+ command: "fullstack-cli action-plugin init",
2445
2442
  overwrite: false
2446
2443
  },
2447
- // 5a. 迁移已有应用的老形式 postinstall(裸 fullstack-cli → npx -y)。
2448
- // patch-script 只在脚本以指定前缀开头时改写,用户真正手改过的脚本保持原样。
2449
- {
2450
- type: "patch-script",
2451
- name: "postinstall",
2452
- to: "npx -y @lark-apaas/fullstack-cli action-plugin init",
2453
- ifStartsWith: "fullstack-cli action-plugin init"
2454
- },
2455
2444
  // 6. 替换 drizzle.config.ts(仅当文件存在时)
2456
2445
  {
2457
2446
  from: "templates/drizzle.config.ts",
@@ -2480,42 +2469,49 @@ var syncConfig = {
2480
2469
  name: "lint",
2481
2470
  to: "node ./scripts/lint.js",
2482
2471
  ifStartsWith: "concurrently "
2483
- },
2484
- // 10. 把老 `npm run upgrade && ./scripts/dev.sh` 形式迁移到 `./scripts/dev.sh`,
2485
- // 让本地 `npm run dev` 不再前置跑 fullstack-cli sync。新版 dev.sh 按 SANDBOX_ID 是否非空
2486
- // 判分支:沙箱直接 exec dev.js(脚本同步由平台 pod 启动时做过,dev 入口不再 upgrade);
2487
- // 本地走 miaoda app upgrade 兜底 + dev-local.sh。
2488
- {
2489
- type: "patch-script",
2490
- name: "dev",
2491
- to: "./scripts/dev.sh",
2492
- ifStartsWith: "npm run upgrade && "
2493
- },
2494
- // 11. 把 `upgrade` 脚本里裸 `fullstack-cli sync` 改成 `npx -y @lark-apaas/fullstack-cli sync`。
2495
- // 跟 postinstall 同款根因:fullstack-cli 不是用户应用的 dep,新机器无全局命令会 ENOENT。
2496
- {
2497
- type: "patch-script",
2498
- name: "upgrade",
2499
- to: "npx -y @lark-apaas/fullstack-cli sync --disable-gen-openapi",
2500
- ifStartsWith: "fullstack-cli sync"
2501
2472
  }
2502
- ],
2503
- // 文件权限设置
2504
- permissions: {
2505
- // 所有 .sh 文件设置为可执行
2506
- // '**/*.sh': 0o755,
2507
- }
2508
- };
2509
- function genSyncConfig(perms = {}) {
2510
- if (!perms.disableGenOpenapi) {
2511
- syncConfig.sync.push({
2473
+ ];
2474
+ if (!opts.disableGenOpenapi) {
2475
+ rules.push({
2512
2476
  from: "templates/helper/gen-openapi.ts",
2513
2477
  to: "scripts/gen-openapi.ts",
2514
2478
  type: "file",
2515
2479
  overwrite: true
2516
2480
  });
2517
2481
  }
2518
- 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
+ function viteReactProfile() {
2500
+ return {
2501
+ sync: [],
2502
+ permissions: {},
2503
+ activateGitHooks: true
2504
+ };
2505
+ }
2506
+ var SYNC_PROFILES = {
2507
+ "design-stack": defaultProfile,
2508
+ "nestjs-react-fullstack": defaultProfile,
2509
+ "vite-react": viteReactProfile,
2510
+ html: emptyProfile
2511
+ };
2512
+ function genSyncConfig(stack, opts = {}) {
2513
+ const factory = stack && SYNC_PROFILES[stack] || defaultProfile;
2514
+ return factory(opts);
2519
2515
  }
2520
2516
 
2521
2517
  // src/utils/file-ops.ts
@@ -2640,9 +2636,10 @@ async function run2(options) {
2640
2636
  console.log("[fullstack-cli] Skip syncing (not a valid npm project)");
2641
2637
  process.exit(0);
2642
2638
  }
2639
+ const stack = resolveStack(userProjectRoot);
2643
2640
  try {
2644
- console.log("[fullstack-cli] Starting sync...");
2645
- const config = genSyncConfig({
2641
+ console.log(`[fullstack-cli] Starting sync${stack ? ` (stack: ${stack})` : ""}...`);
2642
+ const config = genSyncConfig(stack, {
2646
2643
  disableGenOpenapi: options.disableGenOpenapi ?? false
2647
2644
  });
2648
2645
  if (!config || !config.sync) {
@@ -2655,11 +2652,13 @@ async function run2(options) {
2655
2652
  if (config.permissions) {
2656
2653
  setPermissions(config.permissions, userProjectRoot);
2657
2654
  }
2658
- try {
2659
- activateGitHooks(userProjectRoot);
2660
- } catch (error) {
2661
- const message = error instanceof Error ? error.message : String(error);
2662
- console.warn(`[fullstack-cli] \u26A0 Failed to activate git hooks: ${message}`);
2655
+ if (config.activateGitHooks !== false) {
2656
+ try {
2657
+ activateGitHooks(userProjectRoot);
2658
+ } catch (error) {
2659
+ const message = error instanceof Error ? error.message : String(error);
2660
+ console.warn(`[fullstack-cli] \u26A0 Failed to activate git hooks: ${message}`);
2661
+ }
2663
2662
  }
2664
2663
  console.log("[fullstack-cli] Sync completed successfully \u2705");
2665
2664
  } catch (error) {
@@ -2668,6 +2667,20 @@ async function run2(options) {
2668
2667
  process.exit(1);
2669
2668
  }
2670
2669
  }
2670
+ function resolveStack(userProjectRoot) {
2671
+ const sparkMetaPath = path5.join(userProjectRoot, ".spark", "meta.json");
2672
+ if (!fs7.existsSync(sparkMetaPath)) {
2673
+ return void 0;
2674
+ }
2675
+ try {
2676
+ const meta = JSON.parse(fs7.readFileSync(sparkMetaPath, "utf-8"));
2677
+ return typeof meta.stack === "string" ? meta.stack : void 0;
2678
+ } catch (error) {
2679
+ const message = error instanceof Error ? error.message : String(error);
2680
+ console.warn(`[fullstack-cli] \u26A0 Failed to read .spark/meta.json, fallback to default sync: ${message}`);
2681
+ return void 0;
2682
+ }
2683
+ }
2671
2684
  async function syncRule(rule, pluginRoot, userProjectRoot) {
2672
2685
  if (rule.type === "delete-file" || rule.type === "delete-directory") {
2673
2686
  const destPath2 = path5.join(userProjectRoot, rule.to);
@@ -3157,9 +3170,9 @@ function getCliVersion() {
3157
3170
 
3158
3171
  // src/commands/upgrade/get-upgrade-files.ts
3159
3172
  function getUpgradeFilesToStage(disableGenOpenapi = true) {
3160
- const syncConfig2 = genSyncConfig({ disableGenOpenapi });
3173
+ const syncConfig = genSyncConfig(void 0, { disableGenOpenapi });
3161
3174
  const filesToStage = /* @__PURE__ */ new Set();
3162
- syncConfig2.sync.forEach((rule) => {
3175
+ syncConfig.sync.forEach((rule) => {
3163
3176
  if (rule.type === "file" || rule.type === "directory" || rule.type === "merge-json") {
3164
3177
  filesToStage.add(rule.to);
3165
3178
  } else if (rule.type === "remove-line" || rule.type === "add-line") {
@@ -4482,10 +4495,15 @@ import fs15 from "fs";
4482
4495
  import { createRequire as createRequire2 } from "module";
4483
4496
  import path13 from "path";
4484
4497
  var CAPABILITIES_DIR = "server/capabilities";
4498
+ var SHARED_CAPABILITIES_DIR = "shared/capabilities";
4485
4499
  function getProjectRoot2() {
4486
4500
  return process.cwd();
4487
4501
  }
4488
4502
  function getCapabilitiesDir() {
4503
+ const sharedDir = path13.join(getProjectRoot2(), SHARED_CAPABILITIES_DIR);
4504
+ if (fs15.existsSync(sharedDir)) {
4505
+ return sharedDir;
4506
+ }
4489
4507
  return path13.join(getProjectRoot2(), CAPABILITIES_DIR);
4490
4508
  }
4491
4509
  function getCapabilityPath(id) {
@@ -4660,7 +4678,7 @@ function logError(message) {
4660
4678
  async function list2(options) {
4661
4679
  try {
4662
4680
  if (!capabilitiesDirExists()) {
4663
- logError("server/capabilities directory not found");
4681
+ logError("capabilities directory not found (looked for shared/capabilities and server/capabilities)");
4664
4682
  process.exit(1);
4665
4683
  }
4666
4684
  if (options.id) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lark-apaas/fullstack-cli",
3
- "version": "1.1.49-alpha.1",
3
+ "version": "1.1.49-alpha.2",
4
4
  "description": "CLI tool for fullstack template management",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -31,7 +31,7 @@
31
31
  "access": "public"
32
32
  },
33
33
  "dependencies": {
34
- "@lark-apaas/http-client": "0.1.7-alpha.9",
34
+ "@lark-apaas/http-client": "0.1.7-alpha.10",
35
35
  "@lydell/node-pty": "1.1.0",
36
36
  "@vercel/nft": "^0.30.3",
37
37
  "commander": "^13.0.0",
@@ -1,29 +1,2 @@
1
1
  #!/usr/bin/env bash
2
- # `npm run dev` 入口;按 SANDBOX_ID 是否非空判断运行环境:
3
- # - SANDBOX_ID 非空(沙箱平台注入应用所属沙箱 ID)→ 直接跑 dev.js
4
- # (保活 / restart loop / 文件日志 —— 沙箱生产形态)。脚本同步由平台 pod 启动阶段做过,
5
- # dev 入口不再额外 `npm run upgrade`。
6
- # - 否则(本地)→ 走 miaoda app upgrade 兜底 + 跑 dev-local.sh:纯 stdout、崩了就崩、Agent 友好。
7
- # 显式想跑本地路径可用 `npm run dev:local`(绕过 SANDBOX_ID 判断)。
8
- set -euo pipefail
9
- SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
10
-
11
- if [ -n "${SANDBOX_ID:-}" ]; then
12
- exec node "$SCRIPT_DIR/dev.js" "$@"
13
- fi
14
-
15
- if [ ! -x "$SCRIPT_DIR/dev-local.sh" ]; then
16
- echo "[dev] scripts/dev-local.sh 缺失或不可执行;先跑 \`miaoda app upgrade\` 同步平台脚本" >&2
17
- exit 1
18
- fi
19
-
20
- # 本地启动前先跑一次 miaoda app upgrade:同步 platform-controlled 内容 + 升 @lark-apaas/* 到
21
- # 最新 alpha + 迁移老 npm scripts。沙箱不走这里(SANDBOX_ID 分支已经 exec return)。
22
- # miaoda 缺失时软失败(agent 环境可能没装),靠用户自己保证 .env.local / scripts 现状能跑。
23
- if command -v miaoda >/dev/null 2>&1; then
24
- miaoda app upgrade || echo "[dev] miaoda app upgrade 失败,按现状继续" >&2
25
- else
26
- echo "[dev] miaoda 未装,跳过 upgrade;建议 npm i -g @lark-apaas/miaoda-cli" >&2
27
- fi
28
-
29
- exec "$SCRIPT_DIR/dev-local.sh" "$@"
2
+ exec node "$(dirname "$0")/dev.js" "$@"