@lunora/cli 1.0.0-alpha.352 → 1.0.0-alpha.353
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.mjs +1 -1
- package/dist/index.mjs +1 -1
- package/dist/packem_chunks/handler.mjs +1 -1
- package/dist/packem_chunks/handler13.mjs +1 -1
- package/dist/packem_chunks/handler14.mjs +1 -1
- package/dist/packem_chunks/handler19.mjs +1 -1
- package/dist/packem_chunks/handler20.mjs +1 -1
- package/dist/packem_chunks/handler22.mjs +3 -3
- package/dist/packem_chunks/handler26.mjs +1 -1
- package/dist/packem_chunks/handler27.mjs +15 -15
- package/dist/packem_chunks/handler28.mjs +1 -1
- package/dist/packem_chunks/handler9.mjs +1 -1
- package/dist/packem_chunks/runDeployCommand.mjs +3 -3
- package/dist/packem_chunks/runDevCommand.mjs +1 -1
- package/dist/packem_chunks/runInitCommand.mjs +44 -44
- package/dist/packem_shared/COMMANDS-CWnIJmxM.mjs +1 -0
- package/dist/packem_shared/cli-6BRlq6nw.mjs +2 -0
- package/dist/packem_shared/cli-manifest-CRet0egA.mjs +1 -0
- package/dist/packem_shared/cloudflare-credentials-lC5JtPLe.mjs +1 -0
- package/dist/packem_shared/{commands-Cg06JNO2.mjs → commands-DgUDxkA8.mjs} +5 -5
- package/dist/packem_shared/plan-DJeIwzFu.mjs +5 -0
- package/dist/packem_shared/{planDevCommand-1uuaH06D.mjs → planDevCommand-DkaC-fNF.mjs} +1 -1
- package/dist/packem_shared/resolve-BrsV4Qyc.mjs +5 -0
- package/dist/packem_shared/runAddCommand-DTvfp4h2.mjs +1 -0
- package/dist/packem_shared/secret-key-B4aoLE0w.mjs +1 -0
- package/dist/packem_shared/{storage-ChJtQ9E4.mjs → storage-DWhTX8eS.mjs} +1 -1
- package/package.json +7 -7
- package/dist/packem_shared/COMMANDS-DRMcVnnw.mjs +0 -1
- package/dist/packem_shared/cli-CG_JgNKu.mjs +0 -2
- package/dist/packem_shared/plan-Cod9Cgll.mjs +0 -5
- package/dist/packem_shared/resolve-DUCSc7jQ.mjs +0 -5
- package/dist/packem_shared/runAddCommand-BsOrlyfD.mjs +0 -1
- package/dist/packem_shared/secret-key-DsMeUoEg.mjs +0 -1
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import{existsSync as
|
|
1
|
+
import{existsSync as v,mkdirSync as M,writeFileSync as w,readFileSync as T,readdirSync as de,rmSync as $,lstatSync as ue,mkdtempSync as pe,copyFileSync as Je,renameSync as Xe}from"node:fs";import{tmpdir as he}from"node:os";import{installArgsFor as me,execArgsFor as Qe,detectFramework as Ze,isInteractive as y,LUNA_ART as et,LUNA_NAME as tt,LUNA_SIGNOFF as rt,BADGES as g,paintAnswer as at,detectPackageManager as P,detectInstalledManagers as ot,runScriptCommand as nt,detectLintTools as it,addArgsFor as st,readProjectDependencies as fe,applyLintIgnores as lt,readProjectManifest as ct}from"@lunora/config";import{readJsonSync as dt,walkSync as ut}from"@visulima/fs";import{join as p,dirname as S,basename as N,resolve as ge,relative as ve}from"@visulima/path";import{downloadTemplate as we}from"giget";import{modify as pt,applyEdits as ht}from"jsonc-parser";import{join as K,dirname as mt}from"node:path";import{d as ft}from"../packem_shared/command-CAXl2A1S.mjs";import{EXIT_CODE as m}from"../packem_shared/EXIT_CODE-D_XCixv8.mjs";import gt from"magic-string";import{Project as vt,SyntaxKind as f}from"ts-morph";import{P as q}from"../packem_shared/prompt-cancelled-BvsNxg_Q.mjs";import{l as ye,m as wt,n as be,o as xe,a as yt}from"../packem_shared/resolve-BrsV4Qyc.mjs";import{defaultSpawner as ke}from"../packem_shared/createRecordingSpawner-Ch7zuQQE.mjs";import{d as bt,e as xt,f as kt,a as Ce,t as G,g as Se,h as Ct,b as Le,i as Me,w as St,j as Lt,k as Ae,l as Mt}from"../packem_shared/tui-prompts-B3YwUhGw.mjs";import{A as Ee,E as Ne,p as At,w as Et,M as Nt,r as It,k as Rt,e as _t,c as Ie,l as Re,i as $t,f as Ot}from"../packem_shared/storage-DWhTX8eS.mjs";import{r as Tt}from"../packem_shared/commands-DgUDxkA8.mjs";import{logStep as Q}from"../packem_shared/createLogger-Cl18I8AX.mjs";import{r as Pt}from"../packem_shared/lint-ignore-report-DKZagpqk.mjs";import{DEFAULT_OBSERVABILITY as Dt,CLOUDFLARE_TOOLCHAIN_VERSIONS as Z}from"@lunora/config/cloudflare";import Bt from"node:dns/promises";const Y={bun:{githubCacheKey:void 0,githubSetupStep:` - uses: oven-sh/setup-bun@v2
|
|
2
2
|
`,gitlabImage:"oven/bun:1",gitlabProvisionScript:[],installCmd:"bun install --frozen-lockfile",lockfile:"bun.lockb"},npm:{githubCacheKey:"npm",githubSetupStep:"",gitlabImage:"node:22",gitlabProvisionScript:[],installCmd:"npm ci",lockfile:"package-lock.json"},pnpm:{githubCacheKey:"pnpm",githubSetupStep:` - uses: pnpm/action-setup@v4
|
|
3
3
|
with:
|
|
4
4
|
version: latest
|
|
5
|
-
`,gitlabImage:"node:22",gitlabProvisionScript:["corepack enable"],installCmd:"pnpm install --frozen-lockfile",lockfile:"pnpm-lock.yaml"},yarn:{githubCacheKey:"yarn",githubSetupStep:"",gitlabImage:"node:22",gitlabProvisionScript:["corepack enable"],installCmd:"yarn install --frozen-lockfile",lockfile:"yarn.lock"}},L=(e,t)=>{const r=
|
|
5
|
+
`,gitlabImage:"node:22",gitlabProvisionScript:["corepack enable"],installCmd:"pnpm install --frozen-lockfile",lockfile:"pnpm-lock.yaml"},yarn:{githubCacheKey:"yarn",githubSetupStep:"",gitlabImage:"node:22",gitlabProvisionScript:["corepack enable"],installCmd:"yarn install --frozen-lockfile",lockfile:"yarn.lock"}},L=(e,t)=>{const r=Qe(e,"lunora",t);return[r.command,...r.args].join(" ")},ee=e=>` - uses: actions/checkout@v4
|
|
6
6
|
${e.githubSetupStep} - uses: actions/setup-node@v4
|
|
7
7
|
with:
|
|
8
8
|
node-version: 22
|
|
9
9
|
${e.githubCacheKey===void 0?"":` cache: ${e.githubCacheKey}
|
|
10
|
-
`} - run: ${e.installCmd}`,
|
|
10
|
+
`} - run: ${e.installCmd}`,jt=e=>{const t=Y[e],r=t.githubCacheKey===void 0?`# (below) requires it — run \`${e} install\` locally and`:`# (below) and the ${e} cache both require it — run \`${e} install\` locally and`;return`name: Deploy
|
|
11
11
|
|
|
12
12
|
on:
|
|
13
13
|
push:
|
|
@@ -49,7 +49,7 @@ ${ee(t)}
|
|
|
49
49
|
steps:
|
|
50
50
|
${ee(t)}
|
|
51
51
|
- run: ${L(e,["deploy","--preview"])}
|
|
52
|
-
`},
|
|
52
|
+
`},Ut=e=>{const t=Y[e],r=[...t.gitlabProvisionScript,t.installCmd].map(a=>` - ${a}`).join(`
|
|
53
53
|
`);return`stages:
|
|
54
54
|
- deploy
|
|
55
55
|
|
|
@@ -84,16 +84,16 @@ preview:
|
|
|
84
84
|
- if: $CI_PIPELINE_SOURCE == "merge_request_event"
|
|
85
85
|
script:
|
|
86
86
|
- ${L(e,["deploy","--preview"])}
|
|
87
|
-
`},
|
|
87
|
+
`},_e={github:{file:K(".github","workflows","deploy.yml"),secretsHint:"repository secrets (Settings → Secrets and variables → Actions)"},gitlab:{file:".gitlab-ci.yml",secretsHint:"masked CI/CD variables (Settings → CI/CD → Variables)"}},Vt=(e,t)=>e==="github"?jt(t):Ut(t),Ft=e=>e==="github"||e==="gitlab",Wt=(e,t,r,a={})=>{const o=K(e,_e[t].file);return v(o)&&a.overwrite!==!0?{path:o,skipped:!0,written:!1}:(M(mt(o),{recursive:!0}),w(o,Vt(t,r),"utf8"),{path:o,skipped:!1,written:!0})},Ht=(e,t,r,a,o={})=>{const n=_e[t];try{const i=Wt(e,t,r,o);if(i.skipped)a.info(`--ci ${t}: ${n.file} already exists — left unchanged (re-run with overwrite to replace).`);else{const s=me(r),l=[s.command,...s.args].join(" "),{installCmd:c,lockfile:u}=Y[r];a.success(`--ci ${t}: wrote ${n.file}`),a.info(`--ci ${t}: set CLOUDFLARE_API_TOKEN and CLOUDFLARE_ACCOUNT_ID as ${n.secretsHint} to enable deploys.`),a.info(`--ci ${t}: run \`${l}\` and commit ${u} before pushing — the pipeline runs \`${c}\`.`)}return i}catch(i){const s=i instanceof Error?i.message:String(i);return a.warn(`--ci ${t}: could not write ${n.file} (${s})`),{path:K(e,n.file),skipped:!1,written:!1}}},zt={astro:"@lunora/react",none:"@lunora/react",nuxt:"@lunora/vue","react-router":"@lunora/react","solid-start":"@lunora/solid",sveltekit:"@lunora/svelte","tanstack-start":"@lunora/react","tanstack-start-solid":"@lunora/solid",vinext:"@lunora/react"},Kt=e=>{const t=Ze(e);return{...t,adapter:zt[t.framework]}},_="lunora()",te='import { lunora } from "@lunora/vite";',qt="@lunora/vite",Gt="lunora",Yt=e=>{for(const t of e.getStatements()){if(t.getKind()!==f.ExportAssignment)continue;const r=t.asKindOrThrow(f.ExportAssignment).getExpression();if(r.getKind()!==f.CallExpression)continue;const a=r.asKindOrThrow(f.CallExpression);if(a.getExpression().getText()!=="defineConfig")continue;const o=a.getArguments()[0];if(o?.getKind()===f.ObjectLiteralExpression)return o.asKindOrThrow(f.ObjectLiteralExpression)}},Jt=e=>{for(const t of e.getStatements()){if(t.getKind()!==f.ExportAssignment)continue;const r=t.asKindOrThrow(f.ExportAssignment).getExpression();if(r.getKind()===f.ObjectLiteralExpression)return r.asKindOrThrow(f.ObjectLiteralExpression)}},Xt=e=>e.getDescendantsOfKind(f.CallExpression).some(t=>t.getExpression().getText()===Gt),Qt=e=>e.getImportDeclarations().some(t=>t.getModuleSpecifierValue()===qt),Zt=e=>new vt({compilerOptions:{allowJs:!0},useInMemoryFileSystem:!0}).createSourceFile("vite.config.ts",e,{overwrite:!0}),er=(e,t)=>{const r=t.getImportDeclarations().at(-1)?.getEnd()??0;r===0?e.prepend(`${te}
|
|
88
88
|
`):e.appendLeft(r,`
|
|
89
|
-
${te}`)},
|
|
90
|
-
`);return}const a=r.getDescendantsOfKind(
|
|
89
|
+
${te}`)},tr=(e,t)=>{const r=t.getProperty("plugins");if(r===void 0){const i=t.getProperties(),s=t.getStart()+1;if(i.length===0){e.appendLeft(s,` plugins: [${_}] `);return}const l=i[0];if(l===void 0)return"could not locate the start of the Vite config object's first property";e.appendLeft(l.getStart(),`plugins: [${_}],
|
|
90
|
+
`);return}const a=r.getDescendantsOfKind(f.ArrayLiteralExpression)[0];if(a===void 0)return"the Vite config's `plugins` is not an array literal — add `lunora()` to it by hand";const o=a.getElements();if(o.length===0){e.appendLeft(a.getStart()+1,_);return}const n=o[0];if(n===void 0)return"could not locate the first entry of the Vite config's `plugins` array";e.appendLeft(n.getStart(),`${_}, `)},$e=e=>{const t=Zt(e);if(Xt(t))return{changed:!1,code:e,reason:"lunora plugin already present"};const r=Yt(t)??Jt(t);if(r===void 0)return{changed:!1,code:e,reason:"could not locate a Vite config plugins array to patch"};const a=new gt(e);Qt(t)||er(a,t);const o=tr(a,r);return o!==void 0?{changed:!1,code:e,reason:o}:{changed:!0,code:a.toString()}},rr=/enotfound|eai_again|econnrefused|etimedout|network|fetch failed|getaddrinfo/u,ar=/404|not found|could not find|no such/u,or=(e,t)=>{const r=e instanceof Error?e.message:String(e),a=r.toLowerCase(),o=`failed to download template "${t.templateType}" from ${t.remote}: ${r}`;return ar.test(a)?{hints:[`Check the template name "${t.templateType}" and the ref "${t.ref}".`,"List/inspect available templates, or target a branch/tag with `--ref <branch>`."],message:`template "${t.templateType}" not found at ${t.remote}: ${r}`}:rr.test(a)?{hints:["You appear to be offline or unable to reach GitHub.","To scaffold without a network, point at a local template root: `lunora init --from <dir>`."],message:o}:{hints:["If this is a network/offline issue, scaffold from a local root with `lunora init --from <dir>`."],message:o}},O=async(e,t,r)=>{if(y()){await xt(g[e],t,r);return}if(process.stdout.write(`
|
|
91
91
|
`),r===void 0||r===""){Q(e,t);return}const a=r.split(`
|
|
92
|
-
`).map(o=>
|
|
92
|
+
`).map(o=>at(o)).join(`
|
|
93
93
|
`);Q(e,`${t}
|
|
94
|
-
${a}`)},
|
|
95
|
-
${
|
|
96
|
-
${
|
|
94
|
+
${a}`)},nr=async e=>{if(y()){await bt();return}e.info(`
|
|
95
|
+
${et}
|
|
96
|
+
${tt}: ${rt}`)},Oe=[{description:"LLMs via Workers AI (summarize, generate, stream)",label:"AI",value:"ai"},{description:"Sign-up / sign-in (asks which provider)",label:"Authentication",value:"auth"},{description:"Copy-in auth screens for your framework (sign in/up, reset, 2FA)",label:"Auth UI",value:"auth-ui"},{description:"Snapshot + restore your Durable Object data",label:"Backups",value:"backup"},{description:"Headless browser screenshots + PDFs",label:"Browser rendering",value:"browser"},{description:"Zero Trust identity via Cloudflare Access",label:"Cloudflare Access",value:"cloudflare-access"},{description:"Scheduled jobs via Cron Triggers (@lunora/scheduler)",label:"Cron jobs",value:"crons"},{description:"Cloudflare Email Workers + a dev mail catcher",label:"Transactional email",value:"email"},{description:"OpenFeature feature flags (ctx.flags)",label:"Feature flags",value:"flags"},{description:"External Postgres/MySQL via Hyperdrive",label:"Hyperdrive",value:"hyperdrive"},{description:"Stripe-first payments (checkout, subscription, webhooks)",label:"Payments",value:"payment"},{description:"Live presence / who's-online over hibernated WebSockets",label:"Presence",value:"presence"},{description:"Async message queues (push/pull consumers)",label:"Queues",value:"queue"},{description:"Typed R2 buckets + signed URLs (@lunora/storage)",label:"File storage",value:"storage"},{description:"Durable long-running workflows (step.do, sleep, branch)",label:"Workflows",value:"workflow"}],re=Oe.map(e=>e.value),ir=e=>e==="email"?Ne:e,sr=(e,t)=>{const r=[];for(const a of e.split(",").map(o=>o.trim()).filter(Boolean))re.includes(a)?r.includes(a)||r.push(a):t(`init: unknown --add feature "${a}" — expected ${re.join(" | ")}; skipping.`);return r},Te=e=>e.resolveAuthUiItem===void 0?"auth-ui-react":e.resolveAuthUiItem(),lr=async e=>{const t=await _t(e.select),r=await Ie(e.text,e.projectName);return{label:"auth",names:[t],transformManifest:a=>Re(a,r)}},cr=async e=>{const t=await e.text(Nt,{placeholder:"you@yourdomain.com"}),r=It(t,a=>{e.logger.warn(a)});return{label:"email",names:[Ne],transformManifest:r===void 0?void 0:a=>Rt(a,r)}},dr=async(e,t)=>{const r=Te(e);if(r===void 0){e.logger.error(`init: ${Ee}`);return}if(t)return{label:"auth-ui",names:[r]};const a=await Ie(e.text,e.projectName);return{label:"auth-ui",names:[r],transformManifest:o=>Re(o,a)}},ur=async e=>{const t=await At(e.text,e.projectName);return{label:"storage",names:["storage"],transformManifest:r=>Et(r,t)}},pr=(e,t)=>{const r=[];let a=!1;for(const o of t){if(o!=="auth-ui"){r.push({label:o,names:[ir(o)]});continue}const n=Te(e);if(n===void 0){e.logger.error(`init: ${Ee}`),a=!0;continue}r.push({label:o,names:[n]})}return{plans:r,refused:a}},hr={auth:lr,"auth-ui":async(e,t)=>dr(e,t.includes("auth")),email:cr,storage:ur},ae=async e=>{if(e.preselected!==void 0&&e.preselected.length>0){const{plans:a,refused:o}=pr(e,e.preselected);return await e.applyAll(a)&&!o}if(!e.interactive)return e.logger.info("tip: add features later with `lunora add <ai|auth|backup|browser|cloudflare-access|crons|email|flags|hyperdrive|payment|presence|queue|storage|workflow>`."),!0;const t=await e.multiSelect("Which features do you want to add?",Oe,{defaults:[]});if(t.length===0)return!0;const r=[];for(const a of t){const o=hr[a],n=o?await o(e,t):{label:a,names:[a]};n!==void 0&&r.push(n)}return await e.applyAll(r),!0},mr=[{description:"Adds an ignores entry to eslint.config.js",label:"ESLint",value:"eslint"},{description:"Writes .prettierignore",label:"Prettier",value:"prettier"},{description:"Adds negated patterns to biome.json",label:"Biome",value:"biome"},{description:"Writes ignorePatterns to .oxlintrc.json",label:"oxlint (oxc)",value:"oxlint"}],fr="Which linter/formatter do you use? We'll tell it to skip Lunora's generated files.",gr=async e=>{const t=e.interactive?await e.multiSelect(fr,mr,{defaults:e.detected}):[...e.detected];if(t.length===0)return[];const r=e.apply(t);return Pt(r,e.logger),r},I="M 259.500 10.552 C 220.080 15.859, 182.424 32.566, 152.500 58.025 C 110.179 94.031, 85.380 137.183, 77.518 188.500 C 75.410 202.255, 74.569 225.677, 75.796 236.466 C 76.757 244.917, 76.683 245.692, 74.518 249.966 C 63.118 272.466, 53.141 303.876, 51.382 322.799 L 50.718 329.943 71.960 320.471 C 83.643 315.262, 93.326 311, 93.478 311 C 93.630 311, 96.547 316.063, 99.959 322.250 C 103.371 328.438, 107.249 334.850, 108.577 336.500 L 110.990 339.500 110.981 336 C 110.977 334.075, 111.499 324.991, 112.143 315.813 L 113.312 299.127 121.406 293.336 C 132.495 285.403, 149.593 271.554, 161 261.268 C 171.556 251.748, 189.116 235, 188.540 235 C 188.337 235, 183.069 238.648, 176.835 243.106 C 142.318 267.789, 68.537 314, 63.646 314 C 61.843 314, 72.791 281.179, 80.905 262.259 C 92.233 235.845, 107.473 212.389, 132.106 183.453 L 138.451 176 148.268 176 C 176.192 176, 197.512 187.154, 212.868 209.797 C 216.470 215.108, 217.035 216.595, 216.477 219.297 C 211.386 243.968, 202.359 274.496, 193.797 296 C 183.898 320.861, 167.147 352.101, 152.395 373.215 L 147.004 380.930 152.891 385.830 C 161.400 392.911, 165.563 396, 166.594 395.998 C 167.092 395.998, 168.772 391.641, 170.327 386.317 C 176.279 365.934, 188.422 338.749, 200.942 317.778 C 223.060 280.731, 256.432 244.369, 294.500 215.836 C 309.956 204.252, 313.937 201.603, 314.719 202.385 C 315.116 202.783, 315.449 213.096, 315.460 225.304 C 315.474 241.855, 315.021 250.405, 313.680 258.924 C 307.009 301.272, 291.175 336.677, 263.112 372 C 255.259 381.883, 227.182 410.673, 218.516 417.727 L 213.532 421.783 223.439 424.880 C 281.705 443.093, 349.165 436.018, 398.616 406.508 C 446.728 377.797, 483.322 331.466, 497.366 281.481 C 503.381 260.075, 504.480 250.741, 504.491 221 C 504.501 191.997, 503.598 184.047, 497.987 163.732 C 484.768 115.871, 452.505 72.708, 407.718 42.964 C 381.051 25.254, 352.818 14.828, 319.695 10.460 C 305.932 8.645, 273.298 8.695, 259.500 10.552",E=`/* The welcome page is a full-bleed starter — reset the browser's default
|
|
97
97
|
body margin/padding so it sits flush; everything else is scoped under
|
|
98
98
|
.lunora-welcome (collision-safe). */
|
|
99
99
|
body {
|
|
@@ -198,7 +198,7 @@ body {
|
|
|
198
198
|
.lunora-welcome .lw-foot { text-align: center; padding-top: 26px; font-family: var(--mono); font-size: 11px; letter-spacing: .1em; text-transform: uppercase; color: var(--t-faint); }
|
|
199
199
|
|
|
200
200
|
@media (prefers-reduced-motion: reduce) { .lunora-welcome * { transition: none !important; } }
|
|
201
|
-
`,
|
|
201
|
+
`,vr=`import { useEffect, useState } from "react";
|
|
202
202
|
|
|
203
203
|
type Theme = "dark" | "light";
|
|
204
204
|
|
|
@@ -240,7 +240,7 @@ export default function App() {
|
|
|
240
240
|
<div className="lw-wrap">
|
|
241
241
|
<div className="brand">
|
|
242
242
|
<svg viewBox="0 0 543 446" role="img" aria-label="Lunora">
|
|
243
|
-
<path d="${
|
|
243
|
+
<path d="${I}" fill="currentColor" fillRule="evenodd" />
|
|
244
244
|
</svg>
|
|
245
245
|
<span className="word">Lunora</span>
|
|
246
246
|
</div>
|
|
@@ -359,7 +359,7 @@ export default function App() {
|
|
|
359
359
|
</div>
|
|
360
360
|
);
|
|
361
361
|
}
|
|
362
|
-
`,
|
|
362
|
+
`,wr=`<script setup lang="ts">
|
|
363
363
|
import { onMounted, ref } from "vue";
|
|
364
364
|
|
|
365
365
|
// Default to "dark" for a stable first paint, then reconcile to the OS
|
|
@@ -399,7 +399,7 @@ const toggle = (): void => {
|
|
|
399
399
|
<div class="lw-wrap">
|
|
400
400
|
<div class="brand">
|
|
401
401
|
<svg viewBox="0 0 543 446" role="img" aria-label="Lunora">
|
|
402
|
-
<path d="${
|
|
402
|
+
<path d="${I}" fill="currentColor" fill-rule="evenodd" />
|
|
403
403
|
</svg>
|
|
404
404
|
<span class="word">Lunora</span>
|
|
405
405
|
</div>
|
|
@@ -515,7 +515,7 @@ const toggle = (): void => {
|
|
|
515
515
|
</div>
|
|
516
516
|
</div>
|
|
517
517
|
</template>
|
|
518
|
-
`,
|
|
518
|
+
`,yr=`import { createSignal, onMount } from "solid-js";
|
|
519
519
|
|
|
520
520
|
export default function App() {
|
|
521
521
|
// Default to "dark" for a stable first paint, then reconcile to the OS
|
|
@@ -555,7 +555,7 @@ export default function App() {
|
|
|
555
555
|
<div class="lw-wrap">
|
|
556
556
|
<div class="brand">
|
|
557
557
|
<svg viewBox="0 0 543 446" role="img" aria-label="Lunora">
|
|
558
|
-
<path d="${
|
|
558
|
+
<path d="${I}" fill="currentColor" fill-rule="evenodd" />
|
|
559
559
|
</svg>
|
|
560
560
|
<span class="word">Lunora</span>
|
|
561
561
|
</div>
|
|
@@ -674,7 +674,7 @@ export default function App() {
|
|
|
674
674
|
</div>
|
|
675
675
|
);
|
|
676
676
|
}
|
|
677
|
-
`,
|
|
677
|
+
`,br=`<script lang="ts">
|
|
678
678
|
import { onMount } from "svelte";
|
|
679
679
|
|
|
680
680
|
// Default to "dark" for a stable first paint, then reconcile to the OS
|
|
@@ -717,7 +717,7 @@ export default function App() {
|
|
|
717
717
|
<div class="lw-wrap">
|
|
718
718
|
<div class="brand">
|
|
719
719
|
<svg viewBox="0 0 543 446" role="img" aria-label="Lunora">
|
|
720
|
-
<path d="${
|
|
720
|
+
<path d="${I}" fill="currentColor" fill-rule="evenodd" />
|
|
721
721
|
</svg>
|
|
722
722
|
<span class="word">Lunora</span>
|
|
723
723
|
</div>
|
|
@@ -832,7 +832,7 @@ export default function App() {
|
|
|
832
832
|
<div class="lw-foot">Running on Lunora · Vite + Svelte</div>
|
|
833
833
|
</div>
|
|
834
834
|
</div>
|
|
835
|
-
`,
|
|
835
|
+
`,xr=`import "./style.css";
|
|
836
836
|
|
|
837
837
|
import { LunoraClient } from "lunorash/client";
|
|
838
838
|
|
|
@@ -860,7 +860,7 @@ const welcomeHtml = \`
|
|
|
860
860
|
<div class="lw-wrap">
|
|
861
861
|
<div class="brand">
|
|
862
862
|
<svg viewBox="0 0 543 446" role="img" aria-label="Lunora">
|
|
863
|
-
<path d="${
|
|
863
|
+
<path d="${I}" fill="currentColor" fill-rule="evenodd" />
|
|
864
864
|
</svg>
|
|
865
865
|
<span class="word">Lunora</span>
|
|
866
866
|
</div>
|
|
@@ -999,7 +999,7 @@ const count = document.querySelector<HTMLSpanElement>("#lw-count")!;
|
|
|
999
999
|
client.subscribe(api.messages.list, { channelId: "channel:demo" }, (result) => {
|
|
1000
1000
|
count.textContent = String(result.messages.length);
|
|
1001
1001
|
});
|
|
1002
|
-
`,D="const url = (import.meta.env.VITE_LUNORA_URL as string | undefined) ?? globalThis.location.origin;",
|
|
1002
|
+
`,D="const url = (import.meta.env.VITE_LUNORA_URL as string | undefined) ?? globalThis.location.origin;",kr=`import "./index.css";
|
|
1003
1003
|
|
|
1004
1004
|
import { LunoraProvider } from "@lunora/react";
|
|
1005
1005
|
import { LunoraClient } from "lunorash/client";
|
|
@@ -1027,7 +1027,7 @@ createRoot(root).render(
|
|
|
1027
1027
|
</LunoraProvider>
|
|
1028
1028
|
</StrictMode>,
|
|
1029
1029
|
);
|
|
1030
|
-
`,
|
|
1030
|
+
`,Cr=`import "./style.css";
|
|
1031
1031
|
|
|
1032
1032
|
import { createLunora } from "@lunora/vue";
|
|
1033
1033
|
import { LunoraClient } from "lunorash/client";
|
|
@@ -1038,7 +1038,7 @@ import App from "./App.vue";
|
|
|
1038
1038
|
// Provide one LunoraClient at the app root via the Vue plugin form.
|
|
1039
1039
|
${D}
|
|
1040
1040
|
createApp(App).use(createLunora(new LunoraClient({ url }))).mount("#app");
|
|
1041
|
-
`,
|
|
1041
|
+
`,Sr=`import "./index.css";
|
|
1042
1042
|
|
|
1043
1043
|
import { LunoraProvider } from "@lunora/solid";
|
|
1044
1044
|
import { LunoraClient } from "lunorash/client";
|
|
@@ -1058,7 +1058,7 @@ render(
|
|
|
1058
1058
|
),
|
|
1059
1059
|
root!,
|
|
1060
1060
|
);
|
|
1061
|
-
`,
|
|
1061
|
+
`,Lr=`<script lang="ts">
|
|
1062
1062
|
import { setLunoraClient } from "@lunora/svelte";
|
|
1063
1063
|
import { LunoraClient } from "lunorash/client";
|
|
1064
1064
|
|
|
@@ -1069,7 +1069,7 @@ render(
|
|
|
1069
1069
|
<\/script>
|
|
1070
1070
|
|
|
1071
1071
|
<App />
|
|
1072
|
-
`,
|
|
1072
|
+
`,Mr=`import "./app.css";
|
|
1073
1073
|
|
|
1074
1074
|
import { mount } from "svelte";
|
|
1075
1075
|
|
|
@@ -1079,7 +1079,7 @@ import Root from "./Root.svelte";
|
|
|
1079
1079
|
const app = mount(Root, { target: document.getElementById("app")! });
|
|
1080
1080
|
|
|
1081
1081
|
export default app;
|
|
1082
|
-
`,B={react:{adapter:"@lunora/react",createViteTemplate:"react-ts",files:[{contents:
|
|
1082
|
+
`,B={react:{adapter:"@lunora/react",createViteTemplate:"react-ts",files:[{contents:kr,path:"src/main.tsx"},{contents:vr,path:"src/App.tsx"},{contents:E,path:"src/index.css"}],label:"React"},solid:{adapter:"@lunora/solid",createViteTemplate:"solid-ts",files:[{contents:Sr,path:"src/index.tsx"},{contents:yr,path:"src/App.tsx"},{contents:E,path:"src/index.css"}],label:"Solid"},svelte:{adapter:"@lunora/svelte",createViteTemplate:"svelte-ts",files:[{contents:Lr,path:"src/Root.svelte"},{contents:Mr,path:"src/main.ts"},{contents:br,path:"src/App.svelte"},{contents:E,path:"src/app.css"}],label:"Svelte"},vanilla:{adapter:"lunorash/client",createViteTemplate:"vanilla-ts",files:[{contents:xr,path:"src/main.ts"},{contents:E,path:"src/style.css"}],label:"Vanilla"},vue:{adapter:"@lunora/vue",createViteTemplate:"vue-ts",files:[{contents:Cr,path:"src/main.ts"},{contents:wr,path:"src/App.vue"},{contents:E,path:"src/style.css"}],label:"Vue"}},j=e=>Object.hasOwn(B,e),Ar=`/**
|
|
1083
1083
|
* Rate-limit schema extension + plugin.
|
|
1084
1084
|
*
|
|
1085
1085
|
* Defines the \`ratelimit_buckets\` table used by \`createDbStore\` for durable,
|
|
@@ -1131,7 +1131,7 @@ export const ratelimit = definePlugin("ratelimit", {
|
|
|
1131
1131
|
}),
|
|
1132
1132
|
middleware,
|
|
1133
1133
|
});
|
|
1134
|
-
`,
|
|
1134
|
+
`,Er=`import { ratelimit } from "./ratelimit/schema.js";
|
|
1135
1135
|
import { defineSchema, defineTable, v } from "lunorash/server";
|
|
1136
1136
|
|
|
1137
1137
|
export default defineSchema({
|
|
@@ -1142,7 +1142,7 @@ export default defineSchema({
|
|
|
1142
1142
|
.shardBy("channelId")
|
|
1143
1143
|
.index("by_channel", ["channelId"]),
|
|
1144
1144
|
}).extend(ratelimit.extension);
|
|
1145
|
-
`,
|
|
1145
|
+
`,Nr=`import { rateLimit } from "lunorash/ratelimit";
|
|
1146
1146
|
|
|
1147
1147
|
import { makeRateLimiter } from "./ratelimit/schema.js";
|
|
1148
1148
|
import type { MutationCtx } from "#lunora/_generated/server.js";
|
|
@@ -1191,7 +1191,7 @@ export const send = mutation
|
|
|
1191
1191
|
|
|
1192
1192
|
return { channelId: args.channelId, id, text: args.text };
|
|
1193
1193
|
});
|
|
1194
|
-
`,
|
|
1194
|
+
`,Ir=`import type { ShardNamespaceLike } from "lunorash/runtime";
|
|
1195
1195
|
|
|
1196
1196
|
import { defineApp } from "../lunora/_generated/app.js";
|
|
1197
1197
|
|
|
@@ -1205,7 +1205,7 @@ const app = defineApp<Env>()
|
|
|
1205
1205
|
|
|
1206
1206
|
export const ShardDO = app.ShardDO;
|
|
1207
1207
|
export default app;
|
|
1208
|
-
`,
|
|
1208
|
+
`,Rr=`{ ${Object.entries(Dt).map(([e,t])=>`${JSON.stringify(e)}: ${JSON.stringify(t)}`).join(", ")} }`,_r=`{
|
|
1209
1209
|
"$schema": "node_modules/wrangler/config-schema.json",
|
|
1210
1210
|
"name": "__NAME__",
|
|
1211
1211
|
"main": "src/server.ts",
|
|
@@ -1215,25 +1215,25 @@ export default app;
|
|
|
1215
1215
|
"bindings": [{ "name": "SHARD", "class_name": "ShardDO" }],
|
|
1216
1216
|
},
|
|
1217
1217
|
"migrations": [{ "tag": "v1", "new_sqlite_classes": ["ShardDO"] }],
|
|
1218
|
-
"observability": ${
|
|
1218
|
+
"observability": ${Rr},
|
|
1219
1219
|
}
|
|
1220
|
-
`,oe=[".wrangler",".env",".env.*","!.env.example",".dev.vars",".dev.vars.*","!.dev.vars.example",".lunora/",".lunora-cache","lunora/_generated"]
|
|
1220
|
+
`,oe=[".wrangler",".env",".env.*","!.env.example",".dev.vars",".dev.vars.*","!.dev.vars.example",".lunora/",".lunora-cache","lunora/_generated"],$r=`# Lunora endpoint for the browser client.
|
|
1221
1221
|
# Vite statically replaces \`import.meta.env.VITE_LUNORA_URL\` at \`vite dev\` / build.
|
|
1222
1222
|
# Leave it unset to use the page origin; set it to point at a deployed Worker:
|
|
1223
1223
|
#
|
|
1224
1224
|
# VITE_LUNORA_URL=https://my-app.example.workers.dev
|
|
1225
|
-
`,
|
|
1225
|
+
`,Or={"@cloudflare/workers-types":Z["@cloudflare/workers-types"],wrangler:Z.wrangler},k=(e,t,r,a)=>{const o=p(e,t);M(S(o),{recursive:!0}),w(o,r,"utf8"),a.push(o)},Tr=/\r?\n/,Pr=e=>{const t=p(e,".gitignore"),r=v(t)?T(t,"utf8"):"",a=new Set(r.split(Tr)),o=oe.filter(s=>!a.has(s));if(o.length===0)return;const n=o.some(s=>!s.startsWith("!"))?[...o.filter(s=>!s.startsWith("!")),...oe.filter(s=>s.startsWith("!"))]:o,i=r.length>0&&!r.endsWith(`
|
|
1226
1226
|
`)?`
|
|
1227
|
-
`:"";w(t,`${r}${
|
|
1227
|
+
`:"";w(t,`${r}${i}
|
|
1228
1228
|
# Lunora
|
|
1229
1229
|
${n.join(`
|
|
1230
1230
|
`)}
|
|
1231
|
-
`,"utf8")},U=e=>e==="lunorash"||e.startsWith("@lunora/"),
|
|
1232
|
-
`,"utf8")},
|
|
1231
|
+
`,"utf8")},U=e=>e==="lunorash"||e.startsWith("@lunora/"),Dr=(e,t,r,a)=>U(e)?a.get(e)??r:t,C=(e,t,r)=>({...e,[t]:r}),ne=(e,t,r)=>Object.fromEntries(Object.entries(e).map(([a,o])=>[a,Dr(a,o,t,r)])),Br=async(e,t,r,a)=>{const o=p(e,"package.json"),n=dt(o);let i=C(n.dependencies??{},"lunorash",a);i=C(i,"@lunora/ratelimit",a),r.adapter.startsWith("@lunora/")&&(i=C(i,r.adapter,a));for(const[u,h]of Object.entries(r.extraDependencies??{}))i=C(i,u,h);let s=C(n.devDependencies??{},"@lunora/vite",a);s=C(s,"@lunora/studio",a);for(const[u,h]of Object.entries(Or))s=C(s,u,h);const l=[...Object.keys(i),...Object.keys(s)].filter(u=>U(u)),c=await ye(l,a);n.name=t,n.imports={...n.imports,"#lunora/*":"./lunora/*"},n.dependencies=ne(i,a,c),n.devDependencies=ne(s,a,c),n.scripts={...n.scripts,codegen:"lunora codegen",deploy:"vite build && lunora deploy"},w(o,`${JSON.stringify(n,void 0,4)}
|
|
1232
|
+
`,"utf8")},jr=["vite.config.ts","vite.config.mts","vite.config.js","vite.config.mjs"],Pe=e=>jr.map(t=>p(e,t)).find(t=>v(t)),Ur=(e,t)=>{const r=Pe(e);if(r===void 0){t.warn("overlay: no vite.config found in the create-vite base — add `lunora()` to your Vite plugins manually.");return}const a=$e(T(r,"utf8"));a.changed&&w(r,a.code,"utf8")},Vr=async e=>{const{adapter:t,distTag:r,logger:a,name:o,target:n}=e,i=[];k(n,p("lunora","ratelimit","schema.ts"),Ar,i),k(n,p("lunora","schema.ts"),Er,i),k(n,p("lunora","messages.ts"),Nr,i),k(n,p("src","server.ts"),Ir,i),k(n,"wrangler.jsonc",_r.replaceAll("__NAME__",o),i),k(n,".env.example",$r,i);for(const s of t.files)k(n,s.path,s.contents,i);return Ur(n,a),await Br(n,o,t,r),Pr(n),i},Fr=["lunar","silver","silent","waning","waxing","crescent","cosmic","stellar","orbital","gibbous","twilight","midnight","shimmering","drifting","weightless"],Wr=["moon","tide","crater","comet","eclipse","halo","orbit","nebula","voyager","lander","rover","beacon","harbor","meadow","fox"],ie=e=>e[Math.floor(Math.random()*e.length)],Hr=()=>`${ie(Fr)}-${ie(Wr)}`,zr=async()=>Bt.lookup("github.com").then(()=>!0,()=>!1),Kr=/^(?:gh|github):([^/]+)\/([^#/]+)(?:\/[^#]*)?(?:#(.+))?$/,De=e=>{const t=Kr.exec(e);if(t===null)return;const[,r,a,o]=t;if(!(r===void 0||a===void 0))return{owner:r,ref:o??"HEAD",repo:a}},qr=async e=>{const t=De(e);if(t===void 0)return;const r=`https://codeload.github.com/${t.owner}/${t.repo}/tar.gz/${t.ref}`;try{const a=await fetch(r,{method:"HEAD"});return a.status===404?!1:a.ok?!0:void 0}catch{return}},Be=async e=>e.isLocal||!(e.source===void 0||De(e.source)!==void 0)?!0:await zr()?e.source!==void 0&&await qr(e.source)===!1?(e.logger.error(`template source not found: ${e.source} — double-check --ref / --source, or browse the templates at https://lunora.sh/docs.`),!1):!0:(e.logger.error("you appear to be offline — connect to the internet and try again, or scaffold from a local template with `--from <dir>`."),!1),x={extras:"Let's finish setting up your app.",framework:"Which framework should we launch?",git:"Initialize a new git repository? (optional)",install:"Install dependencies now?",name:"Where should we land your project?",nextHeader:"Liftoff confirmed — explore your project!",packageManager:"Which package manager?"},Gr=new Set([".gitignore",".html",".js",".json",".jsonc",".md",".mjs",".ts",".tsx"]),Yr=`import { defineConfig } from "vite";
|
|
1233
1233
|
import { lunora } from "@lunora/vite";
|
|
1234
1234
|
|
|
1235
1235
|
export default defineConfig({ plugins: [lunora()] });
|
|
1236
|
-
`,
|
|
1236
|
+
`,Jr=`import { defineSchema, defineTable, v } from "@lunora/server";
|
|
1237
1237
|
|
|
1238
1238
|
export default defineSchema({
|
|
1239
1239
|
messages: defineTable({
|
|
@@ -1243,7 +1243,7 @@ export default defineSchema({
|
|
|
1243
1243
|
.shardBy("channelId")
|
|
1244
1244
|
.index("by_channel", ["channelId"]),
|
|
1245
1245
|
});
|
|
1246
|
-
`,
|
|
1246
|
+
`,Xr=`import { mutation, query, v } from "./_generated/server";
|
|
1247
1247
|
|
|
1248
1248
|
export const list = query
|
|
1249
1249
|
.input({ channelId: v.string(), limit: v.optional(v.number()) })
|
|
@@ -1256,8 +1256,8 @@ export const send = mutation
|
|
|
1256
1256
|
.mutation(async ({ args }) => {
|
|
1257
1257
|
return { channelId: args.channelId, text: args.text };
|
|
1258
1258
|
});
|
|
1259
|
-
`,
|
|
1260
|
-
`),
|
|
1261
|
-
`),e.success(`scaffolded ${String(t.length)} files into ${r}`)},
|
|
1262
|
-
`))},
|
|
1263
|
-
`),t.info(d?.commit?`template: ${d.source} @ ${d.commit} (${String(_.length)} files)`:`template: ${d?.source??h} (${String(_.length)} files)`),J(t,b,s),{code:0,files:b,target:s}}catch(u){if(u instanceof q)throw u;const{hints:h,message:d}=tr(u,{ref:be(o),remote:H(i,n,o),templateType:i});t.error(d);for(const b of h)t.warn(b);return{code:1,files:[],target:s}}finally{O(l,{force:!0,recursive:!0})}},va=e=>{for(const t of["_gitignore","_npmrc","_gitattributes"]){const r=p(e,t);m(r)&&Je(r,p(e,`.${t.slice(1)}`))}},wa=async e=>{const{framework:t,logger:r,markComplete:a,name:o,overlayBaseFrom:n,target:s}=e,i=B[t],l=pe(p(he(),"lunora-vite-base-"));try{let c;if(n!==void 0&&(c=p(n,`template-${i.createViteTemplate}`),!m(c)))return r.error(`create-vite base not found on disk: ${c}`),{code:f.NOT_FOUND,files:[],target:s};const u=async()=>{if(c!==void 0){le(c,s);return}const d=p(l,"base"),b=await ft(ie,"main",r),_=`github:${ie}/packages/create-vite/template-${i.createViteTemplate}#${b}`;await ve(_,{cwd:l,dir:d,force:!0,install:!1,silent:!0}),va(d),le(d,s)};let h=[];return await Me([{label:`create-vite (${i.label}) base ready`,run:u},{label:`Lunora overlay applied (${i.label})`,run:async()=>{h=await Br({adapter:i,distTag:ye(),logger:r,name:o,target:s})}}],{end:Fe,start:"Project initializing…"}),a(),J(r,h,s),{code:0,files:[...V(s)],target:s}}catch(c){if(c instanceof q)throw c;const u=c instanceof Error?c.message:String(c);return r.error(`failed to scaffold the ${i.label} base: ${u}`),{code:1,files:[],target:s}}finally{O(l,{force:!0,recursive:!0})}},z=(e,t,r,a,o)=>(o.error(`init --in-place: could not ${e} ${t}: ${r instanceof Error?r.message:String(r)}`),{code:1,files:[],target:a}),ya=(e,t)=>{const r=p(e,"vite.config.ts");try{w(r,Kr,"utf8")}catch(a){return z("write",r,a,e,t)}return t.success(`created ${r} with lunora() plugin`),{code:0,files:[r],target:e}},ba=(e,t,r)=>{let a;try{a=x(e,"utf8")}catch(n){return z("read",e,n,t,r)}const o=_e(a);if(!o.changed)return r.info(`${e}: ${o.reason??"no changes needed"}`),{code:0,files:[],target:t};try{w(e,o.code,"utf8")}catch(n){return z("write",e,n,t,r)}return r.success(`patched ${e} — added lunora() plugin`),{code:0,files:[e],target:t}},ka=(e,t)=>{const r=p(e,"lunora"),a=p(r,"schema.ts");if(m(a))return t.info(`lunora/ already present — left ${a} untouched`),[];const o=[];try{M(r,{recursive:!0}),w(a,qr,"utf8"),o.push(a);const n=p(r,"messages.ts");m(n)||(w(n,Gr,"utf8"),o.push(n)),t.success(`scaffolded lunora/ (${String(o.length)} file(s))`)}catch(n){const s=n instanceof Error?n.message:String(n);t.error(`init --here: could not scaffold lunora/: ${s}`)}return o},He=e=>e==="sveltekit"||e==="nuxt"||e==="astro",xa=(e,t,r)=>{const{adapter:a,class:o,framework:n}=e;r.info(""),r.info(`detected framework: ${n} (class ${o})`),r.info("next steps:");const s=[a,"@lunora/client","@lunora/runtime","@lunora/server"];He(n)||s.push("@lunora/vite"),r.info(` 1. install the adapter: ${la(t,s)}`),r.info(" 2. run codegen: lunora codegen"),o==="A"?(r.info(" 3. compose one worker: wrap your worker entry with"),r.info(" createWorker({ httpRouter: <your framework SSR handler>, shardDO: ShardDO, ... })"),r.info(` 4. add the provider: mount the ${a} provider in your root layout/route`),r.info(" 5. make a loader live: preloadQuery() in a loader, usePreloadedQuery() in the component"),r.info(" see https://lunora.sh/docs/frameworks/reactive-loaders")):o==="B"?(r.info(" 3. inject Lunora: mount Lunora realtime under /_lunora/* in your server hook"),r.info(` (${n} owns its Cloudflare adapter — Lunora composes into its server entry)`),r.info(` 4. add the provider: mount the ${a} provider in your root layout`),r.info(" 5. read the guide: https://lunora.sh/docs/frameworks/deploy")):(r.info(" 3. add the provider: wrap your app with the LunoraProvider from @lunora/react"),r.info(" 4. read the guide: https://lunora.sh/docs/frameworks/bring-your-framework")),r.info("")},Sa=(e,t,r)=>{if(He(t))return r.info(`${t} wires Lunora through its server entry, not a lunora() Vite plugin — leaving the Vite config alone (see next steps)`),{code:0,files:[],target:e};const a=Te(e);return a===void 0?ya(e,r):ba(a,e,r)},Ca=(e,t)=>{const r=Wt(e),a=Sa(e,r.framework,t);if(a.code!==0)return a;const o=ka(e,t);return xa(r,P(e),t),{code:0,files:[...a.files,...o],target:e}},La=e=>e.yes!==!0&&(e.prompt!==void 0||(e.interactive??y())),ce=async(e,t,r)=>{r.dryRun!==!0&&await hr({apply:a=>it(e,a),detected:nt(e),interactive:t,logger:r.logger,multiSelect:r.lintPrompt??((a,o,n)=>Se(a,o,{...n,badge:v.add}))})},Ma=async(e,t)=>{const r=La(e),a=e.add===void 0?[]:or(e.add,s=>{e.logger.warn(s)}),n={applyAll:async s=>{if(s.length===0)return!0;if(e.dryRun===!0)return E(e.logger,`add ${s.map(d=>d.label).join(", ")}`),!0;const i=[],l=y()?{error:d=>{i.push({level:"error",message:d})},info:()=>{},success:()=>{},warn:d=>{i.push({level:"warn",message:d})}}:e.logger,c=s.map(d=>({running:`adding ${d.label}…`,task:()=>_t({allowUnsafeSource:e.allowUnsafeSource,cwd:t,from:e.registryFrom,logger:l,names:[...d.names],ref:e.ref,source:e.registrySource,transformManifest:d.transformManifest,yes:!0})})),u=`added ${s.map(d=>d.label).join(", ")}`,h=await St(v.add,c,u);for(const{level:d,message:b}of i)e.logger[d](b);return h.every(d=>d.code===0)},interactive:r,logger:e.logger,multiSelect:e.prompt?.multiSelect??((s,i,l)=>Se(s,i,{...l,badge:v.add})),preselected:a.length>0?a:void 0,projectName:I(t),resolveAuthUiItem:()=>{let s;try{const i=JSON.parse(x(p(t,"package.json"),"utf8"));s={...i.dependencies,...i.devDependencies}}catch{return"auth-ui-react"}if(!It(s))return Rt(s)??"auth-ui-react"},select:e.prompt?.select??((s,i,l)=>G(s,i,{...l,badge:v.add})),text:e.prompt?.text??((s,i)=>xe(s,{...i,badge:v.add}))};if(a.length>0){const s=await ae(n);return await ce(t,r,e),s}return y()&&await bt(k.extras),await ae(n),await ce(t,r,e),!0},F="react",ze=[{description:"React SPA — official create-vite base + the Lunora layer (the default)",label:"React",value:"react"},{description:"Vue SPA — create-vite base + Lunora",label:"Vue",value:"vue"},{description:"Solid SPA — create-vite base + Lunora",label:"Solid",value:"solid"},{description:"Solid 2.0 SPA — the Solid 2 line (@solidjs/web, vite-plugin-solid 3)",label:"Solid 2",value:"solid-v2"},{description:"Svelte SPA — create-vite base + Lunora",label:"Svelte",value:"svelte"},{description:"React SPA on Rsbuild — the Worker runs under wrangler dev behind the dev server",label:"React · Rsbuild",value:"rspack-react"},{description:"Next.js (App Router) — OpenNext on Cloudflare + a standalone Lunora worker",label:"Next.js",value:"next"},{description:"TanStack Start (React) — SSR with live-loader routes",label:"TanStack Start · React",value:"tanstack-start-react"},{description:"TanStack Start (React) on Rsbuild — SSR composed into the Lunora worker",label:"TanStack Start · React · Rsbuild",value:"tanstack-start-react-rspack"},{description:"TanStack Start (Solid)",label:"TanStack Start · Solid",value:"tanstack-start-solid"},{description:"Next.js App Router on Vite (vinext) — composed into the Lunora worker (experimental)",label:"vinext · App Router",value:"vinext"},{description:"Next.js Pages Router on Vite (vinext) — composed into one worker (experimental)",label:"vinext · Pages Router",value:"vinext-pages"},{description:"React Router (v7, framework mode) — SSR composed into the Lunora worker",label:"React Router",value:"react-router"},{description:"Astro (islands) — single-worker, Lunora composed into the adapter worker",label:"Astro",value:"astro"},{description:"AnalogJS (Angular) — single-worker, Lunora mounted in Nitro",label:"Analog",value:"analog"},{description:"Nuxt (Vue) — single-worker, Lunora mounted in Nitro",label:"Nuxt",value:"nuxt"},{description:"SvelteKit — single-worker, Lunora composed into the adapter worker",label:"SvelteKit",value:"sveltekit"},{description:"React Native (Expo) — an iOS/Android/web app + a Lunora worker backend",label:"React Native · Expo",value:"expo"},{description:"Worker only — no frontend",label:"Standalone",value:"standalone"}],Ke=Object.keys(B).join("|"),qe=ze.filter(e=>!j(e.value)).map(e=>e.value),Ge=qe.join("|"),Aa=e=>j(e)?{framework:e,kind:"overlay"}:{kind:"template",templateType:e},Ea=async e=>e.vite!==void 0?{framework:e.vite,kind:"overlay"}:e.templateType!==void 0?{kind:"template",templateType:e.templateType}:!y()||e.yes===!0?{framework:F,kind:"overlay"}:Aa(await G(k.framework,ze,{badge:v.tmpl,default:F})??F),Na=e=>{if(y()||e.yes===!0)return;const t=[];if(e.name===void 0&&t.push("a project name (`lunora init <name>`)"),e.templateType===void 0&&e.vite===void 0&&t.push(`a framework — \`--vite <${Ke}>\` for an SPA, or \`-t <${Ge}>\` for a bespoke template`),t.length!==0)return`lunora init can't prompt in a non-interactive terminal — provide ${t.join(" and ")}, or pass --yes to accept the defaults.`},Ia=async(e,t,r,a,o)=>j(t)?await De({isLocal:e.overlayBaseFrom!==void 0,logger:e.logger})?(M(a,{recursive:!0}),wa({framework:t,logger:e.logger,markComplete:o,name:r,overlayBaseFrom:e.overlayBaseFrom,target:a})):{code:1,files:[],target:a}:(e.logger.error(`init: unknown framework "${t}". Supported overlays: ${Object.keys(B).join(", ")}.`),{code:f.USAGE,files:[],target:a}),Ra=async(e,t,r,a,o)=>e.from!==void 0?await fa(e.from,t,a,r,e.logger,o):e.source!==void 0&&e.source.length>0&&!e.allowUnsafeSource&&!ia(e.source)?(e.logger.error(`init: refusing --source ${e.source} — only gh:, github:, or https:// sources are allowed (and may not contain ".."). Re-run with --allow-unsafe-source if you really want this.`),{code:f.USAGE,files:[],target:a}):await De({isLocal:!1,logger:e.logger,source:H(t,e.source,e.ref)})?ga({logger:e.logger,markComplete:o,name:r,ref:e.ref,source:e.source,target:a,templateType:t}):{code:1,files:[],target:a},_a=(e,t)=>{if(X(t))return;let r;try{r=P(e)}catch{return}r==="pnpm"&&je(e)},$a=async(e,t,r)=>{await yt("realtime backend on Cloudflare Workers + Durable Objects");const a=Na(e);if(a!==void 0)return e.logger.error(a),{code:f.USAGE,files:[],target:""};const o=Vr(),n=e.name??await xe(k.name,{badge:v.dir,default:o,placeholder:o}),s=await Ea(e),i=n.trim();if(i.length===0)return e.logger.error("init: refusing an empty project name — pass a directory name (e.g. `lunora init my-app`)."),{code:f.USAGE,files:[],target:""};if(i.includes("/")||i.includes("\\")||i===".."||i===".")return e.logger.error(`init: refusing project name "${i}" — must not contain path separators or be "." / "..".`),{code:f.USAGE,files:[],target:""};if(!Xr.test(i))return e.logger.error(`init: refusing project name "${i}" — a Cloudflare Worker name must be lowercase letters, digits, "-" or "_" (starting with a letter, digit or "_"), and wrangler rejects anything else. Try \`${ea(i)}\`.`),{code:f.USAGE,files:[],target:""};const l=fe(t,i),c=ue(l,{throwIfNoEntry:!1});if(c?.isSymbolicLink()===!0)return e.logger.error(`init: refusing to scaffold into "${l}" — it is a symlink. Remove it, or scaffold into a different directory name.`),{code:f.CONFLICT,files:[],target:l};const u=c!==void 0;if(u&&de(l).length>0)return e.logger.error(`target directory not empty: ${l}`),{code:f.CONFLICT,files:[],target:l};if(e.dryRun===!0){const d=s.kind==="overlay"?`the ${s.framework} create-vite overlay`:`the ${s.templateType} template`;return E(e.logger,`scaffold ${d} into ${l}`),{code:0,files:[],target:l}}r.record(l,u);const h=s.kind==="overlay"?await Ia(e,s.framework,i,l,r.complete):await Ra(e,s.templateType,i,l,r.complete);return h.code===0&&_a(l,t),h},W=(e,t)=>{const{target:r,targetPreExisted:a}=e;if(!(r===void 0||!m(r))){if(a===!0)for(const o of de(r))O(p(r,o),{force:!0,recursive:!0});else O(r,{force:!0,recursive:!0});t.info(`removed the partially-created project at ${r}`)}},Oa=async(e,t,r)=>e.inPlace!==!0?$a(e,t,r):e.dryRun===!0?(E(e.logger,`configure Lunora into ${t}`),{code:0,files:[],target:t}):Ca(t,e.logger),Ta=async(e,t,r)=>{const a=await Ma(e,t.target),o=e.inPlace===!0?void 0:await ma(e,t.target);if(e.inPlace!==!0){await ua(e,t.target);const n=o??P(t.target);await pa(I(t.target),o,n,X(r)),await rr(e.logger)}return a},Pa=(e,t,r)=>{if(t.code!==0||e.ci===void 0)return;if(e.dryRun===!0){E(e.logger,`scaffold a ${e.ci} CI deploy pipeline`);return}const a=e.inPlace===!0?r:t.target;try{const o=P(a);Vt(a,e.ci,o,e.logger)}catch{e.logger.warn(`--ci ${e.ci}: could not detect a package manager for this project — skipped the CI pipeline.`)}},Da=async e=>{const t=e.cwd??process.cwd(),r={};let a;try{a=await Oa(e,t,{complete:()=>{r.target=void 0},record:(o,n)=>{r.target=o,r.targetPreExisted=n}}),a.code===0&&a.target!==""?(r.target=void 0,await Ta(e,a,t)||(a={...a,code:1})):a.code!==0&&W(r,e.logger)}catch(o){if(o instanceof q)return W(r,e.logger),process.stdout.write("\n ✖ Setup cancelled — run `lunora init` again whenever you're ready. 🌙\n"),{code:130,files:[],target:""};throw W(r,e.logger),o}return Pa(e,a,t),a},Ba=e=>typeof e=="string"&&qe.includes(e),ja=(e,t)=>{if(e!==void 0){if(jt(e))return e;t.warn(`init: unknown --ci "${e}" — expected github | gitlab; skipping CI scaffold.`)}},Ua=e=>e===void 0?{}:Ba(e)?{templateType:e}:j(e)?{vite:e}:{error:`init: unknown --template "${e}" — expected a bespoke template (${Ge}) or an overlay framework (${Ke}).`},co=pt(({argument:e,cwd:t,logger:r,options:a})=>{const o=Ua(a.template);return"error"in o?(r.error(o.error),{code:f.USAGE}):Da({add:a.add,allowUnsafeSource:a.allowUnsafeSource===!0,cwd:t,ci:ja(a.ci,r),dryRun:a.dryRun===!0,from:a.from,inPlace:a.here===!0,interactive:a.interactive===!0?!0:void 0,logger:r,name:e[0],ref:a.ref,source:a.source,templateType:o.templateType,vite:a.vite??o.vite,yes:a.yes===!0})});export{ze as FRAMEWORK_CHOICES,co as execute,Ba as isTemplate,Ua as resolveTemplateFlag,H as resolveTemplateSource,Da as runInitCommand};
|
|
1259
|
+
`,Qr="gh:anolilab/lunora/templates",Zr=e=>{const t=e.lastIndexOf(".");return t===-1?!1:Gr.has(e.slice(t))},ea=/^[a-z0-9_][a-z0-9\-_]*$/u,ta=/([a-z0-9])([A-Z])/gu,ra=/[^a-z0-9_]/gu,aa=e=>{const t=e.replaceAll(ta,"$1-$2").toLowerCase().replaceAll(ra,"-").split("-").filter(r=>r.length>0);return t.length>0?t.join("-"):"my-app"},oa=(e,t)=>e.replaceAll("{{name}}",t),na=async(e,t)=>{const r=new Set;for(const a of e)if(N(a)==="package.json")for(const o of Object.keys(fe(S(a))))U(o)&&r.add(o);return ye(r,t)},ia=(e,t,r)=>{let a;try{a=JSON.parse(e)}catch{return e}let o=e;for(const n of["dependencies","devDependencies"])for(const i of Object.keys(a[n]??{})){if(!U(i))continue;const s=r.get(i)??t,l=pt(o,[n,i],s,{formattingOptions:{insertSpaces:!0,tabSize:4}});o=ht(o,l)}return o},sa=["@parcel/watcher","esbuild","lmdb","msgpackr-extract","rs-module-lexer","sharp","unrs-resolver","vue-demi","workerd"],la=["cpu-features","protobufjs","ssh2"],je="pnpm-workspace.yaml",ca=()=>["# pnpm reads its settings from here (the package.json `pnpm` field is no longer read).","# Pre-approve the toolchain's native build scripts so `pnpm install` runs them","# without the interactive `pnpm approve-builds` step; deny the optional native","# builds a scaffold doesn't need (so no C/C++ toolchain is required).","allowBuilds:",...sa.map(e=>` '${e}': true`),...la.map(e=>` '${e}': false`),""].join(`
|
|
1260
|
+
`),Ue=e=>{const t=p(e,je);v(t)||w(t,ca(),"utf8")},V=e=>{const t=[];for(const r of ut(e,{includeDirs:!1,includeFiles:!0}))ue(r.path).isSymbolicLink()||t.push(r.path);return t},se="vitejs/vite",le=(e,t)=>{for(const r of V(e)){const a=p(t,ve(e,r));M(S(a),{recursive:!0}),Je(r,a)}},Ve=async(e,t,r)=>{const a=V(e),o=[],n=be(),i=await na(a,n);for(const s of a){const l=ve(e,s),c=p(t,l);M(S(c),{recursive:!0});const u=T(s);let h=Zr(s)?oa(u.toString("utf8"),r):void 0;h!==void 0&&N(s)==="package.json"&&(h=ia(h,n,i)),h===void 0?w(c,u):w(c,h,"utf8"),o.push(c)}return o},H=(e,t,r)=>t!==void 0&&t.length>0?t:`${Qr}/${e}#${xe(r)}`,da=e=>e.includes("..")?!1:e.startsWith("gh:")||e.startsWith("github:")||e.startsWith("https://"),A=(e,t)=>{e.info(`[dry-run] would ${t}`)},Fe=(e,t,r)=>(e.error(`init: the template at ${r} contains no files — nothing was scaffolded. Check the template name, \`--source\` layout and \`--ref\`.`),{code:m.NOT_FOUND,files:[],target:t}),We="Template files copied.",J=(e,t,r)=>{y()&&process.stdout.write(`
|
|
1261
|
+
`),e.success(`scaffolded ${String(t.length)} files into ${r}`)},ua=(e,t)=>{const{args:r,command:a}=st(e,t);return`${a} ${r.join(" ")}`},He=(e,t)=>{let r=ge(e);for(;;){if(t(r))return!0;const a=S(r);if(a===r)return!1;r=a}},pa=e=>v(p(e,je))?!0:ct(e)?.workspaces!==void 0,X=e=>He(e,pa),ha=e=>He(e,t=>v(p(t,".git"))),ma=async(e,t)=>{if(e.yes===!0||!y()||ha(S(t)))return;if(!await Le(x.git,{badge:g.git,defaultYes:!1})){await Me("Sounds good! You can always run git init manually.");return}if(e.dryRun===!0){A(e.logger,"initialize a git repository");return}const r=e.spawner??ke;(await St("Initializing a git repository…",()=>r({args:["init"],command:"git",cwd:t}))).code===0?await O("git","Initialized an empty git repository."):e.logger.warn("`git init` failed — initialize it yourself later with `git init`.")},fa=async(e,t,r,a)=>{const o=[{code:`cd ./${e}`,lead:"Enter your project directory using"}];t===void 0&&o.push({code:`${r} install`,lead:"Install dependencies with",tail:a?" from the workspace root":void 0}),o.push({code:nt(r,"dev"),lead:"Run",tail:" to start the dev server."},{code:"lunora add",lead:"Add features like auth or storage using"});const n=[{code:"https://lunora.sh/docs",lead:"Read the docs at"},{code:"https://lunora.sh/chat",lead:"Stuck? Join the chat at"}];if(y()){await Lt(g.next,x.nextHeader,o,n);return}const i=o.map(s=>`${s.lead} ${s.code}${s.tail??""}`);i.push("",...n.map(s=>`${s.lead} ${s.code}${s.tail??""}`)),await O("next",x.nextHeader,i.join(`
|
|
1262
|
+
`))},ga=e=>e.yes!==!0&&(e.installPrompt!==void 0||y()),va=async(e,t)=>{if(!ga(e)||X(S(t)))return;const r=ot(e.packageManagerProbe),[a]=r;if(a===void 0)return;if(!await(e.installPrompt?.confirmInstall??(async()=>Le(x.install,{badge:g.deps,defaultYes:!0})))()){await Me("No problem! Remember to install dependencies after setup.");return}let n=a;if(r.length>1&&(n=e.installPrompt?await e.installPrompt.selectManager(r):await G(x.packageManager,r.map(u=>({label:u,value:u})),{badge:g.deps,default:a})??a),e.dryRun===!0){A(e.logger,`install dependencies with ${n}`);return}n==="pnpm"&&Ue(t);const i=e.spawner??ke,{args:s,command:l}=me(n);await O("deps",`Installing dependencies with ${n}…`);const c=await i({args:s,command:l,cwd:t});if(c.code!==0){e.logger.warn(`\`${l} install\` exited with code ${String(c.code)} — run it yourself in ${N(t)}/.`);return}return await O("deps",`Dependencies installed with ${n}.`),n},wa=async(e,t,r,a,o,n)=>{const i=p(e,t);if(!v(i))return o.error(`template not found in local source: ${i}`),{code:m.NOT_FOUND,files:[],target:r};const s=await Ve(i,r,a);return s.length===0?Fe(o,r,i):(n(),J(o,s,r),{code:0,files:s,target:r})},ya=async e=>{const{logger:t,markComplete:r,name:a,ref:o,source:n,target:i,templateType:s}=e,l=pe(p(he(),"lunora-init-fetch-")),c=p(l,"template");try{const u=n!==void 0&&n.length>0?o:await yt(o,t),h=H(s,n,u);let d,b=[];if(await Ae([{label:`${s} template fetched`,run:async()=>{d=await we(h,{cwd:l,dir:c,force:!0,install:!1,silent:!0})}},{label:`files copied into ${a}/`,run:async()=>{b=await Ve(c,i,a)}}],{end:We,start:"Project initializing…"}),b.length===0)return Fe(t,i,d?.source??h);r();const R=V(c);return y()&&process.stdout.write(`
|
|
1263
|
+
`),t.info(d?.commit?`template: ${d.source} @ ${d.commit} (${String(R.length)} files)`:`template: ${d?.source??h} (${String(R.length)} files)`),J(t,b,i),{code:0,files:b,target:i}}catch(u){if(u instanceof q)throw u;const{hints:h,message:d}=or(u,{ref:xe(o),remote:H(s,n,o),templateType:s});t.error(d);for(const b of h)t.warn(b);return{code:1,files:[],target:i}}finally{$(l,{force:!0,recursive:!0})}},ba=e=>{for(const t of["_gitignore","_npmrc","_gitattributes"]){const r=p(e,t);v(r)&&Xe(r,p(e,`.${t.slice(1)}`))}},xa=async e=>{const{framework:t,logger:r,markComplete:a,name:o,overlayBaseFrom:n,target:i}=e,s=B[t],l=pe(p(he(),"lunora-vite-base-"));try{let c;if(n!==void 0&&(c=p(n,`template-${s.createViteTemplate}`),!v(c)))return r.error(`create-vite base not found on disk: ${c}`),{code:m.NOT_FOUND,files:[],target:i};const u=async()=>{if(c!==void 0){le(c,i);return}const d=p(l,"base"),b=await wt(se,"main",r),R=`github:${se}/packages/create-vite/template-${s.createViteTemplate}#${b}`;await we(R,{cwd:l,dir:d,force:!0,install:!1,silent:!0}),ba(d),le(d,i)};let h=[];return await Ae([{label:`create-vite (${s.label}) base ready`,run:u},{label:`Lunora overlay applied (${s.label})`,run:async()=>{h=await Vr({adapter:s,distTag:be(),logger:r,name:o,target:i})}}],{end:We,start:"Project initializing…"}),a(),J(r,h,i),{code:0,files:[...V(i)],target:i}}catch(c){if(c instanceof q)throw c;const u=c instanceof Error?c.message:String(c);return r.error(`failed to scaffold the ${s.label} base: ${u}`),{code:1,files:[],target:i}}finally{$(l,{force:!0,recursive:!0})}},z=(e,t,r,a,o)=>(o.error(`init --in-place: could not ${e} ${t}: ${r instanceof Error?r.message:String(r)}`),{code:1,files:[],target:a}),ka=(e,t)=>{const r=p(e,"vite.config.ts");try{w(r,Yr,"utf8")}catch(a){return z("write",r,a,e,t)}return t.success(`created ${r} with lunora() plugin`),{code:0,files:[r],target:e}},Ca=(e,t,r)=>{let a;try{a=T(e,"utf8")}catch(n){return z("read",e,n,t,r)}const o=$e(a);if(!o.changed)return r.info(`${e}: ${o.reason??"no changes needed"}`),{code:0,files:[],target:t};try{w(e,o.code,"utf8")}catch(n){return z("write",e,n,t,r)}return r.success(`patched ${e} — added lunora() plugin`),{code:0,files:[e],target:t}},Sa=(e,t)=>{const r=p(e,"lunora"),a=p(r,"schema.ts");if(v(a))return t.info(`lunora/ already present — left ${a} untouched`),[];const o=[];try{M(r,{recursive:!0}),w(a,Jr,"utf8"),o.push(a);const n=p(r,"messages.ts");v(n)||(w(n,Xr,"utf8"),o.push(n)),t.success(`scaffolded lunora/ (${String(o.length)} file(s))`)}catch(n){const i=n instanceof Error?n.message:String(n);t.error(`init --here: could not scaffold lunora/: ${i}`)}return o},ze=e=>e==="sveltekit"||e==="nuxt"||e==="astro",La=(e,t,r)=>{const{adapter:a,class:o,framework:n}=e;r.info(""),r.info(`detected framework: ${n} (class ${o})`),r.info("next steps:");const i=[a,"@lunora/client","@lunora/runtime","@lunora/server"];ze(n)||i.push("@lunora/vite"),r.info(` 1. install the adapter: ${ua(t,i)}`),r.info(" 2. run codegen: lunora codegen"),o==="A"?(r.info(" 3. compose one worker: wrap your worker entry with"),r.info(" createWorker({ httpRouter: <your framework SSR handler>, shardDO: ShardDO, ... })"),r.info(` 4. add the provider: mount the ${a} provider in your root layout/route`),r.info(" 5. make a loader live: preloadQuery() in a loader, usePreloadedQuery() in the component"),r.info(" see https://lunora.sh/docs/frameworks/reactive-loaders")):o==="B"?(r.info(" 3. inject Lunora: mount Lunora realtime under /_lunora/* in your server hook"),r.info(` (${n} owns its Cloudflare adapter — Lunora composes into its server entry)`),r.info(` 4. add the provider: mount the ${a} provider in your root layout`),r.info(" 5. read the guide: https://lunora.sh/docs/frameworks/deploy")):(r.info(" 3. add the provider: wrap your app with the LunoraProvider from @lunora/react"),r.info(" 4. read the guide: https://lunora.sh/docs/frameworks/bring-your-framework")),r.info("")},Ma=(e,t,r)=>{if(ze(t))return r.info(`${t} wires Lunora through its server entry, not a lunora() Vite plugin — leaving the Vite config alone (see next steps)`),{code:0,files:[],target:e};const a=Pe(e);return a===void 0?ka(e,r):Ca(a,e,r)},Aa=(e,t)=>{const r=Kt(e),a=Ma(e,r.framework,t);if(a.code!==0)return a;const o=Sa(e,t);return La(r,P(e),t),{code:0,files:[...a.files,...o],target:e}},Ea=e=>e.yes!==!0&&(e.prompt!==void 0||(e.interactive??y())),ce=async(e,t,r)=>{r.dryRun!==!0&&await gr({apply:a=>lt(e,a),detected:it(e),interactive:t,logger:r.logger,multiSelect:r.lintPrompt??((a,o,n)=>Se(a,o,{...n,badge:g.add}))})},Na=async(e,t)=>{const r=Ea(e),a=e.add===void 0?[]:sr(e.add,i=>{e.logger.warn(i)}),n={applyAll:async i=>{if(i.length===0)return!0;if(e.dryRun===!0)return A(e.logger,`add ${i.map(d=>d.label).join(", ")}`),!0;const s=[],l=y()?{error:d=>{s.push({level:"error",message:d})},info:()=>{},success:()=>{},warn:d=>{s.push({level:"warn",message:d})}}:e.logger,c=i.map(d=>({running:`adding ${d.label}…`,task:()=>Tt({allowUnsafeSource:e.allowUnsafeSource,cwd:t,from:e.registryFrom,logger:l,names:[...d.names],ref:e.ref,source:e.registrySource,transformManifest:d.transformManifest,yes:!0})})),u=`added ${i.map(d=>d.label).join(", ")}`,h=await Mt(g.add,c,u);for(const{level:d,message:b}of s)e.logger[d](b);return h.every(d=>d.code===0)},interactive:r,logger:e.logger,multiSelect:e.prompt?.multiSelect??((i,s,l)=>Se(i,s,{...l,badge:g.add})),preselected:a.length>0?a:void 0,projectName:N(t),resolveAuthUiItem:()=>{const i=fe(t);if(!$t(i))return Ot(i)??"auth-ui-react"},select:e.prompt?.select??((i,s,l)=>G(i,s,{...l,badge:g.add})),text:e.prompt?.text??((i,s)=>Ce(i,{...s,badge:g.add}))};if(a.length>0){const i=await ae(n);return await ce(t,r,e),i}return y()&&await Ct(x.extras),await ae(n),await ce(t,r,e),!0},F="react",Ke=[{description:"React SPA — official create-vite base + the Lunora layer (the default)",label:"React",value:"react"},{description:"Vue SPA — create-vite base + Lunora",label:"Vue",value:"vue"},{description:"Solid SPA — create-vite base + Lunora",label:"Solid",value:"solid"},{description:"Solid 2.0 SPA — the Solid 2 line (@solidjs/web, vite-plugin-solid 3)",label:"Solid 2",value:"solid-v2"},{description:"Svelte SPA — create-vite base + Lunora",label:"Svelte",value:"svelte"},{description:"React SPA on Rsbuild — the Worker runs under wrangler dev behind the dev server",label:"React · Rsbuild",value:"rspack-react"},{description:"Next.js (App Router) — OpenNext on Cloudflare + a standalone Lunora worker",label:"Next.js",value:"next"},{description:"TanStack Start (React) — SSR with live-loader routes",label:"TanStack Start · React",value:"tanstack-start-react"},{description:"TanStack Start (React) on Rsbuild — SSR composed into the Lunora worker",label:"TanStack Start · React · Rsbuild",value:"tanstack-start-react-rspack"},{description:"TanStack Start (Solid)",label:"TanStack Start · Solid",value:"tanstack-start-solid"},{description:"Next.js App Router on Vite (vinext) — composed into the Lunora worker (experimental)",label:"vinext · App Router",value:"vinext"},{description:"Next.js Pages Router on Vite (vinext) — composed into one worker (experimental)",label:"vinext · Pages Router",value:"vinext-pages"},{description:"React Router (v7, framework mode) — SSR composed into the Lunora worker",label:"React Router",value:"react-router"},{description:"Astro (islands) — single-worker, Lunora composed into the adapter worker",label:"Astro",value:"astro"},{description:"AnalogJS (Angular) — single-worker, Lunora mounted in Nitro",label:"Analog",value:"analog"},{description:"Nuxt (Vue) — single-worker, Lunora mounted in Nitro",label:"Nuxt",value:"nuxt"},{description:"SvelteKit — single-worker, Lunora composed into the adapter worker",label:"SvelteKit",value:"sveltekit"},{description:"React Native (Expo) — an iOS/Android/web app + a Lunora worker backend",label:"React Native · Expo",value:"expo"},{description:"Worker only — no frontend",label:"Standalone",value:"standalone"}],qe=Object.keys(B).join("|"),Ge=Ke.filter(e=>!j(e.value)).map(e=>e.value),Ye=Ge.join("|"),Ia=e=>j(e)?{framework:e,kind:"overlay"}:{kind:"template",templateType:e},Ra=async e=>e.vite!==void 0?{framework:e.vite,kind:"overlay"}:e.templateType!==void 0?{kind:"template",templateType:e.templateType}:!y()||e.yes===!0?{framework:F,kind:"overlay"}:Ia(await G(x.framework,Ke,{badge:g.tmpl,default:F})??F),_a=e=>{if(y()||e.yes===!0)return;const t=[];if(e.name===void 0&&t.push("a project name (`lunora init <name>`)"),e.templateType===void 0&&e.vite===void 0&&t.push(`a framework — \`--vite <${qe}>\` for an SPA, or \`-t <${Ye}>\` for a bespoke template`),t.length!==0)return`lunora init can't prompt in a non-interactive terminal — provide ${t.join(" and ")}, or pass --yes to accept the defaults.`},$a=async(e,t,r,a,o)=>j(t)?await Be({isLocal:e.overlayBaseFrom!==void 0,logger:e.logger})?(M(a,{recursive:!0}),xa({framework:t,logger:e.logger,markComplete:o,name:r,overlayBaseFrom:e.overlayBaseFrom,target:a})):{code:1,files:[],target:a}:(e.logger.error(`init: unknown framework "${t}". Supported overlays: ${Object.keys(B).join(", ")}.`),{code:m.USAGE,files:[],target:a}),Oa=async(e,t,r,a,o)=>e.from!==void 0?await wa(e.from,t,a,r,e.logger,o):e.source!==void 0&&e.source.length>0&&!e.allowUnsafeSource&&!da(e.source)?(e.logger.error(`init: refusing --source ${e.source} — only gh:, github:, or https:// sources are allowed (and may not contain ".."). Re-run with --allow-unsafe-source if you really want this.`),{code:m.USAGE,files:[],target:a}):await Be({isLocal:!1,logger:e.logger,source:H(t,e.source,e.ref)})?ya({logger:e.logger,markComplete:o,name:r,ref:e.ref,source:e.source,target:a,templateType:t}):{code:1,files:[],target:a},Ta=(e,t)=>{if(X(t))return;let r;try{r=P(e)}catch{return}r==="pnpm"&&Ue(e)},Pa=async(e,t,r)=>{await kt("realtime backend on Cloudflare Workers + Durable Objects");const a=_a(e);if(a!==void 0)return e.logger.error(a),{code:m.USAGE,files:[],target:""};const o=Hr(),n=e.name??await Ce(x.name,{badge:g.dir,default:o,placeholder:o}),i=await Ra(e),s=n.trim();if(s.length===0)return e.logger.error("init: refusing an empty project name — pass a directory name (e.g. `lunora init my-app`)."),{code:m.USAGE,files:[],target:""};if(s.includes("/")||s.includes("\\")||s===".."||s===".")return e.logger.error(`init: refusing project name "${s}" — must not contain path separators or be "." / "..".`),{code:m.USAGE,files:[],target:""};if(!ea.test(s))return e.logger.error(`init: refusing project name "${s}" — a Cloudflare Worker name must be lowercase letters, digits, "-" or "_" (starting with a letter, digit or "_"), and wrangler rejects anything else. Try \`${aa(s)}\`.`),{code:m.USAGE,files:[],target:""};const l=ge(t,s),c=ue(l,{throwIfNoEntry:!1});if(c?.isSymbolicLink()===!0)return e.logger.error(`init: refusing to scaffold into "${l}" — it is a symlink. Remove it, or scaffold into a different directory name.`),{code:m.CONFLICT,files:[],target:l};const u=c!==void 0;if(u&&de(l).length>0)return e.logger.error(`target directory not empty: ${l}`),{code:m.CONFLICT,files:[],target:l};if(e.dryRun===!0){const d=i.kind==="overlay"?`the ${i.framework} create-vite overlay`:`the ${i.templateType} template`;return A(e.logger,`scaffold ${d} into ${l}`),{code:0,files:[],target:l}}r.record(l,u);const h=i.kind==="overlay"?await $a(e,i.framework,s,l,r.complete):await Oa(e,i.templateType,s,l,r.complete);return h.code===0&&Ta(l,t),h},W=(e,t)=>{const{target:r,targetPreExisted:a}=e;if(!(r===void 0||!v(r))){if(a===!0)for(const o of de(r))$(p(r,o),{force:!0,recursive:!0});else $(r,{force:!0,recursive:!0});t.info(`removed the partially-created project at ${r}`)}},Da=async(e,t,r)=>e.inPlace!==!0?Pa(e,t,r):e.dryRun===!0?(A(e.logger,`configure Lunora into ${t}`),{code:0,files:[],target:t}):Aa(t,e.logger),Ba=async(e,t,r)=>{const a=await Na(e,t.target),o=e.inPlace===!0?void 0:await va(e,t.target);if(e.inPlace!==!0){await ma(e,t.target);const n=o??P(t.target);await fa(N(t.target),o,n,X(r)),await nr(e.logger)}return a},ja=(e,t,r)=>{if(t.code!==0||e.ci===void 0)return;if(e.dryRun===!0){A(e.logger,`scaffold a ${e.ci} CI deploy pipeline`);return}const a=e.inPlace===!0?r:t.target;try{const o=P(a);Ht(a,e.ci,o,e.logger)}catch{e.logger.warn(`--ci ${e.ci}: could not detect a package manager for this project — skipped the CI pipeline.`)}},Ua=async e=>{const t=e.cwd??process.cwd(),r={};let a;try{a=await Da(e,t,{complete:()=>{r.target=void 0},record:(o,n)=>{r.target=o,r.targetPreExisted=n}}),a.code===0&&a.target!==""?(r.target=void 0,await Ba(e,a,t)||(a={...a,code:1})):a.code!==0&&W(r,e.logger)}catch(o){if(o instanceof q)return W(r,e.logger),process.stdout.write("\n ✖ Setup cancelled — run `lunora init` again whenever you're ready. 🌙\n"),{code:130,files:[],target:""};throw W(r,e.logger),o}return ja(e,a,t),a},Va=e=>typeof e=="string"&&Ge.includes(e),Fa=(e,t)=>{if(e!==void 0){if(Ft(e))return e;t.warn(`init: unknown --ci "${e}" — expected github | gitlab; skipping CI scaffold.`)}},Wa=e=>e===void 0?{}:Va(e)?{templateType:e}:j(e)?{vite:e}:{error:`init: unknown --template "${e}" — expected a bespoke template (${Ye}) or an overlay framework (${qe}).`},ho=ft(({argument:e,cwd:t,logger:r,options:a})=>{const o=Wa(a.template);return"error"in o?(r.error(o.error),{code:m.USAGE}):Ua({add:a.add,allowUnsafeSource:a.allowUnsafeSource===!0,cwd:t,ci:Fa(a.ci,r),dryRun:a.dryRun===!0,from:a.from,inPlace:a.here===!0,interactive:a.interactive===!0?!0:void 0,logger:r,name:e[0],ref:a.ref,source:a.source,templateType:o.templateType,vite:a.vite??o.vite,yes:a.yes===!0})});export{Ke as FRAMEWORK_CHOICES,ho as execute,Va as isTemplate,Wa as resolveTemplateFlag,H as resolveTemplateSource,Ua as runInitCommand};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{C as E,R as M,V as a,r as s}from"./cli-6BRlq6nw.mjs";import"./cli-manifest-CRet0egA.mjs";import"./EXIT_CODE-D_XCixv8.mjs";import"./createLogger-Cl18I8AX.mjs";import"./render-lunora-error-C3OJY5wk.mjs";export{E as COMMANDS,M as REGISTERED_COMMAND_NAMES,a as VERSION,s as runCli};
|