Skip to content

Commit

Permalink
fix:fc3 sync 指令,应该包含 asyncinvokeconfig, provision 和 concurrency
Browse files Browse the repository at this point in the history
  • Loading branch information
mozhou52 committed Oct 15, 2024
1 parent 0b88a78 commit deff8f8
Showing 1 changed file with 40 additions and 2 deletions.
42 changes: 40 additions & 2 deletions src/subCommands/sync/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,8 @@ export default class Sync {
const triggers = await this.getTriggers();
let asyncInvokeConfig = {};
let vpcBindingConfig = {};
let concurrencyConfig = {};
let provisionConfig = {};
try {
asyncInvokeConfig = await this.fcSdk.getAsyncInvokeConfig(
this.functionName,
Expand All @@ -96,6 +98,18 @@ export default class Sync {
// eslint-disable-next-line no-empty
}

try {
provisionConfig = await this.fcSdk.getFunctionProvisionConfig(this.functionName, 'LATEST');
} catch (ex) {
// eslint-disable-next-line no-empty
}

try {
concurrencyConfig = await this.fcSdk.getFunctionConcurrency(this.functionName);
} catch (ex) {
// eslint-disable-next-line no-empty
}

try {
vpcBindingConfig = await this.fcSdk.getVpcBinding(
this.functionName,
Expand All @@ -104,10 +118,24 @@ export default class Sync {
} catch (ex) {
// eslint-disable-next-line no-empty
}
return await this.write(functionInfo, triggers, asyncInvokeConfig, vpcBindingConfig);
return await this.write(
functionInfo,
triggers,
asyncInvokeConfig,
vpcBindingConfig,
concurrencyConfig,
provisionConfig,
);
}

async write(functionConfig: any, triggers: any, asyncInvokeConfig: any, vpcBindingConfig: any) {
async write(
functionConfig: any,
triggers: any,
asyncInvokeConfig: any,
vpcBindingConfig: any,
concurrencyConfig: any,
provisionConfig: any,
) {
const syncFolderName = 'sync-clone';

const baseDir = this.target
Expand Down Expand Up @@ -156,6 +184,16 @@ export default class Sync {
if (!_.isEmpty(asyncInvokeConfig)) {
props.asyncInvokeConfig = asyncInvokeConfig;
}
if (!_.isEmpty(provisionConfig)) {
_.unset(provisionConfig, 'current');
_.unset(provisionConfig, 'currentError');
_.unset(provisionConfig, 'functionArn');
props.provisionConfig = provisionConfig;
}
if (!_.isEmpty(concurrencyConfig)) {
_.unset(concurrencyConfig, 'functionArn');
props.concurrencyConfig = concurrencyConfig;
}

if (!_.isEmpty(vpcBindingConfig)) {
const vpcIds = _.get(functionConfig.vpcBinding, 'vpcIds', []);
Expand Down

0 comments on commit deff8f8

Please sign in to comment.