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

@trafficops/cli

v0.1.0

Published

Generate static pages from TrafficOps templates with an Ink form or JSON data

Readme

TrafficOps CLI

Generate static websites from TrafficOps templates. The CLI uses Commander.js for commands and Ink for a form built from each template's schema. Node.js 22 or newer is required.

npx @trafficops/cli --template ./my-template --output ./generated
npx @trafficops/cli --template ./my-template --data ./values.json --output ./generated

npm install -g @trafficops/cli
tops --template ./my-template/index.tpl --data ./values.json

Without --data, the terminal form walks through text, number/range, boolean, select, image-path, rich-text, nested group and repeater fields. Use arrows for choices, Space to toggle booleans, Enter to advance, Ctrl+U to clear, Ctrl+B to go back, and Esc to cancel. Repeater item counts determine the following item forms. Type \n for multiline content. Required values and constraints are checked before generation.

With --data, generation is fully noninteractive and works in scripts or CI. Omitted fields use defaults. JSON numbers and booleans must have their actual JSON types, and unknown field names are rejected. Example:

{
  "title": "A new campaign",
  "accent": "#7c3aed",
  "showCards": true,
  "cards": [{ "title": "Start here", "body": "Tell your story." }]
}

| Option | Purpose | | --- | --- | | -t, --template <path> | Required .tpl/.tpl.html file or directory. | | -d, --data <json> | JSON setting values; bypass the form. | | -o, --output <directory> | Output directory, default ./generated. | | --context <json> | Optional safe runtime context containing query, locale and actions. | | -f, --force | Replace generated files that already exist. | | --help, --version | Show usage or package version. |

Directory mode generates all entry pages and copies non-template assets unchanged. Keep configuration/secrets outside the project directory. Hidden files/directories, node_modules and vendor are omitted, and symlinks are rejected. File mode reads only that file and its include graph; use directory mode to copy CSS, images and other assets. Relative image paths stay as written, with no upload, download or image processing.

Source suffixes .tpl and .tpl.html become .html; included fragments do not become standalone pages. Shared field definitions are available across pages. The output directory must be outside a source project directory. Existing generated paths require --force, symlink destinations are rejected, and all destinations are checked before any file is written. Force replaces only generated files and preserves unrelated output files.

Runtime context example:

{
  "locale": "en-GB",
  "query": { "campaign": "summer" },
  "actions": { "submit": "/submit" }
}

The runtime compatibility documentation describes supported syntax and intentional limits. In particular, HTML/Markdown formatted values are sanitized; values are never evaluated as code or rescanned for template directives. The PHP engine remains authoritative for host-specific dialects and serialized JSON definitions.

Develop and verify

From the repository root:

npm ci
npm run build:cli
node tops-cli/dist/cli.js --template examples/campaign --data examples/campaign-data.json --output generated
npm test --workspace=@trafficops/cli
npm run test:pack --workspace=@trafficops/cli

test:pack packs the real npm artifact, installs it in an isolated temporary consumer and runs version and page-generation checks. The CLI bundle includes the private runtime source; published packages have no dependency on a workspace path. Commander, Ink, React, Marked and sanitize-html remain ordinary public npm dependencies. tops and trafficops are equivalent executable names.