Skip to content
This repository was archived by the owner on Apr 15, 2026. It is now read-only.

Commit 3e40d49

Browse files
committed
2 parents e28f16a + 27aa8d9 commit 3e40d49

12 files changed

Lines changed: 96 additions & 9 deletions

File tree

packages/framework-core/src/index.ts

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,11 @@ export { CloudApi } from "./api";
2222
export * from "./types";
2323

2424
const packageInfo = require("../package");
25-
const SUPPORT_COMMANDS = ["deploy", "compile"];
25+
const SUPPORT_COMMANDS = ["deploy", "compile", "run"];
26+
27+
interface CommandParams {
28+
runCommand?: string
29+
}
2630

2731
export async function run(
2832
{
@@ -33,7 +37,8 @@ export async function run(
3337
resourceProviders,
3438
}: CloudbaseFrameworkConfig,
3539
command: "deploy" = "deploy",
36-
module?: string
40+
module?: string,
41+
params?: CommandParams
3742
) {
3843
const logger = getLogger(logLevel);
3944

@@ -113,7 +118,7 @@ export async function run(
113118
await pluginManager.init(module);
114119
await pluginManager.build(module);
115120
const compileResult = await pluginManager.compile(module);
116-
await samManager.generate(
121+
samManager.generate(
117122
samMeta,
118123
JSON.parse(JSON.stringify(compileResult))
119124
);
@@ -124,10 +129,12 @@ export async function run(
124129
await pluginManager.build(module);
125130

126131
const compileResult = await pluginManager.compile(module);
127-
await samManager.generate(
132+
samManager.generate(
128133
samMeta,
129134
JSON.parse(JSON.stringify(compileResult))
130135
);
136+
} else if (command === "run") {
137+
await pluginManager.run(module, params?.runCommand);
131138
}
132139

133140
logger.info("✨ done");

packages/framework-core/src/plugin-manager/index.ts

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ interface PluginHookOption {
2626
icon?: string;
2727
}
2828

29-
type PluginHookName = "init" | "build" | "deploy" | "compile";
29+
type PluginHookName = "init" | "build" | "deploy" | "compile" | "run";
3030

3131
/**
3232
* 插件管理器
@@ -76,7 +76,7 @@ export default class PluginManager {
7676
}
7777

7878
/**
79-
* 部署
79+
* 编译
8080
*
8181
* @param id
8282
*/
@@ -99,6 +99,19 @@ export default class PluginManager {
9999
});
100100
}
101101

102+
/**
103+
* 执行本地命令
104+
*
105+
* @param id
106+
*/
107+
async run(id?: string, runCommand?: string) {
108+
return this.callPluginHook("run", {
109+
id,
110+
params: { runCommand },
111+
icon: emoji("🚢"),
112+
});
113+
}
114+
102115
/**
103116
* 调用插件钩子
104117
* @param id

packages/framework-core/src/plugin/index.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,13 @@ export default abstract class Plugin {
7272
*/
7373
abstract compile?(params: any): Promise<any>;
7474

75+
/**
76+
* 执行本地命令
77+
*
78+
* @param params 参数信息
79+
*/
80+
abstract run?(params: any): Promise<any>;
81+
7582
/**
7683
*
7784
* 移除资源

packages/framework-plugin-container/src/index.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,11 @@ class ContainerPlugin extends Plugin {
7171
this.api.logger.debug("ContainerPlugin: init", this.resolvedInputs);
7272
}
7373

74+
/**
75+
* 执行本地命令
76+
*/
77+
async run() {}
78+
7479
/**
7580
* 删除资源
7681
*/

packages/framework-plugin-dart/src/index.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,11 @@ class DartPlugin extends Plugin {
4444
return this.containerPlugin.compile();
4545
}
4646

47+
/**
48+
* 执行本地命令
49+
*/
50+
async run() {}
51+
4752
/**
4853
* 删除资源
4954
*/

packages/framework-plugin-database/src/index.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,11 @@ class DatabasePlugin extends Plugin {
5151
this.api.logger.debug("DatabasePlugin: init", this.resolvedInputs);
5252
}
5353

54+
/**
55+
* 执行本地命令
56+
*/
57+
async run() {}
58+
5459
/**
5560
* 删除资源
5661
*/

packages/framework-plugin-function/src/index.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,11 @@ class FunctionPlugin extends Plugin {
107107
};
108108
}
109109

110+
/**
111+
* 执行本地命令
112+
*/
113+
async run() {}
114+
110115
/**
111116
* 删除资源
112117
*/

packages/framework-plugin-node/src/index.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,11 @@ class NodePlugin extends Plugin {
6767
return this.pluginImpl.compile(params);
6868
}
6969

70+
/**
71+
* 执行本地命令
72+
*/
73+
async run() {}
74+
7075
/**
7176
* 删除资源
7277
*/

packages/framework-plugin-node/src/node-container-impl.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,11 @@ class NodeContainerPlugin extends Plugin {
4646
return this.containerPlugin.compile();
4747
}
4848

49+
/**
50+
* 执行本地命令
51+
*/
52+
async run() {}
53+
4954
/**
5055
* 删除资源
5156
*/

packages/framework-plugin-node/src/node-function-impl.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,11 @@ class NodeFunctionPlugin extends Plugin {
4545
return this.functionPlugin.compile();
4646
}
4747

48+
/**
49+
* 执行本地命令
50+
*/
51+
async run() {}
52+
4853
/**
4954
* 删除资源
5055
*/

0 commit comments

Comments
 (0)