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

cdkoutputs2sh

v0.0.2

Published

CLI tool and library that converts AWS CDK stack output JSON files into sourceable shell environment variable export scripts

Readme

cdkoutputs2sh

npm version License: MIT TypeScript Node.js

English | 日本語

cdkoutputs2sh is a CLI tool and library that converts AWS CDK stack output JSON files (generated by cdk deploy --outputs-file var/outputs.json) into sourceable shell environment variable export scripts (var/outputs.sh).

Features

  • Automatic conversion from CDK output (JSON) to export VAR=... format
  • Preserves mapping between variable names and original StackName.OutputKey in comments
  • Safe shell quoting with single quotes
  • Warns and skips non-scalar values (arrays/objects)
  • Detects variable name collisions and exits with error

Installation

npm install -D cdkoutputs2sh

Usage

  1. Deploy with CDK and generate JSON output
    cdk deploy --outputs-file var/outputs.json
  2. Convert to shell script
    cdkoutputs2sh --input var/outputs.json --output var/outputs.sh
  3. Source the generated script
    source var/outputs.sh
    echo "$AWSCDKP0STACK_INSTANCEID"

Options

| Option | Alias | Description | Default | | ----------------- | -------- | -------------------------------- | ---------------- | | --input | -i | Input JSON file | var/outputs.json | | --output | -o | Output shell script | var/outputs.sh | | --fail-on-missing | none | Fail if input file doesn't exist | false | | --verbose | -v / -vv | Log level (INFO / DEBUG) | none | | --help | -h | Show help | - |

Variable Name Generation Rules

  1. Combine StackName_OutputKey and convert to uppercase
  2. Replace non-alphanumeric characters with _ and merge consecutive _ into one
  3. Remove leading/trailing _
  4. Add V_ prefix if starts with a number
  5. Add CDK_ prefix if stack name starts with Cdk (for sample compatibility)
  6. Error on collision

Examples:

  • AwsCdkP0Stack.InstanceId → AWSCDKP0STACK_INSTANCEID
  • CdkLambdaUrls1Stack.Lambda1FunctionUrl → CDK_CDKLAMBDAURLS1STACK_LAMBDA1FUNCTIONURL

Limitations and Notes

  • Array/object values are skipped
  • Change CDK Output names if collision occurs
  • Output file permissions are set to 0644

Node.js API

import { convertCdkOutputs } from "cdkoutputs2sh";

const { exportBlock, mapping } = convertCdkOutputs({
  input: "var/outputs.json",
  output: "var/outputs.sh",
  verbose: 1,
});

console.log(exportBlock);
console.log(mapping["AWSCDKP0STACK_INSTANCEID"]);

Development

After cloning the repository:

npm run init  # Not `npm init`. See run-scripts
npm run smoketest # Shows help message
npm test # Vitest test cases

License

MIT License