@lark-apaas/fullstack-cli 1.1.6-alpha.2 → 1.1.6-alpha.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.
Files changed (2) hide show
  1. package/dist/index.js +51 -54
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -439,7 +439,6 @@ var syncCommand = {
439
439
  import fs3 from "fs";
440
440
  import path3 from "path";
441
441
  import { spawnSync as spawnSync2, execSync } from "child_process";
442
- var CONFIG_FILE_NAME = ".capabilityrc.json";
443
442
  function parsePluginName(input) {
444
443
  const match = input.match(/^(@[^/]+\/[^@]+)(?:@(.+))?$/);
445
444
  if (!match) {
@@ -455,36 +454,44 @@ function parsePluginName(input) {
455
454
  function getProjectRoot() {
456
455
  return process.cwd();
457
456
  }
458
- function getConfigPath() {
459
- return path3.join(getProjectRoot(), CONFIG_FILE_NAME);
457
+ function getPackageJsonPath() {
458
+ return path3.join(getProjectRoot(), "package.json");
460
459
  }
461
460
  function getPluginPath(pluginName) {
462
461
  return path3.join(getProjectRoot(), "node_modules", pluginName);
463
462
  }
464
- function readConfig() {
465
- const configPath = getConfigPath();
466
- if (!fs3.existsSync(configPath)) {
467
- return { plugins: {} };
463
+ function readPackageJson() {
464
+ const pkgPath = getPackageJsonPath();
465
+ if (!fs3.existsSync(pkgPath)) {
466
+ throw new Error("package.json not found in current directory");
468
467
  }
469
468
  try {
470
- const content = fs3.readFileSync(configPath, "utf-8");
469
+ const content = fs3.readFileSync(pkgPath, "utf-8");
471
470
  return JSON.parse(content);
472
471
  } catch {
473
- console.warn(`[action-plugin] Warning: Failed to parse ${CONFIG_FILE_NAME}, using empty config`);
474
- return { plugins: {} };
472
+ throw new Error("Failed to parse package.json");
475
473
  }
476
474
  }
477
- function writeConfig(config) {
478
- const configPath = getConfigPath();
479
- fs3.writeFileSync(configPath, JSON.stringify(config, null, 2) + "\n", "utf-8");
475
+ function writePackageJson(pkg2) {
476
+ const pkgPath = getPackageJsonPath();
477
+ fs3.writeFileSync(pkgPath, JSON.stringify(pkg2, null, 2) + "\n", "utf-8");
478
+ }
479
+ function readActionPlugins() {
480
+ const pkg2 = readPackageJson();
481
+ return pkg2.actionPlugins || {};
482
+ }
483
+ function writeActionPlugins(plugins) {
484
+ const pkg2 = readPackageJson();
485
+ pkg2.actionPlugins = plugins;
486
+ writePackageJson(pkg2);
480
487
  }
481
488
  function isPluginInstalled(pluginName) {
482
- const config = readConfig();
483
- return pluginName in config.plugins;
489
+ const plugins = readActionPlugins();
490
+ return pluginName in plugins;
484
491
  }
485
- function getInstalledPluginInfo(pluginName) {
486
- const config = readConfig();
487
- return config.plugins[pluginName] || null;
492
+ function getInstalledPluginVersion(pluginName) {
493
+ const plugins = readActionPlugins();
494
+ return plugins[pluginName] || null;
488
495
  }
489
496
  function npmInstall(tgzPath) {
490
497
  console.log(`[action-plugin] Running npm install ${tgzPath}...`);
@@ -737,21 +744,21 @@ async function installOne(nameWithVersion) {
737
744
  try {
738
745
  console.log(`[action-plugin] Installing ${name}@${requestedVersion}...`);
739
746
  if (isPluginInstalled(name) && requestedVersion !== "latest") {
740
- const info = getInstalledPluginInfo(name);
741
- if (info && info.version === requestedVersion) {
747
+ const installedVer = getInstalledPluginVersion(name);
748
+ if (installedVer === requestedVersion) {
742
749
  console.log(`[action-plugin] Plugin ${name}@${requestedVersion} is already installed`);
743
- return { name, version: info.version, success: true, skipped: true };
750
+ return { name, version: installedVer, success: true, skipped: true };
744
751
  }
745
752
  }
746
753
  if (isPluginInstalled(name) && requestedVersion === "latest") {
747
- const info = getInstalledPluginInfo(name);
748
- if (info) {
754
+ const installedVer = getInstalledPluginVersion(name);
755
+ if (installedVer) {
749
756
  const latestInfo = await getPluginVersion(name, "latest");
750
- if (info.version === latestInfo.version) {
751
- console.log(`[action-plugin] Plugin ${name} is already up to date (version: ${info.version})`);
752
- return { name, version: info.version, success: true, skipped: true };
757
+ if (installedVer === latestInfo.version) {
758
+ console.log(`[action-plugin] Plugin ${name} is already up to date (version: ${installedVer})`);
759
+ return { name, version: installedVer, success: true, skipped: true };
753
760
  }
754
- console.log(`[action-plugin] Found newer version: ${latestInfo.version} (installed: ${info.version})`);
761
+ console.log(`[action-plugin] Found newer version: ${latestInfo.version} (installed: ${installedVer})`);
755
762
  }
756
763
  }
757
764
  const downloadResult = await downloadPlugin(name, requestedVersion);
@@ -766,12 +773,9 @@ async function installOne(nameWithVersion) {
766
773
  }
767
774
  }
768
775
  const installedVersion = getPackageVersion(name) || downloadResult.version;
769
- const config = readConfig();
770
- config.plugins[name] = {
771
- version: installedVersion,
772
- installedAt: (/* @__PURE__ */ new Date()).toISOString()
773
- };
774
- writeConfig(config);
776
+ const plugins = readActionPlugins();
777
+ plugins[name] = installedVersion;
778
+ writeActionPlugins(plugins);
775
779
  console.log(`[action-plugin] Successfully installed ${name}@${installedVersion}`);
776
780
  return { name, version: installedVersion, success: true };
777
781
  } catch (error) {
@@ -824,23 +828,19 @@ async function updateOne(nameWithVersion) {
824
828
  console.error(`[action-plugin] Plugin ${name} is not installed`);
825
829
  return { name, success: false, notInstalled: true };
826
830
  }
827
- const currentInfo = getInstalledPluginInfo(name);
828
- const oldVersion = currentInfo?.version || "unknown";
831
+ const oldVersion = getInstalledPluginVersion(name) || "unknown";
829
832
  console.log(`[action-plugin] Current version: ${oldVersion}`);
830
833
  const downloadResult = await downloadPlugin(name, "latest");
831
834
  tgzPath = downloadResult.tgzPath;
832
- if (currentInfo && currentInfo.version === downloadResult.version) {
835
+ if (oldVersion === downloadResult.version) {
833
836
  console.log(`[action-plugin] Plugin ${name} is already up to date (version: ${downloadResult.version})`);
834
837
  return { name, oldVersion, newVersion: downloadResult.version, success: true, skipped: true };
835
838
  }
836
839
  npmInstall(tgzPath);
837
840
  const installedVersion = getPackageVersion(name) || downloadResult.version;
838
- const config = readConfig();
839
- config.plugins[name] = {
840
- version: installedVersion,
841
- installedAt: (/* @__PURE__ */ new Date()).toISOString()
842
- };
843
- writeConfig(config);
841
+ const plugins = readActionPlugins();
842
+ plugins[name] = installedVersion;
843
+ writeActionPlugins(plugins);
844
844
  console.log(`[action-plugin] Successfully updated ${name} to ${installedVersion}`);
845
845
  return { name, oldVersion, newVersion: installedVersion, success: true };
846
846
  } catch (error) {
@@ -897,9 +897,9 @@ async function remove(nameWithVersion) {
897
897
  process.exit(1);
898
898
  }
899
899
  removePluginDirectory(name);
900
- const config = readConfig();
901
- delete config.plugins[name];
902
- writeConfig(config);
900
+ const plugins = readActionPlugins();
901
+ delete plugins[name];
902
+ writeActionPlugins(plugins);
903
903
  console.log(`[action-plugin] Successfully removed ${name}`);
904
904
  } catch (error) {
905
905
  const message = error instanceof Error ? error.message : String(error);
@@ -911,25 +911,22 @@ async function remove(nameWithVersion) {
911
911
  // src/commands/action-plugin/list.handler.ts
912
912
  async function list() {
913
913
  try {
914
- const config = readConfig();
915
- const plugins = Object.entries(config.plugins);
914
+ const plugins = Object.entries(readActionPlugins());
916
915
  if (plugins.length === 0) {
917
916
  console.log("[action-plugin] No plugins installed");
918
917
  console.log('[action-plugin] Use "action-plugin install <name>" to install a plugin');
919
918
  return;
920
919
  }
921
920
  console.log("[action-plugin] Installed plugins:\n");
922
- const nameWidth = Math.max(30, ...plugins.map(([name]) => name.length + 2));
921
+ const nameWidth = Math.max(40, ...plugins.map(([name]) => name.length + 2));
923
922
  const versionWidth = 15;
924
- const dateWidth = 25;
925
923
  console.log(
926
- " " + "Plugin".padEnd(nameWidth) + "Version".padEnd(versionWidth) + "Installed At"
924
+ " " + "Plugin".padEnd(nameWidth) + "Version"
927
925
  );
928
- console.log(" " + "-".repeat(nameWidth + versionWidth + dateWidth));
929
- for (const [name, info] of plugins) {
930
- const installedAt = new Date(info.installedAt).toLocaleString();
926
+ console.log(" " + "-".repeat(nameWidth + versionWidth));
927
+ for (const [name, version] of plugins) {
931
928
  console.log(
932
- " " + name.padEnd(nameWidth) + info.version.padEnd(versionWidth) + installedAt
929
+ " " + name.padEnd(nameWidth) + version
933
930
  );
934
931
  }
935
932
  console.log(`
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lark-apaas/fullstack-cli",
3
- "version": "1.1.6-alpha.2",
3
+ "version": "1.1.6-alpha.3",
4
4
  "description": "CLI tool for fullstack template management",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",