@lark-apaas/fullstack-cli 1.1.48 → 1.1.49-alpha.1

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,8 +2370,9 @@ import fs7 from "fs";
2370
2370
  import { fileURLToPath as fileURLToPath3 } from "url";
2371
2371
 
2372
2372
  // src/config/sync.ts
2373
- function buildDefaultRules(opts) {
2374
- const rules = [
2373
+ var syncConfig = {
2374
+ // 派生规则
2375
+ sync: [
2375
2376
  // 1. 派生 scripts 目录(总是覆盖;递归同步,包含 scripts/hooks/run-precommit.js)
2376
2377
  {
2377
2378
  from: "templates/scripts",
@@ -2434,13 +2435,23 @@ function buildDefaultRules(opts) {
2434
2435
  to: ".gitignore",
2435
2436
  pattern: "package-lock.json"
2436
2437
  },
2437
- // 5. 注册 postinstall 脚本,自动恢复 action plugins
2438
+ // 5. 注册 postinstall 脚本,自动恢复 action plugins
2439
+ // 用 npx -y 形式而不是裸 `fullstack-cli`:用户项目的 deps 没有 fullstack-cli,
2440
+ // bare 形式在新机器(PATH 没全局 fullstack-cli)下 npm i 立即 ENOENT。
2438
2441
  {
2439
2442
  type: "add-script",
2440
2443
  name: "postinstall",
2441
- command: "fullstack-cli action-plugin init",
2444
+ command: "npx -y @lark-apaas/fullstack-cli action-plugin init",
2442
2445
  overwrite: false
2443
2446
  },
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
+ },
2444
2455
  // 6. 替换 drizzle.config.ts(仅当文件存在时)
2445
2456
  {
2446
2457
  from: "templates/drizzle.config.ts",
@@ -2469,49 +2480,42 @@ function buildDefaultRules(opts) {
2469
2480
  name: "lint",
2470
2481
  to: "node ./scripts/lint.js",
2471
2482
  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"
2472
2501
  }
2473
- ];
2474
- if (!opts.disableGenOpenapi) {
2475
- rules.push({
2502
+ ],
2503
+ // 文件权限设置
2504
+ permissions: {
2505
+ // 所有 .sh 文件设置为可执行
2506
+ // '**/*.sh': 0o755,
2507
+ }
2508
+ };
2509
+ function genSyncConfig(perms = {}) {
2510
+ if (!perms.disableGenOpenapi) {
2511
+ syncConfig.sync.push({
2476
2512
  from: "templates/helper/gen-openapi.ts",
2477
2513
  to: "scripts/gen-openapi.ts",
2478
2514
  type: "file",
2479
2515
  overwrite: true
2480
2516
  });
2481
2517
  }
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);
2518
+ return syncConfig;
2515
2519
  }
2516
2520
 
2517
2521
  // src/utils/file-ops.ts
@@ -2636,10 +2640,9 @@ async function run2(options) {
2636
2640
  console.log("[fullstack-cli] Skip syncing (not a valid npm project)");
2637
2641
  process.exit(0);
2638
2642
  }
2639
- const stack = resolveStack(userProjectRoot);
2640
2643
  try {
2641
- console.log(`[fullstack-cli] Starting sync${stack ? ` (stack: ${stack})` : ""}...`);
2642
- const config = genSyncConfig(stack, {
2644
+ console.log("[fullstack-cli] Starting sync...");
2645
+ const config = genSyncConfig({
2643
2646
  disableGenOpenapi: options.disableGenOpenapi ?? false
2644
2647
  });
2645
2648
  if (!config || !config.sync) {
@@ -2652,13 +2655,11 @@ async function run2(options) {
2652
2655
  if (config.permissions) {
2653
2656
  setPermissions(config.permissions, userProjectRoot);
2654
2657
  }
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
- }
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}`);
2662
2663
  }
2663
2664
  console.log("[fullstack-cli] Sync completed successfully \u2705");
2664
2665
  } catch (error) {
@@ -2667,20 +2668,6 @@ async function run2(options) {
2667
2668
  process.exit(1);
2668
2669
  }
2669
2670
  }
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
- }
2684
2671
  async function syncRule(rule, pluginRoot, userProjectRoot) {
2685
2672
  if (rule.type === "delete-file" || rule.type === "delete-directory") {
2686
2673
  const destPath2 = path5.join(userProjectRoot, rule.to);
@@ -3170,9 +3157,9 @@ function getCliVersion() {
3170
3157
 
3171
3158
  // src/commands/upgrade/get-upgrade-files.ts
3172
3159
  function getUpgradeFilesToStage(disableGenOpenapi = true) {
3173
- const syncConfig = genSyncConfig(void 0, { disableGenOpenapi });
3160
+ const syncConfig2 = genSyncConfig({ disableGenOpenapi });
3174
3161
  const filesToStage = /* @__PURE__ */ new Set();
3175
- syncConfig.sync.forEach((rule) => {
3162
+ syncConfig2.sync.forEach((rule) => {
3176
3163
  if (rule.type === "file" || rule.type === "directory" || rule.type === "merge-json") {
3177
3164
  filesToStage.add(rule.to);
3178
3165
  } else if (rule.type === "remove-line" || rule.type === "add-line") {
@@ -4495,15 +4482,10 @@ import fs15 from "fs";
4495
4482
  import { createRequire as createRequire2 } from "module";
4496
4483
  import path13 from "path";
4497
4484
  var CAPABILITIES_DIR = "server/capabilities";
4498
- var SHARED_CAPABILITIES_DIR = "shared/capabilities";
4499
4485
  function getProjectRoot2() {
4500
4486
  return process.cwd();
4501
4487
  }
4502
4488
  function getCapabilitiesDir() {
4503
- const sharedDir = path13.join(getProjectRoot2(), SHARED_CAPABILITIES_DIR);
4504
- if (fs15.existsSync(sharedDir)) {
4505
- return sharedDir;
4506
- }
4507
4489
  return path13.join(getProjectRoot2(), CAPABILITIES_DIR);
4508
4490
  }
4509
4491
  function getCapabilityPath(id) {
@@ -4678,7 +4660,7 @@ function logError(message) {
4678
4660
  async function list2(options) {
4679
4661
  try {
4680
4662
  if (!capabilitiesDirExists()) {
4681
- logError("capabilities directory not found (looked for shared/capabilities and server/capabilities)");
4663
+ logError("server/capabilities directory not found");
4682
4664
  process.exit(1);
4683
4665
  }
4684
4666
  if (options.id) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lark-apaas/fullstack-cli",
3
- "version": "1.1.48",
3
+ "version": "1.1.49-alpha.1",
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.6",
34
+ "@lark-apaas/http-client": "0.1.7-alpha.9",
35
35
  "@lydell/node-pty": "1.1.0",
36
36
  "@vercel/nft": "^0.30.3",
37
37
  "commander": "^13.0.0",
@@ -1,2 +1,29 @@
1
1
  #!/usr/bin/env bash
2
- exec node "$(dirname "$0")/dev.js" "$@"
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" "$@"