* 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
()
| 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 |
no test coverage detected