Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
public async onDeploy (data: DeployData, next: Next) {
data.logger!.debug('[CloudFunction] 组装云函数配置');
data.logger!.debug('%o', data);
const config = deepMerge(data.config!.plugins![this.name || this.type], { config: this.config });
data.logger!.debug('[CloudFunction] 组装完成 %o', config);
// 引用服务商部署插件
// eslint-disable-next-line security/detect-non-literal-require, @typescript-eslint/no-var-requires
const Provider = require(config.provider.type);
const provider = new Provider(config.provider.config);
data.dependencies![config.provider.type as string] = loadNpmVersion(config.provider.type);
// 部署云函数
await provider.deploy(this.type, data, config);
await next();
}
public async onDeploy (data: DeployData, next: Next) {
switch (this.adapterType || data.config!.plugins[this.name || this.type].adapter) {
case 'sqlite':
data.dependencies!['sqlite3'] = loadNpmVersion('sqlite3')!;
break;
case 'postgresql':
data.dependencies!['pg'] = loadNpmVersion('pg')!;
break;
case 'mysql':
data.dependencies!['mysql'] = loadNpmVersion('mysql')!;
break;
default:
throw Error(`[Sql] Unsupport type: ${this.adapterType || data.config!.plugins[this.name || this.type].type}`);
}
await next();
}
public async onDeploy (data: DeployData, next: Next) {
switch (this.adapterType || data.config!.plugins[this.name || this.type].adapter) {
case 'sqlite':
data.dependencies!['sqlite3'] = loadNpmVersion('sqlite3')!;
break;
case 'postgresql':
data.dependencies!['pg'] = loadNpmVersion('pg')!;
break;
case 'mysql':
data.dependencies!['mysql'] = loadNpmVersion('mysql')!;
break;
default:
throw Error(`[Sql] Unsupport type: ${this.adapterType || data.config!.plugins[this.name || this.type].type}`);
}
await next();
}
public async onDeploy (data: DeployData, next: Next) {
switch (this.adapterType || data.config!.plugins[this.name || this.type].adapter) {
case 'sqlite':
data.dependencies!['sqlite3'] = loadNpmVersion('sqlite3')!;
break;
case 'postgresql':
data.dependencies!['pg'] = loadNpmVersion('pg')!;
break;
case 'mysql':
data.dependencies!['mysql'] = loadNpmVersion('mysql')!;
break;
default:
throw Error(`[Sql] Unsupport type: ${this.adapterType || data.config!.plugins[this.name || this.type].type}`);
}
await next();
}