MCPcopy
hub / github.com/serverless/serverless / dev

Method dev

packages/serverless/lib/plugins/aws/dev/index.js:350–421  ·  view source on GitHub ↗

* The main handler for dev mode. Steps include: * - Packaging the shim and setting it as the service deployment artifact. * - Updating the service to use the shim. * - Spawn a deployment, which will deploy the shim. * - Restoring the state to what it was before. * - Connect to IoT ove

()

Source from the content-addressed store, hash-verified

348 * @returns {Promise<void>} This method is long running, so it does not return a value.
349 */
350 async dev() {
351 this.validateModeOption()
352
353 if (this.shouldUseAgentsDevMode()) {
354 return await this.startAgentsDevMode()
355 }
356
357 const mainProgress = progress.get('main')
358
359 this.validateOnExitOption()
360
361 this.serverless.devmodeEnabled = true
362 logger.logoDevMode()
363
364 // Educate
365 logger.blankLine()
366 logger.aside(
367 `Dev Mode redirects live AWS Lambda events to your local code enabling you to develop faster without the slowness of deploying changes.`,
368 )
369 logger.blankLine()
370 logger.aside(
371 `Docs: https://www.serverless.com/framework/docs/providers/aws/cli-reference/dev`,
372 )
373 logger.blankLine()
374 logger.aside(
375 `Run "serverless deploy" after a Dev Mode session to restore original code.`,
376 )
377
378 mainProgress.notice('Connecting')
379
380 // TODO: This should be applied more selectively
381 // usePolling is enabled because chokidar v4 removed fsevents support,
382 // causing "EMFILE: too many open files" errors on macOS with large projects
383 chokidar
384 .watch(this.serverless.config.serviceDir, {
385 ignored: /\.serverless/,
386 ignoreInitial: true,
387 usePolling: true,
388 })
389 .on('all', async (event, path) => {
390 await this.serverless.pluginManager.spawn('dev-build')
391 })
392
393 this.validateRegion()
394
395 await this.update()
396
397 this._updateHooks()
398
399 logger.debug(
400 `Spawning the deploy command to instrument your AWS Lambda functions with the dev mode shim`,
401 )
402 await this.serverless.pluginManager.spawn('deploy')
403
404 this.logOutputs()
405
406 // After deploying the shim, clear any package artifacts from the in-memory service config
407 // so that local dev builds (dev-build) do not skip building due to pre-set artifacts.

Callers 1

constructorMethod · 0.95

Calls 15

validateModeOptionMethod · 0.95
startAgentsDevModeMethod · 0.95
validateOnExitOptionMethod · 0.95
watchMethod · 0.95
validateRegionMethod · 0.95
updateMethod · 0.95
_updateHooksMethod · 0.95
logOutputsMethod · 0.95
unsetArtifactsMethod · 0.95
restoreMethod · 0.95
connectMethod · 0.95

Tested by

no test coverage detected