zerostarter 0.0.0-93a2b9d → 0.0.0-b1bc340

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/bin/index.mjs +22 -20
  2. package/package.json +1 -1
@@ -1,12 +1,16 @@
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-DMU8fiBc.mjs";import{basename as f,delimiter as p,join as m,resolve as h}from"node:path";import{existsSync as g,readdirSync as _}from"node:fs";import{createInterface as v}from"node:readline/promises";import{parseArgs as y}from"node:util";import{randomBytes as b}from"node:crypto";import{spawn as ee}from"node:child_process";import{access as te}from"node:fs/promises";import{homedir as ne}from"node:os";var re={name:`zerostarter`,version:`0.0.0-93a2b9d`,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 x=()=>!!(process.stdin.isTTY&&process.stdout.isTTY),ie=(e,t=e)=>process.stdout.isTTY?`\x1b]8;;${e}\x07${t}\x1b]8;;\x07`:e,S=(e,t=process.stdout)=>n=>t.isTTY?`\x1b[${e}m${n}\x1b[0m`:n,C=S(`38;5;208`),w=S(`38;2;63;185;80`),T=S(`38;2;210;153;34`),E=S(`38;2;248;81;73`,process.stderr),ae=async(e,t=``)=>{let n=v({input:process.stdin,output:process.stdout});try{return(await n.question(`${e}${t?` (${t})`:``}: `)).trim()||t}finally{n.close()}},D=async(e,t=!0)=>{let n=v({input:process.stdin,output:process.stdout});try{let r=(await n.question(`${e} (${t?`Y/n`:`y/N`}) `)).trim().toLowerCase();return r?r===`y`||r===`yes`:t}finally{n.close()}};var oe=class extends Error{constructor(...e){super(...e),this.name=`SubprocessError`,this.stdout=``,this.stderr=``}};const O=[`.exe`,`.com`],k=e=>e.replaceAll(/([()\][%!^"`<>&|;, *?])/g,`^$1`),se=e=>k(k(`"${e.replaceAll(/(\\*)"/g,`$1$1\\"`).replace(/(\\*)$/,`$1$1`)}"`)),ce=async(e,t,n)=>{if(O.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=>O.map(n=>te(`${h(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)?[k(e),t.map(se),{...n,shell:!0}]:[e,t,n]},A=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 oe(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})})})},j=async(e,t,n)=>{let{stdout:r}=await A(e,t,{cwd:n,stdio:[`ignore`,`pipe`,`pipe`]});return r},M=async(e,t,n)=>{await A(e,t,{cwd:n,stdio:`inherit`})},N=async(e,t)=>{try{return await A(e,t,{stdio:`ignore`}),!0}catch{return!1}},ue=RegExp(`\x1B\\[[0-9;?]*[a-zA-Z]`,`g`),de=e=>e.replace(ue,``),P=e=>e>=1e3?`[${(e/1e3).toFixed(2)}s]`:`[${e.toFixed(2)}ms]`,F=async(e,t,n)=>{let r=Date.now();if(!process.stdout.isTTY){await M(e,t,n.cwd);return}let i=n.lines??3,a=[],o=0,s=``,c=``,l=()=>(process.stdout.columns||80)-1,u=e=>{process.stdout.write(e?`\x1B[?7h`:`\x1B[?7l`)},d=()=>{o>0&&(process.stdout.write(`[${o}A`),o=0)},f=()=>{d();let e=a.slice(-i);for(let t of e)process.stdout.write(`${t.slice(0,l())}\n`);o=e.length},p=e=>{c+=e,s+=e;let t=s.split(`
3
- `);s=t.pop()??``;for(let e of t)a.push(de(e).replace(/\r/g,``).replace(/\t/g,` `).trimEnd()),f()};u(!1);try{await A(e,t,{cwd:n.cwd,stdio:[`ignore`,`pipe`,`pipe`]},p)}catch(e){throw d(),u(!0),process.stdout.write(c),e}d(),u(!0);let m=n.summarize(c,Date.now()-r).trim();m&&(console.log(),console.log(m))},I=`pglaunch@5.5.7`,fe=async()=>N(`docker`,[`info`]),L=e=>{let r=m(e,`.env`);if(!s(r)){let i=m(e,`.env.example`);n(r,s(i)?t(i):``)}return r},R=(e,n)=>{let r=`${n}=`,i=t(e).split(`
4
- `).find(e=>e.startsWith(r));return i?i.slice(r.length).trim():``},z=(e,r,i)=>{let a=`${r}=`,o=t(e).split(`
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-DMU8fiBc.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 x}from"node:child_process";import{access as ee}from"node:fs/promises";import{createInterface as te}from"node:readline/promises";import{randomBytes as ne}from"node:crypto";import{parseArgs as re}from"node:util";import{homedir as ie}from"node:os";const S=(e,t,n=process.stdout)=>r=>n.isTTY?`\x1b[${e}m${r}\x1b[${t}m`:r,C=S(`36`,`39`),w=S(`32`,`39`),T=S(`33`,`39`),E=S(`90`,`39`),D=S(`2`,`22`),O=S(`31`,`39`,process.stderr),k=S(`38;5;208`,`39`),A=[`◆`,`◇`],j={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`],M=e=>e.replaceAll(/([()\][%!^"`<>&|;, *?])/g,`^$1`),se=e=>M(M(`"${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=>ee(`${_(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)?[M(e),t.map(se),{...n,shell:!0}]:[e,t,n]},N=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=x(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})})})},P=async(e,t,n)=>{let{stdout:r}=await N(e,t,{cwd:n,stdio:[`ignore`,`pipe`,`pipe`]});return r},ue=async(e,t,n)=>{await N(e,t,{cwd:n,stdio:`inherit`})},F=async(e,t)=>{try{return await N(e,t,{stdio:`ignore`}),!0}catch{return!1}},de=RegExp(`\x1B\\[[0-9;?]*[a-zA-Z]`,`g`),fe=e=>e.replace(de,``),pe=e=>e>=1e3?`[${(e/1e3).toFixed(2)}s]`:`[${e.toFixed(2)}ms]`,me=new WeakSet,he=e=>{if(process.stderr.write(`\n ${O(e instanceof Error?e.message:String(e))}\n`),!(e instanceof ae)||me.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(` ${D(e)}\n`)},ge=async(e,t,n)=>{let r=Date.now(),i=process.stdout,a=n.label??``;if(!i.isTTY){a&&i.write(` ${C(j.active)} ${a}\n`),await ue(e,t,n.cwd);return}let o=n.lines??3,s=[],c=0,l=0,u=``,d=``,f=()=>(i.columns||80)-1,p=e=>{i.write(e?`\x1B[?7h`:`\x1B[?7l`)},m=()=>{l>0&&(i.write(`[${l}A`),l=0)},h=()=>{m();let e=0;if(i.write(` ${C(A[c])} ${a}\n`),e++,s.length){i.write(` ${E(j.bar)}\n`),e++;for(let t of s.slice(-o))i.write(` ${E(j.bar)} ${D(t.slice(0,Math.max(0,f()-5)))}\n`),e++}l=e},g=e=>{d+=e,u+=e;let t=u.split(`
4
+ `);u=t.pop()??``;for(let e of t)s.push(fe(e).replace(/\r/g,``).replace(/\t/g,` `).trimEnd()),h()};h(),p(!1);let _=()=>{p(!0),process.exit(130)};process.once(`SIGINT`,_);let v=setInterval(()=>{c=(c+1)%A.length,h()},400),y=()=>{clearInterval(v),process.removeListener(`SIGINT`,_)};try{await N(e,t,{cwd:n.cwd,stdio:[`ignore`,`pipe`,`pipe`]},g)}catch(e){throw y(),m(),p(!0),i.write(d),e&&typeof e==`object`&&me.add(e),e}y(),m(),p(!0);let b=n.summarize(d,Date.now()-r).trim();i.write(` ${C(j.active)} ${b||a}\n`);let x=s.slice(-o);if(x.length){i.write(` ${E(j.bar)}\n`);for(let e of x)i.write(` ${E(j.bar)} ${D(e.slice(0,Math.max(0,f()-5)))}\n`)}};var _e={name:`zerostarter`,version:`0.0.0-b1bc340`,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 I=()=>!!(process.stdin.isTTY&&process.stdout.isTTY),ve=(e,t=e)=>process.stdout.isTTY?`\x1b]8;;${e}\x07${t}\x1b]8;;\x07`:e,L=e=>ve(e,C(e)),R=e=>{process.stdout.write(`\n ${E(j.barStart)} ${e}\n`)},z=e=>{process.stdout.write(` ${E(j.barEnd)} ${e}\n`)},B=(e=`Cancelled`)=>{process.stdout.write(` ${E(j.barEnd)} ${O(e)}\n`)},V=e=>e.replace(RegExp(`\x1B\\[[0-9;?]*[a-zA-Z]`,`g`),``).replace(RegExp(`\x1B\\]8;;.*?\\x07`,`g`),``).length,H=(e,t=``,n=!1)=>{let r=`\n${e}\n`.split(`
5
+ `),i=V(t),a=r.reduce((e,t)=>Math.max(e,V(t)),i),o=Math.max(a,54)+2,s=r.map(e=>` ${E(j.bar)} ${e}${` `.repeat(o-V(e))}${E(j.bar)}`).join(`
6
+ `),c=n?j.cornerBL:j.connectL;process.stdout.write(` ${C(j.active)} ${t} ${E(j.barH.repeat(Math.max(o-i-1,1))+j.cornerTR)}\n${s}\n ${E(c+j.barH.repeat(o+2)+j.cornerBR)}\n`)},U=(e,t=[])=>{process.stdout.write(` ${C(j.active)} ${e}\n`);for(let e of t)process.stdout.write(` ${E(j.bar)} ${e}\n`)},ye=e=>{process.stdout.write(` ${w(j.active)} ${w(e)}\n`)},W=(e,t=[])=>{process.stdout.write(` ${T(j.warn)} ${T(e)}\n`);for(let e of t)process.stdout.write(` ${E(j.bar)} ${T(e)}\n`)},be=async(e,t,n)=>{let r=process.stdout,i=null;if(r.isTTY){let t=0;r.write(` ${C(A[0])} ${e}`),i=setInterval(()=>{t=(t+1)%A.length,r.write(`\r ${C(A[t])} ${e}`)},400)}try{let e=await n();return i&&clearInterval(i),r.write(r.isTTY?`\r\x1b[K ${C(j.active)} ${t}\n`:` ${C(j.active)} ${t}\n`),e}catch(e){throw i&&clearInterval(i),r.isTTY&&r.write(`\r\x1B[K`),e}},xe=e=>{let t=e?`${w(j.radioOn)} Yes`:D(`${j.radioOff} Yes`),n=e?D(`${j.radioOff} No`):`${w(j.radioOn)} No`;return` ${E(j.bar)} ${t} ${D(`/`)} ${n}`},G=async(e,t=!0)=>{let n=process.stdout;return I()?new Promise(r=>{let i=t,a=process.stdin,o=Math.max(1,Math.ceil((5+V(e))/(n.columns||80)));n.write(` ${C(j.active)} ${e}\n`),n.write(xe(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(),n.write(` ${C(j.active)} ${e} ${D(i?`Yes`:`No`)}\n`),r(i)};function u(t){t===``?(s(),c(),n.write(` ${D(j.active)} ${D(e)}\n`),B(),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${xe(i)}`))}a.on(`data`,u)}):(n.write(` ${C(j.active)} ${e} ${D(t?`Yes`:`No`)}\n`),t)},Se=async(e,t=``)=>{process.stdout.write(` ${C(j.active)} ${e}${t?` ${D(`(${t})`)}`:``}\n`);let n=te({input:process.stdin,output:process.stdout});try{return(await n.question(` ${E(j.bar)} `)).trim()||t}finally{n.close()}},Ce=`pglaunch@5.5.7`,we=async()=>F(`docker`,[`info`]),Te=e=>{let r=h(e,`.env`);if(!s(r)){let i=h(e,`.env.example`);n(r,s(i)?t(i):``)}return r},Ee=(e,n)=>{let r=`${n}=`,i=t(e).split(`
8
+ `).find(e=>e.startsWith(r));return i?i.slice(r.length).trim():``},De=(e,r,i)=>{let a=`${r}=`,o=t(e).split(`
5
9
  `),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(`
6
- `))},B=e=>{let t=L(e);R(t,`BETTER_AUTH_SECRET`)||z(t,`BETTER_AUTH_SECRET`,b(32).toString(`base64`))},V=e=>{let t=m(e,`.env`);return s(t)&&R(t,`POSTGRES_URL`)!==``},pe=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]:``}},H=async(e,t)=>{let n=t?[`--bun`,I,`-k`,`-c`]:[`--bun`,I,`-k`],r;try{r=await j(`bunx`,n,e)}catch(e){let t=e;r=[t.stdout,t.stderr].filter(Boolean).join(`
7
- `)}return pe(r)},me=e=>new Promise(t=>setTimeout(t,e)),he=async e=>{if(e)for(let t=0;t<30;t++){if(await N(`docker`,[`exec`,e,`pg_isready`,`-U`,`postgres`]))return;await me(1e3)}},ge=async e=>{let t=L(e),n=await H(e,!1)||await H(e,!0);if(!n)throw Error(`pglaunch did not print a connection URL`);z(t,`POSTGRES_URL`,n.url),await he(n.container);let r=_e(e);await F(`bun`,[`run`,`db:migrate`],{cwd:e,summarize:(e,t)=>e.includes(`migrations applied successfully`)?`${r} migration${r===1?``:`s`} applied ${P(t)}`:`Database migrated ${P(t)}`})},_e=e=>{try{return _(m(e,`packages/db/drizzle`)).filter(e=>e.endsWith(`.sql`)).length}catch{return 0}},U=async e=>{await F(`bun`,[`install`],{cwd:e,summarize:e=>(e.match(/[\d,]+ packages installed[^\n]*/g)??e.match(/Checked [^\n]*install[^\n]*/g))?.at(-1)?.trim()??`Dependencies installed.`})},ve=async()=>{if(!await N(`bun`,[`--version`]))throw Error(`bun is not on PATH`)},W=async(e=ve,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}},ye=async(e,t=`main`)=>{await j(`bunx`,[`--bun`,`gitpick@6.0.0`,`https://github.com/nrjdalal/zerostarter/tree/${t}`,e])},G=async(e,t=`main`)=>{await j(`bunx`,[`--bun`,`gitpick@6.0.0`,`https://github.com/nrjdalal/zerostarter/tree/${t}`,e,`-o`])},be=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()},xe=async e=>(await j(`git`,[`status`,`--porcelain`],e)).trim()===``,Se=async(e,t)=>{for(let n of t)try{await j(`git`,[`checkout`,`--`,n],e),await j(`git`,[`clean`,`-fd`,`--`,n],e)}catch{}},Ce=async e=>{await j(`git`,[`reset`,`--hard`,`HEAD`],e),await j(`git`,[`clean`,`-fd`],e)},K=async(e,t,n)=>{if(!s(m(e,`.git`)))throw Error(t);if(!await xe(e))throw Error(n)},q=async(e,t,n)=>{try{await n()}catch(n){throw await Ce(e),console.log(t),n}},we=async e=>{await j(`git`,[`init`,`-q`,`-b`,`canary`],e)},Te=async(e,t)=>{await j(`git`,[`branch`,t],e)},J=async(e,t)=>{await j(`git`,[`add`,`-A`],e);try{await j(`git`,[`commit`,`--no-verify`,`-q`,`-m`,t],e)}catch{}},Ee=(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`,De=(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`]},Oe=(e=process.argv.slice(2))=>[`zerostarter`,...e].join(` `),ke=()=>m(process.env.BUN_INSTALL||m(ne(),`.bun`),`bin`),Y=async(e=!1)=>{if(await W())return;let t=Ee(),n=`bunx --bun ${Oe()}`;if(console.error(E(`Seems like you are using ${t===`unknown`?`npx/pnpx`:t} or Windows, try using:`)),console.error(C(` ${n}`)),console.error(``),e||x()&&await D(`Or install bun now and continue?`,!0)){let{cmd:e,args:t}=De();console.error(`Installing bun from https://bun.sh/install ...`);try{if(await M(e,t),process.env.PATH=`${ke()}${p}${process.env.PATH||``}`,await W())return;console.error(E(`
8
- bun is installed but isn't on this shell's PATH yet. Open a new terminal and re-run:`)),console.error(C(` ${n}`))}catch{console.error(E(`
9
- Could not install bun. Install it from https://bun.sh, then re-run:`)),console.error(C(` ${n}`))}}process.exit(1)},Ae=e=>!g(e)||_(e).filter(e=>e!==`.git`).length===0,X=e=>s(m(e,`packages/config/src/site.ts`)),je=async e=>{let{positionals:t,values:n}=y({allowPositionals:!0,args:e,options:{db:{type:`boolean`},"dry-run":{type:`boolean`},help:{short:`h`,type:`boolean`},yes:{short:`y`,type:`boolean`}}});if(n.help){console.log(`Usage:
10
+ `))},Oe=e=>{let t=Te(e);Ee(t,`BETTER_AUTH_SECRET`)||De(t,`BETTER_AUTH_SECRET`,ne(32).toString(`base64`))},K=e=>{let t=h(e,`.env`);return s(t)&&Ee(t,`POSTGRES_URL`)!==``},ke=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]:``}},Ae=async(e,t)=>{let n=t?[`--bun`,Ce,`-k`,`-c`]:[`--bun`,Ce,`-k`],r;try{r=await P(`bunx`,n,e)}catch(e){let t=e;r=[t.stdout,t.stderr].filter(Boolean).join(`
11
+ `)}return{launch:ke(r),out:r}},je=e=>new Promise(t=>setTimeout(t,e)),Me=async e=>{if(e)for(let t=0;t<30;t++){if(await F(`docker`,[`exec`,e,`pg_isready`,`-U`,`postgres`]))return;await je(1e3)}},Ne=async e=>{let t=Te(e),n=await Ae(e,!1),r=n.launch?n:await Ae(e,!0);if(!r.launch)throw Error(r.out.trim()||`pglaunch did not print a connection URL`);De(t,`POSTGRES_URL`,r.launch.url),await Me(r.launch.container);let i=Pe(e);await ge(`bun`,[`run`,`db:migrate`],{cwd:e,label:`Provisioning the database`,summarize:(e,t)=>e.includes(`migrations applied successfully`)?`${i} migration${i===1?``:`s`} applied ${pe(t)}`:`Database migrated ${pe(t)}`})},Pe=e=>{try{return b(h(e,`packages/db/drizzle`)).filter(e=>e.endsWith(`.sql`)).length}catch{return 0}},q=async e=>{await ge(`bun`,[`install`],{cwd:e,label:`Installing dependencies`,summarize:e=>(e.match(/[\d,]+ packages installed[^\n]*/g)??e.match(/Checked [^\n]*install[^\n]*/g))?.at(-1)?.trim()??`Dependencies installed`})},Fe=async()=>{if(!await F(`bun`,[`--version`]))throw Error(`bun is not on PATH`)},Ie=async(e=Fe,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}},Le=async(e,t=`main`)=>{await P(`bunx`,[`--bun`,`gitpick@6.0.0`,`https://github.com/nrjdalal/zerostarter/tree/${t}`,e])},Re=async(e,t=`main`)=>{await P(`bunx`,[`--bun`,`gitpick@6.0.0`,`https://github.com/nrjdalal/zerostarter/tree/${t}`,e,`-o`])},ze=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()},Be=async e=>(await P(`git`,[`status`,`--porcelain`],e)).trim()===``,Ve=async(e,t)=>{for(let n of t)try{await P(`git`,[`checkout`,`--`,n],e),await P(`git`,[`clean`,`-fd`,`--`,n],e)}catch{}},He=async e=>{await P(`git`,[`reset`,`--hard`,`HEAD`],e),await P(`git`,[`clean`,`-fd`],e)},Ue=async(e,t,n)=>{if(!s(h(e,`.git`)))throw Error(t);if(!await Be(e))throw Error(n)},We=async(e,t,n)=>{try{await n()}catch(n){throw await He(e),console.log(t),n}},Ge=async e=>{await P(`git`,[`init`,`-q`,`-b`,`canary`],e)},Ke=async(e,t)=>{await P(`git`,[`branch`,t],e)},J=async(e,t)=>{await P(`git`,[`add`,`-A`],e);try{await P(`git`,[`commit`,`--no-verify`,`-q`,`-m`,t],e)}catch{}},Y=(e,t)=>{try{return re(t)}catch(t){process.stderr.write(`${O(t instanceof Error?t.message:String(t))}\n\n`),process.stdout.write(`${e}\n`),process.exit(1)}},qe=(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`,Je=(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`]},Ye=(e=process.argv.slice(2))=>[`zerostarter`,...e].join(` `),Xe=()=>h(process.env.BUN_INSTALL||h(ie(),`.bun`),`bin`),X=async(e=!1)=>{if(await Ie())return;let t=qe(),n=`bunx --bun ${Ye()}`;if(console.error(O(`Seems like you are using ${t===`unknown`?`npx/pnpx`:t} or Windows, try using:`)),console.error(k(` ${n}`)),console.error(``),e||I()&&await G(`Or install bun now and continue?`,!0)){let{cmd:e,args:t}=Je();console.error(`Installing bun from https://bun.sh/install ...`);try{if(await ue(e,t),process.env.PATH=`${Xe()}${p}${process.env.PATH||``}`,await Ie())return;console.error(O(`
12
+ bun is installed but isn't on this shell's PATH yet. Open a new terminal and re-run:`)),console.error(k(` ${n}`))}catch{console.error(O(`
13
+ Could not install bun. Install it from https://bun.sh, then re-run:`)),console.error(k(` ${n}`))}}process.exit(1)},Ze=`Usage:
10
14
  $ bunx zerostarter init [dir] [options]
11
15
 
12
16
  Scaffold ZeroStarter into dir (default .) as a fresh product. The author's
@@ -19,14 +23,10 @@ Options:
19
23
  -y, --yes Skip prompts, taking defaults (provisions Postgres when Docker is running)
20
24
  --db Provision a local Postgres (pglaunch) and migrate; needs Docker
21
25
  --dry-run Print the plan without writing anything
22
- -h, --help Display help`);return}n[`dry-run`]||await Y(!!n.yes);let r=x()&&!n.yes,i=t[0]??`.`,a=h(i),o=X(a);if(!o&&!Ae(a)){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 ae(`Directory isn't empty. Project name`);if(!e)throw Error(`No directory name provided.`);i=e}let c=h(i),l=f(c),d={name:l};if(n[`dry-run`]){console.log(`bunx zerostarter init (dry run)`),console.log(` target: ${c}`),console.log(` name: ${l}`),console.log(` mode: ${X(c)?`in place`:`fetch first`}`);return}if(o&&r&&!await D(T(`Convert ${c} in place? This rewrites files and commits.`),!1)){console.log(`Aborted.`);return}console.log(),X(c)||(console.log(`Fetching the latest ZeroStarter ...`),await ye(c)),s(m(c,`.git`))||(await we(c),await J(c,`ci(init): scaffold from zerostarter`),await Te(c,`main`)),console.log(`Removing starter content and rebranding ...`),u(c,d),console.log(`Installing dependencies ...`),await U(c),await J(c,`ci(init): re-baseline as ${l}`),B(c);let p=!1,g=await fe(),_=V(c),v=!1;if(_?n.db&&console.log(T(` --db ignored: POSTGRES_URL is already set in .env.`)):n.db?v=!0:r?(console.log(),v=await D(`Provision a local Postgres database now?`,g)):v=g,v&&g)try{await ge(c),p=!0}catch(e){let t=e.stderr,n=t?String(t).trim():e instanceof Error?e.message:String(e);V(c)?console.log(T(`
23
- Postgres is provisioned, but the migration failed; run bun run db:migrate.`)):console.log(T(`
24
- Database setup failed; set POSTGRES_URL in .env yourself.`)),n&&console.log(T(` ${n}`))}else v&&console.log(T(`
25
- Docker isn't running, so the database wasn't provisioned. Set POSTGRES_URL in .env, or start Docker and re-run for automatic setup.`));let b=[[`packages/config/src/site.ts`,`your brand: name, tagline, links`],[`web/next/content`,`your docs and blog`],[`web/next/public`,`your logo and assets`]];console.log(`\n${w(`✓`)} ${l} is ready.\n`),console.log(`Next steps:`),c!==process.cwd()&&console.log(` ${C(`cd ${i}`)}`),V(c)||console.log(` ${C(`set POSTGRES_URL in .env`)} # your Postgres connection string`),p||console.log(` ${C(`bun run db:migrate`)}`),console.log(` ${C(`bun run dev`)}`),console.log(`
26
- Push to an empty GitHub repo when ready:`),console.log(` ${C(`git push origin canary`)}`),console.log(`canary becomes the default branch; your next push seeds main and opens the release PR.`),console.log(`
27
- Make it yours:`);for(let[e,t]of b)console.log(` ${e.padEnd(29)} ${t}`);console.log(p?`
28
- Everything works out of the box: dependencies are installed and the local Postgres is migrated. Add OAuth or other credentials to .env whenever you like.`:`
29
- It needs a Postgres database to run: a hosted one like Neon works, or a local Docker one (re-run with Docker running to auto-provision). OAuth and other credentials are optional.`)},Me=async t=>{let{positionals:n,values:r}=y({allowPositionals:!0,args:t,options:{help:{short:`h`,type:`boolean`},yes:{short:`y`,type:`boolean`}}});if(r.help){console.log(`Usage:
26
+ -h, --help Display help`,Qe=e=>!v(e)||b(e).filter(e=>e!==`.git`).length===0,Z=e=>s(h(e,`packages/config/src/site.ts`)),$e=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)}},et=async e=>{let{positionals:t,values:n}=Y(Ze,{allowPositionals:!0,args:e,options:{db:{type:`boolean`},"dry-run":{type:`boolean`},help:{short:`h`,type:`boolean`},yes:{short:`y`,type:`boolean`}}});if(n.help){console.log(Ze);return}n[`dry-run`]||await X(!!n.yes);let r=I()&&!n.yes,i=t[0]??`.`,a=_(i),o=Z(a),c=!o&&!Qe(a);if(!o&&!n[`dry-run`]){let e=$e(c?process.cwd():m(a));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`]||R(L(`https://zerostarter.dev`)),c){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 Se(`What should we name your project?`);if(!e)throw Error(`No directory name provided.`);i=e}let l=_(i),d=f(l),p={name:d};if(n[`dry-run`]){console.log(`bunx zerostarter init (dry run)`),console.log(` target: ${l}`),console.log(` name: ${d}`),console.log(` mode: ${Z(l)?`in place`:`fetch first`}`);return}if(o&&r&&!await G(`Convert ${d} in place? This rewrites files and commits.`,!1)){B(`Aborted`);return}Z(l)||await be(`Fetching the latest ZeroStarter`,`Fetched the latest ZeroStarter`,()=>Le(l)),s(h(l,`.git`))||(await Ge(l),await J(l,`ci(init): scaffold from zerostarter`),await Ke(l,`main`)),await be(`Rebranding to ${d}`,`Rebranded to ${d}`,()=>u(l,p)),await q(l),await J(l,`ci(init): re-baseline as ${d}`),Oe(l);let g=!1,v=await we(),y=K(l),b=!1;if(y?n.db&&W(`--db ignored: POSTGRES_URL is already set in .env.`):b=n.db?!0:r?await G(`Provision a local Postgres database now?`,v):v,b&&v)try{await Ne(l),g=!0}catch(e){if(K(l))W(`Postgres is provisioned, but the migration failed; run bun run db:migrate.`);else{let t=e instanceof Error?e.message.trim():String(e);W(`Database setup failed; set POSTGRES_URL in .env yourself.`,t?t.split(`
27
+ `).filter(e=>e.trim()).slice(-5):[])}}else b&&W(`Docker isn't running, so the database wasn't provisioned. Set POSTGRES_URL in .env, or start Docker and re-run for automatic setup.`);H([`${k(`packages/config/src/site.ts`)} and ${k(`web/next/content`)}`,`to manage branding and blogs & docs respectively`].join(`
28
+ `),`Edit and make it yours`),ye(`${d} is ready`);let x=[];l!==process.cwd()&&x.push(k(`cd ${i}`)),K(l)||x.push(`set POSTGRES_URL in .env`),g||x.push(k(`bun run db:migrate`)),x.push(k(`bun run dev`)),H(x.join(`
29
+ `),`Next steps`),z(`Learn more ${L(`https://zerostarter.dev/docs`)}`)},tt=`Usage:
30
30
  $ bunx zerostarter reinit [dir] [options]
31
31
 
32
32
  Re-scaffold an existing git repo (default .) as a fresh ZeroStarter: delete every
@@ -36,7 +36,8 @@ branch; push when ready.
36
36
 
37
37
  Options:
38
38
  -y, --yes Skip the confirmation prompt
39
- -h, --help Display help`);return}await Y(!!r.yes);let i=h(n[0]??`.`),a=f(i),o=x()&&!r.yes;if(await K(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.`),o&&!await D(T(`Delete every file in ${i} (keeping .git and .env*) and re-scaffold as ${a}?`),!1)){console.log(`Aborted.`);return}console.log(),console.log(`Removing all files (keeping .git and your .env* files) ...`),await q(i,T(`reinit failed; restored your committed files (deleted gitignored files, except .env*, are gone).`),async()=>{e(i),console.log(`Fetching the latest ZeroStarter ...`),await G(i),console.log(`Rebranding ...`),u(i,{name:a}),console.log(`Installing dependencies ...`),await U(i),B(i),await J(i,`ci(reinit): re-baseline as ${a}`)}),console.log(`\n${w(`✓`)} ${a} re-scaffolded; .git history, remote, and .env* files are intact.`),console.log(`Next steps:`),V(i)||console.log(` ${C(`set POSTGRES_URL in .env`)} # your Postgres connection string`),console.log(` ${C(`bun run db:migrate`)}`),console.log(` ${C(`bun run dev`)}`),console.log(` ${C(`git push`)} # to your existing remote`)},Ne=async e=>{let{positionals:t,values:n}=y({allowPositionals:!0,args:e,options:{help:{short:`h`,type:`boolean`}}});if(n.help){console.log(`Usage:
39
+ -h, --help Display help`,nt=async t=>{let{positionals:n,values:r}=Y(tt,{allowPositionals:!0,args:t,options:{help:{short:`h`,type:`boolean`},yes:{short:`y`,type:`boolean`}}});if(r.help){console.log(tt);return}await X(!!r.yes);let i=_(n[0]??`.`),a=f(i),o=I()&&!r.yes;if(await Ue(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.`),R(L(`https://zerostarter.dev`)),o&&!await G(`Delete every file in ${a} (keeping .git and .env*) and re-scaffold?`,!1)){B(`Aborted`);return}await We(i,T(`reinit failed; restored your committed files (deleted gitignored files, except .env*, are gone).`),async()=>{e(i),await Re(i),U(`Fetched the latest ZeroStarter (kept .git and .env*)`),u(i,{name:a}),U(`Rebranded to ${a}`),await q(i),Oe(i),await J(i,`ci(reinit): re-baseline as ${a}`)});let s=[];K(i)||s.push(`set POSTGRES_URL in .env`),s.push(k(`bun run db:migrate`)),s.push(k(`bun run dev`)),s.push(k(`git push`)),H(s.join(`
40
+ `),`Next steps`),z(w(`${a} re-scaffolded; .git history, remote, and .env* files are intact`))},rt=`Usage:
40
41
  $ bunx zerostarter sync [dir] [options]
41
42
 
42
43
  Re-baseline an existing fork (default .) on the latest ZeroStarter: a gitpick overlay
@@ -45,13 +46,14 @@ identity, and favicon are preserved. Requires a clean tree; lands as a reviewabl
45
46
  you commit yourself.
46
47
 
47
48
  Options:
48
- -h, --help Display help`);return}await Y();let u=h(t[0]??`.`);await K(u,`No git repository in ${u}. Run sync inside an existing fork.`,`Working tree has uncommitted changes. Commit or stash them first so the sync lands as a reviewable diff.`);let f=m(u,`package.json`),p=new Map(l(u).map(e=>[e,a(e)])),g=i(await be());g.length===0&&console.log(T(`Warning: no PRESERVE_ON_SYNC directive found; fork-owned files may be overwritten.`)),console.log(),console.log(`Overlaying the latest ZeroStarter (content, public/marketing, and site.ts preserved) ...`),await q(u,T(`Sync failed; rolled the working tree back to your last commit.`),async()=>{await G(u),o(u),d(m(u,`.gitpickignore`));for(let[e,t]of p)s(e)&&r(e,c(t,a(e),e===f));await Se(u,g)}),console.log(`Installing dependencies ...`),await U(u),console.log(),console.log(C(`Synced to the latest ZeroStarter.`)),console.log(`Starter files were updated (edits to them were overwritten); files you added and your`),console.log(`content, public/marketing, and branding were preserved.`),console.log(T(`Review the diff and commit: git -C ${u} status`))},{author:Z,name:Q,version:Pe}=re,$=`Version:
49
- ${Q}@${Pe}
49
+ -h, --help Display help`,it=async e=>{let{positionals:t,values:n}=Y(rt,{allowPositionals:!0,args:e,options:{help:{short:`h`,type:`boolean`}}});if(n.help){console.log(rt);return}await X();let u=_(t[0]??`.`);await Ue(u,`No git repository in ${u}. Run sync inside an existing fork.`,`Working tree has uncommitted changes. Commit or stash them first so the sync lands as a reviewable diff.`),R(L(`https://zerostarter.dev`));let f=h(u,`package.json`),p=new Map(l(u).map(e=>[e,a(e)])),m=i(await ze());m.length===0&&W(`No PRESERVE_ON_SYNC directive found; fork-owned files may be overwritten.`),await We(u,T(`Sync failed; rolled the working tree back to your last commit.`),async()=>{await Re(u),o(u),d(h(u,`.gitpickignore`));for(let[e,t]of p)s(e)&&r(e,c(t,a(e),e===f));await Ve(u,m)}),U(`Overlaid the latest ZeroStarter (content, public/marketing, and branding preserved)`),await q(u),H([`Starter files were updated (edits overwritten); your content, public/marketing, and branding were preserved.`,T(`Review the diff and commit: git -C ${u} status`)].join(`
50
+ `),`Review the changes`),z(k(`Synced to the latest ZeroStarter`))},{author:Q,name:$,version:at}=_e,ot=`Version:
51
+ ${$}@${at}
50
52
 
51
53
  Go from zero to a production-ready SaaS, rebranded and ready to ship.
52
54
 
53
55
  Usage:
54
- $ ${Q} <command> [options]
56
+ $ ${$} <command> [options]
55
57
 
56
58
  Commands:
57
59
  init [dir] Scaffold ZeroStarter into dir (default .) as a fresh product.
@@ -64,4 +66,4 @@ Options:
64
66
  -h, --help Display help
65
67
 
66
68
  Author:
67
- ${Z.name} <${Z.email}> (${ie(Z.url)})`;(async()=>{try{let e=process.argv.slice(2),t=e[0],n=e.slice(1);switch(t){case`init`:return await je(n);case`reinit`:return await Me(n);case`sync`:return await Ne(n);case void 0:case`-h`:case`--help`:console.log($);return;case`-v`:case`--version`:console.log(`${Q}@${Pe}`);return;default:console.error(E(`Unknown command: ${t}\n`)),console.log($),process.exit(1)}}catch(e){console.error(E(e instanceof Error?e.message:String(e))),process.exit(1)}})();export{};
69
+ ${Q.name} <${Q.email}> (${ve(Q.url)})`;(async()=>{try{let e=process.argv.slice(2),t=e[0],n=e.slice(1);switch(t){case`init`:return await et(n);case`reinit`:return await nt(n);case`sync`:return await it(n);case void 0:case`-h`:case`--help`:console.log(ot);return;case`-v`:case`--version`:console.log(`${$}@${at}`);return;default:console.error(O(`Unknown command: ${t}\n`)),console.log(ot),process.exit(1)}}catch(e){he(e),process.exit(1)}})();export{};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "zerostarter",
3
- "version": "0.0.0-93a2b9d",
3
+ "version": "0.0.0-b1bc340",
4
4
  "description": "Go from zero to a production-ready SaaS, rebranded and ready to ship.",
5
5
  "keywords": [
6
6
  "cli",