@lark-apaas/fullstack-cli 1.1.6-alpha.3 → 1.1.6-alpha.4
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 +74 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -737,6 +737,70 @@ 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;
|
|
@@ -939,6 +1003,15 @@ async function list() {
|
|
|
939
1003
|
}
|
|
940
1004
|
|
|
941
1005
|
// src/commands/action-plugin/index.ts
|
|
1006
|
+
var initCommand = {
|
|
1007
|
+
name: "init",
|
|
1008
|
+
description: "Install all plugins from package.json",
|
|
1009
|
+
register(program) {
|
|
1010
|
+
program.command(this.name).description(this.description).action(async () => {
|
|
1011
|
+
await init();
|
|
1012
|
+
});
|
|
1013
|
+
}
|
|
1014
|
+
};
|
|
942
1015
|
var installCommand = {
|
|
943
1016
|
name: "install",
|
|
944
1017
|
description: "Install action plugin(s) (default: latest version)",
|
|
@@ -982,7 +1055,7 @@ var listCommand = {
|
|
|
982
1055
|
var actionPluginCommandGroup = {
|
|
983
1056
|
name: "action-plugin",
|
|
984
1057
|
description: "Manage action plugins",
|
|
985
|
-
commands: [installCommand, updateCommand, removeCommand, listCommand]
|
|
1058
|
+
commands: [initCommand, installCommand, updateCommand, removeCommand, listCommand]
|
|
986
1059
|
};
|
|
987
1060
|
|
|
988
1061
|
// src/commands/capability/utils.ts
|