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