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

thunder-client-env-templater

v2.1.0

Published

Creates a thunder client environment file from env template files

Downloads

34

Readme

thunder-client-env-templater

Creating thunder client collections using environments so you can easily switch between dev, test, beta, prod, etc is a great thing. Makes it easy to to test and work with your code across all the environments you support. However, most api calls require some sort of secret information like an api key or auth credentials. And you should not check that information into the repo. And maybe Postman Cloud is not a solution that you can use. Now when you use the environment for the first time or you want to pull in any updates to it, you will need to look up that secret information and update your local environments, but also, ensure your local copies with the secrets do not accidentally get check back into the repo.

This is where thunder-client-env-templates helps. You save your secrets to SSM and update your env templates to have the ssm path. You can save your templates to the repo. The logic takes the template, looks up any SSM params needed, and then creates the real thunder client environment file with the secret values. Lastly, you use gitignore to ensure that real environment file do not get checked into the repo.

Version

Thunder client updated how the environment configuration is saved. Not sure which TC version made the change assuming it was 2.7 or 2.8, but the environment files are saved as separate files in the environments folder. Previously, there was one thunderEnvironments.json file which had all environments.

  • Version 2.0.0+ outputs in the new environments folder format (assuming TC version post 2.7)
  • Version 1.0.0 outputs in the old single environment file format (assuming TC version pre 2.7)

Publishing

When new changes are complete and pass build and test.

  • run yarn version
  • enter new version number
  • this will build, test, lint, create change log, bump version, create tag, push changes and tag, and finally npm publish

Install

  • If using yarn, run yarn add thunder-client-env-templater
  • If using npm, run npm install thunder-client-env-templater

Run/Test locally

  • run npx ts-node src/runner.ts like npx ts-node src/runner.ts --config=./.thunder-client/config.json

Usage

  • Create a thunder client folder (TCF) for you thunder client files (.thunder-client)
  • Create a folder in your TCF for your env templates (.thunder-client/env-templates)
  • Create a json file for each environment that will be templated (.thunder-client/env-templates/env-abc.json)
  • Update the environment file with all the environment variables required. If the variable is not a secret, just add the name/value in plain text (knowing this will be saved to your repo in plain text). If the variable is a secret, save the secret value to SSM and then add the name and ssm path as the value in the environment template file.
# env template
{
  "name": "[dev or test or prod etc]",
  "data": [
    {
      "name": "baseUrl",
      "value": "https://dev-api.projecta.com/api"
    },
    {
      "name": "4TEMPLATER:username", # use 4TEMPLATER: to identify this is one for the templates to process
      "value": "ssm:/projectA/dev/username:false",  #:true means it is encrypted ssm value; :false means it is not encrypted
    },
    {
      "key": "4TEMPLATER:password",
      "value": "ssm:/projectA/dev/password:true"
    }
  ]
}


# outputted to environment file or folder
{
  "name": "[dev or test or prod etc]",
  "data": [
    {
      "name": "baseUrl",
      "value": "https://dev-api.projecta.com/api"
    },
    {
      "name": "username",
      "value": "[the value in ssm at path /projectA/dev/username]",
    },
    {
      "key": "password",
      "value": "[the value in ssm at path /projectA/dev/password decrypted]"
    }
  ]
}
  • Update .gitignore and add the outputted thunder-client environment file/folder so it doesn't get checked into your repo.
# .thunder-client/.gitignore
thunderEnvironment*.json
environments-backup*/
tc_env_*.json
thunderActivity.json
  • Create thunder-client config to ease the templater execution
# .thunder-client/config.json
# project setup to put all thunder client files in .thunder-client folder
{
  "awsRegion": "us-east-2",
  "thunderClientEnvironmentFileDir": "./.thunder-client/thunder-tests",
  "templateFiles": ["./.thunder-client/env-templates/*.json"]
}
  • Add script to your package.json
{
  ...
  "scripts": {
    ...
      "tc:template": "yarn thunder-client-env-templater --config ./.thunder-client/config.json",
    ...
  }
  ...
}
  • Run yarn tc:template when needed to create/update thunder client environment file/folder. If using ssm, make sure to update ~/.aws/credentials before