zerostarter 0.1.35 → 0.1.36

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 +12 -15
  2. package/package.json +1 -1
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import{A as e,C as t,D as n,E as r,F as i,I as a,M as o,N as s,O as c,P as l,S as u,T as d,_ as f,a as p,b as m,c as ee,d as h,f as g,g as _,h as v,i as y,j as b,k as x,l as S,m as C,n as te,o as ne,p as w,r as re,s as ie,t as T,u as E,v as D,w as ae,x as O,y as k}from"../convert-DjNN2nhd.mjs";import{basename as oe,delimiter as se,dirname as ce,join as A,parse as le,resolve as j}from"node:path";import{existsSync as M,readFileSync as ue,readdirSync as de}from"node:fs";import{randomBytes as fe}from"node:crypto";import{createInterface as pe}from"node:readline/promises";import{parseArgs as me}from"node:util";import{homedir as he}from"node:os";var ge={name:`zerostarter`,version:`0.1.35`,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`},devDependencies:{"@packages/config":`workspace:*`,"@types/bun":`catalog:`,"@types/node":`catalog:`,tsdown:`catalog:`,typescript:`catalog:`}};const N=()=>!!(process.stdin.isTTY&&process.stdout.isTTY),_e=(e,t=e)=>process.stdout.isTTY?`\x1b]8;;${e}\x07${t}\x1b]8;;\x07`:e,P=e=>_e(e,k(e)),F=e=>{process.stdout.write(`\n ${O(D.barStart)} ${e}\n ${O(D.bar)}\n`)},I=e=>{process.stdout.write(` ${O(D.bar)}\n ${O(D.barEnd)} ${e}\n`)},L=(e=`Cancelled`)=>{process.stdout.write(` ${O(D.barEnd)} ${d(e)}\n`)},R=e=>e.replace(/* @__PURE__ */ RegExp(`\x1B\\[[0-9;?]*[a-zA-Z]`,`g`),``).replace(/* @__PURE__ */ RegExp(`\x1B\\]8;;.*?\\x07`,`g`),``).length,z=(e,t=``,n=!1)=>{let r=`\n${e}\n`.split(`
2
+ import{A as e,C as t,D as n,E as r,F as i,I as a,M as o,N as s,O as c,P as l,S as u,T as d,_ as f,a as p,b as m,c as ee,d as h,f as g,g as _,h as v,i as y,j as b,k as x,l as S,m as C,n as te,o as ne,p as w,r as re,s as ie,t as T,u as E,v as D,w as ae,x as O,y as k}from"../convert-DjNN2nhd.mjs";import{basename as oe,delimiter as se,dirname as ce,join as A,parse as le,resolve as j}from"node:path";import{existsSync as M,readFileSync as ue,readdirSync as de}from"node:fs";import{randomBytes as fe}from"node:crypto";import{createInterface as pe}from"node:readline/promises";import{parseArgs as me}from"node:util";import{homedir as he}from"node:os";var ge={name:`zerostarter`,version:`0.1.36`,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`},devDependencies:{"@packages/config":`workspace:*`,"@types/bun":`catalog:`,"@types/node":`catalog:`,tsdown:`catalog:`,typescript:`catalog:`}};const N=()=>!!(process.stdin.isTTY&&process.stdout.isTTY),_e=(e,t=e)=>process.stdout.isTTY?`\x1b]8;;${e}\x07${t}\x1b]8;;\x07`:e,P=e=>_e(e,k(e)),F=e=>{process.stdout.write(`\n ${O(D.barStart)} ${e}\n ${O(D.bar)}\n`)},I=e=>{process.stdout.write(` ${O(D.bar)}\n ${O(D.barEnd)} ${e}\n`)},L=(e=`Cancelled`)=>{process.stdout.write(` ${O(D.barEnd)} ${d(e)}\n`)},R=e=>e.replace(/* @__PURE__ */ RegExp(`\x1B\\[[0-9;?]*[a-zA-Z]`,`g`),``).replace(/* @__PURE__ */ RegExp(`\x1B\\]8;;.*?\\x07`,`g`),``).length,z=(e,t=``,n=!1)=>{let r=`\n${e}\n`.split(`
3
3
  `),i=R(t),a=r.reduce((e,t)=>Math.max(e,R(t)),i),o=Math.max(a,54)+2,s=r.map(e=>` ${O(D.bar)} ${e}${` `.repeat(o-R(e))}${O(D.bar)}`).join(`
