MCPcopy
hub / github.com/serverless/serverless / init

Method init

packages/serverless/lib/serverless.js:147–168  ·  view source on GitHub ↗

* Initializes the serverless instance. This method is responsible for creating * an instance ID, initializing a new CLI instance, setting CLI options and * commands, loading the service and all plugins, and setting the loaded plugins * and commands for the CLI. This is typically called at t

()

Source from the content-addressed store, hash-verified

145 * @throws {Error} If there's an error in loading the service or plugins.
146 */
147 async init() {
148 logger.debug('Initializing')
149 // create an instanceId (can be e.g. used when a predictable random value is needed)
150 this.instanceId = this.instanceId ?? new Date().getTime().toString()
151
152 // create a new CLI instance
153 this.cli = new this.classes.CLI(this)
154
155 // set the options and commands which were processed by the CLI
156 this.pluginManager.setCliOptions(this.processedInput.options)
157 this.pluginManager.setCliCommands(this.processedInput.commands)
158 await this.service.load(this.processedInput.options)
159
160 // load all plugins
161 await this.pluginManager.loadAllPlugins(this.service.plugins)
162 this.isConfigurationExtendable = false
163
164 // give the CLI the plugins and commands so that it can print out
165 // information such as options when the user enters --help
166 this.cli.setLoadedPlugins(this.pluginManager.getPlugins())
167 this.cli.setLoadedCommands(this.pluginManager.getCommands())
168 }
169
170 /**
171 * Executes the Serverless instance. This method is responsible for reloading

Callers 2

runFrameworkFunction · 0.95
index.test.jsFile · 0.45

Calls 9

debugMethod · 0.80
setCliOptionsMethod · 0.80
setCliCommandsMethod · 0.80
loadMethod · 0.80
setLoadedPluginsMethod · 0.80
getPluginsMethod · 0.80
setLoadedCommandsMethod · 0.80
getCommandsMethod · 0.80
loadAllPluginsMethod · 0.45

Tested by

no test coverage detected