npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

serverless-introspect

v1.0.0

Published

Introspect serverless internals to aid plugin development

Downloads

430

Readme

Serverless Introspect

This diagnostic Serverless plugin allows dumping all available serverless commands as well as all the event hooks triggered by each command. This is extremely useful when developing new serverless plugins that rely on properly integrating with existing serverless commands and which need to run at a moment during the execution of such commands.

Installation

First, add the plugin to your project:

npm install --save-dev serverless-introspect

Then, inside your project's serverless.yml file add serverless-introspect to the top-level plugins section. If there is no plugin section you will need to add it to the file.

plugins:
  - serverless-introspect

Usage

The plugin adds two commands:

serverless introspect events

This command dumps all available lifecycle events next to a hierarchical tree of the available serverless commands:

$ serverless introspect events
introspect: interactiveCli                   initializeService, setupAws, tabCompletion, end
introspect: config
introspect:   credentials                    config
introspect:   tabcompletion
introspect:     install                      install
introspect:     uninstall                    uninstall
introspect: create                           create
introspect: install                          install
introspect: package                          cleanup, initialize, setupProviderConfiguration, createDeploymentArtifacts, compileLayers, compileFunctions, compileEvents, finalize
introspect:   function*                      package

...

introspect: introspect!
introspect:   events                         run
introspect:   hooks                          run
introspect: offline                          start
introspect:   start                          init, end
introspect: login                            login
introspect: logout                           logout
introspect: generate-event                   generate-event
introspect: test                             test
introspect: dashboard                        dashboard

In this example, we can see that the offline command has the lifecycle event start. This means that when serverless offline is run, the following events will be fired:

  • before:offline:start
  • offline:start
  • after:offline:start

Similarly, the package command has several lifecycle events, which will cause the following events to fire:

  • before:package:cleanup
  • package:cleanup
  • after:package:cleanup
  • before:package:initialize
  • package:initialize
  • after:package:initialize
  • before:package:setupProviderConfiguration
  • etc...

Commands annotated with * are internal commands that can only be invoked internally by serverless. Commands annotated with ! are container commands that cannot be invoked by themselves.

serverless introspect hooks

This command displays all the plugins hooked up to the available fully qualified events. You may filter the events by providing the command whose lifecycle events should be displayed:

$ sls introspect hooks -c offline
introspect: before:offline:start                                             ServerlessHooks, ServerlessOfflineKinesis
introspect:        offline:start                                             ServerlessOffline
introspect:  after:offline:start                                             ServerlessHooks

This example shows that the ServerlessHooks, ServerlessOfflineKinesis and ServerlessOffline are connected to the various offline command lifecycle events.