UNPKG

1.46 kBJavaScriptView Raw
1/* @flow */
2'use strict'
3
4/* ::
5import type {
6 CLIFlags,
7 CLIOptions
8} from '../types.js'
9*/
10
11/**
12bm serve serverless --input . --output /tmp/foobar
13*/
14
15const lib = require('../lib/serverless.js')
16
17module.exports = function (
18 input /* : Array<string> */,
19 flags /* : CLIFlags */,
20 logger /* : typeof console */,
21 options /* : CLIOptions */
22) /* : Promise<void> */ {
23 const cwd = flags.cwd
24 const out = flags.out
25 const env = flags.env
26 const bmServerVersion = flags.bmServerVersion
27 const vpcSecurityGroups = flags.vpcSecurityGroups || ''
28 const vpcSubnets = flags.vpcSubnets || ''
29 const deploymentBucket = flags.deploymentBucket
30 const executionRole = flags.executionRole
31
32 if (!out) {
33 return Promise.reject(new Error('"--out" is mandatory'))
34 }
35
36 return lib.copyProject(cwd, out)
37 .then((projectPath) => {
38 return lib.applyTemplate(out)
39 .then(() => lib.copyWrapper(out))
40 .then(() => lib.copyConfiguration(out, projectPath, env))
41 .then(() => lib.registerFunctions(out, projectPath, env))
42 .then(() => lib.registerNodeVersion(out, bmServerVersion))
43 .then(() => lib.registerDeploymentBucket(out, deploymentBucket))
44 .then(() => lib.registerExecutionRole(out, executionRole))
45 .then(() => lib.registerRootProxy(out, env))
46 .then(() => lib.registerVpc(out, vpcSecurityGroups, vpcSubnets, ','))
47 .then(() => lib.registerVariables(out, projectPath, env))
48 })
49}