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 🙏

© 2025 – Pkg Stats / Ryan Hefner

@heiwa4126/cdk2env

v0.0.3

Published

Convert AWS CDK outputs.json to shell-sourceable export file. CLI tool and library with dual ESM/CJS support.

Readme

cdk2env (@heiwa4126/cdk2env)

npm version License: MIT TypeScript Node.js

Convert AWS CDK outputs.json to shell-sourceable export file. Provides both CLI tool and programmatic API with dual ESM/CJS support.

Features

  • 🚀 CLI & Library: Use as a command-line tool or programmatic API
  • 📦 Dual Module Support: Works with both ES Modules and CommonJS
  • 🔒 Shell-Safe: Automatic escaping prevents shell injection attacks
  • Zero Dependencies: Built with Node.js standard library only
  • 📝 TypeScript: Full type definitions included
  • Well Tested: Comprehensive test coverage

Installation

Global (CLI)

npm install -g @heiwa4126/cdk2env
# or
pnpm add -g @heiwa4126/cdk2env

Local (Library)

npm install --save-dev @heiwa4126/cdk2env
# or
pnpm add -D @heiwa4126/cdk2env

Usage

CLI

# Default: var/outputs.json → var/outputs.sh
cdk2env

# Custom input file
cdk2env path/to/outputs.json

# Custom input and output
cdk2env path/to/outputs.json path/to/exports.sh

# Show help
cdk2env --help

# Show version
cdk2env --version

Library API

ES Modules

import { convertOutputsToShell } from "@heiwa4126/cdk2env";

await convertOutputsToShell({
  inputPath: "var/outputs.json",
  outputPath: "var/outputs.sh",
});

CommonJS

const { convertOutputsToShell } = require("@heiwa4126/cdk2env");

await convertOutputsToShell({
  inputPath: "var/outputs.json",
  outputPath: "var/outputs.sh",
});

TypeScript

import { convertOutputsToShell, type ConvertOptions } from "@heiwa4126/cdk2env";

const options: ConvertOptions = {
  inputPath: "var/outputs.json",
  outputPath: "var/outputs.sh",
  prefix: "APP_", // Custom prefix (default: 'CDK_')
};

await convertOutputsToShell(options);

Example Workflow

# 1. Deploy CDK and generate outputs
cdk deploy --outputs-file var/outputs.json

# 2. Convert to shell format
cdk2env

# 3. Source the generated file
source var/outputs.sh

# 4. Use environment variables
echo $CDK_MYSTACK_APIENDPOINT
curl $CDK_MYSTACK_APIENDPOINT/health

Input/Output Format

Input: CDK outputs.json

{
  "MyStack": {
    "ApiEndpoint": "https://abc123.execute-api.us-east-1.amazonaws.com",
    "BucketName": "my-bucket-abc123"
  }
}

Output: Shell export file

#!/usr/bin/env bash
# Auto-generated from CDK outputs.json. Do not edit manually.

export CDK_MYSTACK_APIENDPOINT='https://abc123.execute-api.us-east-1.amazonaws.com'
export CDK_MYSTACK_BUCKETNAME='my-bucket-abc123'

Variable Naming Convention

  • Prefix: CDK_ (customizable via API)
  • Format: CDK_STACKNAME_OUTPUTKEY (uppercase)
  • Special characters → _
  • Example: MyStack.ApiEndpointCDK_MYSTACK_APIENDPOINT

Security

All values are wrapped in single quotes with proper escaping:

// Input
{
  "Stack": {
    "Message": "It's a test! $(whoami)"
  }
}

// Output (safe)
export CDK_STACK_MESSAGE='It'\''s a test! $(whoami)'

Development

# Install dependencies
pnpm install

# Build
pnpm run build

# Test
pnpm test

# Lint
pnpm run lint

# Format
pnpm run format

# All checks (lint + test + build + smoke-test)
pnpm run prepublishOnly

Documentation

See docs/SPEC.md for complete specification.

License

MIT