@lunora/cli 1.0.0-alpha.4 → 1.0.0-alpha.400
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 +33 -0
- package/README.md +3 -1
- package/__assets__/package-og.svg +1 -1
- package/dist/bin.mjs +2 -10
- package/dist/index.d.mts +1161 -372
- package/dist/index.d.ts +1161 -372
- package/dist/index.mjs +1 -19
- package/dist/packem_chunks/dispatch.mjs +1 -0
- package/dist/packem_chunks/handler.mjs +1 -78
- package/dist/packem_chunks/handler10.mjs +1 -22
- package/dist/packem_chunks/handler11.mjs +1 -192
- package/dist/packem_chunks/handler12.mjs +1 -131
- package/dist/packem_chunks/handler13.mjs +3 -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 +7 -105
- package/dist/packem_chunks/handler18.mjs +1 -172
- package/dist/packem_chunks/handler19.mjs +1 -89
- package/dist/packem_chunks/handler2.mjs +1 -114
- package/dist/packem_chunks/handler20.mjs +3 -94
- package/dist/packem_chunks/handler21.mjs +3 -311
- package/dist/packem_chunks/handler22.mjs +1 -0
- package/dist/packem_chunks/handler23.mjs +2 -0
- package/dist/packem_chunks/handler24.mjs +99 -0
- package/dist/packem_chunks/handler25.mjs +2 -0
- package/dist/packem_chunks/handler26.mjs +9 -0
- package/dist/packem_chunks/handler27.mjs +1 -0
- package/dist/packem_chunks/handler3.mjs +1 -204
- package/dist/packem_chunks/handler4.mjs +3 -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 +2 -174
- package/dist/packem_chunks/handler9.mjs +1 -16
- package/dist/packem_chunks/runCodegenCommand.mjs +4 -52
- package/dist/packem_chunks/runDeployCommand.mjs +11 -504
- package/dist/packem_chunks/runDevCommand.mjs +2 -0
- package/dist/packem_chunks/runInitCommand.mjs +1176 -576
- package/dist/packem_chunks/runResetCommand.mjs +1 -41
- package/dist/packem_chunks/runRpcCommand.mjs +1 -68
- package/dist/packem_shared/COMMANDS-aSTSMwZS.mjs +1 -0
- package/dist/packem_shared/DEFAULT_IMPORT_BATCH_SIZE-CyIsI3S1.mjs +1 -0
- package/dist/packem_shared/EXIT_CODE-D_XCixv8.mjs +1 -0
- package/dist/packem_shared/admin-token-VdUnvnKW.mjs +1 -0
- package/dist/packem_shared/admin-url-DJB8P6Jh.mjs +1 -0
- package/dist/packem_shared/api-spec-lYyq4vL6.mjs +1 -0
- package/dist/packem_shared/binding-manifest-file-CQ1eQYy1.mjs +2 -0
- package/dist/packem_shared/buildRegistryIndex-Dc8D8AR6.mjs +1 -0
- package/dist/packem_shared/cap-error-body-YBKO32BF.mjs +1 -0
- package/dist/packem_shared/catalog-CahzmDLV.mjs +1 -0
- package/dist/packem_shared/cli-CFsmCYWp.mjs +2 -0
- package/dist/packem_shared/cli-manifest-DoQ_3bzs.mjs +1 -0
- package/dist/packem_shared/cloudflare-credentials-BVmZnDZk.mjs +1 -0
- package/dist/packem_shared/codegen-error-AmH54ofi.mjs +3 -0
- package/dist/packem_shared/command-BgjsvUFg.mjs +1 -0
- package/dist/packem_shared/commands-DvSfLvyt.mjs +13 -0
- package/dist/packem_shared/createLogger-4TujevyB.mjs +2 -0
- package/dist/packem_shared/createRecordingSpawner-Ch7zuQQE.mjs +1 -0
- package/dist/packem_shared/deploy-target-resolve-BTCW1Iv4.mjs +1 -0
- package/dist/packem_shared/diffSnapshots-htqNZT8Q.mjs +7 -0
- package/dist/packem_shared/docker-AqLAkOyY.mjs +1 -0
- package/dist/packem_shared/health-probe-Bw9JFfIy.mjs +1 -0
- package/dist/packem_shared/import-BRM1hs7j.mjs +12 -0
- package/dist/packem_shared/index-oHZBGBwB.mjs +1 -0
- package/dist/packem_shared/insertSchemaExtension-DuiV6cba.mjs +8 -0
- package/dist/packem_shared/lint-ignore-report-DKZagpqk.mjs +2 -0
- package/dist/packem_shared/mcp-config-file-CcDTeXIq.mjs +2 -0
- package/dist/packem_shared/open-url-EnKy--w-.mjs +1 -0
- package/dist/packem_shared/output-format-DWe_tkTR.mjs +2 -0
- package/dist/packem_shared/parseManifest-CwPTKdtS.mjs +1 -0
- package/dist/packem_shared/path-containment-CgxYZggb.mjs +1 -0
- package/dist/packem_shared/plan-DVfi3TrN.mjs +5 -0
- package/dist/packem_shared/planDevCommand-IglbXy5A.mjs +1 -0
- package/dist/packem_shared/platform-diagnostics-Cn2g6Jh-.mjs +4 -0
- package/dist/packem_shared/prompt-cancelled-BvsNxg_Q.mjs +1 -0
- package/dist/packem_shared/render-lunora-error-C3OJY5wk.mjs +2 -0
- package/dist/packem_shared/resolve-Bdc9KEUv.mjs +5 -0
- package/dist/packem_shared/resolve-target-C_ZloTvd.mjs +1 -0
- package/dist/packem_shared/runAddCommand-BChdJQ5L.mjs +1 -0
- package/dist/packem_shared/runExportCommand-slAq5BCF.mjs +5 -0
- package/dist/packem_shared/runMigrateGenerateCommand-BwemPIOz.mjs +11 -0
- package/dist/packem_shared/schemaIrToSnapshot-BHuNOfgs.mjs +1 -0
- package/dist/packem_shared/secret-key-8DPOH98z.mjs +1 -0
- package/dist/packem_shared/shared-D-zCOmgY.mjs +1 -0
- package/dist/packem_shared/storage-DNzYhXR-.mjs +1 -0
- package/dist/packem_shared/tui-prompts-B3YwUhGw.mjs +4 -0
- package/dist/packem_shared/variables-CPYyJtsL.mjs +1 -0
- package/dist/packem_shared/wrangler-name-Dsk5K1f-.mjs +1 -0
- package/dist/packem_shared/wrangler-secrets-CTQPpalP.mjs +1 -0
- package/package.json +41 -19
- package/skills/README.md +35 -17
- package/skills/lunora/SKILL.md +154 -64
- package/skills/lunora-create-package/SKILL.md +97 -84
- package/skills/lunora-deploy/SKILL.md +175 -105
- package/skills/lunora-functions/SKILL.md +362 -56
- package/skills/lunora-migration-helper/SKILL.md +162 -137
- package/skills/lunora-performance-audit/SKILL.md +137 -95
- package/skills/lunora-quickstart/SKILL.md +137 -136
- package/skills/lunora-realtime/SKILL.md +140 -99
- package/skills/lunora-setup-auth/SKILL.md +162 -102
- package/skills/lunora-setup-hyperdrive/SKILL.md +130 -109
- package/skills/lunora-setup-hyperdrive-global/SKILL.md +93 -90
- package/skills/lunora-setup-mail/SKILL.md +85 -113
- package/skills/lunora-setup-scheduler/SKILL.md +132 -96
- package/skills/lunora-setup-storage/SKILL.md +189 -91
- package/dist/packem_chunks/planDevCommand.mjs +0 -543
- package/dist/packem_chunks/runMigrateGenerateCommand.mjs +0 -397
- package/dist/packem_shared/COMMANDS-CHw4zOZ9.mjs +0 -922
- 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-BDXcJCCJ.mjs +0 -14
- package/dist/packem_shared/commands-SUPdjsu5.mjs +0 -787
- package/dist/packem_shared/createLogger-CHPNjFw2.mjs +0 -73
- package/dist/packem_shared/defaultSpawner-DxI3mebw.mjs +0 -43
- package/dist/packem_shared/diffSnapshots-RR2ZE8Ya.mjs +0 -161
- package/dist/packem_shared/docker-hMQ97KSQ.mjs +0 -21
- package/dist/packem_shared/features-ocSSpZtS.mjs +0 -24
- package/dist/packem_shared/insertSchemaExtension-BuzF6-t2.mjs +0 -59
- package/dist/packem_shared/open-url-Dfq6fAyT.mjs +0 -41
- package/dist/packem_shared/output-format-7gyGR3h8.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-Txwh1Xw1.mjs +0 -4
- package/dist/packem_shared/schema-drift-gate-BtBt0as0.mjs +0 -79
- package/dist/packem_shared/schemaIrToSnapshot-aBTo7TM5.mjs +0 -43
- package/dist/packem_shared/wrangler-name-cy4yhm9j.mjs +0 -12
|
@@ -1,18 +1,13 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
import { Project, SyntaxKind } from 'ts-morph';
|
|
12
|
-
import { c as resolveSourceRef, d as resolveDistTag, r as runAddCommand } from '../packem_shared/commands-SUPdjsu5.mjs';
|
|
13
|
-
import { p as promptAuthProvider, E as EMAIL_ITEM } from '../packem_shared/features-ocSSpZtS.mjs';
|
|
14
|
-
|
|
15
|
-
const GITHUB_CONTENT = `name: Deploy
|
|
1
|
+
import{existsSync as v,mkdirSync as M,writeFileSync as w,readFileSync as T,readdirSync as de,rmSync as $,lstatSync as ue,mkdtempSync as pe,copyFileSync as Je,renameSync as Xe}from"node:fs";import{tmpdir as he}from"node:os";import{detectFramework as Qe,isInteractive as y,LUNA_ART as Ze,LUNA_NAME as et,LUNA_SIGNOFF as tt,BADGES as g,paintAnswer as rt,detectLintTools as at,readProjectDependencies as me,applyLintIgnores as ot,readProjectManifest as nt}from"@lunora/config";import{readJsonSync as it,walkSync as st}from"@visulima/fs";import{join as p,dirname as S,basename as N,resolve as fe,relative as ge}from"@visulima/path";import{downloadTemplate as ve}from"giget";import{modify as lt,applyEdits as ct}from"jsonc-parser";import{join as K,dirname as dt}from"node:path";import{installArgsFor as we,execArgsFor as ut,detectPackageManager as P,detectInstalledManagers as pt,runScriptCommand as ht,addArgsFor as mt}from"@lunora/config/cli";import{d as ft}from"../packem_shared/command-BgjsvUFg.mjs";import{EXIT_CODE as m}from"../packem_shared/EXIT_CODE-D_XCixv8.mjs";import gt from"magic-string";import{Project as vt,SyntaxKind as f}from"ts-morph";import{P as q}from"../packem_shared/prompt-cancelled-BvsNxg_Q.mjs";import{l as ye,m as wt,n as be,o as xe,a as yt}from"../packem_shared/resolve-Bdc9KEUv.mjs";import{defaultSpawner as ke}from"../packem_shared/createRecordingSpawner-Ch7zuQQE.mjs";import{d as bt,e as xt,f as kt,a as Ce,t as G,g as Se,h as Ct,b as Le,i as Me,w as St,j as Lt,k as Ae,l as Mt}from"../packem_shared/tui-prompts-B3YwUhGw.mjs";import{A as Ee,E as Ne,p as At,w as Et,M as Nt,r as It,k as Rt,e as _t,c as Ie,l as Re,i as $t,f as Ot}from"../packem_shared/storage-DNzYhXR-.mjs";import{r as Tt}from"../packem_shared/commands-DvSfLvyt.mjs";import{logStep as Q}from"../packem_shared/createLogger-4TujevyB.mjs";import{r as Pt}from"../packem_shared/lint-ignore-report-DKZagpqk.mjs";import{DEFAULT_OBSERVABILITY as Dt,CLOUDFLARE_TOOLCHAIN_VERSIONS as Z}from"@lunora/config/cloudflare";import Bt from"node:dns/promises";const Y={bun:{githubCacheKey:void 0,githubSetupStep:` - uses: oven-sh/setup-bun@v2
|
|
2
|
+
`,gitlabImage:"oven/bun:1",gitlabProvisionScript:[],installCmd:"bun install --frozen-lockfile",lockfile:"bun.lockb"},npm:{githubCacheKey:"npm",githubSetupStep:"",gitlabImage:"node:22",gitlabProvisionScript:[],installCmd:"npm ci",lockfile:"package-lock.json"},pnpm:{githubCacheKey:"pnpm",githubSetupStep:` - uses: pnpm/action-setup@v4
|
|
3
|
+
with:
|
|
4
|
+
version: latest
|
|
5
|
+
`,gitlabImage:"node:22",gitlabProvisionScript:["corepack enable"],installCmd:"pnpm install --frozen-lockfile",lockfile:"pnpm-lock.yaml"},yarn:{githubCacheKey:"yarn",githubSetupStep:"",gitlabImage:"node:22",gitlabProvisionScript:["corepack enable"],installCmd:"yarn install --frozen-lockfile",lockfile:"yarn.lock"}},L=(e,t)=>{const r=ut(e,"lunora",t);return[r.command,...r.args].join(" ")},ee=e=>` - uses: actions/checkout@v4
|
|
6
|
+
${e.githubSetupStep} - uses: actions/setup-node@v4
|
|
7
|
+
with:
|
|
8
|
+
node-version: 22
|
|
9
|
+
${e.githubCacheKey===void 0?"":` cache: ${e.githubCacheKey}
|
|
10
|
+
`} - run: ${e.installCmd}`,jt=e=>{const t=Y[e],r=t.githubCacheKey===void 0?`# (below) requires it — run \`${e} install\` locally and`:`# (below) and the ${e} cache both require it — run \`${e} install\` locally and`;return`name: Deploy
|
|
16
11
|
|
|
17
12
|
on:
|
|
18
13
|
push:
|
|
@@ -20,8 +15,8 @@ on:
|
|
|
20
15
|
pull_request:
|
|
21
16
|
workflow_dispatch:
|
|
22
17
|
|
|
23
|
-
# Prerequisite: commit your
|
|
24
|
-
|
|
18
|
+
# Prerequisite: commit your ${t.lockfile}. \`${t.installCmd}\`
|
|
19
|
+
${r}
|
|
25
20
|
# commit the lockfile before pushing, or the first CI run fails.
|
|
26
21
|
#
|
|
27
22
|
# Set these repository secrets (Settings → Secrets and variables → Actions):
|
|
@@ -39,16 +34,10 @@ jobs:
|
|
|
39
34
|
permissions:
|
|
40
35
|
contents: read
|
|
41
36
|
steps:
|
|
42
|
-
|
|
43
|
-
- uses: pnpm/action-setup@v4
|
|
44
|
-
- uses: actions/setup-node@v4
|
|
45
|
-
with:
|
|
46
|
-
node-version: 22
|
|
47
|
-
cache: pnpm
|
|
48
|
-
- run: pnpm install --frozen-lockfile
|
|
37
|
+
${ee(t)}
|
|
49
38
|
# Codegen + wrangler validation gate (no deploy) — fails fast on drift.
|
|
50
|
-
- run:
|
|
51
|
-
- run:
|
|
39
|
+
- run: ${L(e,["prepare"])}
|
|
40
|
+
- run: ${L(e,["deploy"])}
|
|
52
41
|
|
|
53
42
|
# Preview version on every pull request — uploads a versioned preview URL;
|
|
54
43
|
# production traffic is untouched.
|
|
@@ -58,31 +47,24 @@ jobs:
|
|
|
58
47
|
permissions:
|
|
59
48
|
contents: read
|
|
60
49
|
steps:
|
|
61
|
-
|
|
62
|
-
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
node-version: 22
|
|
66
|
-
cache: pnpm
|
|
67
|
-
- run: pnpm install --frozen-lockfile
|
|
68
|
-
- run: pnpm exec lunora deploy --preview
|
|
69
|
-
`;
|
|
70
|
-
const GITLAB_CONTENT = `stages:
|
|
50
|
+
${ee(t)}
|
|
51
|
+
- run: ${L(e,["deploy","--preview"])}
|
|
52
|
+
`},Ut=e=>{const t=Y[e],r=[...t.gitlabProvisionScript,t.installCmd].map(a=>` - ${a}`).join(`
|
|
53
|
+
`);return`stages:
|
|
71
54
|
- deploy
|
|
72
55
|
|
|
73
|
-
# Prerequisite: commit your
|
|
74
|
-
# (below) requires it — run
|
|
56
|
+
# Prerequisite: commit your ${t.lockfile}. \`${t.installCmd}\`
|
|
57
|
+
# (below) requires it — run \`${e} install\` locally and commit the lockfile
|
|
75
58
|
# before pushing, or the first pipeline fails.
|
|
76
59
|
#
|
|
77
60
|
# Set these as masked CI/CD variables (Settings → CI/CD → Variables):
|
|
78
61
|
# CLOUDFLARE_API_TOKEN — a Workers-scoped API token
|
|
79
62
|
# CLOUDFLARE_ACCOUNT_ID — your Cloudflare account id
|
|
80
63
|
.lunora_base:
|
|
81
|
-
image:
|
|
64
|
+
image: ${t.gitlabImage}
|
|
82
65
|
stage: deploy
|
|
83
66
|
before_script:
|
|
84
|
-
|
|
85
|
-
- pnpm install --frozen-lockfile
|
|
67
|
+
${r}
|
|
86
68
|
|
|
87
69
|
# Production deploy on the default branch.
|
|
88
70
|
deploy:
|
|
@@ -91,8 +73,8 @@ deploy:
|
|
|
91
73
|
- if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
|
|
92
74
|
script:
|
|
93
75
|
# Codegen + wrangler validation gate (no deploy) — fails fast on drift.
|
|
94
|
-
-
|
|
95
|
-
-
|
|
76
|
+
- ${L(e,["prepare"])}
|
|
77
|
+
- ${L(e,["deploy"])}
|
|
96
78
|
|
|
97
79
|
# Preview version on every merge request (versioned preview URL; production
|
|
98
80
|
# traffic is untouched).
|
|
@@ -101,564 +83,1182 @@ preview:
|
|
|
101
83
|
rules:
|
|
102
84
|
- if: $CI_PIPELINE_SOURCE == "merge_request_event"
|
|
103
85
|
script:
|
|
104
|
-
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
const path = join(projectRoot, spec.file);
|
|
122
|
-
if (existsSync(path) && options.overwrite !== true) {
|
|
123
|
-
return { path, skipped: true, written: false };
|
|
124
|
-
}
|
|
125
|
-
mkdirSync(dirname(path), { recursive: true });
|
|
126
|
-
writeFileSync(path, spec.content, "utf8");
|
|
127
|
-
return { path, skipped: false, written: true };
|
|
128
|
-
};
|
|
129
|
-
const scaffoldCiWorkflow = (projectRoot, provider, logger, options = {}) => {
|
|
130
|
-
const spec = WORKFLOWS[provider];
|
|
131
|
-
try {
|
|
132
|
-
const result = writeCiWorkflow(projectRoot, provider, options);
|
|
133
|
-
if (result.skipped) {
|
|
134
|
-
logger.info(`--ci ${provider}: ${spec.file} already exists — left unchanged (re-run with overwrite to replace).`);
|
|
135
|
-
} else {
|
|
136
|
-
logger.success(`--ci ${provider}: wrote ${spec.file}`);
|
|
137
|
-
logger.info(`--ci ${provider}: set CLOUDFLARE_API_TOKEN and CLOUDFLARE_ACCOUNT_ID as ${spec.secretsHint} to enable deploys.`);
|
|
138
|
-
logger.info(
|
|
139
|
-
`--ci ${provider}: run \`pnpm install\` and commit pnpm-lock.yaml before pushing — the pipeline runs \`pnpm install --frozen-lockfile\`.`
|
|
140
|
-
);
|
|
141
|
-
}
|
|
142
|
-
return result;
|
|
143
|
-
} catch (error) {
|
|
144
|
-
const message = error instanceof Error ? error.message : String(error);
|
|
145
|
-
logger.warn(`--ci ${provider}: could not write ${spec.file} (${message})`);
|
|
146
|
-
return { path: join(projectRoot, spec.file), skipped: false, written: false };
|
|
147
|
-
}
|
|
148
|
-
};
|
|
86
|
+
- ${L(e,["deploy","--preview"])}
|
|
87
|
+
`},_e={github:{file:K(".github","workflows","deploy.yml"),secretsHint:"repository secrets (Settings → Secrets and variables → Actions)"},gitlab:{file:".gitlab-ci.yml",secretsHint:"masked CI/CD variables (Settings → CI/CD → Variables)"}},Vt=(e,t)=>e==="github"?jt(t):Ut(t),Ft=e=>e==="github"||e==="gitlab",Wt=(e,t,r,a={})=>{const o=K(e,_e[t].file);return v(o)&&a.overwrite!==!0?{path:o,skipped:!0,written:!1}:(M(dt(o),{recursive:!0}),w(o,Vt(t,r),"utf8"),{path:o,skipped:!1,written:!0})},Ht=(e,t,r,a,o={})=>{const n=_e[t];try{const i=Wt(e,t,r,o);if(i.skipped)a.info(`--ci ${t}: ${n.file} already exists — left unchanged (re-run with overwrite to replace).`);else{const s=we(r),l=[s.command,...s.args].join(" "),{installCmd:c,lockfile:u}=Y[r];a.success(`--ci ${t}: wrote ${n.file}`),a.info(`--ci ${t}: set CLOUDFLARE_API_TOKEN and CLOUDFLARE_ACCOUNT_ID as ${n.secretsHint} to enable deploys.`),a.info(`--ci ${t}: run \`${l}\` and commit ${u} before pushing — the pipeline runs \`${c}\`.`)}return i}catch(i){const s=i instanceof Error?i.message:String(i);return a.warn(`--ci ${t}: could not write ${n.file} (${s})`),{path:K(e,n.file),skipped:!1,written:!1}}},zt={astro:"@lunora/react",none:"@lunora/react",nuxt:"@lunora/vue","react-router":"@lunora/react","solid-start":"@lunora/solid",sveltekit:"@lunora/svelte","tanstack-start":"@lunora/react","tanstack-start-solid":"@lunora/solid",vinext:"@lunora/react"},Kt=e=>{const t=Qe(e);return{...t,adapter:zt[t.framework]}},_="lunora()",te='import { lunora } from "@lunora/vite";',qt="@lunora/vite",Gt="lunora",Yt=e=>{for(const t of e.getStatements()){if(t.getKind()!==f.ExportAssignment)continue;const r=t.asKindOrThrow(f.ExportAssignment).getExpression();if(r.getKind()!==f.CallExpression)continue;const a=r.asKindOrThrow(f.CallExpression);if(a.getExpression().getText()!=="defineConfig")continue;const o=a.getArguments()[0];if(o?.getKind()===f.ObjectLiteralExpression)return o.asKindOrThrow(f.ObjectLiteralExpression)}},Jt=e=>{for(const t of e.getStatements()){if(t.getKind()!==f.ExportAssignment)continue;const r=t.asKindOrThrow(f.ExportAssignment).getExpression();if(r.getKind()===f.ObjectLiteralExpression)return r.asKindOrThrow(f.ObjectLiteralExpression)}},Xt=e=>e.getDescendantsOfKind(f.CallExpression).some(t=>t.getExpression().getText()===Gt),Qt=e=>e.getImportDeclarations().some(t=>t.getModuleSpecifierValue()===qt),Zt=e=>new vt({compilerOptions:{allowJs:!0},useInMemoryFileSystem:!0}).createSourceFile("vite.config.ts",e,{overwrite:!0}),er=(e,t)=>{const r=t.getImportDeclarations().at(-1)?.getEnd()??0;r===0?e.prepend(`${te}
|
|
88
|
+
`):e.appendLeft(r,`
|
|
89
|
+
${te}`)},tr=(e,t)=>{const r=t.getProperty("plugins");if(r===void 0){const i=t.getProperties(),s=t.getStart()+1;if(i.length===0){e.appendLeft(s,` plugins: [${_}] `);return}const l=i[0];if(l===void 0)return"could not locate the start of the Vite config object's first property";e.appendLeft(l.getStart(),`plugins: [${_}],
|
|
90
|
+
`);return}const a=r.getDescendantsOfKind(f.ArrayLiteralExpression)[0];if(a===void 0)return"the Vite config's `plugins` is not an array literal — add `lunora()` to it by hand";const o=a.getElements();if(o.length===0){e.appendLeft(a.getStart()+1,_);return}const n=o[0];if(n===void 0)return"could not locate the first entry of the Vite config's `plugins` array";e.appendLeft(n.getStart(),`${_}, `)},$e=e=>{const t=Zt(e);if(Xt(t))return{changed:!1,code:e,reason:"lunora plugin already present"};const r=Yt(t)??Jt(t);if(r===void 0)return{changed:!1,code:e,reason:"could not locate a Vite config plugins array to patch"};const a=new gt(e);Qt(t)||er(a,t);const o=tr(a,r);return o!==void 0?{changed:!1,code:e,reason:o}:{changed:!0,code:a.toString()}},rr=/enotfound|eai_again|econnrefused|etimedout|network|fetch failed|getaddrinfo/u,ar=/404|not found|could not find|no such/u,or=(e,t)=>{const r=e instanceof Error?e.message:String(e),a=r.toLowerCase(),o=`failed to download template "${t.templateType}" from ${t.remote}: ${r}`;return ar.test(a)?{hints:[`Check the template name "${t.templateType}" and the ref "${t.ref}".`,"List/inspect available templates, or target a branch/tag with `--ref <branch>`."],message:`template "${t.templateType}" not found at ${t.remote}: ${r}`}:rr.test(a)?{hints:["You appear to be offline or unable to reach GitHub.","To scaffold without a network, point at a local template root: `lunora init --from <dir>`."],message:o}:{hints:["If this is a network/offline issue, scaffold from a local root with `lunora init --from <dir>`."],message:o}},O=async(e,t,r)=>{if(y()){await xt(g[e],t,r);return}if(process.stdout.write(`
|
|
91
|
+
`),r===void 0||r===""){Q(e,t);return}const a=r.split(`
|
|
92
|
+
`).map(o=>rt(o)).join(`
|
|
93
|
+
`);Q(e,`${t}
|
|
94
|
+
${a}`)},nr=async e=>{if(y()){await bt();return}e.info(`
|
|
95
|
+
${Ze}
|
|
96
|
+
${et}: ${tt}`)},Oe=[{description:"LLMs via Workers AI (summarize, generate, stream)",label:"AI",value:"ai"},{description:"Sign-up / sign-in (asks which provider)",label:"Authentication",value:"auth"},{description:"Copy-in auth screens for your framework (sign in/up, reset, 2FA)",label:"Auth UI",value:"auth-ui"},{description:"Snapshot + restore your Durable Object data",label:"Backups",value:"backup"},{description:"Headless browser screenshots + PDFs",label:"Browser rendering",value:"browser"},{description:"Zero Trust identity via Cloudflare Access",label:"Cloudflare Access",value:"cloudflare-access"},{description:"Scheduled jobs via Cron Triggers (@lunora/scheduler)",label:"Cron jobs",value:"crons"},{description:"Cloudflare Email Workers + a dev mail catcher",label:"Transactional email",value:"email"},{description:"OpenFeature feature flags (ctx.flags)",label:"Feature flags",value:"flags"},{description:"External Postgres/MySQL via Hyperdrive",label:"Hyperdrive",value:"hyperdrive"},{description:"Stripe-first payments (checkout, subscription, webhooks)",label:"Payments",value:"payment"},{description:"Live presence / who's-online over hibernated WebSockets",label:"Presence",value:"presence"},{description:"Async message queues (push/pull consumers)",label:"Queues",value:"queue"},{description:"Typed R2 buckets + signed URLs (@lunora/storage)",label:"File storage",value:"storage"},{description:"Durable long-running workflows (step.do, sleep, branch)",label:"Workflows",value:"workflow"}],re=Oe.map(e=>e.value),ir=e=>e==="email"?Ne:e,sr=(e,t)=>{const r=[];for(const a of e.split(",").map(o=>o.trim()).filter(Boolean))re.includes(a)?r.includes(a)||r.push(a):t(`init: unknown --add feature "${a}" — expected ${re.join(" | ")}; skipping.`);return r},Te=e=>e.resolveAuthUiItem===void 0?"auth-ui-react":e.resolveAuthUiItem(),lr=async e=>{const t=await _t(e.select),r=await Ie(e.text,e.projectName);return{label:"auth",names:[t],transformManifest:a=>Re(a,r)}},cr=async e=>{const t=await e.text(Nt,{placeholder:"you@yourdomain.com"}),r=It(t,a=>{e.logger.warn(a)});return{label:"email",names:[Ne],transformManifest:r===void 0?void 0:a=>Rt(a,r)}},dr=async(e,t)=>{const r=Te(e);if(r===void 0){e.logger.error(`init: ${Ee}`);return}if(t)return{label:"auth-ui",names:[r]};const a=await Ie(e.text,e.projectName);return{label:"auth-ui",names:[r],transformManifest:o=>Re(o,a)}},ur=async e=>{const t=await At(e.text,e.projectName);return{label:"storage",names:["storage"],transformManifest:r=>Et(r,t)}},pr=(e,t)=>{const r=[];let a=!1;for(const o of t){if(o!=="auth-ui"){r.push({label:o,names:[ir(o)]});continue}const n=Te(e);if(n===void 0){e.logger.error(`init: ${Ee}`),a=!0;continue}r.push({label:o,names:[n]})}return{plans:r,refused:a}},hr={auth:lr,"auth-ui":async(e,t)=>dr(e,t.includes("auth")),email:cr,storage:ur},ae=async e=>{if(e.preselected!==void 0&&e.preselected.length>0){const{plans:a,refused:o}=pr(e,e.preselected);return await e.applyAll(a)&&!o}if(!e.interactive)return e.logger.info("tip: add features later with `lunora add <ai|auth|backup|browser|cloudflare-access|crons|email|flags|hyperdrive|payment|presence|queue|storage|workflow>`."),!0;const t=await e.multiSelect("Which features do you want to add?",Oe,{defaults:[]});if(t.length===0)return!0;const r=[];for(const a of t){const o=hr[a],n=o?await o(e,t):{label:a,names:[a]};n!==void 0&&r.push(n)}return await e.applyAll(r),!0},mr=[{description:"Adds an ignores entry to eslint.config.js",label:"ESLint",value:"eslint"},{description:"Writes .prettierignore",label:"Prettier",value:"prettier"},{description:"Adds negated patterns to biome.json",label:"Biome",value:"biome"},{description:"Writes ignorePatterns to .oxlintrc.json",label:"oxlint (oxc)",value:"oxlint"}],fr="Which linter/formatter do you use? We'll tell it to skip Lunora's generated files.",gr=async e=>{const t=e.interactive?await e.multiSelect(fr,mr,{defaults:e.detected}):[...e.detected];if(t.length===0)return[];const r=e.apply(t);return Pt(r,e.logger),r},I="M 259.500 10.552 C 220.080 15.859, 182.424 32.566, 152.500 58.025 C 110.179 94.031, 85.380 137.183, 77.518 188.500 C 75.410 202.255, 74.569 225.677, 75.796 236.466 C 76.757 244.917, 76.683 245.692, 74.518 249.966 C 63.118 272.466, 53.141 303.876, 51.382 322.799 L 50.718 329.943 71.960 320.471 C 83.643 315.262, 93.326 311, 93.478 311 C 93.630 311, 96.547 316.063, 99.959 322.250 C 103.371 328.438, 107.249 334.850, 108.577 336.500 L 110.990 339.500 110.981 336 C 110.977 334.075, 111.499 324.991, 112.143 315.813 L 113.312 299.127 121.406 293.336 C 132.495 285.403, 149.593 271.554, 161 261.268 C 171.556 251.748, 189.116 235, 188.540 235 C 188.337 235, 183.069 238.648, 176.835 243.106 C 142.318 267.789, 68.537 314, 63.646 314 C 61.843 314, 72.791 281.179, 80.905 262.259 C 92.233 235.845, 107.473 212.389, 132.106 183.453 L 138.451 176 148.268 176 C 176.192 176, 197.512 187.154, 212.868 209.797 C 216.470 215.108, 217.035 216.595, 216.477 219.297 C 211.386 243.968, 202.359 274.496, 193.797 296 C 183.898 320.861, 167.147 352.101, 152.395 373.215 L 147.004 380.930 152.891 385.830 C 161.400 392.911, 165.563 396, 166.594 395.998 C 167.092 395.998, 168.772 391.641, 170.327 386.317 C 176.279 365.934, 188.422 338.749, 200.942 317.778 C 223.060 280.731, 256.432 244.369, 294.500 215.836 C 309.956 204.252, 313.937 201.603, 314.719 202.385 C 315.116 202.783, 315.449 213.096, 315.460 225.304 C 315.474 241.855, 315.021 250.405, 313.680 258.924 C 307.009 301.272, 291.175 336.677, 263.112 372 C 255.259 381.883, 227.182 410.673, 218.516 417.727 L 213.532 421.783 223.439 424.880 C 281.705 443.093, 349.165 436.018, 398.616 406.508 C 446.728 377.797, 483.322 331.466, 497.366 281.481 C 503.381 260.075, 504.480 250.741, 504.491 221 C 504.501 191.997, 503.598 184.047, 497.987 163.732 C 484.768 115.871, 452.505 72.708, 407.718 42.964 C 381.051 25.254, 352.818 14.828, 319.695 10.460 C 305.932 8.645, 273.298 8.695, 259.500 10.552",E=`/* The welcome page is a full-bleed starter — reset the browser's default
|
|
97
|
+
body margin/padding so it sits flush; everything else is scoped under
|
|
98
|
+
.lunora-welcome (collision-safe). */
|
|
99
|
+
body {
|
|
100
|
+
margin: 0;
|
|
101
|
+
padding: 0;
|
|
102
|
+
}
|
|
149
103
|
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
const base = detectFramework$1(root);
|
|
162
|
-
return { ...base, adapter: ADAPTER_BY_FRAMEWORK[base.framework] };
|
|
163
|
-
};
|
|
104
|
+
.lunora-welcome {
|
|
105
|
+
--cyan: hsl(186 84% 56%); --violet: hsl(256 72% 68%); --rose: hsl(330 80% 64%);
|
|
106
|
+
--ribbon: linear-gradient(115deg, var(--cyan), var(--violet) 52%, var(--rose));
|
|
107
|
+
--sans: "Geist Sans", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
|
|
108
|
+
--mono: "Geist Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;
|
|
109
|
+
/* NIGHT (default) */
|
|
110
|
+
--bg: #0e0e11; --surface: hsl(240 12% 8% / 0.72); --surface-2: hsl(240 11% 11% / 0.82);
|
|
111
|
+
--line: hsl(0 0% 100% / 0.08); --line-2: hsl(0 0% 100% / 0.14);
|
|
112
|
+
--t-display: hsl(228 30% 97%); --t-primary: hsl(228 26% 90%); --t-secondary: hsl(228 12% 62%); --t-faint: hsl(228 10% 44%);
|
|
113
|
+
--logo: hsl(228 30% 97%); --accent: var(--violet); --shot-bg: hsl(240 12% 6%);
|
|
114
|
+
--glow-1: hsl(256 80% 52% / 0.30); --glow-2: hsl(196 84% 52% / 0.13); --arc: hsl(256 60% 70% / 0.11);
|
|
164
115
|
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
}
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
}
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
}
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
}
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
}
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
116
|
+
position: relative; min-height: 100vh; background: var(--bg); color: var(--t-primary);
|
|
117
|
+
font-family: var(--sans); line-height: 1.55; -webkit-font-smoothing: antialiased; overflow-x: hidden;
|
|
118
|
+
transition: background .3s, color .3s;
|
|
119
|
+
}
|
|
120
|
+
.lunora-welcome[data-theme="light"] {
|
|
121
|
+
--bg: hsl(228 32% 97%); --surface: hsl(0 0% 100% / 0.82); --surface-2: hsl(0 0% 100% / 0.95);
|
|
122
|
+
--line: hsl(228 16% 88%); --line-2: hsl(228 14% 80%);
|
|
123
|
+
--t-display: hsl(240 14% 10%); --t-primary: hsl(240 12% 18%); --t-secondary: hsl(235 9% 42%); --t-faint: hsl(235 8% 58%);
|
|
124
|
+
--logo: hsl(240 16% 9%); --accent: hsl(256 58% 56%); --shot-bg: hsl(228 26% 99%);
|
|
125
|
+
--glow-1: hsl(256 80% 60% / 0.14); --glow-2: hsl(196 84% 58% / 0.08); --arc: hsl(256 40% 55% / 0.12);
|
|
126
|
+
}
|
|
127
|
+
.lunora-welcome *, .lunora-welcome *::before, .lunora-welcome *::after { box-sizing: border-box; }
|
|
128
|
+
.lunora-welcome a { color: inherit; text-decoration: none; }
|
|
129
|
+
.lunora-welcome button { font-family: inherit; cursor: pointer; }
|
|
130
|
+
.lunora-welcome ::selection { background: hsl(256 72% 68% / 0.3); }
|
|
131
|
+
.lunora-welcome code { font-family: var(--mono); }
|
|
132
|
+
|
|
133
|
+
/* glow background */
|
|
134
|
+
.lunora-welcome .lw-bg { position: fixed; inset: 0; z-index: 0; pointer-events: none; overflow: hidden; }
|
|
135
|
+
.lunora-welcome .lw-bg .glow { position: absolute; left: 50%; top: -4%; width: 860px; height: 720px; transform: translateX(-50%);
|
|
136
|
+
border-radius: 50%; background: radial-gradient(circle at 50% 50%, var(--glow-1), var(--glow-2) 40%, transparent 66%); }
|
|
137
|
+
.lunora-welcome .lw-bg .arc { position: absolute; left: 50%; border-radius: 50%; border: 1px solid var(--arc); transform: translateX(-50%); }
|
|
138
|
+
.lunora-welcome .lw-bg .arc.a1 { top: -340px; width: 980px; height: 980px; }
|
|
139
|
+
.lunora-welcome .lw-bg .arc.a2 { top: -240px; width: 720px; height: 720px; opacity: .7; }
|
|
140
|
+
|
|
141
|
+
/* theme toggle */
|
|
142
|
+
.lunora-welcome .lw-toggle { position: fixed; z-index: 5; top: 20px; right: clamp(16px,4vw,36px); display: inline-flex; align-items: center;
|
|
143
|
+
gap: 7px; border: 1px solid var(--line-2); background: var(--surface); backdrop-filter: blur(12px); color: var(--t-secondary);
|
|
144
|
+
font-family: var(--mono); font-size: 10.5px; letter-spacing: .1em; text-transform: uppercase; padding: 7px 11px; transition: .15s; }
|
|
145
|
+
.lunora-welcome .lw-toggle:hover { color: var(--t-display); border-color: var(--accent); }
|
|
146
|
+
.lunora-welcome .lw-toggle svg { width: 13px; height: 13px; }
|
|
147
|
+
|
|
148
|
+
.lunora-welcome .lw-wrap { position: relative; z-index: 2; width: 100%; max-width: 1080px; margin: 0 auto;
|
|
149
|
+
padding: clamp(44px,8vh,92px) clamp(20px,5vw,48px); display: flex; flex-direction: column; min-height: 100vh; }
|
|
150
|
+
.lunora-welcome .brand { display: flex; align-items: center; justify-content: center; gap: 15px; margin-bottom: clamp(38px,6vh,68px); color: var(--logo); }
|
|
151
|
+
.lunora-welcome .brand svg { width: 54px; height: auto; display: block; }
|
|
152
|
+
.lunora-welcome .brand .word { font-size: 34px; font-weight: 600; letter-spacing: -0.03em; color: var(--t-display); }
|
|
153
|
+
|
|
154
|
+
.lunora-welcome .grid { display: grid; grid-template-columns: 1.06fr 0.94fr; gap: 16px; align-items: stretch; flex: 1; max-height: 580px; }
|
|
155
|
+
@media (max-width: 820px) { .lunora-welcome .grid { grid-template-columns: 1fr; max-height: none; } }
|
|
156
|
+
|
|
157
|
+
.lunora-welcome .card { border: 1px solid var(--line); background: var(--surface); backdrop-filter: blur(10px); transition: border-color .2s, background .2s; }
|
|
158
|
+
.lunora-welcome .card:hover { border-color: var(--line-2); background: var(--surface-2); }
|
|
159
|
+
.lunora-welcome .card:hover .arrow { color: var(--accent); transform: translateX(3px); }
|
|
160
|
+
.lunora-welcome .arrow { color: var(--t-faint); transition: color .2s, transform .2s; }
|
|
161
|
+
.lunora-welcome .arrow svg { width: 20px; height: 20px; display: block; }
|
|
162
|
+
.lunora-welcome .ic { display: grid; place-items: center; color: var(--accent);
|
|
163
|
+
border: 1px solid color-mix(in oklab, var(--accent) 36%, transparent); background: color-mix(in oklab, var(--accent) 12%, transparent); }
|
|
164
|
+
.lunora-welcome .ic svg { display: block; }
|
|
165
|
+
|
|
166
|
+
/* left feature card — stretches to fill the box height */
|
|
167
|
+
.lunora-welcome .feature { padding: clamp(18px,2vw,24px); display: flex; flex-direction: column; }
|
|
168
|
+
.lunora-welcome .shot { border: 1px solid var(--line); overflow: hidden; background: var(--shot-bg);
|
|
169
|
+
-webkit-mask-image: linear-gradient(to bottom, #000 56%, transparent 100%); mask-image: linear-gradient(to bottom, #000 56%, transparent 100%); }
|
|
170
|
+
.lunora-welcome .shot .top { display: flex; align-items: center; gap: 12px; padding: 11px 14px; border-bottom: 1px solid var(--line); }
|
|
171
|
+
.lunora-welcome .shot .wm { display: flex; align-items: center; gap: 7px; font-size: 12px; font-weight: 600; color: var(--t-primary); }
|
|
172
|
+
.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%); }
|
|
173
|
+
.lunora-welcome .shot .search { flex: 1; height: 22px; border: 1px solid var(--line); border-radius: 4px; }
|
|
174
|
+
.lunora-welcome .shot .ver { font-family: var(--mono); font-size: 8px; letter-spacing: .08em; color: var(--t-faint); }
|
|
175
|
+
.lunora-welcome .shot .body { display: grid; grid-template-columns: 92px 1fr; min-height: 224px; }
|
|
176
|
+
.lunora-welcome .shot .nav { border-right: 1px solid var(--line); padding: 14px 12px; display: flex; flex-direction: column; gap: 11px; }
|
|
177
|
+
.lunora-welcome .shot .nav i, .lunora-welcome .shot .doc i { height: 5px; border-radius: 2px; background: var(--line); }
|
|
178
|
+
.lunora-welcome .shot .doc { padding: 16px 18px; display: flex; flex-direction: column; gap: 9px; }
|
|
179
|
+
.lunora-welcome .shot .doc .h { height: 8px; width: 46%; border-radius: 2px; background: var(--line-2); margin-bottom: 5px; }
|
|
180
|
+
.lunora-welcome .shot .doc .accent { height: 5px; width: 26%; border-radius: 2px; background: var(--accent); }
|
|
181
|
+
.lunora-welcome .feature .info { margin-top: auto; padding-top: clamp(18px,2.4vh,28px); }
|
|
182
|
+
.lunora-welcome .feature .ic { width: 40px; height: 40px; margin-bottom: 15px; }
|
|
183
|
+
.lunora-welcome .feature .ic svg { width: 19px; height: 19px; }
|
|
184
|
+
.lunora-welcome .feature h2 { margin: 0 0 10px; font-size: 19px; font-weight: 600; letter-spacing: -0.015em; color: var(--t-display); }
|
|
185
|
+
.lunora-welcome .feature .row { display: flex; align-items: flex-end; gap: 16px; }
|
|
186
|
+
.lunora-welcome .feature p { margin: 0; color: var(--t-secondary); font-size: 14px; max-width: 50ch; }
|
|
187
|
+
.lunora-welcome .feature .row .arrow { margin-left: auto; }
|
|
188
|
+
|
|
189
|
+
/* right stack — smaller cards, spread to align bottoms with the feature */
|
|
190
|
+
.lunora-welcome .stack { display: flex; flex-direction: column; gap: 16px; height: 100%; }
|
|
191
|
+
.lunora-welcome .mini { flex: 1; padding: 15px 17px; display: flex; align-items: center; gap: 16px; min-height: 0; }
|
|
192
|
+
.lunora-welcome .mini .mc { flex: 1; }
|
|
193
|
+
.lunora-welcome .mini .ic { width: 32px; height: 32px; margin-bottom: 10px; }
|
|
194
|
+
.lunora-welcome .mini .ic svg { width: 16px; height: 16px; }
|
|
195
|
+
.lunora-welcome .mini h3 { margin: 0 0 5px; font-size: 16px; font-weight: 600; letter-spacing: -0.01em; color: var(--t-display); }
|
|
196
|
+
.lunora-welcome .mini p { margin: 0; color: var(--t-secondary); font-size: 12.5px; line-height: 1.45; }
|
|
197
|
+
|
|
198
|
+
.lunora-welcome .lw-foot { text-align: center; padding-top: 26px; font-family: var(--mono); font-size: 11px; letter-spacing: .1em; text-transform: uppercase; color: var(--t-faint); }
|
|
199
|
+
|
|
200
|
+
@media (prefers-reduced-motion: reduce) { .lunora-welcome * { transition: none !important; } }
|
|
201
|
+
`,vr=`import { useEffect, useState } from "react";
|
|
202
|
+
|
|
203
|
+
type Theme = "dark" | "light";
|
|
204
|
+
|
|
205
|
+
export default function App() {
|
|
206
|
+
// Default to "dark" for a stable first paint, then reconcile to the OS
|
|
207
|
+
// preference; the toggle takes over after that.
|
|
208
|
+
const [theme, setTheme] = useState<Theme>("dark");
|
|
209
|
+
|
|
210
|
+
useEffect(() => {
|
|
211
|
+
if (typeof window !== "undefined" && window.matchMedia("(prefers-color-scheme: light)").matches) {
|
|
212
|
+
setTheme("light");
|
|
213
|
+
}
|
|
214
|
+
}, []);
|
|
215
|
+
|
|
216
|
+
const isLight = theme === "light";
|
|
217
|
+
|
|
218
|
+
return (
|
|
219
|
+
<div className="lunora-welcome" data-theme={theme}>
|
|
220
|
+
<div className="lw-bg">
|
|
221
|
+
<div className="arc a1" />
|
|
222
|
+
<div className="arc a2" />
|
|
223
|
+
<div className="glow" />
|
|
224
|
+
</div>
|
|
225
|
+
|
|
226
|
+
<button className="lw-toggle" type="button" aria-label="Toggle color theme" onClick={() => setTheme(isLight ? "dark" : "light")}>
|
|
227
|
+
{isLight ? (
|
|
228
|
+
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.8">
|
|
229
|
+
<path d="M21 12.8A9 9 0 1 1 11.2 3a7 7 0 0 0 9.8 9.8z" />
|
|
230
|
+
</svg>
|
|
231
|
+
) : (
|
|
232
|
+
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.8">
|
|
233
|
+
<circle cx="12" cy="12" r="4" />
|
|
234
|
+
<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" />
|
|
235
|
+
</svg>
|
|
236
|
+
)}
|
|
237
|
+
<span>{isLight ? "Ivory" : "Night"}</span>
|
|
238
|
+
</button>
|
|
239
|
+
|
|
240
|
+
<div className="lw-wrap">
|
|
241
|
+
<div className="brand">
|
|
242
|
+
<svg viewBox="0 0 543 446" role="img" aria-label="Lunora">
|
|
243
|
+
<path d="${I}" fill="currentColor" fillRule="evenodd" />
|
|
244
|
+
</svg>
|
|
245
|
+
<span className="word">Lunora</span>
|
|
246
|
+
</div>
|
|
247
|
+
|
|
248
|
+
<div className="grid">
|
|
249
|
+
<a className="card feature" href="https://lunora.sh/docs">
|
|
250
|
+
<div className="shot" aria-hidden="true">
|
|
251
|
+
<div className="top">
|
|
252
|
+
<span className="wm">
|
|
253
|
+
<i /> Lunora
|
|
254
|
+
</span>
|
|
255
|
+
<span className="search" />
|
|
256
|
+
<span className="ver">v0.1</span>
|
|
257
|
+
</div>
|
|
258
|
+
<div className="body">
|
|
259
|
+
<div className="nav">
|
|
260
|
+
<i style={{ width: "80%" }} />
|
|
261
|
+
<i style={{ width: "60%" }} />
|
|
262
|
+
<i style={{ width: "72%" }} />
|
|
263
|
+
<i style={{ width: "50%" }} />
|
|
264
|
+
<i style={{ width: "66%" }} />
|
|
265
|
+
<i style={{ width: "44%" }} />
|
|
266
|
+
<i style={{ width: "58%" }} />
|
|
267
|
+
</div>
|
|
268
|
+
<div className="doc">
|
|
269
|
+
<span className="h" />
|
|
270
|
+
<i style={{ width: "92%" }} />
|
|
271
|
+
<i style={{ width: "88%" }} />
|
|
272
|
+
<span className="accent" />
|
|
273
|
+
<i style={{ width: "80%" }} />
|
|
274
|
+
<i style={{ width: "90%" }} />
|
|
275
|
+
<i style={{ width: "72%" }} />
|
|
276
|
+
<i style={{ width: "84%" }} />
|
|
277
|
+
<i style={{ width: "78%" }} />
|
|
278
|
+
</div>
|
|
279
|
+
</div>
|
|
280
|
+
</div>
|
|
281
|
+
<div className="info">
|
|
282
|
+
<span className="ic">
|
|
283
|
+
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.7">
|
|
284
|
+
<path d="M4 5a2 2 0 0 1 2-2h9l5 5v11a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2z" />
|
|
285
|
+
<path d="M14 3v5h5" />
|
|
286
|
+
</svg>
|
|
287
|
+
</span>
|
|
288
|
+
<h2>Documentation</h2>
|
|
289
|
+
<div className="row">
|
|
290
|
+
<p>
|
|
291
|
+
Schemas, queries, live subscriptions, sharding, and edge deploy — start to finish. New here or coming from Convex or tRPC,
|
|
292
|
+
you'll have a live app fast.
|
|
293
|
+
</p>
|
|
294
|
+
<span className="arrow">
|
|
295
|
+
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2">
|
|
296
|
+
<path d="M5 12h14M13 6l6 6-6 6" />
|
|
297
|
+
</svg>
|
|
298
|
+
</span>
|
|
299
|
+
</div>
|
|
300
|
+
</div>
|
|
301
|
+
</a>
|
|
302
|
+
|
|
303
|
+
<div className="stack">
|
|
304
|
+
<a className="card mini" href="https://lunora.sh/blog">
|
|
305
|
+
<div className="mc">
|
|
306
|
+
<span className="ic">
|
|
307
|
+
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.7">
|
|
308
|
+
<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" />
|
|
309
|
+
</svg>
|
|
310
|
+
</span>
|
|
311
|
+
<h3>Blog</h3>
|
|
312
|
+
<p>Product updates, deep dives, and what's new in Lunora.</p>
|
|
313
|
+
</div>
|
|
314
|
+
<span className="arrow">
|
|
315
|
+
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2">
|
|
316
|
+
<path d="M5 12h14M13 6l6 6-6 6" />
|
|
317
|
+
</svg>
|
|
318
|
+
</span>
|
|
319
|
+
</a>
|
|
320
|
+
<a className="card mini" href="/_lunora">
|
|
321
|
+
<div className="mc">
|
|
322
|
+
<span className="ic">
|
|
323
|
+
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.7">
|
|
324
|
+
<rect x="3" y="3" width="18" height="18" rx="1" />
|
|
325
|
+
<path d="M3 9h18M9 21V9" />
|
|
326
|
+
</svg>
|
|
327
|
+
</span>
|
|
328
|
+
<h3>Lunora Studio</h3>
|
|
329
|
+
<p>Local admin for schema, data, logs, and advisors.</p>
|
|
330
|
+
</div>
|
|
331
|
+
<span className="arrow">
|
|
332
|
+
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2">
|
|
333
|
+
<path d="M5 12h14M13 6l6 6-6 6" />
|
|
334
|
+
</svg>
|
|
335
|
+
</span>
|
|
336
|
+
</a>
|
|
337
|
+
<a className="card mini" href="https://lunora.sh/packages">
|
|
338
|
+
<div className="mc">
|
|
339
|
+
<span className="ic">
|
|
340
|
+
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.7">
|
|
341
|
+
<path d="M12 2 3 7v10l9 5 9-5V7z" />
|
|
342
|
+
<path d="M3 7l9 5 9-5M12 12v10" />
|
|
343
|
+
</svg>
|
|
344
|
+
</span>
|
|
345
|
+
<h3>Cloudflare ecosystem</h3>
|
|
346
|
+
<p>Auth, mail, storage, AI, payments — one deploy.</p>
|
|
347
|
+
</div>
|
|
348
|
+
<span className="arrow">
|
|
349
|
+
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2">
|
|
350
|
+
<path d="M5 12h14M13 6l6 6-6 6" />
|
|
351
|
+
</svg>
|
|
352
|
+
</span>
|
|
353
|
+
</a>
|
|
354
|
+
</div>
|
|
355
|
+
</div>
|
|
356
|
+
|
|
357
|
+
<div className="lw-foot">Running on Lunora · Vite + React</div>
|
|
358
|
+
</div>
|
|
359
|
+
</div>
|
|
360
|
+
);
|
|
361
|
+
}
|
|
362
|
+
`,wr=`<script setup lang="ts">
|
|
363
|
+
import { onMounted, ref } from "vue";
|
|
364
|
+
|
|
365
|
+
// Default to "dark" for a stable first paint, then reconcile to the OS
|
|
366
|
+
// preference; the toggle takes over after that.
|
|
367
|
+
const theme = ref<"dark" | "light">("dark");
|
|
368
|
+
|
|
369
|
+
onMounted(() => {
|
|
370
|
+
if (window.matchMedia("(prefers-color-scheme: light)").matches) {
|
|
371
|
+
theme.value = "light";
|
|
263
372
|
}
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
const
|
|
267
|
-
|
|
268
|
-
return { changed: false, code: source, reason: "lunora plugin already present" };
|
|
269
|
-
}
|
|
270
|
-
const configObject = findConfigObject(source);
|
|
271
|
-
if (configObject === void 0) {
|
|
272
|
-
return { changed: false, code: source, reason: "could not locate a Vite config plugins array to patch" };
|
|
273
|
-
}
|
|
274
|
-
const ms = new MagicString(source);
|
|
275
|
-
const alreadyImported = source.includes(LUNORA_VITE_DOUBLE) || source.includes(LUNORA_VITE_SINGLE);
|
|
276
|
-
if (alreadyImported) {
|
|
277
|
-
patchPluginsArray(ms, configObject);
|
|
278
|
-
} else {
|
|
279
|
-
addImport(ms, source);
|
|
280
|
-
patchPluginsArray(ms, configObject);
|
|
281
|
-
}
|
|
282
|
-
return { changed: true, code: ms.toString() };
|
|
373
|
+
});
|
|
374
|
+
|
|
375
|
+
const toggle = (): void => {
|
|
376
|
+
theme.value = theme.value === "light" ? "dark" : "light";
|
|
283
377
|
};
|
|
378
|
+
<\/script>
|
|
284
379
|
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
380
|
+
<template>
|
|
381
|
+
<div class="lunora-welcome" :data-theme="theme">
|
|
382
|
+
<div class="lw-bg">
|
|
383
|
+
<div class="arc a1" />
|
|
384
|
+
<div class="arc a2" />
|
|
385
|
+
<div class="glow" />
|
|
386
|
+
</div>
|
|
387
|
+
|
|
388
|
+
<button class="lw-toggle" type="button" aria-label="Toggle color theme" @click="toggle">
|
|
389
|
+
<svg v-if="theme === 'light'" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8">
|
|
390
|
+
<path d="M21 12.8A9 9 0 1 1 11.2 3a7 7 0 0 0 9.8 9.8z" />
|
|
391
|
+
</svg>
|
|
392
|
+
<svg v-else viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8">
|
|
393
|
+
<circle cx="12" cy="12" r="4" />
|
|
394
|
+
<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" />
|
|
395
|
+
</svg>
|
|
396
|
+
<span>{{ theme === "light" ? "Ivory" : "Night" }}</span>
|
|
397
|
+
</button>
|
|
398
|
+
|
|
399
|
+
<div class="lw-wrap">
|
|
400
|
+
<div class="brand">
|
|
401
|
+
<svg viewBox="0 0 543 446" role="img" aria-label="Lunora">
|
|
402
|
+
<path d="${I}" fill="currentColor" fill-rule="evenodd" />
|
|
403
|
+
</svg>
|
|
404
|
+
<span class="word">Lunora</span>
|
|
405
|
+
</div>
|
|
406
|
+
|
|
407
|
+
<div class="grid">
|
|
408
|
+
<a class="card feature" href="https://lunora.sh/docs">
|
|
409
|
+
<div class="shot" aria-hidden="true">
|
|
410
|
+
<div class="top">
|
|
411
|
+
<span class="wm"><i /> Lunora</span>
|
|
412
|
+
<span class="search" />
|
|
413
|
+
<span class="ver">v0.1</span>
|
|
414
|
+
</div>
|
|
415
|
+
<div class="body">
|
|
416
|
+
<div class="nav">
|
|
417
|
+
<i style="width: 80%" />
|
|
418
|
+
<i style="width: 60%" />
|
|
419
|
+
<i style="width: 72%" />
|
|
420
|
+
<i style="width: 50%" />
|
|
421
|
+
<i style="width: 66%" />
|
|
422
|
+
<i style="width: 44%" />
|
|
423
|
+
<i style="width: 58%" />
|
|
424
|
+
</div>
|
|
425
|
+
<div class="doc">
|
|
426
|
+
<span class="h" />
|
|
427
|
+
<i style="width: 92%" />
|
|
428
|
+
<i style="width: 88%" />
|
|
429
|
+
<span class="accent" />
|
|
430
|
+
<i style="width: 80%" />
|
|
431
|
+
<i style="width: 90%" />
|
|
432
|
+
<i style="width: 72%" />
|
|
433
|
+
<i style="width: 84%" />
|
|
434
|
+
<i style="width: 78%" />
|
|
435
|
+
</div>
|
|
436
|
+
</div>
|
|
437
|
+
</div>
|
|
438
|
+
<div class="info">
|
|
439
|
+
<span class="ic">
|
|
440
|
+
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.7">
|
|
441
|
+
<path d="M4 5a2 2 0 0 1 2-2h9l5 5v11a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2z" />
|
|
442
|
+
<path d="M14 3v5h5" />
|
|
443
|
+
</svg>
|
|
444
|
+
</span>
|
|
445
|
+
<h2>Documentation</h2>
|
|
446
|
+
<div class="row">
|
|
447
|
+
<p>
|
|
448
|
+
Schemas, queries, live subscriptions, sharding, and edge deploy — start to finish. New here or coming from Convex or tRPC,
|
|
449
|
+
you'll have a live app fast.
|
|
450
|
+
</p>
|
|
451
|
+
<span class="arrow">
|
|
452
|
+
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
|
|
453
|
+
<path d="M5 12h14M13 6l6 6-6 6" />
|
|
454
|
+
</svg>
|
|
455
|
+
</span>
|
|
456
|
+
</div>
|
|
457
|
+
</div>
|
|
458
|
+
</a>
|
|
459
|
+
|
|
460
|
+
<div class="stack">
|
|
461
|
+
<a class="card mini" href="https://lunora.sh/blog">
|
|
462
|
+
<div class="mc">
|
|
463
|
+
<span class="ic">
|
|
464
|
+
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.7">
|
|
465
|
+
<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" />
|
|
466
|
+
</svg>
|
|
467
|
+
</span>
|
|
468
|
+
<h3>Blog</h3>
|
|
469
|
+
<p>Product updates, deep dives, and what's new in Lunora.</p>
|
|
470
|
+
</div>
|
|
471
|
+
<span class="arrow">
|
|
472
|
+
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
|
|
473
|
+
<path d="M5 12h14M13 6l6 6-6 6" />
|
|
474
|
+
</svg>
|
|
475
|
+
</span>
|
|
476
|
+
</a>
|
|
477
|
+
<a class="card mini" href="/_lunora">
|
|
478
|
+
<div class="mc">
|
|
479
|
+
<span class="ic">
|
|
480
|
+
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.7">
|
|
481
|
+
<rect x="3" y="3" width="18" height="18" rx="1" />
|
|
482
|
+
<path d="M3 9h18M9 21V9" />
|
|
483
|
+
</svg>
|
|
484
|
+
</span>
|
|
485
|
+
<h3>Lunora Studio</h3>
|
|
486
|
+
<p>Local admin for schema, data, logs, and advisors.</p>
|
|
487
|
+
</div>
|
|
488
|
+
<span class="arrow">
|
|
489
|
+
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
|
|
490
|
+
<path d="M5 12h14M13 6l6 6-6 6" />
|
|
491
|
+
</svg>
|
|
492
|
+
</span>
|
|
493
|
+
</a>
|
|
494
|
+
<a class="card mini" href="https://lunora.sh/packages">
|
|
495
|
+
<div class="mc">
|
|
496
|
+
<span class="ic">
|
|
497
|
+
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.7">
|
|
498
|
+
<path d="M12 2 3 7v10l9 5 9-5V7z" />
|
|
499
|
+
<path d="M3 7l9 5 9-5M12 12v10" />
|
|
500
|
+
</svg>
|
|
501
|
+
</span>
|
|
502
|
+
<h3>Cloudflare ecosystem</h3>
|
|
503
|
+
<p>Auth, mail, storage, AI, payments — one deploy.</p>
|
|
504
|
+
</div>
|
|
505
|
+
<span class="arrow">
|
|
506
|
+
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
|
|
507
|
+
<path d="M5 12h14M13 6l6 6-6 6" />
|
|
508
|
+
</svg>
|
|
509
|
+
</span>
|
|
510
|
+
</a>
|
|
511
|
+
</div>
|
|
512
|
+
</div>
|
|
513
|
+
|
|
514
|
+
<div class="lw-foot">Running on Lunora · Vite + Vue</div>
|
|
515
|
+
</div>
|
|
516
|
+
</div>
|
|
517
|
+
</template>
|
|
518
|
+
`,yr=`import { createSignal, onMount } from "solid-js";
|
|
519
|
+
|
|
520
|
+
export default function App() {
|
|
521
|
+
// Default to "dark" for a stable first paint, then reconcile to the OS
|
|
522
|
+
// preference; the toggle takes over after that.
|
|
523
|
+
const [theme, setTheme] = createSignal<"dark" | "light">("dark");
|
|
524
|
+
|
|
525
|
+
onMount(() => {
|
|
526
|
+
if (window.matchMedia("(prefers-color-scheme: light)").matches) {
|
|
527
|
+
setTheme("light");
|
|
528
|
+
}
|
|
529
|
+
});
|
|
530
|
+
|
|
531
|
+
const isLight = () => theme() === "light";
|
|
532
|
+
|
|
533
|
+
return (
|
|
534
|
+
<div class="lunora-welcome" data-theme={theme()}>
|
|
535
|
+
<div class="lw-bg">
|
|
536
|
+
<div class="arc a1" />
|
|
537
|
+
<div class="arc a2" />
|
|
538
|
+
<div class="glow" />
|
|
539
|
+
</div>
|
|
540
|
+
|
|
541
|
+
<button class="lw-toggle" type="button" aria-label="Toggle color theme" onClick={() => setTheme(isLight() ? "dark" : "light")}>
|
|
542
|
+
{isLight() ? (
|
|
543
|
+
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8">
|
|
544
|
+
<path d="M21 12.8A9 9 0 1 1 11.2 3a7 7 0 0 0 9.8 9.8z" />
|
|
545
|
+
</svg>
|
|
546
|
+
) : (
|
|
547
|
+
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8">
|
|
548
|
+
<circle cx="12" cy="12" r="4" />
|
|
549
|
+
<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" />
|
|
550
|
+
</svg>
|
|
551
|
+
)}
|
|
552
|
+
<span>{isLight() ? "Ivory" : "Night"}</span>
|
|
553
|
+
</button>
|
|
554
|
+
|
|
555
|
+
<div class="lw-wrap">
|
|
556
|
+
<div class="brand">
|
|
557
|
+
<svg viewBox="0 0 543 446" role="img" aria-label="Lunora">
|
|
558
|
+
<path d="${I}" fill="currentColor" fill-rule="evenodd" />
|
|
559
|
+
</svg>
|
|
560
|
+
<span class="word">Lunora</span>
|
|
561
|
+
</div>
|
|
562
|
+
|
|
563
|
+
<div class="grid">
|
|
564
|
+
<a class="card feature" href="https://lunora.sh/docs">
|
|
565
|
+
<div class="shot" aria-hidden="true">
|
|
566
|
+
<div class="top">
|
|
567
|
+
<span class="wm">
|
|
568
|
+
<i /> Lunora
|
|
569
|
+
</span>
|
|
570
|
+
<span class="search" />
|
|
571
|
+
<span class="ver">v0.1</span>
|
|
572
|
+
</div>
|
|
573
|
+
<div class="body">
|
|
574
|
+
<div class="nav">
|
|
575
|
+
<i style={{ width: "80%" }} />
|
|
576
|
+
<i style={{ width: "60%" }} />
|
|
577
|
+
<i style={{ width: "72%" }} />
|
|
578
|
+
<i style={{ width: "50%" }} />
|
|
579
|
+
<i style={{ width: "66%" }} />
|
|
580
|
+
<i style={{ width: "44%" }} />
|
|
581
|
+
<i style={{ width: "58%" }} />
|
|
582
|
+
</div>
|
|
583
|
+
<div class="doc">
|
|
584
|
+
<span class="h" />
|
|
585
|
+
<i style={{ width: "92%" }} />
|
|
586
|
+
<i style={{ width: "88%" }} />
|
|
587
|
+
<span class="accent" />
|
|
588
|
+
<i style={{ width: "80%" }} />
|
|
589
|
+
<i style={{ width: "90%" }} />
|
|
590
|
+
<i style={{ width: "72%" }} />
|
|
591
|
+
<i style={{ width: "84%" }} />
|
|
592
|
+
<i style={{ width: "78%" }} />
|
|
593
|
+
</div>
|
|
594
|
+
</div>
|
|
595
|
+
</div>
|
|
596
|
+
<div class="info">
|
|
597
|
+
<span class="ic">
|
|
598
|
+
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.7">
|
|
599
|
+
<path d="M4 5a2 2 0 0 1 2-2h9l5 5v11a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2z" />
|
|
600
|
+
<path d="M14 3v5h5" />
|
|
601
|
+
</svg>
|
|
602
|
+
</span>
|
|
603
|
+
<h2>Documentation</h2>
|
|
604
|
+
<div class="row">
|
|
605
|
+
<p>
|
|
606
|
+
Schemas, queries, live subscriptions, sharding, and edge deploy — start to finish. New here or coming from Convex or tRPC,
|
|
607
|
+
you'll have a live app fast.
|
|
608
|
+
</p>
|
|
609
|
+
<span class="arrow">
|
|
610
|
+
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
|
|
611
|
+
<path d="M5 12h14M13 6l6 6-6 6" />
|
|
612
|
+
</svg>
|
|
613
|
+
</span>
|
|
614
|
+
</div>
|
|
615
|
+
</div>
|
|
616
|
+
</a>
|
|
617
|
+
|
|
618
|
+
<div class="stack">
|
|
619
|
+
<a class="card mini" href="https://lunora.sh/blog">
|
|
620
|
+
<div class="mc">
|
|
621
|
+
<span class="ic">
|
|
622
|
+
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.7">
|
|
623
|
+
<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" />
|
|
624
|
+
</svg>
|
|
625
|
+
</span>
|
|
626
|
+
<h3>Blog</h3>
|
|
627
|
+
<p>Product updates, deep dives, and what's new in Lunora.</p>
|
|
628
|
+
</div>
|
|
629
|
+
<span class="arrow">
|
|
630
|
+
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
|
|
631
|
+
<path d="M5 12h14M13 6l6 6-6 6" />
|
|
632
|
+
</svg>
|
|
633
|
+
</span>
|
|
634
|
+
</a>
|
|
635
|
+
<a class="card mini" href="/_lunora">
|
|
636
|
+
<div class="mc">
|
|
637
|
+
<span class="ic">
|
|
638
|
+
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.7">
|
|
639
|
+
<rect x="3" y="3" width="18" height="18" rx="1" />
|
|
640
|
+
<path d="M3 9h18M9 21V9" />
|
|
641
|
+
</svg>
|
|
642
|
+
</span>
|
|
643
|
+
<h3>Lunora Studio</h3>
|
|
644
|
+
<p>Local admin for schema, data, logs, and advisors.</p>
|
|
645
|
+
</div>
|
|
646
|
+
<span class="arrow">
|
|
647
|
+
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
|
|
648
|
+
<path d="M5 12h14M13 6l6 6-6 6" />
|
|
649
|
+
</svg>
|
|
650
|
+
</span>
|
|
651
|
+
</a>
|
|
652
|
+
<a class="card mini" href="https://lunora.sh/packages">
|
|
653
|
+
<div class="mc">
|
|
654
|
+
<span class="ic">
|
|
655
|
+
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.7">
|
|
656
|
+
<path d="M12 2 3 7v10l9 5 9-5V7z" />
|
|
657
|
+
<path d="M3 7l9 5 9-5M12 12v10" />
|
|
658
|
+
</svg>
|
|
659
|
+
</span>
|
|
660
|
+
<h3>Cloudflare ecosystem</h3>
|
|
661
|
+
<p>Auth, mail, storage, AI, payments — one deploy.</p>
|
|
662
|
+
</div>
|
|
663
|
+
<span class="arrow">
|
|
664
|
+
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
|
|
665
|
+
<path d="M5 12h14M13 6l6 6-6 6" />
|
|
666
|
+
</svg>
|
|
667
|
+
</span>
|
|
668
|
+
</a>
|
|
669
|
+
</div>
|
|
670
|
+
</div>
|
|
671
|
+
|
|
672
|
+
<div class="lw-foot">Running on Lunora · Vite + Solid</div>
|
|
673
|
+
</div>
|
|
674
|
+
</div>
|
|
675
|
+
);
|
|
676
|
+
}
|
|
677
|
+
`,br=`<script lang="ts">
|
|
678
|
+
import { onMount } from "svelte";
|
|
679
|
+
|
|
680
|
+
// Default to "dark" for a stable first paint, then reconcile to the OS
|
|
681
|
+
// preference; the toggle takes over after that.
|
|
682
|
+
let theme = $state<"dark" | "light">("dark");
|
|
683
|
+
const isLight = $derived(theme === "light");
|
|
684
|
+
|
|
685
|
+
onMount(() => {
|
|
686
|
+
if (window.matchMedia("(prefers-color-scheme: light)").matches) {
|
|
687
|
+
theme = "light";
|
|
688
|
+
}
|
|
689
|
+
});
|
|
690
|
+
|
|
691
|
+
const toggle = (): void => {
|
|
692
|
+
theme = theme === "light" ? "dark" : "light";
|
|
693
|
+
};
|
|
694
|
+
<\/script>
|
|
695
|
+
|
|
696
|
+
<div class="lunora-welcome" data-theme={theme}>
|
|
697
|
+
<div class="lw-bg">
|
|
698
|
+
<div class="arc a1"></div>
|
|
699
|
+
<div class="arc a2"></div>
|
|
700
|
+
<div class="glow"></div>
|
|
701
|
+
</div>
|
|
702
|
+
|
|
703
|
+
<button class="lw-toggle" type="button" aria-label="Toggle color theme" onclick={toggle}>
|
|
704
|
+
{#if isLight}
|
|
705
|
+
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8">
|
|
706
|
+
<path d="M21 12.8A9 9 0 1 1 11.2 3a7 7 0 0 0 9.8 9.8z" />
|
|
707
|
+
</svg>
|
|
708
|
+
{:else}
|
|
709
|
+
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8">
|
|
710
|
+
<circle cx="12" cy="12" r="4" />
|
|
711
|
+
<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" />
|
|
712
|
+
</svg>
|
|
713
|
+
{/if}
|
|
714
|
+
<span>{isLight ? "Ivory" : "Night"}</span>
|
|
715
|
+
</button>
|
|
716
|
+
|
|
717
|
+
<div class="lw-wrap">
|
|
718
|
+
<div class="brand">
|
|
719
|
+
<svg viewBox="0 0 543 446" role="img" aria-label="Lunora">
|
|
720
|
+
<path d="${I}" fill="currentColor" fill-rule="evenodd" />
|
|
721
|
+
</svg>
|
|
722
|
+
<span class="word">Lunora</span>
|
|
723
|
+
</div>
|
|
724
|
+
|
|
725
|
+
<div class="grid">
|
|
726
|
+
<a class="card feature" href="https://lunora.sh/docs">
|
|
727
|
+
<div class="shot" aria-hidden="true">
|
|
728
|
+
<div class="top">
|
|
729
|
+
<span class="wm"><i></i> Lunora</span>
|
|
730
|
+
<span class="search"></span>
|
|
731
|
+
<span class="ver">v0.1</span>
|
|
732
|
+
</div>
|
|
733
|
+
<div class="body">
|
|
734
|
+
<div class="nav">
|
|
735
|
+
<i style="width: 80%"></i>
|
|
736
|
+
<i style="width: 60%"></i>
|
|
737
|
+
<i style="width: 72%"></i>
|
|
738
|
+
<i style="width: 50%"></i>
|
|
739
|
+
<i style="width: 66%"></i>
|
|
740
|
+
<i style="width: 44%"></i>
|
|
741
|
+
<i style="width: 58%"></i>
|
|
742
|
+
</div>
|
|
743
|
+
<div class="doc">
|
|
744
|
+
<span class="h"></span>
|
|
745
|
+
<i style="width: 92%"></i>
|
|
746
|
+
<i style="width: 88%"></i>
|
|
747
|
+
<span class="accent"></span>
|
|
748
|
+
<i style="width: 80%"></i>
|
|
749
|
+
<i style="width: 90%"></i>
|
|
750
|
+
<i style="width: 72%"></i>
|
|
751
|
+
<i style="width: 84%"></i>
|
|
752
|
+
<i style="width: 78%"></i>
|
|
753
|
+
</div>
|
|
754
|
+
</div>
|
|
755
|
+
</div>
|
|
756
|
+
<div class="info">
|
|
757
|
+
<span class="ic">
|
|
758
|
+
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.7">
|
|
759
|
+
<path d="M4 5a2 2 0 0 1 2-2h9l5 5v11a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2z" />
|
|
760
|
+
<path d="M14 3v5h5" />
|
|
761
|
+
</svg>
|
|
762
|
+
</span>
|
|
763
|
+
<h2>Documentation</h2>
|
|
764
|
+
<div class="row">
|
|
765
|
+
<p>
|
|
766
|
+
Schemas, queries, live subscriptions, sharding, and edge deploy — start to finish. New here or coming from Convex or tRPC,
|
|
767
|
+
you'll have a live app fast.
|
|
768
|
+
</p>
|
|
769
|
+
<span class="arrow">
|
|
770
|
+
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
|
|
771
|
+
<path d="M5 12h14M13 6l6 6-6 6" />
|
|
772
|
+
</svg>
|
|
773
|
+
</span>
|
|
774
|
+
</div>
|
|
775
|
+
</div>
|
|
776
|
+
</a>
|
|
777
|
+
|
|
778
|
+
<div class="stack">
|
|
779
|
+
<a class="card mini" href="https://lunora.sh/blog">
|
|
780
|
+
<div class="mc">
|
|
781
|
+
<span class="ic">
|
|
782
|
+
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.7">
|
|
783
|
+
<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" />
|
|
784
|
+
</svg>
|
|
785
|
+
</span>
|
|
786
|
+
<h3>Blog</h3>
|
|
787
|
+
<p>Product updates, deep dives, and what's new in Lunora.</p>
|
|
788
|
+
</div>
|
|
789
|
+
<span class="arrow">
|
|
790
|
+
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
|
|
791
|
+
<path d="M5 12h14M13 6l6 6-6 6" />
|
|
792
|
+
</svg>
|
|
793
|
+
</span>
|
|
794
|
+
</a>
|
|
795
|
+
<a class="card mini" href="/_lunora">
|
|
796
|
+
<div class="mc">
|
|
797
|
+
<span class="ic">
|
|
798
|
+
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.7">
|
|
799
|
+
<rect x="3" y="3" width="18" height="18" rx="1" />
|
|
800
|
+
<path d="M3 9h18M9 21V9" />
|
|
801
|
+
</svg>
|
|
802
|
+
</span>
|
|
803
|
+
<h3>Lunora Studio</h3>
|
|
804
|
+
<p>Local admin for schema, data, logs, and advisors.</p>
|
|
805
|
+
</div>
|
|
806
|
+
<span class="arrow">
|
|
807
|
+
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
|
|
808
|
+
<path d="M5 12h14M13 6l6 6-6 6" />
|
|
809
|
+
</svg>
|
|
810
|
+
</span>
|
|
811
|
+
</a>
|
|
812
|
+
<a class="card mini" href="https://lunora.sh/packages">
|
|
813
|
+
<div class="mc">
|
|
814
|
+
<span class="ic">
|
|
815
|
+
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.7">
|
|
816
|
+
<path d="M12 2 3 7v10l9 5 9-5V7z" />
|
|
817
|
+
<path d="M3 7l9 5 9-5M12 12v10" />
|
|
818
|
+
</svg>
|
|
819
|
+
</span>
|
|
820
|
+
<h3>Cloudflare ecosystem</h3>
|
|
821
|
+
<p>Auth, mail, storage, AI, payments — one deploy.</p>
|
|
822
|
+
</div>
|
|
823
|
+
<span class="arrow">
|
|
824
|
+
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
|
|
825
|
+
<path d="M5 12h14M13 6l6 6-6 6" />
|
|
826
|
+
</svg>
|
|
827
|
+
</span>
|
|
828
|
+
</a>
|
|
829
|
+
</div>
|
|
830
|
+
</div>
|
|
831
|
+
|
|
832
|
+
<div class="lw-foot">Running on Lunora · Vite + Svelte</div>
|
|
833
|
+
</div>
|
|
834
|
+
</div>
|
|
835
|
+
`,xr=`import "./style.css";
|
|
836
|
+
|
|
837
|
+
import { LunoraClient } from "lunorash/client";
|
|
838
|
+
|
|
839
|
+
import { api } from "#lunora/_generated/api.js";
|
|
840
|
+
|
|
841
|
+
// \`@lunora/vite\` runs the Worker on the same origin as Vite, so default to
|
|
842
|
+
// \`location.origin\`. Point \`VITE_LUNORA_URL\` at a deployed Worker to develop
|
|
843
|
+
// the client against production data.
|
|
844
|
+
const url = (import.meta.env.VITE_LUNORA_URL as string | undefined) ?? globalThis.location.origin;
|
|
845
|
+
const client = new LunoraClient({ url });
|
|
846
|
+
|
|
847
|
+
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>';
|
|
848
|
+
const SUN_ICON =
|
|
849
|
+
'<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>';
|
|
850
|
+
|
|
851
|
+
const welcomeHtml = \`
|
|
852
|
+
<div class="lw-bg">
|
|
853
|
+
<div class="arc a1"></div>
|
|
854
|
+
<div class="arc a2"></div>
|
|
855
|
+
<div class="glow"></div>
|
|
856
|
+
</div>
|
|
857
|
+
|
|
858
|
+
<button class="lw-toggle" type="button" aria-label="Toggle color theme"></button>
|
|
859
|
+
|
|
860
|
+
<div class="lw-wrap">
|
|
861
|
+
<div class="brand">
|
|
862
|
+
<svg viewBox="0 0 543 446" role="img" aria-label="Lunora">
|
|
863
|
+
<path d="${I}" fill="currentColor" fill-rule="evenodd" />
|
|
864
|
+
</svg>
|
|
865
|
+
<span class="word">Lunora</span>
|
|
866
|
+
</div>
|
|
867
|
+
|
|
868
|
+
<div class="grid">
|
|
869
|
+
<a class="card feature" href="https://lunora.sh/docs">
|
|
870
|
+
<div class="shot" aria-hidden="true">
|
|
871
|
+
<div class="top">
|
|
872
|
+
<span class="wm"><i></i> Lunora</span>
|
|
873
|
+
<span class="search"></span>
|
|
874
|
+
<span class="ver">v0.1</span>
|
|
875
|
+
</div>
|
|
876
|
+
<div class="body">
|
|
877
|
+
<div class="nav">
|
|
878
|
+
<i style="width: 80%"></i>
|
|
879
|
+
<i style="width: 60%"></i>
|
|
880
|
+
<i style="width: 72%"></i>
|
|
881
|
+
<i style="width: 50%"></i>
|
|
882
|
+
<i style="width: 66%"></i>
|
|
883
|
+
<i style="width: 44%"></i>
|
|
884
|
+
<i style="width: 58%"></i>
|
|
885
|
+
</div>
|
|
886
|
+
<div class="doc">
|
|
887
|
+
<span class="h"></span>
|
|
888
|
+
<i style="width: 92%"></i>
|
|
889
|
+
<i style="width: 88%"></i>
|
|
890
|
+
<span class="accent"></span>
|
|
891
|
+
<i style="width: 80%"></i>
|
|
892
|
+
<i style="width: 90%"></i>
|
|
893
|
+
<i style="width: 72%"></i>
|
|
894
|
+
<i style="width: 84%"></i>
|
|
895
|
+
<i style="width: 78%"></i>
|
|
896
|
+
</div>
|
|
897
|
+
</div>
|
|
898
|
+
</div>
|
|
899
|
+
<div class="info">
|
|
900
|
+
<span class="ic">
|
|
901
|
+
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.7">
|
|
902
|
+
<path d="M4 5a2 2 0 0 1 2-2h9l5 5v11a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2z" />
|
|
903
|
+
<path d="M14 3v5h5" />
|
|
904
|
+
</svg>
|
|
905
|
+
</span>
|
|
906
|
+
<h2>Documentation</h2>
|
|
907
|
+
<div class="row">
|
|
908
|
+
<p>
|
|
909
|
+
Schemas, queries, live subscriptions, sharding, and edge deploy — start to finish. New here or coming from Convex or tRPC,
|
|
910
|
+
you'll have a live app fast.
|
|
911
|
+
</p>
|
|
912
|
+
<span class="arrow">
|
|
913
|
+
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
|
|
914
|
+
<path d="M5 12h14M13 6l6 6-6 6" />
|
|
915
|
+
</svg>
|
|
916
|
+
</span>
|
|
917
|
+
</div>
|
|
918
|
+
</div>
|
|
919
|
+
</a>
|
|
920
|
+
|
|
921
|
+
<div class="stack">
|
|
922
|
+
<a class="card mini" href="https://lunora.sh/blog">
|
|
923
|
+
<div class="mc">
|
|
924
|
+
<span class="ic">
|
|
925
|
+
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.7">
|
|
926
|
+
<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" />
|
|
927
|
+
</svg>
|
|
928
|
+
</span>
|
|
929
|
+
<h3>Blog</h3>
|
|
930
|
+
<p>Product updates, deep dives, and what's new in Lunora.</p>
|
|
931
|
+
</div>
|
|
932
|
+
<span class="arrow">
|
|
933
|
+
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
|
|
934
|
+
<path d="M5 12h14M13 6l6 6-6 6" />
|
|
935
|
+
</svg>
|
|
936
|
+
</span>
|
|
937
|
+
</a>
|
|
938
|
+
<a class="card mini" href="/_lunora">
|
|
939
|
+
<div class="mc">
|
|
940
|
+
<span class="ic">
|
|
941
|
+
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.7">
|
|
942
|
+
<rect x="3" y="3" width="18" height="18" rx="1" />
|
|
943
|
+
<path d="M3 9h18M9 21V9" />
|
|
944
|
+
</svg>
|
|
945
|
+
</span>
|
|
946
|
+
<h3>Lunora Studio</h3>
|
|
947
|
+
<p>Local admin for schema, data, logs, and advisors.</p>
|
|
948
|
+
</div>
|
|
949
|
+
<span class="arrow">
|
|
950
|
+
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
|
|
951
|
+
<path d="M5 12h14M13 6l6 6-6 6" />
|
|
952
|
+
</svg>
|
|
953
|
+
</span>
|
|
954
|
+
</a>
|
|
955
|
+
<a class="card mini" href="https://lunora.sh/packages">
|
|
956
|
+
<div class="mc">
|
|
957
|
+
<span class="ic">
|
|
958
|
+
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.7">
|
|
959
|
+
<path d="M12 2 3 7v10l9 5 9-5V7z" />
|
|
960
|
+
<path d="M3 7l9 5 9-5M12 12v10" />
|
|
961
|
+
</svg>
|
|
962
|
+
</span>
|
|
963
|
+
<h3>Cloudflare ecosystem</h3>
|
|
964
|
+
<p>Auth, mail, storage, AI, payments — one deploy.</p>
|
|
965
|
+
</div>
|
|
966
|
+
<span class="arrow">
|
|
967
|
+
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
|
|
968
|
+
<path d="M5 12h14M13 6l6 6-6 6" />
|
|
969
|
+
</svg>
|
|
970
|
+
</span>
|
|
971
|
+
</a>
|
|
972
|
+
</div>
|
|
973
|
+
</div>
|
|
974
|
+
|
|
975
|
+
<div class="lw-foot">Running on Lunora · Vite + Vanilla · <span id="lw-count">0</span> messages</div>
|
|
976
|
+
</div>
|
|
977
|
+
\`;
|
|
978
|
+
|
|
979
|
+
const root = document.querySelector<HTMLDivElement>("#app")!;
|
|
980
|
+
root.classList.add("lunora-welcome");
|
|
981
|
+
root.innerHTML = welcomeHtml;
|
|
982
|
+
|
|
983
|
+
// Theme toggle: flip the root's data-theme + swap the button's icon/label.
|
|
984
|
+
const toggleButton = root.querySelector<HTMLButtonElement>(".lw-toggle")!;
|
|
985
|
+
|
|
986
|
+
const paintToggle = (theme: "dark" | "light"): void => {
|
|
987
|
+
root.dataset.theme = theme;
|
|
988
|
+
toggleButton.innerHTML = \`\${theme === "light" ? MOON_ICON : SUN_ICON}<span>\${theme === "light" ? "Ivory" : "Night"}</span>\`;
|
|
303
989
|
};
|
|
304
990
|
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
991
|
+
paintToggle(window.matchMedia("(prefers-color-scheme: light)").matches ? "light" : "dark");
|
|
992
|
+
toggleButton.addEventListener("click", () => {
|
|
993
|
+
paintToggle(root.dataset.theme === "light" ? "dark" : "light");
|
|
994
|
+
});
|
|
995
|
+
|
|
996
|
+
// Live demo: the message count of a demo channel re-renders on every delta.
|
|
997
|
+
const count = document.querySelector<HTMLSpanElement>("#lw-count")!;
|
|
998
|
+
|
|
999
|
+
client.subscribe(api.messages.list, { channelId: "channel:demo" }, (result) => {
|
|
1000
|
+
count.textContent = String(result.messages.length);
|
|
1001
|
+
});
|
|
1002
|
+
`,D="const url = (import.meta.env.VITE_LUNORA_URL as string | undefined) ?? globalThis.location.origin;",kr=`import "./index.css";
|
|
1003
|
+
|
|
1004
|
+
import { LunoraProvider } from "@lunora/react";
|
|
1005
|
+
import { LunoraClient } from "lunorash/client";
|
|
1006
|
+
import { StrictMode } from "react";
|
|
1007
|
+
import { createRoot } from "react-dom/client";
|
|
1008
|
+
|
|
1009
|
+
import App from "./App.tsx";
|
|
1010
|
+
|
|
1011
|
+
// \`@lunora/vite\` runs the Worker on the same origin as Vite, so default to
|
|
1012
|
+
// \`location.origin\`. Point \`VITE_LUNORA_URL\` at a deployed Worker to develop
|
|
1013
|
+
// the client against production data.
|
|
1014
|
+
${D}
|
|
1015
|
+
const client = new LunoraClient({ url });
|
|
1016
|
+
|
|
1017
|
+
const root = document.getElementById("root");
|
|
1018
|
+
|
|
1019
|
+
if (!root) {
|
|
1020
|
+
throw new Error("missing #root mount node");
|
|
1021
|
+
}
|
|
1022
|
+
|
|
1023
|
+
createRoot(root).render(
|
|
1024
|
+
<StrictMode>
|
|
1025
|
+
<LunoraProvider client={client}>
|
|
1026
|
+
<App />
|
|
1027
|
+
</LunoraProvider>
|
|
1028
|
+
</StrictMode>,
|
|
1029
|
+
);
|
|
1030
|
+
`,Cr=`import "./style.css";
|
|
1031
|
+
|
|
1032
|
+
import { createLunora } from "@lunora/vue";
|
|
1033
|
+
import { LunoraClient } from "lunorash/client";
|
|
1034
|
+
import { createApp } from "vue";
|
|
1035
|
+
|
|
1036
|
+
import App from "./App.vue";
|
|
1037
|
+
|
|
1038
|
+
// Provide one LunoraClient at the app root via the Vue plugin form.
|
|
1039
|
+
${D}
|
|
1040
|
+
createApp(App).use(createLunora(new LunoraClient({ url }))).mount("#app");
|
|
1041
|
+
`,Sr=`import "./index.css";
|
|
1042
|
+
|
|
1043
|
+
import { LunoraProvider } from "@lunora/solid";
|
|
1044
|
+
import { LunoraClient } from "lunorash/client";
|
|
1045
|
+
import { render } from "solid-js/web";
|
|
1046
|
+
|
|
1047
|
+
import App from "./App";
|
|
1048
|
+
|
|
1049
|
+
${D}
|
|
1050
|
+
const client = new LunoraClient({ url });
|
|
1051
|
+
const root = document.getElementById("root");
|
|
1052
|
+
|
|
1053
|
+
render(
|
|
1054
|
+
() => (
|
|
1055
|
+
<LunoraProvider client={client}>
|
|
1056
|
+
<App />
|
|
1057
|
+
</LunoraProvider>
|
|
1058
|
+
),
|
|
1059
|
+
root!,
|
|
1060
|
+
);
|
|
1061
|
+
`,Lr=`<script lang="ts">
|
|
1062
|
+
import { setLunoraClient } from "@lunora/svelte";
|
|
1063
|
+
import { LunoraClient } from "lunorash/client";
|
|
1064
|
+
|
|
1065
|
+
import App from "./App.svelte";
|
|
1066
|
+
|
|
1067
|
+
${D}
|
|
1068
|
+
setLunoraClient(new LunoraClient({ url }));
|
|
1069
|
+
<\/script>
|
|
1070
|
+
|
|
1071
|
+
<App />
|
|
1072
|
+
`,Mr=`import "./app.css";
|
|
1073
|
+
|
|
1074
|
+
import { mount } from "svelte";
|
|
1075
|
+
|
|
1076
|
+
import Root from "./Root.svelte";
|
|
1077
|
+
|
|
1078
|
+
// Mount \`Root\` (it sets the ambient LunoraClient) rather than \`App\` directly.
|
|
1079
|
+
const app = mount(Root, { target: document.getElementById("app")! });
|
|
1080
|
+
|
|
1081
|
+
export default app;
|
|
1082
|
+
`,B={react:{adapter:"@lunora/react",createViteTemplate:"react-ts",files:[{contents:kr,path:"src/main.tsx"},{contents:vr,path:"src/App.tsx"},{contents:E,path:"src/index.css"}],label:"React"},solid:{adapter:"@lunora/solid",createViteTemplate:"solid-ts",files:[{contents:Sr,path:"src/index.tsx"},{contents:yr,path:"src/App.tsx"},{contents:E,path:"src/index.css"}],label:"Solid"},svelte:{adapter:"@lunora/svelte",createViteTemplate:"svelte-ts",files:[{contents:Lr,path:"src/Root.svelte"},{contents:Mr,path:"src/main.ts"},{contents:br,path:"src/App.svelte"},{contents:E,path:"src/app.css"}],label:"Svelte"},vanilla:{adapter:"lunorash/client",createViteTemplate:"vanilla-ts",files:[{contents:xr,path:"src/main.ts"},{contents:E,path:"src/style.css"}],label:"Vanilla"},vue:{adapter:"@lunora/vue",createViteTemplate:"vue-ts",files:[{contents:Cr,path:"src/main.ts"},{contents:wr,path:"src/App.vue"},{contents:E,path:"src/style.css"}],label:"Vue"}},j=e=>Object.hasOwn(B,e),Ar=`/**
|
|
1083
|
+
* Rate-limit schema extension + plugin.
|
|
1084
|
+
*
|
|
1085
|
+
* Defines the \`ratelimit_buckets\` table used by \`createDbStore\` for durable,
|
|
1086
|
+
* DO-backed rate limiting. Included automatically in every Lunora project.
|
|
1087
|
+
*/
|
|
1088
|
+
import type { Middleware } from "lunorash/server";
|
|
1089
|
+
import { defineSchemaExtension, defineTable, definePlugin, v } from "lunorash/server";
|
|
1090
|
+
import { createDbStore, RateLimiter } from "lunorash/ratelimit";
|
|
1091
|
+
import type { RateLimitConfigMap } from "lunorash/ratelimit";
|
|
1092
|
+
|
|
1093
|
+
/**
|
|
1094
|
+
* Named limits this app enforces. This is the one place they live — add your own
|
|
1095
|
+
* and reference them by name from \`rateLimit(limiter, "<name>", …)\` (see
|
|
1096
|
+
* \`lunora/messages.ts\`).
|
|
1097
|
+
*/
|
|
1098
|
+
export const limits = {
|
|
1099
|
+
/** Chat writes: 30 per caller per minute, refilling continuously over 60s. */
|
|
1100
|
+
send: { kind: "token bucket", period: 60_000, rate: 30 },
|
|
1101
|
+
} as const satisfies RateLimitConfigMap;
|
|
1102
|
+
|
|
1103
|
+
export type LimitName = keyof typeof limits;
|
|
1104
|
+
|
|
1105
|
+
export const makeRateLimiter = (ctx: { db: unknown }): RateLimiter<LimitName> =>
|
|
1106
|
+
new RateLimiter<LimitName>({
|
|
1107
|
+
config: limits,
|
|
1108
|
+
store: createDbStore({ db: ctx.db as never, table: "ratelimit_buckets" }),
|
|
1109
|
+
});
|
|
1110
|
+
|
|
1111
|
+
const middleware: Middleware<{ api?: Record<string, unknown>; db: unknown }, { api: Record<string, unknown>; db: unknown }> = ({ ctx, next }) =>
|
|
1112
|
+
next({
|
|
1113
|
+
ctx: {
|
|
1114
|
+
...ctx,
|
|
1115
|
+
api: { ...ctx.api, ratelimit: makeRateLimiter(ctx) },
|
|
1116
|
+
},
|
|
1117
|
+
});
|
|
1118
|
+
|
|
1119
|
+
export const ratelimit = definePlugin("ratelimit", {
|
|
1120
|
+
extension: defineSchemaExtension("ratelimit", {
|
|
1121
|
+
tables: {
|
|
1122
|
+
buckets: defineTable({
|
|
1123
|
+
key: v.string(),
|
|
1124
|
+
value: v.number(),
|
|
1125
|
+
ts: v.number(),
|
|
1126
|
+
prev: v.optional(v.number()),
|
|
1127
|
+
})
|
|
1128
|
+
.index("by_key", ["key"])
|
|
1129
|
+
.index("by_ts", ["ts"])
|
|
1130
|
+
.externallyManaged(),
|
|
1131
|
+
},
|
|
1132
|
+
}),
|
|
1133
|
+
middleware,
|
|
1134
|
+
});
|
|
1135
|
+
`,Er=`import { ratelimit } from "./ratelimit/schema.js";
|
|
1136
|
+
import { defineSchema, defineTable, v } from "lunorash/server";
|
|
1137
|
+
|
|
1138
|
+
export default defineSchema({
|
|
1139
|
+
messages: defineTable({
|
|
1140
|
+
channelId: v.string(),
|
|
1141
|
+
text: v.string(),
|
|
1142
|
+
})
|
|
1143
|
+
.shardBy("channelId")
|
|
1144
|
+
.index("by_channel", ["channelId"]),
|
|
1145
|
+
}).extend(ratelimit.extension);
|
|
1146
|
+
`,Nr=`import { rateLimit } from "lunorash/ratelimit";
|
|
1147
|
+
|
|
1148
|
+
import { makeRateLimiter } from "./ratelimit/schema.js";
|
|
1149
|
+
import type { MutationCtx } from "#lunora/_generated/server.js";
|
|
1150
|
+
import { mutation, query, v } from "#lunora/_generated/server.js";
|
|
1151
|
+
|
|
1152
|
+
/**
|
|
1153
|
+
* The limiter comes from \`lunora/ratelimit/schema.ts\` — that file owns the named
|
|
1154
|
+
* limits and the durable store, so tuning \`send\` there is what changes this
|
|
1155
|
+
* procedure's budget. Build it from the generated \`MutationCtx\` so
|
|
1156
|
+
* \`rateLimit(limiter, …)\` infers the full procedure context: \`ctx.auth\`/\`ctx.ip\`
|
|
1157
|
+
* in the key callback and a typed \`ctx.db\` in the handler both depend on it.
|
|
1158
|
+
*/
|
|
1159
|
+
const limiter = (ctx: MutationCtx) => makeRateLimiter(ctx);
|
|
1160
|
+
|
|
1161
|
+
/**
|
|
1162
|
+
* One bucket per caller, not one bucket for the whole app.
|
|
1163
|
+
*
|
|
1164
|
+
* \`ctx.auth.userId\` is \`null\` until you wire auth (\`lunora registry add auth\`),
|
|
1165
|
+
* so the \`ctx.ip\` fallback is what actually keys the limit in a fresh project.
|
|
1166
|
+
* Keying on \`"anon"\` alone would let one script exhaust the budget for every user.
|
|
1167
|
+
*
|
|
1168
|
+
* \`ctx.ip\` is Cloudflare's server-side \`CF-Connecting-IP\` and is populated ONLY
|
|
1169
|
+
* when the app runs on Cloudflare, where the edge stamps that header over
|
|
1170
|
+
* anything the client sent. Deploy this to another target and \`ctx.ip\` is
|
|
1171
|
+
* \`undefined\` by design — the runtime will not pass on a header the caller can
|
|
1172
|
+
* type — so every anonymous caller falls back to the shared \`"anon"\` bucket.
|
|
1173
|
+
* Off Cloudflare, key on something the caller cannot choose (an API key, a
|
|
1174
|
+
* signed session) before relying on this limit.
|
|
1175
|
+
*/
|
|
1176
|
+
const byCaller = { key: (ctx: { auth: { userId?: null | string }; ip?: string }): string => ctx.auth.userId ?? ctx.ip ?? "anon" };
|
|
1177
|
+
|
|
1178
|
+
export const list = query.input({ channelId: v.string().max(256), limit: v.optional(v.number()) }).query(async ({ args, ctx }) => {
|
|
1179
|
+
const messages = await ctx.db
|
|
1180
|
+
.query("messages")
|
|
1181
|
+
.withIndex("by_channel", (q) => q.eq("channelId", args.channelId))
|
|
1182
|
+
.take(args.limit ?? 50);
|
|
1183
|
+
|
|
1184
|
+
return { channelId: args.channelId, messages };
|
|
1185
|
+
});
|
|
1186
|
+
|
|
1187
|
+
export const send = mutation
|
|
1188
|
+
.input({ channelId: v.string().max(256), text: v.string().max(4096) })
|
|
1189
|
+
.use(rateLimit(limiter, "send", byCaller))
|
|
1190
|
+
.mutation(async ({ args, ctx }) => {
|
|
1191
|
+
const id = await ctx.db.insert("messages", { channelId: args.channelId, text: args.text });
|
|
1192
|
+
|
|
1193
|
+
return { channelId: args.channelId, id, text: args.text };
|
|
1194
|
+
});
|
|
1195
|
+
`,Ir=`import type { ShardNamespaceLike } from "lunorash/runtime";
|
|
1196
|
+
|
|
1197
|
+
import { defineApp } from "../lunora/_generated/app.js";
|
|
1198
|
+
|
|
1199
|
+
interface Env extends Record<string, unknown> {
|
|
1200
|
+
SHARD: ShardNamespaceLike;
|
|
1201
|
+
}
|
|
1202
|
+
|
|
1203
|
+
const app = defineApp<Env>()
|
|
1204
|
+
.shard((env) => env.SHARD)
|
|
1205
|
+
.build();
|
|
1206
|
+
|
|
1207
|
+
export const ShardDO = app.ShardDO;
|
|
1208
|
+
export default app;
|
|
1209
|
+
`,Rr=`{ ${Object.entries(Dt).map(([e,t])=>`${JSON.stringify(e)}: ${JSON.stringify(t)}`).join(", ")} }`,_r=`{
|
|
1210
|
+
"$schema": "node_modules/wrangler/config-schema.json",
|
|
1211
|
+
"name": "__NAME__",
|
|
1212
|
+
"main": "src/server.ts",
|
|
1213
|
+
"compatibility_date": "2026-10-01",
|
|
1214
|
+
"compatibility_flags": ["nodejs_compat"],
|
|
1215
|
+
"durable_objects": {
|
|
1216
|
+
"bindings": [{ "name": "SHARD", "class_name": "ShardDO" }],
|
|
1217
|
+
},
|
|
1218
|
+
"migrations": [{ "tag": "v1", "new_sqlite_classes": ["ShardDO"] }],
|
|
1219
|
+
"observability": ${Rr},
|
|
1220
|
+
}
|
|
1221
|
+
`,oe=[".wrangler",".env",".env.*","!.env.example",".dev.vars",".dev.vars.*","!.dev.vars.example",".lunora/",".lunora-cache","lunora/_generated"],$r=`# Lunora endpoint for the browser client.
|
|
1222
|
+
# Vite statically replaces \`import.meta.env.VITE_LUNORA_URL\` at \`vite dev\` / build.
|
|
1223
|
+
# Leave it unset to use the page origin; set it to point at a deployed Worker:
|
|
1224
|
+
#
|
|
1225
|
+
# VITE_LUNORA_URL=https://my-app.example.workers.dev
|
|
1226
|
+
`,Or={"@cloudflare/workers-types":Z["@cloudflare/workers-types"],wrangler:Z.wrangler},k=(e,t,r,a)=>{const o=p(e,t);M(S(o),{recursive:!0}),w(o,r,"utf8"),a.push(o)},Tr=/\r?\n/,Pr=e=>{const t=p(e,".gitignore"),r=v(t)?T(t,"utf8"):"",a=new Set(r.split(Tr)),o=oe.filter(s=>!a.has(s));if(o.length===0)return;const n=o.some(s=>!s.startsWith("!"))?[...o.filter(s=>!s.startsWith("!")),...oe.filter(s=>s.startsWith("!"))]:o,i=r.length>0&&!r.endsWith(`
|
|
1227
|
+
`)?`
|
|
1228
|
+
`:"";w(t,`${r}${i}
|
|
1229
|
+
# Lunora
|
|
1230
|
+
${n.join(`
|
|
1231
|
+
`)}
|
|
1232
|
+
`,"utf8")},U=e=>e==="lunorash"||e.startsWith("@lunora/"),Dr=(e,t,r,a)=>U(e)?a.get(e)??r:t,C=(e,t,r)=>({...e,[t]:r}),ne=(e,t,r)=>Object.fromEntries(Object.entries(e).map(([a,o])=>[a,Dr(a,o,t,r)])),Br=async(e,t,r,a)=>{const o=p(e,"package.json"),n=it(o);let i=C(n.dependencies??{},"lunorash",a);i=C(i,"@lunora/ratelimit",a),r.adapter.startsWith("@lunora/")&&(i=C(i,r.adapter,a));for(const[u,h]of Object.entries(r.extraDependencies??{}))i=C(i,u,h);let s=C(n.devDependencies??{},"@lunora/vite",a);s=C(s,"@lunora/studio",a);for(const[u,h]of Object.entries(Or))s=C(s,u,h);const l=[...Object.keys(i),...Object.keys(s)].filter(u=>U(u)),c=await ye(l,a);n.name=t,n.imports={...n.imports,"#lunora/*":"./lunora/*"},n.dependencies=ne(i,a,c),n.devDependencies=ne(s,a,c),n.scripts={...n.scripts,codegen:"lunora codegen",deploy:"vite build && lunora deploy"},w(o,`${JSON.stringify(n,void 0,4)}
|
|
1233
|
+
`,"utf8")},jr=["vite.config.ts","vite.config.mts","vite.config.js","vite.config.mjs"],Pe=e=>jr.map(t=>p(e,t)).find(t=>v(t)),Ur=(e,t)=>{const r=Pe(e);if(r===void 0){t.warn("overlay: no vite.config found in the create-vite base — add `lunora()` to your Vite plugins manually.");return}const a=$e(T(r,"utf8"));a.changed&&w(r,a.code,"utf8")},Vr=async e=>{const{adapter:t,distTag:r,logger:a,name:o,target:n}=e,i=[];k(n,p("lunora","ratelimit","schema.ts"),Ar,i),k(n,p("lunora","schema.ts"),Er,i),k(n,p("lunora","messages.ts"),Nr,i),k(n,p("src","server.ts"),Ir,i),k(n,"wrangler.jsonc",_r.replaceAll("__NAME__",o),i),k(n,".env.example",$r,i);for(const s of t.files)k(n,s.path,s.contents,i);return Ur(n,a),await Br(n,o,t,r),Pr(n),i},Fr=["lunar","silver","silent","waning","waxing","crescent","cosmic","stellar","orbital","gibbous","twilight","midnight","shimmering","drifting","weightless"],Wr=["moon","tide","crater","comet","eclipse","halo","orbit","nebula","voyager","lander","rover","beacon","harbor","meadow","fox"],ie=e=>e[Math.floor(Math.random()*e.length)],Hr=()=>`${ie(Fr)}-${ie(Wr)}`,zr=async()=>Bt.lookup("github.com").then(()=>!0,()=>!1),Kr=/^(?:gh|github):([^/]+)\/([^#/]+)(?:\/[^#]*)?(?:#(.+))?$/,De=e=>{const t=Kr.exec(e);if(t===null)return;const[,r,a,o]=t;if(!(r===void 0||a===void 0))return{owner:r,ref:o??"HEAD",repo:a}},qr=async e=>{const t=De(e);if(t===void 0)return;const r=`https://codeload.github.com/${t.owner}/${t.repo}/tar.gz/${t.ref}`;try{const a=await fetch(r,{method:"HEAD"});return a.status===404?!1:a.ok?!0:void 0}catch{return}},Be=async e=>e.isLocal||!(e.source===void 0||De(e.source)!==void 0)?!0:await zr()?e.source!==void 0&&await qr(e.source)===!1?(e.logger.error(`template source not found: ${e.source} — double-check --ref / --source, or browse the templates at https://lunora.sh/docs.`),!1):!0:(e.logger.error("you appear to be offline — connect to the internet and try again, or scaffold from a local template with `--from <dir>`."),!1),x={extras:"Let's finish setting up your app.",framework:"Which framework should we launch?",git:"Initialize a new git repository? (optional)",install:"Install dependencies now?",name:"Where should we land your project?",nextHeader:"Liftoff confirmed — explore your project!",packageManager:"Which package manager?"},Gr=new Set([".gitignore",".html",".js",".json",".jsonc",".md",".mjs",".ts",".tsx"]),Yr=`import { defineConfig } from "vite";
|
|
308
1234
|
import { lunora } from "@lunora/vite";
|
|
309
1235
|
|
|
310
1236
|
export default defineConfig({ plugins: [lunora()] });
|
|
311
|
-
|
|
312
|
-
const SAMPLE_SCHEMA = `import { defineSchema, defineTable, v } from "@lunora/server";
|
|
1237
|
+
`,Jr=`import { defineSchema, defineTable, v } from "@lunora/server";
|
|
313
1238
|
|
|
314
1239
|
export default defineSchema({
|
|
315
1240
|
messages: defineTable({
|
|
316
|
-
channelId: v.
|
|
1241
|
+
channelId: v.string(),
|
|
317
1242
|
text: v.string(),
|
|
318
1243
|
})
|
|
319
1244
|
.shardBy("channelId")
|
|
320
1245
|
.index("by_channel", ["channelId"]),
|
|
321
1246
|
});
|
|
322
|
-
|
|
323
|
-
const SAMPLE_FUNCTION = `import { mutation, query, v } from "./_generated/server";
|
|
1247
|
+
`,Xr=`import { mutation, query, v } from "./_generated/server";
|
|
324
1248
|
|
|
325
1249
|
export const list = query
|
|
326
|
-
.input({ channelId: v.
|
|
1250
|
+
.input({ channelId: v.string(), limit: v.optional(v.number()) })
|
|
327
1251
|
.query(async ({ args }) => {
|
|
328
1252
|
return { channelId: args.channelId, limit: args.limit ?? 50, messages: [] };
|
|
329
1253
|
});
|
|
330
1254
|
|
|
331
1255
|
export const send = mutation
|
|
332
|
-
.input({ channelId: v.
|
|
1256
|
+
.input({ channelId: v.string(), text: v.string() })
|
|
333
1257
|
.mutation(async ({ args }) => {
|
|
334
1258
|
return { channelId: args.channelId, text: args.text };
|
|
335
1259
|
});
|
|
336
|
-
|
|
337
|
-
const
|
|
338
|
-
const
|
|
339
|
-
|
|
340
|
-
if (lastDot === -1) {
|
|
341
|
-
return false;
|
|
342
|
-
}
|
|
343
|
-
return TEXT_EXTENSIONS.has(filePath.slice(lastDot));
|
|
344
|
-
};
|
|
345
|
-
const substitute = (content, name) => content.replaceAll("{{name}}", name);
|
|
346
|
-
const isLunoraDep = (name) => name === "lunorash" || name.startsWith("@lunora/");
|
|
347
|
-
const stampLunoraDeps = (packageJsonText, distTag) => {
|
|
348
|
-
let parsed;
|
|
349
|
-
try {
|
|
350
|
-
parsed = JSON.parse(packageJsonText);
|
|
351
|
-
} catch {
|
|
352
|
-
return packageJsonText;
|
|
353
|
-
}
|
|
354
|
-
let text = packageJsonText;
|
|
355
|
-
for (const section of ["dependencies", "devDependencies"]) {
|
|
356
|
-
for (const name of Object.keys(parsed[section] ?? {})) {
|
|
357
|
-
if (!isLunoraDep(name)) {
|
|
358
|
-
continue;
|
|
359
|
-
}
|
|
360
|
-
const edits = modify(text, [section, name], distTag, { formattingOptions: { insertSpaces: true, tabSize: 4 } });
|
|
361
|
-
text = applyEdits(text, edits);
|
|
362
|
-
}
|
|
363
|
-
}
|
|
364
|
-
return text;
|
|
365
|
-
};
|
|
366
|
-
const collectFiles = (directory) => {
|
|
367
|
-
const out = [];
|
|
368
|
-
for (const entry of walkSync(directory, { includeDirs: false, includeFiles: true })) {
|
|
369
|
-
out.push(entry.path);
|
|
370
|
-
}
|
|
371
|
-
return out;
|
|
372
|
-
};
|
|
373
|
-
const copyTemplate = (sourceDirectory, target, name) => {
|
|
374
|
-
const files = collectFiles(sourceDirectory);
|
|
375
|
-
const written = [];
|
|
376
|
-
const distTag = resolveDistTag();
|
|
377
|
-
for (const source of files) {
|
|
378
|
-
const relativePath = relative(sourceDirectory, source);
|
|
379
|
-
const destination = join$1(target, relativePath);
|
|
380
|
-
mkdirSync(dirname$1(destination), { recursive: true });
|
|
381
|
-
const raw = readFileSync(source);
|
|
382
|
-
let text = isTextFile(source) ? substitute(raw.toString("utf8"), name) : void 0;
|
|
383
|
-
if (text !== void 0 && basename(source) === "package.json") {
|
|
384
|
-
text = stampLunoraDeps(text, distTag);
|
|
385
|
-
}
|
|
386
|
-
if (text === void 0) {
|
|
387
|
-
writeFileSync(destination, raw);
|
|
388
|
-
} else {
|
|
389
|
-
writeFileSync(destination, text, "utf8");
|
|
390
|
-
}
|
|
391
|
-
written.push(destination);
|
|
392
|
-
}
|
|
393
|
-
return written;
|
|
394
|
-
};
|
|
395
|
-
const resolveTemplateSource = (templateType, source, ref) => {
|
|
396
|
-
if (source !== void 0 && source.length > 0) {
|
|
397
|
-
return source;
|
|
398
|
-
}
|
|
399
|
-
return `${DEFAULT_SOURCE_BASE}/${templateType}#${resolveSourceRef(ref)}`;
|
|
400
|
-
};
|
|
401
|
-
const isSafeSource = (source) => {
|
|
402
|
-
if (source.includes("..")) {
|
|
403
|
-
return false;
|
|
404
|
-
}
|
|
405
|
-
return source.startsWith("gh:") || source.startsWith("github:") || source.startsWith("https://");
|
|
406
|
-
};
|
|
407
|
-
const logScaffoldSuccess = (logger, written, target, name) => {
|
|
408
|
-
logger.success(`scaffolded ${String(written.length)} files into ${target}`);
|
|
409
|
-
logger.info("next steps:");
|
|
410
|
-
logger.info(` cd ${name}`);
|
|
411
|
-
logger.info(" pnpm install");
|
|
412
|
-
logger.info(" pnpm dev");
|
|
413
|
-
};
|
|
414
|
-
const scaffoldFromLocal = (fromRoot, templateType, target, name, logger) => {
|
|
415
|
-
const templateDirectory = join$1(fromRoot, templateType);
|
|
416
|
-
if (!existsSync(templateDirectory)) {
|
|
417
|
-
logger.error(`template not found in local source: ${templateDirectory}`);
|
|
418
|
-
return { code: 1, files: [], target };
|
|
419
|
-
}
|
|
420
|
-
const written = copyTemplate(templateDirectory, target, name);
|
|
421
|
-
logScaffoldSuccess(logger, written, target, name);
|
|
422
|
-
return { code: 0, files: written, target };
|
|
423
|
-
};
|
|
424
|
-
const scaffoldFromRemote = async (options) => {
|
|
425
|
-
const { logger, name, ref, source, target, templateType } = options;
|
|
426
|
-
const stagingRoot = mkdtempSync(join$1(tmpdir(), "lunora-init-fetch-"));
|
|
427
|
-
const stagingDirectory = join$1(stagingRoot, "template");
|
|
428
|
-
try {
|
|
429
|
-
const remote = resolveTemplateSource(templateType, source, ref);
|
|
430
|
-
logger.info(`fetching template from ${remote}`);
|
|
431
|
-
const downloaded = await downloadTemplate(remote, {
|
|
432
|
-
cwd: stagingRoot,
|
|
433
|
-
dir: stagingDirectory,
|
|
434
|
-
force: true,
|
|
435
|
-
install: false,
|
|
436
|
-
silent: true
|
|
437
|
-
});
|
|
438
|
-
const staged = collectFiles(stagingDirectory);
|
|
439
|
-
if (downloaded.commit) {
|
|
440
|
-
logger.info(`resolved ${downloaded.source} @ ${downloaded.commit} (${String(staged.length)} file(s))`);
|
|
441
|
-
} else {
|
|
442
|
-
logger.info(`resolved ${downloaded.source} (${String(staged.length)} file(s))`);
|
|
443
|
-
}
|
|
444
|
-
const written = copyTemplate(stagingDirectory, target, name);
|
|
445
|
-
logScaffoldSuccess(logger, written, target, name);
|
|
446
|
-
return { code: 0, files: written, target };
|
|
447
|
-
} catch (error) {
|
|
448
|
-
const message = error instanceof Error ? error.message : String(error);
|
|
449
|
-
logger.error(`failed to download template: ${message}`);
|
|
450
|
-
return { code: 1, files: [], target };
|
|
451
|
-
} finally {
|
|
452
|
-
rmSync(stagingRoot, { force: true, recursive: true });
|
|
453
|
-
}
|
|
454
|
-
};
|
|
455
|
-
const createMinimalViteConfig = (cwd, logger) => {
|
|
456
|
-
const target = join$1(cwd, "vite.config.ts");
|
|
457
|
-
try {
|
|
458
|
-
writeFileSync(target, MINIMAL_VITE_CONFIG, "utf8");
|
|
459
|
-
} catch (error) {
|
|
460
|
-
const message = error instanceof Error ? error.message : String(error);
|
|
461
|
-
logger.error(`init --in-place: could not write ${target}: ${message}`);
|
|
462
|
-
return { code: 1, files: [], target: cwd };
|
|
463
|
-
}
|
|
464
|
-
logger.success(`created ${target} with lunora() plugin`);
|
|
465
|
-
return { code: 0, files: [target], target: cwd };
|
|
466
|
-
};
|
|
467
|
-
const patchExistingViteConfig = (viteConfigPath, cwd, logger) => {
|
|
468
|
-
let source;
|
|
469
|
-
try {
|
|
470
|
-
source = readFileSync(viteConfigPath, "utf8");
|
|
471
|
-
} catch (error) {
|
|
472
|
-
const message = error instanceof Error ? error.message : String(error);
|
|
473
|
-
logger.error(`init --in-place: could not read ${viteConfigPath}: ${message}`);
|
|
474
|
-
return { code: 1, files: [], target: cwd };
|
|
475
|
-
}
|
|
476
|
-
const result = patchViteConfig(source);
|
|
477
|
-
if (!result.changed) {
|
|
478
|
-
logger.info(`${viteConfigPath}: ${result.reason ?? "no changes needed"}`);
|
|
479
|
-
return { code: 0, files: [], target: cwd };
|
|
480
|
-
}
|
|
481
|
-
try {
|
|
482
|
-
writeFileSync(viteConfigPath, result.code, "utf8");
|
|
483
|
-
} catch (error) {
|
|
484
|
-
const message = error instanceof Error ? error.message : String(error);
|
|
485
|
-
logger.error(`init --in-place: could not write ${viteConfigPath}: ${message}`);
|
|
486
|
-
return { code: 1, files: [], target: cwd };
|
|
487
|
-
}
|
|
488
|
-
logger.success(`patched ${viteConfigPath} — added lunora() plugin`);
|
|
489
|
-
return { code: 0, files: [viteConfigPath], target: cwd };
|
|
490
|
-
};
|
|
491
|
-
const scaffoldLunoraDirectory = (cwd, logger) => {
|
|
492
|
-
const lunoraDirectory = join$1(cwd, "lunora");
|
|
493
|
-
const schemaPath = join$1(lunoraDirectory, "schema.ts");
|
|
494
|
-
if (existsSync(schemaPath)) {
|
|
495
|
-
logger.info(`lunora/ already present — left ${schemaPath} untouched`);
|
|
496
|
-
return [];
|
|
497
|
-
}
|
|
498
|
-
const written = [];
|
|
499
|
-
try {
|
|
500
|
-
mkdirSync(lunoraDirectory, { recursive: true });
|
|
501
|
-
writeFileSync(schemaPath, SAMPLE_SCHEMA, "utf8");
|
|
502
|
-
written.push(schemaPath);
|
|
503
|
-
const functionPath = join$1(lunoraDirectory, "messages.ts");
|
|
504
|
-
if (!existsSync(functionPath)) {
|
|
505
|
-
writeFileSync(functionPath, SAMPLE_FUNCTION, "utf8");
|
|
506
|
-
written.push(functionPath);
|
|
507
|
-
}
|
|
508
|
-
logger.success(`scaffolded lunora/ (${String(written.length)} file(s))`);
|
|
509
|
-
} catch (error) {
|
|
510
|
-
const message = error instanceof Error ? error.message : String(error);
|
|
511
|
-
logger.error(`init --here: could not scaffold lunora/: ${message}`);
|
|
512
|
-
}
|
|
513
|
-
return written;
|
|
514
|
-
};
|
|
515
|
-
const printFrameworkNextSteps = (detection, logger) => {
|
|
516
|
-
const { adapter, class: frameworkClass, framework } = detection;
|
|
517
|
-
logger.info("");
|
|
518
|
-
logger.info(`detected framework: ${framework} (class ${frameworkClass})`);
|
|
519
|
-
logger.info("next steps:");
|
|
520
|
-
logger.info(` 1. install the adapter: pnpm add ${adapter} @lunora/client @lunora/runtime @lunora/server`);
|
|
521
|
-
logger.info(" 2. run codegen: lunora codegen");
|
|
522
|
-
if (frameworkClass === "A") {
|
|
523
|
-
logger.info(" 3. compose one worker: wrap your worker entry with");
|
|
524
|
-
logger.info(" createWorker({ httpRouter: <your framework SSR handler>, shardDO: ShardDO, ... })");
|
|
525
|
-
logger.info(` 4. add the provider: mount the ${adapter} provider in your root layout/route`);
|
|
526
|
-
logger.info(" 5. make a loader live: preloadQuery() in a loader, usePreloadedQuery() in the component");
|
|
527
|
-
logger.info(" see https://lunora.sh/docs/frameworks/reactive-loaders");
|
|
528
|
-
} else if (frameworkClass === "B") {
|
|
529
|
-
logger.info(" 3. inject Lunora: mount Lunora realtime under /_lunora/* in your server hook");
|
|
530
|
-
logger.info(` (${framework} owns its Cloudflare adapter — Lunora composes into its server entry)`);
|
|
531
|
-
logger.info(` 4. add the provider: mount the ${adapter} provider in your root layout`);
|
|
532
|
-
logger.info(" 5. read the guide: https://lunora.sh/docs/frameworks/deploy");
|
|
533
|
-
} else {
|
|
534
|
-
logger.info(" 3. add the provider: wrap your app with the LunoraProvider from @lunora/react");
|
|
535
|
-
logger.info(" 4. read the guide: https://lunora.sh/docs/frameworks/bring-your-framework");
|
|
536
|
-
}
|
|
537
|
-
logger.info("");
|
|
538
|
-
};
|
|
539
|
-
const findExistingViteConfig = (cwd) => {
|
|
540
|
-
for (const candidate of VITE_CONFIG_CANDIDATES) {
|
|
541
|
-
const full = join$1(cwd, candidate);
|
|
542
|
-
if (existsSync(full)) {
|
|
543
|
-
return full;
|
|
544
|
-
}
|
|
545
|
-
}
|
|
546
|
-
return void 0;
|
|
547
|
-
};
|
|
548
|
-
const patchOrCreateViteConfig = (cwd, framework, logger) => {
|
|
549
|
-
const viteConfigPath = findExistingViteConfig(cwd);
|
|
550
|
-
if (viteConfigPath === void 0) {
|
|
551
|
-
if (framework === "sveltekit" || framework === "nuxt" || framework === "astro") {
|
|
552
|
-
logger.info(`no Vite config found — ${framework} wires Lunora through its server entry (see next steps)`);
|
|
553
|
-
return { code: 0, files: [], target: cwd };
|
|
554
|
-
}
|
|
555
|
-
return createMinimalViteConfig(cwd, logger);
|
|
556
|
-
}
|
|
557
|
-
return patchExistingViteConfig(viteConfigPath, cwd, logger);
|
|
558
|
-
};
|
|
559
|
-
const runInPlaceInit = (cwd, logger) => {
|
|
560
|
-
const detection = detectFramework(cwd);
|
|
561
|
-
const viteResult = patchOrCreateViteConfig(cwd, detection.framework, logger);
|
|
562
|
-
if (viteResult.code !== 0) {
|
|
563
|
-
return viteResult;
|
|
564
|
-
}
|
|
565
|
-
const scaffolded = scaffoldLunoraDirectory(cwd, logger);
|
|
566
|
-
printFrameworkNextSteps(detection, logger);
|
|
567
|
-
return { code: 0, files: [...viteResult.files, ...scaffolded], target: cwd };
|
|
568
|
-
};
|
|
569
|
-
const offerIsInteractive = (options) => options.yes !== true && (options.prompt !== void 0 || (options.interactive ?? isInteractive()));
|
|
570
|
-
const maybeOfferExtras = async (options, projectDirectory) => {
|
|
571
|
-
const interactive = offerIsInteractive(options);
|
|
572
|
-
const apply = async (names) => {
|
|
573
|
-
const result = await runAddCommand({
|
|
574
|
-
allowUnsafeSource: options.allowUnsafeSource,
|
|
575
|
-
cwd: projectDirectory,
|
|
576
|
-
from: options.registryFrom,
|
|
577
|
-
logger: options.logger,
|
|
578
|
-
names: [...names],
|
|
579
|
-
ref: options.ref,
|
|
580
|
-
source: options.registrySource,
|
|
581
|
-
yes: true
|
|
582
|
-
});
|
|
583
|
-
return result.code === 0;
|
|
584
|
-
};
|
|
585
|
-
await offerRegistryExtras({
|
|
586
|
-
apply,
|
|
587
|
-
interactive,
|
|
588
|
-
logger: options.logger,
|
|
589
|
-
multiSelect: options.prompt?.multiSelect ?? ((message, choices, settings) => promptMultiSelect(message, choices, settings)),
|
|
590
|
-
select: options.prompt?.select ?? ((message, choices, settings) => promptSelect(message, choices, settings))
|
|
591
|
-
});
|
|
592
|
-
};
|
|
593
|
-
const scaffoldNewProject = async (options, cwd) => {
|
|
594
|
-
const name = options.name ?? "lunora-app";
|
|
595
|
-
const templateType = options.templateType ?? "vite";
|
|
596
|
-
if (templateType === "next") {
|
|
597
|
-
options.logger.warn('template "next" is not yet available — re-run with `-t vite` or `-t standalone`.');
|
|
598
|
-
return { code: 1, files: [], target: "" };
|
|
599
|
-
}
|
|
600
|
-
if (name.includes("/") || name.includes("\\") || name === ".." || name === ".") {
|
|
601
|
-
options.logger.error(`init: refusing project name "${name}" — must not contain path separators or be "." / "..".`);
|
|
602
|
-
return { code: 1, files: [], target: "" };
|
|
603
|
-
}
|
|
604
|
-
const target = resolve(cwd, name);
|
|
605
|
-
if (existsSync(target)) {
|
|
606
|
-
const entries = readdirSync(target);
|
|
607
|
-
if (entries.length > 0) {
|
|
608
|
-
options.logger.error(`target directory not empty: ${target}`);
|
|
609
|
-
return { code: 1, files: [], target };
|
|
610
|
-
}
|
|
611
|
-
}
|
|
612
|
-
if (options.from !== void 0) {
|
|
613
|
-
return scaffoldFromLocal(options.from, templateType, target, name, options.logger);
|
|
614
|
-
}
|
|
615
|
-
if (options.source !== void 0 && options.source.length > 0 && !options.allowUnsafeSource && !isSafeSource(options.source)) {
|
|
616
|
-
options.logger.error(
|
|
617
|
-
`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.`
|
|
618
|
-
);
|
|
619
|
-
return { code: 1, files: [], target };
|
|
620
|
-
}
|
|
621
|
-
return scaffoldFromRemote({ logger: options.logger, name, ref: options.ref, source: options.source, target, templateType });
|
|
622
|
-
};
|
|
623
|
-
const runInitCommand = async (options) => {
|
|
624
|
-
const cwd = options.cwd ?? process.cwd();
|
|
625
|
-
const result = options.inPlace === true ? runInPlaceInit(cwd, options.logger) : await scaffoldNewProject(options, cwd);
|
|
626
|
-
if (result.code === 0 && result.target !== "") {
|
|
627
|
-
await maybeOfferExtras(options, result.target);
|
|
628
|
-
}
|
|
629
|
-
if (result.code === 0 && options.ci !== void 0) {
|
|
630
|
-
scaffoldCiWorkflow(options.inPlace === true ? cwd : result.target, options.ci, options.logger);
|
|
631
|
-
}
|
|
632
|
-
return result;
|
|
633
|
-
};
|
|
634
|
-
const isTemplate = (value) => value === "astro" || value === "next" || value === "nuxt" || value === "standalone" || value === "sveltekit" || value === "tanstack-start-react" || value === "tanstack-start-solid" || value === "vite";
|
|
635
|
-
const resolveCiProvider = (raw, logger) => {
|
|
636
|
-
if (raw === void 0) {
|
|
637
|
-
return void 0;
|
|
638
|
-
}
|
|
639
|
-
if (isCiProvider(raw)) {
|
|
640
|
-
return raw;
|
|
641
|
-
}
|
|
642
|
-
logger.warn(`init: unknown --ci "${raw}" — expected github | gitlab; skipping CI scaffold.`);
|
|
643
|
-
return void 0;
|
|
644
|
-
};
|
|
645
|
-
const execute = defineHandler(({ argument, cwd, logger, options }) => {
|
|
646
|
-
const templateRaw = options.template ?? "vite";
|
|
647
|
-
const template = isTemplate(templateRaw) ? templateRaw : "vite";
|
|
648
|
-
return runInitCommand({
|
|
649
|
-
allowUnsafeSource: options.allowUnsafeSource === true,
|
|
650
|
-
cwd,
|
|
651
|
-
ci: resolveCiProvider(options.ci, logger),
|
|
652
|
-
from: options.from,
|
|
653
|
-
inPlace: options.here === true,
|
|
654
|
-
interactive: options.interactive === true ? true : void 0,
|
|
655
|
-
logger,
|
|
656
|
-
name: argument[0],
|
|
657
|
-
ref: options.ref,
|
|
658
|
-
source: options.source,
|
|
659
|
-
templateType: template,
|
|
660
|
-
yes: options.yes === true
|
|
661
|
-
});
|
|
662
|
-
});
|
|
663
|
-
|
|
664
|
-
export { execute, isTemplate, resolveTemplateSource, runInitCommand };
|
|
1260
|
+
`,Qr="gh:anolilab/lunora/templates",Zr=e=>{const t=e.lastIndexOf(".");return t===-1?!1:Gr.has(e.slice(t))},ea=/^[a-z0-9_][a-z0-9\-_]*$/u,ta=/([a-z0-9])([A-Z])/gu,ra=/[^a-z0-9_]/gu,aa=e=>{const t=e.replaceAll(ta,"$1-$2").toLowerCase().replaceAll(ra,"-").split("-").filter(r=>r.length>0);return t.length>0?t.join("-"):"my-app"},oa=(e,t)=>e.replaceAll("{{name}}",t),na=async(e,t)=>{const r=new Set;for(const a of e)if(N(a)==="package.json")for(const o of Object.keys(me(S(a))))U(o)&&r.add(o);return ye(r,t)},ia=(e,t,r)=>{let a;try{a=JSON.parse(e)}catch{return e}let o=e;for(const n of["dependencies","devDependencies"])for(const i of Object.keys(a[n]??{})){if(!U(i))continue;const s=r.get(i)??t,l=lt(o,[n,i],s,{formattingOptions:{insertSpaces:!0,tabSize:4}});o=ct(o,l)}return o},sa=["@parcel/watcher","esbuild","lmdb","msgpackr-extract","rs-module-lexer","sharp","unrs-resolver","vue-demi","workerd"],la=["cpu-features","protobufjs","ssh2"],je="pnpm-workspace.yaml",ca=()=>["# pnpm reads its settings from here (the package.json `pnpm` field is no longer read).","# Pre-approve the toolchain's native build scripts so `pnpm install` runs them","# without the interactive `pnpm approve-builds` step; deny the optional native","# builds a scaffold doesn't need (so no C/C++ toolchain is required).","allowBuilds:",...sa.map(e=>` '${e}': true`),...la.map(e=>` '${e}': false`),""].join(`
|
|
1261
|
+
`),Ue=e=>{const t=p(e,je);v(t)||w(t,ca(),"utf8")},V=e=>{const t=[];for(const r of st(e,{includeDirs:!1,includeFiles:!0}))ue(r.path).isSymbolicLink()||t.push(r.path);return t},se="vitejs/vite",le=(e,t)=>{for(const r of V(e)){const a=p(t,ge(e,r));M(S(a),{recursive:!0}),Je(r,a)}},Ve=async(e,t,r)=>{const a=V(e),o=[],n=be(),i=await na(a,n);for(const s of a){const l=ge(e,s),c=p(t,l);M(S(c),{recursive:!0});const u=T(s);let h=Zr(s)?oa(u.toString("utf8"),r):void 0;h!==void 0&&N(s)==="package.json"&&(h=ia(h,n,i)),h===void 0?w(c,u):w(c,h,"utf8"),o.push(c)}return o},H=(e,t,r)=>t!==void 0&&t.length>0?t:`${Qr}/${e}#${xe(r)}`,da=e=>e.includes("..")?!1:e.startsWith("gh:")||e.startsWith("github:")||e.startsWith("https://"),A=(e,t)=>{e.info(`[dry-run] would ${t}`)},Fe=(e,t,r)=>(e.error(`init: the template at ${r} contains no files — nothing was scaffolded. Check the template name, \`--source\` layout and \`--ref\`.`),{code:m.NOT_FOUND,files:[],target:t}),We="Template files copied.",J=(e,t,r)=>{y()&&process.stdout.write(`
|
|
1262
|
+
`),e.success(`scaffolded ${String(t.length)} files into ${r}`)},ua=(e,t)=>{const{args:r,command:a}=mt(e,t);return`${a} ${r.join(" ")}`},He=(e,t)=>{let r=fe(e);for(;;){if(t(r))return!0;const a=S(r);if(a===r)return!1;r=a}},pa=e=>v(p(e,je))?!0:nt(e)?.workspaces!==void 0,X=e=>He(e,pa),ha=e=>He(e,t=>v(p(t,".git"))),ma=async(e,t)=>{if(e.yes===!0||!y()||ha(S(t)))return;if(!await Le(x.git,{badge:g.git,defaultYes:!1})){await Me("Sounds good! You can always run git init manually.");return}if(e.dryRun===!0){A(e.logger,"initialize a git repository");return}const r=e.spawner??ke;(await St("Initializing a git repository…",()=>r({args:["init"],command:"git",cwd:t}))).code===0?await O("git","Initialized an empty git repository."):e.logger.warn("`git init` failed — initialize it yourself later with `git init`.")},fa=async(e,t,r,a)=>{const o=[{code:`cd ./${e}`,lead:"Enter your project directory using"}];t===void 0&&o.push({code:`${r} install`,lead:"Install dependencies with",tail:a?" from the workspace root":void 0}),o.push({code:ht(r,"dev"),lead:"Run",tail:" to start the dev server."},{code:"lunora add",lead:"Add features like auth or storage using"});const n=[{code:"https://lunora.sh/docs",lead:"Read the docs at"},{code:"https://lunora.sh/chat",lead:"Stuck? Join the chat at"}];if(y()){await Lt(g.next,x.nextHeader,o,n);return}const i=o.map(s=>`${s.lead} ${s.code}${s.tail??""}`);i.push("",...n.map(s=>`${s.lead} ${s.code}${s.tail??""}`)),await O("next",x.nextHeader,i.join(`
|
|
1263
|
+
`))},ga=e=>e.yes!==!0&&(e.installPrompt!==void 0||y()),va=async(e,t)=>{if(!ga(e)||X(S(t)))return;const r=pt(e.packageManagerProbe),[a]=r;if(a===void 0)return;if(!await(e.installPrompt?.confirmInstall??(async()=>Le(x.install,{badge:g.deps,defaultYes:!0})))()){await Me("No problem! Remember to install dependencies after setup.");return}let n=a;if(r.length>1&&(n=e.installPrompt?await e.installPrompt.selectManager(r):await G(x.packageManager,r.map(u=>({label:u,value:u})),{badge:g.deps,default:a})??a),e.dryRun===!0){A(e.logger,`install dependencies with ${n}`);return}n==="pnpm"&&Ue(t);const i=e.spawner??ke,{args:s,command:l}=we(n);await O("deps",`Installing dependencies with ${n}…`);const c=await i({args:s,command:l,cwd:t});if(c.code!==0){e.logger.warn(`\`${l} install\` exited with code ${String(c.code)} — run it yourself in ${N(t)}/.`);return}return await O("deps",`Dependencies installed with ${n}.`),n},wa=async(e,t,r,a,o,n)=>{const i=p(e,t);if(!v(i))return o.error(`template not found in local source: ${i}`),{code:m.NOT_FOUND,files:[],target:r};const s=await Ve(i,r,a);return s.length===0?Fe(o,r,i):(n(),J(o,s,r),{code:0,files:s,target:r})},ya=async e=>{const{logger:t,markComplete:r,name:a,ref:o,source:n,target:i,templateType:s}=e,l=pe(p(he(),"lunora-init-fetch-")),c=p(l,"template");try{const u=n!==void 0&&n.length>0?o:await yt(o,t),h=H(s,n,u);let d,b=[];if(await Ae([{label:`${s} template fetched`,run:async()=>{d=await ve(h,{cwd:l,dir:c,force:!0,install:!1,silent:!0})}},{label:`files copied into ${a}/`,run:async()=>{b=await Ve(c,i,a)}}],{end:We,start:"Project initializing…"}),b.length===0)return Fe(t,i,d?.source??h);r();const R=V(c);return y()&&process.stdout.write(`
|
|
1264
|
+
`),t.info(d?.commit?`template: ${d.source} @ ${d.commit} (${String(R.length)} files)`:`template: ${d?.source??h} (${String(R.length)} files)`),J(t,b,i),{code:0,files:b,target:i}}catch(u){if(u instanceof q)throw u;const{hints:h,message:d}=or(u,{ref:xe(o),remote:H(s,n,o),templateType:s});t.error(d);for(const b of h)t.warn(b);return{code:1,files:[],target:i}}finally{$(l,{force:!0,recursive:!0})}},ba=e=>{for(const t of["_gitignore","_npmrc","_gitattributes"]){const r=p(e,t);v(r)&&Xe(r,p(e,`.${t.slice(1)}`))}},xa=async e=>{const{framework:t,logger:r,markComplete:a,name:o,overlayBaseFrom:n,target:i}=e,s=B[t],l=pe(p(he(),"lunora-vite-base-"));try{let c;if(n!==void 0&&(c=p(n,`template-${s.createViteTemplate}`),!v(c)))return r.error(`create-vite base not found on disk: ${c}`),{code:m.NOT_FOUND,files:[],target:i};const u=async()=>{if(c!==void 0){le(c,i);return}const d=p(l,"base"),b=await wt(se,"main",r),R=`github:${se}/packages/create-vite/template-${s.createViteTemplate}#${b}`;await ve(R,{cwd:l,dir:d,force:!0,install:!1,silent:!0}),ba(d),le(d,i)};let h=[];return await Ae([{label:`create-vite (${s.label}) base ready`,run:u},{label:`Lunora overlay applied (${s.label})`,run:async()=>{h=await Vr({adapter:s,distTag:be(),logger:r,name:o,target:i})}}],{end:We,start:"Project initializing…"}),a(),J(r,h,i),{code:0,files:[...V(i)],target:i}}catch(c){if(c instanceof q)throw c;const u=c instanceof Error?c.message:String(c);return r.error(`failed to scaffold the ${s.label} base: ${u}`),{code:1,files:[],target:i}}finally{$(l,{force:!0,recursive:!0})}},z=(e,t,r,a,o)=>(o.error(`init --in-place: could not ${e} ${t}: ${r instanceof Error?r.message:String(r)}`),{code:1,files:[],target:a}),ka=(e,t)=>{const r=p(e,"vite.config.ts");try{w(r,Yr,"utf8")}catch(a){return z("write",r,a,e,t)}return t.success(`created ${r} with lunora() plugin`),{code:0,files:[r],target:e}},Ca=(e,t,r)=>{let a;try{a=T(e,"utf8")}catch(n){return z("read",e,n,t,r)}const o=$e(a);if(!o.changed)return r.info(`${e}: ${o.reason??"no changes needed"}`),{code:0,files:[],target:t};try{w(e,o.code,"utf8")}catch(n){return z("write",e,n,t,r)}return r.success(`patched ${e} — added lunora() plugin`),{code:0,files:[e],target:t}},Sa=(e,t)=>{const r=p(e,"lunora"),a=p(r,"schema.ts");if(v(a))return t.info(`lunora/ already present — left ${a} untouched`),[];const o=[];try{M(r,{recursive:!0}),w(a,Jr,"utf8"),o.push(a);const n=p(r,"messages.ts");v(n)||(w(n,Xr,"utf8"),o.push(n)),t.success(`scaffolded lunora/ (${String(o.length)} file(s))`)}catch(n){const i=n instanceof Error?n.message:String(n);t.error(`init --here: could not scaffold lunora/: ${i}`)}return o},ze=e=>e==="sveltekit"||e==="nuxt"||e==="astro",La=(e,t,r)=>{const{adapter:a,class:o,framework:n}=e;r.info(""),r.info(`detected framework: ${n} (class ${o})`),r.info("next steps:");const i=[a,"@lunora/client","@lunora/runtime","@lunora/server"];ze(n)||i.push("@lunora/vite"),r.info(` 1. install the adapter: ${ua(t,i)}`),r.info(" 2. run codegen: lunora codegen"),o==="A"?(r.info(" 3. compose one worker: wrap your worker entry with"),r.info(" createWorker({ httpRouter: <your framework SSR handler>, shardDO: ShardDO, ... })"),r.info(` 4. add the provider: mount the ${a} provider in your root layout/route`),r.info(" 5. make a loader live: preloadQuery() in a loader, usePreloadedQuery() in the component"),r.info(" see https://lunora.sh/docs/frameworks/reactive-loaders")):o==="B"?(r.info(" 3. inject Lunora: mount Lunora realtime under /_lunora/* in your server hook"),r.info(` (${n} owns its Cloudflare adapter — Lunora composes into its server entry)`),r.info(` 4. add the provider: mount the ${a} provider in your root layout`),r.info(" 5. read the guide: https://lunora.sh/docs/frameworks/deploy")):(r.info(" 3. add the provider: wrap your app with the LunoraProvider from @lunora/react"),r.info(" 4. read the guide: https://lunora.sh/docs/frameworks/bring-your-framework")),r.info("")},Ma=(e,t,r)=>{if(ze(t))return r.info(`${t} wires Lunora through its server entry, not a lunora() Vite plugin — leaving the Vite config alone (see next steps)`),{code:0,files:[],target:e};const a=Pe(e);return a===void 0?ka(e,r):Ca(a,e,r)},Aa=(e,t)=>{const r=Kt(e),a=Ma(e,r.framework,t);if(a.code!==0)return a;const o=Sa(e,t);return La(r,P(e),t),{code:0,files:[...a.files,...o],target:e}},Ea=e=>e.yes!==!0&&(e.prompt!==void 0||(e.interactive??y())),ce=async(e,t,r)=>{r.dryRun!==!0&&await gr({apply:a=>ot(e,a),detected:at(e),interactive:t,logger:r.logger,multiSelect:r.lintPrompt??((a,o,n)=>Se(a,o,{...n,badge:g.add}))})},Na=async(e,t)=>{const r=Ea(e),a=e.add===void 0?[]:sr(e.add,i=>{e.logger.warn(i)}),n={applyAll:async i=>{if(i.length===0)return!0;if(e.dryRun===!0)return A(e.logger,`add ${i.map(d=>d.label).join(", ")}`),!0;const s=[],l=y()?{error:d=>{s.push({level:"error",message:d})},info:()=>{},success:()=>{},warn:d=>{s.push({level:"warn",message:d})}}:e.logger,c=i.map(d=>({running:`adding ${d.label}…`,task:()=>Tt({allowUnsafeSource:e.allowUnsafeSource,cwd:t,from:e.registryFrom,logger:l,names:[...d.names],ref:e.ref,source:e.registrySource,transformManifest:d.transformManifest,yes:!0})})),u=`added ${i.map(d=>d.label).join(", ")}`,h=await Mt(g.add,c,u);for(const{level:d,message:b}of s)e.logger[d](b);return h.every(d=>d.code===0)},interactive:r,logger:e.logger,multiSelect:e.prompt?.multiSelect??((i,s,l)=>Se(i,s,{...l,badge:g.add})),preselected:a.length>0?a:void 0,projectName:N(t),resolveAuthUiItem:()=>{const i=me(t);if(!$t(i))return Ot(i)??"auth-ui-react"},select:e.prompt?.select??((i,s,l)=>G(i,s,{...l,badge:g.add})),text:e.prompt?.text??((i,s)=>Ce(i,{...s,badge:g.add}))};if(a.length>0){const i=await ae(n);return await ce(t,r,e),i}return y()&&await Ct(x.extras),await ae(n),await ce(t,r,e),!0},F="react",Ke=[{description:"React SPA — official create-vite base + the Lunora layer (the default)",label:"React",value:"react"},{description:"Vue SPA — create-vite base + Lunora",label:"Vue",value:"vue"},{description:"Solid SPA — create-vite base + Lunora",label:"Solid",value:"solid"},{description:"Solid 2.0 SPA — the Solid 2 line (@solidjs/web, vite-plugin-solid 3)",label:"Solid 2",value:"solid-v2"},{description:"Svelte SPA — create-vite base + Lunora",label:"Svelte",value:"svelte"},{description:"React SPA on Rsbuild — the Worker runs under wrangler dev behind the dev server",label:"React · Rsbuild",value:"rspack-react"},{description:"Next.js (App Router) — OpenNext on Cloudflare + a standalone Lunora worker",label:"Next.js",value:"next"},{description:"TanStack Start (React) — SSR with live-loader routes",label:"TanStack Start · React",value:"tanstack-start-react"},{description:"TanStack Start (React) on Rsbuild — SSR composed into the Lunora worker",label:"TanStack Start · React · Rsbuild",value:"tanstack-start-react-rspack"},{description:"TanStack Start (Solid)",label:"TanStack Start · Solid",value:"tanstack-start-solid"},{description:"Next.js App Router on Vite (vinext) — composed into the Lunora worker (experimental)",label:"vinext · App Router",value:"vinext"},{description:"Next.js Pages Router on Vite (vinext) — composed into one worker (experimental)",label:"vinext · Pages Router",value:"vinext-pages"},{description:"React Router (v7, framework mode) — SSR composed into the Lunora worker",label:"React Router",value:"react-router"},{description:"Astro (islands) — single-worker, Lunora composed into the adapter worker",label:"Astro",value:"astro"},{description:"AnalogJS (Angular) — single-worker, Lunora mounted in Nitro",label:"Analog",value:"analog"},{description:"Nuxt (Vue) — single-worker, Lunora mounted in Nitro",label:"Nuxt",value:"nuxt"},{description:"SvelteKit — single-worker, Lunora composed into the adapter worker",label:"SvelteKit",value:"sveltekit"},{description:"React Native (Expo) — an iOS/Android/web app + a Lunora worker backend",label:"React Native · Expo",value:"expo"},{description:"Worker only — no frontend",label:"Standalone",value:"standalone"}],qe=Object.keys(B).join("|"),Ge=Ke.filter(e=>!j(e.value)).map(e=>e.value),Ye=Ge.join("|"),Ia=e=>j(e)?{framework:e,kind:"overlay"}:{kind:"template",templateType:e},Ra=async e=>e.vite!==void 0?{framework:e.vite,kind:"overlay"}:e.templateType!==void 0?{kind:"template",templateType:e.templateType}:!y()||e.yes===!0?{framework:F,kind:"overlay"}:Ia(await G(x.framework,Ke,{badge:g.tmpl,default:F})??F),_a=e=>{if(y()||e.yes===!0)return;const t=[];if(e.name===void 0&&t.push("a project name (`lunora init <name>`)"),e.templateType===void 0&&e.vite===void 0&&t.push(`a framework — \`--vite <${qe}>\` for an SPA, or \`-t <${Ye}>\` for a bespoke template`),t.length!==0)return`lunora init can't prompt in a non-interactive terminal — provide ${t.join(" and ")}, or pass --yes to accept the defaults.`},$a=async(e,t,r,a,o)=>j(t)?await Be({isLocal:e.overlayBaseFrom!==void 0,logger:e.logger})?(M(a,{recursive:!0}),xa({framework:t,logger:e.logger,markComplete:o,name:r,overlayBaseFrom:e.overlayBaseFrom,target:a})):{code:1,files:[],target:a}:(e.logger.error(`init: unknown framework "${t}". Supported overlays: ${Object.keys(B).join(", ")}.`),{code:m.USAGE,files:[],target:a}),Oa=async(e,t,r,a,o)=>e.from!==void 0?await wa(e.from,t,a,r,e.logger,o):e.source!==void 0&&e.source.length>0&&!e.allowUnsafeSource&&!da(e.source)?(e.logger.error(`init: refusing --source ${e.source} — only gh:, github:, or https:// sources are allowed (and may not contain ".."). Re-run with --allow-unsafe-source if you really want this.`),{code:m.USAGE,files:[],target:a}):await Be({isLocal:!1,logger:e.logger,source:H(t,e.source,e.ref)})?ya({logger:e.logger,markComplete:o,name:r,ref:e.ref,source:e.source,target:a,templateType:t}):{code:1,files:[],target:a},Ta=(e,t)=>{if(X(t))return;let r;try{r=P(e)}catch{return}r==="pnpm"&&Ue(e)},Pa=async(e,t,r)=>{await kt("realtime backend on Cloudflare Workers + Durable Objects");const a=_a(e);if(a!==void 0)return e.logger.error(a),{code:m.USAGE,files:[],target:""};const o=Hr(),n=e.name??await Ce(x.name,{badge:g.dir,default:o,placeholder:o}),i=await Ra(e),s=n.trim();if(s.length===0)return e.logger.error("init: refusing an empty project name — pass a directory name (e.g. `lunora init my-app`)."),{code:m.USAGE,files:[],target:""};if(s.includes("/")||s.includes("\\")||s===".."||s===".")return e.logger.error(`init: refusing project name "${s}" — must not contain path separators or be "." / "..".`),{code:m.USAGE,files:[],target:""};if(!ea.test(s))return e.logger.error(`init: refusing project name "${s}" — a Cloudflare Worker name must be lowercase letters, digits, "-" or "_" (starting with a letter, digit or "_"), and wrangler rejects anything else. Try \`${aa(s)}\`.`),{code:m.USAGE,files:[],target:""};const l=fe(t,s),c=ue(l,{throwIfNoEntry:!1});if(c?.isSymbolicLink()===!0)return e.logger.error(`init: refusing to scaffold into "${l}" — it is a symlink. Remove it, or scaffold into a different directory name.`),{code:m.CONFLICT,files:[],target:l};const u=c!==void 0;if(u&&de(l).length>0)return e.logger.error(`target directory not empty: ${l}`),{code:m.CONFLICT,files:[],target:l};if(e.dryRun===!0){const d=i.kind==="overlay"?`the ${i.framework} create-vite overlay`:`the ${i.templateType} template`;return A(e.logger,`scaffold ${d} into ${l}`),{code:0,files:[],target:l}}r.record(l,u);const h=i.kind==="overlay"?await $a(e,i.framework,s,l,r.complete):await Oa(e,i.templateType,s,l,r.complete);return h.code===0&&Ta(l,t),h},W=(e,t)=>{const{target:r,targetPreExisted:a}=e;if(!(r===void 0||!v(r))){if(a===!0)for(const o of de(r))$(p(r,o),{force:!0,recursive:!0});else $(r,{force:!0,recursive:!0});t.info(`removed the partially-created project at ${r}`)}},Da=async(e,t,r)=>e.inPlace!==!0?Pa(e,t,r):e.dryRun===!0?(A(e.logger,`configure Lunora into ${t}`),{code:0,files:[],target:t}):Aa(t,e.logger),Ba=async(e,t,r)=>{const a=await Na(e,t.target),o=e.inPlace===!0?void 0:await va(e,t.target);if(e.inPlace!==!0){await ma(e,t.target);const n=o??P(t.target);await fa(N(t.target),o,n,X(r)),await nr(e.logger)}return a},ja=(e,t,r)=>{if(t.code!==0||e.ci===void 0)return;if(e.dryRun===!0){A(e.logger,`scaffold a ${e.ci} CI deploy pipeline`);return}const a=e.inPlace===!0?r:t.target;try{const o=P(a);Ht(a,e.ci,o,e.logger)}catch{e.logger.warn(`--ci ${e.ci}: could not detect a package manager for this project — skipped the CI pipeline.`)}},Ua=async e=>{const t=e.cwd??process.cwd(),r={};let a;try{a=await Da(e,t,{complete:()=>{r.target=void 0},record:(o,n)=>{r.target=o,r.targetPreExisted=n}}),a.code===0&&a.target!==""?(r.target=void 0,await Ba(e,a,t)||(a={...a,code:1})):a.code!==0&&W(r,e.logger)}catch(o){if(o instanceof q)return W(r,e.logger),process.stdout.write("\n ✖ Setup cancelled — run `lunora init` again whenever you're ready. 🌙\n"),{code:130,files:[],target:""};throw W(r,e.logger),o}return ja(e,a,t),a},Va=e=>typeof e=="string"&&Ge.includes(e),Fa=(e,t)=>{if(e!==void 0){if(Ft(e))return e;t.warn(`init: unknown --ci "${e}" — expected github | gitlab; skipping CI scaffold.`)}},Wa=e=>e===void 0?{}:Va(e)?{templateType:e}:j(e)?{vite:e}:{error:`init: unknown --template "${e}" — expected a bespoke template (${Ye}) or an overlay framework (${qe}).`},mo=ft(({argument:e,cwd:t,logger:r,options:a})=>{const o=Wa(a.template);return"error"in o?(r.error(o.error),{code:m.USAGE}):Ua({add:a.add,allowUnsafeSource:a.allowUnsafeSource===!0,cwd:t,ci:Fa(a.ci,r),dryRun:a.dryRun===!0,from:a.from,inPlace:a.here===!0,interactive:a.interactive===!0?!0:void 0,logger:r,name:e[0],ref:a.ref,source:a.source,templateType:o.templateType,vite:a.vite??o.vite,yes:a.yes===!0})});export{Ke as FRAMEWORK_CHOICES,mo as execute,Va as isTemplate,Wa as resolveTemplateFlag,H as resolveTemplateSource,Ua as runInitCommand};
|