arkenv 1.0.0-alpha.6 → 1.0.0-alpha.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/dist/index.cjs +8 -4
  2. package/package.json +7 -2
package/dist/index.cjs CHANGED
@@ -113,7 +113,7 @@ ${t?(0,n.styleText)(`cyan`,B):``}
113
113
  outdir: "./dist",
114
114
  ${S.default.green(`plugins: [arkenv]`)}
115
115
  });
116
- `),{success:!0,instructions:i.trim()}}async function dn(e,t){let n=t||await Ht();if(!n)return{status:`not_found`};let r=o.default.basename(n);try{let t=await e.readFile(n);if((0,d.parse)(t)?.compilerOptions?.strict===!0)return{status:`already_strict`,file:r};let i=(0,d.applyEdits)(t,(0,d.modify)(t,[`compilerOptions`,`strict`],!0,{formattingOptions:{insertSpaces:!0,tabSize:2}}));return await e.writeFile(n,i),{status:`updated`,file:r}}catch{return{status:`error`,file:r}}}var fn=class{constructor(e,t,n){this.isQuiet=e,this.stdio=t,this.logger=n}async exists(e){try{return await s.default.access(e),!0}catch{return!1}}async readFile(e){return s.default.readFile(e,`utf-8`)}async writeFile(e,t){await s.default.writeFile(e,t,`utf-8`)}async mkdir(e,t){await s.default.mkdir(e,{recursive:t})}async execute(e,t=[],n){return new Promise((r,i)=>{let a=(0,l.spawn)(e,t,{cwd:n,stdio:this.isQuiet?`pipe`:this.stdio,shell:!1}),o=``,s=``,c=1e4;this.isQuiet&&(a.stdout?.on(`data`,e=>{o=(o+e.toString()).slice(-c)}),a.stderr?.on(`data`,e=>{s=(s+e.toString()).slice(-c)})),a.on(`close`,(e,t)=>{if(e===0)r();else{let n=e===null?`Command terminated by signal ${t}`:`Command failed with code ${e}`;this.isQuiet&&(o&&(n+=`\n${S.default.dim(`STDOUT:`)}\n${o}`),s&&(n+=`\n${S.default.red(`STDERR:`)}\n${s}`)),i(Error(n))}}),a.on(`error`,i)})}async updateTsConfigToStrict(e){return dn(this,e)}async findViteConfig(e){return nn(e)}async findBunConfig(e){return rn(e)}async findNextjsConfig(e){return an(e)}async findNuxtConfig(e){return sn(e)}async bootstrapViteConfig(e,t){return ln(this,e,t)}async bootstrapBunConfig(e,t){return un(e,t)}async bootstrapNextjsConfig(e,t){return on(this,e,t)}async bootstrapNuxtConfig(e){return cn(this,e)}async safeAppend(e,t,n){let{safeAppend:r}=await Promise.resolve().then(()=>wt);return r(e,t,n,this.logger)}};async function pn(e){let t=e.defaultPath||`./src/env.ts`;if(e.hasEnvSchemaFile){let e=await H({message:S.default.yellow(`An existing ArkEnv configuration was found at ${K(t)}. Do you want to overwrite it?`),initialValue:!1,active:`Yes (override my configuration)`,inactive:`No (abort)`});return I(e)||!e?null:e}return!0}async function mn(e){let t=e.detectedKeys,n=e.keysSource||`.env.example`;if(t&&t.length>0){let e=t.length,r=e===1,i=await H({message:n===`.env.example`?`Detected ${K(`.env.example`)} with ${e} ${r?`key`:`keys`}. Use ${r?`it`:`them`} for your schema?`:`Detected ${e} environment variable${r?``:`s`} used in your project. Use ${r?`it`:`them`} for your schema?`,active:`Yes (Recommended)`,initialValue:!0});return I(i)?null:i}return!1}async function hn(e){if(e.framework===`vite`||e.framework===`bun-fullstack`){let t=e.framework===`vite`?`vite-env.d.ts`:`bun-env.d.ts`;if(e.hasTypeFile)return!0;let n=await H({message:`Establish ${K(t)} for typesafe environment variables?`,initialValue:!0,active:`Yes (Recommended)`,inactive:`No`});return I(n)?null:n}return!0}async function gn(e){if(!e.installTypeDefinitions||e.framework!==`vite`&&e.framework!==`bun-fullstack`)return`skip`;let t=e.framework===`vite`?`vite-env.d.ts`:`bun-env.d.ts`;if(e.hasTypeFile){let e=await W({message:`Found existing ${K(t)}. How should we handle ArkEnv types?`,options:[{value:`append`,label:`Append types safely (if needed)`,hint:`Recommended`},{value:`overwrite`,label:`Overwrite entirely`,hint:`Destructive`},{value:`skip`,label:`Skip`}]});return I(e)?null:e}return`overwrite`}async function _n(e){let t=await W({message:`Select an example:`,options:e.examples.map(e=>({value:e.id,label:e.name,...e.description?{hint:e.description}:{}}))});return I(t)?null:t}async function vn(e){let t=await W({message:`Select your framework or build tool:`,initialValue:e.framework,options:[{value:`vanilla`,label:`Vanilla${e.framework===`vanilla`?` (Detected)`:``}`,hint:`Node.js, Bun, server-side or runtime-only validation`},{value:`vite`,label:`Vite${e.framework===`vite`?` (Detected)`:``}`,hint:`Client-side and static inlining validation`},{value:`bun-fullstack`,label:`Bun fullstack dev server${e.framework===`bun-fullstack`?` (Detected)`:``}`,hint:`Client-side bundling and Bun.serve integration`},{value:`nextjs`,label:`Next.js${e.framework===`nextjs`?` (Detected)`:``}`,hint:`Next.js App or Pages Router with build and runtime validation`},{value:`nuxt`,label:`Nuxt${e.framework===`nuxt`?` (Detected)`:``}`,hint:`Nuxt with build and runtime validation`}]});return I(t)?null:t}async function yn(e){let t=await H({message:`Optional: Would you also like to bootstrap a custom Bun.build script for programmatic bundling?`,initialValue:e.initialValue??!1});return I(t)?null:t}async function bn(){let e=await W({message:`Select your preferred validator library:`,options:[{value:`arktype`,label:`ArkType (Recommended)`,hint:`TypeScript's 1:1 validator, optimized from editor to runtime`},{value:`zod`,label:`Zod`,hint:`TypeScript-first schema validation with static type inference`},{value:`valibot`,label:`Valibot`,hint:`The modular and type safe schema library`}]});return I(e)?null:e}async function xn(e){let t=await W({message:`How would you like to structure your environment variables?`,options:(e?.framework,[{value:`flat`,label:`Flat (Recommended)`,hint:`A single flat env.ts file for the best DX`},{value:`strict`,label:`Strict`,hint:`Separate shared, client, and server files for hard bundle boundaries.`}])});return I(t)?null:t}async function Sn(e){let t=await H({message:`Enable automated ${e.framework===`nuxt`?`Nuxt`:`Next.js`} code generation for environment variables?`,initialValue:e.initialValue??!0,active:`Yes (Recommended)`,inactive:`No`});return I(t)?null:t}const Cn={vercel:{label:`Vercel`,hint:`Add VERCEL, VERCEL_ENV, VERCEL_URL, etc.`,serverOnlyKeys:[`VERCEL`],clientExposedKeys:[`VERCEL_ENV`,`VERCEL_URL`],fields:{VERCEL:{type:`string`},VERCEL_ENV:{type:`enum`,values:[`production`,`preview`,`development`]},VERCEL_URL:{type:`string`}}},netlify:{label:`Netlify`,hint:`Add NETLIFY, CONTEXT, URL, DEPLOY_URL, etc.`,serverOnlyKeys:[`NETLIFY`,`DEPLOY_URL`],clientExposedKeys:[`CONTEXT`,`URL`],fields:{NETLIFY:{type:`string`},DEPLOY_URL:{type:`string`},CONTEXT:{type:`enum`,values:[`production`,`deploy-preview`,`branch-deploy`]},URL:{type:`string`}}}};function wn(e){return e===`none`||Object.keys(Cn).includes(e)}function q(e,t){if(e===`none`)return[];let n=Cn[e],r=[...n.serverOnlyKeys,...n.clientExposedKeys];if(t)for(let e of n.clientExposedKeys)r.push(`${t}${e}`);return r}function Tn(e,t,n){if(!n||n===`none`)return;let r=t&&e.startsWith(t)?e.slice(t.length):e,i=Cn[n].fields;return r in i?i[r]:void 0}function En(e,t,n){let r=q(t??`none`,n);if(!(!e?.length&&r.length===0))return Array.from(new Set([...e??[],...r]))}async function Dn(e){let t=[{value:`none`,label:`None`,hint:`Do not add any hosting-specific environment variables`},...Object.entries(Cn).map(([e,t])=>({value:e,label:t.label,hint:t.hint}))],n=await W({message:`Select a hosting provider preset (optional):`,initialValue:e?.initialValue??`none`,options:t});return I(n)?null:n}async function On(e){let t=await H({message:`Use default config path (${K(e.defaultEnvPath||`./src/env.ts`)})?`,initialValue:!0,active:`Yes (Recommended)`,inactive:`No, let me customize it`});return I(t)?null:t}async function kn(e){let t=e.defaultEnvPath||`./src/env.ts`;if(!e.useDefaultPath){let e=await at({message:`Where should we create the ArkEnv config?`,placeholder:t,initialValue:t,defaultValue:t});if(I(e))return null;let n=typeof e==`string`?e.trim():``;return n===``?t:n}return t}const J={example:_n,overwriteEnvSchemaFile:pn,framework:vn,bunBuild:yn,layout:xn,nextjsCodegen:Sn,useDefaultPath:On,path:kn,installTypeDefinitions:hn,envDtsHandling:gn,validator:bn,hostPreset:Dn,useEnvExample:mn};async function An(e,t=!1){return(e?.mode||`existing`)===`new`?jn(e,t):Mn(e,t)}async function jn(e,t=!1){let n=e?.examples||[],r=`arkenv-project`;try{let i;if(e?.name){let t=e.name.trim();i=t===`.`||t===`./`||o.default.resolve(process.cwd(),t)===process.cwd()?`.`:t}else if(t)i=r;else{let e=(Y(await at({message:`Project name:`,placeholder:r,defaultValue:r}))||r).trim();i=e===`.`||e===`./`||o.default.resolve(process.cwd(),e)===process.cwd()?`.`:e}let a=e?.example;!a&&!t?a=Y(await J.example({examples:n})):!a&&t&&(a=`basic`);let s=n.find(e=>e.id===a);if(!s){let e=n.map(e=>e.id).join(`, `);throw Error(`Unknown example ${a}. Available examples: ${e}`)}return{mode:`new`,example:s.id,name:i,path:`./src/env.ts`,validator:`arktype`,framework:s.framework,language:`ts`,installSkill:!1}}catch(e){if(e instanceof Pn)return null;throw e}}async function Mn(e,n=!1){let r=e?.defaultEnvPath||`./src/env.ts`,i=e?.envKeys||null,a=e?.envKeysSource||`.env.example`;if(n){let n=e?.framework||`vanilla`,a;(n===`nextjs`||n===`nuxt`)&&(a=e?.isStrict?`strict`:e?.isSimple?`simple`:(e?.isFlat,`flat`));let o=await Nn(e,n,r),s;return(n===`vite`||n===`bun-fullstack`)&&(s=o?`append`:`overwrite`),(0,t.shake)({mode:`existing`,path:r,validator:`arktype`,framework:n,layout:a,bunFeatures:n===`bun-fullstack`?e?.bunFeatures??[`serve`]:void 0,language:`ts`,overwriteEnvSchemaFile:!0,installTypeDefinitions:n===`vite`||n===`bun-fullstack`,installSkill:!1,envDtsHandling:s,envKeys:i??void 0,disableCodegen:e?.disableCodegen??!1,wrapNextjsConfig:n===`nextjs`?!0:void 0,hostPreset:e?.hostPreset||`none`})}try{let n=Y(await J.overwriteEnvSchemaFile({hasEnvSchemaFile:e?.hasEnvSchemaFile??!1,defaultPath:r})),o=Y(await J.framework({framework:e?.framework})),s;(o===`nextjs`||o===`nuxt`)&&(s=e?.isStrict?`strict`:e?.isSimple?`simple`:e?.isFlat?`flat`:Y(await J.layout({framework:o})));let c;if(o===`bun-fullstack`){let t=!!e?.bunFeatures?.includes(`build`);c=Y(await J.bunBuild({initialValue:t}))}let l=e?.disableCodegen;o===`nuxt`?l=!0:o===`nextjs`&&l===void 0&&(l=!Y(await J.nextjsCodegen({initialValue:!0,framework:o})));let u;if(o===`nextjs`&&!l){let e=await H({message:`Would you like to wrap your Next.js config with ${K(`withArkEnv`)}?`,initialValue:!0,active:`Yes (Recommended)`,inactive:`No`});if(I(e))throw Xe(`Operation cancelled`),new Pn;u=e}let d=Y(await J.useDefaultPath({defaultEnvPath:r})),f=Y(await J.path({useDefaultPath:d,defaultEnvPath:r})),p=await Nn(e,o,f),m=Y(await J.installTypeDefinitions({framework:o,hasTypeFile:p})),h=Y(await J.envDtsHandling({framework:o,installTypeDefinitions:m,hasTypeFile:p})),g=Y(await J.validator()),_=e?.hostPreset===void 0?Y(await J.hostPreset({initialValue:e?.hostPreset})):e.hostPreset,v=Y(await J.useEnvExample({detectedKeys:i,keysSource:a}));return(0,t.shake)({mode:`existing`,overwriteEnvSchemaFile:n,framework:o,layout:s,path:f,installTypeDefinitions:m,envDtsHandling:h,validator:g,hostPreset:_,bunFeatures:o===`bun-fullstack`?c?[`serve`,`build`]:[`serve`]:void 0,language:`ts`,installSkill:!1,envKeys:v?i??void 0:void 0,disableCodegen:l,wrapNextjsConfig:u})}catch(e){if(e instanceof Pn)return null;throw e}}async function Nn(e,t,n){return await e?.hasTypeFileAtPath?.({framework:t,envPath:n})??e?.hasTypeFile??!1}var Pn=class extends Error{constructor(){super(`Operation cancelled`)}};function Y(e){if(e===null||I(e))throw Xe(`Operation cancelled`),new Pn;return e}var Fn=class{async confirm(e,n=!0,r,i){let a=await H((0,t.shake)({message:e,initialValue:n,active:r,inactive:i}));return I(a)?null:a}async runWizard(e,t=!1){return An(e,t)}};const X={isYes:{long:`--yes`,short:`-y`,kind:`boolean`},isForce:{long:`--force`,short:`-f`,kind:`boolean`},isQuiet:{long:`--quiet`,short:`-q`,kind:`boolean`},isJson:{long:`--json`,short:`-j`,kind:`boolean`},isAgent:{long:`--agent`,short:``,kind:`boolean`},helpRequested:{long:`--help`,short:`-h`,kind:`boolean`},example:{long:`--example`,short:`-e`,kind:`value`},isStrict:{long:`--strict`,short:``,kind:`boolean`},isSimple:{long:`--simple`,short:``,kind:`boolean`},isFlat:{long:`--flat`,short:``,kind:`boolean`},noCodegen:{long:`--no-codegen`,short:``,kind:`boolean`},hostPreset:{long:`--host-preset`,short:`-H`,kind:`value`}},In=new Set(Object.values(X).flatMap(e=>[e.long,e.short].filter(Boolean))),Ln=new Set(Object.values(X).filter(e=>e.kind===`value`).flatMap(e=>[e.long,e.short].filter(Boolean)));var Rn=class{constructor(e,t={}){let n=e.slice(2),r=[],i=!1;for(let e of n){if(i){r.push(e),i=!1;continue}if(Ln.has(e)){r.push(e),i=!0;continue}if(/^-[a-zA-Z]{2,}$/.test(e)){let t=e.slice(1).split(``);for(let e of t)r.push(`-${e}`);Ln.has(`-${t[t.length-1]}`)&&(i=!0)}else r.push(e)}this.args=r,this.command=this.args[0];let a=1,o=[];for(this.validationError=void 0;a<this.args.length;){let e=this.args[a];if(e.startsWith(`-`)){if(!In.has(e)){this.validationError=`Unknown argument: ${e}`;break}if(Ln.has(e))if(a+1<this.args.length&&!this.args[a+1].startsWith(`-`))a+=2;else{this.validationError=`Missing value for option: ${e}`;break}else a+=1}else o.push(e),a+=1}if(!this.validationError){let e=X.hostPreset,t=this.getFlagValue(e.long,e.short);t!==void 0&&!wn(t)&&(this.validationError=`Invalid host preset: ${t}`)}this.validationError||(o.length>1?this.validationError=`Unknown argument: ${o[1]}`:this.name=o[0]),this.logger=t.logger||new st({isQuiet:this.isQuiet,isJson:this.isJson,isYes:this.isYes})}get isAgent(){return this.hasFlag(`isAgent`)}get isYes(){return this.isAgent||this.hasFlag(`isYes`)}get isQuiet(){return this.isAgent||this.hasFlag(`isQuiet`)}get isJson(){return this.isAgent||this.hasFlag(`isJson`)}get isForce(){return this.hasFlag(`isForce`)}get helpRequested(){return this.hasFlag(`helpRequested`)}get example(){let e=X.example;return this.getFlagValue(e.long,e.short)}get isStrict(){return this.hasFlag(`isStrict`)}get isSimple(){return this.hasFlag(`isSimple`)}get isFlat(){return this.hasFlag(`isFlat`)}get noCodegen(){return this.hasFlag(`noCodegen`)}get hostPreset(){let e=X.hostPreset,t=this.getFlagValue(e.long,e.short);if(t!==void 0&&wn(t))return t}hasFlag(e){let t=X[e];return this.args.includes(t.long)||!!t.short&&this.args.includes(t.short)}get initInput(){let e={isYes:this.isYes,isForce:this.isForce,isQuiet:this.isQuiet,isAgent:this.isAgent,isStrict:this.isStrict,isSimple:this.isSimple,isFlat:this.isFlat};return this.example!==void 0&&(e.example=this.example),this.name!==void 0&&(e.name=this.name),this.noCodegen&&(e.noCodegen=!0),this.hostPreset!==void 0&&(e.hostPreset=this.hostPreset),e}getFlagValue(e,t){let n=this.args.findIndex(n=>n===e||n===t);if(n!==-1&&this.args[n+1]&&!this.args[n+1].startsWith(`-`))return this.args[n+1]}},zn=`1.0.0-alpha.6`;function Bn(e,t=2,n=4){let r=Math.max(...e.map(e=>e.left.length),0),i=` `.repeat(t);return e.map(e=>{let t=` `.repeat(r-e.left.length+n);return`${i}${e.left}${t}${e.right}`})}var Vn=class{constructor(e){this.logger=e}async execute(){let e=[{left:`arkenv init [project-name]`,right:`Set up ArkEnv in your project`}],t=[{left:`--yes, -y`,right:`Skip prompts and use defaults (also passed to subprocesses)`},{left:`--force, -f`,right:`Bypass technical requirement checks and dirty git working tree check, then force scaffolding`},{left:`--agent`,right:`Enable non-interactive, machine-readable mode for AI agents. Bypasses all prompts and outputs structured JSON. Macro for --yes --quiet --json`},{left:`--example, -e`,right:`Specify an example name when creating a new project`},{left:`--quiet, -q`,right:`Quiet mode: Suppress output, capture logs on failure`},{left:`--json, -j`,right:`Output structured JSON to stdout`},{left:`--no-codegen`,right:`Disable automatic env.gen.ts code generation for Next.js`},{left:`--host-preset, -H <preset>`,right:`Specify a hosting provider preset (none, vercel, netlify)`},{left:`--help, -h`,right:`Show this help message`}];this.logger.log(`ArkEnv CLI v${zn}`),this.logger.log(`\n${S.default.bold(`Usage:`)}`);for(let t of Bn(e))this.logger.log(t);this.logger.log(`\n${S.default.bold(`Options:`)}`);for(let e of Bn(t))this.logger.log(e)}};async function Hn(e,t){let n=t.targetDir??process.cwd(),r=o.default.join(process.cwd(),`.arkenv-temp`);await e.mkdir(r,!0),t.targetDir&&await e.mkdir(n,!0);try{await e.execute(`git`,[`clone`,`--filter=blob:none`,`--sparse`,t.repository,r]);let i=`examples/${t.example}`;await e.execute(`git`,[`-C`,r,`sparse-checkout`,`set`,i]);let a=o.default.join(r,i),c=await s.default.readdir(a),l=[];for(let t of c){let r=o.default.join(n,t);await e.exists(r)&&l.push(t)}if(l.length>0)throw Error(`Scaffolding into a non-empty directory failed. The following paths already exist: ${l.join(`, `)}`);await Un(a,n);for(let e of[`package-lock.json`,`pnpm-lock.yaml`,`yarn.lock`,`bun.lockb`,`bun.lock`])await s.default.rm(o.default.join(n,e),{force:!0});let u=o.default.join(n,`package.json`);if(await e.exists(u)){let n=await e.readFile(u),r=JSON.parse(n);r.name=t.targetName,delete r.packageManager,await e.writeFile(u,JSON.stringify(r,null,2))}}finally{await s.default.rm(r,{recursive:!0,force:!0})}}async function Un(e,t){let n=await s.default.readdir(e);await Promise.all(n.map(n=>s.default.cp(o.default.join(e,n),o.default.join(t,n),{recursive:!0,force:!1})))}function Wn(e,t){let n=t.length>0;switch(e){case`pnpm`:return[`pnpm`,[n?`add`:`install`,...t]];case`yarn`:return[`yarn`,[n?`add`:`install`,...t]];case`bun`:return[`bun`,[n?`add`:`install`,...t]];default:return[`npm`,[`install`,...t]]}}function Gn(e,t,n){if(t||e.metadata.skillDetected){let t=e.metadata.framework===`nextjs`&&!e.metadata.disableCodegen,r=e.metadata.framework===`nuxt`&&!e.metadata.disableCodegen,i=t&&!n,a=c.default`
116
+ `),{success:!0,instructions:i.trim()}}async function dn(e,t){let n=t||await Ht();if(!n)return{status:`not_found`};let r=o.default.basename(n);try{let t=await e.readFile(n);if((0,d.parse)(t)?.compilerOptions?.strict===!0)return{status:`already_strict`,file:r};let i=(0,d.applyEdits)(t,(0,d.modify)(t,[`compilerOptions`,`strict`],!0,{formattingOptions:{insertSpaces:!0,tabSize:2}}));return await e.writeFile(n,i),{status:`updated`,file:r}}catch{return{status:`error`,file:r}}}var fn=class{constructor(e,t,n){this.isQuiet=e,this.stdio=t,this.logger=n}async exists(e){try{return await s.default.access(e),!0}catch{return!1}}async readFile(e){return s.default.readFile(e,`utf-8`)}async writeFile(e,t){await s.default.writeFile(e,t,`utf-8`)}async mkdir(e,t){await s.default.mkdir(e,{recursive:t})}async execute(e,t=[],n){return new Promise((r,i)=>{let a=(0,l.spawn)(e,t,{cwd:n,stdio:this.isQuiet?`pipe`:this.stdio,shell:!1}),o=``,s=``,c=1e4;this.isQuiet&&(a.stdout?.on(`data`,e=>{o=(o+e.toString()).slice(-c)}),a.stderr?.on(`data`,e=>{s=(s+e.toString()).slice(-c)})),a.on(`close`,(e,t)=>{if(e===0)r();else{let n=e===null?`Command terminated by signal ${t}`:`Command failed with code ${e}`;this.isQuiet&&(o&&(n+=`\n${S.default.dim(`STDOUT:`)}\n${o}`),s&&(n+=`\n${S.default.red(`STDERR:`)}\n${s}`)),i(Error(n))}}),a.on(`error`,i)})}async updateTsConfigToStrict(e){return dn(this,e)}async findViteConfig(e){return nn(e)}async findBunConfig(e){return rn(e)}async findNextjsConfig(e){return an(e)}async findNuxtConfig(e){return sn(e)}async bootstrapViteConfig(e,t){return ln(this,e,t)}async bootstrapBunConfig(e,t){return un(e,t)}async bootstrapNextjsConfig(e,t){return on(this,e,t)}async bootstrapNuxtConfig(e){return cn(this,e)}async safeAppend(e,t,n){let{safeAppend:r}=await Promise.resolve().then(()=>wt);return r(e,t,n,this.logger)}};async function pn(e){let t=e.defaultPath||`./src/env.ts`;if(e.hasEnvSchemaFile){let e=await H({message:S.default.yellow(`An existing ArkEnv configuration was found at ${K(t)}. Do you want to overwrite it?`),initialValue:!1,active:`Yes (override my configuration)`,inactive:`No (abort)`});return I(e)||!e?null:e}return!0}async function mn(e){let t=e.detectedKeys,n=e.keysSource||`.env.example`;if(t&&t.length>0){let e=t.length,r=e===1,i=await H({message:n===`.env.example`?`Detected ${K(`.env.example`)} with ${e} ${r?`key`:`keys`}. Use ${r?`it`:`them`} for your schema?`:`Detected ${e} environment variable${r?``:`s`} used in your project. Use ${r?`it`:`them`} for your schema?`,active:`Yes (Recommended)`,initialValue:!0});return I(i)?null:i}return!1}async function hn(e){if(e.framework===`vite`||e.framework===`bun-fullstack`){let t=e.framework===`vite`?`vite-env.d.ts`:`bun-env.d.ts`;if(e.hasTypeFile)return!0;let n=await H({message:`Establish ${K(t)} for typesafe environment variables?`,initialValue:!0,active:`Yes (Recommended)`,inactive:`No`});return I(n)?null:n}return!0}async function gn(e){if(!e.installTypeDefinitions||e.framework!==`vite`&&e.framework!==`bun-fullstack`)return`skip`;let t=e.framework===`vite`?`vite-env.d.ts`:`bun-env.d.ts`;if(e.hasTypeFile){let e=await W({message:`Found existing ${K(t)}. How should we handle ArkEnv types?`,options:[{value:`append`,label:`Append types safely (if needed)`,hint:`Recommended`},{value:`overwrite`,label:`Overwrite entirely`,hint:`Destructive`},{value:`skip`,label:`Skip`}]});return I(e)?null:e}return`overwrite`}async function _n(e){let t=await W({message:`Select an example:`,options:e.examples.map(e=>({value:e.id,label:e.name,...e.description?{hint:e.description}:{}}))});return I(t)?null:t}async function vn(e){let t=await W({message:`Select your framework or build tool:`,initialValue:e.framework,options:[{value:`vanilla`,label:`Vanilla${e.framework===`vanilla`?` (Detected)`:``}`,hint:`Node.js, Bun, server-side or runtime-only validation`},{value:`vite`,label:`Vite${e.framework===`vite`?` (Detected)`:``}`,hint:`Client-side and static inlining validation`},{value:`bun-fullstack`,label:`Bun fullstack dev server${e.framework===`bun-fullstack`?` (Detected)`:``}`,hint:`Client-side bundling and Bun.serve integration`},{value:`nextjs`,label:`Next.js${e.framework===`nextjs`?` (Detected)`:``}`,hint:`Next.js App or Pages Router with build and runtime validation`},{value:`nuxt`,label:`Nuxt${e.framework===`nuxt`?` (Detected)`:``}`,hint:`Nuxt with build and runtime validation`}]});return I(t)?null:t}async function yn(e){let t=await H({message:`Optional: Would you also like to bootstrap a custom Bun.build script for programmatic bundling?`,initialValue:e.initialValue??!1});return I(t)?null:t}async function bn(){let e=await W({message:`Select your preferred validator library:`,options:[{value:`arktype`,label:`ArkType (Recommended)`,hint:`TypeScript's 1:1 validator, optimized from editor to runtime`},{value:`zod`,label:`Zod`,hint:`TypeScript-first schema validation with static type inference`},{value:`valibot`,label:`Valibot`,hint:`The modular and type safe schema library`}]});return I(e)?null:e}async function xn(e){let t=await W({message:`How would you like to structure your environment variables?`,options:(e?.framework,[{value:`flat`,label:`Flat (Recommended)`,hint:`A single flat env.ts file for the best DX`},{value:`strict`,label:`Strict`,hint:`Separate shared, client, and server files for hard bundle boundaries.`}])});return I(t)?null:t}async function Sn(e){let t=await H({message:`Enable automated ${e.framework===`nuxt`?`Nuxt`:`Next.js`} code generation for environment variables?`,initialValue:e.initialValue??!0,active:`Yes (Recommended)`,inactive:`No`});return I(t)?null:t}const Cn={vercel:{label:`Vercel`,hint:`Add VERCEL, VERCEL_ENV, VERCEL_URL, etc.`,serverOnlyKeys:[`VERCEL`],clientExposedKeys:[`VERCEL_ENV`,`VERCEL_URL`],fields:{VERCEL:{type:`string`},VERCEL_ENV:{type:`enum`,values:[`production`,`preview`,`development`]},VERCEL_URL:{type:`string`}}},netlify:{label:`Netlify`,hint:`Add NETLIFY, CONTEXT, URL, DEPLOY_URL, etc.`,serverOnlyKeys:[`NETLIFY`,`DEPLOY_URL`],clientExposedKeys:[`CONTEXT`,`URL`],fields:{NETLIFY:{type:`string`},DEPLOY_URL:{type:`string`},CONTEXT:{type:`enum`,values:[`production`,`deploy-preview`,`branch-deploy`]},URL:{type:`string`}}}};function wn(e){return e===`none`||Object.keys(Cn).includes(e)}function q(e,t){if(e===`none`)return[];let n=Cn[e],r=[...n.serverOnlyKeys,...n.clientExposedKeys];if(t)for(let e of n.clientExposedKeys)r.push(`${t}${e}`);return r}function Tn(e,t,n){if(!n||n===`none`)return;let r=t&&e.startsWith(t)?e.slice(t.length):e,i=Cn[n].fields;return r in i?i[r]:void 0}function En(e,t,n){let r=q(t??`none`,n);if(!(!e?.length&&r.length===0))return Array.from(new Set([...e??[],...r]))}async function Dn(e){let t=[{value:`none`,label:`None`,hint:`Do not add any hosting-specific environment variables`},...Object.entries(Cn).map(([e,t])=>({value:e,label:t.label,hint:t.hint}))],n=await W({message:`Select a hosting provider preset (optional):`,initialValue:e?.initialValue??`none`,options:t});return I(n)?null:n}async function On(e){let t=await H({message:`Use default config path (${K(e.defaultEnvPath||`./src/env.ts`)})?`,initialValue:!0,active:`Yes (Recommended)`,inactive:`No, let me customize it`});return I(t)?null:t}async function kn(e){let t=e.defaultEnvPath||`./src/env.ts`;if(!e.useDefaultPath){let e=await at({message:`Where should we create the ArkEnv config?`,placeholder:t,initialValue:t,defaultValue:t});if(I(e))return null;let n=typeof e==`string`?e.trim():``;return n===``?t:n}return t}const J={example:_n,overwriteEnvSchemaFile:pn,framework:vn,bunBuild:yn,layout:xn,nextjsCodegen:Sn,useDefaultPath:On,path:kn,installTypeDefinitions:hn,envDtsHandling:gn,validator:bn,hostPreset:Dn,useEnvExample:mn};async function An(e,t=!1){return(e?.mode||`existing`)===`new`?jn(e,t):Mn(e,t)}async function jn(e,t=!1){let n=e?.examples||[],r=`arkenv-project`;try{let i;if(e?.name){let t=e.name.trim();i=t===`.`||t===`./`||o.default.resolve(process.cwd(),t)===process.cwd()?`.`:t}else if(t)i=r;else{let e=(Y(await at({message:`Project name:`,placeholder:r,defaultValue:r}))||r).trim();i=e===`.`||e===`./`||o.default.resolve(process.cwd(),e)===process.cwd()?`.`:e}let a=e?.example;!a&&!t?a=Y(await J.example({examples:n})):!a&&t&&(a=`basic`);let s=n.find(e=>e.id===a);if(!s){let e=n.map(e=>e.id).join(`, `);throw Error(`Unknown example ${a}. Available examples: ${e}`)}return{mode:`new`,example:s.id,name:i,path:`./src/env.ts`,validator:`arktype`,framework:s.framework,language:`ts`,installSkill:!1}}catch(e){if(e instanceof Pn)return null;throw e}}async function Mn(e,n=!1){let r=e?.defaultEnvPath||`./src/env.ts`,i=e?.envKeys||null,a=e?.envKeysSource||`.env.example`;if(n){let n=e?.framework||`vanilla`,a;(n===`nextjs`||n===`nuxt`)&&(a=e?.isStrict?`strict`:e?.isSimple?`simple`:(e?.isFlat,`flat`));let o=await Nn(e,n,r),s;return(n===`vite`||n===`bun-fullstack`)&&(s=o?`append`:`overwrite`),(0,t.shake)({mode:`existing`,path:r,validator:`arktype`,framework:n,layout:a,bunFeatures:n===`bun-fullstack`?e?.bunFeatures??[`serve`]:void 0,language:`ts`,overwriteEnvSchemaFile:!0,installTypeDefinitions:n===`vite`||n===`bun-fullstack`,installSkill:!1,envDtsHandling:s,envKeys:i??void 0,disableCodegen:e?.disableCodegen??!1,wrapNextjsConfig:n===`nextjs`?!0:void 0,hostPreset:e?.hostPreset||`none`})}try{let n=Y(await J.overwriteEnvSchemaFile({hasEnvSchemaFile:e?.hasEnvSchemaFile??!1,defaultPath:r})),o=Y(await J.framework({framework:e?.framework})),s;(o===`nextjs`||o===`nuxt`)&&(s=e?.isStrict?`strict`:e?.isSimple?`simple`:e?.isFlat?`flat`:Y(await J.layout({framework:o})));let c;if(o===`bun-fullstack`){let t=!!e?.bunFeatures?.includes(`build`);c=Y(await J.bunBuild({initialValue:t}))}let l=e?.disableCodegen;o===`nuxt`?l=!0:o===`nextjs`&&l===void 0&&(l=!Y(await J.nextjsCodegen({initialValue:!0,framework:o})));let u;if(o===`nextjs`&&!l){let e=await H({message:`Would you like to wrap your Next.js config with ${K(`withArkEnv`)}?`,initialValue:!0,active:`Yes (Recommended)`,inactive:`No`});if(I(e))throw Xe(`Operation cancelled`),new Pn;u=e}let d=Y(await J.useDefaultPath({defaultEnvPath:r})),f=Y(await J.path({useDefaultPath:d,defaultEnvPath:r})),p=await Nn(e,o,f),m=Y(await J.installTypeDefinitions({framework:o,hasTypeFile:p})),h=Y(await J.envDtsHandling({framework:o,installTypeDefinitions:m,hasTypeFile:p})),g=Y(await J.validator()),_=e?.hostPreset===void 0?Y(await J.hostPreset({initialValue:e?.hostPreset})):e.hostPreset,v=Y(await J.useEnvExample({detectedKeys:i,keysSource:a}));return(0,t.shake)({mode:`existing`,overwriteEnvSchemaFile:n,framework:o,layout:s,path:f,installTypeDefinitions:m,envDtsHandling:h,validator:g,hostPreset:_,bunFeatures:o===`bun-fullstack`?c?[`serve`,`build`]:[`serve`]:void 0,language:`ts`,installSkill:!1,envKeys:v?i??void 0:void 0,disableCodegen:l,wrapNextjsConfig:u})}catch(e){if(e instanceof Pn)return null;throw e}}async function Nn(e,t,n){return await e?.hasTypeFileAtPath?.({framework:t,envPath:n})??e?.hasTypeFile??!1}var Pn=class extends Error{constructor(){super(`Operation cancelled`)}};function Y(e){if(e===null||I(e))throw Xe(`Operation cancelled`),new Pn;return e}var Fn=class{async confirm(e,n=!0,r,i){let a=await H((0,t.shake)({message:e,initialValue:n,active:r,inactive:i}));return I(a)?null:a}async runWizard(e,t=!1){return An(e,t)}};const X={isYes:{long:`--yes`,short:`-y`,kind:`boolean`},isForce:{long:`--force`,short:`-f`,kind:`boolean`},isQuiet:{long:`--quiet`,short:`-q`,kind:`boolean`},isJson:{long:`--json`,short:`-j`,kind:`boolean`},isAgent:{long:`--agent`,short:``,kind:`boolean`},helpRequested:{long:`--help`,short:`-h`,kind:`boolean`},example:{long:`--example`,short:``,kind:`value`},isStrict:{long:`--strict`,short:``,kind:`boolean`},isSimple:{long:`--simple`,short:``,kind:`boolean`},isFlat:{long:`--flat`,short:``,kind:`boolean`},noCodegen:{long:`--no-codegen`,short:``,kind:`boolean`},hostPreset:{long:`--host-preset`,short:`-H`,kind:`value`}},In=new Set(Object.values(X).flatMap(e=>[e.long,e.short].filter(Boolean))),Ln=new Set(Object.values(X).filter(e=>e.kind===`value`).flatMap(e=>[e.long,e.short].filter(Boolean)));var Rn=class{constructor(e,t={}){let n=e.slice(2),r=[],i=!1;for(let e of n){if(i){r.push(e),i=!1;continue}if(Ln.has(e)){r.push(e),i=!0;continue}if(/^-[a-zA-Z]{2,}$/.test(e)){let t=e.slice(1).split(``);for(let e of t)r.push(`-${e}`);Ln.has(`-${t[t.length-1]}`)&&(i=!0)}else r.push(e)}this.args=r,this.command=this.args[0];let a=1,o=[];for(this.validationError=void 0;a<this.args.length;){let e=this.args[a];if(e.startsWith(`-`)){if(!In.has(e)){this.validationError=`Unknown argument: ${e}`;break}if(Ln.has(e))if(a+1<this.args.length&&!this.args[a+1].startsWith(`-`))a+=2;else{this.validationError=`Missing value for option: ${e}`;break}else a+=1}else o.push(e),a+=1}if(!this.validationError){let e=X.hostPreset,t=this.getFlagValue(e.long,e.short);t!==void 0&&!wn(t)&&(this.validationError=`Invalid host preset: ${t}`)}this.validationError||(o.length>1?this.validationError=`Unknown argument: ${o[1]}`:this.name=o[0]),this.logger=t.logger||new st({isQuiet:this.isQuiet,isJson:this.isJson,isYes:this.isYes})}get isAgent(){return this.hasFlag(`isAgent`)}get isYes(){return this.isAgent||this.hasFlag(`isYes`)}get isQuiet(){return this.isAgent||this.hasFlag(`isQuiet`)}get isJson(){return this.isAgent||this.hasFlag(`isJson`)}get isForce(){return this.hasFlag(`isForce`)}get helpRequested(){return this.hasFlag(`helpRequested`)}get example(){let e=X.example;return this.getFlagValue(e.long,e.short)}get isStrict(){return this.hasFlag(`isStrict`)}get isSimple(){return this.hasFlag(`isSimple`)}get isFlat(){return this.hasFlag(`isFlat`)}get noCodegen(){return this.hasFlag(`noCodegen`)}get hostPreset(){let e=X.hostPreset,t=this.getFlagValue(e.long,e.short);if(t!==void 0&&wn(t))return t}hasFlag(e){let t=X[e];return this.args.includes(t.long)||!!t.short&&this.args.includes(t.short)}get initInput(){let e={isYes:this.isYes,isForce:this.isForce,isQuiet:this.isQuiet,isAgent:this.isAgent,isStrict:this.isStrict,isSimple:this.isSimple,isFlat:this.isFlat};return this.example!==void 0&&(e.example=this.example),this.name!==void 0&&(e.name=this.name),this.noCodegen&&(e.noCodegen=!0),this.hostPreset!==void 0&&(e.hostPreset=this.hostPreset),e}getFlagValue(e,t){let n=this.args.findIndex(n=>n===e||n===t);if(n!==-1&&this.args[n+1]&&!this.args[n+1].startsWith(`-`))return this.args[n+1]}},zn=`1.0.0-alpha.8`;function Bn(e,t=2,n=4){let r=Math.max(...e.map(e=>e.left.length),0),i=` `.repeat(t);return e.map(e=>{let t=` `.repeat(r-e.left.length+n);return`${i}${e.left}${t}${e.right}`})}var Vn=class{constructor(e){this.logger=e}async execute(){let e=[{left:`arkenv init [project-name]`,right:`Set up ArkEnv in your project`}],t=[{left:`--yes, -y`,right:`Skip prompts and use defaults (also passed to subprocesses)`},{left:`--force, -f`,right:`Bypass technical requirement checks and dirty git working tree check, then force scaffolding`},{left:`--agent`,right:`Enable non-interactive, machine-readable mode for AI agents. Bypasses all prompts and outputs structured JSON. Macro for --yes --quiet --json`},{left:`--example`,right:`Specify an example name when creating a new project`},{left:`--quiet, -q`,right:`Quiet mode: Suppress output, capture logs on failure`},{left:`--json, -j`,right:`Output structured JSON to stdout`},{left:`--no-codegen`,right:`Disable automatic env.gen.ts code generation for Next.js`},{left:`--host-preset, -H <preset>`,right:`Specify a hosting provider preset (none, vercel, netlify)`},{left:`--help, -h`,right:`Show this help message`}];this.logger.log(`ArkEnv CLI v${zn}`),this.logger.log(`\n${S.default.bold(`Usage:`)}`);for(let t of Bn(e))this.logger.log(t);this.logger.log(`\n${S.default.bold(`Options:`)}`);for(let e of Bn(t))this.logger.log(e)}};async function Hn(e,t){let n=t.targetDir??process.cwd(),r=o.default.join(process.cwd(),`.arkenv-temp`);await e.mkdir(r,!0),t.targetDir&&await e.mkdir(n,!0);try{await e.execute(`git`,[`clone`,`--filter=blob:none`,`--sparse`,t.repository,r]);let i=`examples/${t.example}`;await e.execute(`git`,[`-C`,r,`sparse-checkout`,`set`,i]);let a=o.default.join(r,i),c=await s.default.readdir(a),l=[];for(let t of c){let r=o.default.join(n,t);await e.exists(r)&&l.push(t)}if(l.length>0)throw Error(`Scaffolding into a non-empty directory failed. The following paths already exist: ${l.join(`, `)}`);await Un(a,n);for(let e of[`package-lock.json`,`pnpm-lock.yaml`,`yarn.lock`,`bun.lockb`,`bun.lock`])await s.default.rm(o.default.join(n,e),{force:!0});let u=o.default.join(n,`package.json`);if(await e.exists(u)){let n=await e.readFile(u),r=JSON.parse(n);r.name=t.targetName,delete r.packageManager,await e.writeFile(u,JSON.stringify(r,null,2))}}finally{await s.default.rm(r,{recursive:!0,force:!0})}}async function Un(e,t){let n=await s.default.readdir(e);await Promise.all(n.map(n=>s.default.cp(o.default.join(e,n),o.default.join(t,n),{recursive:!0,force:!1})))}function Wn(e,t){let n=t.length>0;switch(e){case`pnpm`:return[`pnpm`,[n?`add`:`install`,...t]];case`yarn`:return[`yarn`,[n?`add`:`install`,...t]];case`bun`:return[`bun`,[n?`add`:`install`,...t]];default:return[`npm`,[`install`,...t]]}}function Gn(e,t,n){if(t||e.metadata.skillDetected){let t=e.metadata.framework===`nextjs`&&!e.metadata.disableCodegen,r=e.metadata.framework===`nuxt`&&!e.metadata.disableCodegen,i=t&&!n,a=c.default`
117
117
  Inside your AI assistant (e.g. Claude Code), use:
