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

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 +106 -406
  2. package/package.json +1 -2
package/dist/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  // src/index.ts
2
- import fs29 from "fs";
3
- import path25 from "path";
2
+ import fs28 from "fs";
3
+ import path24 from "path";
4
4
  import { fileURLToPath as fileURLToPath5 } from "url";
5
5
  import { config as dotenvConfig } from "dotenv";
6
6
 
@@ -4690,358 +4690,59 @@ var capabilityCommandGroup = {
4690
4690
  commands: [listCommand2]
4691
4691
  };
4692
4692
 
4693
- // src/commands/component/add.handler.ts
4694
- import { execFile } from "child_process";
4695
-
4696
- // src/commands/component/registry-preparer.ts
4693
+ // src/commands/migration/version-manager.ts
4697
4694
  import fs16 from "fs";
4698
4695
  import path14 from "path";
4699
- import os from "os";
4700
-
4701
- // src/commands/component/service.ts
4702
- import { mapValues } from "es-toolkit";
4703
-
4704
- // src/commands/component/utils.ts
4705
- import createDebug from "debug";
4706
- var debug = createDebug("component");
4707
-
4708
- // src/commands/component/service.ts
4709
- async function getComponents(keys) {
4710
- const client = getHttpClient();
4711
- debug("\u8C03\u7528 /components/batch_get %o", keys);
4712
- const response = await client.post(
4713
- `/api/v1/studio/innerapi/components/batch_get?keys=${keys.join(",")}`
4714
- );
4715
- if (response.status !== 200) {
4716
- throw new Error(
4717
- `\u83B7\u53D6\u7EC4\u4EF6\u4FE1\u606F\u5931\u8D25\uFF1A${response.status} ${response.statusText}`
4718
- );
4719
- }
4720
- const result = await response.json();
4721
- if (result.status_code !== "0") {
4722
- debug("\u63A5\u53E3\u8FD4\u56DE\u9519\u8BEF\uFF1A%o", result);
4723
- throw new Error(`\u83B7\u53D6\u7EC4\u4EF6\u4FE1\u606F\u5931\u8D25\uFF1A${result.error_msg}`);
4724
- }
4725
- return mapValues(result.data.components, ([component]) => component);
4726
- }
4727
- async function getRegistryItem(url) {
4728
- const client = getHttpClient();
4729
- debug("\u4E0B\u8F7D registry-item.json\uFF1A%s", url);
4730
- const response = await client.get(url);
4731
- if (!response.ok) {
4732
- throw new Error(
4733
- `\u4E0B\u8F7D registry-item.json \u5931\u8D25\uFF1A${response.status} ${response.statusText}`
4734
- );
4735
- }
4736
- const item = await response.json();
4737
- return item;
4738
- }
4739
- async function sendInstallEvent(key) {
4740
- const client = getHttpClient();
4741
- await client.post("/api/v1/studio/innerapi/resource_events", {
4742
- events: [
4743
- {
4744
- resourceType: "component",
4745
- resourceKey: key,
4746
- eventType: "install",
4747
- details: {}
4748
- }
4749
- ]
4750
- });
4751
- }
4752
-
4753
- // src/commands/component/registry-preparer.ts
4754
- var REGISTRY_TEMP_DIR = path14.join(os.tmpdir(), "miaoda-registry");
4755
- function parseComponentKey(key) {
4756
- const match = key.match(/^@([^/]+)\/(.+)$/);
4757
- if (!match) {
4758
- throw new Error(
4759
- `Invalid component key format: ${key}. Expected format: @scope/name`
4760
- );
4761
- }
4762
- return { scope: match[1], name: match[2] };
4763
- }
4764
- function getLocalRegistryPath(key) {
4765
- const { scope, name } = parseComponentKey(key);
4766
- return path14.join(REGISTRY_TEMP_DIR, scope, `${name}.json`);
4767
- }
4768
- function ensureDir(dirPath) {
4769
- if (!fs16.existsSync(dirPath)) {
4770
- fs16.mkdirSync(dirPath, { recursive: true });
4771
- }
4772
- }
4773
- async function prepareRecursive(key, visited) {
4774
- if (visited.has(key)) {
4775
- debug("\u8DF3\u8FC7\u5DF2\u5904\u7406\u7684\u7EC4\u4EF6: %s", key);
4776
- return;
4777
- }
4778
- visited.add(key);
4779
- debug("\u5904\u7406\u7EC4\u4EF6: %s", key);
4780
- debug("\u83B7\u53D6\u7EC4\u4EF6\u4E0B\u8F7D\u4FE1\u606F...");
4781
- const infoMap = await getComponents([key]);
4782
- const info = infoMap[key];
4783
- debug("\u7EC4\u4EF6\u4FE1\u606F: %o", info);
4784
- if (!info) {
4785
- throw new Error(`Component not found: ${key}`);
4786
- }
4787
- if (info.status !== "active") {
4788
- throw new Error(`Component is not active: ${key}`);
4789
- }
4790
- debug("\u4E0B\u8F7D registry item: %s", info.downloadURL);
4791
- const registryItem = await getRegistryItem(info.downloadURL);
4792
- debug("registry item \u5185\u5BB9: %o", registryItem);
4793
- const deps = registryItem.registryDependencies || [];
4794
- debug("\u4F9D\u8D56\u5217\u8868: %o", deps);
4795
- for (const dep of deps) {
4796
- await prepareRecursive(dep, visited);
4797
- }
4798
- const rewrittenItem = {
4799
- ...registryItem,
4800
- registryDependencies: deps.map((dep) => getLocalRegistryPath(dep))
4801
- };
4802
- const localPath = getLocalRegistryPath(key);
4803
- ensureDir(path14.dirname(localPath));
4804
- fs16.writeFileSync(localPath, JSON.stringify(rewrittenItem, null, 2), "utf-8");
4805
- debug("\u4FDD\u5B58\u5230: %s", localPath);
4806
- }
4807
- async function prepareComponentRegistryItems(id) {
4808
- const visited = /* @__PURE__ */ new Set();
4809
- await prepareRecursive(id, visited);
4810
- return getLocalRegistryPath(id);
4811
- }
4812
- function cleanupTempDir() {
4813
- try {
4814
- if (fs16.existsSync(REGISTRY_TEMP_DIR)) {
4815
- fs16.rmSync(REGISTRY_TEMP_DIR, { recursive: true, force: true });
4816
- }
4817
- } catch {
4818
- }
4819
- }
4820
- function getDownloadedRegistryItem(itemId) {
4821
- const localPath = getLocalRegistryPath(itemId);
4822
- if (!fs16.existsSync(localPath)) {
4823
- return null;
4824
- }
4825
- const content = fs16.readFileSync(localPath, "utf-8");
4826
- return JSON.parse(content);
4827
- }
4828
-
4829
- // src/commands/component/shadcn-executor.ts
4830
- import * as pty from "@lydell/node-pty";
4831
- function parseOutput(output) {
4832
- const state = {
4833
- currentSection: null,
4834
- files: /* @__PURE__ */ new Set()
4835
- };
4836
- const lines = output.split("\n");
4837
- for (const line of lines) {
4838
- const trimmedLine = line.trim();
4839
- if (/Created \d+ files?:/.test(trimmedLine)) {
4840
- state.currentSection = "created";
4841
- continue;
4842
- }
4843
- if (/Updated \d+ files?:/.test(trimmedLine)) {
4844
- state.currentSection = "updated";
4845
- continue;
4846
- }
4847
- if (/Skipped \d+ files?:/.test(trimmedLine)) {
4848
- state.currentSection = "skipped";
4849
- continue;
4850
- }
4851
- if (state.currentSection && trimmedLine.startsWith("- ")) {
4852
- const filePath = trimmedLine.slice(2).trim();
4853
- if (filePath && filePath.includes("/")) {
4854
- state.files.add(filePath);
4855
- }
4856
- }
4857
- if (state.currentSection && trimmedLine.length > 1 && !trimmedLine.startsWith("- ")) {
4858
- state.currentSection = null;
4859
- }
4860
- }
4861
- return Array.from(state.files);
4862
- }
4863
- function toFileInfo(filePath) {
4864
- const name = filePath.split("/").pop() || filePath;
4865
- return { name, path: filePath };
4866
- }
4867
- var PROMPT_PATTERNS = [
4868
- // 文件覆盖确认 - 回答 n(不覆盖)
4869
- { pattern: /overwrite/i, answer: "n\n" },
4870
- // 主题/样式选择 - 回答 n(不安装额外主题)
4871
- { pattern: /theme/i, answer: "n\n" },
4872
- { pattern: /style/i, answer: "n\n" },
4873
- // 继续确认 - 回答 y
4874
- { pattern: /continue\?/i, answer: "y\n" },
4875
- { pattern: /proceed\?/i, answer: "y\n" }
4876
- ];
4877
- async function executeShadcnAdd(registryItemPath) {
4878
- return new Promise((resolve2) => {
4879
- let output = "";
4880
- const args = ["--yes", "shadcn@3.8.2", "add", registryItemPath];
4881
- const ptyProcess = pty.spawn("npx", args, {
4882
- name: "xterm-color",
4883
- cols: 120,
4884
- rows: 30,
4885
- cwd: process.cwd(),
4886
- env: {
4887
- ...process.env,
4888
- // 禁用颜色输出以便解析
4889
- NO_COLOR: "1",
4890
- FORCE_COLOR: "0"
4891
- }
4892
- });
4893
- ptyProcess.onData((data) => {
4894
- output += data;
4895
- for (const { pattern, answer } of PROMPT_PATTERNS) {
4896
- if (pattern.test(data)) {
4897
- ptyProcess.write(answer);
4898
- return;
4899
- }
4900
- }
4901
- });
4902
- const timeoutId = setTimeout(() => {
4903
- ptyProcess.kill();
4904
- resolve2({
4905
- success: false,
4906
- files: [],
4907
- error: "\u6267\u884C\u8D85\u65F6"
4908
- });
4909
- }, 3 * 60 * 1e3);
4910
- ptyProcess.onExit(({ exitCode }) => {
4911
- clearTimeout(timeoutId);
4912
- const success = exitCode === 0;
4913
- const filePaths = parseOutput(output);
4914
- const files = filePaths.map(toFileInfo);
4915
- resolve2({
4916
- success,
4917
- files,
4918
- error: success ? void 0 : output || `Process exited with code ${exitCode}`
4919
- });
4920
- });
4921
- });
4922
- }
4923
-
4924
- // src/commands/component/add.handler.ts
4925
- function runActionPluginInit() {
4926
- return new Promise((resolve2) => {
4927
- execFile("fullstack-cli", ["action-plugin", "init"], { cwd: process.cwd(), stdio: "ignore" }, (error) => {
4928
- if (error) {
4929
- debug("action-plugin init \u5931\u8D25: %s", error.message);
4930
- }
4931
- resolve2();
4932
- });
4933
- });
4934
- }
4935
- function printResult(result) {
4936
- console.log(JSON.stringify(result, null, 2));
4937
- }
4938
- async function addComponent(key) {
4939
- debug("\u5F00\u59CB\u5B89\u88C5\u7EC4\u4EF6: %s", key);
4940
- debug("\u51C6\u5907 registry items...");
4941
- const registryItemPath = await prepareComponentRegistryItems(key);
4942
- debug("registry item \u8DEF\u5F84: %s", registryItemPath);
4943
- const registryItem = getDownloadedRegistryItem(key);
4944
- debug("\u83B7\u53D6\u5230 registry item: %o", registryItem);
4945
- debug("\u6267\u884C shadcn add...");
4946
- const executeResult = await executeShadcnAdd(registryItemPath);
4947
- debug("shadcn \u6267\u884C\u7ED3\u679C: %o", executeResult);
4948
- if (!executeResult.success) {
4949
- throw new Error(executeResult.error || "\u5B89\u88C5\u5931\u8D25\uFF0C\u672A\u77E5\u539F\u56E0");
4950
- }
4951
- return {
4952
- success: true,
4953
- name: key,
4954
- description: registryItem?.description || "",
4955
- files: executeResult.files,
4956
- docs: registryItem?.docs || ""
4957
- };
4958
- }
4959
- async function add(key) {
4960
- try {
4961
- const result = await addComponent(key);
4962
- printResult(result);
4963
- void sendInstallEvent(key);
4964
- } catch (error) {
4965
- const errorMessage = error instanceof Error ? error.message : "\u5B89\u88C5\u5931\u8D25\uFF0C\u539F\u56E0\u672A\u77E5";
4966
- printResult({
4967
- success: false,
4968
- errors: [{ message: errorMessage }]
4969
- });
4970
- } finally {
4971
- await runActionPluginInit();
4972
- cleanupTempDir();
4973
- }
4974
- }
4975
-
4976
- // src/commands/component/index.ts
4977
- var addCommand = {
4978
- name: "add",
4979
- description: "\u5B89\u88C5\u5999\u642D\u7EC4\u4EF6\u5E02\u573A\u4E2D\u7684\u7EC4\u4EF6",
4980
- register(program) {
4981
- program.command(this.name).description(this.description).argument("<component>", "\u7EC4\u4EF6 ID (\u4F8B\u5982 @miaoda/button)").action(async (component) => {
4982
- await add(component);
4983
- });
4984
- }
4985
- };
4986
- var componentCommandGroup = {
4987
- name: "component",
4988
- description: "\u7EC4\u4EF6\u76F8\u5173\u547D\u4EE4",
4989
- commands: [addCommand]
4990
- };
4991
-
4992
- // src/commands/migration/version-manager.ts
4993
- import fs17 from "fs";
4994
- import path15 from "path";
4995
4696
  var PACKAGE_JSON = "package.json";
