{"_id":"confstash","_rev":"4-bffc7ef59b8df38f2ee70402bf25fed8","name":"confstash","dist-tags":{"latest":"0.1.3"},"versions":{"0.1.0":{"name":"confstash","version":"0.1.0","keywords":["config","configuration","rc","cosmiconfig","presets","extends","loader","cli"],"author":"Constructive <developers@constructive.io>","license":"MIT","_id":"confstash@0.1.0","maintainers":[{"name":"pyramation","email":"pyramation@gmail.com"}],"homepage":"https://github.com/constructive-io/dev-utils","bugs":{"url":"https://github.com/constructive-io/dev-utils/issues"},"dist":{"shasum":"5fa288618bcc33d303468655243e436cd899b6f1","tarball":"https://registry.npmjs.org/confstash/-/confstash-0.1.0.tgz","fileCount":31,"integrity":"sha512-Xn5cqxQ8PR/miWONro1fRmOm98KmShmIGiOECsCIli9e7PUgY+36cWAvdVQESBL1VdC9eKNsIUFlA7+4zUqIlw==","signatures":[{"sig":"MEUCIAOHfaVBnxBcSwEiBIvBIkS9JJ4EwY1VmvWCZdhxQzk+AiEA7GgCLfiKGmHvISyLLBfA5zVtMZlX4i+gASk+QaJG6MI=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":70430},"main":"index.js","types":"index.d.ts","module":"esm/index.js","gitHead":"8a788f355703ecb6abe9d5926940f7682502ee34","scripts":{"copy":"makage assets","lint":"eslint . --fix","test":"cross-env NODE_OPTIONS=--experimental-vm-modules jest","build":"makage build","clean":"makage clean","test:watch":"cross-env NODE_OPTIONS=--experimental-vm-modules jest --watch","prepublishOnly":"npm run build"},"_npmUser":{"name":"pyramation","email":"pyramation@gmail.com"},"repository":{"url":"https://github.com/constructive-io/dev-utils","type":"git"},"_npmVersion":"lerna/8.2.4/node@v22.13.1+arm64 (darwin)","description":"Standardized project configuration loading — config files, rc files, presets, and layered merge with provenance","directories":{},"_nodeVersion":"22.13.1","dependencies":{"js-yaml":"^4.1.0","appstash":"0.7.0"},"publishConfig":{"access":"public","directory":"dist"},"_hasShrinkwrap":false,"devDependencies":{"makage":"0.1.10","cross-env":"^10.1.0","@types/js-yaml":"^4.0.9"},"_npmOperationalInternal":{"tmp":"tmp/confstash_0.1.0_1785274153985_0.04023513716970761","host":"s3://npm-registry-packages-npm-production"}},"0.1.1":{"name":"confstash","version":"0.1.1","keywords":["config","configuration","rc","cosmiconfig","presets","extends","loader","cli"],"author":"Constructive <developers@constructive.io>","license":"MIT","_id":"confstash@0.1.1","maintainers":[{"name":"pyramation","email":"pyramation@gmail.com"}],"homepage":"https://github.com/constructive-io/dev-utils","bugs":{"url":"https://github.com/constructive-io/dev-utils/issues"},"dist":{"shasum":"ed3f734f39eac0237c0b917715dbfcc735c341d2","tarball":"https://registry.npmjs.org/confstash/-/confstash-0.1.1.tgz","fileCount":31,"integrity":"sha512-p147LZjZ2pQhbnfDGlF3teuGpHpo98xqmPZfUcIkdlEewDq0Es9YQe45skzklZJErr3UmFZUwXDyOpcsHiWs0A==","signatures":[{"sig":"MEYCIQDSSGSn7wHad5fj7nEyr5cVI+2zIdlyjqUWnSZ8kz6f1wIhAJ2PN/dtuREUhvbsv91fg7QJjlgUE74gEi2k0YCf2ZoL","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":70288},"main":"index.js","types":"index.d.ts","module":"esm/index.js","gitHead":"2985d68020ec7d1eeae9a839bdb7ebb68727dd55","scripts":{"copy":"makage assets","lint":"eslint . --fix","test":"cross-env NODE_OPTIONS=--experimental-vm-modules jest","build":"makage build","clean":"makage clean","test:watch":"cross-env NODE_OPTIONS=--experimental-vm-modules jest --watch","prepublishOnly":"npm run build"},"_npmUser":{"name":"pyramation","email":"pyramation@gmail.com"},"repository":{"url":"https://github.com/constructive-io/dev-utils","type":"git"},"_npmVersion":"lerna/8.2.4/node@v22.13.1+arm64 (darwin)","description":"Standardized project configuration loading — config files, rc files, presets, and layered merge with provenance","directories":{},"_nodeVersion":"22.13.1","dependencies":{"js-yaml":"^4.1.0","appstash":"0.7.1"},"publishConfig":{"access":"public","directory":"dist"},"_hasShrinkwrap":false,"devDependencies":{"makage":"0.1.10","cross-env":"^10.1.0","@types/js-yaml":"^4.0.9"},"_npmOperationalInternal":{"tmp":"tmp/confstash_0.1.1_1785533377872_0.9351041198803187","host":"s3://npm-registry-packages-npm-production"}},"0.1.2":{"name":"confstash","version":"0.1.2","keywords":["config","configuration","rc","cosmiconfig","presets","extends","loader","cli"],"author":"Constructive <developers@constructive.io>","license":"MIT","_id":"confstash@0.1.2","maintainers":[{"name":"pyramation","email":"pyramation@gmail.com"}],"homepage":"https://github.com/constructive-io/dev-utils","bugs":{"url":"https://github.com/constructive-io/dev-utils/issues"},"dist":{"shasum":"20554d42553354b6a067647785ea2a0b4e28e1a4","tarball":"https://registry.npmjs.org/confstash/-/confstash-0.1.2.tgz","fileCount":31,"integrity":"sha512-OoEz4asxr7hSoWQFPGu0dP/BtOAS393k64a2eP4B4YFihK/z8BRlxjc3oTjA47Gu1ZlcUfdnlVCovQXR0ZH84A==","signatures":[{"sig":"MEQCIDnhr4oJIlszzkQ/kou37/95aI5019bNPxk21++R/eELAiA8z58QfxU04ejHm4DAlVGDKVopXO0VZNoj4BfNMJf3Qw==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":70288},"main":"index.js","types":"index.d.ts","module":"esm/index.js","gitHead":"9ae46e62fa96a289374cff253e3528108d7f4d61","scripts":{"copy":"makage assets","lint":"eslint . --fix","test":"cross-env NODE_OPTIONS=--experimental-vm-modules jest","build":"makage build","clean":"makage clean","test:watch":"cross-env NODE_OPTIONS=--experimental-vm-modules jest --watch","prepublishOnly":"npm run build"},"_npmUser":{"name":"pyramation","email":"pyramation@gmail.com"},"repository":{"url":"https://github.com/constructive-io/dev-utils","type":"git"},"_npmVersion":"lerna/8.2.4/node@v22.13.1+arm64 (darwin)","description":"Standardized project configuration loading — config files, rc files, presets, and layered merge with provenance","directories":{},"_nodeVersion":"22.13.1","dependencies":{"js-yaml":"^4.1.0","appstash":"0.8.0"},"publishConfig":{"access":"public","directory":"dist"},"_hasShrinkwrap":false,"devDependencies":{"makage":"0.1.10","cross-env":"^10.1.0","@types/js-yaml":"^4.0.9"},"_npmOperationalInternal":{"tmp":"tmp/confstash_0.1.2_1785805837199_0.27764056213777843","host":"s3://npm-registry-packages-npm-production"}},"0.1.3":{"_id":"confstash@0.1.3","bugs":{"url":"https://github.com/constructive-io/dev-utils/issues"},"dist":{"shasum":"16ee1e678d0ebacb0005e596c730c94ee2ab5491","tarball":"https://registry.npmjs.org/confstash/-/confstash-0.1.3.tgz","fileCount":31,"integrity":"sha512-a74y96UzNwVHGBB/XN9itYtjwxLfSYbVwri0Hs7R9ZUsqkUOLcVuGpAEm/a5/f1c+9rjv/XPzipm5aP1umtRDA==","signatures":[{"sig":"MEUCIQClsguzz1obGb7XecqLoivFCR1VRmiwX0etRX1ANTCzeQIgQpd8Zy2+Wv+RF6jIkJTFmk/7pD839KttvZSQT6XxmRI=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"},{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIQCXponNUAlCLYip8UtT2GLr1EXe9PPEsIhoePW+h3jQjwIgJVF2w6q24ALoUEyBxXcc9ktCDd9Xed0uzmv3Liq+bn8="}],"unpackedSize":70191},"main":"index.js","name":"confstash","_from":"file:/tmp/packs-HjyxSq/confstash-0.1.3.tgz","types":"index.d.ts","author":{"name":"Constructive","email":"developers@constructive.io"},"module":"esm/index.js","license":"MIT","scripts":{"copy":"makage assets","lint":"eslint . --fix","test":"cross-env NODE_OPTIONS=--experimental-vm-modules jest","build":"makage build","clean":"makage clean","test:watch":"cross-env NODE_OPTIONS=--experimental-vm-modules jest --watch"},"version":"0.1.3","_npmUser":{"name":"GitHub Actions","email":"npm-oidc-no-reply@github.com","trustedPublisher":{"id":"github","oidcConfigId":"35ef19f5-57a2-4a3d-a48d-05ccf0220e1b"}},"homepage":"https://github.com/constructive-io/dev-utils","keywords":["config","configuration","rc","cosmiconfig","presets","extends","loader","cli"],"_resolved":"/tmp/packs-HjyxSq/confstash-0.1.3.tgz","_integrity":"sha512-a74y96UzNwVHGBB/XN9itYtjwxLfSYbVwri0Hs7R9ZUsqkUOLcVuGpAEm/a5/f1c+9rjv/XPzipm5aP1umtRDA==","repository":{"url":"git+https://github.com/constructive-io/dev-utils.git","type":"git"},"_npmVersion":"11.21.3","description":"Standardized project configuration loading — config files, rc files, presets, and layered merge with provenance","directories":{},"maintainers":[{"name":"pyramation","email":"pyramation@gmail.com"}],"_nodeVersion":"24.22.3","dependencies":{"js-yaml":"^4.1.0","appstash":"0.8.1"},"publishConfig":{"access":"public","directory":"dist"},"_hasShrinkwrap":false,"devDependencies":{"makage":"0.1.10","cross-env":"^10.1.0","@types/js-yaml":"^4.0.9"},"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/confstash_0.1.3_1795409744973_0.2450799067756726"}}},"time":{"created":"2026-07-28T21:29:13.808Z","modified":"2026-11-23T04:55:45.306Z","0.1.0":"2026-07-28T21:29:14.126Z","0.1.1":"2026-07-31T21:29:37.992Z","0.1.2":"2026-08-04T01:10:37.364Z","0.1.3":"2026-11-23T04:55:45.064Z"},"bugs":{"url":"https://github.com/constructive-io/dev-utils/issues"},"author":{"name":"Constructive","email":"developers@constructive.io"},"license":"MIT","homepage":"https://github.com/constructive-io/dev-utils","keywords":["config","configuration","rc","cosmiconfig","presets","extends","loader","cli"],"repository":{"url":"git+https://github.com/constructive-io/dev-utils.git","type":"git"},"description":"Standardized project configuration loading — config files, rc files, presets, and layered merge with provenance","maintainers":[{"name":"pyramation","email":"pyramation@gmail.com"}],"readme":"# confstash\n\n<p align=\"center\">\n  <img src=\"https://raw.githubusercontent.com/constructive-io/constructive/refs/heads/main/assets/outline-logo.svg\" height=\"250\">\n  <br />\n    <strong>standardized project configuration loading</strong>\n  <br />\n  <br />\n  Config files, rc files, presets, and layered merge with provenance\n  <br />\n  <br />\n  <a href=\"https://github.com/constructive-io/dev-utils/actions/workflows/ci.yml\">\n    <img height=\"20\" src=\"https://github.com/constructive-io/dev-utils/actions/workflows/ci.yml/badge.svg\" />\n  </a>\n  <a href=\"https://github.com/constructive-io/dev-utils/blob/main/LICENSE\">\n    <img height=\"20\" src=\"https://img.shields.io/badge/license-MIT-blue.svg\"/>\n  </a>\n</p>\n\nStandardized project configuration loading for CLI tools — the project-level complement to [`appstash`](../appstash) (user-level directories).\n\nGive it a tool name and it discovers `mytool.config.{ts,js,mjs,cjs}`, `.mytoolrc{,.json,.yaml,.yml,.js}`, `mytool.json`, and `package.json` keys via walk-up search, resolves `extends`/preset chains, and merges layered configuration with per-key provenance:\n\n```\ndefaults -> presets (extends) -> user stash -> project file -> env vars -> runtime overrides\n```\n\n## Installation\n\n```bash\nnpm install confstash\n```\n\n## Features\n\n- **Walk-up discovery**: finds config in the current directory or any parent\n- **Every format**: `.config.ts/js/mjs/cjs` modules, rc files (JSON/YAML), JSON, `package.json` keys\n- **Presets & extends**: named presets, relative paths, or npm packages — recursively, with cycle detection\n- **Layered merge**: deterministic precedence with `replace` or `concat` array strategies\n- **Provenance**: `explainSync()` tells you which layer supplied every value (`--print-config` UX)\n- **Sync and async**: fully synchronous path for CLIs (ESM configs require `load()`)\n- **User layer**: optional `~/.<tool>/config/config.json` layer via appstash\n- **Typed**: `defineConfig<T>()` + generic loader for full type safety\n\n## Usage\n\n### Basic Usage\n\n```typescript\nimport { createConfigLoader } from 'confstash';\n\ninterface MyConfig {\n  level: string;\n  rules: Record<string, string>;\n}\n\nconst loader = createConfigLoader<MyConfig>({\n  tool: 'mytool',\n  defaults: { level: 'medium', rules: {} }\n});\n\nconst { config, filepath, layers, isEmpty } = loader.loadSync();\n// or: await loader.load()  — also supports .mjs / ESM configs\n```\n\n### Presets and extends\n\n```typescript\nconst loader = createConfigLoader<MyConfig>({\n  tool: 'mytool',\n  presets: {\n    'mytool:recommended': { level: 'medium', rules: { A1: 'error' } },\n    'mytool:strict': { extends: 'mytool:recommended', level: 'high' }\n  }\n});\n```\n\n```jsonc\n// .mytoolrc.json\n{\n  \"extends\": \"mytool:strict\",     // or \"./team-preset.js\", or \"some-npm-pkg\"\n  \"rules\": { \"A1\": \"off\" }\n}\n```\n\n### Typed config authoring\n\n```typescript\n// mytool.config.ts\nimport { defineConfig } from 'confstash';\n\nexport default defineConfig({\n  extends: 'mytool:recommended',\n  level: 'high'\n});\n```\n\n### Environment and CLI layers\n\n```typescript\nconst loader = createConfigLoader<MyConfig>({\n  tool: 'mytool',\n  envLayer: (env) => (env.MYTOOL_LEVEL ? { level: env.MYTOOL_LEVEL } : {}),\n  userStash: true // include ~/.mytool/config/config.json (via appstash)\n});\n\nconst { config } = loader.loadSync({\n  overrides: parsedCliFlags // highest precedence\n});\n```\n\n### Provenance / print-config\n\n```typescript\nfor (const entry of loader.explainSync()) {\n  console.log(`${entry.path} = ${JSON.stringify(entry.value)}  (${entry.source}: ${entry.origin})`);\n}\n// level = \"high\"        (file: /repo/mytool.config.ts)\n// rules.A1 = \"error\"    (preset: mytool:recommended)\n```\n\n### Custom search places\n\n```typescript\n// pgpm-compatible discovery\nconst loader = createConfigLoader({\n  tool: 'pgpm',\n  searchPlaces: ['pgpm.config.js', 'pgpm.json'],\n  arrayMerge: 'replace'\n});\n```\n\n## API\n\n### `createConfigLoader<T>(options)`\n\n**Options:**\n- `tool` (string): tool name; drives default search places and the user stash directory\n- `searchPlaces` (SearchPlace[]): filenames or `{ packageJson: key }` entries, in precedence order\n- `defaults` (Partial<T>): lowest-precedence layer\n- `presets` (Record<string, Partial<T>>): named presets resolvable via `extends`\n- `envLayer` ((env) => Partial<T>): map environment variables into a layer\n- `userStash` (boolean): include `~/.<tool>/config/config.json` (default `false`)\n- `arrayMerge` (`'replace' | 'concat'`): array strategy (default `'replace'`)\n- `validate` ((config: T) => T | void): validate/normalize the merged result\n- `walkUp` (boolean): search parent directories (default `true`)\n\n**Returns:** `ConfigLoader<T>` with `load(params)`, `loadSync(params)`, `explainSync(params)`, `searchPlaces`.\n\n**Load params:** `cwd`, `overrides`, `configFile` (skip discovery), `env`.\n\n### Utilities\n\n- `defineConfig<T>(config)` — identity helper for typed config files\n- `defaultSearchPlaces(tool)` — the derived search place list\n- `findConfigSync(startDir, searchPlaces, walkUp?)` / `findUpDir(startDir, filename)` — discovery primitives\n- `loadFileSync(found)` / `loadFile(found)` — format-aware file loading\n- `deepMerge(target, source, arrayMerge?)` / `mergeLayers(layers)` / `explainLayers(layers)` — merge primitives\n- `ConfigLoadError` — thrown for unreadable/invalid config files\n\n## Related\n\n- [`appstash`](../appstash) — user-level directories (`~/.<tool>/{config,cache,data,logs}`) and the optional `userStash` layer\n\n---\n\n## Development\n\n### Setup\n\n1. Clone the repository:\n\n```bash\ngit clone https://github.com/constructive-io/dev-utils.git\n```\n\n2. Install dependencies:\n\n```bash\ncd dev-utils\npnpm install\npnpm build\n```\n\n3. Test the package of interest:\n\n```bash\ncd packages/<packagename>\npnpm test:watch\n```\n\n## Credits\n\n**🛠 Built by the [Constructive](https://constructive.io) team — creators of modular Postgres tooling for secure, composable backends. If you like our work, contribute on [GitHub](https://github.com/constructive-io).**\n\n## Disclaimer\n\nAS DESCRIBED IN THE LICENSES, THE SOFTWARE IS PROVIDED \"AS IS\", AT YOUR OWN RISK, AND WITHOUT WARRANTIES OF ANY KIND.\n\nNo developer or entity involved in creating this software will be liable for any claims or damages whatsoever associated with your use, inability to use, or your interaction with other users of the code, including any direct, indirect, incidental, special, exemplary, punitive or consequential damages, or loss of profits, cryptocurrencies, tokens, or anything else of value.\n","readmeFilename":"README.md"}