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

aws-multi-env

v2.0.2

Published

Rename and remove files to match deployment environment.

Downloads

3

Readme

🚩 Table of Contents

🚀 Introduction

When deploying to AWS you might want to have different configurations files per environment, and this package does just that.

It finds files that match an environment key and renames to proper naming, remove files from other environments and keep the ones without especific env.

🔧 Installation

There's no need to install aws-multi-env, you can use it with npx.

📖 Usage

To run any command the working tree on the source folders must be clean.

npx aws-multi-env [command] <options>

Preparing files for deployment with an application name app-server-prod:

$ npx aws-multi-env prepare --env app-server-prod
» i  Current environment: prod
» i  Renaming files from "prod" to correct name, and removing other files
» i    Removed: ./.ebextensions/certbot.staging.config
» i    Keep: ./.ebextensions/migration.config
» i    Removed: ./.ebextensions/ssl.staging.config
» i    Removed: ./.platform/nginx/conf.d/https_custom.staging.conf
» √  Environment ready, files were renamed and/or removed

Then, after you build/deploy you can revert the changes to deploy on another environment:

$ npx aws-multi-env revert --env app-server-prod
» i  Current environment: prod
» i  Renaming files back and restoring removed files
» i    Running: git clean ./.ebextensions/** ./.platform/**
» i    Running: git checkout ./.ebextensions/** ./.platform/**
» √  Environment restored, files renamed back and/or restored

Use on CI:

- name: Prepare deploy staging
  run: |
    npx aws-multi-env prepare --env "${{ secrets.AWS_ENVIRONMENT_NAME_STAGING }}"
    yarn build && zip -r "$RUNNER_TEMP/deploy-staging.zip" .
    npx aws-multi-env revert --env "${{ secrets.AWS_ENVIRONMENT_NAME_STAGING }}"

- name: Prepare deploy prod
  run: |
    npx aws-multi-env prepare --env "${{ secrets.AWS_ENVIRONMENT_NAME_PROD }}"
    yarn build && zip -r "$RUNNER_TEMP/deploy-prod.zip" .
    npx aws-multi-env revert --env "${{ secrets.AWS_ENVIRONMENT_NAME_PROD }}"

Commands

| Command | Description | |---------|----------------------------------------------------------------| | config | Output loaded configuration | | prepare | Rename and remove files on source folders to match environment | | revert | Undo changes on source folders |

Options

| Argument | Description | Type | |-----------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|----------------------------------------------------------------| | --env | Environment name to deploy and match files to, it will match the last portion of the name: app-server-prod will match prod. If no environment was matched, will match from branches. | [string] | | --envs | Acceptable environments, optionally mapped to branches. Example: --envs.prod --envs.staging=beta | [string] [required] | | --source | Array of glob folders to find files. | [array] [default: ["./.ebextensions/**","./.platform/**"]] | | --envMatcher | Regex to match if file is environment specific. | [string] [default: ".+[.][a-z]+..+$"] | | --envMatcherSeparator | The environment separator on file names | [string] [default: "."] | | --dryRun | Run without making any actual changes | [boolean] [default: false] |

Using config file

We use cosmiconfig to load the config file, checkout some examples:

.aws-multi-envrc.json

{
  "envs": {
    "prod": ["main"],
    "staging": ["beta"]
  },
  "source": ["./.ebextensions/**"]
}

.aws-multi-envrc.yml

envs:
  prod:
    - main
  staging:
    - beta
source:
  - ./.ebextensions/**
  - ./.platform/**

💬 Contributing

Would like to help make this package better? Please take a look at the contributing guidelines for a detailed explanation on how you can contribute.

❤️ Acknowledgments

I'd like thank my daily coffee!