118
118
  ${K(`/arkenv`)} - automatically refine your schema and configure integrations.
119
119
  `;return i?(a+=`
@@ -144,7 +144,7 @@ ${t?(0,n.styleText)(`cyan`,B):``}
144
144
  declare namespace NodeJS {
145
145
  interface ProcessEnv extends ProcessEnvAugmented {}
146
146
  }
147
- `,Z={nextjs:{id:`nextjs`,packageName:`@arkenv/nextjs`,clientPrefix:`NEXT_PUBLIC_`,displayName:`Next.js`,supportsWrapNextjsConfig:!0},nuxt:{id:`nuxt`,packageName:`@arkenv/nuxt`,clientPrefix:`NUXT_PUBLIC_`,displayName:`Nuxt`,supportsWrapNextjsConfig:!1}};function Xn(e){if(e===`nextjs`||e===`nuxt`)return Z[e]}function Zn(e){return e===`nextjs`||e===`nuxt`}const Qn={nextjs:Z.nextjs.clientPrefix,nuxt:Z.nuxt.clientPrefix,vite:`VITE_`,"bun-fullstack":`BUN_PUBLIC_`,vanilla:``};function $n(e){let{typeFilePath:t,typeFileExists:n,envDtsHandling:r,templateContent:i,appendContent:a,overwriteLabel:o,appendLabel:s}=e;return r===`skip`?[]:r===`append`||!r&&n?[{path:t,content:a,action:`append`,label:s}]:[{path:t,content:i,action:n?`overwrite`:`create`,label:o}]}function er(e,t){let n=Xn(e.framework);return{framework:e.framework,clientPrefix:Qn[e.framework],...n?.packageName!==void 0&&{packageName:n.packageName},disableCodegen:e.disableCodegen===!0,...e.layout!==void 0&&{layout:e.layout},...t!==void 0&&{nextjsImportPath:t},...e.hostPreset!==void 0&&{hostPreset:e.hostPreset}}}const tr={NODE_ENV:`development`,PORT:`3000`,DATABASE_URL:`postgres://localhost:5432/mydb`},nr=`generated`;function rr(e){let t={};for(let n of e)t[n]=tr[n]??``;return t}function ir(e,t,n){if(!n)return;let r=((n.compilerOptions||{}).paths||{})[`@/*`];if(!r)return;let i=n.path?o.default.dirname(n.path):e,a=o.default.relative(i,t).replace(/\\/g,`/`);for(let e of r){let t=e.replace(/^\.\//,``).replace(/\*$/,``);if(t===``||a.startsWith(t)){let e=a;return t!==``&&a.startsWith(t)&&(e=a.substring(t.length)),e=e.replace(/^\/+/,``).replace(/\/+$/,``),`@/${e}/env.gen`.replace(/\/+/g,`/`)}}}function ar(e,t,n){if(!(!Zn(n.framework)||n.disableCodegen||!e.tsConfig?.parsed))return ir(e.cwd,t,e.tsConfig.parsed)}function or(e,t){return ar(e,o.default.join(e.targetDir,nr),t)}function sr(e,t,n){return ar(e,o.default.join(t,nr),n)}function Q(e,t,n,r){let i=er(t,r),a=e.getSimpleTemplate(t.envKeys??[],i),o=n.existingFiles.includes(n.targetPath);return!o||t.overwriteEnvSchemaFile!==!1?[{path:n.targetPath,content:a,action:o?`overwrite`:`create`,label:`environment schema`}]:[]}function cr(e,t,n,r){let i=o.default.extname(n.targetPath),a=n.targetPath.slice(0,-i.length),s=o.default.join(a,`internal`,`shared${i}`),c=o.default.join(a,`client${i}`),l=o.default.join(a,`server${i}`),u=er(t,r),d=e.getStrictTemplates(t.envKeys??[],u),f=n.existingFiles.includes(s),p=n.existingFiles.includes(c),m=n.existingFiles.includes(l),h=[];return(!f||t.overwriteEnvSchemaFile!==!1)&&h.push({path:s,content:d.shared,action:f?`overwrite`:`create`,label:`shared environment schema`}),(!p||t.overwriteEnvSchemaFile!==!1)&&h.push({path:c,content:d.client,action:p?`overwrite`:`create`,label:`client environment schema`}),(!m||t.overwriteEnvSchemaFile!==!1)&&h.push({path:l,content:d.server,action:m?`overwrite`:`create`,label:`server environment schema`}),h}const lr={clientPrefix:Qn[`bun-fullstack`],getEnvDefaults(e){return e&&e.length>0?rr(e):{BUN_PUBLIC_API_URL:`https://api.example.com`,NODE_ENV:`development`}},getDependencies(e){return e.bunFeatures?.length?[`@arkenv/bun-plugin`]:[]},requiresArktypePeer(e){return!!e.bunFeatures?.length},bootstrap(e){return(0,t.shake)({framework:`bun-fullstack`,bunFeatures:e.bunFeatures})},getSchemaFiles(e,t,n){return Q(e,t,n)},getTypeDefinitionFiles(e,t){if(!e.bunFeatures?.length||e.installTypeDefinitions===!1)return[];let n=o.default.join(t.targetDir,`bun-env.d.ts`);return $n({typeFilePath:n,typeFileExists:t.existingFiles.includes(n),envDtsHandling:e.envDtsHandling,templateContent:Yn(e.path),appendContent:t.targetPath,overwriteLabel:`bun-fullstack types`,appendLabel:`${e.framework} types`})}};function ur(e){let{id:n,packageName:r,clientPrefix:i,supportsWrapNextjsConfig:a}=e,s=`${i}API_URL`;return{clientPrefix:i,getEnvDefaults(e){return e&&e.length>0?rr(e):{DATABASE_URL:`postgres://localhost:5432/mydb`,[s]:`https://api.example.com`,NODE_ENV:`development`}},getDependencies(){return[r]},requiresArktypePeer(){return!0},bootstrap(e){return(0,t.shake)({framework:n,...a&&{wrapNextjsConfig:e.wrapNextjsConfig!==!1},disableCodegen:e.disableCodegen})},getSchemaFiles(e,t,n){if(t.layout===`strict`){let r=o.default.extname(n.targetPath);return cr(e,t,n,sr(n,n.targetPath.slice(0,-r.length),t))}return Q(e,t,n,or(n,t))},getTypeDefinitionFiles(){return[]}}}const dr=ur(Z.nextjs),fr=ur(Z.nuxt),pr={clientPrefix:Qn.vanilla,getEnvDefaults(e){return e&&e.length>0?rr(e):{PORT:`3000`,NODE_ENV:`development`}},getDependencies(){return[]},requiresArktypePeer(){return!1},bootstrap(){},getSchemaFiles(e,t,n){return Q(e,t,n)},getTypeDefinitionFiles(){return[]}},mr={vite:{clientPrefix:Qn.vite,getEnvDefaults(e){return e&&e.length>0?rr(e):{PORT:`3000`,VITE_API_URL:`https://api.example.com`}},getDependencies(){return[`@arkenv/vite-plugin`]},requiresArktypePeer(){return!0},bootstrap(e){return(0,t.shake)({framework:`vite`})},getSchemaFiles(e,t,n){return Q(e,t,n)},getTypeDefinitionFiles(e,t){return e.installTypeDefinitions===!1?[]:$n({typeFilePath:o.default.join(t.targetDir,`vite-env.d.ts`),typeFileExists:t.existingFiles.includes(o.default.join(t.targetDir,`vite-env.d.ts`)),envDtsHandling:e.envDtsHandling,templateContent:Jn(e.path),appendContent:t.targetPath,overwriteLabel:`vite types`,appendLabel:`${e.framework} types`})}},"bun-fullstack":lr,nextjs:dr,nuxt:fr,vanilla:pr},hr={basic:{HOST:`localhost`,PORT:`3000`,NODE_ENV:`development`},"basic-js":{HOST:`localhost`,PORT:`3000`,NODE_ENV:`development`},"with-bun":{HOST:`localhost`,PORT:`3000`,NODE_ENV:`development`},"with-nextjs":{DATABASE_URL:`postgres://localhost:5432/mydb`,NEXT_PUBLIC_API_URL:`https://api.example.com`,NODE_ENV:`development`},"with-nextjs-strict":{DATABASE_URL:`postgres://localhost:5432/mydb`,NEXT_PUBLIC_API_URL:`https://api.example.com`,NODE_ENV:`development`},"with-nuxt":{DATABASE_URL:`postgres://localhost:5432/mydb`,NUXT_PUBLIC_API_URL:`https://api.example.com`,NODE_ENV:`development`},"with-vite-react":{PORT:`3000`,VITE_MY_VAR:`hello`,VITE_MY_NUMBER:`42`,VITE_MY_BOOLEAN:`true`},"with-bun-react":{BUN_PUBLIC_API_URL:`https://api.example.com`,BUN_PUBLIC_DEBUG:`true`,NODE_ENV:`development`},"with-zod":{HOST:`localhost`,PORT:`3000`,NODE_ENV:`development`},"with-standard-schema":{HOST:`localhost`,PORT:`3000`,NODE_ENV:`development`}};function gr(e,t){return hr[e]??t()}function _r(e){switch(e){case`pnpm`:return[`pnpm`,`dlx`];case`yarn`:return[`yarn`,`dlx`];case`bun`:return[`bunx`];default:return[`npx`]}}function vr(e,t,n,r){let i=q(r??`none`,n);for(let a of i)n&&a.startsWith(n)?e.clientFields.push(`\t\t${t.formatCodegenField(a,`client`,n,r)}`):e.serverFields.push(`\t\t${t.formatCodegenField(a,`server`,n,r)}`)}function yr(e){let t=[];for(let n of e){let e=n.trim().match(/^([a-zA-Z0-9_]+)\s*:/);e&&t.push(e[1])}return t}function br(e,t,n,r=[]){let i=[],a=new Set,o=e=>{a.has(e)||(a.add(e),i.push(`\t\t${e}: process.env.${e},`))};if(e&&e.length>0){for(let n of e)(n.startsWith(t)||n===`NODE_ENV`||r.includes(n))&&o(n);return i}o(`${t}API_URL`),o(`NODE_ENV`);for(let e of yr(n))o(e);for(let e of r)o(e);return i}function xr(e){let{envKeys:t,dialect:n,config:r,importPath:i,disableCodegen:a,layout:o,hostPreset:s}=e,{clientPrefix:c}=r,l=[],u=[],d=[];if(t&&t.length>0)for(let e of t)e.startsWith(c)?u.push(`\t\t${n.formatCodegenField(e,`client`,c,s)}`):e===`NODE_ENV`?d.push(`\t\t${n.formatCodegenField(e,`shared`,c,s)}`):l.push(`\t\t${n.formatCodegenField(e,`server`,c,s)}`);else{let e=n.getDefaultCodegenFields(c);l.push(...e.serverFields),u.push(...e.clientFields),d.push(...e.sharedFields),vr({serverFields:l,clientFields:u},n,c,s)}return o!==`simple`&&o!==`strict`?Sr({serverFields:l,clientFields:u,sharedFields:d,envKeys:t,dialect:n,config:r,nextjsImportPath:i,disableCodegen:a}):Cr({serverFields:l,clientFields:u,sharedFields:d,envKeys:t,dialect:n,config:r,nextjsImportPath:i,disableCodegen:a,layout:o})}function Sr(e){let{serverFields:t,clientFields:n,sharedFields:r,envKeys:i,dialect:a,config:o,nextjsImportPath:s,disableCodegen:c}=e,{clientPrefix:l,packageName:u,displayName:d}=o,f=o.id,p=a.extraImport,m=[...t,...n,...r].map(e=>e.replace(/^\t\t/,` `)),h=[];for(let e of r){let t=e.trim().match(/^([a-zA-Z0-9_]+)\s*:/);if(t){let e=t[1];e!==`NODE_ENV`&&h.push(e)}}let g=[];if(h.length>0&&g.push(`\texposeToClient: [${h.map(e=>`"${e}"`).join(`, `)}]`),c&&f===`nextjs`){let e=br(i,l,n,h);g.push(`\truntimeEnv: {\n${e.join(`
147
+ `,Z={nextjs:{id:`nextjs`,packageName:`@arkenv/nextjs`,clientPrefix:`NEXT_PUBLIC_`,displayName:`Next.js`,supportsWrapNextjsConfig:!0},nuxt:{id:`nuxt`,packageName:`@arkenv/nuxt`,clientPrefix:`NUXT_PUBLIC_`,displayName:`Nuxt`,supportsWrapNextjsConfig:!1}};function Xn(e){if(e===`nextjs`||e===`nuxt`)return Z[e]}function Zn(e){return e===`nextjs`||e===`nuxt`}const Qn={nextjs:Z.nextjs.clientPrefix,nuxt:Z.nuxt.clientPrefix,vite:`VITE_`,"bun-fullstack":`BUN_PUBLIC_`,vanilla:``};function $n(e){let{typeFilePath:t,typeFileExists:n,envDtsHandling:r,templateContent:i,appendContent:a,overwriteLabel:o,appendLabel:s}=e;return r===`skip`?[]:r===`append`||!r&&n?[{path:t,content:a,action:`append`,label:s}]:[{path:t,content:i,action:n?`overwrite`:`create`,label:o}]}function er(e,t){let n=Xn(e.framework);return{framework:e.framework,clientPrefix:Qn[e.framework],...n?.packageName!==void 0&&{packageName:n.packageName},disableCodegen:e.disableCodegen===!0,...e.layout!==void 0&&{layout:e.layout},...t!==void 0&&{nextjsImportPath:t},...e.hostPreset!==void 0&&{hostPreset:e.hostPreset}}}const tr={NODE_ENV:`development`,PORT:`3000`,DATABASE_URL:`postgres://localhost:5432/mydb`},nr=`generated`;function rr(e){let t={};for(let n of e)t[n]=tr[n]??``;return t}function ir(e,t,n){if(!n)return;let r=((n.compilerOptions||{}).paths||{})[`@/*`];if(!r)return;let i=n.path?o.default.dirname(n.path):e,a=o.default.relative(i,t).replace(/\\/g,`/`);for(let e of r){let t=e.replace(/^\.\//,``).replace(/\*$/,``);if(t===``||a.startsWith(t)){let e=a;return t!==``&&a.startsWith(t)&&(e=a.substring(t.length)),e=e.replace(/^\/+/,``).replace(/\/+$/,``),`@/${e}/env.gen`.replace(/\/+/g,`/`)}}}function ar(e,t,n){if(!(!Zn(n.framework)||n.disableCodegen||!e.tsConfig?.parsed))return ir(e.cwd,t,e.tsConfig.parsed)}function or(e,t){return ar(e,o.default.join(e.targetDir,nr),t)}function sr(e,t,n){return ar(e,o.default.join(t,nr),n)}function Q(e,t,n,r){let i=er(t,r),a=e.getSimpleTemplate(t.envKeys??[],i),o=n.existingFiles.includes(n.targetPath);return!o||t.overwriteEnvSchemaFile!==!1?[{path:n.targetPath,content:a,action:o?`overwrite`:`create`,label:`environment schema`}]:[]}function cr(e,t,n,r){let i=o.default.extname(n.targetPath),a=n.targetPath.slice(0,-i.length),s=o.default.join(a,`internal`,`shared${i}`),c=o.default.join(a,`client${i}`),l=o.default.join(a,`server${i}`),u=er(t,r),d=e.getStrictTemplates(t.envKeys??[],u),f=n.existingFiles.includes(s),p=n.existingFiles.includes(c),m=n.existingFiles.includes(l),h=[];return(!f||t.overwriteEnvSchemaFile!==!1)&&h.push({path:s,content:d.shared,action:f?`overwrite`:`create`,label:`shared environment schema`}),(!p||t.overwriteEnvSchemaFile!==!1)&&h.push({path:c,content:d.client,action:p?`overwrite`:`create`,label:`client environment schema`}),(!m||t.overwriteEnvSchemaFile!==!1)&&h.push({path:l,content:d.server,action:m?`overwrite`:`create`,label:`server environment schema`}),h}const lr={clientPrefix:Qn[`bun-fullstack`],getEnvDefaults(e){return e&&e.length>0?rr(e):{BUN_PUBLIC_API_URL:`https://api.example.com`,NODE_ENV:`development`}},getDependencies(e){return e.bunFeatures?.length?[`@arkenv/bun-plugin`]:[]},requiresArktypePeer(e){return!!e.bunFeatures?.length},bootstrap(e){return(0,t.shake)({framework:`bun-fullstack`,bunFeatures:e.bunFeatures})},getSchemaFiles(e,t,n){return Q(e,t,n)},getTypeDefinitionFiles(e,t){if(!e.bunFeatures?.length||e.installTypeDefinitions===!1)return[];let n=o.default.join(t.targetDir,`bun-env.d.ts`);return $n({typeFilePath:n,typeFileExists:t.existingFiles.includes(n),envDtsHandling:e.envDtsHandling,templateContent:Yn(e.path),appendContent:t.targetPath,overwriteLabel:`bun-fullstack types`,appendLabel:`${e.framework} types`})}};function ur(e){let{id:n,packageName:r,clientPrefix:i,supportsWrapNextjsConfig:a}=e,s=`${i}API_URL`;return{clientPrefix:i,getEnvDefaults(e){return e&&e.length>0?rr(e):{DATABASE_URL:`postgres://localhost:5432/mydb`,[s]:`https://api.example.com`,NODE_ENV:`development`}},getDependencies(){return[r]},requiresArktypePeer(){return!0},bootstrap(e){return(0,t.shake)({framework:n,...a&&{wrapNextjsConfig:e.wrapNextjsConfig!==!1},disableCodegen:e.disableCodegen})},getSchemaFiles(e,t,n){if(t.layout===`strict`){let r=o.default.extname(n.targetPath);return cr(e,t,n,sr(n,n.targetPath.slice(0,-r.length),t))}return Q(e,t,n,or(n,t))},getTypeDefinitionFiles(){return[]}}}const dr=ur(Z.nextjs),fr=ur(Z.nuxt),pr={clientPrefix:Qn.vanilla,getEnvDefaults(e){return e&&e.length>0?rr(e):{PORT:`3000`,NODE_ENV:`development`}},getDependencies(){return[]},requiresArktypePeer(){return!1},bootstrap(){},getSchemaFiles(e,t,n){return Q(e,t,n)},getTypeDefinitionFiles(){return[]}},mr={vite:{clientPrefix:Qn.vite,getEnvDefaults(e){return e&&e.length>0?rr(e):{PORT:`3000`,VITE_API_URL:`https://api.example.com`}},getDependencies(){return[`@arkenv/vite-plugin`]},requiresArktypePeer(){return!0},bootstrap(e){return(0,t.shake)({framework:`vite`})},getSchemaFiles(e,t,n){return Q(e,t,n)},getTypeDefinitionFiles(e,t){return e.installTypeDefinitions===!1?[]:$n({typeFilePath:o.default.join(t.targetDir,`vite-env.d.ts`),typeFileExists:t.existingFiles.includes(o.default.join(t.targetDir,`vite-env.d.ts`)),envDtsHandling:e.envDtsHandling,templateContent:Jn(e.path),appendContent:t.targetPath,overwriteLabel:`vite types`,appendLabel:`${e.framework} types`})}},"bun-fullstack":lr,nextjs:dr,nuxt:fr,vanilla:pr},hr={basic:{HOST:`localhost`,PORT:`3000`,NODE_ENV:`development`},"basic-js":{HOST:`localhost`,PORT:`3000`,NODE_ENV:`development`},"with-bun":{HOST:`localhost`,PORT:`3000`,NODE_ENV:`development`},"with-nextjs":{DATABASE_URL:`postgres://localhost:5432/mydb`,NEXT_PUBLIC_API_URL:`https://api.example.com`,NODE_ENV:`development`},"with-nextjs-strict":{DATABASE_URL:`postgres://localhost:5432/mydb`,NEXT_PUBLIC_API_URL:`https://api.example.com`,NODE_ENV:`development`},"with-nuxt":{DATABASE_URL:`postgres://localhost:5432/mydb`,NUXT_PUBLIC_API_URL:`https://api.example.com`,NODE_ENV:`development`},"with-vite-react":{PORT:`3000`,VITE_MY_VAR:`hello`,VITE_MY_NUMBER:`42`,VITE_MY_BOOLEAN:`true`},"with-bun-react":{BUN_PUBLIC_API_URL:`https://api.example.com`,BUN_PUBLIC_DEBUG:`true`,NODE_ENV:`development`},"with-zod":{HOST:`localhost`,PORT:`3000`,NODE_ENV:`development`},"with-valibot":{HOST:`localhost`,PORT:`3000`,NODE_ENV:`development`},"with-standard-schema":{HOST:`localhost`,PORT:`3000`,NODE_ENV:`development`}};function gr(e,t){return hr[e]??t()}function _r(e){switch(e){case`pnpm`:return[`pnpm`,`dlx`];case`yarn`:return[`yarn`,`dlx`];case`bun`:return[`bunx`];default:return[`npx`]}}function vr(e,t,n,r){let i=q(r??`none`,n);for(let a of i)n&&a.startsWith(n)?e.clientFields.push(`\t\t${t.formatCodegenField(a,`client`,n,r)}`):e.serverFields.push(`\t\t${t.formatCodegenField(a,`server`,n,r)}`)}function yr(e){let t=[];for(let n of e){let e=n.trim().match(/^([a-zA-Z0-9_]+)\s*:/);e&&t.push(e[1])}return t}function br(e,t,n,r=[]){let i=[],a=new Set,o=e=>{a.has(e)||(a.add(e),i.push(`\t\t${e}: process.env.${e},`))};if(e&&e.length>0){for(let n of e)(n.startsWith(t)||n===`NODE_ENV`||r.includes(n))&&o(n);return i}o(`${t}API_URL`),o(`NODE_ENV`);for(let e of yr(n))o(e);for(let e of r)o(e);return i}function xr(e){let{envKeys:t,dialect:n,config:r,importPath:i,disableCodegen:a,layout:o,hostPreset:s}=e,{clientPrefix:c}=r,l=[],u=[],d=[];if(t&&t.length>0)for(let e of t)e.startsWith(c)?u.push(`\t\t${n.formatCodegenField(e,`client`,c,s)}`):e===`NODE_ENV`?d.push(`\t\t${n.formatCodegenField(e,`shared`,c,s)}`):l.push(`\t\t${n.formatCodegenField(e,`server`,c,s)}`);else{let e=n.getDefaultCodegenFields(c);l.push(...e.serverFields),u.push(...e.clientFields),d.push(...e.sharedFields),vr({serverFields:l,clientFields:u},n,c,s)}return o!==`simple`&&o!==`strict`?Sr({serverFields:l,clientFields:u,sharedFields:d,envKeys:t,dialect:n,config:r,nextjsImportPath:i,disableCodegen:a}):Cr({serverFields:l,clientFields:u,sharedFields:d,envKeys:t,dialect:n,config:r,nextjsImportPath:i,disableCodegen:a,layout:o})}function Sr(e){let{serverFields:t,clientFields:n,sharedFields:r,envKeys:i,dialect:a,config:o,nextjsImportPath:s,disableCodegen:c}=e,{clientPrefix:l,packageName:u,displayName:d}=o,f=o.id,p=a.extraImport,m=[...t,...n,...r].map(e=>e.replace(/^\t\t/,` `)),h=[];for(let e of r){let t=e.trim().match(/^([a-zA-Z0-9_]+)\s*:/);if(t){let e=t[1];e!==`NODE_ENV`&&h.push(e)}}let g=[];if(h.length>0&&g.push(`\texposeToClient: [${h.map(e=>`"${e}"`).join(`, `)}]`),c&&f===`nextjs`){let e=br(i,l,n,h);g.push(`\truntimeEnv: {\n${e.join(`
148
148
  `)}\n\t}`)}let _=g.length>0?`, {\n${g.join(`,
