@@ -27,6 +27,7 @@ const trigger_delete_1 = require("./trigger-delete");
2727const invoke_1 = require ( "./invoke" ) ;
2828const copy_1 = require ( "./copy" ) ;
2929const code_download_1 = require ( "./code-download" ) ;
30+ const run_1 = require ( "./run" ) ;
3031function getFunctionContext ( name , envId , configPath ) {
3132 return __awaiter ( this , void 0 , void 0 , function * ( ) {
3233 const cloudBaseConfig = yield utils_1 . resolveCloudBaseConfig ( configPath ) ;
@@ -121,16 +122,6 @@ const commands = [
121122 yield detail_1 . detail ( ctx , options ) ;
122123 } )
123124 } ,
124- {
125- cmd : 'functions:invoke [functionName] [params] [envId]' ,
126- options : [ ] ,
127- desc : '触发云函数' ,
128- handler : ( name , jsonStringParams , envId , options ) => __awaiter ( void 0 , void 0 , void 0 , function * ( ) {
129- const { configFile } = options . parent ;
130- const ctx = yield getFunctionContext ( name , envId , configFile ) ;
131- yield invoke_1 . invoke ( ctx , jsonStringParams ) ;
132- } )
133- } ,
134125 {
135126 cmd : 'functions:code:update <functionName> [envId]' ,
136127 options : [
@@ -232,6 +223,54 @@ const commands = [
232223 const ctx = yield getFunctionContext ( functionName , envId , configFile ) ;
233224 yield trigger_delete_1 . triggerDelete ( ctx , triggerName ) ;
234225 } )
226+ } ,
227+ {
228+ cmd : 'functions:invoke [functionName] [params] [envId]' ,
229+ options : [ ] ,
230+ desc : '触发云端部署的云函数' ,
231+ handler : ( name , jsonStringParams , envId , options ) => __awaiter ( void 0 , void 0 , void 0 , function * ( ) {
232+ const { configFile } = options . parent ;
233+ const ctx = yield getFunctionContext ( name , envId , configFile ) ;
234+ yield invoke_1 . invoke ( ctx , jsonStringParams ) ;
235+ } )
236+ } ,
237+ {
238+ cmd : 'functions:run' ,
239+ options : [
240+ {
241+ flags : '--path <path>' ,
242+ desc : '云函数路径,使用默认配置直接调用云函数,无需配置文件'
243+ } ,
244+ {
245+ flags : '--name <name>' ,
246+ desc : '指定云函数的名称进行调用,需要配置文件'
247+ } ,
248+ {
249+ flags : '--params <params>' ,
250+ desc : '调用函数传入的参数,JSON 字符串格式'
251+ } ,
252+ {
253+ flags : '--port <port>' ,
254+ desc : '启动调试时监听的端口号,默认为 9229'
255+ } ,
256+ {
257+ flags : '--debug' ,
258+ desc : '启动调试模式'
259+ }
260+ ] ,
261+ desc : '本地运行云函数(当前仅支持 Node)' ,
262+ handler : ( options ) => __awaiter ( void 0 , void 0 , void 0 , function * ( ) {
263+ const { path } = options ;
264+ if ( path ) {
265+ yield run_1 . debugFunctionByPath ( path , options ) ;
266+ }
267+ else {
268+ const { name } = options ;
269+ const { configFile } = options . parent ;
270+ const ctx = yield getFunctionContext ( name , '' , configFile ) ;
271+ yield run_1 . debugByConfig ( ctx , options ) ;
272+ }
273+ } )
235274 }
236275] ;
237276commands . forEach ( item => {
0 commit comments