4996
4697
  var VERSION_FIELD = "migrationVersion";
4997
4698
  function getPackageJsonPath2() {
4998
- return path15.join(process.cwd(), PACKAGE_JSON);
4699
+ return path14.join(process.cwd(), PACKAGE_JSON);
4999
4700
  }
5000
4701
  function getCurrentVersion() {
5001
4702
  const pkgPath = getPackageJsonPath2();
5002
- if (!fs17.existsSync(pkgPath)) {
4703
+ if (!fs16.existsSync(pkgPath)) {
5003
4704
  throw new Error("package.json not found");
5004
4705
  }
5005
- const pkg2 = JSON.parse(fs17.readFileSync(pkgPath, "utf-8"));
4706
+ const pkg2 = JSON.parse(fs16.readFileSync(pkgPath, "utf-8"));
5006
4707
  return pkg2[VERSION_FIELD] ?? 0;
5007
4708
  }
5008
4709
  function setCurrentVersion(version) {
5009
4710
  const pkgPath = getPackageJsonPath2();
5010
- const pkg2 = JSON.parse(fs17.readFileSync(pkgPath, "utf-8"));
4711
+ const pkg2 = JSON.parse(fs16.readFileSync(pkgPath, "utf-8"));
5011
4712
  pkg2[VERSION_FIELD] = version;
5012
- fs17.writeFileSync(pkgPath, JSON.stringify(pkg2, null, 2) + "\n", "utf-8");
4713
+ fs16.writeFileSync(pkgPath, JSON.stringify(pkg2, null, 2) + "\n", "utf-8");
5013
4714
  }
5014
4715
 
5015
4716
  // src/commands/migration/versions/v001_capability/json-migrator/detector.ts
5016
- import fs19 from "fs";
5017
- import path17 from "path";
5018
-
5019
- // src/commands/migration/versions/v001_capability/utils.ts
5020
4717
  import fs18 from "fs";
5021
4718
  import path16 from "path";
4719
+
4720
+ // src/commands/migration/versions/v001_capability/utils.ts
4721
+ import fs17 from "fs";
4722
+ import path15 from "path";
5022
4723
  var CAPABILITIES_DIR2 = "server/capabilities";
5023
4724
  function getProjectRoot3() {
5024
4725
  return process.cwd();
5025
4726
  }
5026
4727
  function getCapabilitiesDir2() {
5027
- return path16.join(getProjectRoot3(), CAPABILITIES_DIR2);
4728
+ return path15.join(getProjectRoot3(), CAPABILITIES_DIR2);
5028
4729
  }
5029
4730
  function getPluginManifestPath2(pluginKey) {
5030
- return path16.join(getProjectRoot3(), "node_modules", pluginKey, "manifest.json");
4731
+ return path15.join(getProjectRoot3(), "node_modules", pluginKey, "manifest.json");
5031
4732
  }
5032
4733
 
5033
4734
  // src/commands/migration/versions/v001_capability/json-migrator/detector.ts
5034
4735
  function detectJsonMigration() {
5035
4736
  const capabilitiesDir = getCapabilitiesDir2();
5036
- const oldFilePath = path17.join(capabilitiesDir, "capabilities.json");
5037
- if (!fs19.existsSync(oldFilePath)) {
4737
+ const oldFilePath = path16.join(capabilitiesDir, "capabilities.json");
4738
+ if (!fs18.existsSync(oldFilePath)) {
5038
4739
  return {
5039
4740
  needsMigration: false,
5040
4741
  reason: "capabilities.json not found"
5041
4742
  };
5042
4743
  }
5043
4744
  try {
5044
- const content = fs19.readFileSync(oldFilePath, "utf-8");
4745
+ const content = fs18.readFileSync(oldFilePath, "utf-8");
5045
4746
  const parsed = JSON.parse(content);
5046
4747
  if (!Array.isArray(parsed)) {
5047
4748
  return {
@@ -5092,8 +4793,8 @@ async function check(options) {
5092
4793
  }
5093
4794
 
5094
4795
  // src/commands/migration/versions/v001_capability/json-migrator/index.ts
5095
- import fs20 from "fs";
5096
- import path18 from "path";
4796
+ import fs19 from "fs";
4797
+ import path17 from "path";
5097
4798
 
5098
4799
  // src/commands/migration/versions/v001_capability/mapping.ts
5099
4800
  var DEFAULT_PLUGIN_VERSION = "1.0.0";
@@ -5323,18 +5024,18 @@ function transformCapabilities(oldCapabilities) {
5323
5024
  // src/commands/migration/versions/v001_capability/json-migrator/index.ts
5324
5025
  function loadExistingCapabilities() {
5325
5026
  const capabilitiesDir = getCapabilitiesDir2();
5326
- if (!fs20.existsSync(capabilitiesDir)) {
5027
+ if (!fs19.existsSync(capabilitiesDir)) {
5327
5028
  return [];
5328
5029
  }
5329
- const files = fs20.readdirSync(capabilitiesDir);
5030
+ const files = fs19.readdirSync(capabilitiesDir);
5330
5031
  const capabilities = [];
5331
5032
  for (const file of files) {
5332
5033
  if (file === "capabilities.json" || !file.endsWith(".json")) {
5333
5034
  continue;
5334
5035
  }
5335
5036
  try {
5336
- const filePath = path18.join(capabilitiesDir, file);
5337
- const content = fs20.readFileSync(filePath, "utf-8");
5037
+ const filePath = path17.join(capabilitiesDir, file);
5038
+ const content = fs19.readFileSync(filePath, "utf-8");
5338
5039
  const capability = JSON.parse(content);
5339
5040
  if (capability.id && capability.pluginKey) {
5340
5041
  capabilities.push(capability);
@@ -5392,9 +5093,9 @@ async function migrateJsonFiles(options) {
5392
5093
  }
5393
5094
  const capabilitiesDir = getCapabilitiesDir2();
5394
5095
  for (const cap of newCapabilities) {
5395
- const filePath = path18.join(capabilitiesDir, `${cap.id}.json`);
5096
+ const filePath = path17.join(capabilitiesDir, `${cap.id}.json`);
5396
5097
  const content = JSON.stringify(cap, null, 2);
5397
- fs20.writeFileSync(filePath, content, "utf-8");
5098
+ fs19.writeFileSync(filePath, content, "utf-8");
5398
5099
  console.log(` \u2713 Created: ${cap.id}.json`);
5399
5100
  }
5400
5101
  return {
@@ -5406,11 +5107,11 @@ async function migrateJsonFiles(options) {
5406
5107
  }
5407
5108
 
5408
5109
  // src/commands/migration/versions/v001_capability/plugin-installer/detector.ts
5409
- import fs21 from "fs";
5110
+ import fs20 from "fs";
5410
5111
  function isPluginInstalled2(pluginKey) {
5411
5112
  const actionPlugins = readActionPlugins();
5412
5113
  const manifestPath = getPluginManifestPath2(pluginKey);
5413
- return fs21.existsSync(manifestPath) && !!actionPlugins[pluginKey];
5114
+ return fs20.existsSync(manifestPath) && !!actionPlugins[pluginKey];
5414
5115
  }
5415
5116
  function detectPluginsToInstall(capabilities) {
5416
5117
  const pluginKeys = /* @__PURE__ */ new Set();
@@ -5486,12 +5187,12 @@ async function installPlugins(capabilities, options) {
5486
5187
  }
5487
5188
 
5488
5189
  // src/commands/migration/versions/v001_capability/code-migrator/index.ts
5489
- import path20 from "path";
5190
+ import path19 from "path";
5490
5191
  import { Project as Project3 } from "ts-morph";
5491
5192
 
5492
5193
  // src/commands/migration/versions/v001_capability/code-migrator/scanner.ts
5493
- import fs22 from "fs";
5494
- import path19 from "path";
5194
+ import fs21 from "fs";
5195
+ import path18 from "path";
5495
5196
  var EXCLUDED_DIRS = [
5496
5197
  "node_modules",
5497
5198
  "dist",
@@ -5506,9 +5207,9 @@ var EXCLUDED_PATTERNS = [
5506
5207
  /\.d\.ts$/
5507
5208
  ];
5508
5209
  function scanDirectory(dir, files = []) {
5509
- const entries = fs22.readdirSync(dir, { withFileTypes: true });
5210
+ const entries = fs21.readdirSync(dir, { withFileTypes: true });
5510
5211
  for (const entry of entries) {
5511
- const fullPath = path19.join(dir, entry.name);
5212
+ const fullPath = path18.join(dir, entry.name);
5512
5213
  if (entry.isDirectory()) {
5513
5214
  if (EXCLUDED_DIRS.includes(entry.name)) {
5514
5215
  continue;
@@ -5524,14 +5225,14 @@ function scanDirectory(dir, files = []) {
5524
5225
  return files;
5525
5226
  }
5526
5227
  function scanServerFiles() {
5527
- const serverDir = path19.join(getProjectRoot3(), "server");
5528
- if (!fs22.existsSync(serverDir)) {
5228
+ const serverDir = path18.join(getProjectRoot3(), "server");
5229
+ if (!fs21.existsSync(serverDir)) {
5529
5230
  return [];
5530
5231
  }
5531
5232
  return scanDirectory(serverDir);
5532
5233
  }
5533
5234
  function hasCapabilityImport(filePath) {
5534
- const content = fs22.readFileSync(filePath, "utf-8");
5235
+ const content = fs21.readFileSync(filePath, "utf-8");
5535
5236
  return /import\s+.*from\s+['"][^'"]*capabilities[^'"]*['"]/.test(content);
5536
5237
  }
5537
5238
  function scanFilesToMigrate() {
@@ -5908,7 +5609,7 @@ function analyzeFile(project, filePath, actionNameMap) {
5908
5609
  const callSites = analyzeCallSites(sourceFile, imports);
5909
5610
  const classInfo = analyzeClass(sourceFile);
5910
5611
  const { canMigrate, reason } = canAutoMigrate(classInfo);
5911
- const relativePath = path20.relative(getProjectRoot3(), filePath);
5612
+ const relativePath = path19.relative(getProjectRoot3(), filePath);
5912
5613
  return {
5913
5614
  filePath: relativePath,
5914
5615
  imports,
@@ -5919,7 +5620,7 @@ function analyzeFile(project, filePath, actionNameMap) {
5919
5620
  };
5920
5621
  }
5921
5622
  function migrateFile(project, analysis, dryRun) {
5922
- const absolutePath = path20.join(getProjectRoot3(), analysis.filePath);
5623
+ const absolutePath = path19.join(getProjectRoot3(), analysis.filePath);
5923
5624
  if (!analysis.canAutoMigrate) {
5924
5625
  return {
5925
5626
  filePath: analysis.filePath,
@@ -6022,17 +5723,17 @@ function getSuggestion(analysis) {
6022
5723
  }
6023
5724
 
6024
5725
  // src/commands/migration/versions/v001_capability/cleanup.ts
6025
- import fs23 from "fs";
6026
- import path21 from "path";
5726
+ import fs22 from "fs";
5727
+ import path20 from "path";
6027
5728
  function cleanupOldFiles(capabilities, dryRun) {
6028
5729
  const deletedFiles = [];
6029
5730
  const errors = [];
6030
5731
  const capabilitiesDir = getCapabilitiesDir2();
6031
- const oldJsonPath = path21.join(capabilitiesDir, "capabilities.json");
6032
- if (fs23.existsSync(oldJsonPath)) {
5732
+ const oldJsonPath = path20.join(capabilitiesDir, "capabilities.json");
5733
+ if (fs22.existsSync(oldJsonPath)) {
6033
5734
  try {
6034
5735
  if (!dryRun) {
6035
- fs23.unlinkSync(oldJsonPath);
5736
+ fs22.unlinkSync(oldJsonPath);
6036
5737
  }
6037
5738
  deletedFiles.push("capabilities.json");
6038
5739
  } catch (error) {
@@ -6040,11 +5741,11 @@ function cleanupOldFiles(capabilities, dryRun) {
6040
5741
  }
6041
5742
  }
6042
5743
  for (const cap of capabilities) {
6043
- const tsFilePath = path21.join(capabilitiesDir, `${cap.id}.ts`);
6044
- if (fs23.existsSync(tsFilePath)) {
5744
+ const tsFilePath = path20.join(capabilitiesDir, `${cap.id}.ts`);
5745
+ if (fs22.existsSync(tsFilePath)) {
6045
5746
  try {
6046
5747
  if (!dryRun) {
6047
- fs23.unlinkSync(tsFilePath);
5748
+ fs22.unlinkSync(tsFilePath);
6048
5749
  }
6049
5750
  deletedFiles.push(`${cap.id}.ts`);
6050
5751
  } catch (error) {
@@ -6060,8 +5761,8 @@ function cleanupOldFiles(capabilities, dryRun) {
6060
5761
  }
6061
5762
 
6062
5763
  // src/commands/migration/versions/v001_capability/report-generator.ts
6063
- import fs24 from "fs";
6064
- import path22 from "path";
5764
+ import fs23 from "fs";
5765
+ import path21 from "path";
6065
5766
  var REPORT_FILE = "capability-migration-report.md";
6066
5767
  function printSummary(result) {
6067
5768
  const { jsonMigration, pluginInstallation, codeMigration, cleanup } = result;
@@ -6224,15 +5925,15 @@ async function generateReport(result) {
6224
5925
  }
6225
5926
  lines.push("");
6226
5927
  const logDir = process.env.LOG_DIR || "logs";
6227
- if (!fs24.existsSync(logDir)) {
5928
+ if (!fs23.existsSync(logDir)) {
6228
5929
  return;
6229
5930
  }
6230
- const reportDir = path22.join(logDir, "migration");
6231
- if (!fs24.existsSync(reportDir)) {
6232
- fs24.mkdirSync(reportDir, { recursive: true });
5931
+ const reportDir = path21.join(logDir, "migration");
5932
+ if (!fs23.existsSync(reportDir)) {
5933
+ fs23.mkdirSync(reportDir, { recursive: true });
6233
5934
  }
6234
- const reportPath = path22.join(reportDir, REPORT_FILE);
6235
- fs24.writeFileSync(reportPath, lines.join("\n"), "utf-8");
5935
+ const reportPath = path21.join(reportDir, REPORT_FILE);
5936
+ fs23.writeFileSync(reportPath, lines.join("\n"), "utf-8");
6236
5937
  console.log(`\u{1F4C4} Report generated: ${reportPath}`);
6237
5938
  }
6238
5939
 
@@ -6764,10 +6465,10 @@ var migrationCommand = {
6764
6465
  };
6765
6466
 
6766
6467
  // src/commands/read-logs/index.ts
6767
- import path23 from "path";
6468
+ import path22 from "path";
6768
6469
 
6769
6470
  // src/commands/read-logs/std-utils.ts
6770
- import fs25 from "fs";
6471
+ import fs24 from "fs";
6771
6472
  function formatStdPrefixTime(localTime) {
6772
6473
  const match = localTime.match(/^(\d{4})-(\d{2})-(\d{2}) (\d{2}):(\d{2}):(\d{2})$/);
6773
6474
  if (!match) return localTime;
@@ -6797,11 +6498,11 @@ function stripPrefixFromStdLine(line) {
6797
6498
  return `[${time}] ${content}`;
6798
6499
  }
6799
6500
  function readStdLinesTailFromLastMarkerPaged(filePath, maxLines, offset, isMarker) {
6800
- const stat = fs25.statSync(filePath);
6501
+ const stat = fs24.statSync(filePath);
6801
6502
  if (stat.size === 0) {
6802
6503
  return { lines: [], markerFound: false, totalLinesCount: 0 };
6803
6504
  }
6804
- const fd = fs25.openSync(filePath, "r");
6505
+ const fd = fs24.openSync(filePath, "r");
6805
6506
  const chunkSize = 64 * 1024;
6806
6507
  let position = stat.size;
6807
6508
  let remainder = "";
@@ -6815,7 +6516,7 @@ function readStdLinesTailFromLastMarkerPaged(filePath, maxLines, offset, isMarke
6815
6516
  const length = Math.min(chunkSize, position);
6816
6517
  position -= length;
6817
6518
  const buffer = Buffer.alloc(length);
6818
- fs25.readSync(fd, buffer, 0, length, position);
6519
+ fs24.readSync(fd, buffer, 0, length, position);
6819
6520
  let chunk = buffer.toString("utf8");
6820
6521
  if (remainder) {
6821
6522
  chunk += remainder;
@@ -6857,7 +6558,7 @@ function readStdLinesTailFromLastMarkerPaged(filePath, maxLines, offset, isMarke
6857
6558
  }
6858
6559
  }
6859
6560
  } finally {
6860
- fs25.closeSync(fd);
6561
+ fs24.closeSync(fd);
6861
6562
  }
6862
6563
  return { lines: collected.reverse(), markerFound, totalLinesCount };
6863
6564
  }
@@ -6878,21 +6579,21 @@ function readServerStdSegment(filePath, maxLines, offset) {
6878
6579
  }
6879
6580
 
6880
6581
  // src/commands/read-logs/tail.ts
6881
- import fs26 from "fs";
6582
+ import fs25 from "fs";
6882
6583
  function fileExists(filePath) {
6883
6584
  try {
6884
- fs26.accessSync(filePath, fs26.constants.F_OK | fs26.constants.R_OK);
6585
+ fs25.accessSync(filePath, fs25.constants.F_OK | fs25.constants.R_OK);
6885
6586
  return true;
6886
6587
  } catch {
6887
6588
  return false;
6888
6589
  }
6889
6590
  }
6890
6591
  function readFileTailLines(filePath, maxLines) {
6891
- const stat = fs26.statSync(filePath);
6592
+ const stat = fs25.statSync(filePath);
6892
6593
  if (stat.size === 0) {
6893
6594
  return [];
6894
6595
  }
6895
- const fd = fs26.openSync(filePath, "r");
6596
+ const fd = fs25.openSync(filePath, "r");
6896
6597
  const chunkSize = 64 * 1024;
6897
6598
  const chunks = [];
6898
6599
  let position = stat.size;
@@ -6902,13 +6603,13 @@ function readFileTailLines(filePath, maxLines) {
6902
6603
  const length = Math.min(chunkSize, position);
6903
6604
  position -= length;
6904
6605
  const buffer = Buffer.alloc(length);
6905
- fs26.readSync(fd, buffer, 0, length, position);
6606
+ fs25.readSync(fd, buffer, 0, length, position);
6906
6607
  chunks.unshift(buffer.toString("utf8"));
6907
6608
  const chunkLines = buffer.toString("utf8").split("\n").length - 1;
6908
6609
  collectedLines += chunkLines;
6909
6610
  }
6910
6611
  } finally {
6911
- fs26.closeSync(fd);
6612
+ fs25.closeSync(fd);
6912
6613
  }
6913
6614
  const content = chunks.join("");
6914
6615
  const allLines = content.split("\n");
@@ -6924,11 +6625,11 @@ function readFileTailLines(filePath, maxLines) {
6924
6625
  return allLines.slice(allLines.length - maxLines);
6925
6626
  }
6926
6627
  function readFileTailNonEmptyLinesWithOffset(filePath, maxLines, offset) {
6927
- const stat = fs26.statSync(filePath);
6628
+ const stat = fs25.statSync(filePath);
6928
6629
  if (stat.size === 0) {
6929
6630
  return { lines: [], totalLinesCount: 0 };
6930
6631
  }
6931
- const fd = fs26.openSync(filePath, "r");
6632
+ const fd = fs25.openSync(filePath, "r");
6932
6633
  const chunkSize = 64 * 1024;
6933
6634
  let position = stat.size;
6934
6635
  let remainder = "";
@@ -6940,7 +6641,7 @@ function readFileTailNonEmptyLinesWithOffset(filePath, maxLines, offset) {
6940
6641
  const length = Math.min(chunkSize, position);
6941
6642
  position -= length;
6942
6643
  const buffer = Buffer.alloc(length);
6943
- fs26.readSync(fd, buffer, 0, length, position);
6644
+ fs25.readSync(fd, buffer, 0, length, position);
6944
6645
  let chunk = buffer.toString("utf8");
6945
6646
  if (remainder) {
6946
6647
  chunk += remainder;
@@ -6971,7 +6672,7 @@ function readFileTailNonEmptyLinesWithOffset(filePath, maxLines, offset) {
6971
6672
  }
6972
6673
  }
6973
6674
  } finally {
6974
- fs26.closeSync(fd);
6675
+ fs25.closeSync(fd);
6975
6676
  }
6976
6677
  return { lines: collected.reverse(), totalLinesCount };
6977
6678
  }
@@ -7113,7 +6814,7 @@ function readDevStdSegment(filePath, maxLines, offset) {
7113
6814
  }
7114
6815
 
7115
6816
  // src/commands/read-logs/json-lines.ts
7116
- import fs27 from "fs";
6817
+ import fs26 from "fs";
7117
6818
  function normalizePid(value) {
7118
6819
  if (typeof value === "number") {
7119
6820
  return String(value);
@@ -7164,11 +6865,11 @@ function buildWantedLevelSet(levels) {
7164
6865
  return set.size > 0 ? set : null;
7165
6866
  }
7166
6867
  function readJsonLinesLastPid(filePath, maxLines, offset, levels) {
7167
- const stat = fs27.statSync(filePath);
6868
+ const stat = fs26.statSync(filePath);
7168
6869
  if (stat.size === 0) {
7169
6870
  return { lines: [], totalLinesCount: 0 };
7170
6871
  }
7171
- const fd = fs27.openSync(filePath, "r");
6872
+ const fd = fs26.openSync(filePath, "r");
7172
6873
  const chunkSize = 64 * 1024;
7173
6874
  let position = stat.size;
7174
6875
  let remainder = "";
@@ -7183,7 +6884,7 @@ function readJsonLinesLastPid(filePath, maxLines, offset, levels) {
7183
6884
  const length = Math.min(chunkSize, position);
7184
6885
  position -= length;
7185
6886
  const buffer = Buffer.alloc(length);
7186
- fs27.readSync(fd, buffer, 0, length, position);
6887
+ fs26.readSync(fd, buffer, 0, length, position);
7187
6888
  let chunk = buffer.toString("utf8");
7188
6889
  if (remainder) {
7189
6890
  chunk += remainder;
@@ -7245,7 +6946,7 @@ function readJsonLinesLastPid(filePath, maxLines, offset, levels) {
7245
6946
  }
7246
6947
  }
7247
6948
  } finally {
7248
- fs27.closeSync(fd);
6949
+ fs26.closeSync(fd);
7249
6950
  }
7250
6951
  return { lines: collected.reverse(), totalLinesCount };
7251
6952
  }
@@ -7288,11 +6989,11 @@ function extractTraceId(obj) {
7288
6989
  function readJsonLinesByTraceId(filePath, traceId, maxLines, offset, levels) {
7289
6990
  const wanted = traceId.trim();
7290
6991
  if (!wanted) return { lines: [], totalLinesCount: 0 };
7291
- const stat = fs27.statSync(filePath);
6992
+ const stat = fs26.statSync(filePath);
7292
6993
  if (stat.size === 0) {
7293
6994
  return { lines: [], totalLinesCount: 0 };
7294
6995
  }
7295
- const fd = fs27.openSync(filePath, "r");
6996
+ const fd = fs26.openSync(filePath, "r");
7296
6997
  const chunkSize = 64 * 1024;
7297
6998
  let position = stat.size;
7298
6999
  let remainder = "";
@@ -7305,7 +7006,7 @@ function readJsonLinesByTraceId(filePath, traceId, maxLines, offset, levels) {
7305
7006
  const length = Math.min(chunkSize, position);
7306
7007
  position -= length;
7307
7008
  const buffer = Buffer.alloc(length);
7308
- fs27.readSync(fd, buffer, 0, length, position);
7009
+ fs26.readSync(fd, buffer, 0, length, position);
7309
7010
  let chunk = buffer.toString("utf8");
7310
7011
  if (remainder) {
7311
7012
  chunk += remainder;
@@ -7358,7 +7059,7 @@ function readJsonLinesByTraceId(filePath, traceId, maxLines, offset, levels) {
7358
7059
  }
7359
7060
  }
7360
7061
  } finally {
7361
- fs27.closeSync(fd);
7062
+ fs26.closeSync(fd);
7362
7063
  }
7363
7064
  return { lines: collected.reverse(), totalLinesCount };
7364
7065
  }
@@ -7367,11 +7068,11 @@ function readJsonLinesTailByLevel(filePath, maxLines, offset, levels) {
7367
7068
  if (!wantedLevelSet) {
7368
7069
  return { lines: [], totalLinesCount: 0 };
7369
7070
  }
7370
- const stat = fs27.statSync(filePath);
7071
+ const stat = fs26.statSync(filePath);
7371
7072
  if (stat.size === 0) {
7372
7073
  return { lines: [], totalLinesCount: 0 };
7373
7074
  }
7374
- const fd = fs27.openSync(filePath, "r");
7075
+ const fd = fs26.openSync(filePath, "r");
7375
7076
  const chunkSize = 64 * 1024;
7376
7077
  let position = stat.size;
7377
7078
  let remainder = "";
@@ -7383,7 +7084,7 @@ function readJsonLinesTailByLevel(filePath, maxLines, offset, levels) {
7383
7084
  const length = Math.min(chunkSize, position);
7384
7085
  position -= length;
7385
7086
  const buffer = Buffer.alloc(length);
7386
- fs27.readSync(fd, buffer, 0, length, position);
7087
+ fs26.readSync(fd, buffer, 0, length, position);
7387
7088
  let chunk = buffer.toString("utf8");
7388
7089
  if (remainder) {
7389
7090
  chunk += remainder;
@@ -7430,7 +7131,7 @@ function readJsonLinesTailByLevel(filePath, maxLines, offset, levels) {
7430
7131
  }
7431
7132
  }
7432
7133
  } finally {
7433
- fs27.closeSync(fd);
7134
+ fs26.closeSync(fd);
7434
7135
  }
7435
7136
  return { lines: collected.reverse(), totalLinesCount };
7436
7137
  }
@@ -7664,30 +7365,30 @@ async function readLogsJsonResult(options) {
7664
7365
  };
7665
7366
  }
7666
7367
  function resolveLogFilePath(logDir, type) {
7667
- const base = path23.isAbsolute(logDir) ? logDir : path23.join(process.cwd(), logDir);
7368
+ const base = path22.isAbsolute(logDir) ? logDir : path22.join(process.cwd(), logDir);
7668
7369
  if (type === "server") {
7669
- return path23.join(base, "server.log");
7370
+ return path22.join(base, "server.log");
7670
7371
  }
7671
7372
  if (type === "trace") {
7672
- return path23.join(base, "trace.log");
7373
+ return path22.join(base, "trace.log");
7673
7374
  }
7674
7375
  if (type === "server-std") {
7675
- return path23.join(base, "server.std.log");
7376
+ return path22.join(base, "server.std.log");
7676
7377
  }
7677
7378
  if (type === "client-std") {
7678
- return path23.join(base, "client.std.log");
7379
+ return path22.join(base, "client.std.log");
7679
7380
  }
7680
7381
  if (type === "dev") {
7681
- return path23.join(base, "dev.log");
7382
+ return path22.join(base, "dev.log");
7682
7383
  }
7683
7384
  if (type === "dev-std") {
7684
- return path23.join(base, "dev.std.log");
7385
+ return path22.join(base, "dev.std.log");
7685
7386
  }
7686
7387
  if (type === "install-dep-std") {
7687
- return path23.join(base, "install-dep.std.log");
7388
+ return path22.join(base, "install-dep.std.log");
7688
7389
  }
7689
7390
  if (type === "browser") {
7690
- return path23.join(base, "browser.log");
7391
+ return path22.join(base, "browser.log");
7691
7392
  }
7692
7393
  throw new Error(`Unsupported log type: ${type}`);
7693
7394
  }
@@ -7864,9 +7565,9 @@ function camelToKebab(str) {
7864
7565
  }
7865
7566
 
7866
7567
  // src/commands/build/upload-static.handler.ts
7867
- import * as fs28 from "fs";
7868
- import * as os2 from "os";
7869
- import * as path24 from "path";
7568
+ import * as fs27 from "fs";
7569
+ import * as os from "os";
7570
+ import * as path23 from "path";
7870
7571
  import { execFileSync } from "child_process";
7871
7572
  function readCredentialsFromEnv() {
7872
7573
  const uploadPrefix = process.env.STATIC_UPLOAD_PREFIX;
@@ -7890,8 +7591,8 @@ async function uploadStatic(options) {
7890
7591
  endpoint = UPLOAD_STATIC_DEFAULTS.endpoint,
7891
7592
  region = UPLOAD_STATIC_DEFAULTS.region
7892
7593
  } = options;
7893
- const resolvedStaticDir = path24.resolve(staticDir);
7894
- if (!fs28.existsSync(resolvedStaticDir)) {
7594
+ const resolvedStaticDir = path23.resolve(staticDir);
7595
+ if (!fs27.existsSync(resolvedStaticDir)) {
7895
7596
  console.error(`${LOG_PREFIX} \u76EE\u5F55\u4E0D\u5B58\u5728: ${resolvedStaticDir}\uFF0C\u8DF3\u8FC7\u4E0A\u4F20`);
7896
7597
  return;
7897
7598
  }
@@ -7924,8 +7625,8 @@ async function uploadStatic(options) {
7924
7625
  ({ AccessKeyID: accessKeyID, SecretAccessKey: secretAccessKey, SessionToken: sessionToken } = uploadCredential);
7925
7626
  }
7926
7627
  console.error(`${LOG_PREFIX} \u4E0A\u4F20\u76EE\u6807: ${uploadPrefix}`);
7927
- const confPath = path24.join(os2.tmpdir(), `.tosutilconfig-static-${process.pid}`);
7928
- fs28.writeFileSync(confPath, "");
7628
+ const confPath = path23.join(os.tmpdir(), `.tosutilconfig-static-${process.pid}`);
7629
+ fs27.writeFileSync(confPath, "");
7929
7630
  try {
7930
7631
  console.error(`${LOG_PREFIX} \u914D\u7F6E tosutil...`);
7931
7632
  configureTosutil(resolvedTosutil, confPath, {
@@ -7939,7 +7640,7 @@ async function uploadStatic(options) {
7939
7640
  uploadToTos(resolvedTosutil, confPath, resolvedStaticDir, uploadPrefix);
7940
7641
  } finally {
7941
7642
  try {
7942
- fs28.unlinkSync(confPath);
7643
+ fs27.unlinkSync(confPath);
7943
7644
  } catch {
7944
7645
  }
7945
7646
  }
@@ -7959,8 +7660,8 @@ async function uploadStatic(options) {
7959
7660
  }
7960
7661
  }
7961
7662
  function resolveTosutilPath(tosutilPath) {
7962
- if (path24.isAbsolute(tosutilPath)) {
7963
- return fs28.existsSync(tosutilPath) ? tosutilPath : null;
7663
+ if (path23.isAbsolute(tosutilPath)) {
7664
+ return fs27.existsSync(tosutilPath) ? tosutilPath : null;
7964
7665
  }
7965
7666
  try {
7966
7667
  const resolved = execFileSync("which", [tosutilPath], { encoding: "utf-8" }).trim();
@@ -8005,7 +7706,7 @@ async function resolveBucketId(appId) {
8005
7706
  return bucketId;
8006
7707
  }
8007
7708
  function isDirEmpty(dirPath) {
8008
- const entries = fs28.readdirSync(dirPath);
7709
+ const entries = fs27.readdirSync(dirPath);
8009
7710
  return entries.length === 0;
8010
7711
  }
8011
7712
 
@@ -8093,19 +7794,18 @@ var commands = [
8093
7794
  upgradeCommand,
8094
7795
  actionPluginCommandGroup,
8095
7796
  capabilityCommandGroup,
8096
- componentCommandGroup,
8097
7797
  migrationCommand,
8098
7798
  readLogsCommand,
8099
7799
  buildCommandGroup
8100
7800
  ];
8101
7801
 
8102
7802
  // src/index.ts
8103
- var envPath = path25.join(process.cwd(), ".env");
8104
- if (fs29.existsSync(envPath)) {
7803
+ var envPath = path24.join(process.cwd(), ".env");
7804
+ if (fs28.existsSync(envPath)) {
8105
7805
  dotenvConfig({ path: envPath });
8106
7806
  }
8107
- var __dirname = path25.dirname(fileURLToPath5(import.meta.url));
8108
- var pkg = JSON.parse(fs29.readFileSync(path25.join(__dirname, "../package.json"), "utf-8"));
7807
+ var __dirname = path24.dirname(fileURLToPath5(import.meta.url));
7808
+ var pkg = JSON.parse(fs28.readFileSync(path24.join(__dirname, "../package.json"), "utf-8"));
8109
7809
  var cli = new FullstackCLI(pkg.version);
8110
7810
  cli.useAll(commands);
8111
7811
  cli.run();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lark-apaas/fullstack-cli",
3
- "version": "1.1.47",
3
+ "version": "1.1.48-alpha.0",
4
4
  "description": "CLI tool for fullstack template management",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -43,7 +43,6 @@
43
43
  "inflection": "^3.0.2",
44
44
  "pinyin-pro": "^3.27.0",
45
45
  "postgres": "^3.4.3",
46
- "shadcn": "3.8.2",
47
46
  "ts-morph": "^27.0.0",
48
47
  "zod-to-json-schema": "^3.24.1"
49
48
  },