zerostarter 0.0.0-091adc1 → 0.0.0-0bef4db
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 +42 -9
- package/dist/convert-DMU8fiBc.mjs +104 -0
- package/dist/index.mjs +1 -1
- package/package.json +1 -1
- package/dist/convert-BzMTXW9D.mjs +0 -110
package/dist/bin/index.mjs
CHANGED
|
@@ -1,28 +1,61 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import{
|
|
3
|
-
$
|
|
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-0bef4db`,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`)},ie=e=>{process.stdout.write(`${E(k.bar)}\n${E(k.barEnd)} ${e}\n`)},N=(e=`Cancelled`)=>{process.stdout.write(`${E(k.bar)}\n${E(k.barEnd)} ${O(e)}\n`)},P=e=>e.replace(RegExp(`\x1B\\[[0-9;?]*[a-zA-Z]`,`g`),``).replace(RegExp(`\x1B\\]8;;.*?\\x07`,`g`),``).length,F=(e,t=``)=>{let n=`\n${e}\n`.split(`
|
|
3
|
+
`),r=P(t),i=Math.max(n.reduce((e,t)=>Math.max(e,P(t)),r),r)+2,a=n.map(e=>`${E(k.bar)} ${e}${` `.repeat(i-P(e))}${E(k.bar)}`).join(`
|
|
4
|
+
`);process.stdout.write(`${E(k.bar)}\n${T(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`)},ae=e=>{process.stdout.write(`${E(k.bar)}\n${C(k.submit)} ${C(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`)},oe=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,n=!1)=>{let r=process.stdout;return A()?new Promise(i=>{let a=t,o=process.stdin;r.write(`${E(k.bar)}\n${T(k.active)} ${e}\n`),r.write(oe(a)),o.setRawMode(!0),o.resume(),o.setEncoding(`utf8`);let s=()=>{o.setRawMode(!1),o.pause(),o.removeListener(`data`,l)},c=()=>{s(),r.write(`\r\x1B[K\x1B[1A\r\x1B[K`),n?r.write(`\x1B[1A\r\x1B[K`):r.write(`${T(k.submit)} ${e} ${D(a?`Yes`:`No`)}\n`),i(a)};function l(t){t===``?(s(),r.write(`\r\x1b[K\x1b[1A\r\x1b[K${D(k.submit)} ${D(e)}\n`),N(),process.exit(130)):t===`\r`||t===`
|
|
5
|
+
`?c():t===`y`||t===`Y`?(a=!0,c()):t===`n`||t===`N`?(a=!1,c()):(t===`\x1B[C`||t===`\x1B[D`||t===`\x1B[A`||t===`\x1B[B`||t===`h`||t===`l`)&&(a=!a,r.write(`\r\x1b[K${oe(a)}`))}o.on(`data`,l)}):(n||r.write(`${E(k.bar)}\n${T(k.submit)} ${e} ${D(t?`Yes`:`No`)}\n`),t)},se=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 ce=class extends Error{constructor(...e){super(...e),this.name=`SubprocessError`,this.stdout=``,this.stderr=``}};const z=[`.exe`,`.com`],B=e=>e.replaceAll(/([()\][%!^"`<>&|;, *?])/g,`^$1`),le=e=>B(B(`"${e.replaceAll(/(\\*)"/g,`$1$1\\"`).replace(/(\\*)$/,`$1$1`)}"`)),ue=async(e,t,n)=>{if(z.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=>z.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)?[B(e),t.map(le),{...n,shell:!0}]:[e,t,n]},V=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=ee(a,o,s),l=``,u=``;return new Promise((e,t)=>{let n=(e,n,r)=>{let i=new ce(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})})})},H=async(e,t,n)=>{let{stdout:r}=await V(e,t,{cwd:n,stdio:[`ignore`,`pipe`,`pipe`]});return r},U=async(e,t,n)=>{await V(e,t,{cwd:n,stdio:`inherit`})},W=async(e,t)=>{try{return await V(e,t,{stdio:`ignore`}),!0}catch{return!1}},fe=RegExp(`\x1B\\[[0-9;?]*[a-zA-Z]`,`g`),pe=e=>e.replace(fe,``),G=e=>e>=1e3?`[${(e/1e3).toFixed(2)}s]`:`[${e.toFixed(2)}ms]`,me=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 U(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 V(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`)},he=`pglaunch@5.5.7`,ge=async()=>W(`docker`,[`info`]),_e=e=>{let r=m(e,`.env`);if(!s(r)){let i=m(e,`.env.example`);n(r,s(i)?t(i):``)}return r},ve=(e,n)=>{let r=`${n}=`,i=t(e).split(`
|
|
7
|
+
`).find(e=>e.startsWith(r));return i?i.slice(r.length).trim():``},ye=(e,r,i)=>{let a=`${r}=`,o=t(e).split(`
|
|
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
|
+
`))},be=e=>{let t=_e(e);ve(t,`BETTER_AUTH_SECRET`)||ye(t,`BETTER_AUTH_SECRET`,b(32).toString(`base64`))},K=e=>{let t=m(e,`.env`);return s(t)&&ve(t,`POSTGRES_URL`)!==``},xe=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]:``}},Se=async(e,t)=>{let n=t?[`--bun`,he,`-k`,`-c`]:[`--bun`,he,`-k`],r;try{r=await H(`bunx`,n,e)}catch(e){let t=e;r=[t.stdout,t.stderr].filter(Boolean).join(`
|
|
10
|
+
`)}return xe(r)},Ce=e=>new Promise(t=>setTimeout(t,e)),we=async e=>{if(e)for(let t=0;t<30;t++){if(await W(`docker`,[`exec`,e,`pg_isready`,`-U`,`postgres`]))return;await Ce(1e3)}},Te=async e=>{let t=_e(e),n=await Se(e,!1)||await Se(e,!0);if(!n)throw Error(`pglaunch did not print a connection URL`);ye(t,`POSTGRES_URL`,n.url),await we(n.container);let r=Ee(e);await me(`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 ${G(t)}`:`Database migrated ${G(t)}`})},Ee=e=>{try{return _(m(e,`packages/db/drizzle`)).filter(e=>e.endsWith(`.sql`)).length}catch{return 0}},q=async e=>{await me(`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`})},De=async()=>{if(!await W(`bun`,[`--version`]))throw Error(`bun is not on PATH`)},Oe=async(e=De,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}},ke=async(e,t=`main`)=>{await H(`bunx`,[`--bun`,`gitpick@6.0.0`,`https://github.com/nrjdalal/zerostarter/tree/${t}`,e])},Ae=async(e,t=`main`)=>{await H(`bunx`,[`--bun`,`gitpick@6.0.0`,`https://github.com/nrjdalal/zerostarter/tree/${t}`,e,`-o`])},je=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()},Me=async e=>(await H(`git`,[`status`,`--porcelain`],e)).trim()===``,Ne=async(e,t)=>{for(let n of t)try{await H(`git`,[`checkout`,`--`,n],e),await H(`git`,[`clean`,`-fd`,`--`,n],e)}catch{}},Pe=async e=>{await H(`git`,[`reset`,`--hard`,`HEAD`],e),await H(`git`,[`clean`,`-fd`],e)},Fe=async(e,t,n)=>{if(!s(m(e,`.git`)))throw Error(t);if(!await Me(e))throw Error(n)},Ie=async(e,t,n)=>{try{await n()}catch(n){throw await Pe(e),console.log(t),n}},Le=async e=>{await H(`git`,[`init`,`-q`,`-b`,`canary`],e)},Re=async(e,t)=>{await H(`git`,[`branch`,t],e)},J=async(e,t)=>{await H(`git`,[`add`,`-A`],e);try{await H(`git`,[`commit`,`--no-verify`,`-q`,`-m`,t],e)}catch{}},ze=(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`,Be=(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`]},Ve=(e=process.argv.slice(2))=>[`zerostarter`,...e].join(` `),He=()=>m(process.env.BUN_INSTALL||m(ne(),`.bun`),`bin`),Y=async(e=!1)=>{if(await Oe())return;let t=ze(),n=`bunx --bun ${Ve()}`;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}=Be();console.error(`Installing bun from https://bun.sh/install ...`);try{if(await U(e,t),process.env.PATH=`${He()}${p}${process.env.PATH||``}`,await Oe())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)},Ue=e=>!g(e)||_(e).filter(e=>e!==`.git`).length===0,X=e=>s(m(e,`packages/config/src/site.ts`)),We=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:
|
|
13
|
+
$ bunx zerostarter init [dir] [options]
|
|
4
14
|
|
|
5
15
|
Scaffold ZeroStarter into dir (default .) as a fresh product. The author's
|
|
6
|
-
content
|
|
16
|
+
content and public assets are left out for you to supply; the
|
|
7
17
|
dir name becomes the project name and site.ts + package.json are rebranded. If
|
|
8
18
|
the dir already holds a ZeroStarter clone it is used in place; otherwise the
|
|
9
19
|
latest ZeroStarter is fetched into it first.
|
|
10
20
|
|
|
11
21
|
Options:
|
|
12
|
-
-y, --yes Skip prompts
|
|
22
|
+
-y, --yes Skip prompts, taking defaults (provisions Postgres when Docker is running)
|
|
23
|
+
--db Provision a local Postgres (pglaunch) and migrate; needs Docker
|
|
13
24
|
--dry-run Print the plan without writing anything
|
|
14
|
-
-h, --help Display help`);return}let
|
|
15
|
-
Make it yours
|
|
16
|
-
|
|
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&&!Ue(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 se(`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)){N(`Aborted`);return}X(c)||(await ke(c),I(`Fetched the latest ZeroStarter`)),s(m(c,`.git`))||(await Le(c),await J(c,`ci(init): scaffold from zerostarter`),await Re(c,`main`)),u(c,d),I(`Rebranded to ${l}`),await q(c),await J(c,`ci(init): re-baseline as ${l}`),be(c);let p=!1,g=await ge(),_=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,!0):g,v&&g)try{await Te(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.`);F([`Edit ${S(`packages/config/src/site.ts`)} to manage branding`,`Edit ${S(`web/next/content`)} to manage blog and docs`].join(`
|
|
26
|
+
`),`Make it yours`),ae(`${l} is ready`);let 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`)),F(b.join(`
|
|
27
|
+
`),`Next steps`),p||console.log(`
|
|
28
|
+
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.`)},Ge=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:
|
|
29
|
+
$ bunx zerostarter reinit [dir] [options]
|
|
30
|
+
|
|
31
|
+
Re-scaffold an existing git repo (default .) as a fresh ZeroStarter: delete every
|
|
32
|
+
file (keeping .git and your .env* files, so history, remote, and secrets survive), fetch the
|
|
33
|
+
latest ZeroStarter, and rebrand to the dir name. The commit lands on the current
|
|
34
|
+
branch; push when ready.
|
|
35
|
+
|
|
36
|
+
Options:
|
|
37
|
+
-y, --yes Skip the confirmation prompt
|
|
38
|
+
-h, --help Display help`);return}await Y(!!r.yes);let i=h(n[0]??`.`),a=f(i),o=A()&&!r.yes;if(await Fe(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)){N(`Aborted`);return}await Ie(i,w(`reinit failed; restored your committed files (deleted gitignored files, except .env*, are gone).`),async()=>{e(i),await Ae(i),I(`Fetched the latest ZeroStarter (kept .git and .env*)`),u(i,{name:a}),I(`Rebranded to ${a}`),await q(i),be(i),await J(i,`ci(reinit): re-baseline as ${a}`)}),ie(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`)},Ke=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
|
+
$ bunx zerostarter sync [dir] [options]
|
|
40
|
+
|
|
41
|
+
Re-baseline an existing fork (default .) on the latest ZeroStarter: a gitpick overlay
|
|
42
|
+
updates the starter files while your content, public/marketing, branding, package.json
|
|
43
|
+
identity, and favicon are preserved. Requires a clean tree; lands as a reviewable diff
|
|
44
|
+
you commit yourself.
|
|
45
|
+
|
|
46
|
+
Options:
|
|
47
|
+
-h, --help Display help`);return}await Y();let u=h(t[0]??`.`);await Fe(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 je());g.length===0&&L(`No PRESERVE_ON_SYNC directive found; fork-owned files may be overwritten.`),await Ie(u,w(`Sync failed; rolled the working tree back to your last commit.`),async()=>{await Ae(u),o(u),d(m(u,`.gitpickignore`));for(let[e,t]of p)s(e)&&r(e,c(t,a(e),e===f));await Ne(u,g)}),I(`Overlaid the latest ZeroStarter (content, public/marketing, and branding preserved)`),await q(u),ie(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:qe}=re,$=`Version:
|
|
48
|
+
${Q}@${qe}
|
|
17
49
|
|
|
18
50
|
Go from zero to a production-ready SaaS, rebranded and ready to ship.
|
|
19
51
|
|
|
20
52
|
Usage:
|
|
21
|
-
$ ${
|
|
53
|
+
$ ${Q} <command> [options]
|
|
22
54
|
|
|
23
55
|
Commands:
|
|
24
56
|
init [dir] Scaffold ZeroStarter into dir (default .) as a fresh product.
|
|
25
57
|
The dir name becomes the project name.
|
|
58
|
+
reinit [dir] Re-scaffold an existing git repo as a fresh ZeroStarter (keeps .git and .env)
|
|
26
59
|
sync Re-baseline an existing fork on ZeroStarter's latest scaffold
|
|
27
60
|
|
|
28
61
|
Options:
|
|
@@ -30,4 +63,4 @@ Options:
|
|
|
30
63
|
-h, --help Display help
|
|
31
64
|
|
|
32
65
|
Author:
|
|
33
|
-
${
|
|
66
|
+
${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 We(n);case`reinit`:return await Ge(n);case`sync`:return await Ke(n);case void 0:case`-h`:case`--help`:console.log($);return;case`-v`:case`--version`:console.log(`${Q}@${qe}`);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{};
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
import{dirname as e,join as t}from"node:path";import{existsSync as n,mkdirSync as r,readFileSync as i,readdirSync as a,rmSync as o,writeFileSync as s}from"node:fs";const c=e=>n(e),l=e=>i(e,`utf8`),u=(t,n)=>{r(e(t),{recursive:!0}),s(t,n)},d=e=>{o(e,{force:!0,recursive:!0})},f=new Set([`node_modules`,`.next`,`.turbo`,`dist`]),p=(e,n=!0)=>{for(let r of a(e,{withFileTypes:!0})){let i=t(e,r.name);if(r.name===`.git`){if(n)continue;o(i,{force:!0,recursive:!0});continue}r.isDirectory()?f.has(r.name)?o(i,{force:!0,recursive:!0}):(p(i,!1),a(i).length===0&&o(i,{force:!0,recursive:!0})):r.name.startsWith(`.env`)||o(i,{force:!0})}},m=e=>{let n=[];for(let r of a(e,{withFileTypes:!0})){if(r.name===`.git`||f.has(r.name))continue;let i=t(e,r.name);r.isDirectory()?n.push(...m(i)):r.name===`package.json`&&n.push(i)}return n},h=e=>JSON.parse(l(e)),g=(e,t)=>{u(e,`${JSON.stringify(t,null,2)}\n`)},_=(e,t)=>{if(!n(e))return!1;let r=l(e),i=r.replace(t,``);return i===r?!1:(s(e,i),!0)},v=[`homepage`,`bugs`,`license`,`author`,`repository`,`funding`],y=[`name`,`version`,...v],b=e=>{let t=e.split(`
|
|
2
|
+
`).find(e=>e.trim().startsWith(`# PRESERVE_ON_SYNC`));return t?t.trim().slice(18).replace(/^\s*-\s*/,``).split(`,`).map(e=>e.trim()).filter(Boolean):[]},x=(e,t)=>{let n={...e,...t};return Object.keys(n).length>0?n:void 0},S=(e,t)=>{let n=Array.isArray(e)?e:[],r=Array.isArray(t)?t:[];return n.length||r.length?[...new Set([...r,...n])]:void 0},C=[`dependencies`,`devDependencies`,`optionalDependencies`,`peerDependencies`,`resolutions`,`catalog`,`scripts`,`overrides`],w=(e,t,n)=>{let r={...t};for(let n of Object.keys(e))n in t||(r[n]=e[n]);for(let n of C){let i=x(e[n],t[n]);i&&(r[n]=i)}let i=S(e.workspaces,t.workspaces);if(i&&(r.workspaces=i),n)for(let t of y)t in e?r[t]=e[t]:delete r[t];return r},T=({name:e})=>{let t=e.charAt(0).toUpperCase()+e.slice(1);return`// Brand identity for this app: the single source a fork edits to rebrand. web reads it via lib/config.ts.
|
|
3
|
+
export const site = {
|
|
4
|
+
name: "${t}",
|
|
5
|
+
description: "${t} is just getting started. Tell its story here.",
|
|
6
|
+
tagline: "Your tagline, ready when you are.",
|
|
7
|
+
social: {
|
|
8
|
+
github: "",
|
|
9
|
+
x: "",
|
|
10
|
+
discord: "",
|
|
11
|
+
},
|
|
12
|
+
// Local-only dev agent identity (api/hono agents router).
|
|
13
|
+
agent: {
|
|
14
|
+
name: "LocalAgent",
|
|
15
|
+
email: "agent@local.host",
|
|
16
|
+
},
|
|
17
|
+
// Injectable long-form text blocks. A product sets its own, or leaves them empty.
|
|
18
|
+
apiReferenceDescription: "",
|
|
19
|
+
llmsFullPreamble: "",
|
|
20
|
+
} as const
|
|
21
|
+
|
|
22
|
+
export type Site = typeof site
|
|
23
|
+
`},E=()=>`import { redirect } from "next/navigation"
|
|
24
|
+
|
|
25
|
+
// Fresh fork: redirect to the waitlist until you build your real home page.
|
|
26
|
+
export default function Home() {
|
|
27
|
+
redirect("/waitlist")
|
|
28
|
+
}
|
|
29
|
+
`,D=()=>'# AGENTS.md\n\nGuidance for AI coding agents working in this repository.\n\n## Instructions\n\n- ALWAYS: Use `@/` for imports, and follow the `design` skill for UI and styling conventions.\n- ALWAYS: Keep documentation in sync with every change.\n- NEVER: Include "Co-authored-by" in commit messages.\n- NEVER: Use em-dashes (the long dash, U+2014) in code, comments, docs, or copy. Regular hyphens are fine; for a pause or aside, use a comma, colon, or period.\n\n## Skills\n\nCustom skills live in `.agents/skills` (symlinked to `.claude/skills`). Start with the `codebase-map` skill to orient, then load the task skill that fits (`api-endpoint`, `db-migration`, `dev`, `design`, and more).\n',O=({name:e})=>`# ${e.charAt(0).toUpperCase()+e.slice(1)}
|
|
30
|
+
|
|
31
|
+
Built on top of [ZeroStarter](https://zerostarter.dev).
|
|
32
|
+
|
|
33
|
+
## Development
|
|
34
|
+
|
|
35
|
+
\`\`\`bash
|
|
36
|
+
bun run dev
|
|
37
|
+
\`\`\`
|
|
38
|
+
|
|
39
|
+
Web runs on http://localhost:3000 and the API on http://localhost:4000.
|
|
40
|
+
`,k=()=>`---
|
|
41
|
+
slug: /docs
|
|
42
|
+
title: Introduction
|
|
43
|
+
description: Documentation.
|
|
44
|
+
---
|
|
45
|
+
|
|
46
|
+
# Introduction
|
|
47
|
+
|
|
48
|
+
This is your documentation home. Start writing, this page is yours.
|
|
49
|
+
`,A=()=>`---
|
|
50
|
+
slug: /console/docs
|
|
51
|
+
title: Introduction
|
|
52
|
+
description: Internal documentation.
|
|
53
|
+
---
|
|
54
|
+
|
|
55
|
+
# Introduction
|
|
56
|
+
|
|
57
|
+
Your team's internal docs live here.
|
|
58
|
+
`,j=e=>`---
|
|
59
|
+
title: Blog
|
|
60
|
+
description: Latest articles and updates
|
|
61
|
+
createdAt: ${e}
|
|
62
|
+
---
|
|
63
|
+
|
|
64
|
+
## Recent Posts
|
|
65
|
+
|
|
66
|
+
<BlogPostList />
|
|
67
|
+
`,M=e=>`---
|
|
68
|
+
title: Hello World
|
|
69
|
+
description: The first post on your new blog.
|
|
70
|
+
createdAt: ${e}
|
|
71
|
+
publishedAt: ${e}
|
|
72
|
+
---
|
|
73
|
+
|
|
74
|
+
## Hello World
|
|
75
|
+
|
|
76
|
+
Your very first post. Replace it with something worth reading.
|
|
77
|
+
`,N=()=>`import type { DocsConfig } from "./src/lib/docs/types"
|
|
78
|
+
|
|
79
|
+
const docsConfig = {
|
|
80
|
+
docs: {
|
|
81
|
+
"Getting Started": [
|
|
82
|
+
{
|
|
83
|
+
"/docs": {
|
|
84
|
+
title: "Introduction",
|
|
85
|
+
description: "Documentation.",
|
|
86
|
+
},
|
|
87
|
+
},
|
|
88
|
+
],
|
|
89
|
+
},
|
|
90
|
+
console: {
|
|
91
|
+
"Getting Started": [
|
|
92
|
+
{
|
|
93
|
+
"/console/docs": {
|
|
94
|
+
title: "Introduction",
|
|
95
|
+
description: "Internal documentation.",
|
|
96
|
+
},
|
|
97
|
+
},
|
|
98
|
+
],
|
|
99
|
+
},
|
|
100
|
+
} satisfies DocsConfig
|
|
101
|
+
|
|
102
|
+
export default docsConfig
|
|
103
|
+
`,P=(e,...n)=>t(e,...n),F=e=>e.toLowerCase().replace(/[^a-z0-9]+/g,`-`).replace(/^-+|-+$/g,``)||`app`,I=e=>{let t=P(e,`.gitpickignore`);if(c(t)){for(let n of l(t).split(`
|
|
104
|
+
`)){let t=n.trim();if(!(!t||t.startsWith(`#`))){if(/[*?![\]]/.test(t))throw Error(`.gitpickignore entry "${t}" is not a literal path; the in-place converter only supports literal paths (a glob or negation would diverge from gitpick's fetch).`);d(P(e,t))}}d(t)}},L=/\r?\nexport const caveat = localFont\(\{[\s\S]*?\r?\n\}\)\r?\n/,R=/\r?\nexport const newsreader = localFont\(\{[\s\S]*?\r?\n\}\)\r?\n/,z=/[ \t]*\{[^}\r\n]*href:[ \t]*["']\/hire["'][^}\r\n]*\},?[ \t]*\r?\n/,B=(e,t)=>{let n=new Date,r=n.toISOString().slice(0,10),i=[n.getFullYear(),n.getMonth()+1,n.getDate()].map(e=>String(e).padStart(2,`0`)).join(`-`),a=i<r?i:r;u(P(e,`web/next/content/docs/index.mdx`),k()),u(P(e,`web/next/content/blog/index.mdx`),j(a)),u(P(e,`web/next/content/blog/hello-world.mdx`),M(a)),u(P(e,`web/next/content/console/docs/index.mdx`),A()),u(P(e,`web/next/docs.config.ts`),N()),u(P(e,`web/next/public/.gitkeep`),``),u(P(e,`web/next/src/app/page.tsx`),E()),u(P(e,`AGENTS.md`),D()),u(P(e,`README.md`),O(t))},V=e=>{let t=P(e,`web/next/src/lib/fonts.ts`),n=P(e,`web/next/src/components/navbar/home.tsx`);if(_(t,L),_(t,R),_(n,z),c(t)&&l(t).includes(`fonts/marketing/`))throw Error(`fonts.ts still references fonts/marketing/ after fixDangling (regex drift). Update packages/cli/src/convert.ts.`);if(c(n)&&/href:\s*["']\/hire["']/.test(l(n)))throw Error(`navbar/home.tsx still has the /hire entry after fixDangling (regex drift). Update packages/cli/src/convert.ts.`)},H=(e,t)=>{u(P(e,`packages/config/src/site.ts`),T(t));let n=P(e,`package.json`),r=h(n);r.name=F(t.name),r.version=`0.0.0`;for(let e of v)delete r[e];g(n,r)},U=(e,t)=>{I(e),B(e,t),V(e),H(e,t)};export{p as a,l as c,u as d,g as f,b as i,h as l,V as n,c as o,w as r,m as s,U as t,d as u};
|
package/dist/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{t as e}from"./convert-
|
|
1
|
+
import{t as e}from"./convert-DMU8fiBc.mjs";export{e as convertRepo};
|
package/package.json
CHANGED
|
@@ -1,110 +0,0 @@
|
|
|
1
|
-
import{dirname as e,join as t}from"node:path";import{existsSync as n,mkdirSync as r,readFileSync as i,rmSync as a,writeFileSync as o}from"node:fs";const s=e=>n(e),c=e=>i(e,`utf8`),l=(t,n)=>{r(e(t),{recursive:!0}),o(t,n)},u=e=>{a(e,{force:!0,recursive:!0})},d=e=>JSON.parse(c(e)),f=(e,t)=>{l(e,`${JSON.stringify(t,null,2)}\n`)},p=(e,t)=>{if(!n(e))return!1;let r=c(e),i=r;for(let[e,n]of t)i=i.split(e).join(n);return i===r?!1:(o(e,i),!0)},m=({name:e})=>{let t=e.charAt(0).toUpperCase()+e.slice(1);return`// Brand identity for this app: the single source a fork edits to rebrand. web reads it via lib/config.ts.
|
|
2
|
-
export const site = {
|
|
3
|
-
name: "${t}",
|
|
4
|
-
description: "${t} is just getting started. Tell its story here.",
|
|
5
|
-
tagline: "Your tagline, ready when you are.",
|
|
6
|
-
social: {
|
|
7
|
-
github: "",
|
|
8
|
-
x: "",
|
|
9
|
-
discord: "",
|
|
10
|
-
},
|
|
11
|
-
// Local-only dev agent identity (api/hono agents router).
|
|
12
|
-
agent: {
|
|
13
|
-
name: "LocalAgent",
|
|
14
|
-
email: "agent@local.host",
|
|
15
|
-
},
|
|
16
|
-
// Injectable long-form text blocks. A product sets its own, or leaves them empty.
|
|
17
|
-
apiReferenceDescription: "",
|
|
18
|
-
llmsFullPreamble: "",
|
|
19
|
-
} as const
|
|
20
|
-
|
|
21
|
-
export type Site = typeof site
|
|
22
|
-
`},h=()=>`import { redirect } from "next/navigation"
|
|
23
|
-
|
|
24
|
-
// Fresh fork: redirect to the waitlist until you build your real home page.
|
|
25
|
-
export default function Home() {
|
|
26
|
-
redirect("/waitlist")
|
|
27
|
-
}
|
|
28
|
-
`,g=()=>`# AGENTS.md
|
|
29
|
-
|
|
30
|
-
Guidance for AI coding agents working in this repository.
|
|
31
|
-
`,_=()=>`---
|
|
32
|
-
slug: /docs
|
|
33
|
-
title: Introduction
|
|
34
|
-
description: Documentation.
|
|
35
|
-
---
|
|
36
|
-
|
|
37
|
-
# Introduction
|
|
38
|
-
|
|
39
|
-
This is your documentation home. Start writing, this page is yours.
|
|
40
|
-
`,v=()=>`---
|
|
41
|
-
slug: /console/docs
|
|
42
|
-
title: Introduction
|
|
43
|
-
description: Internal documentation.
|
|
44
|
-
---
|
|
45
|
-
|
|
46
|
-
# Introduction
|
|
47
|
-
|
|
48
|
-
Your team's internal docs live here.
|
|
49
|
-
`,y=e=>`---
|
|
50
|
-
title: Blog
|
|
51
|
-
description: Latest articles and updates
|
|
52
|
-
createdAt: ${e}
|
|
53
|
-
---
|
|
54
|
-
|
|
55
|
-
## Recent Posts
|
|
56
|
-
|
|
57
|
-
<BlogPostList />
|
|
58
|
-
`,b=e=>`---
|
|
59
|
-
title: Hello World
|
|
60
|
-
description: The first post on your new blog.
|
|
61
|
-
createdAt: ${e}
|
|
62
|
-
publishedAt: ${e}
|
|
63
|
-
---
|
|
64
|
-
|
|
65
|
-
## Hello World
|
|
66
|
-
|
|
67
|
-
Your very first post. Replace it with something worth reading.
|
|
68
|
-
`,x=()=>`import type { DocsConfig } from "./src/lib/docs/types"
|
|
69
|
-
|
|
70
|
-
const docsConfig = {
|
|
71
|
-
docs: {
|
|
72
|
-
"Getting Started": [
|
|
73
|
-
{
|
|
74
|
-
"/docs": {
|
|
75
|
-
title: "Introduction",
|
|
76
|
-
description: "Documentation.",
|
|
77
|
-
},
|
|
78
|
-
},
|
|
79
|
-
],
|
|
80
|
-
},
|
|
81
|
-
console: {
|
|
82
|
-
"Getting Started": [
|
|
83
|
-
{
|
|
84
|
-
"/console/docs": {
|
|
85
|
-
title: "Introduction",
|
|
86
|
-
description: "Internal documentation.",
|
|
87
|
-
},
|
|
88
|
-
},
|
|
89
|
-
],
|
|
90
|
-
},
|
|
91
|
-
} satisfies DocsConfig
|
|
92
|
-
|
|
93
|
-
export default docsConfig
|
|
94
|
-
`,S=(e,...n)=>t(e,...n),C=e=>e.toLowerCase().replace(/[^a-z0-9]+/g,`-`).replace(/^-+|-+$/g,``)||`app`,w=[`web/next/content`,`web/next/public`,`.agents/skills`,`.claude/skills`,`.github/skills`],T=[`packages/cli`,`.github/workflows/cli-release.yml`,`.github/audit`,`.github/reviews`,`.infisical.json`,`.github/assets/graph-build.svg`,`.github/assets/cli.tape`,`.github/assets/setup.sh`,`.github/assets/cli.gif`,`.github/FUNDING.yml`,`LICENSE.md`,`CHANGELOG.md`,`bun.lock`,`skills-lock.json`,`web/next/src/app/hire`,`web/next/src/app/resume`,`web/next/src/fonts/caveat-latin-wght-normal.woff2`,`web/next/src/fonts/newsreader-latin-wght-normal.woff2`,`web/next/src/fonts/newsreader-latin-wght-italic.woff2`],E=e=>{let t=new Date,n=t.toISOString().slice(0,10),r=[t.getFullYear(),t.getMonth()+1,t.getDate()].map(e=>String(e).padStart(2,`0`)).join(`-`),i=r<n?r:n;l(S(e,`web/next/content/docs/index.mdx`),_()),l(S(e,`web/next/content/blog/index.mdx`),y(i)),l(S(e,`web/next/content/blog/hello-world.mdx`),b(i)),l(S(e,`web/next/content/console/docs/index.mdx`),v()),l(S(e,`web/next/docs.config.ts`),x()),l(S(e,`web/next/public/.gitkeep`),``),l(S(e,`web/next/src/app/page.tsx`),h()),l(S(e,`AGENTS.md`),g())},D=e=>{let t=p(S(e,`web/next/src/components/navbar/home.tsx`),[[` { href: "/hire", label: "Hire" },
|
|
95
|
-
`,``]]),n=p(S(e,`web/next/src/lib/fonts.ts`),[[`
|
|
96
|
-
export const caveat = localFont({
|
|
97
|
-
src: "../fonts/caveat-latin-wght-normal.woff2",
|
|
98
|
-
variable: "--font-caveat",
|
|
99
|
-
weight: "400 700",
|
|
100
|
-
})
|
|
101
|
-
`,``]]),r=p(S(e,`web/next/src/lib/fonts.ts`),[[`
|
|
102
|
-
export const newsreader = localFont({
|
|
103
|
-
src: [
|
|
104
|
-
{ path: "../fonts/newsreader-latin-wght-normal.woff2", style: "normal" },
|
|
105
|
-
{ path: "../fonts/newsreader-latin-wght-italic.woff2", style: "italic" },
|
|
106
|
-
],
|
|
107
|
-
variable: "--font-newsreader",
|
|
108
|
-
weight: "200 800",
|
|
109
|
-
})
|
|
110
|
-
`,``]]);if(!n||!r)throw Error(`fonts.ts: caveat/newsreader exports not found, but their woff2 files were removed (template drift). Update packages/cli/src/convert.ts.`);if(!t)throw Error(`navbar/home.tsx: /hire entry not found (template drift). Update packages/cli/src/convert.ts.`)},O=(e,t)=>{l(S(e,`packages/config/src/site.ts`),m(t));let n=S(e,`package.json`),r=d(n);r.name=C(t.name),r.version=`0.0.0`,delete r.homepage,delete r.bugs,delete r.license,delete r.author,delete r.repository,delete r.funding,f(n,r)},k=(e,t)=>{for(let t of[...w,...T])u(S(e,t));E(e),D(e),O(e,t)};export{s as n,k as t};
|