zerostarter 0.1.2 → 0.1.3-canary.0

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.
@@ -1,16 +1,17 @@
1
1
  #!/usr/bin/env node
2
- import{a as e,c as t,d as n,f as r,i,l as a,n as o,o as s,r as c,s as l,t as u,u as d}from"../convert-HXDPuaZU.mjs";import{basename as f,delimiter as p,dirname as m,join as h,parse as g,resolve as _}from"node:path";import{existsSync as v,readFileSync as y,readdirSync as b}from"node:fs";import{spawn as ee}from"node:child_process";import{access as x}from"node:fs/promises";import{createInterface as S}from"node:readline/promises";import{randomBytes as te}from"node:crypto";import{parseArgs as ne}from"node:util";import{homedir as re}from"node:os";const C=(e,t,n=process.stdout)=>r=>n.isTTY?`\x1b[${e}m${r}\x1b[${t}m`:r,w=C(`36`,`39`),T=C(`32`,`39`),E=C(`33`,`39`),D=C(`90`,`39`),O=C(`2`,`22`),k=C(`31`,`39`,process.stderr),ie=C(`2`,`22`,process.stderr),A=C(`38;5;208`,`39`),j=[`◇`,`◆`],M=(e,t)=>{let n=(e%j.length+j.length)%j.length;return`${w(j[n])} ${t}`},N={barStart:`┌`,bar:`│`,barEnd:`└`,active:`◆`,submit:`◇`,radioOn:`●`,radioOff:`○`,warn:`▲`,error:`■`,barH:`─`,cornerTR:`╮`,connectL:`├`,cornerBL:`╰`,cornerBR:`╯`};var ae=class extends Error{constructor(...e){super(...e),this.name=`SubprocessError`,this.stdout=``,this.stderr=``}};const oe=[`.exe`,`.com`],P=e=>e.replaceAll(/([()\][%!^"`<>&|;, *?])/g,`^$1`),se=e=>P(P(`"${e.replaceAll(/(\\*)"/g,`$1$1\\"`).replace(/(\\*)$/,`$1$1`)}"`)),ce=async(e,t,n)=>{if(oe.some(t=>e.toLowerCase().endsWith(t)))return!0;let r=(n.PATH||n.Path||``).split(p).filter(Boolean).map(e=>e.replace(/^"(.*)"$/,`$1`));try{return await Promise.any([t,...r].flatMap(t=>oe.map(n=>x(`${_(t,e)}${n}`)))),!0}catch{return!1}},le=async(e,t,n,r=process.platform===`win32`)=>{let i=n.cwd?String(n.cwd):`.`,a=n.env||process.env;return r&&!n.shell&&!await ce(e,i,a)?[P(e),t.map(se),{...n,shell:!0}]:[e,t,n]},F=async(e,t,n,r)=>{let i=[e,...t].join(` `),[a,o,s]=await le(e,t,n);s.shell&&o.length>0&&(a=[a,...o].join(` `),o=[]);let c=ee(a,o,s),l=``,u=``;return new Promise((e,t)=>{let n=(e,n,r)=>{let i=new ae(e,r?{cause:r}:void 0);i.stdout=l,i.stderr=u,i.exitCode=n,t(i)},a=e=>{e.code!==`ERR_STREAM_PREMATURE_CLOSE`&&e.code!==`EPIPE`&&n(`Command failed: ${i}`,void 0,e)};c.stdout&&(c.stdout.setEncoding(`utf8`),c.stdout.on(`data`,e=>{l+=e,r?.(e)}),c.stdout.on(`error`,a)),c.stderr&&(c.stderr.setEncoding(`utf8`),c.stderr.on(`data`,e=>{u+=e,r?.(e)}),c.stderr.on(`error`,a)),c.on(`error`,e=>n(`Command failed: ${i}`,void 0,e)),c.on(`close`,(t,r)=>{if(r)return n(`Command was terminated with ${r}: ${i}`);if(t!==0)return n(`Command failed with exit code ${t}: ${i}`,t??void 0);e({stdout:l,stderr:u})})})},I=async(e,t,n)=>{let{stdout:r}=await F(e,t,{cwd:n,stdio:[`ignore`,`pipe`,`pipe`]});return r},ue=async(e,t,n)=>{await F(e,t,{cwd:n,stdio:`inherit`})},L=async(e,t)=>{try{return await F(e,t,{stdio:`ignore`}),!0}catch{return!1}},de=RegExp(`\x1B\\[[0-9;?]*[a-zA-Z]`,`g`),fe=e=>e.replace(de,``),pe=new WeakSet,me=e=>{if(process.stderr.write(`\n ${k(e instanceof Error?e.message:String(e))}\n`),!(e instanceof ae)||pe.has(e))return;let t=(e.stderr||e.stdout||``).trim();if(!t)return;let n=fe(t).split(`
3
- `).map(e=>e.trimEnd()).filter(Boolean).slice(-12);for(let e of n)process.stderr.write(` ${ie(e)}\n`)},he=async(e,t,n)=>{let r=process.stdout,i=n.label??``;if(!r.isTTY){i&&r.write(` ${w(N.active)} ${i}\n`),await ue(e,t,n.cwd);return}let a=n.lines??3,o=[],s=0,c=0,l=``,u=``,d=()=>(r.columns||80)-1,f=e=>{r.write(e?`\x1B[?7h`:`\x1B[?7l`)},p=()=>{c>0&&(r.write(`[${c}A`),c=0)},m=()=>{p();let e=0;r.write(` ${M(s,i)}\n`),e++;for(let t of o.slice(-a))r.write(` ${D(N.bar)} ${O(t.slice(0,Math.max(0,d()-5)))}\n`),e++;c=e},h=e=>{u+=e,l+=e;let t=l.split(`
4
- `);l=t.pop()??``;for(let e of t)o.push(fe(e).replace(/\r/g,``).replace(/\t/g,` `).trimEnd()),m()};m(),f(!1);let g=()=>{f(!0),process.exit(130)};process.once(`SIGINT`,g);let _=setInterval(()=>{s+=1,m()},400),v=()=>{clearInterval(_),process.removeListener(`SIGINT`,g)};try{await F(e,t,{cwd:n.cwd,stdio:[`ignore`,`pipe`,`pipe`]},h)}catch(e){throw v(),p(),f(!0),r.write(u),e&&typeof e==`object`&&pe.add(e),e}v(),p(),f(!0),r.write(` ${w(N.active)} ${n.done??i}\n`);for(let e of o.slice(-a))r.write(` ${D(N.bar)} ${O(e.slice(0,Math.max(0,d()-5)))}\n`)};var ge={name:`zerostarter`,version:`0.1.2`,description:`Go from zero to a production-ready SaaS, rebranded and ready to ship.`,keywords:[`cli`,`saas`,`scaffold`,`starter`,`template`,`zerostarter`],homepage:`https://github.com/nrjdalal/zerostarter#readme`,bugs:`https://github.com/nrjdalal/zerostarter/issues`,license:`MIT`,author:{name:`Neeraj Dalal`,email:`admin@nrjdalal.com`,url:`https://nrjdalal.com`},repository:`nrjdalal/zerostarter`,funding:`https://github.com/sponsors/nrjdalal`,bin:{zerostarter:`dist/bin/index.mjs`},files:[`dist`],type:`module`,types:`./dist/index.d.mts`,exports:`./dist/index.mjs`,scripts:{build:`tsdown`,"check-types":`tsc --noEmit`,dev:`tsdown --watch`,test:`bun test`},devDependencies:{"@packages/config":`workspace:*`,"@types/bun":`catalog:`,"@types/node":`catalog:`,tsdown:`catalog:`,typescript:`catalog:`}};const R=()=>!!(process.stdin.isTTY&&process.stdout.isTTY),_e=(e,t=e)=>process.stdout.isTTY?`\x1b]8;;${e}\x07${t}\x1b]8;;\x07`:e,z=e=>_e(e,w(e)),B=e=>{process.stdout.write(`\n ${D(N.barStart)} ${e}\n ${D(N.bar)}\n`)},V=e=>{process.stdout.write(` ${D(N.bar)}\n ${D(N.barEnd)} ${e}\n`)},H=(e=`Cancelled`)=>{process.stdout.write(` ${D(N.barEnd)} ${k(e)}\n`)},U=e=>e.replace(RegExp(`\x1B\\[[0-9;?]*[a-zA-Z]`,`g`),``).replace(RegExp(`\x1B\\]8;;.*?\\x07`,`g`),``).length,W=(e,t=``,n=!1)=>{let r=`\n${e}\n`.split(`
5
- `),i=U(t),a=r.reduce((e,t)=>Math.max(e,U(t)),i),o=Math.max(a,54)+2,s=r.map(e=>` ${D(N.bar)} ${e}${` `.repeat(o-U(e))}${D(N.bar)}`).join(`
6
- `),c=n?N.cornerBL:N.connectL;process.stdout.write(` ${w(N.active)} ${t} ${D(N.barH.repeat(Math.max(o-i-1,1))+N.cornerTR)}\n${s}\n ${D(c+N.barH.repeat(o+2)+N.cornerBR)}\n`)},G=(e,t=[])=>{process.stdout.write(` ${w(N.active)} ${e}\n`);for(let e of t)process.stdout.write(` ${D(N.bar)} ${e}\n`)},ve=e=>{process.stdout.write(` ${T(N.active)} ${T(e)}\n`)},K=(e,t=[])=>{process.stdout.write(` ${E(N.warn)} ${E(e)}\n`);for(let e of t)process.stdout.write(` ${D(N.bar)} ${E(e)}\n`)},ye=async(e,t,n)=>{let r=process.stdout,i=null;if(r.isTTY){let t=0;r.write(` ${M(0,e)}`),i=setInterval(()=>{t+=1,r.write(`\r\x1b[K ${M(t,e)}`)},400)}try{let e=await n();return i&&clearInterval(i),r.write(r.isTTY?`\r\x1b[K ${w(N.active)} ${t}\n`:` ${w(N.active)} ${t}\n`),e}catch(e){throw i&&clearInterval(i),r.isTTY&&r.write(`\r\x1B[K`),e}},be=e=>{let t=e?`${T(N.radioOn)} Yes`:O(`${N.radioOff} Yes`),n=e?O(`${N.radioOff} No`):`${T(N.radioOn)} No`;return` ${D(N.bar)} ${t} ${O(`/`)} ${n}`},q=async(e,t=!0)=>{let n=process.stdout;return R()?new Promise(r=>{let i=t,a=process.stdin,o=Math.max(1,Math.ceil((5+U(e))/(n.columns||80)));n.write(` ${w(N.submit)} ${e}\n`),n.write(be(i)),a.setRawMode(!0),a.resume(),a.setEncoding(`utf8`);let s=()=>{a.setRawMode(!1),a.pause(),a.removeListener(`data`,u)},c=()=>{n.write(`\r\x1b[K\x1b[${o}A\r\x1b[0J`)},l=()=>{s(),c(),r(i)};function u(t){t===``?(s(),c(),n.write(` ${w(N.submit)} ${O(e)}\n`),H(),process.exit(130)):t===`\r`||t===`
7
- `?l():t===`y`||t===`Y`?(i=!0,l()):t===`n`||t===`N`?(i=!1,l()):(t===`\x1B[C`||t===`\x1B[D`||t===`\x1B[A`||t===`\x1B[B`||t===`h`||t===`l`)&&(i=!i,n.write(`\r\x1b[K${be(i)}`))}a.on(`data`,u)}):(n.write(` ${w(N.active)} ${e} ${O(t?`Yes`:`No`)}\n`),t)},xe=async(e,t=``)=>{process.stdout.write(` ${w(N.submit)} ${e}${t?` ${O(`(${t})`)}`:``}\n`);let n=S({input:process.stdin,output:process.stdout});try{return(await n.question(` ${D(N.bar)} `)).trim()||t}finally{n.close()}},Se=`pglaunch@5.5.7`,Ce=async()=>L(`docker`,[`info`]),we=t=>{let n=h(t,`.env`);if(!e(n)){let r=h(t,`.env.example`);d(n,e(r)?l(r):``)}return n},Te=(e,t)=>{let n=`${t}=`,r=l(e).split(`
8
- `).find(e=>e.startsWith(n));return r?r.slice(n.length).trim():``},Ee=(e,t,n)=>{let r=`${t}=`,i=l(e).split(`
9
- `),a=i.findIndex(e=>e.startsWith(r));if(a>=0)i[a]=`${r}${n}`;else{for(;i.length&&i[i.length-1]===``;)i.pop();i.push(`${r}${n}`,``)}d(e,i.join(`
10
- `))},De=e=>{let t=we(e);Te(t,`BETTER_AUTH_SECRET`)||Ee(t,`BETTER_AUTH_SECRET`,te(32).toString(`base64`))},J=t=>{let n=h(t,`.env`);return e(n)&&Te(n,`POSTGRES_URL`)!==``},Oe=e=>{let t=e.match(/postgres(?:ql)?:\/\/[\w.:@\-/%?=&]+/);if(!t)return null;let n=e.match(/name "([^" ]+) :\d+" started/),r=e.match(/similar name "([^"]+)"/);return{url:t[0],container:n?n[1]:r?r[1]:``}},ke=async(e,t)=>{let n=t?[`--bun`,Se,`-k`,`-c`]:[`--bun`,Se,`-k`],r;try{r=await I(`bunx`,n,e)}catch(e){let t=e;r=[t.stdout,t.stderr].filter(Boolean).join(`
11
- `)}return{launch:Oe(r),out:r}},Ae=e=>new Promise(t=>setTimeout(t,e)),je=async e=>{if(e)for(let t=0;t<30;t++){if(await L(`docker`,[`exec`,e,`pg_isready`,`-U`,`postgres`]))return;await Ae(1e3)}},Me=async e=>{let t=we(e),n=await ke(e,!1),r=n.launch?n:await ke(e,!0);if(!r.launch)throw Error(r.out.trim()||`pglaunch did not print a connection URL`);Ee(t,`POSTGRES_URL`,r.launch.url),await je(r.launch.container),await he(`bun`,[`run`,`db:migrate`],{cwd:e,label:`Provisioning a local Postgres database`,done:`Provisioned a local Postgres database`})},Y=async e=>{await he(`bun`,[`install`],{cwd:e,label:`Installing dependencies`,done:`Installed dependencies`})},Ne=async()=>{if(!await L(`bun`,[`--version`]))throw Error(`bun is not on PATH`)},Pe=async(e=Ne,t=!!process.versions.bun,n=process.env.npm_config_user_agent||``)=>{if(t||n.startsWith(`bun/`))return!0;try{return await e(),!0}catch{return!1}},Fe=async(e,t=`main`)=>{await I(`bunx`,[`--bun`,`gitpick@6.0.0`,`https://github.com/nrjdalal/zerostarter/tree/${t}`,e])},Ie=async(e,t=`main`)=>{await I(`bunx`,[`--bun`,`gitpick@6.0.0`,`https://github.com/nrjdalal/zerostarter/tree/${t}`,e,`-o`])},Le=async(e=`main`)=>{let t=`https://raw.githubusercontent.com/nrjdalal/zerostarter/${e}/.gitpickignore`,n=await fetch(t);if(!n.ok)throw Error(`Could not fetch .gitpickignore from ${e} (HTTP ${n.status}).`);return n.text()},Re=async e=>(await I(`git`,[`status`,`--porcelain`],e)).trim()===``,ze=async(e,t)=>{for(let n of t)try{await I(`git`,[`checkout`,`--`,n],e),await I(`git`,[`clean`,`-fd`,`--`,n],e)}catch{}},Be=async e=>{await I(`git`,[`reset`,`--hard`,`HEAD`],e),await I(`git`,[`clean`,`-fd`],e)},Ve=async(t,n,r)=>{if(!e(h(t,`.git`)))throw Error(n);if(!await Re(t))throw Error(r)},He=async(e,t,n)=>{try{await n()}catch(n){throw await Be(e),console.log(t),n}},Ue=async e=>{await I(`git`,[`init`,`-q`,`-b`,`canary`],e)},We=async(e,t)=>{await I(`git`,[`branch`,t],e)},X=async(e,t)=>{await I(`git`,[`add`,`-A`],e);try{await I(`git`,[`commit`,`--no-verify`,`-q`,`-m`,t],e)}catch{}},Z=(e,t)=>{try{return ne(t)}catch(t){process.stderr.write(`${k(t instanceof Error?t.message:String(t))}\n\n`),process.stdout.write(`${e}\n`),process.exit(1)}},Ge=(e=process.env.npm_config_user_agent||``)=>e.startsWith(`bun/`)?`bunx`:e.startsWith(`pnpm/`)?`pnpm dlx`:e.startsWith(`yarn/`)?`yarn dlx`:e.startsWith(`npm/`)?`npx`:`unknown`,Ke=(e=process.platform)=>e===`win32`?{cmd:`powershell`,args:[`-Command`,`irm bun.sh/install.ps1 | iex`]}:{cmd:`bash`,args:[`-c`,`curl -fsSL https://bun.sh/install | bash`]},qe=(e=process.argv.slice(2))=>[`zerostarter`,...e].join(` `),Je=()=>h(process.env.BUN_INSTALL||h(re(),`.bun`),`bin`),Q=async(e=!1)=>{if(await Pe())return;let t=Ge(),n=`bunx --bun ${qe()}`;if(console.error(k(`Seems like you are using ${t===`unknown`?`npx/pnpx`:t} or Windows, try using:`)),console.error(A(` ${n}`)),console.error(``),e||R()&&await q(`Or install bun now and continue?`,!0)){let{cmd:e,args:t}=Ke();console.error(`Installing bun from https://bun.sh/install ...`);try{if(await ue(e,t),process.env.PATH=`${Je()}${p}${process.env.PATH||``}`,await Pe())return;console.error(k(`
12
- bun is installed but isn't on this shell's PATH yet. Open a new terminal and re-run:`)),console.error(A(` ${n}`))}catch{console.error(k(`
13
- Could not install bun. Install it from https://bun.sh, then re-run:`)),console.error(A(` ${n}`))}}process.exit(1)},Ye=`Usage:
2
+ import{a as e,c as t,d as n,f as r,i,l as a,n as o,o as s,p as c,r as l,s as u,t as d,u as f}from"../convert-DHCJQjgd.mjs";import{basename as p,delimiter as m,dirname as h,join as g,parse as _,resolve as v}from"node:path";import{existsSync as y,readFileSync as b,readdirSync as ee}from"node:fs";import{spawn as x}from"node:child_process";import{access as te}from"node:fs/promises";import{createInterface as S}from"node:readline/promises";import{randomBytes as C}from"node:crypto";import{parseArgs as ne}from"node:util";import{homedir as w}from"node:os";const T=(e,t,n=process.stdout)=>r=>n.isTTY?`\x1b[${e}m${r}\x1b[${t}m`:r,E=T(`36`,`39`),D=T(`32`,`39`),O=T(`33`,`39`),k=T(`90`,`39`),A=T(`2`,`22`),j=T(`31`,`39`,process.stderr),re=T(`2`,`22`,process.stderr),M=T(`38;5;208`,`39`),N=[`◇`,`◆`],P=(e,t)=>{let n=(e%N.length+N.length)%N.length;return`${E(N[n])} ${t}`},F={barStart:`┌`,bar:`│`,barEnd:`└`,active:`◆`,submit:`◇`,radioOn:`●`,radioOff:`○`,checkboxOn:`◼`,checkboxOff:`◻`,warn:`▲`,error:`■`,barH:`─`,cornerTR:`╮`,connectL:`├`,cornerBL:`╰`,cornerBR:`╯`};var ie=class extends Error{constructor(...e){super(...e),this.name=`SubprocessError`,this.stdout=``,this.stderr=``}};const ae=[`.exe`,`.com`],I=e=>e.replaceAll(/([()\][%!^"`<>&|;, *?])/g,`^$1`),oe=e=>I(I(`"${e.replaceAll(/(\\*)"/g,`$1$1\\"`).replace(/(\\*)$/,`$1$1`)}"`)),se=async(e,t,n)=>{if(ae.some(t=>e.toLowerCase().endsWith(t)))return!0;let r=(n.PATH||n.Path||``).split(m).filter(Boolean).map(e=>e.replace(/^"(.*)"$/,`$1`));try{return await Promise.any([t,...r].flatMap(t=>ae.map(n=>te(`${v(t,e)}${n}`)))),!0}catch{return!1}},ce=async(e,t,n,r=process.platform===`win32`)=>{let i=n.cwd?String(n.cwd):`.`,a=n.env||process.env;return r&&!n.shell&&!await se(e,i,a)?[I(e),t.map(oe),{...n,shell:!0}]:[e,t,n]},L=async(e,t,n,r)=>{let i=[e,...t].join(` `),[a,o,s]=await ce(e,t,n);s.shell&&o.length>0&&(a=[a,...o].join(` `),o=[]);let c=x(a,o,s),l=``,u=``;return new Promise((e,t)=>{let n=(e,n,r)=>{let i=new ie(e,r?{cause:r}:void 0);i.stdout=l,i.stderr=u,i.exitCode=n,t(i)},a=e=>{e.code!==`ERR_STREAM_PREMATURE_CLOSE`&&e.code!==`EPIPE`&&n(`Command failed: ${i}`,void 0,e)};c.stdout&&(c.stdout.setEncoding(`utf8`),c.stdout.on(`data`,e=>{l+=e,r?.(e)}),c.stdout.on(`error`,a)),c.stderr&&(c.stderr.setEncoding(`utf8`),c.stderr.on(`data`,e=>{u+=e,r?.(e)}),c.stderr.on(`error`,a)),c.on(`error`,e=>n(`Command failed: ${i}`,void 0,e)),c.on(`close`,(t,r)=>{if(r)return n(`Command was terminated with ${r}: ${i}`);if(t!==0)return n(`Command failed with exit code ${t}: ${i}`,t??void 0);e({stdout:l,stderr:u})})})},R=async(e,t,n)=>{let{stdout:r}=await L(e,t,{cwd:n,stdio:[`ignore`,`pipe`,`pipe`]});return r},le=async(e,t,n)=>{await L(e,t,{cwd:n,stdio:`inherit`})},z=async(e,t)=>{try{return await L(e,t,{stdio:`ignore`}),!0}catch{return!1}},ue=RegExp(`\x1B\\[[0-9;?]*[a-zA-Z]`,`g`),de=e=>e.replace(ue,``),fe=new WeakSet,pe=e=>{if(process.stderr.write(`\n ${j(e instanceof Error?e.message:String(e))}\n`),!(e instanceof ie)||fe.has(e))return;let t=(e.stderr||e.stdout||``).trim();if(!t)return;let n=de(t).split(`
3
+ `).map(e=>e.trimEnd()).filter(Boolean).slice(-12);for(let e of n)process.stderr.write(` ${re(e)}\n`)},me=async(e,t,n)=>{let r=process.stdout,i=n.label??``;if(!r.isTTY){i&&r.write(` ${E(F.active)} ${i}\n`),await le(e,t,n.cwd);return}let a=n.lines??3,o=[],s=0,c=0,l=``,u=``,d=()=>(r.columns||80)-1,f=e=>{r.write(e?`\x1B[?7h`:`\x1B[?7l`)},p=()=>{c>0&&(r.write(`[${c}A`),c=0)},m=()=>{p();let e=0;r.write(` ${P(s,i)}\n`),e++;for(let t of o.slice(-a))r.write(` ${k(F.bar)} ${A(t.slice(0,Math.max(0,d()-5)))}\n`),e++;c=e},h=e=>{u+=e,l+=e;let t=l.split(`
4
+ `);l=t.pop()??``;for(let e of t)o.push(de(e).replace(/\r/g,``).replace(/\t/g,` `).trimEnd()),m()};m(),f(!1);let g=()=>{f(!0),process.exit(130)};process.once(`SIGINT`,g);let _=setInterval(()=>{s+=1,m()},400),v=()=>{clearInterval(_),process.removeListener(`SIGINT`,g)};try{await L(e,t,{cwd:n.cwd,stdio:[`ignore`,`pipe`,`pipe`]},h)}catch(e){throw v(),p(),f(!0),r.write(u),e&&typeof e==`object`&&fe.add(e),e}v(),p(),f(!0),r.write(` ${E(F.active)} ${n.done??i}\n`);for(let e of o.slice(-a))r.write(` ${k(F.bar)} ${A(e.slice(0,Math.max(0,d()-5)))}\n`)};var he={name:`zerostarter`,version:`0.1.3-canary.0`,description:`Go from zero to a production-ready SaaS, rebranded and ready to ship.`,keywords:[`cli`,`saas`,`scaffold`,`starter`,`template`,`zerostarter`],homepage:`https://github.com/nrjdalal/zerostarter#readme`,bugs:`https://github.com/nrjdalal/zerostarter/issues`,license:`MIT`,author:{name:`Neeraj Dalal`,email:`admin@nrjdalal.com`,url:`https://nrjdalal.com`},repository:`nrjdalal/zerostarter`,funding:`https://github.com/sponsors/nrjdalal`,bin:{zerostarter:`dist/bin/index.mjs`},files:[`dist`],type:`module`,types:`./dist/index.d.mts`,exports:`./dist/index.mjs`,scripts:{build:`tsdown`,"check-types":`tsc --noEmit`,dev:`tsdown --watch`,test:`bun test`},devDependencies:{"@packages/config":`workspace:*`,"@types/bun":`catalog:`,"@types/node":`catalog:`,tsdown:`catalog:`,typescript:`catalog:`}};const B=()=>!!(process.stdin.isTTY&&process.stdout.isTTY),ge=(e,t=e)=>process.stdout.isTTY?`\x1b]8;;${e}\x07${t}\x1b]8;;\x07`:e,V=e=>ge(e,E(e)),H=e=>{process.stdout.write(`\n ${k(F.barStart)} ${e}\n ${k(F.bar)}\n`)},U=e=>{process.stdout.write(` ${k(F.bar)}\n ${k(F.barEnd)} ${e}\n`)},W=(e=`Cancelled`)=>{process.stdout.write(` ${k(F.barEnd)} ${j(e)}\n`)},G=e=>e.replace(RegExp(`\x1B\\[[0-9;?]*[a-zA-Z]`,`g`),``).replace(RegExp(`\x1B\\]8;;.*?\\x07`,`g`),``).length,K=(e,t=``,n=!1)=>{let r=`\n${e}\n`.split(`
5
+ `),i=G(t),a=r.reduce((e,t)=>Math.max(e,G(t)),i),o=Math.max(a,54)+2,s=r.map(e=>` ${k(F.bar)} ${e}${` `.repeat(o-G(e))}${k(F.bar)}`).join(`
6
+ `),c=n?F.cornerBL:F.connectL;process.stdout.write(` ${E(F.active)} ${t} ${k(F.barH.repeat(Math.max(o-i-1,1))+F.cornerTR)}\n${s}\n ${k(c+F.barH.repeat(o+2)+F.cornerBR)}\n`)},q=(e,t=[])=>{process.stdout.write(` ${E(F.active)} ${e}\n`);for(let e of t)process.stdout.write(` ${k(F.bar)} ${e}\n`)},_e=e=>{process.stdout.write(` ${D(F.active)} ${D(e)}\n`)},J=(e,t=[])=>{process.stdout.write(` ${O(F.warn)} ${O(e)}\n`);for(let e of t)process.stdout.write(` ${k(F.bar)} ${O(e)}\n`)},ve=async(e,t,n)=>{let r=process.stdout,i=null;if(r.isTTY){let t=0;r.write(` ${P(0,e)}`),i=setInterval(()=>{t+=1,r.write(`\r\x1b[K ${P(t,e)}`)},400)}try{let e=await n();return i&&clearInterval(i),r.write(r.isTTY?`\r\x1b[K ${E(F.active)} ${t}\n`:` ${E(F.active)} ${t}\n`),e}catch(e){throw i&&clearInterval(i),r.isTTY&&r.write(`\r\x1B[K`),e}},ye=e=>{let t=e?`${D(F.radioOn)} Yes`:A(`${F.radioOff} Yes`),n=e?A(`${F.radioOff} No`):`${D(F.radioOn)} No`;return` ${k(F.bar)} ${t} ${A(`/`)} ${n}`},Y=async(e,t=!0)=>{let n=process.stdout;return B()?new Promise(r=>{let i=t,a=process.stdin,o=Math.max(1,Math.ceil((5+G(e))/(n.columns||80)));n.write(` ${E(F.submit)} ${e}\n`),n.write(ye(i)),a.setRawMode(!0),a.resume(),a.setEncoding(`utf8`);let s=()=>{a.setRawMode(!1),a.pause(),a.removeListener(`data`,u)},c=()=>{n.write(`\r\x1b[K\x1b[${o}A\r\x1b[0J`)},l=()=>{s(),c(),r(i)};function u(t){t===``?(s(),c(),n.write(` ${E(F.submit)} ${A(e)}\n`),W(),process.exit(130)):t===`\r`||t===`
7
+ `?l():t===`y`||t===`Y`?(i=!0,l()):t===`n`||t===`N`?(i=!1,l()):(t===`\x1B[C`||t===`\x1B[D`||t===`\x1B[A`||t===`\x1B[B`||t===`h`||t===`l`)&&(i=!i,n.write(`\r\x1b[K${ye(i)}`))}a.on(`data`,u)}):(n.write(` ${E(F.active)} ${e} ${A(t?`Yes`:`No`)}\n`),t)},be=async(e,t)=>{if(t.length===0)return[];let n=process.stdout,r=new Set(t.filter(e=>e.checked).map(e=>e.value)),i=()=>t.filter(e=>r.has(e.value)).map(e=>e.label).join(`, `)||`none`;return B()?new Promise(a=>{let o=process.stdin,s=0,c=e=>{let n=t[e],i=r.has(n.value)?D(F.checkboxOn):A(F.checkboxOff),a=e===s?n.label:A(n.label);return` ${k(F.bar)} ${i} ${a}`},l=e=>{e||n.write(`\x1b[${t.length}A`);for(let e=0;e<t.length;e++)n.write(`\r\x1b[K${c(e)}\n`)};n.write(` ${E(F.submit)} ${e}\n`),l(!0),o.setRawMode(!0),o.resume(),o.setEncoding(`utf8`);let u=()=>{o.setRawMode(!1),o.pause(),o.removeListener(`data`,d)};function d(o){if(o===``)u(),n.write(`\x1b[${t.length+1}A\r\x1b[0J ${E(F.submit)} ${A(e)}\n`),W(),process.exit(130);else if(o===`\r`||o===`
8
+ `)u(),n.write(`\x1b[${t.length+1}A\r\x1b[0J ${E(F.submit)} ${e} ${A(i())}\n`),a([...r]);else if(o===`\x1B[A`||o===`k`)s=(s-1+t.length)%t.length,l(!1);else if(o===`\x1B[B`||o===`j`)s=(s+1)%t.length,l(!1);else if(o===` `){let e=t[s].value;r.has(e)?r.delete(e):r.add(e),l(!1)}}o.on(`data`,d)}):(n.write(` ${E(F.submit)} ${e} ${A(i())}\n`),[...r])},xe=async(e,t=``)=>{process.stdout.write(` ${E(F.submit)} ${e}${t?` ${A(`(${t})`)}`:``}\n`);let n=S({input:process.stdin,output:process.stdout});try{return(await n.question(` ${k(F.bar)} `)).trim()||t}finally{n.close()}},Se=`pglaunch@5.5.7`,Ce=async()=>z(`docker`,[`info`]),we=e=>{let r=g(e,`.env`);if(!s(r)){let i=g(e,`.env.example`);n(r,s(i)?t(i):``)}return r},Te=(e,n)=>{let r=`${n}=`,i=t(e).split(`
9
+ `).find(e=>e.startsWith(r));return i?i.slice(r.length).trim():``},Ee=(e,r,i)=>{let a=`${r}=`,o=t(e).split(`
10
+ `),s=o.findIndex(e=>e.startsWith(a));if(s>=0)o[s]=`${a}${i}`;else{for(;o.length&&o[o.length-1]===``;)o.pop();o.push(`${a}${i}`,``)}n(e,o.join(`
11
+ `))},De=e=>{let t=we(e);Te(t,`BETTER_AUTH_SECRET`)||Ee(t,`BETTER_AUTH_SECRET`,C(32).toString(`base64`))},X=e=>{let t=g(e,`.env`);return s(t)&&Te(t,`POSTGRES_URL`)!==``},Oe=e=>{let t=e.match(/postgres(?:ql)?:\/\/[\w.:@\-/%?=&]+/);if(!t)return null;let n=e.match(/name "([^" ]+) :\d+" started/),r=e.match(/similar name "([^"]+)"/);return{url:t[0],container:n?n[1]:r?r[1]:``}},ke=async(e,t)=>{let n=t?[`--bun`,Se,`-k`,`-c`]:[`--bun`,Se,`-k`],r;try{r=await R(`bunx`,n,e)}catch(e){let t=e;r=[t.stdout,t.stderr].filter(Boolean).join(`
12
+ `)}return{launch:Oe(r),out:r}},Ae=e=>new Promise(t=>setTimeout(t,e)),je=async e=>{if(e)for(let t=0;t<30;t++){if(await z(`docker`,[`exec`,e,`pg_isready`,`-U`,`postgres`]))return;await Ae(1e3)}},Me=async e=>{let t=we(e),n=await ke(e,!1),r=n.launch?n:await ke(e,!0);if(!r.launch)throw Error(r.out.trim()||`pglaunch did not print a connection URL`);Ee(t,`POSTGRES_URL`,r.launch.url),await je(r.launch.container),await me(`bun`,[`run`,`db:migrate`],{cwd:e,label:`Provisioning a local Postgres database`,done:`Provisioned a local Postgres database`})},Ne=async e=>{await me(`bun`,[`install`],{cwd:e,label:`Installing dependencies`,done:`Installed dependencies`})},Pe=async()=>{if(!await z(`bun`,[`--version`]))throw Error(`bun is not on PATH`)},Fe=async(e=Pe,t=!!process.versions.bun,n=process.env.npm_config_user_agent||``)=>{if(t||n.startsWith(`bun/`))return!0;try{return await e(),!0}catch{return!1}},Ie=async(e,t=`main`)=>{await R(`bunx`,[`--bun`,`gitpick@6.0.0`,`https://github.com/nrjdalal/zerostarter/tree/${t}`,e])},Le=async(e,t=`main`)=>{await R(`bunx`,[`--bun`,`gitpick@6.0.0`,`https://github.com/nrjdalal/zerostarter/tree/${t}`,e,`-o`])},Re=async(e=`main`)=>{let t=`https://raw.githubusercontent.com/nrjdalal/zerostarter/${e}/.gitpickignore`,n=await fetch(t);if(!n.ok)throw Error(`Could not fetch .gitpickignore from ${e} (HTTP ${n.status}).`);return n.text()},ze=async e=>(await R(`git`,[`status`,`--porcelain`],e)).trim()===``,Be=async(e,t)=>{for(let n of t)try{await R(`git`,[`checkout`,`--`,n],e),await R(`git`,[`clean`,`-fd`,`--`,n],e)}catch{}},Ve=async e=>{await R(`git`,[`reset`,`--hard`,`HEAD`],e),await R(`git`,[`clean`,`-fd`],e)},He=async(e,t,n)=>{if(!s(g(e,`.git`)))throw Error(t);if(!await ze(e))throw Error(n)},Ue=async(e,t,n)=>{try{await n()}catch(n){throw await Ve(e),console.log(t),n}},We=async e=>{await R(`git`,[`init`,`-q`,`-b`,`canary`],e)},Ge=async(e,t)=>{await R(`git`,[`branch`,t],e)},Ke=async(e,t)=>{await R(`git`,[`add`,`-A`],e);try{await R(`git`,[`commit`,`--no-verify`,`-q`,`-m`,t],e)}catch{}},qe=(e,t)=>{try{return ne(t)}catch(t){process.stderr.write(`${j(t instanceof Error?t.message:String(t))}\n\n`),process.stdout.write(`${e}\n`),process.exit(1)}},Je=(e=process.env.npm_config_user_agent||``)=>e.startsWith(`bun/`)?`bunx`:e.startsWith(`pnpm/`)?`pnpm dlx`:e.startsWith(`yarn/`)?`yarn dlx`:e.startsWith(`npm/`)?`npx`:`unknown`,Ye=(e=process.platform)=>e===`win32`?{cmd:`powershell`,args:[`-Command`,`irm bun.sh/install.ps1 | iex`]}:{cmd:`bash`,args:[`-c`,`curl -fsSL https://bun.sh/install | bash`]},Xe=(e=process.argv.slice(2))=>[`zerostarter`,...e].join(` `),Ze=()=>g(process.env.BUN_INSTALL||g(w(),`.bun`),`bin`),Qe=async(e=!1)=>{if(await Fe())return;let t=Je(),n=`bunx --bun ${Xe()}`;if(console.error(j(`Seems like you are using ${t===`unknown`?`npx/pnpx`:t} or Windows, try using:`)),console.error(M(` ${n}`)),console.error(``),e||B()&&await Y(`Or install bun now and continue?`,!0)){let{cmd:e,args:t}=Ye();console.error(`Installing bun from https://bun.sh/install ...`);try{if(await le(e,t),process.env.PATH=`${Ze()}${m}${process.env.PATH||``}`,await Fe())return;console.error(j(`
13
+ bun is installed but isn't on this shell's PATH yet. Open a new terminal and re-run:`)),console.error(M(` ${n}`))}catch{console.error(j(`
14
+ Could not install bun. Install it from https://bun.sh, then re-run:`)),console.error(M(` ${n}`))}}process.exit(1)},Z=[{value:`apiDocs`,flag:`api-docs`,label:`API docs`},{value:`blog`,flag:`blog`,label:`Blog`},{value:`docs`,flag:`docs`,label:`Docs`},{value:`internalDocs`,flag:`internal-docs`,label:`Internal (console) docs`},{value:`waitlist`,flag:`waitlist`,label:`Waitlist (else a plain landing home)`}],$e=`Usage:
14
15
  $ bunx zerostarter init [dir] [options]
15
16
 
16
17
  Scaffold ZeroStarter into dir (default .) as a fresh product. The author's
@@ -24,10 +25,17 @@ Options:
24
25
  --canary Scaffold from the canary branch instead of main (for testing)
25
26
  --db Provision a local Postgres (pglaunch) and migrate; needs Docker
26
27
  --dry-run Print the plan without writing anything
27
- -h, --help Display help`,Xe=e=>!v(e)||b(e).filter(e=>e!==`.git`).length===0,$=t=>e(h(t,`packages/config/src/site.ts`)),Ze=e=>{let t=e,{root:n}=g(t);for(;;){if(v(h(t,`bun.lock`))||v(h(t,`bun.lockb`)))return t;let e=h(t,`package.json`);if(v(e))try{if(JSON.parse(y(e,`utf8`)).workspaces)return t}catch{}if(t===n)return null;t=m(t)}},Qe=async t=>{let{positionals:n,values:r}=Z(Ye,{allowPositionals:!0,args:t,options:{canary:{type:`boolean`},db:{type:`boolean`},"dry-run":{type:`boolean`},help:{short:`h`,type:`boolean`},yes:{short:`y`,type:`boolean`}}});if(r.help){console.log(Ye);return}r[`dry-run`]||await Q(!!r.yes);let i=R()&&!r.yes,a=r.canary?`canary`:`main`,o=n[0]??`.`,s=_(o),c=$(s),l=!c&&!Xe(s);if(!c&&!r[`dry-run`]){let e=Ze(l?process.cwd():m(s));if(e)throw Error(`Cannot scaffold inside an existing project (a workspace was found at ${e}). Run it in a fresh directory outside that project.`)}if(r[`dry-run`]||B(z(`https://zerostarter.dev`)),l){if(!i)throw Error(`Directory is not empty. Run it in an empty directory, or pass a project name: bunx zerostarter init <name>`);let e=await xe(`What should we name your project?`);if(!e)throw Error(`No directory name provided.`);o=e}let d=_(o),p=f(d),g={name:p},v=`--canary ignored: converting the existing checkout in place, so nothing is fetched.`;if(r[`dry-run`]){console.log(`bunx zerostarter init (dry run)`),console.log(` target: ${d}`),console.log(` name: ${p}`),console.log(` mode: ${$(d)?`in place`:`fetch ${a}`}`),$(d)&&r.canary&&console.log(` note: ${v}`);return}if(c&&i&&!await q(`Convert ${p} in place? This rewrites files and commits.`,!1)){H(`Aborted`);return}if($(d))r.canary&&K(v);else{let e=r.canary?` (canary)`:``;await ye(`Fetching the latest ZeroStarter${e}`,`Fetched the latest ZeroStarter${e}`,()=>Fe(d,a))}e(h(d,`.git`))||(await Ue(d),await X(d,`ci(init): scaffold from zerostarter`),await We(d,`main`)),await ye(`Rebranding to ${p}`,`Rebranded to ${p}`,()=>u(d,g)),await Y(d),await X(d,`ci(init): re-baseline as ${p}`),De(d);let y=!1,b=await Ce(),ee=J(d),x=!1;if(ee?r.db&&K(`--db ignored: POSTGRES_URL is already set in .env.`):x=r.db?!0:i?await q(`Provision a local Postgres database?`,b):b,x&&b)try{await Me(d),y=!0}catch(e){if(J(d))K(`Postgres is provisioned, but the migration failed; run bun run db:migrate.`);else{let t=e instanceof Error?e.message.trim():String(e);K(`Database setup failed; set POSTGRES_URL in .env yourself.`,t?t.split(`
28
- `).filter(e=>e.trim()).slice(-5):[])}}else x&&K(`Docker isn't running, so the database wasn't provisioned. Set POSTGRES_URL in .env, or start Docker and re-run for automatic setup.`);W([`${A(`packages/config/src/site.ts`)} and ${A(`web/next/content`)}`,`to manage branding and blogs & docs respectively`].join(`
29
- `),`Edit and make it yours`),ve(`${p} is ready`);let S=[];d!==process.cwd()&&S.push(A(`cd ${o}`)),J(d)||S.push(`set POSTGRES_URL in .env`),y||S.push(A(`bun run db:migrate`)),S.push(A(`bun run dev`)),W(S.join(`
30
- `),`Next steps`),V(`Learn more ${z(`https://zerostarter.dev/docs`)}`)},$e=`Usage:
28
+ -h, --help Display help
29
+
30
+ Features (default on, except the waitlist; pass any flag to skip the interactive picker):
31
+ --api-docs, --no-api-docs The /api/docs API reference
32
+ --blog, --no-blog The /blog
33
+ --docs, --no-docs The /docs
34
+ --internal-docs, --no-internal-docs The /console/docs internal docs
35
+ --waitlist, --no-waitlist The /waitlist (off leaves a plain landing home)`,et=e=>!y(e)||ee(e).filter(e=>e!==`.git`).length===0,Q=e=>s(g(e,`packages/config/src/site.ts`)),tt=e=>{let t=e,{root:n}=_(t);for(;;){if(y(g(t,`bun.lock`))||y(g(t,`bun.lockb`)))return t;let e=g(t,`package.json`);if(y(e))try{if(JSON.parse(b(e,`utf8`)).workspaces)return t}catch{}if(t===n)return null;t=h(t)}},nt=async e=>{let{positionals:t,values:n}=qe($e,{allowPositionals:!0,args:e,options:{canary:{type:`boolean`},db:{type:`boolean`},"dry-run":{type:`boolean`},help:{short:`h`,type:`boolean`},yes:{short:`y`,type:`boolean`},"api-docs":{type:`boolean`},"no-api-docs":{type:`boolean`},blog:{type:`boolean`},"no-blog":{type:`boolean`},docs:{type:`boolean`},"no-docs":{type:`boolean`},"internal-docs":{type:`boolean`},"no-internal-docs":{type:`boolean`},waitlist:{type:`boolean`},"no-waitlist":{type:`boolean`}}});if(n.help){console.log($e);return}n[`dry-run`]||await Qe(!!n.yes);let r=B()&&!n.yes,i=n.canary?`canary`:`main`,a=n,o=Z.some(e=>a[e.flag]||a[`no-${e.flag}`]),c={...l};for(let e of Z)c[e.value]=a[`no-${e.flag}`]?!1:a[e.flag]?!0:l[e.value];let u=t[0]??`.`,f=v(u),m=Q(f),_=!m&&!et(f);if(!m&&!n[`dry-run`]){let e=tt(_?process.cwd():h(f));if(e)throw Error(`Cannot scaffold inside an existing project (a workspace was found at ${e}). Run it in a fresh directory outside that project.`)}if(n[`dry-run`]||H(V(`https://zerostarter.dev`)),_){if(!r)throw Error(`Directory is not empty. Run it in an empty directory, or pass a project name: bunx zerostarter init <name>`);let e=await xe(`What should we name your project?`);if(!e)throw Error(`No directory name provided.`);u=e}let y=v(u),b=p(y),ee={name:b},x=`--canary ignored: converting the existing checkout in place, so nothing is fetched.`,te=e=>Z.filter(t=>e[t.value]).map(e=>e.value).join(`, `)||`none`;if(n[`dry-run`]){console.log(`bunx zerostarter init (dry run)`),console.log(` target: ${y}`),console.log(` name: ${b}`),console.log(` mode: ${Q(y)?`in place`:`fetch ${i}`}`),console.log(` features: ${te(c)}`),Q(y)&&n.canary&&console.log(` note: ${x}`);return}if(m&&r&&!await Y(`Convert ${b} in place? This rewrites files and commits.`,!1)){W(`Aborted`);return}if(r&&!o){let e=new Set(await be(`Which optional surfaces should this fork ship with?`,Z.map(e=>({value:e.value,label:e.label,checked:l[e.value]}))));for(let t of Z)c[t.value]=e.has(t.value)}if(Q(y))n.canary&&J(x);else{let e=n.canary?` (canary)`:``;await ve(`Fetching the latest ZeroStarter${e}`,`Fetched the latest ZeroStarter${e}`,()=>Ie(y,i))}s(g(y,`.git`))||(await We(y),await Ke(y,`ci(init): scaffold from zerostarter`),await Ge(y,`main`)),await ve(`Rebranding to ${b}`,`Rebranded to ${b}`,()=>d(y,ee,c)),await Ne(y),await Ke(y,`ci(init): re-baseline as ${b}`),De(y);let S=!1,C=await Ce(),ne=X(y),w=!1;if(ne?n.db&&J(`--db ignored: POSTGRES_URL is already set in .env.`):w=n.db?!0:r?await Y(`Provision a local Postgres database?`,C):C,w&&C)try{await Me(y),S=!0}catch(e){if(X(y))J(`Postgres is provisioned, but the migration failed; run bun run db:migrate.`);else{let t=e instanceof Error?e.message.trim():String(e);J(`Database setup failed; set POSTGRES_URL in .env yourself.`,t?t.split(`
36
+ `).filter(e=>e.trim()).slice(-5):[])}}else w&&J(`Docker isn't running, so the database wasn't provisioned. Set POSTGRES_URL in .env, or start Docker and re-run for automatic setup.`);K([`${M(`packages/config/src/site.ts`)} and ${M(`web/next/content`)}`,`to manage branding and blogs & docs respectively`].join(`
37
+ `),`Edit and make it yours`),_e(`${b} is ready`);let T=[];y!==process.cwd()&&T.push(M(`cd ${u}`)),X(y)||T.push(`set POSTGRES_URL in .env`),S||T.push(M(`bun run db:migrate`)),T.push(M(`bun run dev`)),K(T.join(`
38
+ `),`Next steps`),U(`Learn more ${V(`https://zerostarter.dev/docs`)}`)},rt=`Usage:
31
39
  $ bunx zerostarter reinit [dir] [options]
32
40
 
33
41
  Re-scaffold an existing git repo (default .) as a fresh ZeroStarter: delete every
@@ -37,8 +45,8 @@ branch; push when ready.
37
45
 
38
46
  Options:
39
47
  -y, --yes Skip the confirmation prompt
40
- -h, --help Display help`,et=async e=>{let{positionals:t,values:n}=Z($e,{allowPositionals:!0,args:e,options:{help:{short:`h`,type:`boolean`},yes:{short:`y`,type:`boolean`}}});if(n.help){console.log($e);return}await Q(!!n.yes);let r=_(t[0]??`.`),a=f(r),o=R()&&!n.yes;if(await Ve(r,`No git repository in ${r}. reinit re-scaffolds an existing repo; use init for a new project.`,`Working tree has uncommitted changes. Commit or stash them first; reinit deletes every tracked file.`),B(z(`https://zerostarter.dev`)),o&&!await q(`Delete every file in ${a} (keeping .git and .env*) and re-scaffold?`,!1)){H(`Aborted`);return}await He(r,E(`reinit failed; restored your committed files (deleted gitignored files, except .env*, are gone).`),async()=>{i(r),await Ie(r),G(`Fetched the latest ZeroStarter (kept .git and .env*)`),u(r,{name:a}),G(`Rebranded to ${a}`),await Y(r),De(r),await X(r,`ci(reinit): re-baseline as ${a}`)});let s=[];J(r)||s.push(`set POSTGRES_URL in .env`),s.push(A(`bun run db:migrate`)),s.push(A(`bun run dev`)),s.push(A(`git push`)),W(s.join(`
41
- `),`Next steps`),V(T(`${a} re-scaffolded; .git history, remote, and .env* files are intact`))},tt=`Usage:
48
+ -h, --help Display help`,it=async t=>{let{positionals:n,values:r}=qe(rt,{allowPositionals:!0,args:t,options:{help:{short:`h`,type:`boolean`},yes:{short:`y`,type:`boolean`}}});if(r.help){console.log(rt);return}await Qe(!!r.yes);let i=v(n[0]??`.`),a=p(i),o=B()&&!r.yes;if(await He(i,`No git repository in ${i}. reinit re-scaffolds an existing repo; use init for a new project.`,`Working tree has uncommitted changes. Commit or stash them first; reinit deletes every tracked file.`),H(V(`https://zerostarter.dev`)),o&&!await Y(`Delete every file in ${a} (keeping .git and .env*) and re-scaffold?`,!1)){W(`Aborted`);return}await Ue(i,O(`reinit failed; restored your committed files (deleted gitignored files, except .env*, are gone).`),async()=>{e(i),await Le(i),q(`Fetched the latest ZeroStarter (kept .git and .env*)`),d(i,{name:a}),q(`Rebranded to ${a}`),await Ne(i),De(i),await Ke(i,`ci(reinit): re-baseline as ${a}`)});let s=[];X(i)||s.push(`set POSTGRES_URL in .env`),s.push(M(`bun run db:migrate`)),s.push(M(`bun run dev`)),s.push(M(`git push`)),K(s.join(`
49
+ `),`Next steps`),U(D(`${a} re-scaffolded; .git history, remote, and .env* files are intact`))},at=`Usage:
42
50
  $ bunx zerostarter sync [dir] [options]
43
51
 
44
52
  Re-baseline an existing fork (default .) on the latest ZeroStarter: a gitpick overlay
@@ -47,14 +55,14 @@ identity, and favicon are preserved. Requires a clean tree; lands as a reviewabl
47
55
  you commit yourself.
48
56
 
49
57
  Options:
50
- -h, --help Display help`,nt=async i=>{let{positionals:l,values:u}=Z(tt,{allowPositionals:!0,args:i,options:{help:{short:`h`,type:`boolean`}}});if(u.help){console.log(tt);return}await Q();let d=_(l[0]??`.`);await Ve(d,`No git repository in ${d}. Run sync inside an existing fork.`,`Working tree has uncommitted changes. Commit or stash them first so the sync lands as a reviewable diff.`),B(z(`https://zerostarter.dev`));let f=h(d,`package.json`),p=new Map(s(d).map(e=>[e,t(e)])),m=r(await Le()).preserve;m.length===0&&K(`No PRESERVE_ON_SYNC directive found; fork-owned files may be overwritten.`),await He(d,E(`Sync failed; rolled the working tree back to your last commit.`),async()=>{await Ie(d),o(d),a(h(d,`.gitpickignore`));for(let[r,i]of p)e(r)&&n(r,c(i,t(r),r===f));await ze(d,m)}),G(`Overlaid the latest ZeroStarter (content, public/marketing, and branding preserved)`),await Y(d),W([`Starter files were updated (edits overwritten); your content, public/marketing, and branding were preserved.`,E(`Review the diff and commit: git -C ${d} status`)].join(`
51
- `),`Review the changes`),V(A(`Synced to the latest ZeroStarter`))},{author:rt,name:it,version:at}=ge,ot=`Version:
52
- ${it}@${at}
58
+ -h, --help Display help`,ot=async e=>{let{positionals:t,values:n}=qe(at,{allowPositionals:!0,args:e,options:{help:{short:`h`,type:`boolean`}}});if(n.help){console.log(at);return}await Qe();let l=v(t[0]??`.`);await He(l,`No git repository in ${l}. Run sync inside an existing fork.`,`Working tree has uncommitted changes. Commit or stash them first so the sync lands as a reviewable diff.`),H(V(`https://zerostarter.dev`));let d=g(l,`package.json`),p=new Map(u(l).map(e=>[e,a(e)])),m=c(await Re()).preserve;m.length===0&&J(`No PRESERVE_ON_SYNC directive found; fork-owned files may be overwritten.`),await Ue(l,O(`Sync failed; rolled the working tree back to your last commit.`),async()=>{await Le(l),o(l),f(g(l,`.gitpickignore`));for(let[e,t]of p)s(e)&&r(e,i(t,a(e),e===d));await Be(l,m)}),q(`Overlaid the latest ZeroStarter (content, public/marketing, and branding preserved)`),await Ne(l),K([`Starter files were updated (edits overwritten); your content, public/marketing, and branding were preserved.`,O(`Review the diff and commit: git -C ${l} status`)].join(`
59
+ `),`Review the changes`),U(M(`Synced to the latest ZeroStarter`))},{author:st,name:$,version:ct}=he,lt=`Version:
60
+ ${$}@${ct}
53
61
 
54
62
  Go from zero to a production-ready SaaS, rebranded and ready to ship.
55
63
 
56
64
  Usage:
57
- $ ${it} <command> [options]
65
+ $ ${$} <command> [options]
58
66
 
59
67
  Commands:
60
68
  init [dir] Scaffold ZeroStarter into dir (default .) as a fresh product.
@@ -67,4 +75,4 @@ Options:
67
75
  -h, --help Display help
68
76
 
69
77
  Author:
70
- ${rt.name} <${rt.email}> (${_e(rt.url)})`;(async()=>{try{let e=process.argv.slice(2),t=e[0],n=e.slice(1);switch(t){case`init`:return await Qe(n);case`reinit`:return await et(n);case`sync`:return await nt(n);case void 0:case`-h`:case`--help`:console.log(ot);return;case`-v`:case`--version`:console.log(`${it}@${at}`);return;default:console.error(k(`Unknown command: ${t}\n`)),console.log(ot),process.exit(1)}}catch(e){me(e),process.exit(1)}})();export{};
78
+ ${st.name} <${st.email}> (${ge(st.url)})`;(async()=>{try{let e=process.argv.slice(2),t=e[0],n=e.slice(1);switch(t){case`init`:return await nt(n);case`reinit`:return await it(n);case`sync`:return await ot(n);case void 0:case`-h`:case`--help`:console.log(lt);return;case`-v`:case`--version`:console.log(`${$}@${ct}`);return;default:console.error(j(`Unknown command: ${t}\n`)),console.log(lt),process.exit(1)}}catch(e){pe(e),process.exit(1)}})();export{};
@@ -1,8 +1,17 @@
1
1
  import{dirname as e,join as t}from"node:path";import{existsSync as n,mkdirSync as r,readFileSync as i,readdirSync as a,rmSync as o,writeFileSync as s}from"node:fs";const c=e=>{let t=[],n=[],r=!1;for(let i of e.split(`
2
- `)){let e=i.trim();if(e){if(!r&&e.startsWith(`# PRESERVE_ON_SYNC`)){n=e.slice(18).replace(/^\s*-\s*/,``).split(`,`).map(e=>e.trim()).filter(Boolean),r=!0;continue}e.startsWith(`#`)||t.push(e)}}return{excludes:t,preserve:n}},l=e=>n(e),u=e=>i(e,`utf8`),d=(t,n)=>{r(e(t),{recursive:!0}),s(t,n)},f=e=>{o(e,{force:!0,recursive:!0})},p=new Set([`node_modules`,`.next`,`.turbo`,`dist`]),m=(e,n=!0)=>{for(let r of a(e,{withFileTypes:!0})){let i=t(e,r.name);if(r.name===`.git`){if(n)continue;o(i,{force:!0,recursive:!0});continue}r.isDirectory()?p.has(r.name)?o(i,{force:!0,recursive:!0}):(m(i,!1),a(i).length===0&&o(i,{force:!0,recursive:!0})):r.name.startsWith(`.env`)||o(i,{force:!0})}},h=e=>{let n=[];for(let r of a(e,{withFileTypes:!0})){if(r.name===`.git`||p.has(r.name))continue;let i=t(e,r.name);r.isDirectory()?n.push(...h(i)):r.name===`package.json`&&n.push(i)}return n},g=e=>JSON.parse(u(e)),_=(e,t)=>{d(e,`${JSON.stringify(t,null,2)}\n`)},v=(e,t)=>{if(!n(e))return!1;let r=u(e),i=r.replace(t,``);return i===r?!1:(s(e,i),!0)},y=[`homepage`,`bugs`,`license`,`author`,`repository`,`funding`],b=[`name`,`version`,...y],x=(e,t)=>{let n={...e,...t};return Object.keys(n).length>0?n:void 0},S=(e,t)=>{let n=Array.isArray(e)?e:[],r=Array.isArray(t)?t:[];return n.length||r.length?[...new Set([...r,...n])]:void 0},C=[`dependencies`,`devDependencies`,`optionalDependencies`,`peerDependencies`,`resolutions`,`catalog`,`scripts`,`overrides`],w=(e,t,n)=>{let r={...t};for(let n of Object.keys(e))n in t||(r[n]=e[n]);for(let n of C){let i=x(e[n],t[n]);i&&(r[n]=i)}let i=S(e.workspaces,t.workspaces);if(i&&(r.workspaces=i),n)for(let t of b)t in e?r[t]=e[t]:delete r[t];return r},T=({name:e})=>{let t=e.charAt(0).toUpperCase()+e.slice(1);return`// Brand identity for this app: the single source a fork edits to rebrand. web reads it via lib/config.ts.
2
+ `)){let e=i.trim();if(e){if(!r&&e.startsWith(`# PRESERVE_ON_SYNC`)){n=e.slice(18).replace(/^\s*-\s*/,``).split(`,`).map(e=>e.trim()).filter(Boolean),r=!0;continue}e.startsWith(`#`)||t.push(e)}}return{excludes:t,preserve:n}},l=e=>n(e),u=e=>i(e,`utf8`),d=(t,n)=>{r(e(t),{recursive:!0}),s(t,n)},f=e=>{o(e,{force:!0,recursive:!0})},p=new Set([`node_modules`,`.next`,`.turbo`,`dist`]),m=(e,n=!0)=>{for(let r of a(e,{withFileTypes:!0})){let i=t(e,r.name);if(r.name===`.git`){if(n)continue;o(i,{force:!0,recursive:!0});continue}r.isDirectory()?p.has(r.name)?o(i,{force:!0,recursive:!0}):(m(i,!1),a(i).length===0&&o(i,{force:!0,recursive:!0})):r.name.startsWith(`.env`)||o(i,{force:!0})}},h=e=>{let n=[];for(let r of a(e,{withFileTypes:!0})){if(r.name===`.git`||p.has(r.name))continue;let i=t(e,r.name);r.isDirectory()?n.push(...h(i)):r.name===`package.json`&&n.push(i)}return n},g=e=>JSON.parse(u(e)),_=(e,t)=>{d(e,`${JSON.stringify(t,null,2)}\n`)},v=(e,t)=>{if(!n(e))return!1;let r=u(e),i=r.replace(t,``);return i===r?!1:(s(e,i),!0)},y=[`homepage`,`bugs`,`license`,`author`,`repository`,`funding`],b=[`name`,`version`,...y],x=(e,t)=>{let n={...e,...t};return Object.keys(n).length>0?n:void 0},S=(e,t)=>{let n=Array.isArray(e)?e:[],r=Array.isArray(t)?t:[];return n.length||r.length?[...new Set([...r,...n])]:void 0},C=[`dependencies`,`devDependencies`,`optionalDependencies`,`peerDependencies`,`resolutions`,`catalog`,`scripts`,`overrides`],w=(e,t,n)=>{let r={...t};for(let n of Object.keys(e))n in t||(r[n]=e[n]);for(let n of C){let i=x(e[n],t[n]);i&&(r[n]=i)}let i=S(e.workspaces,t.workspaces);if(i&&(r.workspaces=i),n)for(let t of b)t in e?r[t]=e[t]:delete r[t];return r},T={apiDocs:!0,blog:!0,docs:!0,internalDocs:!0,waitlist:!1},E=e=>`// Optional surfaces a fork enables or disables. Typed boolean (not \`as const\`) so a fork can flip them and the runtime gates are not dead code. Off means the routes 404 and the links, nav, sitemap, llms, and search drop the surface. waitlist off makes the home a plain landing page.
3
+ export const features = {
4
+ apiDocs: ${e.apiDocs},
5
+ blog: ${e.blog},
6
+ docs: ${e.docs},
7
+ internalDocs: ${e.internalDocs},
8
+ waitlist: ${e.waitlist},
9
+ }
10
+
11
+ export type Feature = keyof typeof features`,D=({name:e},t=T)=>{let n=e.charAt(0).toUpperCase()+e.slice(1);return`// Brand identity for this app: the single source a fork edits to rebrand. web reads it via lib/config.ts.
3
12
  export const site = {
4
- name: "${t}",
5
- description: "${t} is just getting started. Tell its story here.",
13
+ name: "${n}",
14
+ description: "${n} is just getting started. Tell its story here.",
6
15
  tagline: "Your tagline, ready when you are.",
7
16
  social: {
8
17
  github: "",
@@ -20,13 +29,25 @@ export const site = {
20
29
  } as const
21
30
 
22
31
  export type Site = typeof site
23
- `},E=()=>`import { redirect } from "next/navigation"
24
32
 
25
- // Fresh fork: redirect to the waitlist until you build your real home page.
33
+ ${E(t)}
34
+ `},O=()=>`import { features, site } from "@packages/config/site"
35
+ import { redirect } from "next/navigation"
36
+
37
+ // Fresh fork: the waitlist capture when the waitlist feature is on, otherwise a plain landing page. Replace this with your real home when ready.
26
38
  export default function Home() {
27
- redirect("/waitlist")
39
+ if (features.waitlist) redirect("/waitlist")
40
+
41
+ return (
42
+ <main className="flex min-h-svh flex-col items-center justify-center p-8 text-center">
43
+ <div className="mx-auto flex w-full max-w-xl flex-col items-center">
44
+ <h1 className="mb-4 text-5xl font-bold tracking-tight sm:text-6xl">{site.name}</h1>
45
+ <p className="text-muted-foreground max-w-md text-lg">{site.tagline}</p>
46
+ </div>
47
+ </main>
48
+ )
28
49
  }
29
- `,D=()=>'# AGENTS.md\n\nGuidance for AI coding agents working in this repository.\n\n## Instructions\n\n- ALWAYS: Use `@/` for imports, and follow the `design` skill for UI and styling conventions.\n- ALWAYS: Keep documentation in sync with every change.\n- NEVER: Include "Co-authored-by" in commit messages.\n- NEVER: Use em-dashes (the long dash, U+2014) in code, comments, docs, or copy. Regular hyphens are fine; for a pause or aside, use a comma, colon, or period.\n\n## Skills\n\nCustom skills live in `.agents/skills` (symlinked to `.claude/skills`). Start with the `codebase-map` skill to orient, then load the task skill that fits (`api-endpoint`, `db-migration`, `dev`, `design`, and more).\n',O=({name:e})=>`# ${e.charAt(0).toUpperCase()+e.slice(1)}
50
+ `,k=()=>'# AGENTS.md\n\nGuidance for AI coding agents working in this repository.\n\n## Instructions\n\n- ALWAYS: Use `@/` for imports, and follow the `design` skill for UI and styling conventions.\n- ALWAYS: Keep documentation in sync with every change.\n- NEVER: Include "Co-authored-by" in commit messages.\n- NEVER: Use em-dashes (the long dash, U+2014) in code, comments, docs, or copy. Regular hyphens are fine; for a pause or aside, use a comma, colon, or period.\n\n## Skills\n\nCustom skills live in `.agents/skills` (symlinked to `.claude/skills`). Start with the `codebase-map` skill to orient, then load the task skill that fits (`api-endpoint`, `db-migration`, `dev`, `design`, and more).\n',A=({name:e})=>`# ${e.charAt(0).toUpperCase()+e.slice(1)}
30
51
 
31
52
  Built on top of [ZeroStarter](https://zerostarter.dev).
32
53
 
@@ -37,7 +58,7 @@ bun run dev
37
58
  \`\`\`
38
59
 
39
60
  Web runs on http://localhost:3000 and the API on http://localhost:4000.
40
- `,k=()=>`---
61
+ `,j=()=>`---
41
62
  slug: /docs
42
63
  title: Introduction
43
64
  description: Documentation.
@@ -46,7 +67,7 @@ description: Documentation.
46
67
  # Introduction
47
68
 
48
69
  This is your documentation home. Start writing, this page is yours.
49
- `,A=()=>`---
70
+ `,M=()=>`---
50
71
  slug: /console/docs
51
72
  title: Introduction
52
73
  description: Internal documentation.
@@ -55,7 +76,7 @@ description: Internal documentation.
55
76
  # Introduction
56
77
 
57
78
  Your team's internal docs live here.
58
- `,j=e=>`---
79
+ `,N=e=>`---
59
80
  title: Blog
60
81
  description: Latest articles and updates
61
82
  createdAt: ${e}
@@ -64,7 +85,7 @@ createdAt: ${e}
64
85
  ## Recent Posts
65
86
 
66
87
  <BlogPostList />
67
- `,M=e=>`---
88
+ `,P=e=>`---
68
89
  title: Hello World
69
90
  description: The first post on your new blog.
70
91
  createdAt: ${e}
@@ -74,7 +95,7 @@ publishedAt: ${e}
74
95
  ## Hello World
75
96
 
76
97
  Your very first post. Replace it with something worth reading.
77
- `,N=()=>`import type { DocsConfig } from "./src/lib/docs"
98
+ `,F=()=>`import type { DocsConfig } from "./src/lib/docs"
78
99
 
79
100
  const docsConfig = {
80
101
  docs: {
@@ -100,4 +121,4 @@ const docsConfig = {
100
121
  } satisfies DocsConfig
101
122
 
102
123
  export default docsConfig
103
- `,P=(e,...n)=>t(e,...n),F=e=>e.toLowerCase().replace(/[^a-z0-9]+/g,`-`).replace(/^-+|-+$/g,``)||`app`,I=e=>{let t=P(e,`.gitpickignore`);if(l(t)){for(let n of c(u(t)).excludes){if(/[*?![\]]/.test(n))throw Error(`.gitpickignore entry "${n}" is not a literal path; the in-place converter only supports literal paths (a glob or negation would diverge from gitpick's fetch).`);f(P(e,n))}f(t)}},L=/[ \t]*\{[^}\r\n]*href:[ \t]*["']\/hire["'][^}\r\n]*\},?[ \t]*\r?\n/,R=(e,t)=>{let n=new Date,r=n.toISOString().slice(0,10),i=[n.getFullYear(),n.getMonth()+1,n.getDate()].map(e=>String(e).padStart(2,`0`)).join(`-`),a=i<r?i:r;d(P(e,`web/next/content/docs/index.mdx`),k()),d(P(e,`web/next/content/blog/index.mdx`),j(a)),d(P(e,`web/next/content/blog/hello-world.mdx`),M(a)),d(P(e,`web/next/content/console/docs/index.mdx`),A()),d(P(e,`web/next/docs.config.ts`),N()),d(P(e,`web/next/public/.gitkeep`),``),d(P(e,`web/next/src/app/page.tsx`),E()),d(P(e,`AGENTS.md`),D()),d(P(e,`README.md`),O(t))},z=e=>{let t=P(e,`web/next/src/lib/fonts.ts`),n=P(e,`web/next/src/lib/marketing/fonts.ts`),r=P(e,`web/next/src/components/common/navbar.tsx`);if(v(r,L),l(n))throw Error(`web/next/src/lib/marketing/fonts.ts survived the fork strip (add web/next/src/lib/marketing/ to .gitpickignore).`);if(l(t)&&u(t).includes(`fonts/marketing/`))throw Error(`fonts.ts references fonts/marketing/; author-only marketing fonts must live in the fork-excluded web/next/src/lib/marketing/, not the shared fonts.ts.`);if(l(r)&&/href:\s*["']\/hire["']/.test(u(r)))throw Error(`common/navbar.tsx still has the /hire entry after fixDangling (regex drift). Update packages/cli/src/convert.ts.`)},B=(e,t)=>{d(P(e,`packages/config/src/site.ts`),T(t));let n=P(e,`package.json`),r=g(n);r.name=F(t.name),r.version=`0.0.0`;for(let e of y)delete r[e];_(n,r)},V=(e,t)=>{I(e),R(e,t),z(e),B(e,t)};export{l as a,g as c,_ as d,c as f,m as i,f as l,z as n,h as o,w as r,u as s,V as t,d as u};
124
+ `,I=(e,...n)=>t(e,...n),L=e=>e.toLowerCase().replace(/[^a-z0-9]+/g,`-`).replace(/^-+|-+$/g,``)||`app`,R=e=>{let t=I(e,`.gitpickignore`);if(l(t)){for(let n of c(u(t)).excludes){if(/[*?![\]]/.test(n))throw Error(`.gitpickignore entry "${n}" is not a literal path; the in-place converter only supports literal paths (a glob or negation would diverge from gitpick's fetch).`);f(I(e,n))}f(t)}},z=/[ \t]*\{[^}\r\n]*href:[ \t]*["']\/hire["'][^}\r\n]*\},?[ \t]*\r?\n/,B=(e,t)=>{let n=new Date,r=n.toISOString().slice(0,10),i=[n.getFullYear(),n.getMonth()+1,n.getDate()].map(e=>String(e).padStart(2,`0`)).join(`-`),a=i<r?i:r;d(I(e,`web/next/content/docs/index.mdx`),j()),d(I(e,`web/next/content/blog/index.mdx`),N(a)),d(I(e,`web/next/content/blog/hello-world.mdx`),P(a)),d(I(e,`web/next/content/console/docs/index.mdx`),M()),d(I(e,`web/next/docs.config.ts`),F()),d(I(e,`web/next/public/.gitkeep`),``),d(I(e,`web/next/src/app/page.tsx`),O()),d(I(e,`AGENTS.md`),k()),d(I(e,`README.md`),A(t))},V=e=>{let t=I(e,`web/next/src/lib/fonts.ts`),n=I(e,`web/next/src/lib/marketing/fonts.ts`),r=I(e,`web/next/src/components/common/navbar.tsx`);if(v(r,z),l(n))throw Error(`web/next/src/lib/marketing/fonts.ts survived the fork strip (add web/next/src/lib/marketing/ to .gitpickignore).`);if(l(t)&&u(t).includes(`fonts/marketing/`))throw Error(`fonts.ts references fonts/marketing/; author-only marketing fonts must live in the fork-excluded web/next/src/lib/marketing/, not the shared fonts.ts.`);if(l(r)&&/href:\s*["']\/hire["']/.test(u(r)))throw Error(`common/navbar.tsx still has the /hire entry after fixDangling (regex drift). Update packages/cli/src/convert.ts.`)},H=(e,t,n)=>{d(I(e,`packages/config/src/site.ts`),D(t,n));let r=I(e,`package.json`),i=g(r);i.name=L(t.name),i.version=`0.0.0`;for(let e of y)delete i[e];_(r,i)},U=(e,t,n=T)=>{R(e),B(e,t),V(e),H(e,t,n)};export{m as a,u as c,d,_ as f,w as i,g as l,V as n,l as o,c as p,T as r,h as s,U as t,f as u};
package/dist/index.d.mts CHANGED
@@ -2,8 +2,15 @@
2
2
  interface Brand {
3
3
  name: string;
4
4
  }
5
+ type FeatureFlags = {
6
+ apiDocs: boolean;
7
+ blog: boolean;
8
+ docs: boolean;
9
+ internalDocs: boolean;
10
+ waitlist: boolean;
11
+ };
5
12
  //#endregion
6
13
  //#region src/convert.d.ts
7
- declare const convertRepo: (root: string, brand: Brand) => void;
14
+ declare const convertRepo: (root: string, brand: Brand, features?: FeatureFlags) => void;
8
15
  //#endregion
9
16
  export { type Brand, convertRepo };
package/dist/index.mjs CHANGED
@@ -1 +1 @@
1
- import{t as e}from"./convert-HXDPuaZU.mjs";export{e as convertRepo};
1
+ import{t as e}from"./convert-DHCJQjgd.mjs";export{e as convertRepo};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "zerostarter",
3
- "version": "0.1.2",
3
+ "version": "0.1.3-canary.0",
4
4
  "description": "Go from zero to a production-ready SaaS, rebranded and ready to ship.",
5
5
  "keywords": [
6
6
  "cli",