{"id":15233,"library":"serverless-plugin-scripts","title":"Serverless Plugin Scripts","description":"serverless-plugin-scripts is a utility plugin for the Serverless Framework that extends its capabilities by allowing users to define custom shell commands and attach scripts to existing Serverless lifecycle events directly within their `serverless.yml` configuration files. The latest stable version, 1.0.2, was released in October 2017. As the project has not seen any updates or commits since then, it is considered abandoned and is no longer actively maintained. While it might still function with older Serverless Framework versions (specifically pre-v2, and likely struggling with v3+), it lacks compatibility with recent major Serverless releases and modern JavaScript/TypeScript project setups. There is no active release cadence, and users should be aware of potential security vulnerabilities or runtime issues due to its age. Its key differentiator was offering a simple, declarative way to embed shell commands into the Serverless deployment and development workflow, mitigating the need for external build scripts for simple operations. However, for robust CI/CD or complex build processes, more modern and maintained alternatives are recommended.","status":"abandoned","version":"1.0.2","language":"javascript","source_language":"en","source_url":"git://github.com/mvila/serverless-plugin-scripts","tags":["javascript","serverless","plugin","script","shell","customize","command","hook","CLI"],"install":[{"cmd":"npm install serverless-plugin-scripts","lang":"bash","label":"npm"},{"cmd":"yarn add serverless-plugin-scripts","lang":"bash","label":"yarn"},{"cmd":"pnpm add serverless-plugin-scripts","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Required as a peer dependency for the plugin to function within the Serverless Framework ecosystem. Significant compatibility issues are expected with Serverless Framework versions 3.x and above due to the plugin's abandoned status.","package":"serverless","optional":false}],"imports":[{"note":"This plugin is activated by listing its name under the `plugins` section in `serverless.yml`. It does not expose any direct JavaScript exports for `import` or `require` statements in your application code; its functionality is entirely configuration-driven.","symbol":"Plugin Activation","correct":"plugins:\n  - serverless-plugin-scripts"},{"note":"Custom CLI commands are defined within the `custom.scripts.commands` block in `serverless.yml`. These commands can then be invoked via `serverless myCommand` from the terminal.","symbol":"Custom Commands","correct":"custom:\n  scripts:\n    commands:\n      myCommand: echo 'Running my custom command'"},{"note":"Scripts attached to Serverless lifecycle events are defined under `custom.scripts.hooks` in `serverless.yml`. The event names must exactly match Serverless Framework's internal events (e.g., `deploy:createDeploymentArtifacts`).","symbol":"Lifecycle Hooks","correct":"custom:\n  scripts:\n    hooks:\n      'deploy:createDeploymentArtifacts': npm run build"}],"quickstart":{"code":"# serverless.yml\nservice: my-serverless-app\n\nplugins:\n  - serverless-plugin-scripts\n\ncustom:\n  scripts:\n    commands:\n      hello: echo \"Hello from ${self:service} service at $(date) using Serverless Framework!\"\n      greet:\n        handler: echo \"Greeting from serverless-plugin-scripts. The first argument is $1\"\n        description: \"Greets with an optional argument\"\n    hooks:\n      'deploy:createDeploymentArtifacts': npm run build-frontend # Example build step\n      'package:createPackage': echo \"Packaging started for ${self:service} at $(date)\"\n      'after:deploy:deploy': echo \"Deployment completed for ${self:service}! All resources are up.\"\n\n# Terminal commands to run after setting up serverless.yml\nnpm install --save serverless-plugin-scripts\nserverless hello\nserverless greet --param myName # Note: arguments are passed positionally as $1, $2, etc.\nserverless deploy","lang":"javascript","description":"This quickstart demonstrates how to install `serverless-plugin-scripts`, configure custom CLI commands and lifecycle hooks in `serverless.yml`, and execute them using the Serverless CLI."},"warnings":[{"fix":"Consider migrating to a more actively maintained plugin or implementing custom script execution directly within your CI/CD pipeline or build scripts. Manually executing `npm run build` as part of your deployment process is often a safer alternative.","message":"This plugin is effectively abandoned since its last update in October 2017. It is highly unlikely to be compatible with Serverless Framework versions 3.x and above, which introduced significant breaking changes to the plugin system.","severity":"breaking","affected_versions":">=3.0.0"},{"fix":"Minimize the scope of executed commands, avoid direct user input, and prioritize alternative, more secure methods for complex operations. Regularly review the commands for potential exploits.","message":"Executing shell commands directly via a plugin can pose security risks if the commands are not carefully vetted or if user input is incorporated without proper sanitization. Given the plugin's abandoned status, there will be no security patches for potential vulnerabilities.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Consult the official Serverless Framework documentation for your specific version to verify correct lifecycle event names and plugin API usage. Consider updating to a newer, maintained plugin if available.","message":"The Serverless Framework has evolved significantly since this plugin's last release. Some lifecycle event names or core functionalities might have changed or been deprecated, leading to scripts not being invoked as expected.","severity":"deprecated","affected_versions":">=2.0.0"}],"env_vars":null,"last_verified":"2026-04-21T00:00:00.000Z","next_check":"2026-07-20T00:00:00.000Z","problems":[{"fix":"Downgrade your Serverless Framework CLI version (e.g., `npm install -g serverless@~1`) or remove this plugin and migrate its functionality to external scripts or a newer, compatible plugin.","cause":"The Serverless Framework version being used is too new (e.g., v3+) and has breaking changes that prevent this old plugin from loading correctly.","error":"Plugin \"serverless-plugin-scripts\" isn't a valid plugin"},{"fix":"Ensure that simple commands are defined as a single string, e.g., `myCommand: 'echo Hello'`. For more complex configurations (like adding a description), use the `handler` property: `myCommand: { handler: 'echo Hello', description: '...' }`.","cause":"The command handler for a custom script command in `serverless.yml` was provided as an object instead of a direct string, or an incorrect YAML structure was used.","error":"custom.scripts.commands.myCommand: must be a string"},{"fix":"Ensure all necessary executables are installed and accessible in the system's PATH where the Serverless command is executed. For CI/CD, verify the build environment setup.","cause":"A script defined in `custom.scripts.hooks` or `commands` attempts to execute a command (like `npm`, `yarn`, `aws`, etc.) that is not found in the environment's PATH.","error":"Error: spawn npm ENOENT"},{"fix":"This issue might indicate a deeper incompatibility with the Serverless Framework version. For simpler cases, ensure the `service` property is defined at the top of your `serverless.yml`. For complex scenarios, it may necessitate migrating away from this abandoned plugin.","cause":"Variable interpolation using `${self:service}` or similar might fail if the Serverless context is not fully initialized or accessible at the point the script is invoked, or due to incompatibility with newer Serverless versions.","error":"Cannot read property 'service' of undefined"}],"ecosystem":"npm"}