{"_id":"@andyrmitchell/cli-config-file-ts","_rev":"7-0c9ec26ea28343e8ba051e9f09fa19d1","name":"@andyrmitchell/cli-config-file-ts","dist-tags":{"latest":"0.0.8"},"versions":{"0.0.2":{"name":"@andyrmitchell/cli-config-file-ts","version":"0.0.2","author":"","license":"MIT","_id":"@andyrmitchell/cli-config-file-ts@0.0.2","maintainers":[{"name":"andyrmitchell","email":"a.r.mitchell@gmail.com"}],"dist":{"shasum":"f49b4fa0581d672e2045167c60616fa3582dd46a","tarball":"https://registry.npmjs.org/@andyrmitchell/cli-config-file-ts/-/cli-config-file-ts-0.0.2.tgz","fileCount":9,"integrity":"sha512-7qfW056C2eucrtOn8Nh/2l/QcT3ImkdhTYz7WFrhU/nt6arerRtcsiYgezS8LRBGOiuOYlDFfp8i39ALbSwjaQ==","signatures":[{"sig":"MEYCIQC6CciVSg3O5eVNBMqURGSRQPDbGKtPwDGfRblO0eyvUQIhAOeqLXmTnVcIfpX37yIkTxs44QgJ2caAyBdkxvfUSQc7","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":9906362},"type":"module","engines":{"node":">=19.0.0"},"exports":{".":{"types":"./dist/index.d.ts","default":"./dist/index.js"},"./schema":{"types":"./dist/index-schema.d.ts","default":"./dist/index-schema.js"}},"gitHead":"24129d987210c9211ccb9143c815a89400e30701","scripts":{"test":"vitest","build":"tsup","pkglint":"./build/publint_pipeable.sh","test:watch":"vitest --watch","build_prepare":"npm run build && npm run pkglint","build_release":"npm run build_prepare && np","prepublishOnly":"npm run build_prepare"},"_npmUser":{"name":"andyrmitchell","actor":{"name":"andyrmitchell","type":"user","email":"a.r.mitchell@gmail.com"},"email":"a.r.mitchell@gmail.com"},"_npmVersion":"10.7.0","description":"Load and validate TypeScript config files with optional Zod schema support. Lightweight, zero dependencies, comprehensive error handling.","directories":{},"sideEffects":false,"_nodeVersion":"20.15.1","publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"tsx":"^4.20.3","tsup":"^8.5.0","execa":"^9.6.0","vitest":"^3.2.3","typescript":"^5.8.3","@types/jest":"^29.5.12"},"peerDependencies":{"zod":"^3.23.8"},"_npmOperationalInternal":{"tmp":"tmp/cli-config-file-ts_0.0.2_1750177119044_0.7234830613835836","host":"s3://npm-registry-packages-npm-production"}},"0.0.3":{"name":"@andyrmitchell/cli-config-file-ts","version":"0.0.3","author":"","license":"MIT","_id":"@andyrmitchell/cli-config-file-ts@0.0.3","maintainers":[{"name":"andyrmitchell","email":"a.r.mitchell@gmail.com"}],"dist":{"shasum":"28297c7b20f3b803fac11dff82dcba65b0e7c85c","tarball":"https://registry.npmjs.org/@andyrmitchell/cli-config-file-ts/-/cli-config-file-ts-0.0.3.tgz","fileCount":9,"integrity":"sha512-V7DHYddQm+KGv+3lloMklIxFoXyB1BbJZdIiFYwKGe3a32FCacd8HoHZGVcJQcggczozDuV4mtsghrmI/ZvIrA==","signatures":[{"sig":"MEQCIC5tDUcfimDe5FDgVgni1W9kfud7DHzUa1U2AWGoL2glAiBHSndHm8yEwqUtR8abbmaqSVhZ9WEtG4fIvDR0FmvMOQ==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":9906399},"type":"module","engines":{"node":">=19.0.0"},"exports":{".":{"types":"./dist/index.d.ts","default":"./dist/index.js"},"./schema":{"types":"./dist/index-schema.d.ts","default":"./dist/index-schema.js"}},"gitHead":"df588b12ba33c0d0eda915b2721cd65da6140779","scripts":{"test":"vitest","build":"tsup","pkglint":"./build/publint_pipeable.sh","test:watch":"vitest --watch","build_prepare":"npm run build && npm run pkglint","build_release":"npm run build_prepare && np","prepublishOnly":"npm run build_prepare"},"_npmUser":{"name":"andyrmitchell","actor":{"name":"andyrmitchell","type":"user","email":"a.r.mitchell@gmail.com"},"email":"a.r.mitchell@gmail.com"},"_npmVersion":"10.7.0","description":"Load and validate TypeScript config files with optional Zod schema support. Lightweight, zero dependencies, comprehensive error handling.","directories":{},"sideEffects":false,"_nodeVersion":"20.15.1","publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"tsx":"^4.20.3","tsup":"^8.5.0","execa":"^9.6.0","vitest":"^3.2.3","typescript":"^5.8.3","@types/jest":"^29.5.12"},"peerDependencies":{"zod":"^3.23.8"},"_npmOperationalInternal":{"tmp":"tmp/cli-config-file-ts_0.0.3_1750177732739_0.07490061240755352","host":"s3://npm-registry-packages-npm-production"}},"0.0.4":{"name":"@andyrmitchell/cli-config-file-ts","version":"0.0.4","author":"","license":"MIT","_id":"@andyrmitchell/cli-config-file-ts@0.0.4","maintainers":[{"name":"andyrmitchell","email":"a.r.mitchell@gmail.com"}],"dist":{"shasum":"416bd3e01682106a8535819e410cc507845310db","tarball":"https://registry.npmjs.org/@andyrmitchell/cli-config-file-ts/-/cli-config-file-ts-0.0.4.tgz","fileCount":9,"integrity":"sha512-IVEJUorWncS67hbedRmOnr9i/d2wnR9Zgj+Lu1f3gtxJkdZGo670HR4tKjR2NlYrJcTOGGgKX1bTjYPfgY9q2Q==","signatures":[{"sig":"MEQCIGSJRKL3l8IyQzU6OmdaY20Hkd9VYkooS6f/8BgvYdXZAiAQiRLLQb3qAjtzkProhXTnLPHMhuPbxaTIozdmojqY8w==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":9906847},"type":"module","engines":{"node":">=19.0.0"},"exports":{".":{"types":"./dist/index.d.ts","default":"./dist/index.js"},"./schema":{"types":"./dist/index-schema.d.ts","default":"./dist/index-schema.js"}},"gitHead":"c5b0b872f3b2fbe121a6964478cfb2c795ab9c7a","scripts":{"test":"vitest","build":"tsup","pkglint":"./build/publint_pipeable.sh","test:watch":"vitest --watch","build_prepare":"npm run build && npm run pkglint","build_release":"npm run build_prepare && np","prepublishOnly":"npm run build_prepare"},"_npmUser":{"name":"andyrmitchell","actor":{"name":"andyrmitchell","type":"user","email":"a.r.mitchell@gmail.com"},"email":"a.r.mitchell@gmail.com"},"_npmVersion":"10.7.0","description":"Load and validate TypeScript config files with optional Zod schema support. Lightweight, zero dependencies, comprehensive error handling.","directories":{},"sideEffects":false,"_nodeVersion":"20.15.1","publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"tsx":"^4.20.3","tsup":"^8.5.0","execa":"^9.6.0","vitest":"^3.2.3","typescript":"^5.8.3","@types/jest":"^29.5.12"},"peerDependencies":{"zod":"^3.23.8"},"_npmOperationalInternal":{"tmp":"tmp/cli-config-file-ts_0.0.4_1750179009720_0.47917667939801567","host":"s3://npm-registry-packages-npm-production"}},"0.0.5":{"name":"@andyrmitchell/cli-config-file-ts","version":"0.0.5","author":"","license":"MIT","_id":"@andyrmitchell/cli-config-file-ts@0.0.5","maintainers":[{"name":"andyrmitchell","email":"a.r.mitchell@gmail.com"}],"dist":{"shasum":"6a73def2371638df8ece18b89619fe3b1a5eb860","tarball":"https://registry.npmjs.org/@andyrmitchell/cli-config-file-ts/-/cli-config-file-ts-0.0.5.tgz","fileCount":9,"integrity":"sha512-SoN/ZaCU/eKLGeWqdmRd9IyMo/kaDwGiXQmU0/3dvjpop4kpd0RXnPGmsS4nPFqLZT2n3vYQ/pgUdZyncBbyww==","signatures":[{"sig":"MEQCIAyD+6A9fcopvP+szAmijTcLHVGDJ8VvmKAvtUybgIamAiAfvhsyt8pHP8I3lqZ7WQMRfhLN449fr/b8KxpTzHv0Yg==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":9908177},"type":"module","engines":{"node":">=19.0.0"},"exports":{".":{"types":"./dist/index.d.ts","default":"./dist/index.js"},"./schema":{"types":"./dist/index-schema.d.ts","default":"./dist/index-schema.js"}},"gitHead":"cd34528f218ddbddd4c3da3c2fda1da6911be842","scripts":{"test":"vitest","build":"tsup","pkglint":"./build/publint_pipeable.sh","test:watch":"vitest --watch","build_prepare":"npm run build && npm run pkglint","build_release":"npm run build_prepare && np","prepublishOnly":"npm run build_prepare"},"_npmUser":{"name":"andyrmitchell","actor":{"name":"andyrmitchell","type":"user","email":"a.r.mitchell@gmail.com"},"email":"a.r.mitchell@gmail.com"},"_npmVersion":"10.7.0","description":"Load and validate TypeScript config files with optional Zod schema support. Lightweight, zero dependencies, comprehensive error handling.","directories":{},"sideEffects":false,"_nodeVersion":"20.15.1","publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"tsx":"^4.20.3","tsup":"^8.5.0","execa":"^9.6.0","vitest":"^3.2.3","typescript":"^5.8.3","@types/jest":"^29.5.12"},"peerDependencies":{"zod":"^3.23.8"},"_npmOperationalInternal":{"tmp":"tmp/cli-config-file-ts_0.0.5_1750183231954_0.31601335444682555","host":"s3://npm-registry-packages-npm-production"}},"0.0.6":{"name":"@andyrmitchell/cli-config-file-ts","version":"0.0.6","author":"","license":"MIT","_id":"@andyrmitchell/cli-config-file-ts@0.0.6","maintainers":[{"name":"andyrmitchell","email":"a.r.mitchell@gmail.com"}],"dist":{"shasum":"43309ef12f571a005ec5b8ab54516beb425ddcbe","tarball":"https://registry.npmjs.org/@andyrmitchell/cli-config-file-ts/-/cli-config-file-ts-0.0.6.tgz","fileCount":9,"integrity":"sha512-gMo9Li2uC/qWWjnOlsZGfgj2MMMVHXQZPssDDP0kWiCCXyNBOtvIxexYrl0pe5fTnqigh7QUM8T7JWim3me/1w==","signatures":[{"sig":"MEYCIQDdzIaMzMhdq+AJrQQBX7gzbW99QI2qefVK84R4AcvFTgIhAPjmIvxKmIOxE3q3j69itguXwdoyxLQga5PyUAaJyz/S","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":18479},"type":"module","engines":{"node":">=19.0.0"},"exports":{".":{"types":"./dist/index.d.ts","default":"./dist/index.js"},"./schema":{"types":"./dist/index-schema.d.ts","default":"./dist/index-schema.js"}},"gitHead":"7d060acd71516f2c03763892fd02055625426767","scripts":{"test":"vitest","build":"tsup","pkglint":"./build/publint_pipeable.sh","test:watch":"vitest --watch","build_prepare":"npm run build && npm run pkglint","build_release":"npm run build_prepare && np","prepublishOnly":"npm run build_prepare"},"_npmUser":{"name":"andyrmitchell","actor":{"name":"andyrmitchell","type":"user","email":"a.r.mitchell@gmail.com"},"email":"a.r.mitchell@gmail.com"},"_npmVersion":"10.7.0","description":"Load and validate TypeScript config files with optional Zod schema support. Lightweight, zero dependencies, comprehensive error handling.","directories":{},"sideEffects":false,"_nodeVersion":"20.15.1","publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"tsx":"^4.20.3","tsup":"^8.5.0","execa":"^9.6.0","vitest":"^3.2.3","typescript":"^5.8.3","@types/jest":"^29.5.12"},"peerDependencies":{"zod":"^3.23.8","esbuild":">=0.18"},"_npmOperationalInternal":{"tmp":"tmp/cli-config-file-ts_0.0.6_1750184356081_0.7289046476150003","host":"s3://npm-registry-packages-npm-production"}},"0.0.7":{"name":"@andyrmitchell/cli-config-file-ts","version":"0.0.7","author":"","license":"MIT","_id":"@andyrmitchell/cli-config-file-ts@0.0.7","maintainers":[{"name":"andyrmitchell","email":"a.r.mitchell@gmail.com"}],"dist":{"shasum":"a2b199ba98a8fc21ffadc855e4c09a144bc01e15","tarball":"https://registry.npmjs.org/@andyrmitchell/cli-config-file-ts/-/cli-config-file-ts-0.0.7.tgz","fileCount":9,"integrity":"sha512-+iFqtBmgp6cBrj0LpDFyqqC/U6hFglWwrfpnJRYMuCr0GiYspoW1aPBE5WoSGlkEnx+i2WZGP1dcJ4LlLcJwTg==","signatures":[{"sig":"MEUCIQDjiUlcCYHXCJV3+I9ValSsDImqUDSW7DeMkVOCKhuB3wIgQiruPHidWEndTuwH4LF7NRRWJUdTjypgh7YAd9fF+do=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":19078},"type":"module","engines":{"node":">=19.0.0"},"exports":{".":{"types":"./dist/index.d.ts","default":"./dist/index.js"},"./schema":{"types":"./dist/index-schema.d.ts","default":"./dist/index-schema.js"}},"gitHead":"b65ce647e5a4c09f3417661855d6bb1775b876bf","scripts":{"test":"vitest","build":"tsup","pkglint":"./build/publint_pipeable.sh","test:watch":"vitest --watch","build_prepare":"npm run build && npm run pkglint","build_release":"npm run build_prepare && np","prepublishOnly":"npm run build_prepare"},"_npmUser":{"name":"andyrmitchell","actor":{"name":"andyrmitchell","type":"user","email":"a.r.mitchell@gmail.com"},"email":"a.r.mitchell@gmail.com"},"_npmVersion":"10.7.0","description":"Load and validate TypeScript config files with optional Zod schema support. Lightweight, zero dependencies, comprehensive error handling.","directories":{},"sideEffects":false,"_nodeVersion":"20.15.1","publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"tsx":"^4.20.3","tsup":"^8.5.0","execa":"^9.6.0","vitest":"^3.2.3","typescript":"^5.8.3","@types/jest":"^29.5.12"},"peerDependencies":{"zod":"^3.23.8","esbuild":">=0.18"},"_npmOperationalInternal":{"tmp":"tmp/cli-config-file-ts_0.0.7_1750193314152_0.03416984816249058","host":"s3://npm-registry-packages-npm-production"}},"0.0.8":{"name":"@andyrmitchell/cli-config-file-ts","version":"0.0.8","description":"Load and validate TypeScript config files with optional Zod schema support. Lightweight, zero dependencies, comprehensive error handling.","sideEffects":false,"exports":{".":{"types":"./dist/index.d.ts","default":"./dist/index.js"},"./schema":{"types":"./dist/index-schema.d.ts","default":"./dist/index-schema.js"}},"type":"module","publishConfig":{"access":"public"},"scripts":{"build_release":"npm run build_prepare && np","build":"tsup","pkglint":"./build/publint_pipeable.sh","build_prepare":"npm run build && npm run pkglint","prepublishOnly":"npm run build_prepare","test":"vitest","test:watch":"vitest --watch"},"author":"","license":"MIT","engines":{"node":">=19.0.0"},"devDependencies":{"@types/jest":"^29.5.12","execa":"^9.6.0","tsup":"^8.5.0","tsx":"^4.20.3","typescript":"^5.8.3","vitest":"^3.2.3","zod":"^4.4.3"},"peerDependencies":{"esbuild":">=0.18","zod":"^4.1.8"},"gitHead":"1fce8ba865d4c2324130d40f08853bb99a91cdd7","_id":"@andyrmitchell/cli-config-file-ts@0.0.8","_nodeVersion":"24.16.0","_npmVersion":"11.13.0","dist":{"integrity":"sha512-KEvZhsX9z6dYagALqOeHuPVSS4B+23Y+ynoBQ8VkI9DcQhOK/PKRgo8qyYTFjx/LOtm7UPTRXGLDeShfjQeoyg==","shasum":"f4d7b8b7b9478ca0d7dcf9afa8315aabf7dc74bd","tarball":"https://registry.npmjs.org/@andyrmitchell/cli-config-file-ts/-/cli-config-file-ts-0.0.8.tgz","fileCount":9,"unpackedSize":19095,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEQCIHqxjyG5RK84i7oyLV5EPD+MRTLSDOJPqIos1uyBohSOAiAsB8D+U7QuBotP5Z/rxqd5KNvMV2cAqWLCYIJbwZRlPA=="}]},"_npmUser":{"name":"andyrmitchell","email":"a.r.mitchell@gmail.com"},"directories":{},"maintainers":[{"name":"andyrmitchell","email":"a.r.mitchell@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/cli-config-file-ts_0.0.8_1786692156784_0.5480281597618288"},"_hasShrinkwrap":false}},"time":{"created":"2025-06-17T16:18:38.957Z","modified":"2026-08-14T07:22:37.190Z","0.0.2":"2025-06-17T16:18:39.334Z","0.0.3":"2025-06-17T16:28:53.080Z","0.0.4":"2025-06-17T16:50:10.066Z","0.0.5":"2025-06-17T18:00:32.209Z","0.0.6":"2025-06-17T18:19:16.281Z","0.0.7":"2025-06-17T20:48:34.321Z","0.0.8":"2026-08-14T07:22:36.958Z"},"license":"MIT","description":"Load and validate TypeScript config files with optional Zod schema support. Lightweight, zero dependencies, comprehensive error handling.","maintainers":[{"name":"andyrmitchell","email":"a.r.mitchell@gmail.com"}],"readme":"# @andyrmitchell/cli-config-file-ts\n\n**Load and validate TypeScript config files — modern, minimal, and dependency-free (unless you choose to validate with Zod).**\n\n## ✨ Features\n\n- **Modern ESM only** — small, fast, no CommonJS legacy.\n- **Zero dependencies** — unless you opt into schema validation with `zod`.\n- **Supports native TS environments** — works out of the box in runtimes like Bun or tsx.\n- **Automatic fallback to transpilation** — no TS loader? It’ll transpile your config on the fly.\n- **Optional Zod validation** — validate your config with a schema (via a separate export).\n- **Create default config if missing** — optionally auto-generate a config file.\n\n---\n\n## 🚀 Installation\n\n```bash\nnpm install @andyrmitchell/cli-config-file-ts\n```\n\nIf you want to use **Zod validation**, install `zod`:\n\n```bash\nnpm install zod\n```\n\n---\n\n## ⚡ Quick Usage\n\n### Load a config file\n\n```ts\nimport { loadTsConfig } from \"@andyrmitchell/cli-config-file-ts\";\n\nconst config = await loadTsConfig(\"/absolute/path/to/config.ts\");\nconsole.log(config);\n```\n\n👉 You can also explicitly type it if needed:\n\n```ts\nconst config = await loadTsConfig<{ port: number }>(\n  \"/absolute/path/to/config.ts\"\n);\n// config: {port: number}\n```\n\nNote if you want to type it, it's best to use a zod schema to validate it (see below).\n\n---\n\n### Provide a default if file doesn’t exist\n\n```ts\nconst config = await loadTsConfig(\"/absolute/path/to/config.ts\", {\n  config: { port: 3000, host: \"localhost\" },\n});\n```\n\n👉 If the file is missing:\n\n- It writes the default config.\n- Throws an error prompting you to check the new file to confirm you're happy with the defaults and then re-run it.\n\n👉 If you want to **immediately use** the generated config:\n\n```ts\nconst config = await loadTsConfig(\"/absolute/path/to/config.ts\", {\n  config: { port: 3000, host: \"localhost\" },\n  immediatelyUseConfig: true,\n});\n```\n\n---\n\n### Validate config with Zod (with type inference)\n\n```ts\nimport { z } from \"zod\";\nimport { loadTsConfigWithSchema } from \"@andyrmitchell/cli-config-file-ts/schema\";\n\n// Define your Zod schema\nconst schema = z.object({\n  port: z.number(),\n  host: z.string(),\n});\n\n// The returned config is fully typed!\nconst config = await loadTsConfigWithSchema(\n  \"/absolute/path/to/config.ts\",\n  schema\n);\n\n// `config` is inferred as { port: number; host: string }\nconsole.log(config.port.toFixed(0)); // fully typed as number\nconsole.log(config.host.toUpperCase()); // fully typed as string\n```\n\nIf validation fails, you’ll get clear error messages like:\n\n```\nConfig file did not match schema. Validation errors:\nport: Expected number, received string\n```\n\n---\n\n## 🌟 Example config.ts\n\n```ts\nexport default {\n  port: 3000,\n  host: \"localhost\",\n};\n```\n\nor\n\n```ts\nexport const config = {\n  port: 3000,\n  host: \"localhost\",\n};\n```\n\n---\n\n## 📝 Notes\n\n- The path you pass must be **absolute**.\n- Requires Node.js `>=19.0.0`.\n- Supports native TypeScript loading in compatible environments (e.g. Bun, tsx). Falls back to internal transpilation otherwise.\n\n---\n\n## 🛡️ Error handling with isKnownCause\n\nIf you want to surface clear, typed information from loader errors you can check the Error.cause against the helper function isKnownCause.\n\n```ts\ntry {\n  const config = await loadTsConfig(\"/absolute/path/to/config.ts\");\n  // …use your config here…\n} catch (err) {\n  // First, make sure it's an `Error` and has a `.cause`\n  if (err instanceof Error && isKnownCause(err.cause)) {\n    switch (err.cause.type) {\n      case \"file_not_found\":\n        console.error(\"Config file not found:\", err.cause.reason);\n        break;\n      case \"invalid_config_format\":\n        console.error(\"Config failed schema validation.\");\n        break;\n      default:\n        console.error(\"Unhandled config loader error:\", err.cause.type);\n    }\n  } else {\n    // Unknown error — re‑throw or handle generically\n    throw err;\n  }\n}\n```\n\n---\n\n## 📦 Exports\n\n| Export                                     | What it does                               |\n| ------------------------------------------ | ------------------------------------------ |\n| `@andyrmitchell/cli-config-file-ts`        | Core loader without schema validation      |\n| `@andyrmitchell/cli-config-file-ts/schema` | Loader with optional Zod schema validation |\n","readmeFilename":"README.MD"}