zerostarter 0.0.0-5f460c8 → 0.0.0-6598634
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.
- package/dist/bin/index.mjs +11 -13
- package/package.json +1 -1
package/dist/bin/index.mjs
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
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,dirname as m,join as h,parse as g,resolve as _}from"node:path";import{existsSync as v,readFileSync as
|
|
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{createInterface as ee}from"node:readline/promises";import{parseArgs as x}from"node:util";import{randomBytes as te}from"node:crypto";import{spawn as ne}from"node:child_process";import{access as re}from"node:fs/promises";import{homedir as ie}from"node:os";var ae={name:`zerostarter`,version:`0.0.0-6598634`,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 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={barStart:`┌`,bar:`│`,barEnd:`└`,active:`◆`,submit:`◇`,radioOn:`●`,radioOff:`○`,warn:`▲`,error:`■`,barH:`─`,cornerTR:`╮`,connectL:`├`,cornerBL:`╰`,cornerBR:`╯`},j=()=>!!(process.stdin.isTTY&&process.stdout.isTTY),oe=(e,t=e)=>process.stdout.isTTY?`\x1b]8;;${e}\x07${t}\x1b]8;;\x07`:e,M=e=>{process.stdout.write(`\n${E(A.barStart)} ${e}\n`)},N=e=>{process.stdout.write(`${E(A.bar)}\n${E(A.barEnd)} ${e}\n`)},P=(e=`Cancelled`)=>{process.stdout.write(`${E(A.bar)}\n${E(A.barEnd)} ${O(e)}\n`)},F=e=>e.replace(RegExp(`\x1B\\[[0-9;?]*[a-zA-Z]`,`g`),``).replace(RegExp(`\x1B\\]8;;.*?\\x07`,`g`),``).length,I=(e,t=``,n=!1)=>{let r=`\n${e}\n`.split(`
|
|
3
3
|
`),i=F(t),a=Math.max(r.reduce((e,t)=>Math.max(e,F(t)),i),i)+2,o=r.map(e=>`${E(A.bar)} ${e}${` `.repeat(a-F(e))}${E(A.bar)}`).join(`
|
|
4
4
|
`),s=n?A.cornerBL:A.connectL;process.stdout.write(`${E(A.bar)}\n${C(A.submit)} ${t} ${E(A.barH.repeat(Math.max(a-i-1,1))+A.cornerTR)}\n${o}\n${E(s+A.barH.repeat(a+2)+A.cornerBR)}\n`)},L=(e,t=[])=>{process.stdout.write(`${E(A.bar)}\n${C(A.submit)} ${e}\n`);for(let e of t)process.stdout.write(`${E(A.bar)} ${e}\n`)},se=e=>{process.stdout.write(`${E(A.bar)}\n${w(A.submit)} ${w(e)}\n`)},R=(e,t=[])=>{process.stdout.write(`${E(A.bar)}\n${T(A.warn)} ${T(e)}\n`);for(let e of t)process.stdout.write(`${E(A.bar)} ${T(e)}\n`)},z=e=>{let t=e?`${w(A.radioOn)} Yes`:D(`${A.radioOff} Yes`),n=e?D(`${A.radioOff} No`):`${w(A.radioOn)} No`;return`${E(A.bar)} ${t} ${D(`/`)} ${n}`},B=async(e,t=!0)=>{let n=process.stdout;return j()?new Promise(r=>{let i=t,a=process.stdin,o=Math.max(1,Math.ceil((3+F(e))/(n.columns||80)));n.write(`${E(A.bar)}\n${C(A.active)} ${e}\n`),n.write(z(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(A.submit)} ${e} ${D(i?`Yes`:`No`)}\n`),r(i)};function u(t){t===``?(s(),c(),n.write(`${D(A.submit)} ${D(e)}\n`),P(),process.exit(130)):t===`\r`||t===`
|
|
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${z(i)}`))}a.on(`data`,u)}):(n.write(`${E(A.bar)}\n${C(A.submit)} ${e} ${D(t?`Yes`:`No`)}\n`),t)},ce=async(e,t=``)=>{process.stdout.write(`${E(A.bar)}\n${C(A.active)} ${e}${t?` ${D(`(${t})`)}`:``}\n`);let n=
|
|
6
|
-
`);l=t.pop()??``;for(let e of t)s.push(he(e).replace(/\r/g,``).replace(/\t/g,` `).trimEnd()),m()};i.write(a?`${E(A.bar)}\n${C(A.active)} ${n.label}\n${E(A.bar)}\n`:`${E(A.bar)}\n`),f(!1);let g=()=>{f(!0),process.exit(130)};process.once(`SIGINT`,g);try{await
|
|
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${z(i)}`))}a.on(`data`,u)}):(n.write(`${E(A.bar)}\n${C(A.submit)} ${e} ${D(t?`Yes`:`No`)}\n`),t)},ce=async(e,t=``)=>{process.stdout.write(`${E(A.bar)}\n${C(A.active)} ${e}${t?` ${D(`(${t})`)}`:``}\n`);let n=ee({input:process.stdin,output:process.stdout});try{return(await n.question(`${E(A.bar)} `)).trim()||t}finally{n.close()}};var le=class extends Error{constructor(...e){super(...e),this.name=`SubprocessError`,this.stdout=``,this.stderr=``}};const V=[`.exe`,`.com`],H=e=>e.replaceAll(/([()\][%!^"`<>&|;, *?])/g,`^$1`),ue=e=>H(H(`"${e.replaceAll(/(\\*)"/g,`$1$1\\"`).replace(/(\\*)$/,`$1$1`)}"`)),de=async(e,t,n)=>{if(V.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=>V.map(n=>re(`${_(t,e)}${n}`)))),!0}catch{return!1}},fe=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 de(e,i,a)?[H(e),t.map(ue),{...n,shell:!0}]:[e,t,n]},U=async(e,t,n,r)=>{let i=[e,...t].join(` `),[a,o,s]=await fe(e,t,n);s.shell&&o.length>0&&(a=[a,...o].join(` `),o=[]);let c=ne(a,o,s),l=``,u=``;return new Promise((e,t)=>{let n=(e,n,r)=>{let i=new le(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})})})},W=async(e,t,n)=>{let{stdout:r}=await U(e,t,{cwd:n,stdio:[`ignore`,`pipe`,`pipe`]});return r},pe=async(e,t,n)=>{await U(e,t,{cwd:n,stdio:`inherit`})},G=async(e,t)=>{try{return await U(e,t,{stdio:`ignore`}),!0}catch{return!1}},me=RegExp(`\x1B\\[[0-9;?]*[a-zA-Z]`,`g`),he=e=>e.replace(me,``),ge=e=>e>=1e3?`[${(e/1e3).toFixed(2)}s]`:`[${e.toFixed(2)}ms]`,_e=async(e,t,n)=>{let r=Date.now(),i=process.stdout,a=!!n.label;if(!i.isTTY){a&&i.write(`${E(A.bar)}\n${C(A.active)} ${n.label}\n`),await pe(e,t,n.cwd);return}let o=n.lines??3,s=[],c=0,l=``,u=``,d=()=>(i.columns||80)-1,f=e=>{i.write(e?`\x1B[?7h`:`\x1B[?7l`)},p=()=>{c>0&&(i.write(`[${c}A[0J`),c=0)},m=()=>{p();let e=s.slice(-o);for(let t of e)i.write(`${E(A.bar)} ${D(t.slice(0,Math.max(0,d()-3)))}\n`);c=e.length},h=e=>{u+=e,l+=e;let t=l.split(`
|
|
6
|
+
`);l=t.pop()??``;for(let e of t)s.push(he(e).replace(/\r/g,``).replace(/\t/g,` `).trimEnd()),m()};i.write(a?`${E(A.bar)}\n${C(A.active)} ${n.label}\n${E(A.bar)}\n`:`${E(A.bar)}\n`),f(!1);let g=()=>{f(!0),process.exit(130)};process.once(`SIGINT`,g);try{await U(e,t,{cwd:n.cwd,stdio:[`ignore`,`pipe`,`pipe`]},h)}catch(e){throw process.removeListener(`SIGINT`,g),p(),f(!0),i.write(u),e}process.removeListener(`SIGINT`,g),p(),f(!0);let _=n.summarize(u,Date.now()-r).trim();a?(i.write(`\x1B[1A\r\x1B[K`),i.write(`[1A\r[K${C(A.submit)} ${_||n.label}\n`)):i.write(`${C(A.submit)} ${_}\n`)},ve=`pglaunch@5.5.7`,ye=async()=>G(`docker`,[`info`]),be=e=>{let r=h(e,`.env`);if(!s(r)){let i=h(e,`.env.example`);n(r,s(i)?t(i):``)}return r},xe=(e,n)=>{let r=`${n}=`,i=t(e).split(`
|
|
7
7
|
`).find(e=>e.startsWith(r));return i?i.slice(r.length).trim():``},Se=(e,r,i)=>{let a=`${r}=`,o=t(e).split(`
|
|
8
8
|
`),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(`
|
|
9
|
-
`))},Ce=e=>{let t=be(e);xe(t,`BETTER_AUTH_SECRET`)||Se(t,`BETTER_AUTH_SECRET`,te(32).toString(`base64`))},K=e=>{let t=h(e,`.env`);return s(t)&&xe(t,`POSTGRES_URL`)!==``},we=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]:``}},Te=async(e,t)=>{let n=t?[`--bun`,ve,`-k`,`-c`]:[`--bun`,ve,`-k`],r;try{r=await
|
|
10
|
-
`)}return{launch:we(r),out:r}},Ee=e=>new Promise(t=>setTimeout(t,e)),De=async e=>{if(e)for(let t=0;t<30;t++){if(await G(`docker`,[`exec`,e,`pg_isready`,`-U`,`postgres`]))return;await Ee(1e3)}},Oe=async e=>{let t=be(e),n=await Te(e,!1),r=n.launch?n:await Te(e,!0);if(!r.launch)throw Error(r.out.trim()||`pglaunch did not print a connection URL`);Se(t,`POSTGRES_URL`,r.launch.url),await De(r.launch.container);let i=ke(e);await _e(`bun`,[`run`,`db:migrate`],{cwd:e,summarize:(e,t)=>e.includes(`migrations applied successfully`)?`${i} migration${i===1?``:`s`} applied ${ge(t)}`:`Database migrated ${ge(t)}`})},ke=e=>{try{return
|
|
9
|
+
`))},Ce=e=>{let t=be(e);xe(t,`BETTER_AUTH_SECRET`)||Se(t,`BETTER_AUTH_SECRET`,te(32).toString(`base64`))},K=e=>{let t=h(e,`.env`);return s(t)&&xe(t,`POSTGRES_URL`)!==``},we=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]:``}},Te=async(e,t)=>{let n=t?[`--bun`,ve,`-k`,`-c`]:[`--bun`,ve,`-k`],r;try{r=await W(`bunx`,n,e)}catch(e){let t=e;r=[t.stdout,t.stderr].filter(Boolean).join(`
|
|
10
|
+
`)}return{launch:we(r),out:r}},Ee=e=>new Promise(t=>setTimeout(t,e)),De=async e=>{if(e)for(let t=0;t<30;t++){if(await G(`docker`,[`exec`,e,`pg_isready`,`-U`,`postgres`]))return;await Ee(1e3)}},Oe=async e=>{let t=be(e),n=await Te(e,!1),r=n.launch?n:await Te(e,!0);if(!r.launch)throw Error(r.out.trim()||`pglaunch did not print a connection URL`);Se(t,`POSTGRES_URL`,r.launch.url),await De(r.launch.container);let i=ke(e);await _e(`bun`,[`run`,`db:migrate`],{cwd:e,summarize:(e,t)=>e.includes(`migrations applied successfully`)?`${i} migration${i===1?``:`s`} applied ${ge(t)}`:`Database migrated ${ge(t)}`})},ke=e=>{try{return b(h(e,`packages/db/drizzle`)).filter(e=>e.endsWith(`.sql`)).length}catch{return 0}},q=async e=>{await _e(`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`})},Ae=async()=>{if(!await G(`bun`,[`--version`]))throw Error(`bun is not on PATH`)},je=async(e=Ae,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}},Me=async(e,t=`main`)=>{await W(`bunx`,[`--bun`,`gitpick@6.0.0`,`https://github.com/nrjdalal/zerostarter/tree/${t}`,e])},Ne=async(e,t=`main`)=>{await W(`bunx`,[`--bun`,`gitpick@6.0.0`,`https://github.com/nrjdalal/zerostarter/tree/${t}`,e,`-o`])},Pe=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()},Fe=async e=>(await W(`git`,[`status`,`--porcelain`],e)).trim()===``,Ie=async(e,t)=>{for(let n of t)try{await W(`git`,[`checkout`,`--`,n],e),await W(`git`,[`clean`,`-fd`,`--`,n],e)}catch{}},Le=async e=>{await W(`git`,[`reset`,`--hard`,`HEAD`],e),await W(`git`,[`clean`,`-fd`],e)},Re=async(e,t,n)=>{if(!s(h(e,`.git`)))throw Error(t);if(!await Fe(e))throw Error(n)},ze=async(e,t,n)=>{try{await n()}catch(n){throw await Le(e),console.log(t),n}},Be=async e=>{await W(`git`,[`init`,`-q`,`-b`,`canary`],e)},Ve=async(e,t)=>{await W(`git`,[`branch`,t],e)},J=async(e,t)=>{await W(`git`,[`add`,`-A`],e);try{await W(`git`,[`commit`,`--no-verify`,`-q`,`-m`,t],e)}catch{}},He=(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`,Ue=(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`]},We=(e=process.argv.slice(2))=>[`zerostarter`,...e].join(` `),Ge=()=>h(process.env.BUN_INSTALL||h(ie(),`.bun`),`bin`),Y=async(e=!1)=>{if(await je())return;let t=He(),n=`bunx --bun ${We()}`;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||j()&&await B(`Or install bun now and continue?`,!0)){let{cmd:e,args:t}=Ue();console.error(`Installing bun from https://bun.sh/install ...`);try{if(await pe(e,t),process.env.PATH=`${Ge()}${p}${process.env.PATH||``}`,await je())return;console.error(O(`
|
|
11
11
|
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(`
|
|
12
|
-
Could not install bun. Install it from https://bun.sh, then re-run:`)),console.error(k(` ${n}`))}}process.exit(1)},Ke=e=>!v(e)||
|
|
12
|
+
Could not install bun. Install it from https://bun.sh, then re-run:`)),console.error(k(` ${n}`))}}process.exit(1)},Ke=e=>!v(e)||b(e).filter(e=>e!==`.git`).length===0,X=e=>s(h(e,`packages/config/src/site.ts`)),qe=e=>{let t=m(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)}},Je=async e=>{let{positionals:t,values:n}=x({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:
|
|
13
13
|
$ bunx zerostarter init [dir] [options]
|
|
14
14
|
|
|
15
15
|
Scaffold ZeroStarter into dir (default .) as a fresh product. The author's
|
|
@@ -22,9 +22,9 @@ Options:
|
|
|
22
22
|
-y, --yes Skip prompts, taking defaults (provisions Postgres when Docker is running)
|
|
23
23
|
--db Provision a local Postgres (pglaunch) and migrate; needs Docker
|
|
24
24
|
--dry-run Print the plan without writing anything
|
|
25
|
-
-h, --help Display help`);return}n[`dry-run`]||await Y(!!n.yes);let r=j()&&!n.yes,i=t[0]??`.`,a=_(i),o=X(a)
|
|
26
|
-
`).filter(e=>e.trim()).slice(-5):[])}}else
|
|
27
|
-
`),`Edit and make it yours`),se(`${
|
|
25
|
+
-h, --help Display help`);return}n[`dry-run`]||await Y(!!n.yes);let r=j()&&!n.yes,i=t[0]??`.`,a=_(i),o=X(a);if(!o&&!n[`dry-run`]){let e=qe(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`]||M(C(`https://zerostarter.dev`)),!o&&!Ke(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 ce(`What should we name your project?`);if(!e)throw Error(`No directory name provided.`);i=e}let c=_(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 B(`Convert ${l} in place? This rewrites files and commits.`,!1)){P(`Aborted`);return}X(c)||(await Me(c),L(`Fetched the latest ZeroStarter`)),s(h(c,`.git`))||(await Be(c),await J(c,`ci(init): scaffold from zerostarter`),await Ve(c,`main`)),u(c,d),L(`Rebranded to ${l}`),await q(c),await J(c,`ci(init): re-baseline as ${l}`),Ce(c);let p=!1,m=await ye(),g=K(c),v=!1;if(g?n.db&&R(`--db ignored: POSTGRES_URL is already set in .env.`):v=n.db?!0:r?await B(`Provision a local Postgres database now?`,m):m,v&&m)try{await Oe(c),p=!0}catch(e){if(K(c))R(`Postgres is provisioned, but the migration failed; run bun run db:migrate.`);else{let t=e instanceof Error?e.message.trim():String(e);R(`Database setup failed; set POSTGRES_URL in .env yourself.`,t?t.split(`
|
|
26
|
+
`).filter(e=>e.trim()).slice(-5):[])}}else v&&R(`Docker isn't running, so the database wasn't provisioned. Set POSTGRES_URL in .env, or start Docker and re-run for automatic setup.`);I([`${k(`packages/config/src/site.ts`)} and ${k(`web/next/content`)}`,`to manage branding and blogs & docs respectively`].join(`
|
|
27
|
+
`),`Edit and make it yours`),se(`${l} is ready`);let y=[];c!==process.cwd()&&y.push(k(`cd ${i}`)),K(c)||y.push(`set POSTGRES_URL in .env`),p||y.push(k(`bun run db:migrate`)),y.push(k(`bun run dev`)),I(y.join(`
|
|
28
28
|
`),`Next steps`),N(`Learn more ${C(`https://zerostarter.dev/docs`)}`)},Ye=async t=>{let{positionals:n,values:r}=x({allowPositionals:!0,args:t,options:{help:{short:`h`,type:`boolean`},yes:{short:`y`,type:`boolean`}}});if(r.help){console.log(`Usage:
|
|
29
29
|
$ bunx zerostarter reinit [dir] [options]
|
|
30
30
|
|
|
@@ -35,8 +35,7 @@ branch; push when ready.
|
|
|
35
35
|
|
|
36
36
|
Options:
|
|
37
37
|
-y, --yes Skip the confirmation prompt
|
|
38
|
-
-h, --help Display help`);return}await Y(!!r.yes);let i=_(n[0]??`.`),a=f(i),o=j()&&!r.yes;if(await Re(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.`),M(C(`https://zerostarter.dev`)),o&&!await B(`Delete every file in ${a} (keeping .git and .env*) and re-scaffold?`,!1)){P(`Aborted`);return}await ze(i,T(`reinit failed; restored your committed files (deleted gitignored files, except .env*, are gone).`),async()=>{e(i),await Ne(i),L(`Fetched the latest ZeroStarter (kept .git and .env*)`),u(i,{name:a}),L(`Rebranded to ${a}`),await q(i),Ce(i),await J(i,`ci(reinit): re-baseline as ${a}`)});
|
|
39
|
-
`),`Next steps`),N(w(`${a} re-scaffolded; .git history, remote, and .env* files are intact`))},Xe=async e=>{let{positionals:t,values:n}=x({allowPositionals:!0,args:e,options:{help:{short:`h`,type:`boolean`}}});if(n.help){console.log(`Usage:
|
|
38
|
+
-h, --help Display help`);return}await Y(!!r.yes);let i=_(n[0]??`.`),a=f(i),o=j()&&!r.yes;if(await Re(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.`),M(C(`https://zerostarter.dev`)),o&&!await B(`Delete every file in ${a} (keeping .git and .env*) and re-scaffold?`,!1)){P(`Aborted`);return}await ze(i,T(`reinit failed; restored your committed files (deleted gitignored files, except .env*, are gone).`),async()=>{e(i),await Ne(i),L(`Fetched the latest ZeroStarter (kept .git and .env*)`),u(i,{name:a}),L(`Rebranded to ${a}`),await q(i),Ce(i),await J(i,`ci(reinit): re-baseline as ${a}`)}),N(w(`${a} re-scaffolded; .git history, remote, and .env* files are intact`)),console.log(),console.log(`Next steps:`),K(i)||console.log(` ${k(`set POSTGRES_URL in .env`)} # your Postgres connection string`),console.log(` ${k(`bun run db:migrate`)}`),console.log(` ${k(`bun run dev`)}`),console.log(` ${k(`git push`)} # to your existing remote`)},Xe=async e=>{let{positionals:t,values:n}=x({allowPositionals:!0,args:e,options:{help:{short:`h`,type:`boolean`}}});if(n.help){console.log(`Usage:
|
|
40
39
|
$ bunx zerostarter sync [dir] [options]
|
|
41
40
|
|
|
42
41
|
Re-baseline an existing fork (default .) on the latest ZeroStarter: a gitpick overlay
|
|
@@ -45,8 +44,7 @@ identity, and favicon are preserved. Requires a clean tree; lands as a reviewabl
|
|
|
45
44
|
you commit yourself.
|
|
46
45
|
|
|
47
46
|
Options:
|
|
48
|
-
-h, --help Display help`);return}await Y();let u=_(t[0]??`.`);await Re(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.`),M(C(`https://zerostarter.dev`));let f=h(u,`package.json`),p=new Map(l(u).map(e=>[e,a(e)])),m=i(await Pe());m.length===0&&R(`No PRESERVE_ON_SYNC directive found; fork-owned files may be overwritten.`),await ze(u,T(`Sync failed; rolled the working tree back to your last commit.`),async()=>{await Ne(u),o(u),d(h(u,`.gitpickignore`));for(let[e,t]of p)s(e)&&r(e,c(t,a(e),e===f));await Ie(u,m)}),L(`Overlaid the latest ZeroStarter (content, public/marketing, and branding preserved)`),await q(u),
|
|
49
|
-
`),`Review the changes`),N(k(`Synced to the latest ZeroStarter`))},{author:Z,name:Q,version:Ze}=ae,$=`Version:
|
|
47
|
+
-h, --help Display help`);return}await Y();let u=_(t[0]??`.`);await Re(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.`),M(C(`https://zerostarter.dev`));let f=h(u,`package.json`),p=new Map(l(u).map(e=>[e,a(e)])),m=i(await Pe());m.length===0&&R(`No PRESERVE_ON_SYNC directive found; fork-owned files may be overwritten.`),await ze(u,T(`Sync failed; rolled the working tree back to your last commit.`),async()=>{await Ne(u),o(u),d(h(u,`.gitpickignore`));for(let[e,t]of p)s(e)&&r(e,c(t,a(e),e===f));await Ie(u,m)}),L(`Overlaid the latest ZeroStarter (content, public/marketing, and branding preserved)`),await q(u),N(k(`Synced to the latest ZeroStarter`)),console.log(),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:Ze}=ae,$=`Version:
|
|
50
48
|
${Q}@${Ze}
|
|
51
49
|
|
|
52
50
|
Go from zero to a production-ready SaaS, rebranded and ready to ship.
|