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

@slsplus/template

v1.1.7

Published

This component is used behind the scenes to deploy your YAML templates. It is loaded by the serverless CLI and executed just as any other component. However, there's a lot you can do with this component programmatically. See the sections below for some ex

Downloads

2

Readme

Template

This component is used behind the scenes to deploy your YAML templates. It is loaded by the serverless CLI and executed just as any other component. However, there's a lot you can do with this component programmatically. See the sections below for some examples.

Programmatic usage and custom environments

To deploy to multiple environments you must utilize the programmatic API, via serverless.js file.

serverless.js

const { Component } = require('@slsplus/core')

class Deploy extends Component {
  async default(inputs = {}) {
    const { env } = inputs

    const template = await this.load('@serverless/template', env)
    return await template({ template: __dirname + '/serverless.yml' })
  }

  async remove(inputs = {}) {
    const { env } = inputs

    const template = await this.load('@serverless/template', env)
    await template.remove(inputs)
  }
}

module.exports = Deploy

serverless.yml

name: test

lambda:
  component: '@serverless/function'
  inputs:
    name: my-function
    description: My Serverless Function
    memory: 128
    timeout: 20
    code: './code'
    hanlder": 'handler.handler'
    region: us-east-1
    runtime: nodejs10.x

Invoking sls --env=dev will result in state files in .serverless/ being prefixed with the value of your env: Deploy.dev.json, etc. That way you can deploy unlimited environments, add pre/post processing, load whatever .env you need, etc.

Running custom methods on a template

A template itself does not contain any methods so custom methods are executed on the specific template aliases.

sls install --component lambda will load the lambda alias from your template, instantiate the corresponding component, and execute the install method passing in the inputs you specify via CLI parameters. Inputs from the template itself are not passed as they can not be interpreted/resolved without running the entire template.

You can pass as many --component parameters as you need.

Running custom methods programmatically

serverless.js

const { Component } = require('@slsplus/core')

class Deploy extends Component {
  /* ...skipped default method for brevity ... */

  async install(inputs = {}) {
    const template = await this.load('@serverless/template')
    await template.install({ template: __dirname + '/serverless.yml', ...inputs })
  }
}

module.exports = Deploy

When invoking methods on a template instance, you always need to pass in a path to the template file or a template object.

Running sls install --component lambda --debug - this will load the template, find the lambda alias, and invoke the install method on the instance of the component.

Couldn't find what you were looking for?

Visit our github and file an issue with as much info as possible about your problem. If you think you've found a bug - please do post a complete reproduction repo. It will help us and our contributors to help you much faster.