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

@bunli/plugin-config

v0.4.4

Published

Config merger plugin for Bunli - loads config from multiple sources

Downloads

320

Readme

@bunli/plugin-config

Configuration file merger plugin for Bunli CLI framework. Loads and merges configuration from multiple sources including user home directory and project-specific config files.

Installation

bun add @bunli/plugin-config

Usage

import { createCLI } from '@bunli/core'
import { configMergerPlugin } from '@bunli/plugin-config'

const cli = await createCLI({
  name: 'my-cli',
  version: '1.0.0',
  plugins: [
    configMergerPlugin({
      sources: [
        '~/.config/{{name}}/config.json',
        '.{{name}}rc.json',
        '.{{name}}rc',
        'package.json'
      ]
    })
  ]
})

// Config is automatically merged into your CLI configuration

Options

interface ConfigMergerOptions {
  /**
   * List of config file paths to load
   * Supports {{name}} template which is replaced with CLI name
   * Paths starting with ~ are expanded to home directory
   */
  sources: string[]
  
  /**
   * Merge strategy for combining configs
   * - 'deep': Recursively merge objects (default)
   * - 'shallow': Only merge top-level properties
   */
  mergeStrategy?: 'deep' | 'shallow'
  
  /**
   * Stop after finding the first config file
   * Default: false (loads and merges all found configs)
   */
  stopOnFirst?: boolean
  
  /**
   * Custom config parser (e.g., for YAML, TOML)
   * Default: JSON.parse
   */
  parser?: (content: string) => any
  
  /**
   * Transform config after loading
   */
  transform?: (config: any) => any
}

Config File Formats

By default, the plugin supports JSON files. Common patterns:

RC Files

# These are equivalent for a CLI named "my-cli"
.my-clirc
.my-clirc.json

Home Directory Config

~/.config/my-cli/config.json
~/.my-clirc

Package.json

{
  "name": "my-project",
  "version": "1.0.0",
  "my-cli": {
    "apiKey": "secret",
    "theme": "dark"
  }
}

Template Variables

  • {{name}} - Replaced with your CLI's name

Load Order

Configs are loaded in the order specified and merged together. Later configs override earlier ones.

// Example: User config overrides defaults
configMergerPlugin({
  sources: [
    '/etc/my-cli/defaults.json',    // System defaults
    '~/.config/my-cli/config.json', // User config
    '.my-clirc'                     // Project config
  ]
})

Stop on First

Use stopOnFirst to implement fallback behavior:

configMergerPlugin({
  sources: [
    '.my-clirc',                    // Check project first
    '~/.config/my-cli/config.json', // Then user
    '/etc/my-cli/defaults.json'     // Finally system
  ],
  stopOnFirst: true // Use only the first found
})

Custom Parsers

Support other formats with custom parsers:

import { parse as parseYAML } from 'yaml'

configMergerPlugin({
  sources: ['.my-cli.yml', '.my-cli.yaml'],
  parser: parseYAML
})

Transform Configs

Apply transformations after loading:

configMergerPlugin({
  sources: ['.my-clirc'],
  transform: (config) => {
    // Expand environment variables
    if (config.apiKey === '$API_KEY') {
      config.apiKey = process.env.API_KEY
    }
    return config
  }
})

Error Handling

Missing config files are silently ignored. Parse errors are logged but don't crash the CLI.

License

MIT © Arya Labs, Inc.