149
149
  `)}\n}`:``;return`${[`import arkenv from "${f===`nuxt`||c?u:s||`./generated/env.gen`}";`,...p?[p]:[]].join(`
150
150
  `)}
@@ -220,7 +220,11 @@ export const env = arkenv(
220
220
  {
221
221
  extends: [SharedSchema]${u}
222
222
  },
223
- );`,server:`import arkenv from "${r}/server";
223
+ );`,server:n.framework===`nuxt`?`import arkenv from "${r}/server";
224
+ ${m}
225
+ export const env = arkenv(
226
+ ${p},
227
+ );`:`import arkenv from "${r}/server";
224
228
  ${m}import { env as clientEnv } from "./client";
225
229
 
226
230
  export const env = arkenv(
@@ -280,4 +284,4 @@ import { z } from "zod";`},zr={arktype:Ir,zod:Rr,valibot:Lr};function Br(e){retu
280
284
  `)?`${r.gitignoreContent}${e.trim()}\n`:`${r.gitignoreContent}\n${e.trim()}\n`;t.files.push({path:a,content:o,action:`overwrite`,label:`.gitignore update`})}}else s||t.files.push({path:a,content:`# Environment variables
281
285
  .env
282
286
  .env.local
283
- `,action:`create`,label:`.gitignore file`})}function Jr(e){let{mode:n,options:r,packageManager:i}=e,a=r.name&&r.name!==`.`?o.default.basename(r.name):void 0;return(0,t.shake)({displayPath:``,framework:r.framework,validator:r.validator,packageManager:i,importPath:``,mode:n,example:r.example,name:a,layout:r.layout,skillDetected:r.skillDetected,disableCodegen:r.disableCodegen})}function Yr(e,t){e.options.installSkill&&(t.skill={dlxCommand:_r(e.packageManager),packageName:`yamcodes/arkenv`,isYes:e.isYes})}function Xr(e){let{options:t,packageManager:n,cwd:r}=e;if(!t.example)throw Error(`New project scaffolding requires an example.`);let i=t.name&&t.name!==`.`?o.default.join(r,t.name):void 0,a=t.name&&t.name!==`.`?o.default.basename(t.name):o.default.basename(r),s={files:[],cwd:r,metadata:Jr(e),clone:{repository:`https://github.com/yamcodes/arkenv.git`,example:t.example,targetName:a,...i!==void 0&&{targetDir:i}},install:{packageManager:n,dependencies:[],...i!==void 0&&{cwd:i}}};Yr(e,s);let c=Gr(gr(t.example,()=>mr[t.framework].getEnvDefaults())),l=i??r;return s.files.push({path:o.default.join(l,`.env`),content:c,action:`create`,label:`local environment variables`},{path:o.default.join(l,`.env.example`),content:c,action:`create`,label:`environment variables template`}),s.metadata.displayPath=`./src/env.ts`,s.metadata.importPath=`./src/env`,s}function Zr(e){let{options:t,packageManager:n,tsConfig:r,shouldUpdateTsConfig:i,cwd:a,existingFiles:s}=e,c=mr[t.framework],l=Vr[t.validator],u=o.default.resolve(a,t.path),d=o.default.dirname(u),f={files:[],cwd:a,metadata:Jr(e)},p={targetPath:u,targetDir:d,cwd:a,existingFiles:s,overwriteEnvSchemaFile:t.overwriteEnvSchemaFile,installTypeDefinitions:t.installTypeDefinitions,envDtsHandling:t.envDtsHandling,path:t.path,tsConfig:r};f.files.push(...c.getSchemaFiles(l,t,p)),Kr(e,f),qr(e,f);let m=[`arkenv`,t.validator,...c.getDependencies(t)];c.requiresArktypePeer(t)&&!m.includes(`arktype`)&&m.push(`arktype`),f.install={packageManager:n,dependencies:m},i&&r.file&&(f.tsConfig={path:o.default.resolve(a,r.file),action:`strict`}),f.files.push(...c.getTypeDefinitionFiles(t,p));let h=c.bootstrap(t);h&&(f.bootstrap=h),Yr(e,f);let g=o.default.relative(a,u).replace(/\\/g,`/`),_=g.startsWith(`.`)?g:`./${g}`,v=_.replace(/\.(ts|js|tsx|jsx)$/,``);return f.metadata.displayPath=_,f.metadata.importPath=v,f.bootstrap&&(f.bootstrap.importPath=v),f}var Qr=class{async fetchRegistry(){try{let e=await fetch(`https://raw.githubusercontent.com/yamcodes/arkenv/main/examples/registry.json`);if(!e.ok)throw Error(`Failed to fetch registry: ${e.statusText}`);return await e.json()}catch{return{examples:[{id:`basic`,name:`Basic`,description:`A minimal ArkEnv setup in Node.js`,framework:`vanilla`},{id:`with-nextjs`,name:`Next.js`,description:`Minimal Next.js project with ArkType`,framework:`nextjs`},{id:`with-vite-react`,name:`React + Vite`,framework:`vite`},{id:`with-bun`,name:`Bun (Vanilla)`,description:`Minimal Bun project with ArkType`,framework:`vanilla`},{id:`with-bun-react`,name:`React + Bun fullstack dev server`,framework:`bun-fullstack`},{id:`with-zod`,name:`Zod`,description:`ArkEnv with Zod in Node.js`,framework:`vanilla`}]}}}},$r=class{constructor(e,t,n,r,i=new Qr){this.logger=e,this.workspace=t,this.prompt=n,this.scanner=r,this.registry=i}async execute(e){let t=await this.collect(e);if(!t)return!1;let n=Hr(t),r=new qn(this.workspace,this.logger);try{await r.execute(n)}catch(e){this.logger.fatal(`Scaffolding failed.`,e)}return!0}async collect(e){this.logger.interactiveStdout(!0);try{let t=e.name;t&&o.default.resolve(process.cwd(),t)===process.cwd()&&(t=`.`);let n={...e,...t!==void 0&&{name:t}},r=t&&t!==`.`?o.default.resolve(process.cwd(),t):process.cwd(),i=await this.workspace.exists(r),a=i?await this.scanner.hasPackageJson(r):!1,s=i?await this.scanner.isEmptyDirectory(r):!0;return n.example===void 0?a?await this.collectExistingProject(n,r):s||n.isForce?await this.collectNewProject(n,s):(this.logger.error(`Directory is not empty and no ${K(`package.json`)} was found.`),this.logger.info(`To scaffold a new project, run ${K(`arkenv init`)} in an empty directory or use ${K(`--force`)} to proceed anyway.`),this.logger.refuse({code:C.NON_EMPTY_DIR,message:`Directory is not empty and no package.json was found.`,retryWith:[`--force`]}),null):await this.collectNewProject(n,s)}finally{this.logger.interactiveStdout(!1)}}async collectExistingProject(e,n){let{isYes:r,isForce:i,isQuiet:a,isAgent:s}=e,c=await this.scanner.checkRequirements(n),l=c.filter(e=>e.status===`fail`),u=c.filter(e=>e.status===`warn`);for(let e of u)this.logger.warn(`${e.requirement}: ${e.message}`);if(l.length>0)if(i){this.logger.warn(`Technical requirements not met, but continuing due to --force flag.`);for(let e of l)this.logger.warn(`${e.requirement}: ${e.message}`)}else{this.logger.error(`Technical requirements not met:`);for(let e of l)this.logger.error(`- ${e.requirement}: ${e.message}${e.current?` (Current: ${e.current}, Expected: ${e.expected})`:``}`);return this.logger.info(`Use --force to bypass these checks.`),this.logger.refuse({code:C.REQUIREMENTS_NOT_MET,message:`Technical requirements not met.`,retryWith:[`--force`],details:{requirements:l.map(e=>(0,t.shake)({requirement:e.requirement,message:e.message,current:e.current,expected:e.expected}))}}),null}let d=await this.scanner.checkGitStatus(n);if(d.status===`dirty`)if(i)this.logger.warn(`Git working tree is not clean, but continuing due to --force flag.`);else return this.logger.error(`Git working tree is not clean. Commit or stash your changes (use 'git stash -u' for untracked files) before running arkenv init.`),this.logger.info(`Use --force to bypass this check.`),this.logger.refuse({code:C.GIT_TREE_DIRTY,message:`Git working tree is not clean.`,retryWith:[`--force`]}),null;d.status===`unknown`&&this.logger.warn(`Git working tree status could not be determined. Proceeding with caution.`);let f=!1,p=await this.scanner.checkTsConfig(n);if(p.status===`not_strict`)if(r)f=!0;else{this.logger.warn(`TypeScript strict mode is not enabled in your ${K(p.file)}.`);let e=await this.prompt.confirm(`ArkEnv requires ${K(`strict`)} mode in your ${K(p.file)}. Would you like to enable it now?`,!0,`Yes (Recommended)`);if(e===null)return null;if(!e)return this.logger.cancel(`Operation cancelled.`),null;f=!0}let m=await this.scanner.detectFramework(n,p.parsed);if(e.isSimple&&m===`nextjs`)return this.logger.error(`❌ Error: The --simple layout is deprecated and no longer supported by the CLI. Arkenv now exclusively uses the Flat Layout. Run npx arkenv init without this flag.`),null;let h=m===`bun-fullstack`?await this.scanner.detectBunFeatures(n,p.parsed):void 0,g=await this.scanner.suggestDefaultEnvPath(n,p.parsed),_=o.default.resolve(n,g),v=await this.scanner.getEnvExampleKeys(n,p.parsed,_),y=await(async()=>{if(e.isStrict){let e=o.default.extname(_),t=_.slice(0,-e.length),n=[o.default.join(t,`internal`,`shared${e}`),o.default.join(t,`client${e}`),o.default.join(t,`server${e}`)];if((await Promise.all(n.map(e=>this.workspace.exists(e)))).some(Boolean))return!0}return this.workspace.exists(_)})(),b=async({framework:e,envPath:t})=>{if(e!==`vite`&&e!==`bun-fullstack`)return!1;let r=e===`vite`?`vite-env.d.ts`:`bun-env.d.ts`,i=o.default.resolve(n,t),a=o.default.dirname(i),s=o.default.join(a,r);return this.workspace.exists(s)},x=await b({framework:m,envPath:g}),S=await this.prompt.runWizard((0,t.shake)({mode:`existing`,framework:m,bunFeatures:h,defaultEnvPath:g,tsConfig:p.parsed??null,envKeys:v?.keys,envKeysSource:v?.source,hasTypeFileAtPath:b,hasTypeFile:x,hasEnvSchemaFile:y,isStrict:e.isStrict,isSimple:e.isSimple,isFlat:e.isFlat,disableCodegen:e.noCodegen,hostPreset:e.hostPreset}),r);if(S===null)return null;let ee=await this.scanner.hasSkill(n);if(ee&&(S.skillDetected=!0,!a&&!s&&this.logger.info(`ArkEnv agent skill detected.`)),ee)S.installSkill=!1;else if(s)S.installSkill=!1;else if(r)S.installSkill=!0;else{let e=await this.prompt.confirm(`Would you like to install the ArkEnv agent skill?`,!0,`Yes (Recommended)`);if(e===null)return null;S.installSkill=e}let w=o.default.resolve(n,S.path);if(S.overwriteEnvSchemaFile===void 0&&(S.layout===`strict`?await(async()=>{let e=o.default.extname(w),t=w.slice(0,-e.length);return(await Promise.all([this.workspace.exists(o.default.join(t,`internal`,`shared${e}`)),this.workspace.exists(o.default.join(t,`client${e}`)),this.workspace.exists(o.default.join(t,`server${e}`))])).some(Boolean)})():await this.workspace.exists(w))){let e=S.layout===`strict`?`Strict layout files (client, server, internal/shared)`:o.default.basename(w),t=await this.prompt.confirm(`${e} already exist. Overwrite?`,!1);if(t===null)return null;if(!t)return this.logger.cancel(`Operation cancelled.`),null;S.overwriteEnvSchemaFile=t}let T=await this.scanner.detectPackageManager(n,p.parsed),E=o.default.extname(w),D=w.slice(0,-E.length),te=S.layout===`strict`?[o.default.join(D,`internal`,`shared${E}`),o.default.join(D,`client${E}`),o.default.join(D,`server${E}`)]:[w],O=[];for(let e of te)await this.workspace.exists(e)&&O.push(e);let k;if(S.framework===`vite`?k=`vite-env.d.ts`:S.framework===`bun-fullstack`&&(k=`bun-env.d.ts`),k){let e=o.default.dirname(w),t=o.default.join(e,k);await this.workspace.exists(t)&&O.push(t)}let A=o.default.join(n,`.env`),j=o.default.join(n,`.env.example`);await this.workspace.exists(A)&&(O.push(A),S.envContent=await this.workspace.readFile(A)),await this.workspace.exists(j)&&(O.push(j),S.envExampleContent=await this.workspace.readFile(j));let ne=o.default.join(n,`.gitignore`);return await this.workspace.exists(ne)&&(O.push(ne),S.gitignoreContent=await this.workspace.readFile(ne)),(0,t.shake)({mode:`existing`,cwd:n,options:S,detectedFramework:m,detectedBunFeatures:h,packageManager:T,tsConfig:p,shouldUpdateTsConfig:f,existingFiles:O,isYes:r})}async collectNewProject(e,n=!0){let{isYes:r,example:i,name:a,isForce:o}=e,s=await this.registry.fetchRegistry(),c=await this.prompt.runWizard((0,t.shake)({mode:`new`,examples:s.examples,example:i,name:a}),r);if(c===null)return null;if(c.name===`.`&&!n&&!o)return this.logger.error(`Cannot scaffold into ${K(`.`)} because the current directory is not empty.`),this.logger.info(`Run ${K(`arkenv init`)} in an empty directory or choose a sub-directory name instead.`),this.logger.refuse({code:C.NON_EMPTY_DIR,message:`Cannot scaffold into the current directory because it is not empty.`,retryWith:[`--force`]}),null;let l=this.detectPackageManager();return(0,t.shake)({mode:`new`,cwd:process.cwd(),options:c,detectedFramework:c.framework,packageManager:l,tsConfig:{status:`not_found`},shouldUpdateTsConfig:!1,existingFiles:[],isYes:r})}detectPackageManager(){let e=process.env.npm_config_user_agent||``;return e.includes(`pnpm`)?`pnpm`:e.includes(`yarn`)?`yarn`:e.includes(`bun`)?`bun`:`npm`}};function ei(e){let t=new Rn(e),n=t.logger,r=new fn(t.isQuiet,n.stdio,n),i=new Fn;return{cli:t,logger:n,workspace:r,prompt:i,initUseCase:new $r(n,r,i,new Yt(n)),helpUseCase:new Vn(n)}}if(typeof require<`u`&&require.main!==module)throw Error(`🚨 ${b(`You imported the 'arkenv' package as a library. Starting with v1.0.0, the 'arkenv' package is exclusively the interactive CLI. If you want to validate environment variables in your code, please install and import '@arkenv/core' instead.`)}`);const ti=new st({isQuiet:!1,isJson:!1});let ni,ri=!1;async function ii(){if(process.env.INIT_CWD)try{process.chdir(process.env.INIT_CWD)}catch{}let{cli:e,logger:n,initUseCase:r,helpUseCase:i}=ei(process.argv);ni=n,ai(n),e.validationError&&(n.error(e.validationError),await i.execute(),await n.flush(),process.exit(1)),e.helpRequested&&(await i.execute(),await n.flush(),process.exit(0)),e.command!==`init`&&(e.command?n.error(`Unknown command: ${e.command}`):n.error(`Missing command.`),await i.execute(),await n.flush(),process.exit(1));try{await r.execute((0,t.shake)(e.initInput))||(await n.flush(),process.exit(1))}catch(e){try{n.fatal(`An unexpected error occurred`,e)}catch{}await n.flush(),process.exit(1)}}function ai(e){let t=async t=>{ri&&process.exit(t),ri=!0,setTimeout(()=>{process.exit(t)},2e3).unref(),e.interactiveStdout&&e.interactiveStdout(!1);try{e.cancel(`Operation cancelled.`),await e.flush()}catch(t){e.error&&e.error(`Logger failed during shutdown`,t)}finally{process.exit(t)}};process.on(`SIGINT`,()=>t(130)),process.on(`SIGTERM`,()=>t(143))}ii(),process.on(`unhandledRejection`,async e=>{let t=ni??ti;try{t.fatal(`Unhandled rejection`,e)}catch{}await t.flush(),process.exit(1)}),process.on(`uncaughtException`,async e=>{let t=ni??ti;try{t.fatal(`Uncaught exception`,e)}catch{}await t.flush(),process.exit(1)});
287
+ `,action:`create`,label:`.gitignore file`})}function Jr(e){let{mode:n,options:r,packageManager:i}=e,a=r.name&&r.name!==`.`?o.default.basename(r.name):void 0;return(0,t.shake)({displayPath:``,framework:r.framework,validator:r.validator,packageManager:i,importPath:``,mode:n,example:r.example,name:a,layout:r.layout,skillDetected:r.skillDetected,disableCodegen:r.disableCodegen})}function Yr(e,t){e.options.installSkill&&(t.skill={dlxCommand:_r(e.packageManager),packageName:`yamcodes/arkenv`,isYes:e.isYes})}function Xr(e){let{options:t,packageManager:n,cwd:r}=e;if(!t.example)throw Error(`New project scaffolding requires an example.`);let i=t.name&&t.name!==`.`?o.default.join(r,t.name):void 0,a=t.name&&t.name!==`.`?o.default.basename(t.name):o.default.basename(r),s={files:[],cwd:r,metadata:Jr(e),clone:{repository:`https://github.com/yamcodes/arkenv.git`,example:t.example,targetName:a,...i!==void 0&&{targetDir:i}},install:{packageManager:n,dependencies:[],...i!==void 0&&{cwd:i}}};Yr(e,s);let c=Gr(gr(t.example,()=>mr[t.framework].getEnvDefaults())),l=i??r;return s.files.push({path:o.default.join(l,`.env`),content:c,action:`create`,label:`local environment variables`},{path:o.default.join(l,`.env.example`),content:c,action:`create`,label:`environment variables template`}),s.metadata.displayPath=`./src/env.ts`,s.metadata.importPath=`./src/env`,s}function Zr(e){let{options:t,packageManager:n,tsConfig:r,shouldUpdateTsConfig:i,cwd:a,existingFiles:s}=e,c=mr[t.framework],l=Vr[t.validator],u=o.default.resolve(a,t.path),d=o.default.dirname(u),f={files:[],cwd:a,metadata:Jr(e)},p={targetPath:u,targetDir:d,cwd:a,existingFiles:s,overwriteEnvSchemaFile:t.overwriteEnvSchemaFile,installTypeDefinitions:t.installTypeDefinitions,envDtsHandling:t.envDtsHandling,path:t.path,tsConfig:r};f.files.push(...c.getSchemaFiles(l,t,p)),Kr(e,f),qr(e,f);let m=[`arkenv`,t.validator,...c.getDependencies(t)];c.requiresArktypePeer(t)&&!m.includes(`arktype`)&&m.push(`arktype`),f.install={packageManager:n,dependencies:m},i&&r.file&&(f.tsConfig={path:o.default.resolve(a,r.file),action:`strict`}),f.files.push(...c.getTypeDefinitionFiles(t,p));let h=c.bootstrap(t);h&&(f.bootstrap=h),Yr(e,f);let g=o.default.relative(a,u).replace(/\\/g,`/`),_=g.startsWith(`.`)?g:`./${g}`,v=_.replace(/\.(ts|js|tsx|jsx)$/,``);return f.metadata.displayPath=_,f.metadata.importPath=v,f.bootstrap&&(f.bootstrap.importPath=v),f}var Qr=class{async fetchRegistry(){try{let e=await fetch(`https://raw.githubusercontent.com/yamcodes/arkenv/main/examples/registry.json`);if(!e.ok)throw Error(`Failed to fetch registry: ${e.statusText}`);return await e.json()}catch{return{examples:[{id:`basic`,name:`Basic`,description:`A minimal ArkEnv setup in Node.js`,framework:`vanilla`},{id:`with-nextjs`,name:`Next.js`,description:`Minimal Next.js project with ArkType`,framework:`nextjs`},{id:`with-vite-react`,name:`React + Vite`,framework:`vite`},{id:`with-bun`,name:`Bun (Vanilla)`,description:`Minimal Bun project with ArkType`,framework:`vanilla`},{id:`with-bun-react`,name:`React + Bun fullstack dev server`,framework:`bun-fullstack`},{id:`with-zod`,name:`Zod`,description:`ArkEnv with Zod in Node.js`,framework:`vanilla`},{id:`with-valibot`,name:`Valibot`,description:`ArkEnv with Valibot in Node.js`,framework:`vanilla`}]}}}},$r=class{constructor(e,t,n,r,i=new Qr){this.logger=e,this.workspace=t,this.prompt=n,this.scanner=r,this.registry=i}async execute(e){let t=await this.collect(e);if(!t)return!1;let n=Hr(t),r=new qn(this.workspace,this.logger);try{await r.execute(n)}catch(e){this.logger.fatal(`Scaffolding failed.`,e)}return!0}async collect(e){this.logger.interactiveStdout(!0);try{let t=e.name;t&&o.default.resolve(process.cwd(),t)===process.cwd()&&(t=`.`);let n={...e,...t!==void 0&&{name:t}},r=t&&t!==`.`?o.default.resolve(process.cwd(),t):process.cwd(),i=await this.workspace.exists(r),a=i?await this.scanner.hasPackageJson(r):!1,s=i?await this.scanner.isEmptyDirectory(r):!0;return n.example===void 0?a?await this.collectExistingProject(n,r):s||n.isForce?await this.collectNewProject(n,s):(this.logger.error(`Directory is not empty and no ${K(`package.json`)} was found.`),this.logger.info(`To scaffold a new project, run ${K(`arkenv init`)} in an empty directory or use ${K(`--force`)} to proceed anyway.`),this.logger.refuse({code:C.NON_EMPTY_DIR,message:`Directory is not empty and no package.json was found.`,retryWith:[`--force`]}),null):await this.collectNewProject(n,s)}finally{this.logger.interactiveStdout(!1)}}async collectExistingProject(e,n){let{isYes:r,isForce:i,isQuiet:a,isAgent:s}=e,c=await this.scanner.checkRequirements(n),l=c.filter(e=>e.status===`fail`),u=c.filter(e=>e.status===`warn`);for(let e of u)this.logger.warn(`${e.requirement}: ${e.message}`);if(l.length>0)if(i){this.logger.warn(`Technical requirements not met, but continuing due to --force flag.`);for(let e of l)this.logger.warn(`${e.requirement}: ${e.message}`)}else{this.logger.error(`Technical requirements not met:`);for(let e of l)this.logger.error(`- ${e.requirement}: ${e.message}${e.current?` (Current: ${e.current}, Expected: ${e.expected})`:``}`);return this.logger.info(`Use --force to bypass these checks.`),this.logger.refuse({code:C.REQUIREMENTS_NOT_MET,message:`Technical requirements not met.`,retryWith:[`--force`],details:{requirements:l.map(e=>(0,t.shake)({requirement:e.requirement,message:e.message,current:e.current,expected:e.expected}))}}),null}let d=await this.scanner.checkGitStatus(n);if(d.status===`dirty`)if(i)this.logger.warn(`Git working tree is not clean, but continuing due to --force flag.`);else return this.logger.error(`Git working tree is not clean. Commit or stash your changes (use 'git stash -u' for untracked files) before running arkenv init.`),this.logger.info(`Use --force to bypass this check.`),this.logger.refuse({code:C.GIT_TREE_DIRTY,message:`Git working tree is not clean.`,retryWith:[`--force`]}),null;d.status===`unknown`&&this.logger.warn(`Git working tree status could not be determined. Proceeding with caution.`);let f=!1,p=await this.scanner.checkTsConfig(n);if(p.status===`not_strict`)if(r)f=!0;else{this.logger.warn(`TypeScript strict mode is not enabled in your ${K(p.file)}.`);let e=await this.prompt.confirm(`ArkEnv requires ${K(`strict`)} mode in your ${K(p.file)}. Would you like to enable it now?`,!0,`Yes (Recommended)`);if(e===null)return null;if(!e)return this.logger.cancel(`Operation cancelled.`),null;f=!0}let m=await this.scanner.detectFramework(n,p.parsed);if(e.isSimple&&m===`nextjs`)return this.logger.error(`❌ Error: The --simple layout is deprecated and no longer supported by the CLI. Arkenv now exclusively uses the Flat Layout. Run npx arkenv init without this flag.`),null;let h=m===`bun-fullstack`?await this.scanner.detectBunFeatures(n,p.parsed):void 0,g=await this.scanner.suggestDefaultEnvPath(n,p.parsed),_=o.default.resolve(n,g),v=await this.scanner.getEnvExampleKeys(n,p.parsed,_),y=await(async()=>{if(e.isStrict){let e=o.default.extname(_),t=_.slice(0,-e.length),n=[o.default.join(t,`internal`,`shared${e}`),o.default.join(t,`client${e}`),o.default.join(t,`server${e}`)];if((await Promise.all(n.map(e=>this.workspace.exists(e)))).some(Boolean))return!0}return this.workspace.exists(_)})(),b=async({framework:e,envPath:t})=>{if(e!==`vite`&&e!==`bun-fullstack`)return!1;let r=e===`vite`?`vite-env.d.ts`:`bun-env.d.ts`,i=o.default.resolve(n,t),a=o.default.dirname(i),s=o.default.join(a,r);return this.workspace.exists(s)},x=await b({framework:m,envPath:g}),S=await this.prompt.runWizard((0,t.shake)({mode:`existing`,framework:m,bunFeatures:h,defaultEnvPath:g,tsConfig:p.parsed??null,envKeys:v?.keys,envKeysSource:v?.source,hasTypeFileAtPath:b,hasTypeFile:x,hasEnvSchemaFile:y,isStrict:e.isStrict,isSimple:e.isSimple,isFlat:e.isFlat,disableCodegen:e.noCodegen,hostPreset:e.hostPreset}),r);if(S===null)return null;let ee=await this.scanner.hasSkill(n);if(ee&&(S.skillDetected=!0,!a&&!s&&this.logger.info(`ArkEnv agent skill detected.`)),ee)S.installSkill=!1;else if(s)S.installSkill=!1;else if(r)S.installSkill=!0;else{let e=await this.prompt.confirm(`Would you like to install the ArkEnv agent skill?`,!0,`Yes (Recommended)`);if(e===null)return null;S.installSkill=e}let w=o.default.resolve(n,S.path);if(S.overwriteEnvSchemaFile===void 0&&(S.layout===`strict`?await(async()=>{let e=o.default.extname(w),t=w.slice(0,-e.length);return(await Promise.all([this.workspace.exists(o.default.join(t,`internal`,`shared${e}`)),this.workspace.exists(o.default.join(t,`client${e}`)),this.workspace.exists(o.default.join(t,`server${e}`))])).some(Boolean)})():await this.workspace.exists(w))){let e=S.layout===`strict`?`Strict layout files (client, server, internal/shared)`:o.default.basename(w),t=await this.prompt.confirm(`${e} already exist. Overwrite?`,!1);if(t===null)return null;if(!t)return this.logger.cancel(`Operation cancelled.`),null;S.overwriteEnvSchemaFile=t}let T=await this.scanner.detectPackageManager(n,p.parsed),E=o.default.extname(w),D=w.slice(0,-E.length),te=S.layout===`strict`?[o.default.join(D,`internal`,`shared${E}`),o.default.join(D,`client${E}`),o.default.join(D,`server${E}`)]:[w],O=[];for(let e of te)await this.workspace.exists(e)&&O.push(e);let k;if(S.framework===`vite`?k=`vite-env.d.ts`:S.framework===`bun-fullstack`&&(k=`bun-env.d.ts`),k){let e=o.default.dirname(w),t=o.default.join(e,k);await this.workspace.exists(t)&&O.push(t)}let A=o.default.join(n,`.env`),j=o.default.join(n,`.env.example`);await this.workspace.exists(A)&&(O.push(A),S.envContent=await this.workspace.readFile(A)),await this.workspace.exists(j)&&(O.push(j),S.envExampleContent=await this.workspace.readFile(j));let ne=o.default.join(n,`.gitignore`);return await this.workspace.exists(ne)&&(O.push(ne),S.gitignoreContent=await this.workspace.readFile(ne)),(0,t.shake)({mode:`existing`,cwd:n,options:S,detectedFramework:m,detectedBunFeatures:h,packageManager:T,tsConfig:p,shouldUpdateTsConfig:f,existingFiles:O,isYes:r})}async collectNewProject(e,n=!0){let{isYes:r,example:i,name:a,isForce:o}=e,s=await this.registry.fetchRegistry(),c=await this.prompt.runWizard((0,t.shake)({mode:`new`,examples:s.examples,example:i,name:a}),r);if(c===null)return null;if(c.name===`.`&&!n&&!o)return this.logger.error(`Cannot scaffold into ${K(`.`)} because the current directory is not empty.`),this.logger.info(`Run ${K(`arkenv init`)} in an empty directory or choose a sub-directory name instead.`),this.logger.refuse({code:C.NON_EMPTY_DIR,message:`Cannot scaffold into the current directory because it is not empty.`,retryWith:[`--force`]}),null;let l=this.detectPackageManager();return(0,t.shake)({mode:`new`,cwd:process.cwd(),options:c,detectedFramework:c.framework,packageManager:l,tsConfig:{status:`not_found`},shouldUpdateTsConfig:!1,existingFiles:[],isYes:r})}detectPackageManager(){let e=process.env.npm_config_user_agent||``;return e.includes(`pnpm`)?`pnpm`:e.includes(`yarn`)?`yarn`:e.includes(`bun`)?`bun`:`npm`}};function ei(e){let t=new Rn(e),n=t.logger,r=new fn(t.isQuiet,n.stdio,n),i=new Fn;return{cli:t,logger:n,workspace:r,prompt:i,initUseCase:new $r(n,r,i,new Yt(n)),helpUseCase:new Vn(n)}}if(typeof require<`u`&&require.main!==module)throw Error(`🚨 ${b(`You imported the 'arkenv' package as a library. Starting with v1.0.0, the 'arkenv' package is exclusively the interactive CLI. If you want to validate environment variables in your code, please install and import '@arkenv/core' instead.`)}`);const ti=new st({isQuiet:!1,isJson:!1});let ni,ri=!1;async function ii(){if(process.env.INIT_CWD)try{process.chdir(process.env.INIT_CWD)}catch{}let{cli:e,logger:n,initUseCase:r,helpUseCase:i}=ei(process.argv);ni=n,ai(n),e.validationError&&(n.error(e.validationError),await i.execute(),await n.flush(),process.exit(1)),e.helpRequested&&(await i.execute(),await n.flush(),process.exit(0)),e.command!==`init`&&(e.command?n.error(`Unknown command: ${e.command}`):n.error(`Missing command.`),await i.execute(),await n.flush(),process.exit(1));try{await r.execute((0,t.shake)(e.initInput))||(await n.flush(),process.exit(1))}catch(e){try{n.fatal(`An unexpected error occurred`,e)}catch{}await n.flush(),process.exit(1)}}function ai(e){let t=async t=>{ri&&process.exit(t),ri=!0,setTimeout(()=>{process.exit(t)},2e3).unref(),e.interactiveStdout&&e.interactiveStdout(!1);try{e.cancel(`Operation cancelled.`),await e.flush()}catch(t){e.error&&e.error(`Logger failed during shutdown`,t)}finally{process.exit(t)}};process.on(`SIGINT`,()=>t(130)),process.on(`SIGTERM`,()=>t(143))}ii(),process.on(`unhandledRejection`,async e=>{let t=ni??ti;try{t.fatal(`Unhandled rejection`,e)}catch{}await t.flush(),process.exit(1)}),process.on(`uncaughtException`,async e=>{let t=ni??ti;try{t.fatal(`Uncaught exception`,e)}catch{}await t.flush(),process.exit(1)});
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "arkenv",
3
3
  "type": "module",
4
- "version": "1.0.0-alpha.6",
4
+ "version": "1.0.0-alpha.8",
5
5
  "description": "Interactive CLI for scaffolding ArkEnv projects",
6
6
  "bin": {
7
7
  "arkenv": "./dist/index.cjs"
@@ -23,7 +23,12 @@
23
23
  "arkenv",
24
24
  "cli",
25
25
  "scaffold",
26
- "init"
26
+ "init",
27
+ "create",
28
+ "generator",
29
+ "env",
30
+ "environment-variables",
31
+ "config"
27
32
  ],
28
33
  "license": "MIT",
29
34
  "homepage": "https://arkenv.js.org",