@lunora/cli 1.0.0-alpha.2 → 1.0.0-alpha.200
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 +1 -1
- package/__assets__/package-og.svg +1 -1
- package/dist/bin.mjs +2 -10
- package/dist/index.d.mts +797 -358
- package/dist/index.d.ts +797 -358
- package/dist/index.mjs +1 -19
- package/dist/packem_chunks/handler.mjs +1 -76
- package/dist/packem_chunks/handler10.mjs +2 -22
- package/dist/packem_chunks/handler11.mjs +2 -192
- package/dist/packem_chunks/handler12.mjs +1 -131
- package/dist/packem_chunks/handler13.mjs +1 -65
- package/dist/packem_chunks/handler14.mjs +1 -58
- package/dist/packem_chunks/handler15.mjs +1 -79
- package/dist/packem_chunks/handler16.mjs +3 -41
- package/dist/packem_chunks/handler17.mjs +1 -105
- package/dist/packem_chunks/handler18.mjs +1 -172
- package/dist/packem_chunks/handler19.mjs +7 -89
- package/dist/packem_chunks/handler2.mjs +2 -114
- package/dist/packem_chunks/handler20.mjs +2 -94
- package/dist/packem_chunks/handler21.mjs +2 -311
- package/dist/packem_chunks/handler22.mjs +3 -0
- package/dist/packem_chunks/handler23.mjs +3 -0
- package/dist/packem_chunks/handler24.mjs +1 -0
- package/dist/packem_chunks/handler25.mjs +99 -0
- package/dist/packem_chunks/handler26.mjs +10 -0
- package/dist/packem_chunks/handler3.mjs +1 -204
- package/dist/packem_chunks/handler4.mjs +1 -33
- package/dist/packem_chunks/handler5.mjs +1 -49
- package/dist/packem_chunks/handler6.mjs +1 -91
- package/dist/packem_chunks/handler7.mjs +3 -42
- package/dist/packem_chunks/handler8.mjs +1 -174
- package/dist/packem_chunks/handler9.mjs +1 -16
- package/dist/packem_chunks/planDevCommand.mjs +7 -543
- package/dist/packem_chunks/runCodegenCommand.mjs +4 -52
- package/dist/packem_chunks/runDeployCommand.mjs +1 -504
- package/dist/packem_chunks/runInitCommand.mjs +1141 -565
- package/dist/packem_chunks/runMigrateGenerateCommand.mjs +9 -395
- package/dist/packem_chunks/runResetCommand.mjs +1 -41
- package/dist/packem_chunks/runRpcCommand.mjs +1 -68
- package/dist/packem_shared/COMMANDS-su5nmqYP.mjs +1 -0
- package/dist/packem_shared/DEFAULT_IMPORT_BATCH_SIZE-Nf7GsE6v.mjs +1 -0
- package/dist/packem_shared/admin-token-rxXZbVMZ.mjs +1 -0
- package/dist/packem_shared/admin-url-Cil3Or6N.mjs +1 -0
- package/dist/packem_shared/advisory-gate-Cl8IEFIj.mjs +1 -0
- package/dist/packem_shared/api-spec-lYyq4vL6.mjs +1 -0
- package/dist/packem_shared/buildRegistryIndex-Zi3bBqpc.mjs +1 -0
- package/dist/packem_shared/cli-RB-BoDnW.mjs +3 -0
- package/dist/packem_shared/codegen-error-C04fGQjf.mjs +3 -0
- package/dist/packem_shared/command-DwC11Cwe.mjs +1 -0
- package/dist/packem_shared/commands-BOgN2nF7.mjs +19 -0
- package/dist/packem_shared/createLogger-hGafwf-3.mjs +2 -0
- package/dist/packem_shared/createRecordingSpawner-DJlNacZ6.mjs +1 -0
- package/dist/packem_shared/deploy-target-D9GPy_tq.mjs +1 -0
- package/dist/packem_shared/detect-package-manager-DSaAqRof.mjs +1 -0
- package/dist/packem_shared/diffSnapshots-CIOFQN_a.mjs +5 -0
- package/dist/packem_shared/docker-DpVxvYpL.mjs +1 -0
- package/dist/packem_shared/health-probe-QEPfFdgJ.mjs +1 -0
- package/dist/packem_shared/import-CrVGrOt3.mjs +12 -0
- package/dist/packem_shared/insertSchemaExtension-DY4pA8wE.mjs +8 -0
- package/dist/packem_shared/lint-ignore-report-CDbcbtv7.mjs +2 -0
- package/dist/packem_shared/open-url-EnKy--w-.mjs +1 -0
- package/dist/packem_shared/output-format-DfogXx0p.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/platform-diagnostics-uOXqysk3.mjs +4 -0
- package/dist/packem_shared/post-codegen-hook-DRdEoTsQ.mjs +1 -0
- package/dist/packem_shared/prompt-cancelled-C8Sj7OqI.mjs +1 -0
- package/dist/packem_shared/resolve-DZAGzg67.mjs +1 -0
- package/dist/packem_shared/resolve-target-C_ZloTvd.mjs +1 -0
- package/dist/packem_shared/runAddCommand-BXz-PXbb.mjs +1 -0
- package/dist/packem_shared/runExportCommand-DmXKEWSq.mjs +5 -0
- package/dist/packem_shared/schema-drift-gate-AscQpYH5.mjs +1 -0
- package/dist/packem_shared/schemaIrToSnapshot-qpRoV7HY.mjs +1 -0
- package/dist/packem_shared/shared-D-zCOmgY.mjs +1 -0
- package/dist/packem_shared/tui-prompts-Dd0pDuNr.mjs +4 -0
- package/dist/packem_shared/vectorize-metadata-DbziRKpX.mjs +1 -0
- package/dist/packem_shared/wrangler-name-Dsk5K1f-.mjs +1 -0
- package/dist/packem_shared/wrangler-secrets-CE7jcf8E.mjs +1 -0
- package/package.json +43 -19
- package/skills/README.md +35 -17
- package/skills/lunora/SKILL.md +65 -9
- package/skills/lunora-functions/SKILL.md +38 -3
- package/skills/lunora-migration-helper/SKILL.md +70 -17
- package/skills/lunora-performance-audit/SKILL.md +36 -6
- package/skills/lunora-quickstart/SKILL.md +90 -24
- package/skills/lunora-realtime/SKILL.md +58 -30
- package/skills/lunora-setup-storage/SKILL.md +7 -3
- package/dist/packem_shared/COMMANDS-1V_KEx35.mjs +0 -905
- 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/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-BZGkRnBs.mjs +0 -693
- 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
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import{V as R}from"../packem_shared/cli-RB-BoDnW.mjs";import{d as T}from"../packem_shared/command-DwC11Cwe.mjs";import{existsSync as u,readFileSync as v,mkdirSync as D,realpathSync as I,statSync as J,writeFileSync as W,chmodSync as z,renameSync as G,unlinkSync as H}from"node:fs";import{homedir as b}from"node:os";import{findWranglerFile as V}from"@lunora/config/cloudflare";import{join as s,dirname as K,relative as q}from"@visulima/path";import{d as B,e as X}from"../packem_shared/detect-package-manager-DSaAqRof.mjs";import{stringify as Z}from"smol-toml";import{parse as Q,modify as Y,applyEdits as ee}from"jsonc-parser";import{readLiveDevServerState as y}from"@lunora/config";import{resolveAdminToken as re}from"@lunora/config/studio-host";import{connectLocalStdio as te}from"@lunora/mcp";const f=e=>({args:[...e.args],command:e.command,...e.env===void 0?{}:{env:e.env}}),h=e=>e.transport==="http"?{type:"http",url:e.url}:f(e),ne=e=>e.transport==="http"?{httpUrl:e.url}:f(e),oe=e=>e.transport==="http"?{serverUrl:e.url}:f(e),ae=e=>({args:["-y","mcp-remote",e],command:"npx"}),le=e=>e.transport==="http"?ae(e.url):f(e),ce=e=>e.transport==="http"?{url:e.url}:f(e),se=e=>e.transport==="http"?{enabled:!0,type:"remote",url:e.url}:{command:[e.command,...e.args],enabled:!0,type:"local",...e.env===void 0?{}:{environment:e.env}},ie=e=>e.transport==="http"?{disabled:!1,type:"streamableHttp",url:e.url}:{disabled:!1,...f(e)},de=({home:e,platform:r})=>{if(r==="darwin")return{global:s(e,"Library","Application Support","Claude","claude_desktop_config.json")};if(r==="win32"){const t=process.env.APPDATA;return t===void 0||t===""?{}:{global:s(t,"Claude","claude_desktop_config.json")}}return r==="linux"?{global:s(e,".config","Claude","claude_desktop_config.json")}:{}},ue=(e,r)=>Z({mcp_servers:{[e]:r.transport==="http"?{url:r.url}:{args:[...r.args],command:r.command,...r.env===void 0?{}:{env:r.env}}}}),p=[{buildEntry:h,paths:({projectRoot:e})=>({project:s(e,".mcp.json")}),format:"json",id:"claude-code",key:"mcpServers",label:"Claude Code"},{buildEntry:h,paths:({home:e,projectRoot:r})=>({global:s(e,".cursor","mcp.json"),project:s(r,".cursor","mcp.json")}),format:"json",id:"cursor",key:"mcpServers",label:"Cursor"},{buildEntry:h,paths:({projectRoot:e})=>({project:s(e,".vscode","mcp.json")}),format:"json",id:"vscode",key:"servers",label:"VS Code (GitHub Copilot)"},{buildEntry:ne,paths:({home:e,projectRoot:r})=>({global:s(e,".gemini","settings.json"),project:s(r,".gemini","settings.json")}),format:"json",id:"gemini",key:"mcpServers",label:"Gemini CLI"},{buildEntry:le,paths:de,format:"json",id:"claude-desktop",key:"mcpServers",label:"Claude Desktop"},{buildEntry:oe,paths:({home:e})=>({global:s(e,".codeium","windsurf","mcp_config.json")}),format:"json",id:"windsurf",key:"mcpServers",label:"Windsurf"},{buildEntry:se,paths:({home:e,projectRoot:r})=>({global:s(e,".config","opencode","opencode.json"),project:s(r,"opencode.json")}),format:"json",id:"opencode",key:"mcp",label:"OpenCode"},{buildEntry:ie,paths:({home:e})=>({global:s(e,".cline","mcp.json")}),format:"json",id:"cline",key:"mcpServers",label:"Cline"},{buildEntry:ce,paths:({home:e})=>({global:s(e,".config","zed","settings.json")}),format:"json",id:"zed",key:"context_servers",label:"Zed"},{paths:({home:e,projectRoot:r})=>({global:s(e,".codex","config.toml"),project:s(r,".codex","config.toml")}),format:"manual",id:"codex",label:"Codex CLI",renderSnippet:ue}],O=p.map(e=>e.id),fe=e=>p.find(r=>r.id===e.toLowerCase()),C=(e,r)=>{let t=e,n;try{t=I(e),n=J(t).mode}catch{}const a=`${t}.lunora-${Math.random().toString(36).slice(2,10)}.tmp`;try{W(a,r,"utf8"),n!==void 0&&z(a,n),G(a,t)}catch(o){try{H(a)}catch{}throw o}},me={formattingOptions:{insertSpaces:!0,tabSize:4}},w=e=>{const r=[],t=Q(e,r,{allowTrailingComma:!0});return{errors:r,value:t}},g=e=>typeof e=="object"&&e!==null&&!Array.isArray(e),S=(e,r,t)=>{if(!g(e))return;const n=e[r];return g(n)?n[t]:void 0},x=e=>{if(!u(e.path))return"absent";let r;try{r=v(e.path,"utf8")}catch{return"invalid"}if(r.trim().length===0)return"absent";const{errors:t,value:n}=w(r);return t.length>0||!g(n)?"invalid":S(n,e.key,e.name)===void 0?"absent":"present"},ge=e=>x(e)==="present",M=(e,r,t,n,a)=>{try{const o=Y(e,[t,n],a,me);o.length>0&&C(r,ee(e,o));return}catch(o){return o instanceof Error?o.message:String(o)}},pe=e=>{const{entry:r,force:t=!1,key:n,name:a,path:o}=e,l=u(o)?v(o,"utf8"):"";if(l.trim().length===0)return D(K(o),{recursive:!0}),C(o,`${JSON.stringify({[n]:{[a]:r}},void 0,4)}
|
|
2
|
+
`),{action:"created",path:o};const{errors:c,value:i}=w(l);if(c.length>0)return{action:"invalid",error:`parse error at offset ${String(c[0]?.offset??0)}`,path:o};if(!g(i))return{action:"invalid",error:"the file's root is not a JSON object",path:o};const m=i[n];if(m!==void 0&&!g(m))return{action:"invalid",error:`"${n}" is not an object`,path:o};if(S(i,n,a)!==void 0&&!t)return{action:"skipped",path:o};const k=M(l,o,n,a,r);return k===void 0?{action:"updated",path:o}:{action:"invalid",error:k,path:o}},ve=e=>{const{key:r,name:t,path:n}=e;if(!u(n))return{action:"absent",path:n};let a;try{a=v(n,"utf8")}catch(i){return{action:"invalid",error:i instanceof Error?i.message:String(i),path:n}}const{errors:o,value:l}=w(a);if(o.length>0)return{action:"invalid",error:`parse error at offset ${String(o[0]?.offset??0)}`,path:n};if(S(l,r,t)===void 0)return{action:"absent",path:n};const c=M(a,n,r,t,void 0);return c===void 0?{action:"removed",path:n}:{action:"invalid",error:c,path:n}},he=["global","project"],d=(e,r)=>{const t=q(r,e);return t.length>0&&!t.startsWith("..")?t:e},ye=(e,r)=>{const t=e.paths(r);return he.flatMap(n=>{const a=t[n];return a===void 0?[]:[{client:e,path:a,scope:n}]})},be=(e,r,t,n)=>{const a=e.paths(r),o=t==="global"?"project":"global",l=a[t]??(n?void 0:a[o]);if(l!==void 0)return{client:e,path:l,scope:a[t]===void 0?o:t}},we=e=>p.filter(r=>Object.values(r.paths(e)).some(t=>u(t))),_=(e,r,t,n)=>{if(e.length===0)return r();const a=[];for(const o of e){const l=fe(o);if(l===void 0){t.error(`mcp ${n}: unknown client "${o}". Known clients: ${O.join(", ")}.`);return}a.push(l)}return a},Se=e=>e.client.format==="json",ke="https://lunora.sh/mcp",L="lunora-docs",N="lunora",je=e=>u(s(e,"lunora"))&&V(e)!==void 0,$e=e=>{const{args:r,command:t}=X(e,"lunora",["mcp","serve"]);return{args:r,command:t,transport:"stdio"}},Ee=e=>({transport:"http",url:e}),Oe=e=>({home:e.home,platform:e.platform,projectRoot:e.cwd}),U=(e,r,t)=>be(e,Oe(t),t.scope??r.preferredScope,t.scope!==void 0||!r.allowScopeFallback),Ce=(e,r,t)=>{const n=U(e,r,t);if(n===void 0){t.logger.warn(`${e.label}: has no ${t.scope??r.preferredScope}-scoped config — skipped "${r.name}".`);return}const{path:a}=n,o=e.buildEntry(r.spec);if(t.print===!0){const i=d(a,t.cwd);return t.force!==!0&&ge({key:e.key,name:r.name,path:a})?(t.logger.info(`${e.label}: "${r.name}" already configured in ${i} — a real install would skip it (re-run with --force to replace).`),{action:"printed",path:a}):(t.logger.info(`${e.label} → ${i}
|
|
3
|
+
${JSON.stringify({[e.key]:{[r.name]:o}},void 0,4)}`),{action:"printed",path:a})}const l=pe({entry:o,force:t.force===!0,key:e.key,name:r.name,path:a}),c=d(a,t.cwd);return l.action==="invalid"?t.logger.error(`${e.label}: ${c} is not valid JSON (${l.error??"unknown error"}) — left untouched.`):l.action==="skipped"?t.logger.info(`${e.label}: "${r.name}" already configured in ${c} — re-run with --force to replace it.`):t.logger.success(`${e.label}: ${l.action==="created"?"created":"updated"} ${c} with "${r.name}".`),{action:l.action,path:a}},xe=(e,r,t)=>{const n=U(e,r,t)?.path;if(n===void 0){t.logger.warn(`${e.label}: no known config location on ${t.platform} — skipped.`);return}return t.logger.info(`${e.label}: add this to ${d(n,t.cwd)}
|
|
4
|
+
|
|
5
|
+
${e.renderSnippet(r.name,r.spec)}`),{action:"printed",path:n}},Me=e=>{const r=[];return e.localOnly!==!0&&r.push({allowScopeFallback:!0,name:L,preferredScope:"global",spec:Ee(e.docsUrl??ke)}),e.docsOnly!==!0&&je(e.cwd)&&r.push({allowScopeFallback:!1,name:N,preferredScope:"project",spec:$e(B(e.cwd))}),r},_e=e=>{const r=e.home??b(),t=e.platform??process.platform;e.logger.info("Supported MCP clients:");for(const n of p){const a=n.paths({home:r,platform:t,projectRoot:e.cwd}),o=l=>{const c=a[l];return c===void 0?"—":d(c,e.cwd)};e.logger.info(` ${n.id.padEnd(15)} ${n.label.padEnd(24)} project: ${o("project").padEnd(30)} global: ${o("global")}`)}return{code:0,written:[]}},Le=e=>e.docsOnly===!0&&e.localOnly===!0?"`--docs-only` and `--local-only` are mutually exclusive — pass at most one.":"`--local-only` was set but this directory is not a Lunora project (no `lunora/` directory and wrangler config).",Ne=(e,r,t)=>{const n=[];for(const a of e)for(const o of r){const l=a.format==="json"?Ce(a,o,t):xe(a,o,t);l!==void 0&&n.push({action:l.action,client:a.id,path:l.path,server:o.name})}return n},Ue=e=>{const r=e.home??b(),t=e.platform??process.platform,n=_(e.clients,()=>we({home:r,platform:t,projectRoot:e.cwd}),e.logger,"install");if(n===void 0)return{code:1,written:[]};if(n.length===0)return e.logger.error(`mcp install: no MCP client config found — name one explicitly, e.g. \`lunora mcp install claude-code\`. Known clients: ${O.join(", ")}.`),{code:1,written:[]};e.clients.length===0&&e.logger.info(`Detected ${String(n.length)} configured client(s): ${n.map(l=>l.label).join(", ")}.`);const a=Me(e);if(a.length===0)return e.logger.error(`mcp install: nothing to install — ${Le(e)}`),{code:1,written:[]};const o=Ne(n,a,{...e,home:r,platform:t});return o.some(l=>l.action==="created"||l.action==="updated")&&e.logger.info("Restart your editor (or reload its MCP servers) to pick up the change."),{code:o.some(l=>l.action==="invalid")?1:0,written:o}},A=100,F=1e3,j=e=>({content:[{text:JSON.stringify(e,void 0,2),type:"text"}]}),Ae=e=>({content:[{text:e,type:"text"}]}),Fe=e=>{const r=typeof e=="string"?Number(e):e;return typeof r!="number"||!Number.isFinite(r)?A:Math.min(F,Math.max(1,Math.floor(r)))},Pe=(e,r)=>{const t=v(e,"utf8").split(`
|
|
6
|
+
`);return t.at(-1)===""&&t.pop(),t.slice(-r).join(`
|
|
7
|
+
`)},Re=e=>[{definition:{description:"Report whether a `lunora dev` server is running for this project, and its URL, studio URL, mode and uptime. Call this first when a query or mutation tool fails to connect.",inputSchema:{properties:{},type:"object"},name:"lunora_dev_status"},handle:async()=>{const r=y(e);return j(r===void 0?{hint:"Start it with `lunora dev` in the project directory.",running:!1}:{background:r.background===!0,logFile:r.logFile,mode:r.mode,pid:r.pid,running:!0,startedAt:r.startedAt,studioUrl:r.studioUrl,url:r.url})}},{definition:{description:"Return the tail of the running dev server's captured log — worker output, request errors, and stack traces. Only available when the server was started in the background (`lunora dev --background`); a foreground server prints to its own terminal.",inputSchema:{properties:{lines:{description:`How many trailing lines to return (default ${String(A)}, max ${String(F)})`,type:"number"}},type:"object"},name:"lunora_dev_logs"},handle:async r=>{const t=y(e);if(t===void 0)return{content:[{text:"no dev server is running — start one with `lunora dev`",type:"text"}],isError:!0};if(t.logFile===void 0||!u(t.logFile))return{content:[{text:"this dev server is not capturing its output to a file (it runs in the foreground) — restart it with `lunora dev --background` to make its logs readable here",type:"text"}],isError:!0};const n=Fe(r.lines),a=Pe(t.logFile,n);return Ae(a.length===0?"(the dev server log is empty)":a)}}],Te=new Set(["127.0.0.1","::1","localhost"]),P=e=>{try{const{hostname:r}=new URL(e);return Te.has(r.startsWith("[")?r.slice(1,-1):r)}catch{return!1}},$=e=>{const r=e.url??y(e.cwd)?.url;if(r===void 0||r.length===0)return;if(e.token!==void 0&&e.token.length>0)return{token:e.token,url:r};if(e.url!==void 0&&!P(e.url))return{url:r};const t=re(e.cwd);return t===void 0||t.length===0?{url:r}:{token:t,url:r}},De=async e=>{await new Promise(r=>{const t=()=>{r()};e.onclose=t,process.stdin.once("close",t),process.stdin.once("end",t)})},Ie=(e,r)=>{if(e===void 0)return"lunora mcp serve: ready (documentation tools). No dev server running yet — start `lunora dev` and the deployment tools start working, no restart needed.\n";if(e.token!==void 0)return`lunora mcp serve: ready — deployment at ${e.url}
|
|
8
|
+
`;const n=r.url!==void 0&&!P(r.url)?"the project's admin token was NOT sent to this non-local --url; pass --token to authenticate deliberately":"no LUNORA_ADMIN_TOKEN in the environment or .dev.vars; the deployment tools will be refused until one is set";return`lunora mcp serve: ready — deployment at ${e.url} (${n})
|
|
9
|
+
`},Je=async(e,r=te)=>{const t=e.writeError??(o=>{process.stderr.write(o)});let n;try{n=await r({allowWrites:e.allowWrites===!0,deployment:()=>$(e),docs:e.noDocs===!0?!1:{...e.docsUrl===void 0?{}:{baseUrl:e.docsUrl}},extraTools:Re(e.cwd),version:e.version})}catch(o){const l=o instanceof Error?o.message:String(o);return t(`lunora mcp serve: failed to start — ${l}
|
|
10
|
+
`),{code:1,deployment:void 0}}const a=$(e);return t(Ie(a,e)),await De(n),{code:0,deployment:a}},We=e=>{const r=[];return e.localOnly!==!0&&r.push(L),e.docsOnly!==!0&&r.push(N),r},ze=(e,r,t,n)=>{const a=ve({key:e.key,name:r,path:t}),o=d(t,n.cwd);return a.action==="removed"?n.logger.success(`${e.label}: removed "${r}" from ${o}.`):a.action==="invalid"&&n.logger.error(`${e.label}: ${o} is not valid JSON (${a.error??"unknown error"}) — left untouched.`),{action:a.action,path:t}},Ge=(e,r,t,n)=>{const a=x({key:e.key,name:r,path:t}),o=d(t,n.cwd);return a==="invalid"?(n.logger.error(`${e.label}: ${o} is not valid JSON — a real run would report it and exit non-zero.`),{action:"invalid",path:t}):a==="absent"?{action:"absent",path:t}:(n.logger.info(`${e.label}: would remove "${r}" from ${o}.`),{action:"removed",path:t})},He=(e,r,t)=>e.flatMap(n=>ye(n,r)).filter(Se).filter(n=>t===void 0||n.scope===t),Ve=e=>{const r=e.home??b(),t=e.platform??process.platform,n=_(e.clients,()=>p,e.logger,"uninstall");if(n===void 0)return{code:1,removed:[]};const a=We(e);if(a.length===0)return e.logger.error("mcp uninstall: nothing to remove — `--docs-only` and `--local-only` are mutually exclusive, pass at most one."),{code:1,removed:[]};const o=[],l={home:r,platform:t,projectRoot:e.cwd};for(const c of He(n,l,e.scope))for(const i of a){const m=e.print===!0?Ge(c.client,i,c.path,e):ze(c.client,i,c.path,e);m.action!=="absent"&&o.push({...m,client:c.client.id,server:i})}return o.length===0?e.logger.info("Nothing to remove — no Lunora MCP servers were configured in the clients checked."):e.print===!0&&e.logger.info("Nothing was changed — re-run without --print to remove these."),{code:o.some(c=>c.action==="invalid")?1:0,removed:o}},E=e=>e.global===!0?"global":e.project===!0?"project":void 0,Ke=async(e,r)=>{const{code:t}=await Je({allowWrites:r.allowWrites===!0,cwd:e,noDocs:r.docs===!1,version:R,...r.docsUrl===void 0?{}:{docsUrl:r.docsUrl},...r.token===void 0?{}:{token:r.token},...r.url===void 0?{}:{url:r.url}});return{code:t}},lr=T(async({argument:e,cwd:r,logger:t,options:n})=>{const[a,...o]=e;if(a==="serve")return Ke(r,n);if(a==="uninstall"){const l=E(n),{code:c}=Ve({clients:o,cwd:r,docsOnly:n.docsOnly===!0,localOnly:n.localOnly===!0,logger:t,print:n.print===!0,...l===void 0?{}:{scope:l}});return{code:c}}if(a==="install"){if(n.list===!0)return _e({cwd:r,logger:t});const l=E(n),{code:c}=Ue({clients:o,cwd:r,docsOnly:n.docsOnly===!0,force:n.force===!0,localOnly:n.localOnly===!0,logger:t,print:n.print===!0,...l===void 0?{}:{scope:l},...n.docsUrl===void 0?{}:{docsUrl:n.docsUrl}});return{code:c}}return t.error("mcp: unknown subcommand. Usage: lunora mcp <install|uninstall|serve>"),{code:1}});export{lr as execute};
|
|
@@ -1,204 +1 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { mkdir, readFile, writeFile } from 'node:fs/promises';
|
|
3
|
-
import { join } from 'node:path';
|
|
4
|
-
import { r as resolveAdminBaseUrl } from '../packem_shared/admin-url-4UzT-CI4.mjs';
|
|
5
|
-
import { d as defineHandler } from '../packem_shared/command-BDXcJCCJ.mjs';
|
|
6
|
-
import { a as resolveProductionWorkerUrl } from '../packem_shared/resolve-target-qbsJ_5sF.mjs';
|
|
7
|
-
import { runExportCommand, runImportCommand } from '../packem_shared/DEFAULT_IMPORT_BATCH_SIZE-Ck-2bU08.mjs';
|
|
8
|
-
|
|
9
|
-
const DEFAULT_BACKUP_DIR = ".lunora-backups";
|
|
10
|
-
const MANIFEST_FILE = "manifest.json";
|
|
11
|
-
const PITR_ENDPOINT_PATH = "/_lunora/admin/pitr";
|
|
12
|
-
const GET_PITR_BOOKMARK_OP = "__lunora_admin__:getPitrBookmark";
|
|
13
|
-
const PITR_RESTORE_OP = "__lunora_admin__:pitrRestore";
|
|
14
|
-
const isManifestEntry = (value) => typeof value === "object" && value !== null && typeof value.id === "string" && typeof value.file === "string";
|
|
15
|
-
const readManifest = async (directory) => {
|
|
16
|
-
const path = join(directory, MANIFEST_FILE);
|
|
17
|
-
if (!existsSync(path)) {
|
|
18
|
-
return [];
|
|
19
|
-
}
|
|
20
|
-
let parsed;
|
|
21
|
-
try {
|
|
22
|
-
parsed = JSON.parse(await readFile(path, "utf8"));
|
|
23
|
-
} catch (error) {
|
|
24
|
-
const message = error instanceof Error ? error.message : String(error);
|
|
25
|
-
throw new Error(`backup: ${path} exists but is not valid JSON (${message}) — refusing to overwrite it; fix or remove it manually`, { cause: error });
|
|
26
|
-
}
|
|
27
|
-
if (!Array.isArray(parsed)) {
|
|
28
|
-
throw new TypeError(`backup: ${path} exists but is not a JSON array — refusing to overwrite it; fix or remove it manually`);
|
|
29
|
-
}
|
|
30
|
-
return parsed.filter(isManifestEntry);
|
|
31
|
-
};
|
|
32
|
-
const writeManifest = async (directory, entries) => {
|
|
33
|
-
await writeFile(join(directory, MANIFEST_FILE), `${JSON.stringify(entries, void 0, 2)}
|
|
34
|
-
`, "utf8");
|
|
35
|
-
};
|
|
36
|
-
const runBackupCreate = async (options, directory) => {
|
|
37
|
-
await mkdir(directory, { recursive: true });
|
|
38
|
-
const timestamp = (options.now ?? (() => /* @__PURE__ */ new Date()))().toISOString();
|
|
39
|
-
const file = `lunora-backup-${timestamp.replaceAll(/[.:]/gu, "-")}.ndjson`;
|
|
40
|
-
const result = await runExportCommand({
|
|
41
|
-
fetchImpl: options.fetchImpl,
|
|
42
|
-
logger: options.logger,
|
|
43
|
-
out: join(directory, file),
|
|
44
|
-
prod: options.prod,
|
|
45
|
-
tables: options.tables,
|
|
46
|
-
token: options.token,
|
|
47
|
-
url: options.url
|
|
48
|
-
});
|
|
49
|
-
if (result.code !== 0) {
|
|
50
|
-
return { code: result.code };
|
|
51
|
-
}
|
|
52
|
-
const entry = { bytes: result.bytes, createdAt: timestamp, file, id: timestamp, rows: result.rows, tables: options.tables };
|
|
53
|
-
const manifest = await readManifest(directory);
|
|
54
|
-
manifest.push(entry);
|
|
55
|
-
await writeManifest(directory, manifest);
|
|
56
|
-
options.logger.success(`backup created: ${file} (${result.rows.toString()} rows, ${result.bytes.toString()} bytes)`);
|
|
57
|
-
return { code: 0, entry };
|
|
58
|
-
};
|
|
59
|
-
const runBackupList = async (options, directory) => {
|
|
60
|
-
const manifest = await readManifest(directory);
|
|
61
|
-
if (manifest.length === 0) {
|
|
62
|
-
options.logger.info(`no backups found in ${directory}`);
|
|
63
|
-
return { code: 0 };
|
|
64
|
-
}
|
|
65
|
-
for (const entry of manifest) {
|
|
66
|
-
options.logger.info(`${entry.id} ${entry.rows.toString()} rows ${entry.bytes.toString()} bytes ${entry.file}`);
|
|
67
|
-
}
|
|
68
|
-
return { code: 0 };
|
|
69
|
-
};
|
|
70
|
-
const runBackupRestore = async (options, directory) => {
|
|
71
|
-
const { target } = options;
|
|
72
|
-
if (target === void 0 || target.length === 0) {
|
|
73
|
-
options.logger.error("restore requires a backup id or file path. Usage: lunora backup restore <id|file>");
|
|
74
|
-
return { code: 1 };
|
|
75
|
-
}
|
|
76
|
-
const manifest = await readManifest(directory);
|
|
77
|
-
const matched = manifest.find((entry) => entry.id === target);
|
|
78
|
-
const file = matched ? join(directory, matched.file) : target;
|
|
79
|
-
if (!existsSync(file)) {
|
|
80
|
-
options.logger.error(`backup not found: ${target}`);
|
|
81
|
-
return { code: 1 };
|
|
82
|
-
}
|
|
83
|
-
const result = await runImportCommand({
|
|
84
|
-
fetchImpl: options.fetchImpl,
|
|
85
|
-
file,
|
|
86
|
-
logger: options.logger,
|
|
87
|
-
prod: options.prod,
|
|
88
|
-
token: options.token,
|
|
89
|
-
url: options.url
|
|
90
|
-
});
|
|
91
|
-
return { code: result.code };
|
|
92
|
-
};
|
|
93
|
-
const resolvePitrRequest = (options) => {
|
|
94
|
-
const token = options.token ?? process.env.LUNORA_ADMIN_TOKEN;
|
|
95
|
-
if (!token) {
|
|
96
|
-
options.logger.error("admin token required — pass --token or set LUNORA_ADMIN_TOKEN");
|
|
97
|
-
return void 0;
|
|
98
|
-
}
|
|
99
|
-
if (options.prod && options.url === void 0) {
|
|
100
|
-
options.logger.error("--prod requires an explicit --url (refusing to target the implicit localhost worker)");
|
|
101
|
-
return void 0;
|
|
102
|
-
}
|
|
103
|
-
if (options.restore === true && options.at === void 0 && options.bookmark === void 0) {
|
|
104
|
-
options.logger.error("pitr --restore requires --at <time> or --bookmark <bookmark>");
|
|
105
|
-
return void 0;
|
|
106
|
-
}
|
|
107
|
-
if (options.restore === true && options.prod === true && options.yes !== true) {
|
|
108
|
-
options.logger.error("pitr --restore --prod restores production data in place. Re-run with --yes to confirm.");
|
|
109
|
-
return void 0;
|
|
110
|
-
}
|
|
111
|
-
const baseUrl = resolveAdminBaseUrl(options.url, options.logger);
|
|
112
|
-
if (baseUrl === void 0) {
|
|
113
|
-
return void 0;
|
|
114
|
-
}
|
|
115
|
-
const fetchImpl = options.pitrFetch ?? globalThis.fetch;
|
|
116
|
-
if (typeof fetchImpl !== "function") {
|
|
117
|
-
throw new TypeError("no fetch implementation available — pass pitrFetch or run on Node >= 18");
|
|
118
|
-
}
|
|
119
|
-
return { fetchImpl, requestUrl: `${baseUrl}${PITR_ENDPOINT_PATH}`, token };
|
|
120
|
-
};
|
|
121
|
-
const buildPitrArgs = (options, isRestore) => {
|
|
122
|
-
const args = {};
|
|
123
|
-
if (options.at !== void 0) {
|
|
124
|
-
args.time = options.at;
|
|
125
|
-
}
|
|
126
|
-
if (isRestore && options.bookmark !== void 0) {
|
|
127
|
-
args.bookmark = options.bookmark;
|
|
128
|
-
}
|
|
129
|
-
if (isRestore && options.restart === true) {
|
|
130
|
-
args.restart = true;
|
|
131
|
-
}
|
|
132
|
-
return args;
|
|
133
|
-
};
|
|
134
|
-
const runBackupPitr = async (options) => {
|
|
135
|
-
const request = resolvePitrRequest(options);
|
|
136
|
-
if (request === void 0) {
|
|
137
|
-
return { code: 1 };
|
|
138
|
-
}
|
|
139
|
-
const isRestore = options.restore === true;
|
|
140
|
-
const functionPath = isRestore ? PITR_RESTORE_OP : GET_PITR_BOOKMARK_OP;
|
|
141
|
-
const args = buildPitrArgs(options, isRestore);
|
|
142
|
-
const action = isRestore ? "restore" : "bookmark";
|
|
143
|
-
options.logger.info(`POST ${request.requestUrl} -> pitr ${action}${options.shard === void 0 ? "" : ` (shard "${options.shard}")`}`);
|
|
144
|
-
const response = await request.fetchImpl(request.requestUrl, {
|
|
145
|
-
body: JSON.stringify({ args, functionPath, shardKey: options.shard }),
|
|
146
|
-
headers: { authorization: `Bearer ${request.token}`, "content-type": "application/json" },
|
|
147
|
-
method: "POST"
|
|
148
|
-
});
|
|
149
|
-
const text = await response.text();
|
|
150
|
-
let body;
|
|
151
|
-
try {
|
|
152
|
-
body = JSON.parse(text);
|
|
153
|
-
} catch {
|
|
154
|
-
body = text;
|
|
155
|
-
}
|
|
156
|
-
options.logger.info(JSON.stringify(body, void 0, 2));
|
|
157
|
-
return { code: response.ok ? 0 : 1 };
|
|
158
|
-
};
|
|
159
|
-
const runBackupCommand = async (options) => {
|
|
160
|
-
const cwd = options.cwd ?? process.cwd();
|
|
161
|
-
const directory = join(cwd, options.dir ?? DEFAULT_BACKUP_DIR);
|
|
162
|
-
try {
|
|
163
|
-
if (options.subcommand === "create") {
|
|
164
|
-
return await runBackupCreate(options, directory);
|
|
165
|
-
}
|
|
166
|
-
if (options.subcommand === "list") {
|
|
167
|
-
return await runBackupList(options, directory);
|
|
168
|
-
}
|
|
169
|
-
if (options.subcommand === "pitr") {
|
|
170
|
-
return await runBackupPitr(options);
|
|
171
|
-
}
|
|
172
|
-
return await runBackupRestore(options, directory);
|
|
173
|
-
} catch (error) {
|
|
174
|
-
options.logger.error(error instanceof Error ? error.message : String(error));
|
|
175
|
-
return { code: 1 };
|
|
176
|
-
}
|
|
177
|
-
};
|
|
178
|
-
const isBackupSubcommand = (value) => value === "create" || value === "list" || value === "pitr" || value === "restore";
|
|
179
|
-
const execute = defineHandler(({ argument, cwd, logger, options }) => {
|
|
180
|
-
const sub = argument[0];
|
|
181
|
-
if (!isBackupSubcommand(sub)) {
|
|
182
|
-
logger.error(`backup: unknown subcommand "${sub ?? ""}" — expected create | list | restore | pitr`);
|
|
183
|
-
return { code: 1 };
|
|
184
|
-
}
|
|
185
|
-
return runBackupCommand({
|
|
186
|
-
at: options.at,
|
|
187
|
-
bookmark: options.bookmark,
|
|
188
|
-
cwd,
|
|
189
|
-
dir: options.dir,
|
|
190
|
-
logger,
|
|
191
|
-
prod: options.prod === true,
|
|
192
|
-
restart: options.restart === true,
|
|
193
|
-
restore: options.restore === true,
|
|
194
|
-
shard: options.shard,
|
|
195
|
-
subcommand: sub,
|
|
196
|
-
tables: options.tables,
|
|
197
|
-
target: argument[1],
|
|
198
|
-
token: options.token,
|
|
199
|
-
url: resolveProductionWorkerUrl({ cwd, prod: options.prod === true, url: options.url }),
|
|
200
|
-
yes: options.yes === true
|
|
201
|
-
});
|
|
202
|
-
});
|
|
203
|
-
|
|
204
|
-
export { execute, runBackupCommand };
|
|
1
|
+
import{d as i}from"../packem_shared/command-DwC11Cwe.mjs";import{e as l,d as m}from"../packem_shared/detect-package-manager-DSaAqRof.mjs";import{i as g}from"../packem_shared/docker-DpVxvYpL.mjs";import{defaultSpawner as p}from"../packem_shared/createRecordingSpawner-DJlNacZ6.mjs";const o=new Set(["build","delete","images","info","list","push"]),f=new Set(["build","push"]),h=async e=>{const[a,...s]=e.argument;if(a===void 0||!o.has(a))return e.logger.error(`lunora containers requires a subcommand: ${[...o].toSorted((u,d)=>u.localeCompare(d)).join(" | ")}. Example: lunora containers build ./containers/app --tag app:v1 --push`),{code:1};if(f.has(a)&&!(e.dockerAvailable??g)())return e.logger.error(`containers ${a} needs a running Docker-compatible engine (it builds/pushes images locally). Start Docker or Colima and retry. Note: container images must target linux/amd64.`),{code:1};const r=["containers",a,...s];e.tag!==void 0&&r.push("--tag",e.tag),e.push===!0&&r.push("--push"),e.env!==void 0&&r.push("--env",e.env);const t=e.cwd??process.cwd(),c=l(m(t),"wrangler",r),n={args:c.args,command:c.command,cwd:t};return e.logger.info(`running ${n.command} ${n.args.join(" ")}`),{code:(await(e.spawner??p)(n)).code,descriptor:n}},D=i(async({argument:e,cwd:a,logger:s,options:r})=>({code:(await h({argument:e,cwd:a,env:r.env,logger:s,push:r.push===!0,tag:r.tag})).code}));export{D as execute,h as runContainersCommand};
|
|
@@ -1,33 +1 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { d as defineHandler } from '../packem_shared/command-BDXcJCCJ.mjs';
|
|
3
|
-
import { runDeployCommand } from './runDeployCommand.mjs';
|
|
4
|
-
|
|
5
|
-
const DEFAULT_OUT_DIR = ".lunora/build";
|
|
6
|
-
const runBuildCommand = async (options) => {
|
|
7
|
-
const outDirectory = options.outDir ?? DEFAULT_OUT_DIR;
|
|
8
|
-
const result = await runDeployCommand({
|
|
9
|
-
apiSpec: options.apiSpec,
|
|
10
|
-
cwd: options.cwd,
|
|
11
|
-
dryRun: true,
|
|
12
|
-
format: options.format,
|
|
13
|
-
logger: options.logger,
|
|
14
|
-
outDir: outDirectory,
|
|
15
|
-
spawner: options.spawner
|
|
16
|
-
});
|
|
17
|
-
if (result.code === 0) {
|
|
18
|
-
options.logger.success(`build complete — bundle written to ${outDirectory}`);
|
|
19
|
-
}
|
|
20
|
-
return result;
|
|
21
|
-
};
|
|
22
|
-
const execute = defineHandler(async ({ cwd, logger, options }) => {
|
|
23
|
-
const result = await runBuildCommand({
|
|
24
|
-
apiSpec: parseApiSpec(options.apiSpec),
|
|
25
|
-
cwd,
|
|
26
|
-
format: options.format,
|
|
27
|
-
logger,
|
|
28
|
-
outDir: options.outDir
|
|
29
|
-
});
|
|
30
|
-
return { code: result.code };
|
|
31
|
-
});
|
|
32
|
-
|
|
33
|
-
export { execute, runBuildCommand };
|
|
1
|
+
import{d}from"../packem_shared/command-DwC11Cwe.mjs";import{e as a,d as m}from"../packem_shared/detect-package-manager-DSaAqRof.mjs";import{defaultSpawner as i}from"../packem_shared/createRecordingSpawner-DJlNacZ6.mjs";const t=(e,r)=>(r!==void 0&&e.push("--env",r),e),u=e=>{const r=t(["deployments","list"],e.env);return e.json&&r.push("--json"),r},l=e=>{switch(e.subcommand){case"inspect":return e.versionId===void 0?{error:"deployments inspect requires a version id. Usage: lunora deployments inspect <version-id>"}:{args:t(["versions","view",e.versionId],e.env)};case"list":return{args:u(e)};case"promote":{if(e.versionId===void 0)return{error:"deployments promote requires a version id. Usage: lunora deployments promote <version-id> --yes"};if(!e.yes)return{error:"deployments promote shifts 100% of live traffic. Re-run with --yes to confirm."};const r=t(["versions","deploy",`${e.versionId}@100%`,"--yes"],e.env);return e.message!==void 0&&r.push("--message",e.message),{args:r}}case"rollback":{if(!e.yes)return{error:"deployments rollback changes the live version. Re-run with --yes to confirm."};const r=t(["rollback"],e.env);return e.versionId!==void 0&&r.push(e.versionId),r.push("--yes"),e.message!==void 0&&r.push("--message",e.message),{args:r}}default:return{error:`deployments: unknown subcommand "${e.subcommand}"`}}},v=async e=>{const{args:r,error:n}=l(e);if(n!==void 0||r===void 0)return e.logger.error(n??"deployments: nothing to run"),{code:1,descriptor:void 0,error:n};const s=e.cwd??process.cwd(),o=a(m(s),"wrangler",r),c={args:o.args,command:o.command,cwd:s};return e.logger.info(`${c.command} ${c.args.join(" ")}`),{code:(await(e.spawner??i)(c)).code,descriptor:c}},g=e=>e==="list"||e==="inspect"||e==="rollback"||e==="promote",h=d(({argument:e,cwd:r,logger:n,options:s})=>{const o=e[0];return g(o)?v({cwd:r,env:s.env,json:s.json===!0,logger:n,message:s.message,subcommand:o,versionId:e[1],yes:s.yes===!0}):(n.error(`deployments: unknown subcommand "${o??""}" — expected list | inspect | rollback | promote`),{code:1})});export{h as execute,v as runDeploymentsCommand};
|
|
@@ -1,49 +1 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { i as isDockerAvailable } from '../packem_shared/docker-hMQ97KSQ.mjs';
|
|
3
|
-
import { defaultSpawner } from '../packem_shared/defaultSpawner-DxI3mebw.mjs';
|
|
4
|
-
|
|
5
|
-
const SUBCOMMANDS = /* @__PURE__ */ new Set(["build", "delete", "images", "info", "list", "push"]);
|
|
6
|
-
const NEEDS_DOCKER = /* @__PURE__ */ new Set(["build", "push"]);
|
|
7
|
-
const runContainersCommand = async (options) => {
|
|
8
|
-
const [subcommand, ...rest] = options.argument;
|
|
9
|
-
if (subcommand === void 0 || !SUBCOMMANDS.has(subcommand)) {
|
|
10
|
-
options.logger.error(
|
|
11
|
-
`lunora containers requires a subcommand: ${[...SUBCOMMANDS].toSorted((a, b) => a.localeCompare(b)).join(" | ")}. Example: lunora containers build ./containers/app --tag app:v1 --push`
|
|
12
|
-
);
|
|
13
|
-
return { code: 1 };
|
|
14
|
-
}
|
|
15
|
-
if (NEEDS_DOCKER.has(subcommand) && !(options.dockerAvailable ?? isDockerAvailable)()) {
|
|
16
|
-
options.logger.error(
|
|
17
|
-
`containers ${subcommand} needs a running Docker-compatible engine (it builds/pushes images locally). Start Docker or Colima and retry. Note: container images must target linux/amd64.`
|
|
18
|
-
);
|
|
19
|
-
return { code: 1 };
|
|
20
|
-
}
|
|
21
|
-
const args = ["exec", "wrangler", "containers", subcommand, ...rest];
|
|
22
|
-
if (options.tag !== void 0) {
|
|
23
|
-
args.push("--tag", options.tag);
|
|
24
|
-
}
|
|
25
|
-
if (options.push === true) {
|
|
26
|
-
args.push("--push");
|
|
27
|
-
}
|
|
28
|
-
if (options.env !== void 0) {
|
|
29
|
-
args.push("--env", options.env);
|
|
30
|
-
}
|
|
31
|
-
const descriptor = { args, command: "pnpm", cwd: options.cwd ?? process.cwd() };
|
|
32
|
-
options.logger.info(`running ${descriptor.command} ${descriptor.args.join(" ")}`);
|
|
33
|
-
const spawner = options.spawner ?? defaultSpawner;
|
|
34
|
-
const result = await spawner(descriptor);
|
|
35
|
-
return { code: result.code, descriptor };
|
|
36
|
-
};
|
|
37
|
-
const execute = defineHandler(async ({ argument, cwd, logger, options }) => {
|
|
38
|
-
const result = await runContainersCommand({
|
|
39
|
-
argument,
|
|
40
|
-
cwd,
|
|
41
|
-
env: options.env,
|
|
42
|
-
logger,
|
|
43
|
-
push: options.push === true,
|
|
44
|
-
tag: options.tag
|
|
45
|
-
});
|
|
46
|
-
return { code: result.code };
|
|
47
|
-
});
|
|
48
|
-
|
|
49
|
-
export { execute, runContainersCommand };
|
|
1
|
+
import{d as s}from"../packem_shared/command-DwC11Cwe.mjs";import{o as c}from"../packem_shared/open-url-EnKy--w-.mjs";const n="https://lunora.sh/docs",l=r=>{let e=0,t=r.length;for(;e<t&&r[e]==="/";)e+=1;for(;t>e&&r[t-1]==="/";)t-=1;return r.slice(e,t)},i=r=>{if(!r||r.length===0)return n;const e=l(r);return e.length===0?n:`${n}/${e}`},a=async r=>{const e=i(r.section);r.logger.info(`opening ${e}`);try{await c(e,{opener:r.opener})}catch(t){const o=t instanceof Error?t.message:String(t);return r.logger.error(`docs: failed to open URL: ${o}`),{code:1,url:e}}return{code:0,url:e}},m=s(({argument:r,logger:e})=>a({logger:e,section:r[0]}));export{m as execute,a as runDocsCommand};
|
|
@@ -1,91 +1 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { defaultSpawner } from '../packem_shared/defaultSpawner-DxI3mebw.mjs';
|
|
3
|
-
|
|
4
|
-
const withEnv = (args, env) => {
|
|
5
|
-
if (env !== void 0) {
|
|
6
|
-
args.push("--env", env);
|
|
7
|
-
}
|
|
8
|
-
return args;
|
|
9
|
-
};
|
|
10
|
-
const buildListArgs = (options) => {
|
|
11
|
-
const args = withEnv(["exec", "wrangler", "deployments", "list"], options.env);
|
|
12
|
-
if (options.json) {
|
|
13
|
-
args.push("--json");
|
|
14
|
-
}
|
|
15
|
-
return args;
|
|
16
|
-
};
|
|
17
|
-
const buildArgs = (options) => {
|
|
18
|
-
switch (options.subcommand) {
|
|
19
|
-
case "inspect": {
|
|
20
|
-
if (options.versionId === void 0) {
|
|
21
|
-
return { error: "deployments inspect requires a version id. Usage: lunora deployments inspect <version-id>" };
|
|
22
|
-
}
|
|
23
|
-
return { args: withEnv(["exec", "wrangler", "versions", "view", options.versionId], options.env) };
|
|
24
|
-
}
|
|
25
|
-
case "list": {
|
|
26
|
-
return { args: buildListArgs(options) };
|
|
27
|
-
}
|
|
28
|
-
case "promote": {
|
|
29
|
-
if (options.versionId === void 0) {
|
|
30
|
-
return { error: "deployments promote requires a version id. Usage: lunora deployments promote <version-id> --yes" };
|
|
31
|
-
}
|
|
32
|
-
if (!options.yes) {
|
|
33
|
-
return { error: "deployments promote shifts 100% of live traffic. Re-run with --yes to confirm." };
|
|
34
|
-
}
|
|
35
|
-
const args = withEnv(["exec", "wrangler", "versions", "deploy", `${options.versionId}@100%`, "--yes"], options.env);
|
|
36
|
-
if (options.message !== void 0) {
|
|
37
|
-
args.push("--message", options.message);
|
|
38
|
-
}
|
|
39
|
-
return { args };
|
|
40
|
-
}
|
|
41
|
-
case "rollback": {
|
|
42
|
-
if (!options.yes) {
|
|
43
|
-
return { error: "deployments rollback changes the live version. Re-run with --yes to confirm." };
|
|
44
|
-
}
|
|
45
|
-
const args = withEnv(["exec", "wrangler", "rollback"], options.env);
|
|
46
|
-
if (options.versionId !== void 0) {
|
|
47
|
-
args.push(options.versionId);
|
|
48
|
-
}
|
|
49
|
-
args.push("--yes");
|
|
50
|
-
if (options.message !== void 0) {
|
|
51
|
-
args.push("--message", options.message);
|
|
52
|
-
}
|
|
53
|
-
return { args };
|
|
54
|
-
}
|
|
55
|
-
default: {
|
|
56
|
-
return { error: `deployments: unknown subcommand "${options.subcommand}"` };
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
};
|
|
60
|
-
const runDeploymentsCommand = async (options) => {
|
|
61
|
-
const { args, error } = buildArgs(options);
|
|
62
|
-
if (error !== void 0 || args === void 0) {
|
|
63
|
-
options.logger.error(error ?? "deployments: nothing to run");
|
|
64
|
-
return { code: 1, descriptor: void 0, error };
|
|
65
|
-
}
|
|
66
|
-
const descriptor = { args, command: "pnpm", cwd: options.cwd ?? process.cwd() };
|
|
67
|
-
options.logger.info(`${descriptor.command} ${descriptor.args.join(" ")}`);
|
|
68
|
-
const spawner = options.spawner ?? defaultSpawner;
|
|
69
|
-
const result = await spawner(descriptor);
|
|
70
|
-
return { code: result.code, descriptor };
|
|
71
|
-
};
|
|
72
|
-
const isDeploymentsSubcommand = (value) => value === "list" || value === "inspect" || value === "rollback" || value === "promote";
|
|
73
|
-
const execute = defineHandler(({ argument, cwd, logger, options }) => {
|
|
74
|
-
const sub = argument[0];
|
|
75
|
-
if (!isDeploymentsSubcommand(sub)) {
|
|
76
|
-
logger.error(`deployments: unknown subcommand "${sub ?? ""}" — expected list | inspect | rollback | promote`);
|
|
77
|
-
return { code: 1 };
|
|
78
|
-
}
|
|
79
|
-
return runDeploymentsCommand({
|
|
80
|
-
cwd,
|
|
81
|
-
env: options.env,
|
|
82
|
-
json: options.json === true,
|
|
83
|
-
logger,
|
|
84
|
-
message: options.message,
|
|
85
|
-
subcommand: sub,
|
|
86
|
-
versionId: argument[1],
|
|
87
|
-
yes: options.yes === true
|
|
88
|
-
});
|
|
89
|
-
});
|
|
90
|
-
|
|
91
|
-
export { execute, runDeploymentsCommand };
|
|
1
|
+
import{existsSync as p,readFileSync as v,realpathSync as h}from"node:fs";import{join as u}from"node:path";import{isPlaceholderValue as w,DEV_VARS_FILE as g,parseDevVariableEntries as k,discoverSchemaInfo as x,inferLunoraBindings as b}from"@lunora/config";import{findWranglerFile as y,readWranglerJsonc as $,validateWranglerConfig as _,collectExportGaps as S}from"@lunora/config/cloudflare";import{i as N,m as A,c as R}from"../packem_shared/vectorize-metadata-DbziRKpX.mjs";import{d as L}from"../packem_shared/command-DwC11Cwe.mjs";import{v as E,i as I,p as D,l as j}from"../packem_shared/output-format-DfogXx0p.mjs";import{i as O}from"../packem_shared/path-containment-CgxYZggb.mjs";const V=o=>{const e=o.trim();if(e==="")return!0;const n=e.toLowerCase();return n.includes("replace")||n.startsWith("<")&&n.endsWith(">")},C=o=>{const e=y(o);if(e===void 0)return{parsed:void 0,path:void 0};const{parsed:n}=$(e);return{parsed:n,path:e}},F=(o,e,n)=>{if(e===void 0){n.push({code:"wrangler-missing",fix:"Run `lunora init` (or `lunora dev`) to scaffold and reconcile wrangler.jsonc.",level:"fail",message:"wrangler.jsonc not found."});return}if(o===void 0){n.push({code:"wrangler-unparseable",fix:`Check ${e} is valid JSONC.`,level:"fail",message:`Could not parse ${e}.`});return}const t=_(o).errors.find(r=>r.includes("SHARD"));t===void 0?n.push({code:"wrangler-shard-binding-ok",level:"pass",message:"wrangler.jsonc present with a SHARD durable-object binding."}):n.push({code:"wrangler-shard-binding-missing",fix:"Run `lunora dev` to auto-reconcile, or add the binding manually.",level:"fail",message:t})},P=(o,e)=>{const{info:n}=x(o,"lunora");for(const a of n?.vectorMetadata??[]){const t=A(a.kind);if(t===void 0){e.push({code:"vector-metadata-unfilterable",fix:"Filter on a string, number or boolean column, or drop it from `metadata`.",level:"warn",message:`vector index "${a.index}" declares metadata "${a.property}", whose type Vectorize cannot filter on.`});continue}e.push({code:"vector-metadata-index-required",fix:`wrangler ${R({index:a.index,property:a.property,type:t}).join(" ")}`,level:"info",message:`vector index "${a.index}" filters on metadata "${a.property}" — that needs a Vectorize metadata index (\`lunora deploy\` creates it).`})}},M=(o,e)=>{if(o===void 0)return;const n=(o.d1_databases??[]).filter(Boolean);for(const a of n){const t=typeof a.database_id=="string"?a.database_id:"";if(V(t)){const r=typeof a.binding=="string"&&a.binding.length>0?a.binding:"<unnamed>";e.push({code:"d1-placeholder-id",fix:"Run `wrangler d1 create <name>` and paste the returned database_id into wrangler.jsonc.",level:"fail",message:`D1 binding "${r}" has a placeholder database_id ("${t||"<empty>"}").`})}}},W=(o,e)=>{if(o===void 0)return;const n=(o.send_email??[]).filter(Boolean);for(const a of n){const t=typeof a.destination_address=="string"?a.destination_address:"";if(t!==""&&w(t)){const r=typeof a.name=="string"&&a.name.length>0?a.name:"send_email";e.push({code:"email-destination-placeholder",fix:"Set destination_address to a verified Cloudflare Email Routing address.",level:"warn",message:`send_email binding "${r}" has a placeholder destination_address ("${t}").`})}}},T=(o,e)=>{const n=u(o,g);if(!p(n))return;let a;try{a=v(n,"utf8")}catch{return}const t=k(a).filter(r=>N(r.key)&&w(r.value)).map(r=>r.key);t.length>0&&e.push({code:"dev-vars-missing-secret",fix:"Run `lunora dev` to auto-generate secrets, or fill them in by hand.",level:"warn",message:`${g} has unfilled secret value(s): ${t.join(", ")}.`})},z=o=>{const e=process.env.LUNORA_ADMIN_TOKEN;e===void 0||e.trim()===""?o.push({code:"admin-token-missing",fix:"Set LUNORA_ADMIN_TOKEN (env or `.dev.vars`) to enable admin RPCs / studio.",level:"info",message:"LUNORA_ADMIN_TOKEN is not set."}):o.push({code:"admin-token-set",level:"pass",message:"LUNORA_ADMIN_TOKEN is set."})},K=async(o,e)=>{let n;try{n=await b({projectRoot:o})}catch{return}const a=S(n),t=[...n.containers.map(r=>({...r,kind:"container"})),...n.workflows.map(r=>({...r,kind:"workflow"})),...n.agents.map(r=>({...r,kind:"agent"}))];for(const r of t.filter(i=>i.exported))e.push({code:"declared-export-ok",level:"pass",message:`${r.kind} "${r.exportName}" is exported by the worker entry.`});for(const r of a)e.push({code:"declared-export-missing",fix:`Add \`export * from "./lunora/_generated/${r.module}"\` to your worker entry (or re-run \`vis generate lunora-${r.kind}\`).`,level:"fail",message:`${r.kind} "${r.exportName}" is declared but ${r.className} is not exported by the worker entry.`})},J=/^[\^~><= ]+/u,U=/^(?<core>\d+\.\d+\.\d+)(?:-(?<channel>[a-z]+)\.(?<counter>\d+))?$/u,B=o=>{const e=o.replace(J,"").trim(),n=U.exec(e);if(!n?.groups)return;const{channel:a,core:t,counter:r}=n.groups;return{channel:a??"",core:t??"",counter:r===void 0?void 0:Number.parseInt(r,10),raw:e}},G=(o,e)=>{const n=u(o,"package.json");if(!p(n))return;let a;try{a=JSON.parse(v(n,"utf8"))}catch{return}const t={...a.devDependencies,...a.dependencies},r=[];for(const[s,c]of Object.entries(t)){if(s!=="lunorash"&&!s.startsWith("@lunora/"))continue;const m=B(c);m&&r.push({name:s,version:m})}if(r.length<2)return;const i=s=>s.map(c=>`${c.name}@${c.version.raw}`).join(", "),l=new Set(r.map(s=>s.version.core)),f=new Set(r.map(s=>s.version.channel));if(l.size>1){e.push({code:"version-skew-cores",fix:'Run `pnpm update "@lunora/*" lunorash` (or `npm`/`yarn` equivalent) so every Lunora package moves to the same release.',level:"warn",message:`Lunora packages span ${String(l.size)} different versions: ${i(r)}.`});return}if(f.size>1){e.push({code:"version-skew-channels",fix:"Pick one channel (all stable, or all alpha/beta) and update the odd package out.",level:"warn",message:`Lunora packages mix release channels (${[...f].map(s=>s===""?"stable":s).join(" + ")}): ${i(r)}.`});return}const d=r.map(s=>s.version.counter).filter(s=>s!==void 0);if(d.length>1){const s=Math.min(...d),c=Math.max(...d);e.push({code:"version-counter-spread",level:"info",message:d.length===r.length&&s===c?`Lunora packages are all at ${[...f][0]??""}.${String(c)}.`:`Lunora pre-release counters span ${String(s)}–${String(c)}: ${i(r)}.`})}},H=[u("@lunora","cli"),"lunorash"],q=(o,e,n)=>{if(e===void 0)return;const a=[];for(const r of H){const i=u(o,"node_modules",r);if(p(i))try{a.push(h(i))}catch{}}if(a.length===0)return;let t;try{t=h(e)}catch{return}a.some(r=>O(r,t))||n.push({code:"cli-shadowed",fix:"Run the project's own CLI: `pnpm exec lunora …` (or `npx lunora …`).",level:"warn",message:`the running lunora (${t}) is not the project's own install (${a.join(", ")}).`})},X=async o=>{const e=o.cwd??process.cwd(),n=[],{parsed:a,path:t}=C(e);F(a,t,n),M(a,n),W(a,n),T(e,n),z(n),G(e,n),P(e,n),q(e,o.executablePath??process.argv[1],n),await K(e,n);const r={fail:0,info:0,pass:0,warn:0};for(const l of n)r[l.level]+=1;const i=r.fail>0?1:0;return{code:i,findings:n,ok:i===0,summary:r}},Q={fail:"FAIL",info:"INFO",pass:"PASS",warn:"WARN"},Y=(o,e)=>{e.info("lunora doctor — project preflight");for(const t of o.findings){const r=`[${Q[t.level]}] ${t.message}`;t.level==="fail"?e.error(r):t.level==="warn"?e.warn(r):e.info(r),t.fix!==void 0&&t.level!=="pass"&&e.info(` fix: ${t.fix}`)}const{fail:n,warn:a}=o.summary;n>0?e.error(`${String(n)} failure(s), ${String(a)} warning(s).`):a>0?e.warn(`0 failures, ${String(a)} warning(s).`):e.success("all checks passed.")},Z=async o=>{const e=E("doctor",o.format);if(e!==void 0)return o.logger.error(e),{code:1,findings:[],ok:!1,summary:{fail:0,info:0,pass:0,warn:0}};const n=j(o.format,o.logger),a=await X({...o});return Y(a,n),I(o.format)&&D(a),a},ce=L(async({cwd:o,logger:e,options:n})=>({code:(await Z({cwd:o,format:n.format,logger:e})).code}));export{ce as execute,X as runDoctor,Z as runDoctorCommand};
|
|
@@ -1,42 +1,3 @@
|
|
|
1
|
-
import { d as
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const DEFAULT_DOCS_URL = "https://lunora.anolilab.dev/docs";
|
|
5
|
-
const trimSlashes = (value) => {
|
|
6
|
-
let start = 0;
|
|
7
|
-
let end = value.length;
|
|
8
|
-
while (start < end && value[start] === "/") {
|
|
9
|
-
start += 1;
|
|
10
|
-
}
|
|
11
|
-
while (end > start && value[end - 1] === "/") {
|
|
12
|
-
end -= 1;
|
|
13
|
-
}
|
|
14
|
-
return value.slice(start, end);
|
|
15
|
-
};
|
|
16
|
-
const buildUrl = (section) => {
|
|
17
|
-
if (!section || section.length === 0) {
|
|
18
|
-
return DEFAULT_DOCS_URL;
|
|
19
|
-
}
|
|
20
|
-
const trimmed = trimSlashes(section);
|
|
21
|
-
if (trimmed.length === 0) {
|
|
22
|
-
return DEFAULT_DOCS_URL;
|
|
23
|
-
}
|
|
24
|
-
return `${DEFAULT_DOCS_URL}/${trimmed}`;
|
|
25
|
-
};
|
|
26
|
-
const runDocsCommand = async (options) => {
|
|
27
|
-
const url = buildUrl(options.section);
|
|
28
|
-
options.logger.info(`opening ${url}`);
|
|
29
|
-
try {
|
|
30
|
-
await openUrl(url, { opener: options.opener });
|
|
31
|
-
} catch (error) {
|
|
32
|
-
const message = error instanceof Error ? error.message : String(error);
|
|
33
|
-
options.logger.error(`docs: failed to open URL: ${message}`);
|
|
34
|
-
return { code: 1, url };
|
|
35
|
-
}
|
|
36
|
-
return { code: 0, url };
|
|
37
|
-
};
|
|
38
|
-
const execute = defineHandler(
|
|
39
|
-
({ argument, logger }) => runDocsCommand({ logger, section: argument[0] })
|
|
40
|
-
);
|
|
41
|
-
|
|
42
|
-
export { execute, runDocsCommand };
|
|
1
|
+
import{existsSync as h,readFileSync as S}from"node:fs";import{join as V}from"node:path";import{DEV_VARS_FILE as d,DEV_VARS_KEY_PATTERN as k,writeDevVariablesFileAtomically as $,removeDevVariableLine as R,upsertDevVariableLine as P,isPlaceholderValue as A,resolveDeployDriver as N,resolveProjectTarget as U,generateSecretValue as z,DEV_VARS_EXAMPLE_FILE as p,parseDevVariableEntries as _,packageNamesFromBindings as M,inferLunoraBindings as Y,requiredSecrets as j,isMintableSecretKey as b}from"@lunora/config";import{d as x}from"../packem_shared/command-DwC11Cwe.mjs";import{d as C,e as q}from"../packem_shared/detect-package-manager-DSaAqRof.mjs";import{defaultSpawner as F}from"../packem_shared/createRecordingSpawner-DJlNacZ6.mjs";import{l as T}from"../packem_shared/wrangler-secrets-CE7jcf8E.mjs";const Z=/[\r\n]/u,B=/["\\]/u,D=r=>new Map(_(r).map(s=>[s.key,s])),m=r=>h(r)?S(r,"utf8"):"",L=r=>r.length<=4?"****":`${r.slice(0,4)}${"*".repeat(Math.min(8,r.length-4))}`,f=r=>D(m(r)),K=r=>r.env??(r.prod===!0?"production":void 0),I=r=>{const s=f(r.devVariablesPath);if(s.size===0)return r.logger.info(`${d}: (empty)`),{code:0,descriptors:[]};for(const t of s.values())r.logger.info(`${t.key}=${L(t.value)}`);return{code:0,descriptors:[]}},O=r=>{const{devVariablesPath:s,logger:t,options:e}=r;if(!e.key)return t.error("env get requires a key. Usage: lunora env get <KEY>"),{code:1,descriptors:[]};const o=f(s).get(e.key);return o?(process.stdout.write(`${o.value}
|
|
2
|
+
`),{code:0,descriptors:[]}):(t.error(`env: ${e.key} is not set in ${d}`),{code:1,descriptors:[]})},G=r=>{const{devVariablesPath:s,logger:t,options:e}=r;if(!e.key)return t.error("env set requires a key. Usage: lunora env set <KEY> <VALUE>"),{code:1,descriptors:[]};if(!k.test(e.key))return t.error(`env: invalid key "${e.key}" — must match [A-Za-z_][A-Za-z0-9_]*`),{code:1,descriptors:[]};if(e.value===void 0)return t.error("env set requires a value. Usage: lunora env set <KEY> <VALUE>"),{code:1,descriptors:[]};if(Z.test(e.value))return t.error(`env: value for "${e.key}" contains a newline, which .dev.vars cannot represent`),{code:1,descriptors:[]};if(B.test(e.value))return t.error(`env: value for "${e.key}" contains a double-quote or backslash, which .dev.vars cannot round-trip`),{code:1,descriptors:[]};const o=m(s);return $(s,P(o,e.key,e.value)),t.success(`env: set ${e.key} (${L(e.value)}) in ${d}`),{code:0,descriptors:[]}},H=r=>{const{devVariablesPath:s,logger:t,options:e}=r;if(!e.key)return t.error("env unset requires a key. Usage: lunora env unset <KEY>"),{code:1,descriptors:[]};if(!k.test(e.key))return t.error(`env: invalid key "${e.key}" — must match [A-Za-z_][A-Za-z0-9_]*`),{code:1,descriptors:[]};const o=m(s);return D(o).has(e.key)?($(s,R(o,e.key)),t.success(`env: unset ${e.key} in ${d}`),{code:0,descriptors:[]}):(t.warn(`env: ${e.key} was not set in ${d}`),{code:0,descriptors:[]})},W=async r=>{const{devVariablesPath:s,logger:t,options:e}=r;if(!e.yes)return t.error("env push uploads secrets to Cloudflare. Re-run with --yes to confirm."),{code:1,descriptors:[]};const o=f(s);if(o.size===0)return t.warn(`${d}: nothing to push (empty)`),{code:0,descriptors:[]};const i=[...o.values()].filter(n=>A(n.value)).map(n=>n.key);if(i.length>0)return t.error(`env push: refusing to upload placeholder value(s) for ${i.join(", ")} — run \`lunora env doctor\` to review, and \`lunora env generate --set\` (or \`lunora env set <KEY> <VALUE>\`) to fill them, then re-run.`),{code:1,descriptors:[]};const c=e.spawner??F,l=e.cwd??process.cwd(),v=C(l),a=[],u=K(e);for(const n of o.values()){const y=N(U(l)).toolchain?.secretPut({environment:u,key:n.key,temporary:e.temporary});if(y===void 0)return t.error("deploy target has no command-line toolchain; cannot push secrets"),{code:1,descriptors:[]};const E=q(v,y.tool,y.args),w={args:E.args,command:E.command,cwd:l,input:n.value};a.push(w),t.info(`pushing ${n.key} -> wrangler secret${u===void 0?"":` (${u})`}`);const g=await c(w);if(g.code!==0)return t.error(`env push: failed at ${n.key} (exit ${String(g.code)})`),{code:g.code,descriptors:a}}return t.success(`env: pushed ${String(o.size)} secret(s)`),{code:0,descriptors:a}},X=r=>(r.options.secretLister??T)({cwd:r.cwd,env:K(r.options),temporary:r.options.temporary}),J=async r=>{const{devVariablesPath:s,logger:t}=r,e=await X(r);if(!e.ok)return t.error(`env diff: ${e.error??"failed to list remote secrets"}`),{code:1,descriptors:[]};const o=new Set(f(s).keys()),i=new Set(e.names),c=[...o].filter(a=>!i.has(a)).toSorted((a,u)=>a.localeCompare(u)),l=e.names.filter(a=>!o.has(a)),v=[...o].filter(a=>i.has(a)).toSorted((a,u)=>a.localeCompare(u));for(const a of c)t.info(`local only (run \`lunora env push\`): ${a}`);for(const a of l)t.info(`remote only (in Cloudflare, not ${d}): ${a}`);return t.info(`in both: ${String(v.length)} secret(s)`),c.length===0&&l.length===0&&t.success("env diff: local and remote secret names match"),{code:0,descriptors:[]}},Q=r=>{const{cwd:s,devVariablesPath:t,logger:e}=r,o=V(s,p);if(!h(o))return e.info(`env doctor: no ${p} to check against — nothing to validate.`),{code:0,descriptors:[]};const i=_(S(o,"utf8")).map(n=>n.key),c=f(t);if(!h(t))return e.error(`env doctor: ${d} is missing. Run \`lunora dev\` to scaffold it, or \`lunora env set <KEY> <VALUE>\`.`),e.info(`expected (from ${p}): ${i.join(", ")}`),{code:1,descriptors:[]};const l=i.filter(n=>!c.has(n)),v=[...c.values()].filter(n=>A(n.value)).map(n=>n.key),a=new Set(i),u=[...c.keys()].filter(n=>!a.has(n));for(const n of l)e.error(`missing: ${n} is in ${p} but not ${d}`);for(const n of v)e.error(`unset: ${n} still has a placeholder value`);for(const n of u)e.info(`extra: ${n} is set locally but not listed in ${p}`);return l.length===0&&v.length===0?(e.success(`env doctor: ${d} looks good (${String(c.size)} var(s)).`),{code:0,descriptors:[]}):{code:1,descriptors:[]}},ee=async r=>{let s=[];try{s=M(await Y({projectRoot:r.cwd}))}catch{}const t=j(s).map(o=>o.key).filter(o=>b(o)),e=[...f(r.devVariablesPath).keys()].filter(o=>b(o));return[...new Set([...t,...e])]},re=async r=>{const{devVariablesPath:s,logger:t,options:e}=r;let o;if(e.key===void 0){if(o=await ee(r),o.length===0)return t.info("env generate: no locally-generatable secrets for this project. Name one explicitly: lunora env generate <KEY>"),{code:0,descriptors:[]}}else{if(!k.test(e.key))return t.error(`env: invalid key "${e.key}" — must match [A-Za-z_][A-Za-z0-9_]*`),{code:1,descriptors:[]};o=[e.key]}const i=o.map(c=>({key:c,value:z()}));if(e.set===!0){let c=m(s);for(const l of i)c=P(c,l.key,l.value);return $(s,c),t.success(`env: generated ${String(i.length)} secret(s) into ${d}: ${i.map(l=>l.key).join(", ")}`),{code:0,descriptors:[]}}for(const c of i)process.stdout.write(`${c.key}=${c.value}
|
|
3
|
+
`);return{code:0,descriptors:[]}},te=async r=>{const s=r.cwd??process.cwd(),t={cwd:s,devVariablesPath:V(s,d),logger:r.logger,options:r};switch(r.subcommand){case"diff":return J(t);case"doctor":return Q(t);case"generate":return re(t);case"get":return O(t);case"list":return I(t);case"push":return W(t);case"set":return G(t);case"unset":return H(t);default:return r.logger.error(`env: unknown subcommand "${r.subcommand}"`),{code:1,descriptors:[]}}},oe=new Set(["diff","doctor","generate","get","list","push","set","unset"]),se=r=>typeof r=="string"&&oe.has(r),ve=x(({argument:r,cwd:s,logger:t,options:e})=>{const o=r[0];return se(o)?te({cwd:s,env:e.env,key:r[1],logger:t,prod:e.prod===!0,set:e.set===!0,subcommand:o,temporary:e.temporary===!0,value:r[2],yes:e.yes===!0}):(t.error(`env: unknown subcommand "${o??""}" — expected list | get | set | unset | push | diff | doctor | generate`),{code:1})});export{ve as execute,te as runEnvCommand};
|