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

gunshi-c12

v1.0.0

Published

Gunshi plugin that provides c12 configuration loading capabilities

Readme

gunshi-c12

Thin Gunshi plugin over c12.

gunshi-c12 does not re-implement config loading. It wires Gunshi global options into direct c12 calls (loadConfig/watchConfig) and exposes them on ctx.extensions.c12.

Install

pnpm add gunshi-c12

Quick Start

import { cli, define } from "gunshi";
import { c12 } from "gunshi-c12";

const command = define({
  name: "build",
  run: async (ctx) => {
    const configApi = ctx.extensions.c12;
    const { config } = await configApi.loadConfig();
    console.log(config);
  },
});

await cli(process.argv.slice(2), command, {
  name: "my-cli",
  version: "1.0.0",
  plugins: [c12({ name: "myapp" })],
});

What This Plugin Adds

  • Registers Gunshi global options:
    • default mode: --config, --env
    • scoped mode (configName): --config-<name>, --env-<name>
  • Resolves APPNAME overrides in scoped mode:
    • configName: "app" reads APP_APPNAME
  • Merges options and calls c12 directly.

Everything else (file formats, layering, extends, dotenv, watch behavior, etc.) is c12 behavior.

Option Merge Rules

The extension merges options in this order:

  1. Plugin options passed to c12(...)
  2. CLI-derived overrides from global flags (config*/env*)
  3. Runtime options passed to loadConfig(...) or watchConfig(...)

For nested overrides, merge is shallow by key (last write wins per key).

Resolved c12 name priority:

  1. options.name passed to c12(...)
  2. In scoped mode, APP_APPNAME-style override (<CONFIGNAME>_APPNAME) then configName
  3. Gunshi program name (ctx.env.name, usually CLI name)
  4. Fallback: "config"

Scoped Configuration (configName)

Use configName when you want config flags scoped to a domain.

import { c12 } from "gunshi-c12";

// Adds --config-app and --env-app
const plugin = c12({ configName: "app", name: "myapp" });

configName also enables APPNAME override lookup:

# Uses APP_APPNAME to override resolved c12 name
APP_APPNAME=project-a my-cli build --config-app ./app.config.ts

API

c12(options?)

Creates the Gunshi plugin.

  • options is c12 LoadConfigOptions plus:
    • configName?: string

Extension Methods

From ctx.extensions.c12:

  • loadConfig(options?) -> forwards to c12.loadConfig
  • watchConfig(options?) -> forwards to c12.watchConfig
  • load(options?) -> alias of loadConfig

Types

This package re-exports core c12 types (for example LoadConfigOptions, WatchConfigOptions, ResolvedConfig, ConfigWatcher) and plugin types (C12Extension, ConfigLoader).

License

MIT