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 🙏

© 2026 – Pkg Stats / Ryan Hefner

dotenv-gcloud-secrets-resolver

v0.1.0

Published

Resolve .env files whose values are literals or ${secret:NAME} references to Google Cloud Secret Manager. Two modes: resolve (local) and translate (CI).

Readme

dotenv-gcloud-secrets-resolver

One parser for .env files whose values are either literals or ${secret:NAME} references to Google Cloud Secret Manager — two modes. Declare each environment variable once, in a committed file, and consume it identically for a local run and a Cloud Run deploy.

  • resolve — for local use. Literals pass through; every ${secret:NAME} is fetched from gcloud Secret Manager. Output: a flat env object for the process.
  • translate — for CI, via the bundled GitHub Action. Literals become gcloud run deploy --set-env-vars entries; ${secret:NAME} references become --set-secrets entries. The secret value is never fetched or inlined — the reference becomes Cloud Run's native Secret Manager mount.

The gcloud project and the secret names are inputs, never baked in — the package is parsing logic only.

The .env file format

# literals — committed in clear, non-sensitive config only
SERVER_PORT=8080
LOG_LEVEL=info
CORS_ALLOWED_ORIGINS=https://app.example.com,https://example.com

# secret references — resolved from gcloud Secret Manager
DB_PASSWORD=${secret:DATABASE_PASSWORD}
JWT_SECRET_KEY=${secret:JWT_SIGNING_KEY:7}   # pinned to version 7
  • A value is a literal or a single secret reference. A value that mixes literal text with ${secret:…} is rejected — a secret must map cleanly onto one --set-secrets entry.
  • ${secret:NAME} uses version latest; ${secret:NAME:VERSION} pins it.
  • # lines are comments; an optional export prefix is tolerated; surrounding quotes are stripped.

See examples/service.env.example.

Library API

const { resolve, translate, toGcloudFlags } = require('dotenv-gcloud-secrets-resolver');

// resolve mode — secrets fetched from gcloud
const env = resolve('envs/local.env', { project: 'my-gcp-project' });

// translate mode — no secret value ever touched
const flags = toGcloudFlags(translate('envs/staging.env'));
// → ['--set-env-vars=^@^SERVER_PORT=8080@…', '--set-secrets=DB_PASSWORD=…:latest']

resolve(file, opts) accepts opts.fetchSecret(secret, version, project) for testing without gcloud.

Secret bytes are used verbatim. resolve returns exactly what gcloud returns, with no trimming — the same bytes Cloud Run mounts via --set-secrets. Never store a secret value with a stray trailing newline; it would break a local run and a deploy identically.

CLI

env-resolver resolve   envs/local.env --project my-gcp-project
env-resolver translate envs/staging.env
env-resolver translate envs/staging.env --json

GitHub Action

- id: env
  uses: super-cache-money/dotenv-gcloud-secrets-resolver@v1
  with:
    file: envs/staging.env

- run: |
    gcloud run deploy my-service \
      --set-env-vars='${{ steps.env.outputs.set-env-vars }}' \
      --set-secrets='${{ steps.env.outputs.set-secrets }}'

Tests

npm test     # node --test

License

MIT