UNPKG

1.67 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 const analyticsConfig = {
32 collectorToken: flags.analyticsCollectorToken,
33 origin: flags.analyticsOrigin
34 }
35
36 if (!out) {
37 return Promise.reject(new Error('"--out" is mandatory'))
38 }
39
40 return lib.copyProject(cwd, out).then(projectPath => {
41 return lib
42 .applyTemplate(out)
43 .then(() => lib.copyWrapper(out))
44 .then(() => lib.copyConfiguration(out, projectPath, env))
45 .then(() => lib.registerFunctions(out, projectPath, env))
46 .then(() => lib.registerNodeVersion(out, bmServerVersion))
47 .then(() => lib.registerDeploymentBucket(out, deploymentBucket))
48 .then(() => lib.registerExecutionRole(out, executionRole))
49 .then(() => lib.registerRootProxy(out, env))
50 .then(() =>
51 lib.registerVpc(
52 out,
53 projectPath,
54 env,
55 vpcSecurityGroups,
56 vpcSubnets,
57 ','
58 )
59 )
60 .then(() => lib.registerVariables(out, projectPath, env, analyticsConfig))
61 })
62}