4
4
  `),c=n?D.cornerBL:D.connectL;process.stdout.write(` ${k(D.active)} ${t} ${O(D.barH.repeat(Math.max(o-i-1,1))+D.cornerTR)}\n${s}\n ${O(c+D.barH.repeat(o+2)+D.cornerBR)}\n`)},B=(e,t=[])=>{process.stdout.write(` ${k(D.active)} ${e}\n`);for(let e of t)process.stdout.write(` ${O(D.bar)} ${e}\n`)},ve=e=>{process.stdout.write(` ${u(D.active)} ${u(e)}\n`)},V=(e,t=[])=>{process.stdout.write(` ${r(D.warn)} ${r(e)}\n`);for(let e of t)process.stdout.write(` ${O(D.bar)} ${r(e)}\n`)},ye=async(e,t,n)=>{let r=process.stdout,i=null;if(r.isTTY){let t=0;r.write(` ${ae(0,e)}`),i=setInterval(()=>{t+=1,r.write(`\r\x1b[K ${ae(t,e)}`)},400)}try{let e=await n();return i&&clearInterval(i),r.write(r.isTTY?`\r\x1b[K ${k(D.active)} ${t}\n`:` ${k(D.active)} ${t}\n`),e}catch(e){throw i&&clearInterval(i),r.isTTY&&r.write(`\r\x1B[K`),e}},be=e=>{let t=e?`${u(D.radioOn)} Yes`:m(`${D.radioOff} Yes`),n=e?m(`${D.radioOff} No`):`${u(D.radioOn)} No`;return` ${O(D.bar)} ${t} ${m(`/`)} ${n}`},H=async(e,t=!0)=>{let n=process.stdout;return N()?new Promise(r=>{let i=t,a=process.stdin,o=Math.max(1,Math.ceil((5+R(e))/(n.columns||80)));n.write(` ${k(D.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(` ${k(D.submit)} ${m(e)}\n`),L(),process.exit(130)):t===`\r`||t===`
5
5
  `?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(` ${k(D.active)} ${e} ${m(t?`Yes`:`No`)}\n`),t)},xe=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 N()?new Promise(a=>{let o=process.stdin,s=0,c=e=>{let n=t[e],i=r.has(n.value)?u(D.checkboxOn):m(D.checkboxOff),a=e===s?n.label:m(n.label);return` ${O(D.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(` ${k(D.submit)} ${e}\n`),l(!0),o.setRawMode(!0),o.resume(),o.setEncoding(`utf8`);let d=()=>{o.setRawMode(!1),o.pause(),o.removeListener(`data`,f)};function f(o){if(o===``)d(),n.write(`\x1b[${t.length+1}A\r\x1b[0J ${k(D.submit)} ${m(e)}\n`),L(),process.exit(130);else if(o===`\r`||o===`
@@ -9,7 +9,8 @@ import{A as e,C as t,D as n,E as r,F as i,I as a,M as o,N as s,O as c,P as l,S a
9
9
  `))},Ee=e=>{let t=Te(e);U(t,`BETTER_AUTH_SECRET`)||W(t,`BETTER_AUTH_SECRET`,fe(32).toString(`base64`)),U(t,`AGENT_SIGNIN_ENABLED`)||W(t,`AGENT_SIGNIN_ENABLED`,`true`)},G=e=>{let t=A(e,`.env`);return x(t)&&U(t,`POSTGRES_URL`)!==``},De=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]:``}},Oe=async(e,t)=>{let n=t?[`--bun`,Ce,`-k`,`-c`]:[`--bun`,Ce,`-k`],r;try{r=await v(`bunx`,n,e)}catch(e){let t=e;r=[t.stdout,t.stderr].filter(Boolean).join(`
10
10
  `)}return{launch:De(r),out:r}},ke=e=>new Promise(t=>setTimeout(t,e)),Ae=async e=>{if(e)for(let t=0;t<30;t++){if(await w(`docker`,[`exec`,e,`pg_isready`,`-U`,`postgres`]))return;await ke(1e3)}},je=async e=>{let t=Te(e),n=await Oe(e,!1),r=n.launch?n:await Oe(e,!0);if(!r.launch)throw Error(r.out.trim()||`pglaunch did not print a connection URL`);W(t,`POSTGRES_URL`,r.launch.url),await Ae(r.launch.container),await f(`bun`,[`run`,`db:migrate`],{cwd:e,label:`Provisioning a local Postgres database`,done:`Provisioned a local Postgres database`})},K=async e=>{await f(`bun`,[`install`],{cwd:e,label:`Installing dependencies`,done:`Installed dependencies`})},Me=async()=>{if(!await w(`bun`,[`--version`]))throw Error(`bun is not on PATH`)},Ne=async(e=Me,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}},Pe=async(e,t=`main`)=>{await v(`bunx`,[`--bun`,`gitpick@6.0.0`,`https://github.com/nrjdalal/zerostarter/tree/${t}`,e])},Fe=async(e,t=`main`)=>{await v(`bunx`,[`--bun`,`gitpick@6.0.0`,`https://github.com/nrjdalal/zerostarter/tree/${t}`,e,`-o`])},Ie=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()},Le=async e=>(await v(`git`,[`status`,`--porcelain`],e)).trim()===``,Re=async(e,t)=>{for(let n of t)try{await v(`git`,[`checkout`,`--`,n],e),await v(`git`,[`clean`,`-fd`,`--`,n],e)}catch{}},ze=async e=>{await v(`git`,[`reset`,`--hard`,`HEAD`],e),await v(`git`,[`clean`,`-fd`],e)},Be=async(e,t,n)=>{if(!x(A(e,`.git`)))throw Error(t);if(!await Le(e))throw Error(n)},Ve=async(e,t,n)=>{try{await n()}catch(n){throw await ze(e),console.log(t),n}},He=async e=>{await v(`git`,[`init`,`-q`,`-b`,`canary`],e)},Ue=async(e,t)=>{await v(`git`,[`branch`,t],e)},q=async(e,t)=>{await v(`git`,[`add`,`-A`],e);try{await v(`git`,[`commit`,`--no-verify`,`-q`,`-m`,t],e)}catch{}},J=(e,t)=>{try{return me(t)}catch(t){process.stderr.write(`${d(t instanceof Error?t.message:String(t))}\n\n`),process.stdout.write(`${e}\n`),process.exit(1)}},We=(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`,Ge=(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`]},Ke=(e=process.argv.slice(2))=>[`zerostarter`,...e].join(` `),qe=()=>A(process.env.BUN_INSTALL||A(he(),`.bun`),`bin`),Y=async(e=!1)=>{if(await Ne())return;let n=We(),r=`bunx --bun ${Ke()}`;if(console.error(d(`Seems like you are using ${n===`unknown`?`npx/pnpx`:n} or Windows, try using:`)),console.error(t(` ${r}`)),console.error(``),e||N()&&await H(`Or install bun now and continue?`,!0)){let{cmd:e,args:n}=Ge();console.error(`Installing bun from https://bun.sh/install ...`);try{if(await _(e,n),process.env.PATH=`${qe()}${se}${process.env.PATH||``}`,await Ne())return;console.error(d(`
11
11
  bun is installed but isn't on this shell's PATH yet. Open a new terminal and re-run:`)),console.error(t(` ${r}`))}catch{console.error(d(`
12
- Could not install bun. Install it from https://bun.sh, then re-run:`)),console.error(t(` ${r}`))}}process.exit(1)},X=[{value:`allowlist`,flag:`allowlist`,label:`Allowlist (grant console access by domain)`},{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)`}],Je=`Usage:
12
+ Could not install bun. Install it from https://bun.sh, then re-run:`)),console.error(t(` ${r}`))}}process.exit(1)},X=[{value:`allowlist`,flag:`allowlist`,help:`Console access by email domain or address`,label:`Allowlist (grant console access by domain)`},{value:`apiDocs`,flag:`api-docs`,help:`The /api/docs API reference`,label:`API docs`},{value:`blog`,flag:`blog`,help:`The /blog`,label:`Blog`},{value:`docs`,flag:`docs`,help:`The /docs`,label:`Docs`},{value:`internalDocs`,flag:`internal-docs`,help:`The /console/docs internal docs`,label:`Internal (console) docs`},{value:`waitlist`,flag:`waitlist`,help:`The /waitlist (off leaves a plain landing home)`,label:`Waitlist (else a plain landing home)`}],Je=X.filter(e=>!g[e.value]).map(e=>e.flag),Ye=X.map(e=>` ${`--${e.flag},`.padEnd(18)}${`--no-${e.flag}`.padEnd(21)}${e.help}`).join(`
13
+ `),Xe=Object.fromEntries(X.flatMap(e=>[[e.flag,{type:`boolean`}],[`no-${e.flag}`,{type:`boolean`}]])),Ze=`Usage:
13
14
  $ bunx zerostarter init [dir] [options]
14
15
 
15
16
  Scaffold ZeroStarter into dir (default .) as a fresh product. The author's
@@ -25,15 +26,11 @@ Options:
25
26
  --dry-run Print the plan without writing anything
26
27
  -h, --help Display help
27
28
 
28
- Features (default on, except the waitlist; pass any flag to skip the interactive picker):
29
- --api-docs, --no-api-docs The /api/docs API reference
30
- --blog, --no-blog The /blog
31
- --docs, --no-docs The /docs
32
- --internal-docs, --no-internal-docs The /console/docs internal docs
33
- --waitlist, --no-waitlist The /waitlist (off leaves a plain landing home)`,Ye=e=>!M(e)||de(e).filter(e=>e!==`.git`).length===0,Z=e=>x(A(e,`packages/config/src/site.ts`)),Xe=e=>{let t=e,{root:n}=le(t);for(;;){if(M(A(t,`bun.lock`))||M(A(t,`bun.lockb`)))return t;let e=A(t,`package.json`);if(M(e))try{if(JSON.parse(ue(e,`utf8`)).workspaces)return t}catch{}if(t===n)return null;t=ce(t)}},Ze=async e=>{let{positionals:n,values:r}=J(Je,{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(r.help){console.log(Je);return}r[`dry-run`]||await Y(!!r.yes);let i=N()&&!r.yes,a=r.canary?`canary`:`main`,o=r,s=X.some(e=>o[e.flag]||o[`no-${e.flag}`]),c={...g};for(let e of X)c[e.value]=o[`no-${e.flag}`]?!1:o[e.flag]?!0:g[e.value];let l=n[0]??`.`,u=j(l),d=Z(u),f=!d&&!Ye(u);if(!d&&!r[`dry-run`]){let e=Xe(f?process.cwd():ce(u));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`]||F(P(`https://zerostarter.dev`)),f){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 Se(`What should we name your project?`);if(!e)throw Error(`No directory name provided.`);l=e}let p=j(l),m=oe(p),ee={name:m},h=`--canary ignored: converting the existing checkout in place, so nothing is fetched.`,_=e=>X.filter(t=>e[t.value]).map(e=>e.value).join(`, `)||`none`;if(r[`dry-run`]){console.log(`bunx zerostarter init (dry run)`),console.log(` target: ${p}`),console.log(` name: ${m}`),console.log(` mode: ${Z(p)?`in place`:`fetch ${a}`}`),console.log(` features: ${_(c)}`),Z(p)&&r.canary&&console.log(` note: ${h}`);return}if(d&&i&&!await H(`Convert ${m} in place? This rewrites files and commits.`,!1)){L(`Aborted`);return}if(i&&!s){let e=new Set(await xe(`Which optional surfaces should this fork ship with?`,X.map(e=>({value:e.value,label:e.label,checked:g[e.value]}))));for(let t of X)c[t.value]=e.has(t.value)}if(Z(p))r.canary&&V(h);else{let e=r.canary?` (canary)`:``;await ye(`Fetching the latest ZeroStarter${e}`,`Fetched the latest ZeroStarter${e}`,()=>Pe(p,a))}x(A(p,`.git`))||(await He(p),await q(p,`ci(init): scaffold from zerostarter`),await Ue(p,`main`)),await ye(`Rebranding to ${m}`,`Rebranded to ${m}`,()=>T(p,ee,c)),await K(p),await E(p),await q(p,`ci(init): re-baseline as ${m}`),Ee(p);let v=!1,y=await we(),b=G(p),S=!1;if(b?r.db&&V(`--db ignored: POSTGRES_URL is already set in .env.`):S=r.db?!0:i?await H(`Provision a local Postgres database?`,y):y,S&&y)try{await je(p),v=!0}catch(e){if(G(p))V(`Postgres is provisioned, but the migration failed; run bun run db:migrate.`);else{let t=e instanceof Error?e.message.trim():String(e);V(`Database setup failed; set POSTGRES_URL in .env yourself.`,t?t.split(`
29
+ Features (on by default, except ${Je.join(` and `)}; pass any flag to skip the interactive picker):
30
+ ${Ye}`,Qe=e=>!M(e)||de(e).filter(e=>e!==`.git`).length===0,Z=e=>x(A(e,`packages/config/src/site.ts`)),$e=e=>{let t=e,{root:n}=le(t);for(;;){if(M(A(t,`bun.lock`))||M(A(t,`bun.lockb`)))return t;let e=A(t,`package.json`);if(M(e))try{if(JSON.parse(ue(e,`utf8`)).workspaces)return t}catch{}if(t===n)return null;t=ce(t)}},et=async e=>{let{positionals:n,values:r}=J(Ze,{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`},...Xe}});if(r.help){console.log(Ze);return}r[`dry-run`]||await Y(!!r.yes);let i=N()&&!r.yes,a=r.canary?`canary`:`main`,o=r,s=X.some(e=>o[e.flag]||o[`no-${e.flag}`]),c={...g};for(let e of X)c[e.value]=o[`no-${e.flag}`]?!1:o[e.flag]?!0:g[e.value];let l=n[0]??`.`,u=j(l),d=Z(u),f=!d&&!Qe(u);if(!d&&!r[`dry-run`]){let e=$e(f?process.cwd():ce(u));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`]||F(P(`https://zerostarter.dev`)),f){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 Se(`What should we name your project?`);if(!e)throw Error(`No directory name provided.`);l=e}let p=j(l),m=oe(p),ee={name:m},h=`--canary ignored: converting the existing checkout in place, so nothing is fetched.`,_=e=>X.filter(t=>e[t.value]).map(e=>e.value).join(`, `)||`none`;if(r[`dry-run`]){console.log(`bunx zerostarter init (dry run)`),console.log(` target: ${p}`),console.log(` name: ${m}`),console.log(` mode: ${Z(p)?`in place`:`fetch ${a}`}`),console.log(` features: ${_(c)}`),Z(p)&&r.canary&&console.log(` note: ${h}`);return}if(d&&i&&!await H(`Convert ${m} in place? This rewrites files and commits.`,!1)){L(`Aborted`);return}if(i&&!s){let e=new Set(await xe(`Which optional surfaces should this fork ship with?`,X.map(e=>({value:e.value,label:e.label,checked:g[e.value]}))));for(let t of X)c[t.value]=e.has(t.value)}if(Z(p))r.canary&&V(h);else{let e=r.canary?` (canary)`:``;await ye(`Fetching the latest ZeroStarter${e}`,`Fetched the latest ZeroStarter${e}`,()=>Pe(p,a))}x(A(p,`.git`))||(await He(p),await q(p,`ci(init): scaffold from zerostarter`),await Ue(p,`main`)),await ye(`Rebranding to ${m}`,`Rebranded to ${m}`,()=>T(p,ee,c)),await K(p),await E(p),await q(p,`ci(init): re-baseline as ${m}`),Ee(p);let v=!1,y=await we(),b=G(p),S=!1;if(b?r.db&&V(`--db ignored: POSTGRES_URL is already set in .env.`):S=r.db?!0:i?await H(`Provision a local Postgres database?`,y):y,S&&y)try{await je(p),v=!0}catch(e){if(G(p))V(`Postgres is provisioned, but the migration failed; run bun run db:migrate.`);else{let t=e instanceof Error?e.message.trim():String(e);V(`Database setup failed; set POSTGRES_URL in .env yourself.`,t?t.split(`
34
31
  `).filter(e=>e.trim()).slice(-5):[])}}else S&&V(`Docker isn't running, so the database wasn't provisioned. Set POSTGRES_URL in .env, or start Docker and re-run for automatic setup.`);z([`${t(`packages/config/src/site.ts`)} and ${t(`web/next/content`)}`,`to manage branding and blogs & docs respectively`].join(`
35
32
  `),`Edit and make it yours`),ve(`${m} is ready`);let C=[];p!==process.cwd()&&C.push(t(`cd ${l}`)),G(p)||C.push(`set POSTGRES_URL in .env`),v||C.push(t(`bun run db:migrate`)),C.push(t(`bun run dev`)),z(C.join(`
36
- `),`Next steps`),I(`Learn more ${P(`https://zerostarter.dev/docs`)}`)},Qe=`Usage:
33
+ `),`Next steps`),I(`Learn more ${P(`https://zerostarter.dev/docs`)}`)},tt=`Usage:
37
34
  $ bunx zerostarter reinit [dir] [options]
38
35
 
39
36
  Re-scaffold an existing git repo (default .) as a fresh ZeroStarter: delete every
@@ -43,8 +40,8 @@ branch; push when ready.
43
40
 
44
41
  Options:
45
42
  -y, --yes Skip the confirmation prompt
46
- -h, --help Display help`,$e=async e=>{let{positionals:n,values:i}=J(Qe,{allowPositionals:!0,args:e,options:{help:{short:`h`,type:`boolean`},yes:{short:`y`,type:`boolean`}}});if(i.help){console.log(Qe);return}await Y(!!i.yes);let a=j(n[0]??`.`),o=oe(a),s=N()&&!i.yes;if(await Be(a,`No git repository in ${a}. 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.`),F(P(`https://zerostarter.dev`)),s&&!await H(`Delete every file in ${o} (keeping .git and .env*) and re-scaffold?`,!1)){L(`Aborted`);return}await Ve(a,r(`reinit failed; restored your committed files (deleted gitignored files, except .env*, are gone).`),async()=>{c(a),await Fe(a),B(`Fetched the latest ZeroStarter (kept .git and .env*)`),T(a,{name:o}),B(`Rebranded to ${o}`),await K(a),await E(a),Ee(a),await q(a,`ci(reinit): re-baseline as ${o}`)});let l=[];G(a)||l.push(`set POSTGRES_URL in .env`),l.push(t(`bun run db:migrate`)),l.push(t(`bun run dev`)),l.push(t(`git push`)),z(l.join(`
47
- `),`Next steps`),I(u(`${o} re-scaffolded; .git history, remote, and .env* files are intact`))},et=`Usage:
43
+ -h, --help Display help`,nt=async e=>{let{positionals:n,values:i}=J(tt,{allowPositionals:!0,args:e,options:{help:{short:`h`,type:`boolean`},yes:{short:`y`,type:`boolean`}}});if(i.help){console.log(tt);return}await Y(!!i.yes);let a=j(n[0]??`.`),o=oe(a),s=N()&&!i.yes;if(await Be(a,`No git repository in ${a}. 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.`),F(P(`https://zerostarter.dev`)),s&&!await H(`Delete every file in ${o} (keeping .git and .env*) and re-scaffold?`,!1)){L(`Aborted`);return}await Ve(a,r(`reinit failed; restored your committed files (deleted gitignored files, except .env*, are gone).`),async()=>{c(a),await Fe(a),B(`Fetched the latest ZeroStarter (kept .git and .env*)`),T(a,{name:o}),B(`Rebranded to ${o}`),await K(a),await E(a),Ee(a),await q(a,`ci(reinit): re-baseline as ${o}`)});let l=[];G(a)||l.push(`set POSTGRES_URL in .env`),l.push(t(`bun run db:migrate`)),l.push(t(`bun run dev`)),l.push(t(`git push`)),z(l.join(`
44
+ `),`Next steps`),I(u(`${o} re-scaffolded; .git history, remote, and .env* files are intact`))},rt=`Usage:
48
45
  $ bunx zerostarter sync [dir] [options]
49
46
 
50
47
  Re-baseline an existing fork (default .) on the latest ZeroStarter: a gitpick overlay
@@ -53,9 +50,9 @@ identity, favicon, and any skill or AGENTS.md you have edited are preserved. Req
53
50
  you commit yourself.
54
51
 
55
52
  Options:
56
- -h, --help Display help`,tt=async c=>{let{positionals:l,values:u}=J(et,{allowPositionals:!0,args:c,options:{help:{short:`h`,type:`boolean`}}});if(u.help){console.log(et);return}await Y();let d=j(l[0]??`.`);await Be(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.`),F(P(`https://zerostarter.dev`));let f=A(d,`package.json`),m=new Map(e(d).map(e=>[e,o(e)])),g=a(await Ie()).preserve;g.length===0&&V(`No PRESERVE_ON_SYNC directive found; fork-owned files may be overwritten.`);let _=re(d),v=h(d),b=ie(d),C=p(),w=`absent`;await Ve(d,r(`Sync failed; rolled the working tree back to your last commit.`),async()=>{await Fe(d),te(d,_),s(A(d,`.gitpickignore`));for(let[e,t]of m)x(e)&&i(e,n(t,o(e),e===f));y(d),C=S(d,v);let e=ie(d);await Re(d,g),w=ee(d,{before:b,upstream:e})}),B(`Overlaid the latest ZeroStarter (content, public/marketing, and branding preserved)`),await K(d),await E(d),ne(d)&&V(`Your AGENTS.md has no skills-table markers, so the pre-commit hook that fills them fails.`,[`Add these two pairs under a ## Skills heading, then commit:`,`<!-- skills:custom --> <!-- /skills:custom -->`,`<!-- skills:vendored --> <!-- /skills:vendored -->`]);let T=e=>e.map(e=>`.agents/skills/${e}/SKILL.md`),D=e=>e.length===1?``:`s`;C.forkOwned.length>0&&B(`Left ${C.forkOwned.length} skill${D(C.forkOwned)} you own untouched:`,T(C.forkOwned)),C.customized.length>0&&(V(`Kept your edits to ${C.customized.length} skill${D(C.customized)}, so they did not take the update:`,T(C.customized)),B(`To take upstream's version instead, delete the skill directory and sync again.`)),w===`customized`&&B(`Kept your AGENTS.md, which you have edited, so it did not take the update. To take the starter's version instead, delete it, commit that on its own, and sync again.`),w===`forkOwned`&&B(`Kept your AGENTS.md. The starter now ships its full agent guide; to take it, delete AGENTS.md, commit that on its own, and sync again.`),C.unverified.length>0&&(V(`Updated ${C.unverified.length} skill${D(C.unverified)} with no sync record, so any edits of yours are in the diff rather than the file:`,T(C.unverified)),B(`Restore any with: git restore --source=HEAD -- .agents/skills/<name>/SKILL.md. Later syncs track them.`)),z([`Starter files were updated (edits overwritten); your content, public/marketing, branding, and the skills and agent guide you own were preserved.`,r(`Review the diff and commit: git -C ${d} status`)].join(`
57
- `),`Review the changes`),I(t(`Synced to the latest ZeroStarter`))},{author:Q,name:$,version:nt}=ge,rt=`Version:
58
- ${$}@${nt}
53
+ -h, --help Display help`,it=async c=>{let{positionals:l,values:u}=J(rt,{allowPositionals:!0,args:c,options:{help:{short:`h`,type:`boolean`}}});if(u.help){console.log(rt);return}await Y();let d=j(l[0]??`.`);await Be(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.`),F(P(`https://zerostarter.dev`));let f=A(d,`package.json`),m=new Map(e(d).map(e=>[e,o(e)])),g=a(await Ie()).preserve;g.length===0&&V(`No PRESERVE_ON_SYNC directive found; fork-owned files may be overwritten.`);let _=re(d),v=h(d),b=ie(d),C=p(),w=`absent`;await Ve(d,r(`Sync failed; rolled the working tree back to your last commit.`),async()=>{await Fe(d),te(d,_),s(A(d,`.gitpickignore`));for(let[e,t]of m)x(e)&&i(e,n(t,o(e),e===f));y(d),C=S(d,v);let e=ie(d);await Re(d,g),w=ee(d,{before:b,upstream:e})}),B(`Overlaid the latest ZeroStarter (content, public/marketing, and branding preserved)`),await K(d),await E(d),ne(d)&&V(`Your AGENTS.md has no skills-table markers, so the pre-commit hook that fills them fails.`,[`Add these two pairs under a ## Skills heading, then commit:`,`<!-- skills:custom --> <!-- /skills:custom -->`,`<!-- skills:vendored --> <!-- /skills:vendored -->`]);let T=e=>e.map(e=>`.agents/skills/${e}/SKILL.md`),D=e=>e.length===1?``:`s`;C.forkOwned.length>0&&B(`Left ${C.forkOwned.length} skill${D(C.forkOwned)} you own untouched:`,T(C.forkOwned)),C.customized.length>0&&(V(`Kept your edits to ${C.customized.length} skill${D(C.customized)}, so they did not take the update:`,T(C.customized)),B(`To take upstream's version instead, delete the skill directory and sync again.`)),w===`customized`&&B(`Kept your AGENTS.md, which you have edited, so it did not take the update. To take the starter's version instead, delete it, commit that on its own, and sync again.`),w===`forkOwned`&&B(`Kept your AGENTS.md. The starter now ships its full agent guide; to take it, delete AGENTS.md, commit that on its own, and sync again.`),C.unverified.length>0&&(V(`Updated ${C.unverified.length} skill${D(C.unverified)} with no sync record, so any edits of yours are in the diff rather than the file:`,T(C.unverified)),B(`Restore any with: git restore --source=HEAD -- .agents/skills/<name>/SKILL.md. Later syncs track them.`)),z([`Starter files were updated (edits overwritten); your content, public/marketing, branding, and the skills and agent guide you own were preserved.`,r(`Review the diff and commit: git -C ${d} status`)].join(`
54
+ `),`Review the changes`),I(t(`Synced to the latest ZeroStarter`))},{author:Q,name:$,version:at}=ge,ot=`Version:
55
+ ${$}@${at}
59
56
 
60
57
  Go from zero to a production-ready SaaS, rebranded and ready to ship.
61
58
 
@@ -73,4 +70,4 @@ Options:
73
70
  -h, --help Display help
74
71
 
75
72
  Author:
76
- ${Q.name} <${Q.email}> (${_e(Q.url)})`;(async()=>{try{let e=process.argv.slice(2),t=e[0],n=e.slice(1);switch(t){case`init`:return await Ze(n);case`reinit`:return await $e(n);case`sync`:return await tt(n);case void 0:case`-h`:case`--help`:console.log(rt);return;case`-v`:case`--version`:console.log(`${$}@${nt}`);return;default:console.error(d(`Unknown command: ${t}\n`)),console.log(rt),process.exit(1)}}catch(e){C(e),process.exit(1)}})();export{};
73
+ ${Q.name} <${Q.email}> (${_e(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(d(`Unknown command: ${t}\n`)),console.log(ot),process.exit(1)}}catch(e){C(e),process.exit(1)}})();export{};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "zerostarter",
3
- "version": "0.1.35",
3
+ "version": "0.1.36",
4
4
  "description": "Go from zero to a production-ready SaaS, rebranded and ready to ship.",
5
5
  "keywords": [
6
6
  "cli",