MCPcopy Create free account
hub / github.com/Serverless-Devs/Serverless-Devs / start

Method start

src/command/env/command/update/action.ts:17–51  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

15 logger.debug(`s env update --option: ${JSON.stringify(options)}`);
16 }
17 async start() {
18 const { template = path.join(process.cwd(), 's.yaml'), ...rest } = this.options;
19 const newData = pick(rest, ENV_KEYS);
20 const envFilePath = await getEnvFilePath(template);
21
22 assert(fs.existsSync(envFilePath), `The file ${envFilePath} was not found`);
23 const { project, environments } = utils.getYamlContent(envFilePath);
24 const isExist = find(environments, item => item.name === this.options.name);
25 assert(isExist, `The environment ${this.options.name} was not found`);
26
27 // Updating Cloud Environment
28 const { access, ...envProps } = isExist;
29 const inputs = {
30 props: {
31 project,
32 ...envProps,
33 },
34 command: 'env',
35 args: ['update'],
36 };
37
38 const { project: p, ...envResult } = await runEnvComponent(inputs, access);
39 const newEnvironments = map(environments, item => {
40 if (item.name === this.options.name) {
41 return {
42 ...item,
43 ...newData,
44 ...envResult,
45 };
46 }
47 return item;
48 });
49 fs.writeFileSync(template, yaml.dump({ project, environments: newEnvironments }));
50 logger.write(chalk.green('Environment updated successfully'));
51 }
52}
53
54export default Action;

Callers 1

index.tsFile · 0.45

Calls 2

getEnvFilePathFunction · 0.90
runEnvComponentFunction · 0.90

Tested by

no test coverage detected