@lark-apaas/fullstack-cli 1.1.6-alpha.3 → 1.1.6-alpha.5
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 +84 -14
- package/package.json +1 -1
- package/templates/scripts/build.sh +7 -0
package/dist/index.js
CHANGED
|
@@ -737,29 +737,90 @@ function cleanupTempFile(tgzPath) {
|
|
|
737
737
|
}
|
|
738
738
|
}
|
|
739
739
|
|
|
740
|
+
// src/commands/action-plugin/init.handler.ts
|
|
741
|
+
async function installOneForInit(name, version) {
|
|
742
|
+
let tgzPath;
|
|
743
|
+
try {
|
|
744
|
+
const installedVersion = getPackageVersion(name);
|
|
745
|
+
if (installedVersion === version) {
|
|
746
|
+
return { name, version, success: true, skipped: true };
|
|
747
|
+
}
|
|
748
|
+
console.log(`[action-plugin] Installing ${name}@${version}...`);
|
|
749
|
+
const downloadResult = await downloadPlugin(name, version);
|
|
750
|
+
tgzPath = downloadResult.tgzPath;
|
|
751
|
+
const pluginDir = extractTgzToNodeModules(tgzPath, name);
|
|
752
|
+
const pluginPkg = readPluginPackageJson(pluginDir);
|
|
753
|
+
if (pluginPkg?.peerDependencies) {
|
|
754
|
+
const missingDeps = checkMissingPeerDeps(pluginPkg.peerDependencies);
|
|
755
|
+
if (missingDeps.length > 0) {
|
|
756
|
+
installMissingDeps(missingDeps);
|
|
757
|
+
}
|
|
758
|
+
}
|
|
759
|
+
console.log(`[action-plugin] \u2713 Installed ${name}@${version}`);
|
|
760
|
+
return { name, version, success: true };
|
|
761
|
+
} catch (error) {
|
|
762
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
763
|
+
console.error(`[action-plugin] \u2717 Failed to install ${name}: ${message}`);
|
|
764
|
+
return { name, version, success: false, error: message };
|
|
765
|
+
} finally {
|
|
766
|
+
if (tgzPath) {
|
|
767
|
+
cleanupTempFile(tgzPath);
|
|
768
|
+
}
|
|
769
|
+
}
|
|
770
|
+
}
|
|
771
|
+
async function init() {
|
|
772
|
+
console.log("[action-plugin] Reading plugins from package.json...");
|
|
773
|
+
const plugins = readActionPlugins();
|
|
774
|
+
const entries = Object.entries(plugins);
|
|
775
|
+
if (entries.length === 0) {
|
|
776
|
+
console.log("[action-plugin] No plugins found in package.json");
|
|
777
|
+
return;
|
|
778
|
+
}
|
|
779
|
+
console.log(`[action-plugin] Found ${entries.length} plugin(s) to install
|
|
780
|
+
`);
|
|
781
|
+
const results = [];
|
|
782
|
+
for (const [name, version] of entries) {
|
|
783
|
+
const result = await installOneForInit(name, version);
|
|
784
|
+
results.push(result);
|
|
785
|
+
}
|
|
786
|
+
console.log("");
|
|
787
|
+
const successful = results.filter((r) => r.success && !r.skipped);
|
|
788
|
+
const skipped = results.filter((r) => r.skipped);
|
|
789
|
+
const failed = results.filter((r) => !r.success);
|
|
790
|
+
if (successful.length > 0 || skipped.length > 0) {
|
|
791
|
+
console.log(
|
|
792
|
+
`[action-plugin] \u2713 All plugins installed successfully (${successful.length + skipped.length}/${entries.length})`
|
|
793
|
+
);
|
|
794
|
+
if (skipped.length > 0) {
|
|
795
|
+
console.log(` Skipped (already installed): ${skipped.map((r) => r.name).join(", ")}`);
|
|
796
|
+
}
|
|
797
|
+
}
|
|
798
|
+
if (failed.length > 0) {
|
|
799
|
+
console.log(`[action-plugin] \u2717 Failed to install ${failed.length} plugin(s): ${failed.map((r) => r.name).join(", ")}`);
|
|
800
|
+
process.exit(1);
|
|
801
|
+
}
|
|
802
|
+
}
|
|
803
|
+
|
|
740
804
|
// src/commands/action-plugin/install.handler.ts
|
|
741
805
|
async function installOne(nameWithVersion) {
|
|
742
806
|
let tgzPath;
|
|
743
807
|
const { name, version: requestedVersion } = parsePluginName(nameWithVersion);
|
|
744
808
|
try {
|
|
745
809
|
console.log(`[action-plugin] Installing ${name}@${requestedVersion}...`);
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
if (
|
|
810
|
+
const actualVersion = getPackageVersion(name);
|
|
811
|
+
if (actualVersion && requestedVersion !== "latest") {
|
|
812
|
+
if (actualVersion === requestedVersion) {
|
|
749
813
|
console.log(`[action-plugin] Plugin ${name}@${requestedVersion} is already installed`);
|
|
750
|
-
return { name, version:
|
|
814
|
+
return { name, version: actualVersion, success: true, skipped: true };
|
|
751
815
|
}
|
|
752
816
|
}
|
|
753
|
-
if (
|
|
754
|
-
const
|
|
755
|
-
if (
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
console.log(`[action-plugin] Plugin ${name} is already up to date (version: ${installedVer})`);
|
|
759
|
-
return { name, version: installedVer, success: true, skipped: true };
|
|
760
|
-
}
|
|
761
|
-
console.log(`[action-plugin] Found newer version: ${latestInfo.version} (installed: ${installedVer})`);
|
|
817
|
+
if (actualVersion && requestedVersion === "latest") {
|
|
818
|
+
const latestInfo = await getPluginVersion(name, "latest");
|
|
819
|
+
if (actualVersion === latestInfo.version) {
|
|
820
|
+
console.log(`[action-plugin] Plugin ${name} is already up to date (version: ${actualVersion})`);
|
|
821
|
+
return { name, version: actualVersion, success: true, skipped: true };
|
|
762
822
|
}
|
|
823
|
+
console.log(`[action-plugin] Found newer version: ${latestInfo.version} (installed: ${actualVersion})`);
|
|
763
824
|
}
|
|
764
825
|
const downloadResult = await downloadPlugin(name, requestedVersion);
|
|
765
826
|
tgzPath = downloadResult.tgzPath;
|
|
@@ -939,6 +1000,15 @@ async function list() {
|
|
|
939
1000
|
}
|
|
940
1001
|
|
|
941
1002
|
// src/commands/action-plugin/index.ts
|
|
1003
|
+
var initCommand = {
|
|
1004
|
+
name: "init",
|
|
1005
|
+
description: "Install all plugins from package.json",
|
|
1006
|
+
register(program) {
|
|
1007
|
+
program.command(this.name).description(this.description).action(async () => {
|
|
1008
|
+
await init();
|
|
1009
|
+
});
|
|
1010
|
+
}
|
|
1011
|
+
};
|
|
942
1012
|
var installCommand = {
|
|
943
1013
|
name: "install",
|
|
944
1014
|
description: "Install action plugin(s) (default: latest version)",
|
|
@@ -982,7 +1052,7 @@ var listCommand = {
|
|
|
982
1052
|
var actionPluginCommandGroup = {
|
|
983
1053
|
name: "action-plugin",
|
|
984
1054
|
description: "Manage action plugins",
|
|
985
|
-
commands: [installCommand, updateCommand, removeCommand, listCommand]
|
|
1055
|
+
commands: [initCommand, installCommand, updateCommand, removeCommand, listCommand]
|
|
986
1056
|
};
|
|
987
1057
|
|
|
988
1058
|
// src/commands/capability/utils.ts
|
package/package.json
CHANGED
|
@@ -18,6 +18,13 @@ print_time() {
|
|
|
18
18
|
echo " ⏱️ 耗时: ${seconds}.$(printf "%03d" $ms)s"
|
|
19
19
|
}
|
|
20
20
|
|
|
21
|
+
# ==================== 步骤 0 ====================
|
|
22
|
+
echo "🗑️ [0/4] 安装插件"
|
|
23
|
+
STEP_START=$(node -e "console.log(Date.now())")
|
|
24
|
+
npx fullstack-cli action-plugin init
|
|
25
|
+
print_time $STEP_START
|
|
26
|
+
echo ""
|
|
27
|
+
|
|
21
28
|
# ==================== 步骤 0 ====================
|
|
22
29
|
echo "📝 [0/4] 更新 openapi 代码"
|
|
23
30
|
STEP_START=$(node -e "console.log(Date.now())")
|