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-glob-merge-yaml

v0.5.5

Published

A Serverless Framework plugin that lets you merge serverless.yml files using variables.

Downloads

448

Readme

Serverless Build Status End-to-end Test Status Coverage Status

Serverless Framework Glob-Merge for YAML

This is a Serverless Framework plugin that lets you merge serverless.yml files using Serverless Framework variables from YAML. You write a variable that contains a path glob (i.e., **/serverless.yml) to merge YAML files and an optional subpath to select only the data you want from the merged YAML.

This plugin is primarily intended for splitting serverless.yml into smaller chunks without needing to create separate Serverless Framework projects or custom ${file(./script.js)} scripts.

Requirements

  • Serverless Framework >= 1.52

Installation

  • Install the package by typing npm i --save-dev serverless-glob-merge-yaml.
  • Add serverless-glob-merge-yaml to your serverless.yml plugins section.
  • Change your variable syntax to allow globs in variable references. (See the example below.)

Example serverless.yml

serverless.yml

service:
  name: test

plugins:
  - serverless-glob-merge-yaml

provider:
  name: aws
  runtime: nodejs12.x
  
  # Change the variable syntax to allow *, +, and | in the variables.
  variableSyntax: "\\${([ *+|~:a-zA-Z0-9._@\\'\",\\-\\/\\(\\)]+?)}"

  iamRoleStatements:
    # Look for serverless.yml in src/ and subdirectories and get the
    # iamRoleStatements from the merged YAML.
    ${glob-merge-yaml:src/**/serverless.yml:provider.iamRoleStatements}

  environment:
    # Provide defaults use stage overrides. The YAML is merged in
    # lexicographical order from env/
    ${glob-merge-yaml:env/*+(default|${opt:stage,'dev'}).yml}

    # The above works like this: Assume you have a files named
    #  env/0default.yml
    #  env/1dev.yml
    #  env/1prod.yml
    #
    # In the dev stage, YAML will merge in this order:
    #  1) env/0default.yml
    #  2) env/1dev.yml
    #
    # In the prod stage, YAML will merge in this order:
    #  1) env/0default.yml
    #  2) env/1prod.yml
    #
    # See: https://github.com/isaacs/node-glob#glob-primer

functions:
  # Merge all functions.yml in src/
  ${glob-merge-yaml:src/**/functions.yml}

resources:
  # Merge all resources.yml in src/
  ${glob-merge-yaml:src/**/resources.yml}

Variable Syntax

The syntax of the variable expression is broken down like this: ${glob-merge-yaml:PATH_GLOB:SUB_PATH}

  • glob-merge-yaml - This is the plugin's variable prefix.
  • PATH_GLOB - Replace this with a path glob. The glob syntax is based on the glob package
  • SUB_PATH - This is an object path that can be used to traverse the merged data structure. You can omit the subpath to return the merged data structure.

Recursion

The YAML files merged with glob-merge-yaml can contain additional glob-merge-yaml statements, so be careful not to create circular references. :)

Contributing

Pull requests are welcome! Especially test scenarios for different situations and configurations.