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

@sofarocean/loft

v0.3.1

Published

Standard build scripts combining Terraform and custom pre- and post- deploy options

Downloads

19

Readme

loft is a set of command line utilities that provide a standard way of managing and deploying infrastructure and code across multiple environments using git, Github, and Terraform.

Lofting "Lofting is a drafting technique whereby curved lines are generated, to be used in plans for streamlined objects such as aircraft and boats."

Usage

loft is published on npm and can be executed anywhere with npx:

npx @sofarocean/loft

Alias

If you find yourself using loft frequently from the command line, you can create an alias by adding an entry to your ~/.profile, ~/.bashrc, or similar:

alias loft='npx @sofarocean/loft'

And then running commands from any directory such as:

loft deploy

Commands

deploy

npx @sofarocean/loft deploy [--pre-apply <script>] [--post-apply <script>]

Running this command from your local machine or on a CI/CD server (such as with Github Actions) will:

  • Infer the environment (dev, staging, or prod) frome the current git branch
  • Load environment variables from the corresponding .env file for your chosen deploy environment
  • Initialize Terraform and select a workspace corresponding to the chosen deploy environment.
  • Run your pre-apply script if specified
  • Run terraform apply with the .tfvars corresponding to the chosen deploy environment
  • Run your post-apply script if specified

The deployment environment can be overridden with the -d or --deploy-env option.

For a full list of options, run:

npx @sofarocean/loft deploy -h

On a CI/CD server

When running on a CI/CD server, you can set the -a or --auto-approve option to auto-approve the Terraform changes.

promote

Use promote to bring code from one environment up to date with another. This is typically used to promote code on dev->staging or staging->prod.

In most cases, you can just run:

npx @sofarocean/loft promote

This will infer the target branch based on your current branch (e.g. if you are currently on dev, this will attempt to promote dev->staging).

You can also specify a target branch:

npx @sofarocean/loft promote --target master

Preview changelog

Before promoting, loft will show you a log of the commits that differ between your current and target branches. Run these by your team before promoting to make sure everything looks good to go!

Back-merging hotfixes

promote will only attempt a fast-forward merge. This will fail if the target branch contains code that is not on the current branch, as is the case when a hotfix was applied directly on the target branch. In this case, you will need to back-merge the changes onto your current branch and resolve any merge conflicts manually before continuing.

Back merging is as simple as:

git merge <target>

where <target> was your original target branch.

TODO

init

Initialize a project with the standard deployment setup:

  • /terraform directory with [dev,staging,prod].tfvars files
  • [dev,staging,prod].env files for environment variables in each environment
  • Run git init if needed
  • Create a dev and staging git branch and checkout dev
  • Configure git remote repository with default branch dev, branch protection, linear history, etc?

test

  • Like deploy, but set up environment variables before running test command
  • Ability to set up temporary terraform stack?

destroy

  • Wraper for terraform destroy that sets variables based on environment and branch, similar to loft deploy

Other things

  • Slack notifications?