@lunora/cli 1.0.0-alpha.12 → 1.0.0-alpha.120
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/LICENSE.md +6 -0
- package/__assets__/package-og.svg +1 -1
- package/dist/bin.mjs +2 -10
- package/dist/index.d.mts +357 -321
- package/dist/index.d.ts +357 -321
- package/dist/index.mjs +1 -19
- package/dist/packem_chunks/handler.mjs +1 -150
- package/dist/packem_chunks/handler10.mjs +1 -22
- package/dist/packem_chunks/handler11.mjs +1 -192
- package/dist/packem_chunks/handler12.mjs +2 -131
- package/dist/packem_chunks/handler13.mjs +2 -65
- package/dist/packem_chunks/handler14.mjs +1 -58
- package/dist/packem_chunks/handler15.mjs +1 -79
- package/dist/packem_chunks/handler16.mjs +1 -43
- package/dist/packem_chunks/handler17.mjs +1 -105
- package/dist/packem_chunks/handler18.mjs +3 -170
- package/dist/packem_chunks/handler19.mjs +1 -89
- package/dist/packem_chunks/handler2.mjs +2 -114
- package/dist/packem_chunks/handler20.mjs +1 -94
- package/dist/packem_chunks/handler21.mjs +2 -311
- package/dist/packem_chunks/handler22.mjs +11 -0
- package/dist/packem_chunks/handler3.mjs +2 -204
- package/dist/packem_chunks/handler4.mjs +1 -33
- package/dist/packem_chunks/handler5.mjs +1 -49
- package/dist/packem_chunks/handler6.mjs +1 -91
- package/dist/packem_chunks/handler7.mjs +1 -42
- package/dist/packem_chunks/handler8.mjs +1 -174
- package/dist/packem_chunks/handler9.mjs +8 -16
- package/dist/packem_chunks/planDevCommand.mjs +7 -500
- package/dist/packem_chunks/runCodegenCommand.mjs +4 -52
- package/dist/packem_chunks/runDeployCommand.mjs +1 -504
- package/dist/packem_chunks/runInitCommand.mjs +996 -1265
- package/dist/packem_chunks/runMigrateGenerateCommand.mjs +9 -395
- package/dist/packem_chunks/runResetCommand.mjs +1 -41
- package/dist/packem_chunks/runRpcCommand.mjs +1 -68
- package/dist/packem_shared/COMMANDS-CQNSsSgS.mjs +3 -0
- package/dist/packem_shared/DEFAULT_IMPORT_BATCH_SIZE-DL87PIEl.mjs +8 -0
- package/dist/packem_shared/admin-url-DfVehV3e.mjs +1 -0
- package/dist/packem_shared/api-spec-BENwiyUa.mjs +1 -0
- package/dist/packem_shared/buildRegistryIndex-DwySASBu.mjs +1 -0
- package/dist/packem_shared/codegen-error-DJN6pTH5.mjs +3 -0
- package/dist/packem_shared/command-Bjv4VmYA.mjs +1 -0
- package/dist/packem_shared/commands-BhX2Bo9B.mjs +19 -0
- package/dist/packem_shared/createLogger--C3x1FNE.mjs +2 -0
- package/dist/packem_shared/createRecordingSpawner-ByIqBepG.mjs +1 -0
- package/dist/packem_shared/detect-package-manager-B2eIuAiP.mjs +1 -0
- package/dist/packem_shared/diffSnapshots-9bDd9nOK.mjs +5 -0
- package/dist/packem_shared/docker-CKvYE9YF.mjs +1 -0
- package/dist/packem_shared/insertSchemaExtension-DZReBZ4_.mjs +8 -0
- package/dist/packem_shared/open-url-CTU_g9gr.mjs +1 -0
- package/dist/packem_shared/output-format-D7cKB-O5.mjs +2 -0
- package/dist/packem_shared/parseManifest-x3WsxKHz.mjs +1 -0
- package/dist/packem_shared/prompt-cancelled-C8Sj7OqI.mjs +1 -0
- package/dist/packem_shared/resolve-target-vxaXHmvg.mjs +1 -0
- package/dist/packem_shared/runAddCommand--TBYJQYi.mjs +1 -0
- package/dist/packem_shared/schema-drift-gate-CpqG-xP4.mjs +1 -0
- package/dist/packem_shared/schemaIrToSnapshot-Clwd2A8e.mjs +1 -0
- package/dist/packem_shared/storage-DOvAKGi4.mjs +1 -0
- package/dist/packem_shared/tui-prompts-CCt3jm1k.mjs +4 -0
- package/dist/packem_shared/vectorize-metadata-BvZbbqUD.mjs +1 -0
- package/dist/packem_shared/wrangler-name-HIl0Z6yx.mjs +1 -0
- package/dist/packem_shared/wrangler-secrets-BMRJwKQU.mjs +1 -0
- package/package.json +23 -16
- package/skills/README.md +28 -14
- package/skills/lunora/SKILL.md +48 -9
- package/skills/lunora-functions/SKILL.md +38 -3
- package/skills/lunora-migration-helper/SKILL.md +36 -17
- package/skills/lunora-performance-audit/SKILL.md +36 -6
- package/skills/lunora-quickstart/SKILL.md +86 -24
- package/skills/lunora-realtime/SKILL.md +43 -30
- package/dist/packem_shared/COMMANDS-D3h9Iwvl.mjs +0 -944
- package/dist/packem_shared/DEFAULT_IMPORT_BATCH_SIZE-Ck-2bU08.mjs +0 -244
- package/dist/packem_shared/admin-url-4UzT-CI4.mjs +0 -19
- package/dist/packem_shared/api-spec-CtA6ilu4.mjs +0 -13
- package/dist/packem_shared/buildRegistryIndex-BcYe607_.mjs +0 -38
- package/dist/packem_shared/command-BC30oSBW.mjs +0 -14
- package/dist/packem_shared/commands-DVr4lduS.mjs +0 -812
- package/dist/packem_shared/createLogger-B40gPzQo.mjs +0 -78
- package/dist/packem_shared/createRecordingSpawner-DxI3mebw.mjs +0 -43
- package/dist/packem_shared/detect-package-manager-DYp7n3mJ.mjs +0 -61
- package/dist/packem_shared/diffSnapshots-BeDvvNiF.mjs +0 -161
- package/dist/packem_shared/docker-hMQ97KSQ.mjs +0 -21
- package/dist/packem_shared/insertSchemaExtension-DAqbfr9Z.mjs +0 -64
- package/dist/packem_shared/open-url-Dfq6fAyT.mjs +0 -41
- package/dist/packem_shared/output-format-wUvAN6AL.mjs +0 -17
- package/dist/packem_shared/parseArgs-YXFuKdEk.mjs +0 -56
- package/dist/packem_shared/parseManifest--vZf2FY1.mjs +0 -94
- package/dist/packem_shared/resolve-target-qbsJ_5sF.mjs +0 -16
- package/dist/packem_shared/runAddCommand-C-NOz8NJ.mjs +0 -4
- package/dist/packem_shared/schema-drift-gate-BtBt0as0.mjs +0 -79
- package/dist/packem_shared/schemaIrToSnapshot-DdsljJT-.mjs +0 -43
- package/dist/packem_shared/storage-DL9OE4oE.mjs +0 -84
- package/dist/packem_shared/tui-prompts-M6OWsuyw.mjs +0 -663
- package/dist/packem_shared/wrangler-name-cy4yhm9j.mjs +0 -12
|
@@ -1,23 +1,4 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { tmpdir } from 'node:os';
|
|
3
|
-
import { detectFramework as detectFramework$1, isInteractive, LUNA_ART, LUNA_NAME, LUNA_SIGNOFF, paintAnswer, BADGES } from '@lunora/config';
|
|
4
|
-
import { walkSync } from '@visulima/fs';
|
|
5
|
-
import { join as join$1, dirname as dirname$1, basename, resolve, relative } from '@visulima/path';
|
|
6
|
-
import { downloadTemplate } from 'giget';
|
|
7
|
-
import { modify, applyEdits } from 'jsonc-parser';
|
|
8
|
-
import { join, dirname } from 'node:path';
|
|
9
|
-
import { d as defineHandler } from '../packem_shared/command-BC30oSBW.mjs';
|
|
10
|
-
import { a as detectInstalledManagers, i as installArgsFor } from '../packem_shared/detect-package-manager-DYp7n3mJ.mjs';
|
|
11
|
-
import MagicString from 'magic-string';
|
|
12
|
-
import { Project, SyntaxKind } from 'ts-morph';
|
|
13
|
-
import { c as resolveSourceRef, d as resolveDistTag, r as runAddCommand } from '../packem_shared/commands-DVr4lduS.mjs';
|
|
14
|
-
import { defaultSpawner } from '../packem_shared/createRecordingSpawner-DxI3mebw.mjs';
|
|
15
|
-
import { d as tuiMascot, e as tuiStep, P as PromptCancelledError, f as tuiMoonrise, t as tuiText, g as tuiHeadline, h as tuiInfo, a as tuiSelect, w as withTuiSpinner, b as tuiConfirm, i as tuiNextSteps, j as tuiTasks, k as tuiMultiSelect, l as withTuiBadgeProgress } from '../packem_shared/tui-prompts-M6OWsuyw.mjs';
|
|
16
|
-
import { logStep } from '../packem_shared/createLogger-B40gPzQo.mjs';
|
|
17
|
-
import { E as EMAIL_ITEM, p as promptBucketName, w as withStorageBucketName, M as MAIL_DESTINATION_PROMPT, r as resolveTypedDestination, f as withMailDestination, e as promptAuthProvider, c as promptDatabaseName, g as withAuthDatabaseName } from '../packem_shared/storage-DL9OE4oE.mjs';
|
|
18
|
-
import dns from 'node:dns/promises';
|
|
19
|
-
|
|
20
|
-
const GITHUB_CONTENT = `name: Deploy
|
|
1
|
+
import{existsSync as h,mkdirSync as L,writeFileSync as m,readFileSync as k,readdirSync as X,rmSync as _,mkdtempSync as Y,lstatSync as $e,cpSync as W,renameSync as Me}from"node:fs";import{tmpdir as Z}from"node:os";import{detectFramework as Ce,isInteractive as g,LUNA_ART as Le,LUNA_NAME as Se,LUNA_SIGNOFF as Ae,paintAnswer as Ne,BADGES as f}from"@lunora/config";import{walkSync as _e}from"@visulima/fs";import{join as p,dirname as $,basename as S,resolve as B,relative as Ie}from"@visulima/path";import{downloadTemplate as ee}from"giget";import{modify as Re,applyEdits as Te}from"jsonc-parser";import{join as E,dirname as Oe}from"node:path";import{i as je}from"../packem_shared/command-Bjv4VmYA.mjs";import{P as te,t as Be,d as Ee,k as Pe}from"../packem_shared/detect-package-manager-B2eIuAiP.mjs";import De from"magic-string";import{Project as ae,SyntaxKind as v}from"ts-morph";import{P}from"../packem_shared/prompt-cancelled-C8Sj7OqI.mjs";import{P as re,g as oe,b as ze,L as se,M as Ve}from"../packem_shared/commands-BhX2Bo9B.mjs";import{defaultSpawner as ie}from"../packem_shared/createRecordingSpawner-ByIqBepG.mjs";import{Y as Ue,h as He,M as We,C as ne,U as qe,i as le,X as ce,B as D,H as Fe,W as Ke,Q as de,I as Je,t as Qe}from"../packem_shared/tui-prompts-CCt3jm1k.mjs";import{logStep as q}from"../packem_shared/createLogger--C3x1FNE.mjs";import{n as pe,u as Ge,p as Xe,b as Ye,d as Ze,l as et,g as tt,e as at,j as rt}from"../packem_shared/storage-DOvAKGi4.mjs";import ot from"node:dns/promises";const st=`name: Deploy
|
|
21
2
|
|
|
22
3
|
on:
|
|
23
4
|
push:
|
|
@@ -71,8 +52,7 @@ jobs:
|
|
|
71
52
|
cache: pnpm
|
|
72
53
|
- run: pnpm install --frozen-lockfile
|
|
73
54
|
- run: pnpm exec lunora deploy --preview
|
|
74
|
-
|
|
75
|
-
const GITLAB_CONTENT = `stages:
|
|
55
|
+
`,it=`stages:
|
|
76
56
|
- deploy
|
|
77
57
|
|
|
78
58
|
# Prerequisite: commit your pnpm-lock.yaml. \`pnpm install --frozen-lockfile\`
|
|
@@ -107,286 +87,922 @@ preview:
|
|
|
107
87
|
- if: $CI_PIPELINE_SOURCE == "merge_request_event"
|
|
108
88
|
script:
|
|
109
89
|
- pnpm exec lunora deploy --preview
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
const path = join(projectRoot, spec.file);
|
|
127
|
-
if (existsSync(path) && options.overwrite !== true) {
|
|
128
|
-
return { path, skipped: true, written: false };
|
|
129
|
-
}
|
|
130
|
-
mkdirSync(dirname(path), { recursive: true });
|
|
131
|
-
writeFileSync(path, spec.content, "utf8");
|
|
132
|
-
return { path, skipped: false, written: true };
|
|
133
|
-
};
|
|
134
|
-
const scaffoldCiWorkflow = (projectRoot, provider, logger, options = {}) => {
|
|
135
|
-
const spec = WORKFLOWS[provider];
|
|
136
|
-
try {
|
|
137
|
-
const result = writeCiWorkflow(projectRoot, provider, options);
|
|
138
|
-
if (result.skipped) {
|
|
139
|
-
logger.info(`--ci ${provider}: ${spec.file} already exists — left unchanged (re-run with overwrite to replace).`);
|
|
140
|
-
} else {
|
|
141
|
-
logger.success(`--ci ${provider}: wrote ${spec.file}`);
|
|
142
|
-
logger.info(`--ci ${provider}: set CLOUDFLARE_API_TOKEN and CLOUDFLARE_ACCOUNT_ID as ${spec.secretsHint} to enable deploys.`);
|
|
143
|
-
logger.info(
|
|
144
|
-
`--ci ${provider}: run \`pnpm install\` and commit pnpm-lock.yaml before pushing — the pipeline runs \`pnpm install --frozen-lockfile\`.`
|
|
145
|
-
);
|
|
146
|
-
}
|
|
147
|
-
return result;
|
|
148
|
-
} catch (error) {
|
|
149
|
-
const message = error instanceof Error ? error.message : String(error);
|
|
150
|
-
logger.warn(`--ci ${provider}: could not write ${spec.file} (${message})`);
|
|
151
|
-
return { path: join(projectRoot, spec.file), skipped: false, written: false };
|
|
152
|
-
}
|
|
153
|
-
};
|
|
90
|
+
`,ue={github:{content:st,file:E(".github","workflows","deploy.yml"),secretsHint:"repository secrets (Settings → Secrets and variables → Actions)"},gitlab:{content:it,file:".gitlab-ci.yml",secretsHint:"masked CI/CD variables (Settings → CI/CD → Variables)"}},nt=e=>e==="github"||e==="gitlab",lt=(e,t,a={})=>{const r=ue[t],o=E(e,r.file);return h(o)&&a.overwrite!==!0?{path:o,skipped:!0,written:!1}:(L(Oe(o),{recursive:!0}),m(o,r.content,"utf8"),{path:o,skipped:!1,written:!0})},ct=(e,t,a,r={})=>{const o=ue[t];try{const s=lt(e,t,r);return s.skipped?a.info(`--ci ${t}: ${o.file} already exists — left unchanged (re-run with overwrite to replace).`):(a.success(`--ci ${t}: wrote ${o.file}`),a.info(`--ci ${t}: set CLOUDFLARE_API_TOKEN and CLOUDFLARE_ACCOUNT_ID as ${o.secretsHint} to enable deploys.`),a.info(`--ci ${t}: run \`pnpm install\` and commit pnpm-lock.yaml before pushing — the pipeline runs \`pnpm install --frozen-lockfile\`.`)),s}catch(s){const i=s instanceof Error?s.message:String(s);return a.warn(`--ci ${t}: could not write ${o.file} (${i})`),{path:E(e,o.file),skipped:!1,written:!1}}},dt={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"},pt=e=>{const t=Ce(e);return{...t,adapter:dt[t.framework]}},N="lunora()",F='import { lunora } from "@lunora/vite";',ut=/\blunora\s*\(/u,ht='"@lunora/vite"',mt="'@lunora/vite'",gt=e=>{for(const t of e.getStatements()){if(t.getKind()!==v.ExportAssignment)continue;const a=t.asKindOrThrow(v.ExportAssignment).getExpression();if(a.getKind()!==v.CallExpression)continue;const r=a.asKindOrThrow(v.CallExpression);if(r.getExpression().getText()!=="defineConfig")continue;const o=r.getArguments()[0];if(o?.getKind()===v.ObjectLiteralExpression)return o.asKindOrThrow(v.ObjectLiteralExpression)}},vt=e=>{for(const t of e.getStatements()){if(t.getKind()!==v.ExportAssignment)continue;const a=t.asKindOrThrow(v.ExportAssignment).getExpression();if(a.getKind()===v.ObjectLiteralExpression)return a.asKindOrThrow(v.ObjectLiteralExpression)}},ft=e=>{const t=new ae({compilerOptions:{allowJs:!0},useInMemoryFileSystem:!0}).createSourceFile("vite.config.ts",e,{overwrite:!0});return gt(t)??vt(t)},wt=e=>{const t=new ae({compilerOptions:{allowJs:!0},useInMemoryFileSystem:!0}).createSourceFile("vite.config.ts",e,{overwrite:!0}).getImportDeclarations();if(t.length===0)return 0;const a=t[t.length-1];return a===void 0?0:a.getEnd()},yt=(e,t)=>{const a=wt(t);a===0?e.prepend(`${F}
|
|
91
|
+
`):e.appendLeft(a,`
|
|
92
|
+
${F}`)},bt=(e,t)=>{const a=t.getProperty("plugins");if(a===void 0){const s=t.getProperties(),i=t.getStart()+1;if(s.length===0)e.appendLeft(i,` plugins: [${N}] `);else{const n=s[0];n!==void 0&&e.appendLeft(n.getStart(),`plugins: [${N}],
|
|
93
|
+
`)}return}const r=a.getDescendantsOfKind(v.ArrayLiteralExpression)[0];if(r===void 0)return;const o=r.getElements();if(o.length===0)e.appendLeft(r.getStart()+1,N);else{const s=o[0];s!==void 0&&e.appendLeft(s.getStart(),`${N}, `)}},he=e=>{if(ut.test(e))return{changed:!1,code:e,reason:"lunora plugin already present"};const t=ft(e);if(t===void 0)return{changed:!1,code:e,reason:"could not locate a Vite config plugins array to patch"};const a=new De(e);return e.includes(ht)||e.includes(mt)||yt(a,e),bt(a,t),{changed:!0,code:a.toString()}},xt=/enotfound|eai_again|econnrefused|etimedout|network|fetch failed|getaddrinfo/u,kt=/404|not found|could not find|no such/u,$t=(e,t)=>{const a=e instanceof Error?e.message:String(e),r=a.toLowerCase(),o=`failed to download template "${t.templateType}" from ${t.remote}: ${a}`;return kt.test(r)?{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}: ${a}`}:xt.test(r)?{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}},I=async(e,t,a)=>{if(g()){await He(f[e],t,a);return}if(process.stdout.write(`
|
|
94
|
+
`),a===void 0||a===""){q(e,t);return}const r=a.split(`
|
|
95
|
+
`).map(o=>Ne(o)).join(`
|
|
96
|
+
`);q(e,`${t}
|
|
97
|
+
${r}`)},Mt=async e=>{if(g()){await Ue();return}e.info(`
|
|
98
|
+
${Le}
|
|
99
|
+
${Se}: ${Ae}`)},me=[{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:"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"}],K=me.map(e=>e.value),Ct=e=>e==="email"?pe:e,Lt=(e,t)=>{const a=[];for(const r of e.split(",").map(o=>o.trim()).filter(Boolean))K.includes(r)?a.includes(r)||a.push(r):t(`init: unknown --add feature "${r}" — expected ${K.join(" | ")}; skipping.`);return a},St=async e=>{const t=await tt(e.select),a=await at(e.text,e.projectName);return{label:"auth",names:[t],transformManifest:r=>rt(r,a)}},At=async e=>{const t=await e.text(Ye,{placeholder:"you@yourdomain.com"}),a=Ze(t,r=>{e.logger.warn(r)});return{label:"email",names:[pe],transformManifest:a===void 0?void 0:r=>et(r,a)}},Nt=async e=>{const t=await Ge(e.text,e.projectName);return{label:"storage",names:["storage"],transformManifest:a=>Xe(a,t)}},_t={auth:St,email:At,storage:Nt},J=async e=>{if(e.preselected!==void 0&&e.preselected.length>0){await e.applyAll(e.preselected.map(r=>({label:r,names:[Ct(r)]})));return}if(!e.interactive){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>`.");return}const t=await e.multiSelect("Which features do you want to add?",me,{defaults:[]});if(t.length===0)return;const a=[];for(const r of t){const o=_t[r];a.push(o?await o(e):{label:r,names:[r]})}await e.applyAll(a)},A="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",C=`/* The welcome page is a full-bleed starter — reset the browser's default
|
|
100
|
+
body margin/padding so it sits flush; everything else is scoped under
|
|
101
|
+
.lunora-welcome (collision-safe). */
|
|
102
|
+
body {
|
|
103
|
+
margin: 0;
|
|
104
|
+
padding: 0;
|
|
105
|
+
}
|
|
154
106
|
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
const base = detectFramework$1(root);
|
|
167
|
-
return { ...base, adapter: ADAPTER_BY_FRAMEWORK[base.framework] };
|
|
168
|
-
};
|
|
107
|
+
.lunora-welcome {
|
|
108
|
+
--cyan: hsl(186 84% 56%); --violet: hsl(256 72% 68%); --rose: hsl(330 80% 64%);
|
|
109
|
+
--ribbon: linear-gradient(115deg, var(--cyan), var(--violet) 52%, var(--rose));
|
|
110
|
+
--sans: "Geist Sans", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
|
|
111
|
+
--mono: "Geist Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;
|
|
112
|
+
/* NIGHT (default) */
|
|
113
|
+
--bg: #0e0e11; --surface: hsl(240 12% 8% / 0.72); --surface-2: hsl(240 11% 11% / 0.82);
|
|
114
|
+
--line: hsl(0 0% 100% / 0.08); --line-2: hsl(0 0% 100% / 0.14);
|
|
115
|
+
--t-display: hsl(228 30% 97%); --t-primary: hsl(228 26% 90%); --t-secondary: hsl(228 12% 62%); --t-faint: hsl(228 10% 44%);
|
|
116
|
+
--logo: hsl(228 30% 97%); --accent: var(--violet); --shot-bg: hsl(240 12% 6%);
|
|
117
|
+
--glow-1: hsl(256 80% 52% / 0.30); --glow-2: hsl(196 84% 52% / 0.13); --arc: hsl(256 60% 70% / 0.11);
|
|
169
118
|
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
continue;
|
|
187
|
-
}
|
|
188
|
-
const argument = call.getArguments()[0];
|
|
189
|
-
if (argument?.getKind() === SyntaxKind.ObjectLiteralExpression) {
|
|
190
|
-
return argument.asKindOrThrow(SyntaxKind.ObjectLiteralExpression);
|
|
191
|
-
}
|
|
192
|
-
}
|
|
193
|
-
return void 0;
|
|
194
|
-
};
|
|
195
|
-
const findPlainExportObject = (sf) => {
|
|
196
|
-
for (const statement of sf.getStatements()) {
|
|
197
|
-
if (statement.getKind() !== SyntaxKind.ExportAssignment) {
|
|
198
|
-
continue;
|
|
199
|
-
}
|
|
200
|
-
const expr = statement.asKindOrThrow(SyntaxKind.ExportAssignment).getExpression();
|
|
201
|
-
if (expr.getKind() === SyntaxKind.ObjectLiteralExpression) {
|
|
202
|
-
return expr.asKindOrThrow(SyntaxKind.ObjectLiteralExpression);
|
|
203
|
-
}
|
|
204
|
-
}
|
|
205
|
-
return void 0;
|
|
206
|
-
};
|
|
207
|
-
const findConfigObject = (sourceText) => {
|
|
208
|
-
const project = new Project({
|
|
209
|
-
compilerOptions: { allowJs: true },
|
|
210
|
-
useInMemoryFileSystem: true
|
|
211
|
-
});
|
|
212
|
-
const sf = project.createSourceFile("vite.config.ts", sourceText, { overwrite: true });
|
|
213
|
-
return findDefineConfigObject(sf) ?? findPlainExportObject(sf);
|
|
214
|
-
};
|
|
215
|
-
const importInsertPosition = (sourceText) => {
|
|
216
|
-
const project = new Project({
|
|
217
|
-
compilerOptions: { allowJs: true },
|
|
218
|
-
useInMemoryFileSystem: true
|
|
219
|
-
});
|
|
220
|
-
const sf = project.createSourceFile("vite.config.ts", sourceText, { overwrite: true });
|
|
221
|
-
const imports = sf.getImportDeclarations();
|
|
222
|
-
if (imports.length === 0) {
|
|
223
|
-
return 0;
|
|
224
|
-
}
|
|
225
|
-
const last = imports[imports.length - 1];
|
|
226
|
-
if (last === void 0) {
|
|
227
|
-
return 0;
|
|
228
|
-
}
|
|
229
|
-
return last.getEnd();
|
|
230
|
-
};
|
|
231
|
-
const addImport = (ms, source) => {
|
|
232
|
-
const insertAt = importInsertPosition(source);
|
|
233
|
-
if (insertAt === 0) {
|
|
234
|
-
ms.prepend(`${LUNORA_IMPORT}
|
|
235
|
-
`);
|
|
236
|
-
} else {
|
|
237
|
-
ms.appendLeft(insertAt, `
|
|
238
|
-
${LUNORA_IMPORT}`);
|
|
239
|
-
}
|
|
240
|
-
};
|
|
241
|
-
const patchPluginsArray = (ms, configObject) => {
|
|
242
|
-
const pluginsProp = configObject.getProperty("plugins");
|
|
243
|
-
if (pluginsProp === void 0) {
|
|
244
|
-
const properties = configObject.getProperties();
|
|
245
|
-
const openBrace = configObject.getStart() + 1;
|
|
246
|
-
if (properties.length === 0) {
|
|
247
|
-
ms.appendLeft(openBrace, ` plugins: [${LUNORA_CALL}] `);
|
|
248
|
-
} else {
|
|
249
|
-
const firstProp = properties[0];
|
|
250
|
-
if (firstProp !== void 0) {
|
|
251
|
-
ms.appendLeft(firstProp.getStart(), `plugins: [${LUNORA_CALL}],
|
|
252
|
-
`);
|
|
253
|
-
}
|
|
254
|
-
}
|
|
255
|
-
return;
|
|
256
|
-
}
|
|
257
|
-
const arrayLit = pluginsProp.getDescendantsOfKind(SyntaxKind.ArrayLiteralExpression)[0];
|
|
258
|
-
if (arrayLit === void 0) {
|
|
259
|
-
return;
|
|
260
|
-
}
|
|
261
|
-
const elements = arrayLit.getElements();
|
|
262
|
-
if (elements.length === 0) {
|
|
263
|
-
ms.appendLeft(arrayLit.getStart() + 1, LUNORA_CALL);
|
|
264
|
-
} else {
|
|
265
|
-
const firstElement = elements[0];
|
|
266
|
-
if (firstElement !== void 0) {
|
|
267
|
-
ms.appendLeft(firstElement.getStart(), `${LUNORA_CALL}, `);
|
|
268
|
-
}
|
|
269
|
-
}
|
|
270
|
-
};
|
|
271
|
-
const patchViteConfig = (source) => {
|
|
272
|
-
if (LUNORA_CALL_RE.test(source)) {
|
|
273
|
-
return { changed: false, code: source, reason: "lunora plugin already present" };
|
|
274
|
-
}
|
|
275
|
-
const configObject = findConfigObject(source);
|
|
276
|
-
if (configObject === void 0) {
|
|
277
|
-
return { changed: false, code: source, reason: "could not locate a Vite config plugins array to patch" };
|
|
278
|
-
}
|
|
279
|
-
const ms = new MagicString(source);
|
|
280
|
-
const alreadyImported = source.includes(LUNORA_VITE_DOUBLE) || source.includes(LUNORA_VITE_SINGLE);
|
|
281
|
-
if (alreadyImported) {
|
|
282
|
-
patchPluginsArray(ms, configObject);
|
|
283
|
-
} else {
|
|
284
|
-
addImport(ms, source);
|
|
285
|
-
patchPluginsArray(ms, configObject);
|
|
286
|
-
}
|
|
287
|
-
return { changed: true, code: ms.toString() };
|
|
288
|
-
};
|
|
119
|
+
position: relative; min-height: 100vh; background: var(--bg); color: var(--t-primary);
|
|
120
|
+
font-family: var(--sans); line-height: 1.55; -webkit-font-smoothing: antialiased; overflow-x: hidden;
|
|
121
|
+
transition: background .3s, color .3s;
|
|
122
|
+
}
|
|
123
|
+
.lunora-welcome[data-theme="light"] {
|
|
124
|
+
--bg: hsl(228 32% 97%); --surface: hsl(0 0% 100% / 0.82); --surface-2: hsl(0 0% 100% / 0.95);
|
|
125
|
+
--line: hsl(228 16% 88%); --line-2: hsl(228 14% 80%);
|
|
126
|
+
--t-display: hsl(240 14% 10%); --t-primary: hsl(240 12% 18%); --t-secondary: hsl(235 9% 42%); --t-faint: hsl(235 8% 58%);
|
|
127
|
+
--logo: hsl(240 16% 9%); --accent: hsl(256 58% 56%); --shot-bg: hsl(228 26% 99%);
|
|
128
|
+
--glow-1: hsl(256 80% 60% / 0.14); --glow-2: hsl(196 84% 58% / 0.08); --arc: hsl(256 40% 55% / 0.12);
|
|
129
|
+
}
|
|
130
|
+
.lunora-welcome *, .lunora-welcome *::before, .lunora-welcome *::after { box-sizing: border-box; }
|
|
131
|
+
.lunora-welcome a { color: inherit; text-decoration: none; }
|
|
132
|
+
.lunora-welcome button { font-family: inherit; cursor: pointer; }
|
|
133
|
+
.lunora-welcome ::selection { background: hsl(256 72% 68% / 0.3); }
|
|
134
|
+
.lunora-welcome code { font-family: var(--mono); }
|
|
289
135
|
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
}
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
${LUNA_ART}
|
|
311
|
-
${LUNA_NAME}: ${LUNA_SIGNOFF}`);
|
|
312
|
-
};
|
|
136
|
+
/* glow background */
|
|
137
|
+
.lunora-welcome .lw-bg { position: fixed; inset: 0; z-index: 0; pointer-events: none; overflow: hidden; }
|
|
138
|
+
.lunora-welcome .lw-bg .glow { position: absolute; left: 50%; top: -4%; width: 860px; height: 720px; transform: translateX(-50%);
|
|
139
|
+
border-radius: 50%; background: radial-gradient(circle at 50% 50%, var(--glow-1), var(--glow-2) 40%, transparent 66%); }
|
|
140
|
+
.lunora-welcome .lw-bg .arc { position: absolute; left: 50%; border-radius: 50%; border: 1px solid var(--arc); transform: translateX(-50%); }
|
|
141
|
+
.lunora-welcome .lw-bg .arc.a1 { top: -340px; width: 980px; height: 980px; }
|
|
142
|
+
.lunora-welcome .lw-bg .arc.a2 { top: -240px; width: 720px; height: 720px; opacity: .7; }
|
|
143
|
+
|
|
144
|
+
/* theme toggle */
|
|
145
|
+
.lunora-welcome .lw-toggle { position: fixed; z-index: 5; top: 20px; right: clamp(16px,4vw,36px); display: inline-flex; align-items: center;
|
|
146
|
+
gap: 7px; border: 1px solid var(--line-2); background: var(--surface); backdrop-filter: blur(12px); color: var(--t-secondary);
|
|
147
|
+
font-family: var(--mono); font-size: 10.5px; letter-spacing: .1em; text-transform: uppercase; padding: 7px 11px; transition: .15s; }
|
|
148
|
+
.lunora-welcome .lw-toggle:hover { color: var(--t-display); border-color: var(--accent); }
|
|
149
|
+
.lunora-welcome .lw-toggle svg { width: 13px; height: 13px; }
|
|
150
|
+
|
|
151
|
+
.lunora-welcome .lw-wrap { position: relative; z-index: 2; width: 100%; max-width: 1080px; margin: 0 auto;
|
|
152
|
+
padding: clamp(44px,8vh,92px) clamp(20px,5vw,48px); display: flex; flex-direction: column; min-height: 100vh; }
|
|
153
|
+
.lunora-welcome .brand { display: flex; align-items: center; justify-content: center; gap: 15px; margin-bottom: clamp(38px,6vh,68px); color: var(--logo); }
|
|
154
|
+
.lunora-welcome .brand svg { width: 54px; height: auto; display: block; }
|
|
155
|
+
.lunora-welcome .brand .word { font-size: 34px; font-weight: 600; letter-spacing: -0.03em; color: var(--t-display); }
|
|
313
156
|
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
157
|
+
.lunora-welcome .grid { display: grid; grid-template-columns: 1.06fr 0.94fr; gap: 16px; align-items: stretch; flex: 1; max-height: 580px; }
|
|
158
|
+
@media (max-width: 820px) { .lunora-welcome .grid { grid-template-columns: 1fr; max-height: none; } }
|
|
159
|
+
|
|
160
|
+
.lunora-welcome .card { border: 1px solid var(--line); background: var(--surface); backdrop-filter: blur(10px); transition: border-color .2s, background .2s; }
|
|
161
|
+
.lunora-welcome .card:hover { border-color: var(--line-2); background: var(--surface-2); }
|
|
162
|
+
.lunora-welcome .card:hover .arrow { color: var(--accent); transform: translateX(3px); }
|
|
163
|
+
.lunora-welcome .arrow { color: var(--t-faint); transition: color .2s, transform .2s; }
|
|
164
|
+
.lunora-welcome .arrow svg { width: 20px; height: 20px; display: block; }
|
|
165
|
+
.lunora-welcome .ic { display: grid; place-items: center; color: var(--accent);
|
|
166
|
+
border: 1px solid color-mix(in oklab, var(--accent) 36%, transparent); background: color-mix(in oklab, var(--accent) 12%, transparent); }
|
|
167
|
+
.lunora-welcome .ic svg { display: block; }
|
|
168
|
+
|
|
169
|
+
/* left feature card — stretches to fill the box height */
|
|
170
|
+
.lunora-welcome .feature { padding: clamp(18px,2vw,24px); display: flex; flex-direction: column; }
|
|
171
|
+
.lunora-welcome .shot { border: 1px solid var(--line); overflow: hidden; background: var(--shot-bg);
|
|
172
|
+
-webkit-mask-image: linear-gradient(to bottom, #000 56%, transparent 100%); mask-image: linear-gradient(to bottom, #000 56%, transparent 100%); }
|
|
173
|
+
.lunora-welcome .shot .top { display: flex; align-items: center; gap: 12px; padding: 11px 14px; border-bottom: 1px solid var(--line); }
|
|
174
|
+
.lunora-welcome .shot .wm { display: flex; align-items: center; gap: 7px; font-size: 12px; font-weight: 600; color: var(--t-primary); }
|
|
175
|
+
.lunora-welcome .shot .wm i { width: 11px; height: 11px; background: var(--ribbon); -webkit-mask: radial-gradient(circle,#000 60%,transparent 62%); mask: radial-gradient(circle,#000 60%,transparent 62%); }
|
|
176
|
+
.lunora-welcome .shot .search { flex: 1; height: 22px; border: 1px solid var(--line); border-radius: 4px; }
|
|
177
|
+
.lunora-welcome .shot .ver { font-family: var(--mono); font-size: 8px; letter-spacing: .08em; color: var(--t-faint); }
|
|
178
|
+
.lunora-welcome .shot .body { display: grid; grid-template-columns: 92px 1fr; min-height: 224px; }
|
|
179
|
+
.lunora-welcome .shot .nav { border-right: 1px solid var(--line); padding: 14px 12px; display: flex; flex-direction: column; gap: 11px; }
|
|
180
|
+
.lunora-welcome .shot .nav i, .lunora-welcome .shot .doc i { height: 5px; border-radius: 2px; background: var(--line); }
|
|
181
|
+
.lunora-welcome .shot .doc { padding: 16px 18px; display: flex; flex-direction: column; gap: 9px; }
|
|
182
|
+
.lunora-welcome .shot .doc .h { height: 8px; width: 46%; border-radius: 2px; background: var(--line-2); margin-bottom: 5px; }
|
|
183
|
+
.lunora-welcome .shot .doc .accent { height: 5px; width: 26%; border-radius: 2px; background: var(--accent); }
|
|
184
|
+
.lunora-welcome .feature .info { margin-top: auto; padding-top: clamp(18px,2.4vh,28px); }
|
|
185
|
+
.lunora-welcome .feature .ic { width: 40px; height: 40px; margin-bottom: 15px; }
|
|
186
|
+
.lunora-welcome .feature .ic svg { width: 19px; height: 19px; }
|
|
187
|
+
.lunora-welcome .feature h2 { margin: 0 0 10px; font-size: 19px; font-weight: 600; letter-spacing: -0.015em; color: var(--t-display); }
|
|
188
|
+
.lunora-welcome .feature .row { display: flex; align-items: flex-end; gap: 16px; }
|
|
189
|
+
.lunora-welcome .feature p { margin: 0; color: var(--t-secondary); font-size: 14px; max-width: 50ch; }
|
|
190
|
+
.lunora-welcome .feature .row .arrow { margin-left: auto; }
|
|
191
|
+
|
|
192
|
+
/* right stack — smaller cards, spread to align bottoms with the feature */
|
|
193
|
+
.lunora-welcome .stack { display: flex; flex-direction: column; gap: 16px; height: 100%; }
|
|
194
|
+
.lunora-welcome .mini { flex: 1; padding: 15px 17px; display: flex; align-items: center; gap: 16px; min-height: 0; }
|
|
195
|
+
.lunora-welcome .mini .mc { flex: 1; }
|
|
196
|
+
.lunora-welcome .mini .ic { width: 32px; height: 32px; margin-bottom: 10px; }
|
|
197
|
+
.lunora-welcome .mini .ic svg { width: 16px; height: 16px; }
|
|
198
|
+
.lunora-welcome .mini h3 { margin: 0 0 5px; font-size: 16px; font-weight: 600; letter-spacing: -0.01em; color: var(--t-display); }
|
|
199
|
+
.lunora-welcome .mini p { margin: 0; color: var(--t-secondary); font-size: 12.5px; line-height: 1.45; }
|
|
200
|
+
|
|
201
|
+
.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); }
|
|
202
|
+
|
|
203
|
+
@media (prefers-reduced-motion: reduce) { .lunora-welcome * { transition: none !important; } }
|
|
204
|
+
`,It=`import { useEffect, useState } from "react";
|
|
205
|
+
|
|
206
|
+
type Theme = "dark" | "light";
|
|
207
|
+
|
|
208
|
+
export default function App() {
|
|
209
|
+
// Default to "dark" for a stable first paint, then reconcile to the OS
|
|
210
|
+
// preference; the toggle takes over after that.
|
|
211
|
+
const [theme, setTheme] = useState<Theme>("dark");
|
|
212
|
+
|
|
213
|
+
useEffect(() => {
|
|
214
|
+
if (typeof window !== "undefined" && window.matchMedia("(prefers-color-scheme: light)").matches) {
|
|
215
|
+
setTheme("light");
|
|
216
|
+
}
|
|
217
|
+
}, []);
|
|
218
|
+
|
|
219
|
+
const isLight = theme === "light";
|
|
220
|
+
|
|
221
|
+
return (
|
|
222
|
+
<div className="lunora-welcome" data-theme={theme}>
|
|
223
|
+
<div className="lw-bg">
|
|
224
|
+
<div className="arc a1" />
|
|
225
|
+
<div className="arc a2" />
|
|
226
|
+
<div className="glow" />
|
|
227
|
+
</div>
|
|
228
|
+
|
|
229
|
+
<button className="lw-toggle" type="button" aria-label="Toggle color theme" onClick={() => setTheme(isLight ? "dark" : "light")}>
|
|
230
|
+
{isLight ? (
|
|
231
|
+
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.8">
|
|
232
|
+
<path d="M21 12.8A9 9 0 1 1 11.2 3a7 7 0 0 0 9.8 9.8z" />
|
|
233
|
+
</svg>
|
|
234
|
+
) : (
|
|
235
|
+
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.8">
|
|
236
|
+
<circle cx="12" cy="12" r="4" />
|
|
237
|
+
<path d="M12 2v2M12 20v2M4 12H2M22 12h-2M5 5l1.5 1.5M17.5 17.5 19 19M19 5l-1.5 1.5M6.5 17.5 5 19" />
|
|
238
|
+
</svg>
|
|
239
|
+
)}
|
|
240
|
+
<span>{isLight ? "Ivory" : "Night"}</span>
|
|
241
|
+
</button>
|
|
242
|
+
|
|
243
|
+
<div className="lw-wrap">
|
|
244
|
+
<div className="brand">
|
|
245
|
+
<svg viewBox="0 0 543 446" role="img" aria-label="Lunora">
|
|
246
|
+
<path d="${A}" fill="currentColor" fillRule="evenodd" />
|
|
247
|
+
</svg>
|
|
248
|
+
<span className="word">Lunora</span>
|
|
249
|
+
</div>
|
|
250
|
+
|
|
251
|
+
<div className="grid">
|
|
252
|
+
<a className="card feature" href="https://lunora.sh/docs">
|
|
253
|
+
<div className="shot" aria-hidden="true">
|
|
254
|
+
<div className="top">
|
|
255
|
+
<span className="wm">
|
|
256
|
+
<i /> Lunora
|
|
257
|
+
</span>
|
|
258
|
+
<span className="search" />
|
|
259
|
+
<span className="ver">v0.1</span>
|
|
260
|
+
</div>
|
|
261
|
+
<div className="body">
|
|
262
|
+
<div className="nav">
|
|
263
|
+
<i style={{ width: "80%" }} />
|
|
264
|
+
<i style={{ width: "60%" }} />
|
|
265
|
+
<i style={{ width: "72%" }} />
|
|
266
|
+
<i style={{ width: "50%" }} />
|
|
267
|
+
<i style={{ width: "66%" }} />
|
|
268
|
+
<i style={{ width: "44%" }} />
|
|
269
|
+
<i style={{ width: "58%" }} />
|
|
270
|
+
</div>
|
|
271
|
+
<div className="doc">
|
|
272
|
+
<span className="h" />
|
|
273
|
+
<i style={{ width: "92%" }} />
|
|
274
|
+
<i style={{ width: "88%" }} />
|
|
275
|
+
<span className="accent" />
|
|
276
|
+
<i style={{ width: "80%" }} />
|
|
277
|
+
<i style={{ width: "90%" }} />
|
|
278
|
+
<i style={{ width: "72%" }} />
|
|
279
|
+
<i style={{ width: "84%" }} />
|
|
280
|
+
<i style={{ width: "78%" }} />
|
|
281
|
+
</div>
|
|
282
|
+
</div>
|
|
283
|
+
</div>
|
|
284
|
+
<div className="info">
|
|
285
|
+
<span className="ic">
|
|
286
|
+
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.7">
|
|
287
|
+
<path d="M4 5a2 2 0 0 1 2-2h9l5 5v11a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2z" />
|
|
288
|
+
<path d="M14 3v5h5" />
|
|
289
|
+
</svg>
|
|
290
|
+
</span>
|
|
291
|
+
<h2>Documentation</h2>
|
|
292
|
+
<div className="row">
|
|
293
|
+
<p>
|
|
294
|
+
Schemas, queries, live subscriptions, sharding, and edge deploy — start to finish. New here or coming from Convex or tRPC,
|
|
295
|
+
you'll have a live app fast.
|
|
296
|
+
</p>
|
|
297
|
+
<span className="arrow">
|
|
298
|
+
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2">
|
|
299
|
+
<path d="M5 12h14M13 6l6 6-6 6" />
|
|
300
|
+
</svg>
|
|
301
|
+
</span>
|
|
302
|
+
</div>
|
|
303
|
+
</div>
|
|
304
|
+
</a>
|
|
305
|
+
|
|
306
|
+
<div className="stack">
|
|
307
|
+
<a className="card mini" href="https://lunora.sh/blog">
|
|
308
|
+
<div className="mc">
|
|
309
|
+
<span className="ic">
|
|
310
|
+
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.7">
|
|
311
|
+
<path d="M5 4h11a1 1 0 0 1 1 1v14a1 1 0 0 1-1 1H6a2 2 0 0 1-2-2V5a1 1 0 0 1 1-1zM8 8h7M8 12h7M8 16h4" />
|
|
312
|
+
</svg>
|
|
313
|
+
</span>
|
|
314
|
+
<h3>Blog</h3>
|
|
315
|
+
<p>Product updates, deep dives, and what's new in Lunora.</p>
|
|
316
|
+
</div>
|
|
317
|
+
<span className="arrow">
|
|
318
|
+
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2">
|
|
319
|
+
<path d="M5 12h14M13 6l6 6-6 6" />
|
|
320
|
+
</svg>
|
|
321
|
+
</span>
|
|
322
|
+
</a>
|
|
323
|
+
<a className="card mini" href="/_lunora">
|
|
324
|
+
<div className="mc">
|
|
325
|
+
<span className="ic">
|
|
326
|
+
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.7">
|
|
327
|
+
<rect x="3" y="3" width="18" height="18" rx="1" />
|
|
328
|
+
<path d="M3 9h18M9 21V9" />
|
|
329
|
+
</svg>
|
|
330
|
+
</span>
|
|
331
|
+
<h3>Lunora Studio</h3>
|
|
332
|
+
<p>Local admin for schema, data, logs, and advisors.</p>
|
|
333
|
+
</div>
|
|
334
|
+
<span className="arrow">
|
|
335
|
+
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2">
|
|
336
|
+
<path d="M5 12h14M13 6l6 6-6 6" />
|
|
337
|
+
</svg>
|
|
338
|
+
</span>
|
|
339
|
+
</a>
|
|
340
|
+
<a className="card mini" href="https://lunora.sh/packages">
|
|
341
|
+
<div className="mc">
|
|
342
|
+
<span className="ic">
|
|
343
|
+
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.7">
|
|
344
|
+
<path d="M12 2 3 7v10l9 5 9-5V7z" />
|
|
345
|
+
<path d="M3 7l9 5 9-5M12 12v10" />
|
|
346
|
+
</svg>
|
|
347
|
+
</span>
|
|
348
|
+
<h3>Cloudflare ecosystem</h3>
|
|
349
|
+
<p>Auth, mail, storage, AI, payments — one deploy.</p>
|
|
350
|
+
</div>
|
|
351
|
+
<span className="arrow">
|
|
352
|
+
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2">
|
|
353
|
+
<path d="M5 12h14M13 6l6 6-6 6" />
|
|
354
|
+
</svg>
|
|
355
|
+
</span>
|
|
356
|
+
</a>
|
|
357
|
+
</div>
|
|
358
|
+
</div>
|
|
359
|
+
|
|
360
|
+
<div className="lw-foot">Running on Lunora · Vite + React</div>
|
|
361
|
+
</div>
|
|
362
|
+
</div>
|
|
363
|
+
);
|
|
364
|
+
}
|
|
365
|
+
`,Rt=`<script setup lang="ts">
|
|
366
|
+
import { onMounted, ref } from "vue";
|
|
367
|
+
|
|
368
|
+
// Default to "dark" for a stable first paint, then reconcile to the OS
|
|
369
|
+
// preference; the toggle takes over after that.
|
|
370
|
+
const theme = ref<"dark" | "light">("dark");
|
|
371
|
+
|
|
372
|
+
onMounted(() => {
|
|
373
|
+
if (window.matchMedia("(prefers-color-scheme: light)").matches) {
|
|
374
|
+
theme.value = "light";
|
|
334
375
|
}
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
const provider = await promptAuthProvider(deps.select);
|
|
340
|
-
const databaseName = await promptDatabaseName(deps.text, deps.projectName);
|
|
341
|
-
return { label: "auth", names: [provider], transformManifest: (manifest) => withAuthDatabaseName(manifest, databaseName) };
|
|
342
|
-
};
|
|
343
|
-
const collectEmailFeature = async (deps) => {
|
|
344
|
-
const answer = await deps.text(MAIL_DESTINATION_PROMPT, { placeholder: "you@yourdomain.com" });
|
|
345
|
-
const destination = resolveTypedDestination(answer, (message) => {
|
|
346
|
-
deps.logger.warn(message);
|
|
347
|
-
});
|
|
348
|
-
return {
|
|
349
|
-
label: "email",
|
|
350
|
-
names: [EMAIL_ITEM],
|
|
351
|
-
transformManifest: destination === void 0 ? void 0 : (manifest) => withMailDestination(manifest, destination)
|
|
352
|
-
};
|
|
353
|
-
};
|
|
354
|
-
const collectStorageFeature = async (deps) => {
|
|
355
|
-
const bucketName = await promptBucketName(deps.text, deps.projectName);
|
|
356
|
-
return { label: "storage", names: ["storage"], transformManifest: (manifest) => withStorageBucketName(manifest, bucketName) };
|
|
357
|
-
};
|
|
358
|
-
const FEATURE_COLLECTORS = {
|
|
359
|
-
auth: collectAuthFeature,
|
|
360
|
-
email: collectEmailFeature,
|
|
361
|
-
storage: collectStorageFeature
|
|
376
|
+
});
|
|
377
|
+
|
|
378
|
+
const toggle = (): void => {
|
|
379
|
+
theme.value = theme.value === "light" ? "dark" : "light";
|
|
362
380
|
};
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
381
|
+
<\/script>
|
|
382
|
+
|
|
383
|
+
<template>
|
|
384
|
+
<div class="lunora-welcome" :data-theme="theme">
|
|
385
|
+
<div class="lw-bg">
|
|
386
|
+
<div class="arc a1" />
|
|
387
|
+
<div class="arc a2" />
|
|
388
|
+
<div class="glow" />
|
|
389
|
+
</div>
|
|
390
|
+
|
|
391
|
+
<button class="lw-toggle" type="button" aria-label="Toggle color theme" @click="toggle">
|
|
392
|
+
<svg v-if="theme === 'light'" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8">
|
|
393
|
+
<path d="M21 12.8A9 9 0 1 1 11.2 3a7 7 0 0 0 9.8 9.8z" />
|
|
394
|
+
</svg>
|
|
395
|
+
<svg v-else viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8">
|
|
396
|
+
<circle cx="12" cy="12" r="4" />
|
|
397
|
+
<path d="M12 2v2M12 20v2M4 12H2M22 12h-2M5 5l1.5 1.5M17.5 17.5 19 19M19 5l-1.5 1.5M6.5 17.5 5 19" />
|
|
398
|
+
</svg>
|
|
399
|
+
<span>{{ theme === "light" ? "Ivory" : "Night" }}</span>
|
|
400
|
+
</button>
|
|
401
|
+
|
|
402
|
+
<div class="lw-wrap">
|
|
403
|
+
<div class="brand">
|
|
404
|
+
<svg viewBox="0 0 543 446" role="img" aria-label="Lunora">
|
|
405
|
+
<path d="${A}" fill="currentColor" fill-rule="evenodd" />
|
|
406
|
+
</svg>
|
|
407
|
+
<span class="word">Lunora</span>
|
|
408
|
+
</div>
|
|
409
|
+
|
|
410
|
+
<div class="grid">
|
|
411
|
+
<a class="card feature" href="https://lunora.sh/docs">
|
|
412
|
+
<div class="shot" aria-hidden="true">
|
|
413
|
+
<div class="top">
|
|
414
|
+
<span class="wm"><i /> Lunora</span>
|
|
415
|
+
<span class="search" />
|
|
416
|
+
<span class="ver">v0.1</span>
|
|
417
|
+
</div>
|
|
418
|
+
<div class="body">
|
|
419
|
+
<div class="nav">
|
|
420
|
+
<i style="width: 80%" />
|
|
421
|
+
<i style="width: 60%" />
|
|
422
|
+
<i style="width: 72%" />
|
|
423
|
+
<i style="width: 50%" />
|
|
424
|
+
<i style="width: 66%" />
|
|
425
|
+
<i style="width: 44%" />
|
|
426
|
+
<i style="width: 58%" />
|
|
427
|
+
</div>
|
|
428
|
+
<div class="doc">
|
|
429
|
+
<span class="h" />
|
|
430
|
+
<i style="width: 92%" />
|
|
431
|
+
<i style="width: 88%" />
|
|
432
|
+
<span class="accent" />
|
|
433
|
+
<i style="width: 80%" />
|
|
434
|
+
<i style="width: 90%" />
|
|
435
|
+
<i style="width: 72%" />
|
|
436
|
+
<i style="width: 84%" />
|
|
437
|
+
<i style="width: 78%" />
|
|
438
|
+
</div>
|
|
439
|
+
</div>
|
|
440
|
+
</div>
|
|
441
|
+
<div class="info">
|
|
442
|
+
<span class="ic">
|
|
443
|
+
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.7">
|
|
444
|
+
<path d="M4 5a2 2 0 0 1 2-2h9l5 5v11a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2z" />
|
|
445
|
+
<path d="M14 3v5h5" />
|
|
446
|
+
</svg>
|
|
447
|
+
</span>
|
|
448
|
+
<h2>Documentation</h2>
|
|
449
|
+
<div class="row">
|
|
450
|
+
<p>
|
|
451
|
+
Schemas, queries, live subscriptions, sharding, and edge deploy — start to finish. New here or coming from Convex or tRPC,
|
|
452
|
+
you'll have a live app fast.
|
|
453
|
+
</p>
|
|
454
|
+
<span class="arrow">
|
|
455
|
+
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
|
|
456
|
+
<path d="M5 12h14M13 6l6 6-6 6" />
|
|
457
|
+
</svg>
|
|
458
|
+
</span>
|
|
459
|
+
</div>
|
|
460
|
+
</div>
|
|
461
|
+
</a>
|
|
462
|
+
|
|
463
|
+
<div class="stack">
|
|
464
|
+
<a class="card mini" href="https://lunora.sh/blog">
|
|
465
|
+
<div class="mc">
|
|
466
|
+
<span class="ic">
|
|
467
|
+
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.7">
|
|
468
|
+
<path d="M5 4h11a1 1 0 0 1 1 1v14a1 1 0 0 1-1 1H6a2 2 0 0 1-2-2V5a1 1 0 0 1 1-1zM8 8h7M8 12h7M8 16h4" />
|
|
469
|
+
</svg>
|
|
470
|
+
</span>
|
|
471
|
+
<h3>Blog</h3>
|
|
472
|
+
<p>Product updates, deep dives, and what's new in Lunora.</p>
|
|
473
|
+
</div>
|
|
474
|
+
<span class="arrow">
|
|
475
|
+
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
|
|
476
|
+
<path d="M5 12h14M13 6l6 6-6 6" />
|
|
477
|
+
</svg>
|
|
478
|
+
</span>
|
|
479
|
+
</a>
|
|
480
|
+
<a class="card mini" href="/_lunora">
|
|
481
|
+
<div class="mc">
|
|
482
|
+
<span class="ic">
|
|
483
|
+
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.7">
|
|
484
|
+
<rect x="3" y="3" width="18" height="18" rx="1" />
|
|
485
|
+
<path d="M3 9h18M9 21V9" />
|
|
486
|
+
</svg>
|
|
487
|
+
</span>
|
|
488
|
+
<h3>Lunora Studio</h3>
|
|
489
|
+
<p>Local admin for schema, data, logs, and advisors.</p>
|
|
490
|
+
</div>
|
|
491
|
+
<span class="arrow">
|
|
492
|
+
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
|
|
493
|
+
<path d="M5 12h14M13 6l6 6-6 6" />
|
|
494
|
+
</svg>
|
|
495
|
+
</span>
|
|
496
|
+
</a>
|
|
497
|
+
<a class="card mini" href="https://lunora.sh/packages">
|
|
498
|
+
<div class="mc">
|
|
499
|
+
<span class="ic">
|
|
500
|
+
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.7">
|
|
501
|
+
<path d="M12 2 3 7v10l9 5 9-5V7z" />
|
|
502
|
+
<path d="M3 7l9 5 9-5M12 12v10" />
|
|
503
|
+
</svg>
|
|
504
|
+
</span>
|
|
505
|
+
<h3>Cloudflare ecosystem</h3>
|
|
506
|
+
<p>Auth, mail, storage, AI, payments — one deploy.</p>
|
|
507
|
+
</div>
|
|
508
|
+
<span class="arrow">
|
|
509
|
+
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
|
|
510
|
+
<path d="M5 12h14M13 6l6 6-6 6" />
|
|
511
|
+
</svg>
|
|
512
|
+
</span>
|
|
513
|
+
</a>
|
|
514
|
+
</div>
|
|
515
|
+
</div>
|
|
516
|
+
|
|
517
|
+
<div class="lw-foot">Running on Lunora · Vite + Vue</div>
|
|
518
|
+
</div>
|
|
519
|
+
</div>
|
|
520
|
+
</template>
|
|
521
|
+
`,Tt=`import { createSignal, onMount } from "solid-js";
|
|
522
|
+
|
|
523
|
+
export default function App() {
|
|
524
|
+
// Default to "dark" for a stable first paint, then reconcile to the OS
|
|
525
|
+
// preference; the toggle takes over after that.
|
|
526
|
+
const [theme, setTheme] = createSignal<"dark" | "light">("dark");
|
|
527
|
+
|
|
528
|
+
onMount(() => {
|
|
529
|
+
if (window.matchMedia("(prefers-color-scheme: light)").matches) {
|
|
530
|
+
setTheme("light");
|
|
531
|
+
}
|
|
532
|
+
});
|
|
533
|
+
|
|
534
|
+
const isLight = () => theme() === "light";
|
|
535
|
+
|
|
536
|
+
return (
|
|
537
|
+
<div class="lunora-welcome" data-theme={theme()}>
|
|
538
|
+
<div class="lw-bg">
|
|
539
|
+
<div class="arc a1" />
|
|
540
|
+
<div class="arc a2" />
|
|
541
|
+
<div class="glow" />
|
|
542
|
+
</div>
|
|
543
|
+
|
|
544
|
+
<button class="lw-toggle" type="button" aria-label="Toggle color theme" onClick={() => setTheme(isLight() ? "dark" : "light")}>
|
|
545
|
+
{isLight() ? (
|
|
546
|
+
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8">
|
|
547
|
+
<path d="M21 12.8A9 9 0 1 1 11.2 3a7 7 0 0 0 9.8 9.8z" />
|
|
548
|
+
</svg>
|
|
549
|
+
) : (
|
|
550
|
+
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8">
|
|
551
|
+
<circle cx="12" cy="12" r="4" />
|
|
552
|
+
<path d="M12 2v2M12 20v2M4 12H2M22 12h-2M5 5l1.5 1.5M17.5 17.5 19 19M19 5l-1.5 1.5M6.5 17.5 5 19" />
|
|
553
|
+
</svg>
|
|
554
|
+
)}
|
|
555
|
+
<span>{isLight() ? "Ivory" : "Night"}</span>
|
|
556
|
+
</button>
|
|
557
|
+
|
|
558
|
+
<div class="lw-wrap">
|
|
559
|
+
<div class="brand">
|
|
560
|
+
<svg viewBox="0 0 543 446" role="img" aria-label="Lunora">
|
|
561
|
+
<path d="${A}" fill="currentColor" fill-rule="evenodd" />
|
|
562
|
+
</svg>
|
|
563
|
+
<span class="word">Lunora</span>
|
|
564
|
+
</div>
|
|
565
|
+
|
|
566
|
+
<div class="grid">
|
|
567
|
+
<a class="card feature" href="https://lunora.sh/docs">
|
|
568
|
+
<div class="shot" aria-hidden="true">
|
|
569
|
+
<div class="top">
|
|
570
|
+
<span class="wm">
|
|
571
|
+
<i /> Lunora
|
|
572
|
+
</span>
|
|
573
|
+
<span class="search" />
|
|
574
|
+
<span class="ver">v0.1</span>
|
|
575
|
+
</div>
|
|
576
|
+
<div class="body">
|
|
577
|
+
<div class="nav">
|
|
578
|
+
<i style={{ width: "80%" }} />
|
|
579
|
+
<i style={{ width: "60%" }} />
|
|
580
|
+
<i style={{ width: "72%" }} />
|
|
581
|
+
<i style={{ width: "50%" }} />
|
|
582
|
+
<i style={{ width: "66%" }} />
|
|
583
|
+
<i style={{ width: "44%" }} />
|
|
584
|
+
<i style={{ width: "58%" }} />
|
|
585
|
+
</div>
|
|
586
|
+
<div class="doc">
|
|
587
|
+
<span class="h" />
|
|
588
|
+
<i style={{ width: "92%" }} />
|
|
589
|
+
<i style={{ width: "88%" }} />
|
|
590
|
+
<span class="accent" />
|
|
591
|
+
<i style={{ width: "80%" }} />
|
|
592
|
+
<i style={{ width: "90%" }} />
|
|
593
|
+
<i style={{ width: "72%" }} />
|
|
594
|
+
<i style={{ width: "84%" }} />
|
|
595
|
+
<i style={{ width: "78%" }} />
|
|
596
|
+
</div>
|
|
597
|
+
</div>
|
|
598
|
+
</div>
|
|
599
|
+
<div class="info">
|
|
600
|
+
<span class="ic">
|
|
601
|
+
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.7">
|
|
602
|
+
<path d="M4 5a2 2 0 0 1 2-2h9l5 5v11a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2z" />
|
|
603
|
+
<path d="M14 3v5h5" />
|
|
604
|
+
</svg>
|
|
605
|
+
</span>
|
|
606
|
+
<h2>Documentation</h2>
|
|
607
|
+
<div class="row">
|
|
608
|
+
<p>
|
|
609
|
+
Schemas, queries, live subscriptions, sharding, and edge deploy — start to finish. New here or coming from Convex or tRPC,
|
|
610
|
+
you'll have a live app fast.
|
|
611
|
+
</p>
|
|
612
|
+
<span class="arrow">
|
|
613
|
+
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
|
|
614
|
+
<path d="M5 12h14M13 6l6 6-6 6" />
|
|
615
|
+
</svg>
|
|
616
|
+
</span>
|
|
617
|
+
</div>
|
|
618
|
+
</div>
|
|
619
|
+
</a>
|
|
620
|
+
|
|
621
|
+
<div class="stack">
|
|
622
|
+
<a class="card mini" href="https://lunora.sh/blog">
|
|
623
|
+
<div class="mc">
|
|
624
|
+
<span class="ic">
|
|
625
|
+
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.7">
|
|
626
|
+
<path d="M5 4h11a1 1 0 0 1 1 1v14a1 1 0 0 1-1 1H6a2 2 0 0 1-2-2V5a1 1 0 0 1 1-1zM8 8h7M8 12h7M8 16h4" />
|
|
627
|
+
</svg>
|
|
628
|
+
</span>
|
|
629
|
+
<h3>Blog</h3>
|
|
630
|
+
<p>Product updates, deep dives, and what's new in Lunora.</p>
|
|
631
|
+
</div>
|
|
632
|
+
<span class="arrow">
|
|
633
|
+
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
|
|
634
|
+
<path d="M5 12h14M13 6l6 6-6 6" />
|
|
635
|
+
</svg>
|
|
636
|
+
</span>
|
|
637
|
+
</a>
|
|
638
|
+
<a class="card mini" href="/_lunora">
|
|
639
|
+
<div class="mc">
|
|
640
|
+
<span class="ic">
|
|
641
|
+
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.7">
|
|
642
|
+
<rect x="3" y="3" width="18" height="18" rx="1" />
|
|
643
|
+
<path d="M3 9h18M9 21V9" />
|
|
644
|
+
</svg>
|
|
645
|
+
</span>
|
|
646
|
+
<h3>Lunora Studio</h3>
|
|
647
|
+
<p>Local admin for schema, data, logs, and advisors.</p>
|
|
648
|
+
</div>
|
|
649
|
+
<span class="arrow">
|
|
650
|
+
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
|
|
651
|
+
<path d="M5 12h14M13 6l6 6-6 6" />
|
|
652
|
+
</svg>
|
|
653
|
+
</span>
|
|
654
|
+
</a>
|
|
655
|
+
<a class="card mini" href="https://lunora.sh/packages">
|
|
656
|
+
<div class="mc">
|
|
657
|
+
<span class="ic">
|
|
658
|
+
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.7">
|
|
659
|
+
<path d="M12 2 3 7v10l9 5 9-5V7z" />
|
|
660
|
+
<path d="M3 7l9 5 9-5M12 12v10" />
|
|
661
|
+
</svg>
|
|
662
|
+
</span>
|
|
663
|
+
<h3>Cloudflare ecosystem</h3>
|
|
664
|
+
<p>Auth, mail, storage, AI, payments — one deploy.</p>
|
|
665
|
+
</div>
|
|
666
|
+
<span class="arrow">
|
|
667
|
+
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
|
|
668
|
+
<path d="M5 12h14M13 6l6 6-6 6" />
|
|
669
|
+
</svg>
|
|
670
|
+
</span>
|
|
671
|
+
</a>
|
|
672
|
+
</div>
|
|
673
|
+
</div>
|
|
674
|
+
|
|
675
|
+
<div class="lw-foot">Running on Lunora · Vite + Solid</div>
|
|
676
|
+
</div>
|
|
677
|
+
</div>
|
|
369
678
|
);
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
679
|
+
}
|
|
680
|
+
`,Ot=`<script lang="ts">
|
|
681
|
+
import { onMount } from "svelte";
|
|
682
|
+
|
|
683
|
+
// Default to "dark" for a stable first paint, then reconcile to the OS
|
|
684
|
+
// preference; the toggle takes over after that.
|
|
685
|
+
let theme = $state<"dark" | "light">("dark");
|
|
686
|
+
const isLight = $derived(theme === "light");
|
|
687
|
+
|
|
688
|
+
onMount(() => {
|
|
689
|
+
if (window.matchMedia("(prefers-color-scheme: light)").matches) {
|
|
690
|
+
theme = "light";
|
|
691
|
+
}
|
|
692
|
+
});
|
|
693
|
+
|
|
694
|
+
const toggle = (): void => {
|
|
695
|
+
theme = theme === "light" ? "dark" : "light";
|
|
696
|
+
};
|
|
697
|
+
<\/script>
|
|
698
|
+
|
|
699
|
+
<div class="lunora-welcome" data-theme={theme}>
|
|
700
|
+
<div class="lw-bg">
|
|
701
|
+
<div class="arc a1"></div>
|
|
702
|
+
<div class="arc a2"></div>
|
|
703
|
+
<div class="glow"></div>
|
|
704
|
+
</div>
|
|
705
|
+
|
|
706
|
+
<button class="lw-toggle" type="button" aria-label="Toggle color theme" onclick={toggle}>
|
|
707
|
+
{#if isLight}
|
|
708
|
+
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8">
|
|
709
|
+
<path d="M21 12.8A9 9 0 1 1 11.2 3a7 7 0 0 0 9.8 9.8z" />
|
|
710
|
+
</svg>
|
|
711
|
+
{:else}
|
|
712
|
+
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8">
|
|
713
|
+
<circle cx="12" cy="12" r="4" />
|
|
714
|
+
<path d="M12 2v2M12 20v2M4 12H2M22 12h-2M5 5l1.5 1.5M17.5 17.5 19 19M19 5l-1.5 1.5M6.5 17.5 5 19" />
|
|
715
|
+
</svg>
|
|
716
|
+
{/if}
|
|
717
|
+
<span>{isLight ? "Ivory" : "Night"}</span>
|
|
718
|
+
</button>
|
|
719
|
+
|
|
720
|
+
<div class="lw-wrap">
|
|
721
|
+
<div class="brand">
|
|
722
|
+
<svg viewBox="0 0 543 446" role="img" aria-label="Lunora">
|
|
723
|
+
<path d="${A}" fill="currentColor" fill-rule="evenodd" />
|
|
724
|
+
</svg>
|
|
725
|
+
<span class="word">Lunora</span>
|
|
726
|
+
</div>
|
|
727
|
+
|
|
728
|
+
<div class="grid">
|
|
729
|
+
<a class="card feature" href="https://lunora.sh/docs">
|
|
730
|
+
<div class="shot" aria-hidden="true">
|
|
731
|
+
<div class="top">
|
|
732
|
+
<span class="wm"><i></i> Lunora</span>
|
|
733
|
+
<span class="search"></span>
|
|
734
|
+
<span class="ver">v0.1</span>
|
|
735
|
+
</div>
|
|
736
|
+
<div class="body">
|
|
737
|
+
<div class="nav">
|
|
738
|
+
<i style="width: 80%"></i>
|
|
739
|
+
<i style="width: 60%"></i>
|
|
740
|
+
<i style="width: 72%"></i>
|
|
741
|
+
<i style="width: 50%"></i>
|
|
742
|
+
<i style="width: 66%"></i>
|
|
743
|
+
<i style="width: 44%"></i>
|
|
744
|
+
<i style="width: 58%"></i>
|
|
745
|
+
</div>
|
|
746
|
+
<div class="doc">
|
|
747
|
+
<span class="h"></span>
|
|
748
|
+
<i style="width: 92%"></i>
|
|
749
|
+
<i style="width: 88%"></i>
|
|
750
|
+
<span class="accent"></span>
|
|
751
|
+
<i style="width: 80%"></i>
|
|
752
|
+
<i style="width: 90%"></i>
|
|
753
|
+
<i style="width: 72%"></i>
|
|
754
|
+
<i style="width: 84%"></i>
|
|
755
|
+
<i style="width: 78%"></i>
|
|
756
|
+
</div>
|
|
757
|
+
</div>
|
|
758
|
+
</div>
|
|
759
|
+
<div class="info">
|
|
760
|
+
<span class="ic">
|
|
761
|
+
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.7">
|
|
762
|
+
<path d="M4 5a2 2 0 0 1 2-2h9l5 5v11a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2z" />
|
|
763
|
+
<path d="M14 3v5h5" />
|
|
764
|
+
</svg>
|
|
765
|
+
</span>
|
|
766
|
+
<h2>Documentation</h2>
|
|
767
|
+
<div class="row">
|
|
768
|
+
<p>
|
|
769
|
+
Schemas, queries, live subscriptions, sharding, and edge deploy — start to finish. New here or coming from Convex or tRPC,
|
|
770
|
+
you'll have a live app fast.
|
|
771
|
+
</p>
|
|
772
|
+
<span class="arrow">
|
|
773
|
+
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
|
|
774
|
+
<path d="M5 12h14M13 6l6 6-6 6" />
|
|
775
|
+
</svg>
|
|
776
|
+
</span>
|
|
777
|
+
</div>
|
|
778
|
+
</div>
|
|
779
|
+
</a>
|
|
780
|
+
|
|
781
|
+
<div class="stack">
|
|
782
|
+
<a class="card mini" href="https://lunora.sh/blog">
|
|
783
|
+
<div class="mc">
|
|
784
|
+
<span class="ic">
|
|
785
|
+
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.7">
|
|
786
|
+
<path d="M5 4h11a1 1 0 0 1 1 1v14a1 1 0 0 1-1 1H6a2 2 0 0 1-2-2V5a1 1 0 0 1 1-1zM8 8h7M8 12h7M8 16h4" />
|
|
787
|
+
</svg>
|
|
788
|
+
</span>
|
|
789
|
+
<h3>Blog</h3>
|
|
790
|
+
<p>Product updates, deep dives, and what's new in Lunora.</p>
|
|
791
|
+
</div>
|
|
792
|
+
<span class="arrow">
|
|
793
|
+
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
|
|
794
|
+
<path d="M5 12h14M13 6l6 6-6 6" />
|
|
795
|
+
</svg>
|
|
796
|
+
</span>
|
|
797
|
+
</a>
|
|
798
|
+
<a class="card mini" href="/_lunora">
|
|
799
|
+
<div class="mc">
|
|
800
|
+
<span class="ic">
|
|
801
|
+
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.7">
|
|
802
|
+
<rect x="3" y="3" width="18" height="18" rx="1" />
|
|
803
|
+
<path d="M3 9h18M9 21V9" />
|
|
804
|
+
</svg>
|
|
805
|
+
</span>
|
|
806
|
+
<h3>Lunora Studio</h3>
|
|
807
|
+
<p>Local admin for schema, data, logs, and advisors.</p>
|
|
808
|
+
</div>
|
|
809
|
+
<span class="arrow">
|
|
810
|
+
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
|
|
811
|
+
<path d="M5 12h14M13 6l6 6-6 6" />
|
|
812
|
+
</svg>
|
|
813
|
+
</span>
|
|
814
|
+
</a>
|
|
815
|
+
<a class="card mini" href="https://lunora.sh/packages">
|
|
816
|
+
<div class="mc">
|
|
817
|
+
<span class="ic">
|
|
818
|
+
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.7">
|
|
819
|
+
<path d="M12 2 3 7v10l9 5 9-5V7z" />
|
|
820
|
+
<path d="M3 7l9 5 9-5M12 12v10" />
|
|
821
|
+
</svg>
|
|
822
|
+
</span>
|
|
823
|
+
<h3>Cloudflare ecosystem</h3>
|
|
824
|
+
<p>Auth, mail, storage, AI, payments — one deploy.</p>
|
|
825
|
+
</div>
|
|
826
|
+
<span class="arrow">
|
|
827
|
+
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
|
|
828
|
+
<path d="M5 12h14M13 6l6 6-6 6" />
|
|
829
|
+
</svg>
|
|
830
|
+
</span>
|
|
831
|
+
</a>
|
|
832
|
+
</div>
|
|
833
|
+
</div>
|
|
834
|
+
|
|
835
|
+
<div class="lw-foot">Running on Lunora · Vite + Svelte</div>
|
|
836
|
+
</div>
|
|
837
|
+
</div>
|
|
838
|
+
`,jt=`import "./style.css";
|
|
839
|
+
|
|
840
|
+
import { LunoraClient } from "lunorash/client";
|
|
841
|
+
|
|
842
|
+
import { api } from "#lunora/_generated/api.js";
|
|
843
|
+
|
|
844
|
+
// \`@lunora/vite\` runs the Worker on the same origin as Vite, so default to
|
|
845
|
+
// \`location.origin\`. Point \`VITE_LUNORA_URL\` at a deployed Worker to develop
|
|
846
|
+
// the client against production data.
|
|
847
|
+
const url = (import.meta.env.VITE_LUNORA_URL as string | undefined) ?? globalThis.location.origin;
|
|
848
|
+
const client = new LunoraClient({ url });
|
|
849
|
+
|
|
850
|
+
const MOON_ICON = '<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8"><path d="M21 12.8A9 9 0 1 1 11.2 3a7 7 0 0 0 9.8 9.8z" /></svg>';
|
|
851
|
+
const SUN_ICON =
|
|
852
|
+
'<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8"><circle cx="12" cy="12" r="4" /><path d="M12 2v2M12 20v2M4 12H2M22 12h-2M5 5l1.5 1.5M17.5 17.5 19 19M19 5l-1.5 1.5M6.5 17.5 5 19" /></svg>';
|
|
853
|
+
|
|
854
|
+
const welcomeHtml = \`
|
|
855
|
+
<div class="lw-bg">
|
|
856
|
+
<div class="arc a1"></div>
|
|
857
|
+
<div class="arc a2"></div>
|
|
858
|
+
<div class="glow"></div>
|
|
859
|
+
</div>
|
|
860
|
+
|
|
861
|
+
<button class="lw-toggle" type="button" aria-label="Toggle color theme"></button>
|
|
862
|
+
|
|
863
|
+
<div class="lw-wrap">
|
|
864
|
+
<div class="brand">
|
|
865
|
+
<svg viewBox="0 0 543 446" role="img" aria-label="Lunora">
|
|
866
|
+
<path d="${A}" fill="currentColor" fill-rule="evenodd" />
|
|
867
|
+
</svg>
|
|
868
|
+
<span class="word">Lunora</span>
|
|
869
|
+
</div>
|
|
870
|
+
|
|
871
|
+
<div class="grid">
|
|
872
|
+
<a class="card feature" href="https://lunora.sh/docs">
|
|
873
|
+
<div class="shot" aria-hidden="true">
|
|
874
|
+
<div class="top">
|
|
875
|
+
<span class="wm"><i></i> Lunora</span>
|
|
876
|
+
<span class="search"></span>
|
|
877
|
+
<span class="ver">v0.1</span>
|
|
878
|
+
</div>
|
|
879
|
+
<div class="body">
|
|
880
|
+
<div class="nav">
|
|
881
|
+
<i style="width: 80%"></i>
|
|
882
|
+
<i style="width: 60%"></i>
|
|
883
|
+
<i style="width: 72%"></i>
|
|
884
|
+
<i style="width: 50%"></i>
|
|
885
|
+
<i style="width: 66%"></i>
|
|
886
|
+
<i style="width: 44%"></i>
|
|
887
|
+
<i style="width: 58%"></i>
|
|
888
|
+
</div>
|
|
889
|
+
<div class="doc">
|
|
890
|
+
<span class="h"></span>
|
|
891
|
+
<i style="width: 92%"></i>
|
|
892
|
+
<i style="width: 88%"></i>
|
|
893
|
+
<span class="accent"></span>
|
|
894
|
+
<i style="width: 80%"></i>
|
|
895
|
+
<i style="width: 90%"></i>
|
|
896
|
+
<i style="width: 72%"></i>
|
|
897
|
+
<i style="width: 84%"></i>
|
|
898
|
+
<i style="width: 78%"></i>
|
|
899
|
+
</div>
|
|
900
|
+
</div>
|
|
901
|
+
</div>
|
|
902
|
+
<div class="info">
|
|
903
|
+
<span class="ic">
|
|
904
|
+
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.7">
|
|
905
|
+
<path d="M4 5a2 2 0 0 1 2-2h9l5 5v11a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2z" />
|
|
906
|
+
<path d="M14 3v5h5" />
|
|
907
|
+
</svg>
|
|
908
|
+
</span>
|
|
909
|
+
<h2>Documentation</h2>
|
|
910
|
+
<div class="row">
|
|
911
|
+
<p>
|
|
912
|
+
Schemas, queries, live subscriptions, sharding, and edge deploy — start to finish. New here or coming from Convex or tRPC,
|
|
913
|
+
you'll have a live app fast.
|
|
914
|
+
</p>
|
|
915
|
+
<span class="arrow">
|
|
916
|
+
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
|
|
917
|
+
<path d="M5 12h14M13 6l6 6-6 6" />
|
|
918
|
+
</svg>
|
|
919
|
+
</span>
|
|
920
|
+
</div>
|
|
921
|
+
</div>
|
|
922
|
+
</a>
|
|
923
|
+
|
|
924
|
+
<div class="stack">
|
|
925
|
+
<a class="card mini" href="https://lunora.sh/blog">
|
|
926
|
+
<div class="mc">
|
|
927
|
+
<span class="ic">
|
|
928
|
+
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.7">
|
|
929
|
+
<path d="M5 4h11a1 1 0 0 1 1 1v14a1 1 0 0 1-1 1H6a2 2 0 0 1-2-2V5a1 1 0 0 1 1-1zM8 8h7M8 12h7M8 16h4" />
|
|
930
|
+
</svg>
|
|
931
|
+
</span>
|
|
932
|
+
<h3>Blog</h3>
|
|
933
|
+
<p>Product updates, deep dives, and what's new in Lunora.</p>
|
|
934
|
+
</div>
|
|
935
|
+
<span class="arrow">
|
|
936
|
+
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
|
|
937
|
+
<path d="M5 12h14M13 6l6 6-6 6" />
|
|
938
|
+
</svg>
|
|
939
|
+
</span>
|
|
940
|
+
</a>
|
|
941
|
+
<a class="card mini" href="/_lunora">
|
|
942
|
+
<div class="mc">
|
|
943
|
+
<span class="ic">
|
|
944
|
+
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.7">
|
|
945
|
+
<rect x="3" y="3" width="18" height="18" rx="1" />
|
|
946
|
+
<path d="M3 9h18M9 21V9" />
|
|
947
|
+
</svg>
|
|
948
|
+
</span>
|
|
949
|
+
<h3>Lunora Studio</h3>
|
|
950
|
+
<p>Local admin for schema, data, logs, and advisors.</p>
|
|
951
|
+
</div>
|
|
952
|
+
<span class="arrow">
|
|
953
|
+
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
|
|
954
|
+
<path d="M5 12h14M13 6l6 6-6 6" />
|
|
955
|
+
</svg>
|
|
956
|
+
</span>
|
|
957
|
+
</a>
|
|
958
|
+
<a class="card mini" href="https://lunora.sh/packages">
|
|
959
|
+
<div class="mc">
|
|
960
|
+
<span class="ic">
|
|
961
|
+
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.7">
|
|
962
|
+
<path d="M12 2 3 7v10l9 5 9-5V7z" />
|
|
963
|
+
<path d="M3 7l9 5 9-5M12 12v10" />
|
|
964
|
+
</svg>
|
|
965
|
+
</span>
|
|
966
|
+
<h3>Cloudflare ecosystem</h3>
|
|
967
|
+
<p>Auth, mail, storage, AI, payments — one deploy.</p>
|
|
968
|
+
</div>
|
|
969
|
+
<span class="arrow">
|
|
970
|
+
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
|
|
971
|
+
<path d="M5 12h14M13 6l6 6-6 6" />
|
|
972
|
+
</svg>
|
|
973
|
+
</span>
|
|
974
|
+
</a>
|
|
975
|
+
</div>
|
|
976
|
+
</div>
|
|
977
|
+
|
|
978
|
+
<div class="lw-foot">Running on Lunora · Vite + Vanilla · <span id="lw-count">0</span> messages</div>
|
|
979
|
+
</div>
|
|
980
|
+
\`;
|
|
981
|
+
|
|
982
|
+
const root = document.querySelector<HTMLDivElement>("#app")!;
|
|
983
|
+
root.classList.add("lunora-welcome");
|
|
984
|
+
root.innerHTML = welcomeHtml;
|
|
985
|
+
|
|
986
|
+
// Theme toggle: flip the root's data-theme + swap the button's icon/label.
|
|
987
|
+
const toggleButton = root.querySelector<HTMLButtonElement>(".lw-toggle")!;
|
|
988
|
+
|
|
989
|
+
const paintToggle = (theme: "dark" | "light"): void => {
|
|
990
|
+
root.dataset.theme = theme;
|
|
991
|
+
toggleButton.innerHTML = \`\${theme === "light" ? MOON_ICON : SUN_ICON}<span>\${theme === "light" ? "Ivory" : "Night"}</span>\`;
|
|
386
992
|
};
|
|
387
993
|
|
|
388
|
-
|
|
389
|
-
|
|
994
|
+
paintToggle(window.matchMedia("(prefers-color-scheme: light)").matches ? "light" : "dark");
|
|
995
|
+
toggleButton.addEventListener("click", () => {
|
|
996
|
+
paintToggle(root.dataset.theme === "light" ? "dark" : "light");
|
|
997
|
+
});
|
|
998
|
+
|
|
999
|
+
// Live demo: the message count of a demo channel re-renders on every delta.
|
|
1000
|
+
const count = document.querySelector<HTMLSpanElement>("#lw-count")!;
|
|
1001
|
+
|
|
1002
|
+
client.onUpdate(api.messages.list, { channelId: "channel:demo" }, (result) => {
|
|
1003
|
+
count.textContent = String(result.messages.length);
|
|
1004
|
+
});
|
|
1005
|
+
`,R="const url = (import.meta.env.VITE_LUNORA_URL as string | undefined) ?? globalThis.location.origin;",Bt=`import "./index.css";
|
|
390
1006
|
|
|
391
1007
|
import { LunoraProvider } from "@lunora/react";
|
|
392
1008
|
import { LunoraClient } from "lunorash/client";
|
|
@@ -398,7 +1014,7 @@ import App from "./App.tsx";
|
|
|
398
1014
|
// \`@lunora/vite\` runs the Worker on the same origin as Vite, so default to
|
|
399
1015
|
// \`location.origin\`. Point \`VITE_LUNORA_URL\` at a deployed Worker to develop
|
|
400
1016
|
// the client against production data.
|
|
401
|
-
${
|
|
1017
|
+
${R}
|
|
402
1018
|
const client = new LunoraClient({ url });
|
|
403
1019
|
|
|
404
1020
|
const root = document.getElementById("root");
|
|
@@ -414,8 +1030,7 @@ createRoot(root).render(
|
|
|
414
1030
|
</LunoraProvider>
|
|
415
1031
|
</StrictMode>,
|
|
416
1032
|
);
|
|
417
|
-
|
|
418
|
-
const VUE_MAIN = `import "./style.css";
|
|
1033
|
+
`,Et=`import "./style.css";
|
|
419
1034
|
|
|
420
1035
|
import { createLunora } from "@lunora/vue";
|
|
421
1036
|
import { LunoraClient } from "lunorash/client";
|
|
@@ -424,10 +1039,9 @@ import { createApp } from "vue";
|
|
|
424
1039
|
import App from "./App.vue";
|
|
425
1040
|
|
|
426
1041
|
// Provide one LunoraClient at the app root via the Vue plugin form.
|
|
427
|
-
${
|
|
1042
|
+
${R}
|
|
428
1043
|
createApp(App).use(createLunora(new LunoraClient({ url }))).mount("#app");
|
|
429
|
-
|
|
430
|
-
const SOLID_INDEX = `import "./index.css";
|
|
1044
|
+
`,Pt=`import "./index.css";
|
|
431
1045
|
|
|
432
1046
|
import { LunoraContext } from "@lunora/solid";
|
|
433
1047
|
import { LunoraClient } from "lunorash/client";
|
|
@@ -435,7 +1049,7 @@ import { render } from "solid-js/web";
|
|
|
435
1049
|
|
|
436
1050
|
import App from "./App";
|
|
437
1051
|
|
|
438
|
-
${
|
|
1052
|
+
${R}
|
|
439
1053
|
const client = new LunoraClient({ url });
|
|
440
1054
|
const root = document.getElementById("root");
|
|
441
1055
|
|
|
@@ -447,20 +1061,18 @@ render(
|
|
|
447
1061
|
),
|
|
448
1062
|
root!,
|
|
449
1063
|
);
|
|
450
|
-
|
|
451
|
-
const SVELTE_ROOT = `<script lang="ts">
|
|
1064
|
+
`,Dt=`<script lang="ts">
|
|
452
1065
|
import { setLunoraClient } from "@lunora/svelte";
|
|
453
1066
|
import { LunoraClient } from "lunorash/client";
|
|
454
1067
|
|
|
455
1068
|
import App from "./App.svelte";
|
|
456
1069
|
|
|
457
|
-
${
|
|
1070
|
+
${R}
|
|
458
1071
|
setLunoraClient(new LunoraClient({ url }));
|
|
459
1072
|
<\/script>
|
|
460
1073
|
|
|
461
1074
|
<App />
|
|
462
|
-
|
|
463
|
-
const SVELTE_MAIN = `import "./app.css";
|
|
1075
|
+
`,zt=`import "./app.css";
|
|
464
1076
|
|
|
465
1077
|
import { mount } from "svelte";
|
|
466
1078
|
|
|
@@ -470,52 +1082,48 @@ import Root from "./Root.svelte";
|
|
|
470
1082
|
const app = mount(Root, { target: document.getElementById("app")! });
|
|
471
1083
|
|
|
472
1084
|
export default app;
|
|
473
|
-
|
|
474
|
-
|
|
1085
|
+
`,T={react:{adapter:"@lunora/react",createViteTemplate:"react-ts",files:[{contents:Bt,path:"src/main.tsx"},{contents:It,path:"src/App.tsx"},{contents:C,path:"src/index.css"}],label:"React"},solid:{adapter:"@lunora/solid",createViteTemplate:"solid-ts",files:[{contents:Pt,path:"src/index.tsx"},{contents:Tt,path:"src/App.tsx"},{contents:C,path:"src/index.css"}],label:"Solid"},svelte:{adapter:"@lunora/svelte",createViteTemplate:"svelte-ts",files:[{contents:Dt,path:"src/Root.svelte"},{contents:zt,path:"src/main.ts"},{contents:Ot,path:"src/App.svelte"},{contents:C,path:"src/app.css"}],label:"Svelte"},vanilla:{adapter:"lunorash/client",createViteTemplate:"vanilla-ts",files:[{contents:jt,path:"src/main.ts"},{contents:C,path:"src/style.css"}],label:"Vanilla"},vue:{adapter:"@lunora/vue",createViteTemplate:"vue-ts",files:[{contents:Et,path:"src/main.ts"},{contents:Rt,path:"src/App.vue"},{contents:C,path:"src/style.css"}],label:"Vue"}},z=e=>Object.hasOwn(T,e),Vt=`import type { Middleware } from "lunorash/server";
|
|
1086
|
+
import { defineSchemaExtension, defineTable, definePlugin, v } from "lunorash/server";
|
|
1087
|
+
import { createDbStore, RateLimiter } from "lunorash/ratelimit";
|
|
1088
|
+
import type { RateLimitConfigMap } from "lunorash/ratelimit";
|
|
475
1089
|
|
|
476
|
-
|
|
1090
|
+
export const limits = {
|
|
1091
|
+
default: { kind: "token bucket", period: 60_000, rate: 10 },
|
|
1092
|
+
} as const satisfies RateLimitConfigMap;
|
|
477
1093
|
|
|
478
|
-
|
|
1094
|
+
export type LimitName = keyof typeof limits;
|
|
479
1095
|
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
const root = document.querySelector<HTMLDivElement>("#app")!;
|
|
486
|
-
|
|
487
|
-
const heading = document.createElement("h1");
|
|
488
|
-
heading.textContent = "Vite + Lunora";
|
|
489
|
-
|
|
490
|
-
const output = document.createElement("pre");
|
|
491
|
-
root.replaceChildren(heading, output);
|
|
492
|
-
|
|
493
|
-
const render = (messages: unknown): void => {
|
|
494
|
-
// textContent (not innerHTML) — never inject server data as markup.
|
|
495
|
-
output.textContent = JSON.stringify(messages, null, 2);
|
|
496
|
-
};
|
|
1096
|
+
export const makeRateLimiter = (ctx: { db: unknown }): RateLimiter<LimitName> =>
|
|
1097
|
+
new RateLimiter<LimitName>({
|
|
1098
|
+
config: limits,
|
|
1099
|
+
store: createDbStore({ db: ctx.db as never, table: "ratelimit_buckets" }),
|
|
1100
|
+
});
|
|
497
1101
|
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
adapter: "@lunora/svelte",
|
|
506
|
-
createViteTemplate: "svelte-ts",
|
|
507
|
-
files: [
|
|
508
|
-
{ contents: SVELTE_ROOT, path: "src/Root.svelte" },
|
|
509
|
-
{ contents: SVELTE_MAIN, path: "src/main.ts" }
|
|
510
|
-
],
|
|
511
|
-
label: "Svelte"
|
|
512
|
-
},
|
|
513
|
-
vanilla: { adapter: "lunorash/client", createViteTemplate: "vanilla-ts", files: [{ contents: VANILLA_MAIN, path: "src/main.ts" }], label: "Vanilla" },
|
|
514
|
-
vue: { adapter: "@lunora/vue", createViteTemplate: "vue-ts", files: [{ contents: VUE_MAIN, path: "src/main.ts" }], label: "Vue" }
|
|
515
|
-
};
|
|
516
|
-
const isOverlayFramework = (value) => Object.hasOwn(ADAPTERS, value);
|
|
1102
|
+
const middleware: Middleware<{ api?: Record<string, unknown>; db: unknown }, { api: Record<string, unknown>; db: unknown }> = ({ ctx, next }) =>
|
|
1103
|
+
next({
|
|
1104
|
+
ctx: {
|
|
1105
|
+
...ctx,
|
|
1106
|
+
api: { ...ctx.api, ratelimit: makeRateLimiter(ctx) },
|
|
1107
|
+
},
|
|
1108
|
+
});
|
|
517
1109
|
|
|
518
|
-
const
|
|
1110
|
+
export const ratelimit = definePlugin("ratelimit", {
|
|
1111
|
+
extension: defineSchemaExtension("ratelimit", {
|
|
1112
|
+
tables: {
|
|
1113
|
+
buckets: defineTable({
|
|
1114
|
+
key: v.string(),
|
|
1115
|
+
value: v.number(),
|
|
1116
|
+
ts: v.number(),
|
|
1117
|
+
prev: v.optional(v.number()),
|
|
1118
|
+
})
|
|
1119
|
+
.index("by_key", ["key"])
|
|
1120
|
+
.externallyManaged(),
|
|
1121
|
+
},
|
|
1122
|
+
}),
|
|
1123
|
+
middleware,
|
|
1124
|
+
});
|
|
1125
|
+
`,Ut=`import { ratelimit } from "./ratelimit/schema.js";
|
|
1126
|
+
import { defineSchema, defineTable, v } from "lunorash/server";
|
|
519
1127
|
|
|
520
1128
|
export default defineSchema({
|
|
521
1129
|
messages: defineTable({
|
|
@@ -524,19 +1132,36 @@ export default defineSchema({
|
|
|
524
1132
|
})
|
|
525
1133
|
.shardBy("channelId")
|
|
526
1134
|
.index("by_channel", ["channelId"]),
|
|
527
|
-
});
|
|
528
|
-
|
|
529
|
-
|
|
1135
|
+
}).extend(ratelimit.extension);
|
|
1136
|
+
`,Ht=`import { RateLimiter, rateLimit, createDbStore } from "lunorash/ratelimit";
|
|
1137
|
+
|
|
1138
|
+
import { mutation, query, v } from "#lunora/_generated/server.js";
|
|
530
1139
|
|
|
531
|
-
|
|
532
|
-
|
|
1140
|
+
const limiter = (ctx: { db: unknown }) => new RateLimiter({
|
|
1141
|
+
config: {
|
|
1142
|
+
send: { kind: "token bucket", period: 60_000, rate: 30 },
|
|
1143
|
+
},
|
|
1144
|
+
store: createDbStore({ db: ctx.db as never, table: "ratelimit_buckets" }),
|
|
533
1145
|
});
|
|
534
1146
|
|
|
535
|
-
export const
|
|
536
|
-
|
|
1147
|
+
export const list = query.input({ channelId: v.string().meta({ schema: { maxLength: 256 } }), limit: v.optional(v.number()) }).query(async ({ args, ctx }) => {
|
|
1148
|
+
const messages = await ctx.db
|
|
1149
|
+
.query("messages")
|
|
1150
|
+
.withIndex("by_channel", (q) => q.eq("channelId", args.channelId))
|
|
1151
|
+
.take(args.limit ?? 50);
|
|
1152
|
+
|
|
1153
|
+
return { channelId: args.channelId, messages };
|
|
537
1154
|
});
|
|
538
|
-
|
|
539
|
-
const
|
|
1155
|
+
|
|
1156
|
+
export const send = mutation
|
|
1157
|
+
.input({ channelId: v.string().meta({ schema: { maxLength: 256 } }), text: v.string().meta({ schema: { maxLength: 4096 } }) })
|
|
1158
|
+
.use(rateLimit(limiter, "send", { key: (ctx) => ctx.auth.userId ?? "anon" }))
|
|
1159
|
+
.mutation(async ({ args, ctx }) => {
|
|
1160
|
+
const id = await ctx.db.insert("messages", { channelId: args.channelId, text: args.text });
|
|
1161
|
+
|
|
1162
|
+
return { channelId: args.channelId, id, text: args.text };
|
|
1163
|
+
});
|
|
1164
|
+
`,Wt=`import type { ShardNamespaceLike } from "lunorash/runtime";
|
|
540
1165
|
|
|
541
1166
|
import { defineApp } from "../lunora/_generated/app.js";
|
|
542
1167
|
|
|
@@ -550,8 +1175,7 @@ const app = defineApp<Env>()
|
|
|
550
1175
|
|
|
551
1176
|
export const ShardDO = app.ShardDO;
|
|
552
1177
|
export default app;
|
|
553
|
-
|
|
554
|
-
const WRANGLER = `{
|
|
1178
|
+
`,qt=`{
|
|
555
1179
|
"$schema": "node_modules/wrangler/config-schema.json",
|
|
556
1180
|
"name": "__NAME__",
|
|
557
1181
|
"main": "src/server.ts",
|
|
@@ -563,200 +1187,23 @@ const WRANGLER = `{
|
|
|
563
1187
|
"migrations": [{ "tag": "v1", "new_sqlite_classes": ["ShardDO"] }],
|
|
564
1188
|
"observability": { "enabled": true, "head_sampling_rate": 1 },
|
|
565
1189
|
}
|
|
566
|
-
|
|
567
|
-
const GITIGNORE_ADDITIONS = [".wrangler", ".env", ".env.*", "!.env.example", ".lunora/", ".lunora-cache", "lunora/_generated"];
|
|
568
|
-
const ENV_EXAMPLE = `# Lunora endpoint for the browser client.
|
|
1190
|
+
`,Ft=[".wrangler",".env",".env.*","!.env.example",".lunora/",".lunora-cache","lunora/_generated"],Kt=`# Lunora endpoint for the browser client.
|
|
569
1191
|
# Vite statically replaces \`import.meta.env.VITE_LUNORA_URL\` at \`vite dev\` / build.
|
|
570
1192
|
# Leave it unset to use the page origin; set it to point at a deployed Worker:
|
|
571
1193
|
#
|
|
572
1194
|
# VITE_LUNORA_URL=https://my-app.example.workers.dev
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
wrangler: "^4.100.0"
|
|
577
|
-
};
|
|
578
|
-
const writeFile = (target, relativePath, contents, written) => {
|
|
579
|
-
const destination = join$1(target, relativePath);
|
|
580
|
-
mkdirSync(dirname$1(destination), { recursive: true });
|
|
581
|
-
writeFileSync(destination, contents, "utf8");
|
|
582
|
-
written.push(destination);
|
|
583
|
-
};
|
|
584
|
-
const NEWLINE = /\r?\n/;
|
|
585
|
-
const ensureGitignore = (target) => {
|
|
586
|
-
const path = join$1(target, ".gitignore");
|
|
587
|
-
const existing = existsSync(path) ? readFileSync(path, "utf8") : "";
|
|
588
|
-
const missing = GITIGNORE_ADDITIONS.filter((entry) => !existing.split(NEWLINE).includes(entry));
|
|
589
|
-
if (missing.length === 0) {
|
|
590
|
-
return;
|
|
591
|
-
}
|
|
592
|
-
const prefix = existing.length > 0 && !existing.endsWith("\n") ? "\n" : "";
|
|
593
|
-
writeFileSync(path, `${existing}${prefix}
|
|
1195
|
+
`,Jt={"@cloudflare/workers-types":"^4.20260611.1",wrangler:"^4.100.0"},b=(e,t,a,r)=>{const o=p(e,t);L($(o),{recursive:!0}),m(o,a,"utf8"),r.push(o)},Qt=/\r?\n/,Gt=e=>{const t=p(e,".gitignore"),a=h(t)?k(t,"utf8"):"",r=Ft.filter(s=>!a.split(Qt).includes(s));if(r.length===0)return;const o=a.length>0&&!a.endsWith(`
|
|
1196
|
+
`)?`
|
|
1197
|
+
`:"";m(t,`${a}${o}
|
|
594
1198
|
# Lunora
|
|
595
|
-
${
|
|
596
|
-
|
|
597
|
-
};
|
|
598
|
-
const
|
|
599
|
-
const withDependency = (map, name, range, distTag) => {
|
|
600
|
-
return { ...map, [name]: stampRange(name, range, distTag) };
|
|
601
|
-
};
|
|
602
|
-
const restampLunora = (map, distTag) => Object.fromEntries(Object.entries(map).map(([name, range]) => [name, stampRange(name, range, distTag)]));
|
|
603
|
-
const patchPackageJson = (target, name, adapter, distTag) => {
|
|
604
|
-
const path = join$1(target, "package.json");
|
|
605
|
-
const parsed = JSON.parse(readFileSync(path, "utf8"));
|
|
606
|
-
let dependencies = withDependency(parsed.dependencies ?? {}, "lunorash", distTag, distTag);
|
|
607
|
-
if (adapter.adapter.startsWith("@lunora/")) {
|
|
608
|
-
dependencies = withDependency(dependencies, adapter.adapter, distTag, distTag);
|
|
609
|
-
}
|
|
610
|
-
for (const [depName, range] of Object.entries(adapter.extraDependencies ?? {})) {
|
|
611
|
-
dependencies = withDependency(dependencies, depName, range, distTag);
|
|
612
|
-
}
|
|
613
|
-
let devDependencies = withDependency(parsed.devDependencies ?? {}, "@lunora/vite", distTag, distTag);
|
|
614
|
-
for (const [depName, range] of Object.entries(COMMON_DEV_DEPENDENCIES)) {
|
|
615
|
-
devDependencies = withDependency(devDependencies, depName, range, distTag);
|
|
616
|
-
}
|
|
617
|
-
parsed.name = name;
|
|
618
|
-
parsed.dependencies = restampLunora(dependencies, distTag);
|
|
619
|
-
parsed.devDependencies = restampLunora(devDependencies, distTag);
|
|
620
|
-
parsed.scripts = { ...parsed.scripts, codegen: "lunora codegen", deploy: "vite build && lunora deploy" };
|
|
621
|
-
writeFileSync(path, `${JSON.stringify(parsed, void 0, 4)}
|
|
622
|
-
`, "utf8");
|
|
623
|
-
};
|
|
624
|
-
const patchBaseViteConfig = (target, logger) => {
|
|
625
|
-
const candidate = ["vite.config.ts", "vite.config.mts", "vite.config.js", "vite.config.mjs"].map((file) => join$1(target, file)).find((path) => existsSync(path));
|
|
626
|
-
if (candidate === void 0) {
|
|
627
|
-
logger.warn("overlay: no vite.config found in the create-vite base — add `lunora()` to your Vite plugins manually.");
|
|
628
|
-
return;
|
|
629
|
-
}
|
|
630
|
-
const result = patchViteConfig(readFileSync(candidate, "utf8"));
|
|
631
|
-
if (result.changed) {
|
|
632
|
-
writeFileSync(candidate, result.code, "utf8");
|
|
633
|
-
}
|
|
634
|
-
};
|
|
635
|
-
const applyLunoraOverlay = (options) => {
|
|
636
|
-
const { adapter, distTag, logger, name, target } = options;
|
|
637
|
-
const written = [];
|
|
638
|
-
writeFile(target, join$1("lunora", "schema.ts"), LUNORA_SCHEMA, written);
|
|
639
|
-
writeFile(target, join$1("lunora", "messages.ts"), LUNORA_MESSAGES, written);
|
|
640
|
-
writeFile(target, join$1("src", "server.ts"), SERVER_ENTRY, written);
|
|
641
|
-
writeFile(target, "wrangler.jsonc", WRANGLER.replaceAll("__NAME__", name), written);
|
|
642
|
-
writeFile(target, ".env.example", ENV_EXAMPLE, written);
|
|
643
|
-
for (const file of adapter.files) {
|
|
644
|
-
writeFile(target, file.path, file.contents, written);
|
|
645
|
-
}
|
|
646
|
-
patchBaseViteConfig(target, logger);
|
|
647
|
-
patchPackageJson(target, name, adapter, distTag);
|
|
648
|
-
ensureGitignore(target);
|
|
649
|
-
return written;
|
|
650
|
-
};
|
|
651
|
-
|
|
652
|
-
const ADJECTIVES = [
|
|
653
|
-
"lunar",
|
|
654
|
-
"silver",
|
|
655
|
-
"silent",
|
|
656
|
-
"waning",
|
|
657
|
-
"waxing",
|
|
658
|
-
"crescent",
|
|
659
|
-
"cosmic",
|
|
660
|
-
"stellar",
|
|
661
|
-
"orbital",
|
|
662
|
-
"gibbous",
|
|
663
|
-
"twilight",
|
|
664
|
-
"midnight",
|
|
665
|
-
"shimmering",
|
|
666
|
-
"drifting",
|
|
667
|
-
"weightless"
|
|
668
|
-
];
|
|
669
|
-
const NOUNS = [
|
|
670
|
-
"moon",
|
|
671
|
-
"tide",
|
|
672
|
-
"crater",
|
|
673
|
-
"comet",
|
|
674
|
-
"eclipse",
|
|
675
|
-
"halo",
|
|
676
|
-
"orbit",
|
|
677
|
-
"nebula",
|
|
678
|
-
"voyager",
|
|
679
|
-
"lander",
|
|
680
|
-
"rover",
|
|
681
|
-
"beacon",
|
|
682
|
-
"harbor",
|
|
683
|
-
"meadow",
|
|
684
|
-
"fox"
|
|
685
|
-
];
|
|
686
|
-
const pick = (items) => (
|
|
687
|
-
// eslint-disable-next-line sonarjs/pseudo-random -- cosmetic default project name, not a security decision.
|
|
688
|
-
items[Math.floor(Math.random() * items.length)]
|
|
689
|
-
);
|
|
690
|
-
const generateProjectName = () => `${pick(ADJECTIVES)}-${pick(NOUNS)}`;
|
|
691
|
-
|
|
692
|
-
const isOnline = async () => dns.lookup("github.com").then(
|
|
693
|
-
() => true,
|
|
694
|
-
() => false
|
|
695
|
-
);
|
|
696
|
-
const GITHUB_SOURCE = /^(?:gh|github):([^/]+)\/([^#/]+)(?:\/[^#]*)?(?:#(.+))?$/;
|
|
697
|
-
const parseGitHubSource = (source) => {
|
|
698
|
-
const match = GITHUB_SOURCE.exec(source);
|
|
699
|
-
if (match === null) {
|
|
700
|
-
return void 0;
|
|
701
|
-
}
|
|
702
|
-
const [, owner, repo, ref] = match;
|
|
703
|
-
if (owner === void 0 || repo === void 0) {
|
|
704
|
-
return void 0;
|
|
705
|
-
}
|
|
706
|
-
return { owner, ref: ref ?? "HEAD", repo };
|
|
707
|
-
};
|
|
708
|
-
const templateRefExists = async (source) => {
|
|
709
|
-
const parsed = parseGitHubSource(source);
|
|
710
|
-
if (parsed === void 0) {
|
|
711
|
-
return void 0;
|
|
712
|
-
}
|
|
713
|
-
const url = `https://codeload.github.com/${parsed.owner}/${parsed.repo}/tar.gz/${parsed.ref}`;
|
|
714
|
-
try {
|
|
715
|
-
const response = await fetch(url, { method: "HEAD" });
|
|
716
|
-
if (response.status === 404) {
|
|
717
|
-
return false;
|
|
718
|
-
}
|
|
719
|
-
return response.ok ? true : void 0;
|
|
720
|
-
} catch {
|
|
721
|
-
return void 0;
|
|
722
|
-
}
|
|
723
|
-
};
|
|
724
|
-
const verifyRemoteTemplate = async (params) => {
|
|
725
|
-
if (params.isLocal) {
|
|
726
|
-
return true;
|
|
727
|
-
}
|
|
728
|
-
const isGitHubBacked = params.source === void 0 || parseGitHubSource(params.source) !== void 0;
|
|
729
|
-
if (!isGitHubBacked) {
|
|
730
|
-
return true;
|
|
731
|
-
}
|
|
732
|
-
if (!await isOnline()) {
|
|
733
|
-
params.logger.error("you appear to be offline — connect to the internet and try again, or scaffold from a local template with `--from <dir>`.");
|
|
734
|
-
return false;
|
|
735
|
-
}
|
|
736
|
-
if (params.source !== void 0 && await templateRefExists(params.source) === false) {
|
|
737
|
-
params.logger.error(`template source not found: ${params.source} — double-check --ref / --source, or browse the templates at https://lunora.sh/docs.`);
|
|
738
|
-
return false;
|
|
739
|
-
}
|
|
740
|
-
return true;
|
|
741
|
-
};
|
|
742
|
-
|
|
743
|
-
const COPY = {
|
|
744
|
-
extras: "Let's finish setting up your app.",
|
|
745
|
-
framework: "Which framework should we launch?",
|
|
746
|
-
git: "Initialize a new git repository? (optional)",
|
|
747
|
-
install: "Install dependencies now?",
|
|
748
|
-
name: "Where should we land your project?",
|
|
749
|
-
nextHeader: "Liftoff confirmed — explore your project!",
|
|
750
|
-
packageManager: "Which package manager?"
|
|
751
|
-
};
|
|
752
|
-
const TEXT_EXTENSIONS = /* @__PURE__ */ new Set([".gitignore", ".html", ".js", ".json", ".jsonc", ".md", ".mjs", ".ts", ".tsx"]);
|
|
753
|
-
const VITE_CONFIG_CANDIDATES = ["vite.config.ts", "vite.config.mts", "vite.config.js", "vite.config.mjs"];
|
|
754
|
-
const MINIMAL_VITE_CONFIG = `import { defineConfig } from "vite";
|
|
1199
|
+
${r.join(`
|
|
1200
|
+
`)}
|
|
1201
|
+
`,"utf8")},ge=e=>e==="lunorash"||e.startsWith("@lunora/"),ve=(e,t,a,r)=>ge(e)?r?.get(e)??a:t,x=(e,t,a,r)=>({...e,[t]:ve(t,a,r)}),Q=(e,t,a)=>Object.fromEntries(Object.entries(e).map(([r,o])=>[r,ve(r,o,t,a)])),Xt=async(e,t,a,r)=>{const o=p(e,"package.json"),s=JSON.parse(k(o,"utf8"));let i=x(s.dependencies??{},"lunorash",r,r);i=x(i,"@lunora/ratelimit",r,r),a.adapter.startsWith("@lunora/")&&(i=x(i,a.adapter,r,r));for(const[u,l]of Object.entries(a.extraDependencies??{}))i=x(i,u,l,r);let n=x(s.devDependencies??{},"@lunora/vite",r,r);n=x(n,"@lunora/studio",r,r);for(const[u,l]of Object.entries(Jt))n=x(n,u,l,r);const c=[...Object.keys(i),...Object.keys(n)].filter(u=>ge(u)),d=await re(c,r);s.name=t,s.imports={...s.imports,"#lunora/*":"./lunora/*"},s.dependencies=Q(i,r,d),s.devDependencies=Q(n,r,d),s.scripts={...s.scripts,codegen:"lunora codegen",deploy:"vite build && lunora deploy"},m(o,`${JSON.stringify(s,void 0,4)}
|
|
1202
|
+
`,"utf8")},Yt=(e,t)=>{const a=["vite.config.ts","vite.config.mts","vite.config.js","vite.config.mjs"].map(o=>p(e,o)).find(o=>h(o));if(a===void 0){t.warn("overlay: no vite.config found in the create-vite base — add `lunora()` to your Vite plugins manually.");return}const r=he(k(a,"utf8"));r.changed&&m(a,r.code,"utf8")},Zt=async e=>{const{adapter:t,distTag:a,logger:r,name:o,target:s}=e,i=[];b(s,p("lunora","ratelimit","schema.ts"),Vt,i),b(s,p("lunora","schema.ts"),Ut,i),b(s,p("lunora","messages.ts"),Ht,i),b(s,p("src","server.ts"),Wt,i),b(s,"wrangler.jsonc",qt.replaceAll("__NAME__",o),i),b(s,".env.example",Kt,i);for(const n of t.files)b(s,n.path,n.contents,i);return Yt(s,r),await Xt(s,o,t,a),Gt(s),i},ea=["lunar","silver","silent","waning","waxing","crescent","cosmic","stellar","orbital","gibbous","twilight","midnight","shimmering","drifting","weightless"],ta=["moon","tide","crater","comet","eclipse","halo","orbit","nebula","voyager","lander","rover","beacon","harbor","meadow","fox"],G=e=>e[Math.floor(Math.random()*e.length)],aa=()=>`${G(ea)}-${G(ta)}`,ra=async()=>ot.lookup("github.com").then(()=>!0,()=>!1),oa=/^(?:gh|github):([^/]+)\/([^#/]+)(?:\/[^#]*)?(?:#(.+))?$/,fe=e=>{const t=oa.exec(e);if(t===null)return;const[,a,r,o]=t;if(!(a===void 0||r===void 0))return{owner:a,ref:o??"HEAD",repo:r}},sa=async e=>{const t=fe(e);if(t===void 0)return;const a=`https://codeload.github.com/${t.owner}/${t.repo}/tar.gz/${t.ref}`;try{const r=await fetch(a,{method:"HEAD"});return r.status===404?!1:r.ok?!0:void 0}catch{return}},we=async e=>e.isLocal||!(e.source===void 0||fe(e.source)!==void 0)?!0:await ra()?e.source!==void 0&&await sa(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),y={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?"},ia=new Set([".gitignore",".html",".js",".json",".jsonc",".md",".mjs",".ts",".tsx"]),na=["vite.config.ts","vite.config.mts","vite.config.js","vite.config.mjs"],la=`import { defineConfig } from "vite";
|
|
755
1203
|
import { lunora } from "@lunora/vite";
|
|
756
1204
|
|
|
757
1205
|
export default defineConfig({ plugins: [lunora()] });
|
|
758
|
-
|
|
759
|
-
const SAMPLE_SCHEMA = `import { defineSchema, defineTable, v } from "@lunora/server";
|
|
1206
|
+
`,ca=`import { defineSchema, defineTable, v } from "@lunora/server";
|
|
760
1207
|
|
|
761
1208
|
export default defineSchema({
|
|
762
1209
|
messages: defineTable({
|
|
@@ -766,8 +1213,7 @@ export default defineSchema({
|
|
|
766
1213
|
.shardBy("channelId")
|
|
767
1214
|
.index("by_channel", ["channelId"]),
|
|
768
1215
|
});
|
|
769
|
-
|
|
770
|
-
const SAMPLE_FUNCTION = `import { mutation, query, v } from "./_generated/server";
|
|
1216
|
+
`,da=`import { mutation, query, v } from "./_generated/server";
|
|
771
1217
|
|
|
772
1218
|
export const list = query
|
|
773
1219
|
.input({ channelId: v.id("channels"), limit: v.optional(v.number()) })
|
|
@@ -780,723 +1226,8 @@ export const send = mutation
|
|
|
780
1226
|
.mutation(async ({ args }) => {
|
|
781
1227
|
return { channelId: args.channelId, text: args.text };
|
|
782
1228
|
});
|
|
783
|
-
|
|
784
|
-
const
|
|
785
|
-
const
|
|
786
|
-
|
|
787
|
-
if (lastDot === -1) {
|
|
788
|
-
return false;
|
|
789
|
-
}
|
|
790
|
-
return TEXT_EXTENSIONS.has(filePath.slice(lastDot));
|
|
791
|
-
};
|
|
792
|
-
const substitute = (content, name) => content.replaceAll("{{name}}", name);
|
|
793
|
-
const isLunoraDep = (name) => name === "lunorash" || name.startsWith("@lunora/");
|
|
794
|
-
const stampLunoraDeps = (packageJsonText, distTag) => {
|
|
795
|
-
let parsed;
|
|
796
|
-
try {
|
|
797
|
-
parsed = JSON.parse(packageJsonText);
|
|
798
|
-
} catch {
|
|
799
|
-
return packageJsonText;
|
|
800
|
-
}
|
|
801
|
-
let text = packageJsonText;
|
|
802
|
-
for (const section of ["dependencies", "devDependencies"]) {
|
|
803
|
-
for (const name of Object.keys(parsed[section] ?? {})) {
|
|
804
|
-
if (!isLunoraDep(name)) {
|
|
805
|
-
continue;
|
|
806
|
-
}
|
|
807
|
-
const edits = modify(text, [section, name], distTag, { formattingOptions: { insertSpaces: true, tabSize: 4 } });
|
|
808
|
-
text = applyEdits(text, edits);
|
|
809
|
-
}
|
|
810
|
-
}
|
|
811
|
-
return text;
|
|
812
|
-
};
|
|
813
|
-
const collectFiles = (directory) => {
|
|
814
|
-
const out = [];
|
|
815
|
-
for (const entry of walkSync(directory, { includeDirs: false, includeFiles: true })) {
|
|
816
|
-
out.push(entry.path);
|
|
817
|
-
}
|
|
818
|
-
return out;
|
|
819
|
-
};
|
|
820
|
-
const copyTemplate = (sourceDirectory, target, name) => {
|
|
821
|
-
const files = collectFiles(sourceDirectory);
|
|
822
|
-
const written = [];
|
|
823
|
-
const distTag = resolveDistTag();
|
|
824
|
-
for (const source of files) {
|
|
825
|
-
const relativePath = relative(sourceDirectory, source);
|
|
826
|
-
const destination = join$1(target, relativePath);
|
|
827
|
-
mkdirSync(dirname$1(destination), { recursive: true });
|
|
828
|
-
const raw = readFileSync(source);
|
|
829
|
-
let text = isTextFile(source) ? substitute(raw.toString("utf8"), name) : void 0;
|
|
830
|
-
if (text !== void 0 && basename(source) === "package.json") {
|
|
831
|
-
text = stampLunoraDeps(text, distTag);
|
|
832
|
-
}
|
|
833
|
-
if (text === void 0) {
|
|
834
|
-
writeFileSync(destination, raw);
|
|
835
|
-
} else {
|
|
836
|
-
writeFileSync(destination, text, "utf8");
|
|
837
|
-
}
|
|
838
|
-
written.push(destination);
|
|
839
|
-
}
|
|
840
|
-
return written;
|
|
841
|
-
};
|
|
842
|
-
const resolveTemplateSource = (templateType, source, ref) => {
|
|
843
|
-
if (source !== void 0 && source.length > 0) {
|
|
844
|
-
return source;
|
|
845
|
-
}
|
|
846
|
-
return `${DEFAULT_SOURCE_BASE}/${templateType}#${resolveSourceRef(ref)}`;
|
|
847
|
-
};
|
|
848
|
-
const isSafeSource = (source) => {
|
|
849
|
-
if (source.includes("..")) {
|
|
850
|
-
return false;
|
|
851
|
-
}
|
|
852
|
-
return source.startsWith("gh:") || source.startsWith("github:") || source.startsWith("https://");
|
|
853
|
-
};
|
|
854
|
-
const logWould = (logger, action) => {
|
|
855
|
-
logger.info(`[dry-run] would ${action}`);
|
|
856
|
-
};
|
|
857
|
-
const logScaffoldSuccess = (logger, written, target) => {
|
|
858
|
-
if (isInteractive()) {
|
|
859
|
-
process.stdout.write("\n");
|
|
860
|
-
}
|
|
861
|
-
logger.success(`scaffolded ${String(written.length)} files into ${target}`);
|
|
862
|
-
};
|
|
863
|
-
const runScriptCommand = (manager, script) => {
|
|
864
|
-
if (manager === "npm") {
|
|
865
|
-
return `npm run ${script}`;
|
|
866
|
-
}
|
|
867
|
-
if (manager === "bun") {
|
|
868
|
-
return `bun run ${script}`;
|
|
869
|
-
}
|
|
870
|
-
return `${manager} ${script}`;
|
|
871
|
-
};
|
|
872
|
-
const isInsideMonorepo = (startDirectory) => {
|
|
873
|
-
let directory = resolve(startDirectory);
|
|
874
|
-
for (; ; ) {
|
|
875
|
-
if (existsSync(join$1(directory, "pnpm-workspace.yaml"))) {
|
|
876
|
-
return true;
|
|
877
|
-
}
|
|
878
|
-
const packagePath = join$1(directory, "package.json");
|
|
879
|
-
if (existsSync(packagePath)) {
|
|
880
|
-
try {
|
|
881
|
-
const parsed = JSON.parse(readFileSync(packagePath, "utf8"));
|
|
882
|
-
if (parsed.workspaces !== void 0) {
|
|
883
|
-
return true;
|
|
884
|
-
}
|
|
885
|
-
} catch {
|
|
886
|
-
}
|
|
887
|
-
}
|
|
888
|
-
const parent = dirname$1(directory);
|
|
889
|
-
if (parent === directory) {
|
|
890
|
-
return false;
|
|
891
|
-
}
|
|
892
|
-
directory = parent;
|
|
893
|
-
}
|
|
894
|
-
};
|
|
895
|
-
const isInsideGitRepo = (startDirectory) => {
|
|
896
|
-
let directory = resolve(startDirectory);
|
|
897
|
-
for (; ; ) {
|
|
898
|
-
if (existsSync(join$1(directory, ".git"))) {
|
|
899
|
-
return true;
|
|
900
|
-
}
|
|
901
|
-
const parent = dirname$1(directory);
|
|
902
|
-
if (parent === directory) {
|
|
903
|
-
return false;
|
|
904
|
-
}
|
|
905
|
-
directory = parent;
|
|
906
|
-
}
|
|
907
|
-
};
|
|
908
|
-
const maybeOfferGit = async (options, target) => {
|
|
909
|
-
if (options.yes === true || !isInteractive() || isInsideGitRepo(dirname$1(target))) {
|
|
910
|
-
return;
|
|
911
|
-
}
|
|
912
|
-
if (!await tuiConfirm(COPY.git, { badge: BADGES.git, defaultYes: false })) {
|
|
913
|
-
await tuiInfo("Sounds good! You can always run git init manually.");
|
|
914
|
-
return;
|
|
915
|
-
}
|
|
916
|
-
if (options.dryRun === true) {
|
|
917
|
-
logWould(options.logger, "initialize a git repository");
|
|
918
|
-
return;
|
|
919
|
-
}
|
|
920
|
-
const spawner = options.spawner ?? defaultSpawner;
|
|
921
|
-
const result = await withTuiSpinner("Initializing a git repository…", () => spawner({ args: ["init"], command: "git", cwd: target }));
|
|
922
|
-
if (result.code === 0) {
|
|
923
|
-
await emitStep("git", "Initialized an empty git repository.");
|
|
924
|
-
} else {
|
|
925
|
-
options.logger.warn("`git init` failed — initialize it yourself later with `git init`.");
|
|
926
|
-
}
|
|
927
|
-
};
|
|
928
|
-
const printNextSteps = async (name, installed, insideMonorepo) => {
|
|
929
|
-
const manager = installed ?? "pnpm";
|
|
930
|
-
const steps = [{ code: `cd ./${name}`, lead: "Enter your project directory using" }];
|
|
931
|
-
if (installed === void 0) {
|
|
932
|
-
steps.push({ code: `${manager} install`, lead: "Install dependencies with", tail: insideMonorepo ? " from the workspace root" : void 0 });
|
|
933
|
-
}
|
|
934
|
-
steps.push(
|
|
935
|
-
{ code: runScriptCommand(manager, "dev"), lead: "Run", tail: " to start the dev server." },
|
|
936
|
-
{ code: "lunora add", lead: "Add features like auth or storage using" }
|
|
937
|
-
);
|
|
938
|
-
const help = [
|
|
939
|
-
{ code: "https://lunora.sh/docs", lead: "Read the docs at" },
|
|
940
|
-
{ code: "https://lunora.sh/chat", lead: "Stuck? Join the chat at" }
|
|
941
|
-
];
|
|
942
|
-
if (isInteractive()) {
|
|
943
|
-
await tuiNextSteps(BADGES.next, COPY.nextHeader, steps, help);
|
|
944
|
-
return;
|
|
945
|
-
}
|
|
946
|
-
const lines = steps.map((step) => `${step.lead} ${step.code}${step.tail ?? ""}`);
|
|
947
|
-
lines.push("", ...help.map((line) => `${line.lead} ${line.code}${line.tail ?? ""}`));
|
|
948
|
-
await emitStep("next", COPY.nextHeader, lines.join("\n"));
|
|
949
|
-
};
|
|
950
|
-
const offerInstallIsInteractive = (options) => options.yes !== true && (options.installPrompt !== void 0 || isInteractive());
|
|
951
|
-
const maybeOfferInstall = async (options, target) => {
|
|
952
|
-
if (!offerInstallIsInteractive(options)) {
|
|
953
|
-
return void 0;
|
|
954
|
-
}
|
|
955
|
-
if (isInsideMonorepo(dirname$1(target))) {
|
|
956
|
-
return void 0;
|
|
957
|
-
}
|
|
958
|
-
const managers = detectInstalledManagers(options.packageManagerProbe);
|
|
959
|
-
const [defaultManager] = managers;
|
|
960
|
-
if (defaultManager === void 0) {
|
|
961
|
-
return void 0;
|
|
962
|
-
}
|
|
963
|
-
const confirm = options.installPrompt?.confirmInstall ?? (async () => tuiConfirm(COPY.install, { badge: BADGES.deps, defaultYes: true }));
|
|
964
|
-
if (!await confirm()) {
|
|
965
|
-
await tuiInfo("No problem! Remember to install dependencies after setup.");
|
|
966
|
-
return void 0;
|
|
967
|
-
}
|
|
968
|
-
let manager = defaultManager;
|
|
969
|
-
if (managers.length > 1) {
|
|
970
|
-
manager = options.installPrompt ? await options.installPrompt.selectManager(managers) : await tuiSelect(
|
|
971
|
-
COPY.packageManager,
|
|
972
|
-
managers.map((candidate) => {
|
|
973
|
-
return { label: candidate, value: candidate };
|
|
974
|
-
}),
|
|
975
|
-
{ badge: BADGES.deps, default: defaultManager }
|
|
976
|
-
) ?? defaultManager;
|
|
977
|
-
}
|
|
978
|
-
if (options.dryRun === true) {
|
|
979
|
-
logWould(options.logger, `install dependencies with ${manager}`);
|
|
980
|
-
return void 0;
|
|
981
|
-
}
|
|
982
|
-
const spawner = options.spawner ?? defaultSpawner;
|
|
983
|
-
const { args, command } = installArgsFor(manager);
|
|
984
|
-
const result = await withTuiSpinner(`Installing dependencies with ${manager}…`, () => spawner({ args, command, cwd: target }));
|
|
985
|
-
if (result.code !== 0) {
|
|
986
|
-
options.logger.warn(`\`${command} install\` exited with code ${String(result.code)} — run it yourself in ${basename(target)}/.`);
|
|
987
|
-
return void 0;
|
|
988
|
-
}
|
|
989
|
-
await emitStep("deps", `Dependencies installed with ${manager}.`);
|
|
990
|
-
return manager;
|
|
991
|
-
};
|
|
992
|
-
const scaffoldFromLocal = (fromRoot, templateType, target, name, logger) => {
|
|
993
|
-
const templateDirectory = join$1(fromRoot, templateType);
|
|
994
|
-
if (!existsSync(templateDirectory)) {
|
|
995
|
-
logger.error(`template not found in local source: ${templateDirectory}`);
|
|
996
|
-
return { code: 1, files: [], target };
|
|
997
|
-
}
|
|
998
|
-
const written = copyTemplate(templateDirectory, target, name);
|
|
999
|
-
logScaffoldSuccess(logger, written, target);
|
|
1000
|
-
return { code: 0, files: written, target };
|
|
1001
|
-
};
|
|
1002
|
-
const scaffoldFromRemote = async (options) => {
|
|
1003
|
-
const { logger, name, ref, source, target, templateType } = options;
|
|
1004
|
-
const stagingRoot = mkdtempSync(join$1(tmpdir(), "lunora-init-fetch-"));
|
|
1005
|
-
const stagingDirectory = join$1(stagingRoot, "template");
|
|
1006
|
-
try {
|
|
1007
|
-
const remote = resolveTemplateSource(templateType, source, ref);
|
|
1008
|
-
let downloaded;
|
|
1009
|
-
let written = [];
|
|
1010
|
-
await tuiTasks(
|
|
1011
|
-
[
|
|
1012
|
-
{
|
|
1013
|
-
label: `${templateType} template fetched`,
|
|
1014
|
-
run: async () => {
|
|
1015
|
-
downloaded = await downloadTemplate(remote, {
|
|
1016
|
-
cwd: stagingRoot,
|
|
1017
|
-
dir: stagingDirectory,
|
|
1018
|
-
force: true,
|
|
1019
|
-
install: false,
|
|
1020
|
-
silent: true
|
|
1021
|
-
});
|
|
1022
|
-
}
|
|
1023
|
-
},
|
|
1024
|
-
{
|
|
1025
|
-
label: `files copied into ${name}/`,
|
|
1026
|
-
run: () => {
|
|
1027
|
-
written = copyTemplate(stagingDirectory, target, name);
|
|
1028
|
-
return Promise.resolve();
|
|
1029
|
-
}
|
|
1030
|
-
}
|
|
1031
|
-
],
|
|
1032
|
-
{ end: "Project initialized!", start: "Project initializing…" }
|
|
1033
|
-
);
|
|
1034
|
-
const staged = collectFiles(stagingDirectory);
|
|
1035
|
-
if (isInteractive()) {
|
|
1036
|
-
process.stdout.write("\n");
|
|
1037
|
-
}
|
|
1038
|
-
logger.info(
|
|
1039
|
-
downloaded?.commit ? `template: ${downloaded.source} @ ${downloaded.commit} (${String(staged.length)} files)` : `template: ${downloaded?.source ?? remote} (${String(staged.length)} files)`
|
|
1040
|
-
);
|
|
1041
|
-
logScaffoldSuccess(logger, written, target);
|
|
1042
|
-
return { code: 0, files: written, target };
|
|
1043
|
-
} catch (error) {
|
|
1044
|
-
if (error instanceof PromptCancelledError) {
|
|
1045
|
-
throw error;
|
|
1046
|
-
}
|
|
1047
|
-
const message = error instanceof Error ? error.message : String(error);
|
|
1048
|
-
logger.error(`failed to download template: ${message}`);
|
|
1049
|
-
return { code: 1, files: [], target };
|
|
1050
|
-
} finally {
|
|
1051
|
-
rmSync(stagingRoot, { force: true, recursive: true });
|
|
1052
|
-
}
|
|
1053
|
-
};
|
|
1054
|
-
const renameCreateViteDotfiles = (directory) => {
|
|
1055
|
-
for (const file of ["_gitignore", "_npmrc", "_gitattributes"]) {
|
|
1056
|
-
const from = join$1(directory, file);
|
|
1057
|
-
if (existsSync(from)) {
|
|
1058
|
-
renameSync(from, join$1(directory, `.${file.slice(1)}`));
|
|
1059
|
-
}
|
|
1060
|
-
}
|
|
1061
|
-
};
|
|
1062
|
-
const scaffoldViteOverlay = async (options) => {
|
|
1063
|
-
const { framework, logger, name, overlayBaseFrom, target } = options;
|
|
1064
|
-
const adapter = ADAPTERS[framework];
|
|
1065
|
-
const stagingRoot = mkdtempSync(join$1(tmpdir(), "lunora-vite-base-"));
|
|
1066
|
-
try {
|
|
1067
|
-
let localBase;
|
|
1068
|
-
if (overlayBaseFrom !== void 0) {
|
|
1069
|
-
localBase = join$1(overlayBaseFrom, `template-${adapter.createViteTemplate}`);
|
|
1070
|
-
if (!existsSync(localBase)) {
|
|
1071
|
-
logger.error(`create-vite base not found on disk: ${localBase}`);
|
|
1072
|
-
return { code: 1, files: [], target };
|
|
1073
|
-
}
|
|
1074
|
-
}
|
|
1075
|
-
const copyBase = async () => {
|
|
1076
|
-
if (localBase !== void 0) {
|
|
1077
|
-
cpSync(localBase, target, { recursive: true });
|
|
1078
|
-
return;
|
|
1079
|
-
}
|
|
1080
|
-
const stagingDirectory = join$1(stagingRoot, "base");
|
|
1081
|
-
const remote = `github:vitejs/vite/packages/create-vite/template-${adapter.createViteTemplate}#main`;
|
|
1082
|
-
await downloadTemplate(remote, { cwd: stagingRoot, dir: stagingDirectory, force: true, install: false, silent: true });
|
|
1083
|
-
renameCreateViteDotfiles(stagingDirectory);
|
|
1084
|
-
cpSync(stagingDirectory, target, { recursive: true });
|
|
1085
|
-
};
|
|
1086
|
-
let written = [];
|
|
1087
|
-
await tuiTasks(
|
|
1088
|
-
[
|
|
1089
|
-
{ label: `create-vite (${adapter.label}) base ready`, run: copyBase },
|
|
1090
|
-
{
|
|
1091
|
-
label: `Lunora overlay applied (${adapter.label})`,
|
|
1092
|
-
run: () => {
|
|
1093
|
-
written = applyLunoraOverlay({ adapter, distTag: resolveDistTag(), logger, name, target });
|
|
1094
|
-
return Promise.resolve();
|
|
1095
|
-
}
|
|
1096
|
-
}
|
|
1097
|
-
],
|
|
1098
|
-
{ end: "Project initialized!", start: "Project initializing…" }
|
|
1099
|
-
);
|
|
1100
|
-
logScaffoldSuccess(logger, written, target);
|
|
1101
|
-
return { code: 0, files: [...collectFiles(target)], target };
|
|
1102
|
-
} catch (error) {
|
|
1103
|
-
if (error instanceof PromptCancelledError) {
|
|
1104
|
-
throw error;
|
|
1105
|
-
}
|
|
1106
|
-
const message = error instanceof Error ? error.message : String(error);
|
|
1107
|
-
logger.error(`failed to scaffold the ${adapter.label} base: ${message}`);
|
|
1108
|
-
return { code: 1, files: [], target };
|
|
1109
|
-
} finally {
|
|
1110
|
-
rmSync(stagingRoot, { force: true, recursive: true });
|
|
1111
|
-
}
|
|
1112
|
-
};
|
|
1113
|
-
const createMinimalViteConfig = (cwd, logger) => {
|
|
1114
|
-
const target = join$1(cwd, "vite.config.ts");
|
|
1115
|
-
try {
|
|
1116
|
-
writeFileSync(target, MINIMAL_VITE_CONFIG, "utf8");
|
|
1117
|
-
} catch (error) {
|
|
1118
|
-
const message = error instanceof Error ? error.message : String(error);
|
|
1119
|
-
logger.error(`init --in-place: could not write ${target}: ${message}`);
|
|
1120
|
-
return { code: 1, files: [], target: cwd };
|
|
1121
|
-
}
|
|
1122
|
-
logger.success(`created ${target} with lunora() plugin`);
|
|
1123
|
-
return { code: 0, files: [target], target: cwd };
|
|
1124
|
-
};
|
|
1125
|
-
const patchExistingViteConfig = (viteConfigPath, cwd, logger) => {
|
|
1126
|
-
let source;
|
|
1127
|
-
try {
|
|
1128
|
-
source = readFileSync(viteConfigPath, "utf8");
|
|
1129
|
-
} catch (error) {
|
|
1130
|
-
const message = error instanceof Error ? error.message : String(error);
|
|
1131
|
-
logger.error(`init --in-place: could not read ${viteConfigPath}: ${message}`);
|
|
1132
|
-
return { code: 1, files: [], target: cwd };
|
|
1133
|
-
}
|
|
1134
|
-
const result = patchViteConfig(source);
|
|
1135
|
-
if (!result.changed) {
|
|
1136
|
-
logger.info(`${viteConfigPath}: ${result.reason ?? "no changes needed"}`);
|
|
1137
|
-
return { code: 0, files: [], target: cwd };
|
|
1138
|
-
}
|
|
1139
|
-
try {
|
|
1140
|
-
writeFileSync(viteConfigPath, result.code, "utf8");
|
|
1141
|
-
} catch (error) {
|
|
1142
|
-
const message = error instanceof Error ? error.message : String(error);
|
|
1143
|
-
logger.error(`init --in-place: could not write ${viteConfigPath}: ${message}`);
|
|
1144
|
-
return { code: 1, files: [], target: cwd };
|
|
1145
|
-
}
|
|
1146
|
-
logger.success(`patched ${viteConfigPath} — added lunora() plugin`);
|
|
1147
|
-
return { code: 0, files: [viteConfigPath], target: cwd };
|
|
1148
|
-
};
|
|
1149
|
-
const scaffoldLunoraDirectory = (cwd, logger) => {
|
|
1150
|
-
const lunoraDirectory = join$1(cwd, "lunora");
|
|
1151
|
-
const schemaPath = join$1(lunoraDirectory, "schema.ts");
|
|
1152
|
-
if (existsSync(schemaPath)) {
|
|
1153
|
-
logger.info(`lunora/ already present — left ${schemaPath} untouched`);
|
|
1154
|
-
return [];
|
|
1155
|
-
}
|
|
1156
|
-
const written = [];
|
|
1157
|
-
try {
|
|
1158
|
-
mkdirSync(lunoraDirectory, { recursive: true });
|
|
1159
|
-
writeFileSync(schemaPath, SAMPLE_SCHEMA, "utf8");
|
|
1160
|
-
written.push(schemaPath);
|
|
1161
|
-
const functionPath = join$1(lunoraDirectory, "messages.ts");
|
|
1162
|
-
if (!existsSync(functionPath)) {
|
|
1163
|
-
writeFileSync(functionPath, SAMPLE_FUNCTION, "utf8");
|
|
1164
|
-
written.push(functionPath);
|
|
1165
|
-
}
|
|
1166
|
-
logger.success(`scaffolded lunora/ (${String(written.length)} file(s))`);
|
|
1167
|
-
} catch (error) {
|
|
1168
|
-
const message = error instanceof Error ? error.message : String(error);
|
|
1169
|
-
logger.error(`init --here: could not scaffold lunora/: ${message}`);
|
|
1170
|
-
}
|
|
1171
|
-
return written;
|
|
1172
|
-
};
|
|
1173
|
-
const printFrameworkNextSteps = (detection, logger) => {
|
|
1174
|
-
const { adapter, class: frameworkClass, framework } = detection;
|
|
1175
|
-
logger.info("");
|
|
1176
|
-
logger.info(`detected framework: ${framework} (class ${frameworkClass})`);
|
|
1177
|
-
logger.info("next steps:");
|
|
1178
|
-
logger.info(` 1. install the adapter: pnpm add ${adapter} @lunora/client @lunora/runtime @lunora/server`);
|
|
1179
|
-
logger.info(" 2. run codegen: lunora codegen");
|
|
1180
|
-
if (frameworkClass === "A") {
|
|
1181
|
-
logger.info(" 3. compose one worker: wrap your worker entry with");
|
|
1182
|
-
logger.info(" createWorker({ httpRouter: <your framework SSR handler>, shardDO: ShardDO, ... })");
|
|
1183
|
-
logger.info(` 4. add the provider: mount the ${adapter} provider in your root layout/route`);
|
|
1184
|
-
logger.info(" 5. make a loader live: preloadQuery() in a loader, usePreloadedQuery() in the component");
|
|
1185
|
-
logger.info(" see https://lunora.sh/docs/frameworks/reactive-loaders");
|
|
1186
|
-
} else if (frameworkClass === "B") {
|
|
1187
|
-
logger.info(" 3. inject Lunora: mount Lunora realtime under /_lunora/* in your server hook");
|
|
1188
|
-
logger.info(` (${framework} owns its Cloudflare adapter — Lunora composes into its server entry)`);
|
|
1189
|
-
logger.info(` 4. add the provider: mount the ${adapter} provider in your root layout`);
|
|
1190
|
-
logger.info(" 5. read the guide: https://lunora.sh/docs/frameworks/deploy");
|
|
1191
|
-
} else {
|
|
1192
|
-
logger.info(" 3. add the provider: wrap your app with the LunoraProvider from @lunora/react");
|
|
1193
|
-
logger.info(" 4. read the guide: https://lunora.sh/docs/frameworks/bring-your-framework");
|
|
1194
|
-
}
|
|
1195
|
-
logger.info("");
|
|
1196
|
-
};
|
|
1197
|
-
const findExistingViteConfig = (cwd) => {
|
|
1198
|
-
for (const candidate of VITE_CONFIG_CANDIDATES) {
|
|
1199
|
-
const full = join$1(cwd, candidate);
|
|
1200
|
-
if (existsSync(full)) {
|
|
1201
|
-
return full;
|
|
1202
|
-
}
|
|
1203
|
-
}
|
|
1204
|
-
return void 0;
|
|
1205
|
-
};
|
|
1206
|
-
const patchOrCreateViteConfig = (cwd, framework, logger) => {
|
|
1207
|
-
const viteConfigPath = findExistingViteConfig(cwd);
|
|
1208
|
-
if (viteConfigPath === void 0) {
|
|
1209
|
-
if (framework === "sveltekit" || framework === "nuxt" || framework === "astro") {
|
|
1210
|
-
logger.info(`no Vite config found — ${framework} wires Lunora through its server entry (see next steps)`);
|
|
1211
|
-
return { code: 0, files: [], target: cwd };
|
|
1212
|
-
}
|
|
1213
|
-
return createMinimalViteConfig(cwd, logger);
|
|
1214
|
-
}
|
|
1215
|
-
return patchExistingViteConfig(viteConfigPath, cwd, logger);
|
|
1216
|
-
};
|
|
1217
|
-
const runInPlaceInit = (cwd, logger) => {
|
|
1218
|
-
const detection = detectFramework(cwd);
|
|
1219
|
-
const viteResult = patchOrCreateViteConfig(cwd, detection.framework, logger);
|
|
1220
|
-
if (viteResult.code !== 0) {
|
|
1221
|
-
return viteResult;
|
|
1222
|
-
}
|
|
1223
|
-
const scaffolded = scaffoldLunoraDirectory(cwd, logger);
|
|
1224
|
-
printFrameworkNextSteps(detection, logger);
|
|
1225
|
-
return { code: 0, files: [...viteResult.files, ...scaffolded], target: cwd };
|
|
1226
|
-
};
|
|
1227
|
-
const offerIsInteractive = (options) => options.yes !== true && (options.prompt !== void 0 || (options.interactive ?? isInteractive()));
|
|
1228
|
-
const maybeOfferExtras = async (options, projectDirectory) => {
|
|
1229
|
-
const interactive = offerIsInteractive(options);
|
|
1230
|
-
const preselected = options.add === void 0 ? [] : parseFeatureList(options.add, (message) => {
|
|
1231
|
-
options.logger.warn(message);
|
|
1232
|
-
});
|
|
1233
|
-
const applyAll = async (plans) => {
|
|
1234
|
-
if (plans.length === 0) {
|
|
1235
|
-
return true;
|
|
1236
|
-
}
|
|
1237
|
-
if (options.dryRun === true) {
|
|
1238
|
-
logWould(options.logger, `add ${plans.map((plan) => plan.label).join(", ")}`);
|
|
1239
|
-
return true;
|
|
1240
|
-
}
|
|
1241
|
-
const buffered = [];
|
|
1242
|
-
const applyLogger = isInteractive() ? {
|
|
1243
|
-
error: (message) => {
|
|
1244
|
-
buffered.push({ level: "error", message });
|
|
1245
|
-
},
|
|
1246
|
-
info: () => {
|
|
1247
|
-
},
|
|
1248
|
-
success: () => {
|
|
1249
|
-
},
|
|
1250
|
-
warn: (message) => {
|
|
1251
|
-
buffered.push({ level: "warn", message });
|
|
1252
|
-
}
|
|
1253
|
-
} : options.logger;
|
|
1254
|
-
const steps = plans.map((plan) => {
|
|
1255
|
-
return {
|
|
1256
|
-
running: `adding ${plan.label}…`,
|
|
1257
|
-
task: () => runAddCommand({
|
|
1258
|
-
allowUnsafeSource: options.allowUnsafeSource,
|
|
1259
|
-
cwd: projectDirectory,
|
|
1260
|
-
from: options.registryFrom,
|
|
1261
|
-
logger: applyLogger,
|
|
1262
|
-
names: [...plan.names],
|
|
1263
|
-
ref: options.ref,
|
|
1264
|
-
source: options.registrySource,
|
|
1265
|
-
transformManifest: plan.transformManifest,
|
|
1266
|
-
yes: true
|
|
1267
|
-
})
|
|
1268
|
-
};
|
|
1269
|
-
});
|
|
1270
|
-
const done = `added ${plans.map((plan) => plan.label).join(", ")}`;
|
|
1271
|
-
const results = await withTuiBadgeProgress(BADGES.add, steps, done);
|
|
1272
|
-
for (const { level, message } of buffered) {
|
|
1273
|
-
options.logger[level](message);
|
|
1274
|
-
}
|
|
1275
|
-
return results.every((result) => result.code === 0);
|
|
1276
|
-
};
|
|
1277
|
-
const deps = {
|
|
1278
|
-
applyAll,
|
|
1279
|
-
interactive,
|
|
1280
|
-
logger: options.logger,
|
|
1281
|
-
multiSelect: options.prompt?.multiSelect ?? ((message, choices, settings) => tuiMultiSelect(message, choices, { ...settings, badge: BADGES.add })),
|
|
1282
|
-
preselected: preselected.length > 0 ? preselected : void 0,
|
|
1283
|
-
projectName: basename(projectDirectory),
|
|
1284
|
-
select: options.prompt?.select ?? ((message, choices, settings) => tuiSelect(message, choices, { ...settings, badge: BADGES.add })),
|
|
1285
|
-
text: options.prompt?.text ?? ((message, settings) => tuiText(message, { ...settings, badge: BADGES.add }))
|
|
1286
|
-
};
|
|
1287
|
-
if (preselected.length > 0) {
|
|
1288
|
-
await offerRegistryExtras(deps);
|
|
1289
|
-
return;
|
|
1290
|
-
}
|
|
1291
|
-
if (isInteractive()) {
|
|
1292
|
-
await tuiHeadline(COPY.extras);
|
|
1293
|
-
}
|
|
1294
|
-
await offerRegistryExtras(deps);
|
|
1295
|
-
};
|
|
1296
|
-
const DEFAULT_FRAMEWORK = "react";
|
|
1297
|
-
const FRAMEWORK_CHOICES = [
|
|
1298
|
-
{ description: "React SPA — official create-vite base + the Lunora layer (the default)", label: "React", value: "react" },
|
|
1299
|
-
{ description: "Vue SPA — create-vite base + Lunora", label: "Vue", value: "vue" },
|
|
1300
|
-
{ description: "Solid SPA — create-vite base + Lunora", label: "Solid", value: "solid" },
|
|
1301
|
-
{ description: "Svelte SPA — create-vite base + Lunora", label: "Svelte", value: "svelte" },
|
|
1302
|
-
{ description: "TanStack Start (React) — SSR with live-loader routes", label: "TanStack Start · React", value: "tanstack-start-react" },
|
|
1303
|
-
{ description: "TanStack Start (Solid)", label: "TanStack Start · Solid", value: "tanstack-start-solid" },
|
|
1304
|
-
{ description: "React Router (v7, framework mode) — SSR composed into the Lunora worker", label: "React Router", value: "react-router" },
|
|
1305
|
-
{ description: "Astro + a standalone Lunora worker", label: "Astro", value: "astro" },
|
|
1306
|
-
{ description: "AnalogJS (Angular) — single-worker, Lunora mounted in Nitro", label: "Analog", value: "analog" },
|
|
1307
|
-
{ description: "Nuxt (Vue) — single-worker, Lunora mounted in Nitro", label: "Nuxt", value: "nuxt" },
|
|
1308
|
-
{ description: "SvelteKit + a standalone Lunora worker", label: "SvelteKit", value: "sveltekit" },
|
|
1309
|
-
{ description: "Worker only — no frontend", label: "Standalone", value: "standalone" }
|
|
1310
|
-
];
|
|
1311
|
-
const OVERLAY_VALUES = Object.keys(ADAPTERS).join("|");
|
|
1312
|
-
const TEMPLATE_VALUES = FRAMEWORK_CHOICES.filter((choice) => !isOverlayFramework(choice.value)).map((choice) => choice.value).join("|");
|
|
1313
|
-
const toScaffoldChoice = (value) => isOverlayFramework(value) ? { framework: value, kind: "overlay" } : { kind: "template", templateType: value };
|
|
1314
|
-
const resolveScaffoldChoice = async (options) => {
|
|
1315
|
-
if (options.vite !== void 0) {
|
|
1316
|
-
return { framework: options.vite, kind: "overlay" };
|
|
1317
|
-
}
|
|
1318
|
-
if (options.templateType !== void 0) {
|
|
1319
|
-
return { kind: "template", templateType: options.templateType };
|
|
1320
|
-
}
|
|
1321
|
-
if (!isInteractive() || options.yes === true) {
|
|
1322
|
-
return { framework: DEFAULT_FRAMEWORK, kind: "overlay" };
|
|
1323
|
-
}
|
|
1324
|
-
return toScaffoldChoice(await tuiSelect(COPY.framework, FRAMEWORK_CHOICES, { badge: BADGES.tmpl, default: DEFAULT_FRAMEWORK }) ?? DEFAULT_FRAMEWORK);
|
|
1325
|
-
};
|
|
1326
|
-
const nonInteractiveInitError = (options) => {
|
|
1327
|
-
if (isInteractive() || options.yes === true) {
|
|
1328
|
-
return void 0;
|
|
1329
|
-
}
|
|
1330
|
-
const missing = [];
|
|
1331
|
-
if (options.name === void 0) {
|
|
1332
|
-
missing.push("a project name (`lunora init <name>`)");
|
|
1333
|
-
}
|
|
1334
|
-
if (options.templateType === void 0 && options.vite === void 0) {
|
|
1335
|
-
missing.push(`a framework — \`--vite <${OVERLAY_VALUES}>\` for an SPA, or \`-t <${TEMPLATE_VALUES}>\` for a bespoke template`);
|
|
1336
|
-
}
|
|
1337
|
-
if (missing.length === 0) {
|
|
1338
|
-
return void 0;
|
|
1339
|
-
}
|
|
1340
|
-
return `lunora init can't prompt in a non-interactive terminal — provide ${missing.join(" and ")}, or pass --yes to accept the defaults.`;
|
|
1341
|
-
};
|
|
1342
|
-
const scaffoldOverlayPath = async (options, framework, name, target) => {
|
|
1343
|
-
if (!isOverlayFramework(framework)) {
|
|
1344
|
-
options.logger.error(`init: unknown framework "${framework}". Supported overlays: ${Object.keys(ADAPTERS).join(", ")}.`);
|
|
1345
|
-
return { code: 1, files: [], target };
|
|
1346
|
-
}
|
|
1347
|
-
if (!await verifyRemoteTemplate({ isLocal: options.overlayBaseFrom !== void 0, logger: options.logger })) {
|
|
1348
|
-
return { code: 1, files: [], target };
|
|
1349
|
-
}
|
|
1350
|
-
mkdirSync(target, { recursive: true });
|
|
1351
|
-
return scaffoldViteOverlay({ framework, logger: options.logger, name, overlayBaseFrom: options.overlayBaseFrom, target });
|
|
1352
|
-
};
|
|
1353
|
-
const scaffoldTemplatePath = async (options, templateType, name, target) => {
|
|
1354
|
-
if (templateType === "next") {
|
|
1355
|
-
options.logger.warn('template "next" is not yet available — re-run with `--vite react` or `-t standalone`.');
|
|
1356
|
-
return { code: 1, files: [], target };
|
|
1357
|
-
}
|
|
1358
|
-
if (options.from !== void 0) {
|
|
1359
|
-
return scaffoldFromLocal(options.from, templateType, target, name, options.logger);
|
|
1360
|
-
}
|
|
1361
|
-
if (options.source !== void 0 && options.source.length > 0 && !options.allowUnsafeSource && !isSafeSource(options.source)) {
|
|
1362
|
-
options.logger.error(
|
|
1363
|
-
`init: refusing --source ${options.source} — only gh:, github:, or https:// sources are allowed (and may not contain ".."). Re-run with --allow-unsafe-source if you really want this.`
|
|
1364
|
-
);
|
|
1365
|
-
return { code: 1, files: [], target };
|
|
1366
|
-
}
|
|
1367
|
-
if (!await verifyRemoteTemplate({ isLocal: false, logger: options.logger, source: resolveTemplateSource(templateType, options.source, options.ref) })) {
|
|
1368
|
-
return { code: 1, files: [], target };
|
|
1369
|
-
}
|
|
1370
|
-
return scaffoldFromRemote({ logger: options.logger, name, ref: options.ref, source: options.source, target, templateType });
|
|
1371
|
-
};
|
|
1372
|
-
const scaffoldNewProject = async (options, cwd, recordTarget) => {
|
|
1373
|
-
await tuiMoonrise("realtime backend on Cloudflare Workers + Durable Objects");
|
|
1374
|
-
const blocked = nonInteractiveInitError(options);
|
|
1375
|
-
if (blocked !== void 0) {
|
|
1376
|
-
options.logger.error(blocked);
|
|
1377
|
-
return { code: 1, files: [], target: "" };
|
|
1378
|
-
}
|
|
1379
|
-
const suggestedName = generateProjectName();
|
|
1380
|
-
const name = options.name ?? await tuiText(COPY.name, { badge: BADGES.dir, default: suggestedName, placeholder: suggestedName });
|
|
1381
|
-
const choice = await resolveScaffoldChoice(options);
|
|
1382
|
-
if (name.includes("/") || name.includes("\\") || name === ".." || name === ".") {
|
|
1383
|
-
options.logger.error(`init: refusing project name "${name}" — must not contain path separators or be "." / "..".`);
|
|
1384
|
-
return { code: 1, files: [], target: "" };
|
|
1385
|
-
}
|
|
1386
|
-
const target = resolve(cwd, name);
|
|
1387
|
-
const targetPreExisted = existsSync(target);
|
|
1388
|
-
if (targetPreExisted) {
|
|
1389
|
-
const entries = readdirSync(target);
|
|
1390
|
-
if (entries.length > 0) {
|
|
1391
|
-
options.logger.error(`target directory not empty: ${target}`);
|
|
1392
|
-
return { code: 1, files: [], target };
|
|
1393
|
-
}
|
|
1394
|
-
}
|
|
1395
|
-
if (options.dryRun === true) {
|
|
1396
|
-
const what = choice.kind === "overlay" ? `the ${choice.framework} create-vite overlay` : `the ${choice.templateType} template`;
|
|
1397
|
-
logWould(options.logger, `scaffold ${what} into ${target}`);
|
|
1398
|
-
return { code: 0, files: [], target };
|
|
1399
|
-
}
|
|
1400
|
-
recordTarget(target, targetPreExisted);
|
|
1401
|
-
return choice.kind === "overlay" ? scaffoldOverlayPath(options, choice.framework, name, target) : scaffoldTemplatePath(options, choice.templateType, name, target);
|
|
1402
|
-
};
|
|
1403
|
-
const resetScaffoldOnCancel = (cleanup, logger) => {
|
|
1404
|
-
const { target, targetPreExisted } = cleanup;
|
|
1405
|
-
if (target === void 0 || !existsSync(target)) {
|
|
1406
|
-
return;
|
|
1407
|
-
}
|
|
1408
|
-
if (targetPreExisted === true) {
|
|
1409
|
-
for (const entry of readdirSync(target)) {
|
|
1410
|
-
rmSync(join$1(target, entry), { force: true, recursive: true });
|
|
1411
|
-
}
|
|
1412
|
-
} else {
|
|
1413
|
-
rmSync(target, { force: true, recursive: true });
|
|
1414
|
-
}
|
|
1415
|
-
logger.info(`removed the partially-created project at ${target}`);
|
|
1416
|
-
};
|
|
1417
|
-
const runScaffoldStep = async (options, cwd, recordTarget) => {
|
|
1418
|
-
if (options.inPlace !== true) {
|
|
1419
|
-
return scaffoldNewProject(options, cwd, recordTarget);
|
|
1420
|
-
}
|
|
1421
|
-
if (options.dryRun === true) {
|
|
1422
|
-
logWould(options.logger, `configure Lunora into ${cwd}`);
|
|
1423
|
-
return { code: 0, files: [], target: cwd };
|
|
1424
|
-
}
|
|
1425
|
-
return runInPlaceInit(cwd, options.logger);
|
|
1426
|
-
};
|
|
1427
|
-
const runPostScaffold = async (options, result, cwd) => {
|
|
1428
|
-
await maybeOfferExtras(options, result.target);
|
|
1429
|
-
const installedManager = options.inPlace === true ? void 0 : await maybeOfferInstall(options, result.target);
|
|
1430
|
-
if (options.inPlace !== true) {
|
|
1431
|
-
await maybeOfferGit(options, result.target);
|
|
1432
|
-
await printNextSteps(basename(result.target), installedManager, isInsideMonorepo(cwd));
|
|
1433
|
-
await emitMascot(options.logger);
|
|
1434
|
-
}
|
|
1435
|
-
};
|
|
1436
|
-
const scaffoldCiPipeline = (options, result, cwd) => {
|
|
1437
|
-
if (result.code !== 0 || options.ci === void 0) {
|
|
1438
|
-
return;
|
|
1439
|
-
}
|
|
1440
|
-
if (options.dryRun === true) {
|
|
1441
|
-
logWould(options.logger, `scaffold a ${options.ci} CI deploy pipeline`);
|
|
1442
|
-
return;
|
|
1443
|
-
}
|
|
1444
|
-
scaffoldCiWorkflow(options.inPlace === true ? cwd : result.target, options.ci, options.logger);
|
|
1445
|
-
};
|
|
1446
|
-
const runInitCommand = async (options) => {
|
|
1447
|
-
const cwd = options.cwd ?? process.cwd();
|
|
1448
|
-
const cleanup = {};
|
|
1449
|
-
let result;
|
|
1450
|
-
try {
|
|
1451
|
-
result = await runScaffoldStep(options, cwd, (target, preExisted) => {
|
|
1452
|
-
cleanup.target = target;
|
|
1453
|
-
cleanup.targetPreExisted = preExisted;
|
|
1454
|
-
});
|
|
1455
|
-
if (result.code === 0 && result.target !== "") {
|
|
1456
|
-
cleanup.target = void 0;
|
|
1457
|
-
await runPostScaffold(options, result, cwd);
|
|
1458
|
-
}
|
|
1459
|
-
} catch (error) {
|
|
1460
|
-
if (error instanceof PromptCancelledError) {
|
|
1461
|
-
resetScaffoldOnCancel(cleanup, options.logger);
|
|
1462
|
-
process.stdout.write("\n ✖ Setup cancelled — run `lunora init` again whenever you're ready. 🌙\n");
|
|
1463
|
-
return { code: 130, files: [], target: "" };
|
|
1464
|
-
}
|
|
1465
|
-
throw error;
|
|
1466
|
-
}
|
|
1467
|
-
scaffoldCiPipeline(options, result, cwd);
|
|
1468
|
-
return result;
|
|
1469
|
-
};
|
|
1470
|
-
const isTemplate = (value) => value === "analog" || value === "astro" || value === "next" || value === "nuxt" || value === "react-router" || value === "standalone" || value === "sveltekit" || value === "tanstack-start-react" || value === "tanstack-start-solid";
|
|
1471
|
-
const resolveCiProvider = (raw, logger) => {
|
|
1472
|
-
if (raw === void 0) {
|
|
1473
|
-
return void 0;
|
|
1474
|
-
}
|
|
1475
|
-
if (isCiProvider(raw)) {
|
|
1476
|
-
return raw;
|
|
1477
|
-
}
|
|
1478
|
-
logger.warn(`init: unknown --ci "${raw}" — expected github | gitlab; skipping CI scaffold.`);
|
|
1479
|
-
return void 0;
|
|
1480
|
-
};
|
|
1481
|
-
const execute = defineHandler(({ argument, cwd, logger, options }) => {
|
|
1482
|
-
const templateType = options.template !== void 0 && isTemplate(options.template) ? options.template : void 0;
|
|
1483
|
-
return runInitCommand({
|
|
1484
|
-
add: options.add,
|
|
1485
|
-
allowUnsafeSource: options.allowUnsafeSource === true,
|
|
1486
|
-
cwd,
|
|
1487
|
-
ci: resolveCiProvider(options.ci, logger),
|
|
1488
|
-
dryRun: options.dryRun === true,
|
|
1489
|
-
from: options.from,
|
|
1490
|
-
inPlace: options.here === true,
|
|
1491
|
-
interactive: options.interactive === true ? true : void 0,
|
|
1492
|
-
logger,
|
|
1493
|
-
name: argument[0],
|
|
1494
|
-
ref: options.ref,
|
|
1495
|
-
source: options.source,
|
|
1496
|
-
templateType,
|
|
1497
|
-
vite: options.vite,
|
|
1498
|
-
yes: options.yes === true
|
|
1499
|
-
});
|
|
1500
|
-
});
|
|
1501
|
-
|
|
1502
|
-
export { execute, isTemplate, resolveTemplateSource, runInitCommand };
|
|
1229
|
+
`,pa="gh:anolilab/lunora/templates",ua=e=>{const t=e.lastIndexOf(".");return t===-1?!1:ia.has(e.slice(t))},ha=(e,t)=>e.replaceAll("{{name}}",t),ye=e=>e==="lunorash"||e.startsWith("@lunora/"),ma=async(e,t)=>{const a=new Set;for(const r of e)if(S(r)==="package.json")try{const o=JSON.parse(k(r,"utf8"));for(const s of["dependencies","devDependencies"])for(const i of Object.keys(o[s]??{}))ye(i)&&a.add(i)}catch{}return re(a,t)},ga=(e,t,a)=>{let r;try{r=JSON.parse(e)}catch{return e}let o=e;for(const s of["dependencies","devDependencies"])for(const i of Object.keys(r[s]??{})){if(!ye(i))continue;const n=a.get(i)??t,c=Re(o,[s,i],n,{formattingOptions:{insertSpaces:!0,tabSize:4}});o=Te(o,c)}return o},va=["@parcel/watcher","esbuild","lmdb","msgpackr-extract","rs-module-lexer","sharp","unrs-resolver","workerd"],fa=["cpu-features","protobufjs","ssh2"],wa="pnpm-workspace.yaml",ya=()=>["# 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:",...va.map(e=>` '${e}': true`),...fa.map(e=>` '${e}': false`),""].join(`
|
|
1230
|
+
`),V=e=>{const t=[];for(const a of _e(e,{includeDirs:!1,includeFiles:!0}))$e(a.path).isSymbolicLink()||t.push(a.path);return t},be=async(e,t,a)=>{const r=V(e),o=[],s=se(),i=await ma(r,s);for(const n of r){const c=Ie(e,n),d=p(t,c);L($(d),{recursive:!0});const u=k(n);let l=ua(n)?ha(u.toString("utf8"),a):void 0;l!==void 0&&S(n)==="package.json"&&(l=ga(l,s,i)),l===void 0?m(d,u):m(d,l,"utf8"),o.push(d)}return o},j=(e,t,a)=>t!==void 0&&t.length>0?t:`${pa}/${e}#${oe(a)}`,ba=e=>e.includes("..")?!1:e.startsWith("gh:")||e.startsWith("github:")||e.startsWith("https://"),M=(e,t)=>{e.info(`[dry-run] would ${t}`)},U=(e,t,a)=>{g()&&process.stdout.write(`
|
|
1231
|
+
`),e.success(`scaffolded ${String(t.length)} files into ${a}`)},xa=(e,t)=>`${e} ${e==="npm"?"install":"add"} ${t.join(" ")}`,xe=e=>{let t=B(e);for(;;){if(h(p(t,"pnpm-workspace.yaml")))return!0;const a=p(t,"package.json");if(h(a))try{if(JSON.parse(k(a,"utf8")).workspaces!==void 0)return!0}catch{}const r=$(t);if(r===t)return!1;t=r}},ka=e=>{let t=B(e);for(;;){if(h(p(t,".git")))return!0;const a=$(t);if(a===t)return!1;t=a}},$a=async(e,t)=>{if(e.yes===!0||!g()||ka($(t)))return;if(!await le(y.git,{badge:f.git,defaultYes:!1})){await ce("Sounds good! You can always run git init manually.");return}if(e.dryRun===!0){M(e.logger,"initialize a git repository");return}const a=e.spawner??ie;(await Fe("Initializing a git repository…",()=>a({args:["init"],command:"git",cwd:t}))).code===0?await I("git","Initialized an empty git repository."):e.logger.warn("`git init` failed — initialize it yourself later with `git init`.")},Ma=async(e,t,a,r)=>{const o=[{code:`cd ./${e}`,lead:"Enter your project directory using"}];t===void 0&&o.push({code:`${a} install`,lead:"Install dependencies with",tail:r?" from the workspace root":void 0}),o.push({code:Pe(a,"dev"),lead:"Run",tail:" to start the dev server."},{code:"lunora add",lead:"Add features like auth or storage using"});const s=[{code:"https://lunora.sh/docs",lead:"Read the docs at"},{code:"https://lunora.sh/chat",lead:"Stuck? Join the chat at"}];if(g()){await Ke(f.next,y.nextHeader,o,s);return}const i=o.map(n=>`${n.lead} ${n.code}${n.tail??""}`);i.push("",...s.map(n=>`${n.lead} ${n.code}${n.tail??""}`)),await I("next",y.nextHeader,i.join(`
|
|
1232
|
+
`))},Ca=e=>e.yes!==!0&&(e.installPrompt!==void 0||g()),La=async(e,t)=>{if(!Ca(e)||xe($(t)))return;const a=Be(e.packageManagerProbe),[r]=a;if(r===void 0)return;if(!await(e.installPrompt?.confirmInstall??(async()=>le(y.install,{badge:f.deps,defaultYes:!0})))()){await ce("No problem! Remember to install dependencies after setup.");return}let o=r;if(a.length>1&&(o=e.installPrompt?await e.installPrompt.selectManager(a):await D(y.packageManager,a.map(d=>({label:d,value:d})),{badge:f.deps,default:r})??r),e.dryRun===!0){M(e.logger,`install dependencies with ${o}`);return}if(o==="pnpm"){const d=p(t,wa);h(d)||m(d,ya(),"utf8")}const s=e.spawner??ie,{args:i,command:n}=Ee(o);await I("deps",`Installing dependencies with ${o}…`);const c=await s({args:i,command:n,cwd:t});if(c.code!==0){e.logger.warn(`\`${n} install\` exited with code ${String(c.code)} — run it yourself in ${S(t)}/.`);return}return await I("deps",`Dependencies installed with ${o}.`),o},Sa=async(e,t,a,r,o)=>{const s=p(e,t);if(!h(s))return o.error(`template not found in local source: ${s}`),{code:1,files:[],target:a};const i=await be(s,a,r);return U(o,i,a),{code:0,files:i,target:a}},Aa=async e=>{const{logger:t,name:a,ref:r,source:o,target:s,templateType:i}=e,n=Y(p(Z(),"lunora-init-fetch-")),c=p(n,"template");try{const d=o!==void 0&&o.length>0?r:await ze(r,t),u=j(i,o,d);let l,w=[];await de([{label:`${i} template fetched`,run:async()=>{l=await ee(u,{cwd:n,dir:c,force:!0,install:!1,silent:!0})}},{label:`files copied into ${a}/`,run:async()=>{w=await be(c,s,a)}}],{end:"Project initialized!",start:"Project initializing…"});const H=V(c);return g()&&process.stdout.write(`
|
|
1233
|
+
`),t.info(l?.commit?`template: ${l.source} @ ${l.commit} (${String(H.length)} files)`:`template: ${l?.source??u} (${String(H.length)} files)`),U(t,w,s),{code:0,files:w,target:s}}catch(d){if(d instanceof P)throw d;const{hints:u,message:l}=$t(d,{ref:oe(r),remote:j(i,o,r),templateType:i});t.error(l);for(const w of u)t.warn(w);return{code:1,files:[],target:s}}finally{_(n,{force:!0,recursive:!0})}},Na=e=>{for(const t of["_gitignore","_npmrc","_gitattributes"]){const a=p(e,t);h(a)&&Me(a,p(e,`.${t.slice(1)}`))}},_a=async e=>{const{framework:t,logger:a,name:r,overlayBaseFrom:o,target:s}=e,i=T[t],n=Y(p(Z(),"lunora-vite-base-"));try{let c;if(o!==void 0&&(c=p(o,`template-${i.createViteTemplate}`),!h(c)))return a.error(`create-vite base not found on disk: ${c}`),{code:1,files:[],target:s};const d=async()=>{if(c!==void 0){W(c,s,{recursive:!0});return}const l=p(n,"base"),w=`github:vitejs/vite/packages/create-vite/template-${i.createViteTemplate}#main`;await ee(w,{cwd:n,dir:l,force:!0,install:!1,silent:!0}),Na(l),W(l,s,{recursive:!0})};let u=[];return await de([{label:`create-vite (${i.label}) base ready`,run:d},{label:`Lunora overlay applied (${i.label})`,run:async()=>{u=await Zt({adapter:i,distTag:se(),logger:a,name:r,target:s})}}],{end:"Project initialized!",start:"Project initializing…"}),U(a,u,s),{code:0,files:[...V(s)],target:s}}catch(c){if(c instanceof P)throw c;const d=c instanceof Error?c.message:String(c);return a.error(`failed to scaffold the ${i.label} base: ${d}`),{code:1,files:[],target:s}}finally{_(n,{force:!0,recursive:!0})}},Ia=(e,t)=>{const a=p(e,"vite.config.ts");try{m(a,la,"utf8")}catch(r){const o=r instanceof Error?r.message:String(r);return t.error(`init --in-place: could not write ${a}: ${o}`),{code:1,files:[],target:e}}return t.success(`created ${a} with lunora() plugin`),{code:0,files:[a],target:e}},Ra=(e,t,a)=>{let r;try{r=k(e,"utf8")}catch(s){const i=s instanceof Error?s.message:String(s);return a.error(`init --in-place: could not read ${e}: ${i}`),{code:1,files:[],target:t}}const o=he(r);if(!o.changed)return a.info(`${e}: ${o.reason??"no changes needed"}`),{code:0,files:[],target:t};try{m(e,o.code,"utf8")}catch(s){const i=s instanceof Error?s.message:String(s);return a.error(`init --in-place: could not write ${e}: ${i}`),{code:1,files:[],target:t}}return a.success(`patched ${e} — added lunora() plugin`),{code:0,files:[e],target:t}},Ta=(e,t)=>{const a=p(e,"lunora"),r=p(a,"schema.ts");if(h(r))return t.info(`lunora/ already present — left ${r} untouched`),[];const o=[];try{L(a,{recursive:!0}),m(r,ca,"utf8"),o.push(r);const s=p(a,"messages.ts");h(s)||(m(s,da,"utf8"),o.push(s)),t.success(`scaffolded lunora/ (${String(o.length)} file(s))`)}catch(s){const i=s instanceof Error?s.message:String(s);t.error(`init --here: could not scaffold lunora/: ${i}`)}return o},Oa=(e,t,a)=>{const{adapter:r,class:o,framework:s}=e;a.info(""),a.info(`detected framework: ${s} (class ${o})`),a.info("next steps:"),a.info(` 1. install the adapter: ${xa(t,[r,"@lunora/client","@lunora/runtime","@lunora/server"])}`),a.info(" 2. run codegen: lunora codegen"),o==="A"?(a.info(" 3. compose one worker: wrap your worker entry with"),a.info(" createWorker({ httpRouter: <your framework SSR handler>, shardDO: ShardDO, ... })"),a.info(` 4. add the provider: mount the ${r} provider in your root layout/route`),a.info(" 5. make a loader live: preloadQuery() in a loader, usePreloadedQuery() in the component"),a.info(" see https://lunora.sh/docs/frameworks/reactive-loaders")):o==="B"?(a.info(" 3. inject Lunora: mount Lunora realtime under /_lunora/* in your server hook"),a.info(` (${s} owns its Cloudflare adapter — Lunora composes into its server entry)`),a.info(` 4. add the provider: mount the ${r} provider in your root layout`),a.info(" 5. read the guide: https://lunora.sh/docs/frameworks/deploy")):(a.info(" 3. add the provider: wrap your app with the LunoraProvider from @lunora/react"),a.info(" 4. read the guide: https://lunora.sh/docs/frameworks/bring-your-framework")),a.info("")},ja=e=>{for(const t of na){const a=p(e,t);if(h(a))return a}},Ba=(e,t,a)=>{const r=ja(e);return r===void 0?t==="sveltekit"||t==="nuxt"||t==="astro"?(a.info(`no Vite config found — ${t} wires Lunora through its server entry (see next steps)`),{code:0,files:[],target:e}):Ia(e,a):Ra(r,e,a)},Ea=(e,t)=>{const a=pt(e),r=Ba(e,a.framework,t);if(r.code!==0)return r;const o=Ta(e,t);return Oa(a,te(e),t),{code:0,files:[...r.files,...o],target:e}},Pa=e=>e.yes!==!0&&(e.prompt!==void 0||(e.interactive??g())),Da=async(e,t)=>{const a=Pa(e),r=e.add===void 0?[]:Lt(e.add,s=>{e.logger.warn(s)}),o={applyAll:async s=>{if(s.length===0)return!0;if(e.dryRun===!0)return M(e.logger,`add ${s.map(l=>l.label).join(", ")}`),!0;const i=[],n=g()?{error:l=>{i.push({level:"error",message:l})},info:()=>{},success:()=>{},warn:l=>{i.push({level:"warn",message:l})}}:e.logger,c=s.map(l=>({running:`adding ${l.label}…`,task:()=>Ve({allowUnsafeSource:e.allowUnsafeSource,cwd:t,from:e.registryFrom,logger:n,names:[...l.names],ref:e.ref,source:e.registrySource,transformManifest:l.transformManifest,yes:!0})})),d=`added ${s.map(l=>l.label).join(", ")}`,u=await Qe(f.add,c,d);for(const{level:l,message:w}of i)e.logger[l](w);return u.every(l=>l.code===0)},interactive:a,logger:e.logger,multiSelect:e.prompt?.multiSelect??((s,i,n)=>Je(s,i,{...n,badge:f.add})),preselected:r.length>0?r:void 0,projectName:S(t),select:e.prompt?.select??((s,i,n)=>D(s,i,{...n,badge:f.add})),text:e.prompt?.text??((s,i)=>ne(s,{...i,badge:f.add}))};if(r.length>0){await J(o);return}g()&&await qe(y.extras),await J(o)},O="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:"Svelte SPA — create-vite base + Lunora",label:"Svelte",value:"svelte"},{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 (Solid)",label:"TanStack Start · Solid",value:"tanstack-start-solid"},{description:"React Router (v7, framework mode) — SSR composed into the Lunora worker",label:"React Router",value:"react-router"},{description:"Astro + a standalone Lunora 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 + a standalone Lunora 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"}],za=Object.keys(T).join("|"),Va=ke.filter(e=>!z(e.value)).map(e=>e.value).join("|"),Ua=e=>z(e)?{framework:e,kind:"overlay"}:{kind:"template",templateType:e},Ha=async e=>e.vite!==void 0?{framework:e.vite,kind:"overlay"}:e.templateType!==void 0?{kind:"template",templateType:e.templateType}:!g()||e.yes===!0?{framework:O,kind:"overlay"}:Ua(await D(y.framework,ke,{badge:f.tmpl,default:O})??O),Wa=e=>{if(g()||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 <${za}>\` for an SPA, or \`-t <${Va}>\` 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.`},qa=async(e,t,a,r)=>z(t)?await we({isLocal:e.overlayBaseFrom!==void 0,logger:e.logger})?(L(r,{recursive:!0}),_a({framework:t,logger:e.logger,name:a,overlayBaseFrom:e.overlayBaseFrom,target:r})):{code:1,files:[],target:r}:(e.logger.error(`init: unknown framework "${t}". Supported overlays: ${Object.keys(T).join(", ")}.`),{code:1,files:[],target:r}),Fa=async(e,t,a,r)=>e.from!==void 0?await Sa(e.from,t,r,a,e.logger):e.source!==void 0&&e.source.length>0&&!e.allowUnsafeSource&&!ba(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:1,files:[],target:r}):await we({isLocal:!1,logger:e.logger,source:j(t,e.source,e.ref)})?Aa({logger:e.logger,name:a,ref:e.ref,source:e.source,target:r,templateType:t}):{code:1,files:[],target:r},Ka=async(e,t,a)=>{await We("realtime backend on Cloudflare Workers + Durable Objects");const r=Wa(e);if(r!==void 0)return e.logger.error(r),{code:1,files:[],target:""};const o=aa(),s=e.name??await ne(y.name,{badge:f.dir,default:o,placeholder:o}),i=await Ha(e),n=s.trim();if(n.length===0)return e.logger.error("init: refusing an empty project name — pass a directory name (e.g. `lunora init my-app`)."),{code:1,files:[],target:""};if(n.includes("/")||n.includes("\\")||n===".."||n===".")return e.logger.error(`init: refusing project name "${n}" — must not contain path separators or be "." / "..".`),{code:1,files:[],target:""};const c=B(t,n),d=h(c);if(d&&X(c).length>0)return e.logger.error(`target directory not empty: ${c}`),{code:1,files:[],target:c};if(e.dryRun===!0){const u=i.kind==="overlay"?`the ${i.framework} create-vite overlay`:`the ${i.templateType} template`;return M(e.logger,`scaffold ${u} into ${c}`),{code:0,files:[],target:c}}return a(c,d),i.kind==="overlay"?qa(e,i.framework,n,c):Fa(e,i.templateType,n,c)},Ja=(e,t)=>{const{target:a,targetPreExisted:r}=e;if(!(a===void 0||!h(a))){if(r===!0)for(const o of X(a))_(p(a,o),{force:!0,recursive:!0});else _(a,{force:!0,recursive:!0});t.info(`removed the partially-created project at ${a}`)}},Qa=async(e,t,a)=>e.inPlace!==!0?Ka(e,t,a):e.dryRun===!0?(M(e.logger,`configure Lunora into ${t}`),{code:0,files:[],target:t}):Ea(t,e.logger),Ga=async(e,t,a)=>{await Da(e,t.target);const r=e.inPlace===!0?void 0:await La(e,t.target);if(e.inPlace!==!0){await $a(e,t.target);const o=r??te(t.target);await Ma(S(t.target),r,o,xe(a)),await Mt(e.logger)}},Xa=(e,t,a)=>{if(!(t.code!==0||e.ci===void 0)){if(e.dryRun===!0){M(e.logger,`scaffold a ${e.ci} CI deploy pipeline`);return}ct(e.inPlace===!0?a:t.target,e.ci,e.logger)}},Ya=async e=>{const t=e.cwd??process.cwd(),a={};let r;try{r=await Qa(e,t,(o,s)=>{a.target=o,a.targetPreExisted=s}),r.code===0&&r.target!==""&&(a.target=void 0,await Ga(e,r,t))}catch(o){if(o instanceof P)return Ja(a,e.logger),process.stdout.write("\n ✖ Setup cancelled — run `lunora init` again whenever you're ready. 🌙\n"),{code:130,files:[],target:""};throw o}return Xa(e,r,t),r},Za=e=>e==="analog"||e==="astro"||e==="expo"||e==="next"||e==="nuxt"||e==="react-router"||e==="standalone"||e==="sveltekit"||e==="tanstack-start-react"||e==="tanstack-start-solid",er=(e,t)=>{if(e!==void 0){if(nt(e))return e;t.warn(`init: unknown --ci "${e}" — expected github | gitlab; skipping CI scaffold.`)}},br=je(({argument:e,cwd:t,logger:a,options:r})=>{const o=r.template!==void 0&&Za(r.template)?r.template:void 0;return Ya({add:r.add,allowUnsafeSource:r.allowUnsafeSource===!0,cwd:t,ci:er(r.ci,a),dryRun:r.dryRun===!0,from:r.from,inPlace:r.here===!0,interactive:r.interactive===!0?!0:void 0,logger:a,name:e[0],ref:r.ref,source:r.source,templateType:o,vite:r.vite,yes:r.yes===!0})});export{br as execute,Za as isTemplate,j as resolveTemplateSource,Ya as runInitCommand};
|