Skip to content
This repository was archived by the owner on May 6, 2025. It is now read-only.

Commit b9924b6

Browse files
zijiezhouhengechang
authored andcommitted
fix: change service:create params
1 parent 54f8b4a commit b9924b6

5 files changed

Lines changed: 20 additions & 13 deletions

File tree

lib/commands/gateway/create.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,13 @@ const error_1 = require("../../error");
1717
const gateway_1 = require("../../gateway");
1818
const function_1 = require("../../function");
1919
const utils_1 = require("../../utils");
20-
function createGw(ctx, servicePath, commandOptions) {
20+
function createGw(ctx, commandOptions) {
2121
return __awaiter(this, void 0, void 0, function* () {
2222
const { envId } = ctx;
23+
const { function: functionName, servicePath } = commandOptions;
2324
if (!servicePath) {
2425
throw new error_1.CloudBaseError('请指定需要创建的 HTTP service 路径!');
2526
}
26-
const { function: functionName } = commandOptions;
2727
if (functionName) {
2828
const loading = utils_1.loadingFactory();
2929
loading.start(`[${functionName}] 云函数 HTTP service 创建中...`);

lib/commands/gateway/index.js

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,22 +37,26 @@ function getGatewayContext(envId, configPath) {
3737
}
3838
const commands = [
3939
{
40-
cmd: 'service:create <servicePath>',
40+
cmd: 'service:create',
4141
options: [
4242
{
4343
flags: '-e, --envId [envId]',
4444
desc: '环境 Id'
4545
},
46+
{
47+
flags: '-p, --service-path <servicePath>',
48+
desc: 'Service Path'
49+
},
4650
{
4751
flags: '-f, --function <function>',
4852
desc: '创建云函数HTTP service'
4953
}
5054
],
5155
desc: '创建HTTP service',
52-
handler: (servicePath, options) => __awaiter(void 0, void 0, void 0, function* () {
56+
handler: (options) => __awaiter(void 0, void 0, void 0, function* () {
5357
const { parent: { configFile }, envId } = options;
5458
const ctx = yield getGatewayContext(envId, configFile);
55-
yield create_1.createGw(ctx, servicePath, options);
59+
yield create_1.createGw(ctx, options);
5660
})
5761
},
5862
{

src/commands/gateway/create.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,15 @@ import { createFunctionGateway } from '../../gateway'
55
import { listFunction } from '../../function'
66
import { loadingFactory } from '../../utils'
77

8-
export async function createGw(ctx: GatewayContext, servicePath: string, commandOptions) {
8+
export async function createGw(ctx: GatewayContext, commandOptions) {
99
const { envId } = ctx
1010

11+
const { function: functionName, servicePath } = commandOptions
12+
1113
if (!servicePath) {
1214
throw new CloudBaseError('请指定需要创建的 HTTP service 路径!')
1315
}
14-
15-
const { function: functionName } = commandOptions
16-
16+
1717
// 创建云函数网关
1818
if (functionName) {
1919
const loading = loadingFactory()

src/commands/gateway/index.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,28 +32,31 @@ async function getGatewayContext(
3232

3333
const commands = [
3434
{
35-
cmd: 'service:create <servicePath>',
35+
cmd: 'service:create',
3636
options: [
3737
{
3838
flags: '-e, --envId [envId]',
3939
desc: '环境 Id'
4040
},
41+
{
42+
flags: '-p, --service-path <servicePath>',
43+
desc: 'Service Path'
44+
},
4145
{
4246
flags: '-f, --function <function>',
4347
desc: '创建云函数HTTP service'
4448
}
4549
],
4650
desc: '创建HTTP service',
4751
handler: async (
48-
servicePath:string,
4952
options
5053
) => {
5154
const {
5255
parent: { configFile },
5356
envId
5457
} = options
5558
const ctx = await getGatewayContext(envId, configFile)
56-
await createGw(ctx, servicePath, options)
59+
await createGw(ctx, options)
5760
}
5861
},
5962

types/commands/gateway/create.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
import { GatewayContext } from '../../types';
2-
export declare function createGw(ctx: GatewayContext, servicePath: string, commandOptions: any): Promise<void>;
2+
export declare function createGw(ctx: GatewayContext, commandOptions: any): Promise<void>;

0 commit comments

Comments
 (0)