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

netlify-plugin-encrypted-files

v0.0.5

Published

this plugin is an unusual one. it has a CLI that works outside of the build bot.

Downloads

15

Readme

Netlify Plugin Encrypted Files

Netlify Build Plugin to partially obscure files (names and contents) in git repos!

This enables you to partially open source your site, while still being able to work as normal on your local machine and in your Netlify builds.

External viewers of your Git repo will just see hashes for your secret content while it is encrypted - and as long as it still builds without these files, they can still contribute to the rest of your site.

Demo

https://netlify-plugin-encrypted-files.netlify.com

Usage

To install, add the following lines to your netlify.toml file:

[[plugins]]
package = "netlify-plugin-encrypted-files"
  # all inputs are optional. uncomment to apply
  # [plugins.inputs]
  # branches = [ # if specified, allow a small set of branches for which the decrypt is applied
    # "master",
    # "swyx/myNewBranch"
  # ] # dont forget to specify a NETLIFY_ENCRYPT_KEY env variable in Netlify's UI

In your local environment, install the plugin and run the encrypt CLI on your project specifying a glob filepath for what should be encrypted and what NETLIFY_ENCRYPT_KEY you intend to use, e.g.

npm i netlify-plugin-encrypted-files
NETLIFY_ENCRYPT_KEY='test' node encrypt.js content/secretstuff/**/*.*

This generates a .encrypted folder which you should check into git. (Here's how it looks - even filenames are obscured!)

Also dont forget to .gitignore your secret content!

On Netlify's side, all it does is it runs decrypt for you, using the same NETLIFY_ENCRYPT_KEY you used to encrypt it. To set the environment variable without it being visible in git, you should use the Netlify UI.

image

How It Works

This plugin is an unusual one: it has a CLI that works outside of the build bot, that you use to encrypt stuff. Then, inside the plugin, it runs the decrypt command for you before proceeding with the build.

The idea is:

  1. while developing, work with your files as normal
  • before committing, run encrypt secretcontent/**/*.md (any file matching logic here will do)
  • make sure files-to-be-encrypted are gitignored
  • encrypt will encrypt your files to the .encrypt folder with the NETLIFY_ENCRYPT_KEY environment variable
  • so you run something like:
    • NETLIFY_ENCRYPT_KEY='test' yarn encrypt demo/files/secretstuff/**/*.*
    • or NETLIFY_ENCRYPT_KEY='test' /node_modules/.bin/encrypt demo/files/secretstuff/**/*.*
  • check the new .encrypt folder into git
  1. while deploying, this plugin runs a decrypt before any build and decrypts it with the same env variable
  2. for collaborators, they should run decrypt on git pull.
  • so you run something like:
    • NETLIFY_ENCRYPT_KEY='test' yarn decrypt demo/files/secretstuff/**/*.*
    • or NETLIFY_ENCRYPT_KEY='test' /node_modules/.bin/decrypt demo/files/secretstuff/**/*.*
  • NOTE: By default this overwrites files since that is usually the desired behavior, but if you want to be extra sure, you can add a --testdecrypt flag:
    • NETLIFY_ENCRYPT_KEY='test' yarn decrypt --testdecrypt demo/files/secretstuff/**/*.*
    • or NETLIFY_ENCRYPT_KEY='test' /node_modules/.bin/decrypt --testdecrypt demo/files/secretstuff/**/*.*
    • this will decrypt to a testdecrypt folder instead of the real destination, so you can preview what the effect of decrypting will be.

Configuration

No configuration is required - by default the decrypting works on all Netlify Builds, but you can restrict it to a small set of branches you specify:

# netlify.toml
[[plugins]]
package = "netlify-plugin-encrypted-files"

  [plugins.inputs]
  
  # if specified, allow a small set of branches for which the decrypt is applied
  branches = [
    "master",
    "swyx/myNewBranch"
  ] 
  
  # dont forget to specify a NETLIFY_ENCRYPT_KEY env variable in Netlify's UI

For Collaborators

To test this repo locally you can run:

  • NETLIFY_ENCRYPT_KEY='test' node encrypt demo/files/secretstuff/**/*.*
  • NETLIFY_ENCRYPT_KEY='test' node decrypt --testdecrypt by default decrypt