@lunora/cli 1.0.0-alpha.126 → 1.0.0-alpha.127
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bin.mjs +1 -1
- package/dist/index.d.mts +18 -3
- package/dist/index.d.ts +18 -3
- package/dist/index.mjs +1 -1
- package/dist/packem_chunks/handler.mjs +1 -1
- package/dist/packem_chunks/handler14.mjs +1 -1
- package/dist/packem_chunks/handler15.mjs +1 -1
- package/dist/packem_chunks/handler16.mjs +1 -1
- package/dist/packem_chunks/handler19.mjs +1 -1
- package/dist/packem_chunks/handler21.mjs +7 -2
- package/dist/packem_chunks/handler22.mjs +2 -99
- package/dist/packem_chunks/handler23.mjs +99 -11
- package/dist/packem_chunks/handler24.mjs +11 -0
- package/dist/packem_chunks/handler4.mjs +1 -1
- package/dist/packem_chunks/handler8.mjs +1 -1
- package/dist/packem_chunks/handler9.mjs +4 -4
- package/dist/packem_chunks/planDevCommand.mjs +6 -6
- package/dist/packem_chunks/runCodegenCommand.mjs +4 -4
- package/dist/packem_chunks/runDeployCommand.mjs +1 -1
- package/dist/packem_chunks/runInitCommand.mjs +1 -1
- package/dist/packem_shared/COMMANDS-BpuzPHyn.mjs +1 -0
- package/dist/packem_shared/cli-C6sRqIMQ.mjs +3 -0
- package/dist/packem_shared/{commands-B1SpMXov.mjs → commands-qFGULoQJ.mjs} +9 -9
- package/dist/packem_shared/deploy-target-Dvr9vxpR.mjs +1 -0
- package/dist/packem_shared/platform-diagnostics-C4TFj5Pu.mjs +4 -0
- package/dist/packem_shared/{runAddCommand-BF35qSZ2.mjs → runAddCommand-Ct-8Rd8I.mjs} +1 -1
- package/dist/packem_shared/{storage-BHSN9Vgb.mjs → storage-B-VWSXkl.mjs} +1 -1
- package/dist/packem_shared/wrangler-name-CHDf3rMP.mjs +1 -0
- package/dist/packem_shared/wrangler-secrets-DDDUuryf.mjs +1 -0
- package/package.json +9 -8
- package/dist/packem_shared/COMMANDS-DmB3_936.mjs +0 -3
- package/dist/packem_shared/wrangler-name-HIl0Z6yx.mjs +0 -1
- package/dist/packem_shared/wrangler-secrets-BMRJwKQU.mjs +0 -1
|
@@ -1,11 +1,99 @@
|
|
|
1
|
-
import{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
${
|
|
7
|
-
`)
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
`},
|
|
11
|
-
`)
|
|
1
|
+
import{existsSync as T,readFileSync as O}from"node:fs";import{writeFile as x,mkdir as k}from"node:fs/promises";import{join as v}from"@visulima/path";import{i as B}from"../packem_shared/command-Bjv4VmYA.mjs";import{createRequire as q}from"node:module";import{LunoraError as w}from"@lunora/errors";import{parseSchema as U,applyAdditiveEdit as F}from"@lunora/config";const Y=/^\//,R=(e,n,t)=>{const a=q(v(t,"noop.cjs"));try{a.resolve(e)}catch{throw new w("INTERNAL",`\`lunora introspect\` needs the \`${n}\` driver to read this database, and it isn't installed.
|
|
2
|
+
|
|
3
|
+
Install it in your project:
|
|
4
|
+
|
|
5
|
+
pnpm add -D ${n}`)}return a(e)},j=e=>{const n=e.slice(0,Math.max(0,e.indexOf(":"))).toLowerCase();if(n==="postgres"||n==="postgresql")return"postgres";if(n==="mysql"||n==="mariadb")return"mysql";throw new w("INTERNAL",`Unrecognised database URL scheme \`${n}\`. Expected a \`postgres://\`, \`postgresql://\`, \`mysql://\`, or \`mariadb://\` connection string.`)},H=e=>{try{const n=new URL(e).pathname.replace(Y,"");return n===""?void 0:decodeURIComponent(n)}catch{return}},J=async(e,n,t,a=process.cwd())=>{if(n==="postgres"){const o=R("pg","pg",a).Client,c=new o({connectionString:e});return await c.connect(),{close:async()=>{await c.end()},execute:async(m,d)=>(await c.query(m,[...d])).rows,schema:t??"public"}}const s=R("mysql2/promise","mysql2",a).createConnection,r=await s(e),i=t??H(e);if(i===void 0)throw new w("INTERNAL","A MySQL connection string must name a database (`mysql://host/<database>`), or pass `--schema`.");return{close:async()=>{await r.end()},execute:async(o,c)=>{const[m]=await r.execute(o,[...c]);return Array.isArray(m)?m:[]},schema:i}},h=new Set(["_creationTime","_id"]),W={bigint:"v.bigint()",bigserial:"v.bigint()",bit:"v.string()",bool:"v.boolean()",boolean:"v.boolean()",box:"v.string()",bpchar:"v.string()",bytea:"v.bytes()",char:"v.string()",character:"v.string()","character varying":"v.string()",cidr:"v.string()",circle:"v.string()",citext:"v.string()",date:"v.date()","double precision":"v.number()",float4:"v.number()",float8:"v.number()",inet:"v.string()",int:"v.number()",int2:"v.number()",int4:"v.number()",int8:"v.bigint()",integer:"v.number()",interval:"v.string()",json:"v.any()",jsonb:"v.any()",line:"v.string()",lseg:"v.string()",macaddr:"v.string()",money:"v.number()",name:"v.string()",numeric:"v.number()",path:"v.string()",point:"v.string()",polygon:"v.string()",real:"v.number()",serial:"v.number()",smallint:"v.number()",smallserial:"v.number()",text:"v.string()",time:"v.string()","time with time zone":"v.string()","time without time zone":"v.string()",timestamp:"v.timestamp()","timestamp with time zone":"v.timestamp()","timestamp without time zone":"v.timestamp()",timestamptz:"v.timestamp()",tsquery:"v.string()",tsvector:"v.string()",uuid:"v.string()",varbit:"v.string()",varchar:"v.string()",xml:"v.string()"},P={bigint:"v.bigint()",binary:"v.bytes()",bit:"v.number()",blob:"v.bytes()",char:"v.string()",date:"v.date()",datetime:"v.timestamp()",decimal:"v.number()",double:"v.number()",enum:"v.string()",float:"v.number()",int:"v.number()",integer:"v.number()",json:"v.any()",longblob:"v.bytes()",longtext:"v.string()",mediumblob:"v.bytes()",mediumint:"v.number()",mediumtext:"v.string()",numeric:"v.number()",set:"v.string()",smallint:"v.number()",text:"v.string()",time:"v.string()",timestamp:"v.timestamp()",tinyblob:"v.bytes()",tinyint:"v.number()",tinytext:"v.string()",varbinary:"v.bytes()",varchar:"v.string()",year:"v.number()"},N=(e,n)=>{const t=(n==="postgres"?W:P)[e.dataType],a=e.references===void 0?t:`v.id(${JSON.stringify(e.references.table)})`;let s=a??"v.any()";for(let r=0;r<e.arrayDepth;r+=1)s=`v.array(${s})`;return e.nullable&&(s=`v.optional(${s})`),{expression:s,known:a!==void 0}},M=/^[A-Z_$][\w$]*$/i,K=/[^\dA-Z]+(.)?/gi,Q=/^\d+/,G=/[^\w-]/g,z=/[\u003C\u003E\u002F\u2028\u2029]/g,X={"/":String.raw`\u002F`,"\u2028":String.raw`\u2028`,"\u2029":String.raw`\u2029`,"<":String.raw`\u003C`,">":String.raw`\u003E`},b=e=>JSON.stringify(e).replaceAll(z,n=>X[n]??n),$=e=>M.test(e)?e:b(e),Z=e=>M.test(e)?`.${e}`:`[${b(e)}]`,I=e=>e.replaceAll("*/",String.raw`*\/`),V=e=>{const n=e.replaceAll(G,"_");return n===""?"table":n},ee=e=>{const n=e.replaceAll(K,(t,a)=>a?.toUpperCase()??"").replace(Q,"");return n===""?"table":`${n.charAt(0).toLowerCase()}${n.slice(1)}`},C=e=>e.columns.filter(n=>!h.has(n.name)),te=e=>{const n=new Set(e.primaryKey);for(const t of e.indexes)for(const a of t.columns)n.add(a);for(const t of e.columns)t.references!==void 0&&n.add(t.name);return[...n].filter(t=>!h.has(t))},D=(e,n,t,a)=>e.references===void 0||n.has(e.references.table)?e:(a.push(`${t}.${e.name}: references \`${e.references.table}\`, which isn't in the generated schema — emitted as a plain column instead of \`v.id(...)\`.`),{arrayDepth:e.arrayDepth,dataType:e.dataType,name:e.name,nullable:e.nullable}),ne=(e,n,t,a)=>{const s=[];for(const i of e.columns){if(h.has(i.name)){a.push(`${e.name}.${i.name}: skipped — \`${i.name}\` is a Lunora system column. Rename it in the source database or map it by hand.`);continue}const o=D(i,t,e.name,a),{expression:c,known:m}=N(o,n);!m&&o.references===void 0&&(a.push(`${e.name}.${i.name}: no mapping for SQL type \`${i.dataType}\` — emitted as \`v.any()\`.`),s.push(` // TODO: \`${I(i.dataType)}\` has no direct validator; narrow this.`)),s.push(` ${$(i.name)}: ${c},`)}const r=[' .global({ backend: "hyperdrive" })'];if(e.primaryKey.length>0&&e.primaryKey.every(i=>!h.has(i))){const i=e.primaryKey.map(o=>b(o)).join(", ");r.push(` .index(${b(`by_${e.primaryKey.join("_")}`)}, [${i}], { unique: true })`)}for(const i of e.indexes){const o=i.columns.filter(d=>!h.has(d));if(o.length===0)continue;const c=o.map(d=>b(d)).join(", "),m=i.unique?", { unique: true }":"";r.push(` .index(${b(i.name)}, [${c}]${m})`)}return` ${$(e.name)}: defineTable({
|
|
6
|
+
${s.join(`
|
|
7
|
+
`)}
|
|
8
|
+
})
|
|
9
|
+
${r.join(`
|
|
10
|
+
`)},`},ae=(e,n,t)=>{const a=new Set(e.tables.map(r=>r.name)),s=e.tables.map(r=>ne(r,e.dialect,a,t)).join(`
|
|
11
|
+
`);return`/**
|
|
12
|
+
* Generated by \`lunora introspect\` from an existing ${e.dialect==="postgres"?"Postgres":"MySQL"} database.
|
|
13
|
+
*
|
|
14
|
+
* This file is a STARTING POINT, not a build artifact — it is written once and is
|
|
15
|
+
* yours to edit. Review it before shipping: column types are mapped
|
|
16
|
+
* conservatively, and every table is \`.global({ backend: "hyperdrive" })\` because
|
|
17
|
+
* its rows live in the external database. Re-running \`lunora introspect\` will not
|
|
18
|
+
* overwrite it unless you pass \`--force\`.
|
|
19
|
+
*/
|
|
20
|
+
import { defineSchema, defineTable, v } from "${n.serverImport}";
|
|
21
|
+
|
|
22
|
+
export default defineSchema({
|
|
23
|
+
${s}
|
|
24
|
+
});
|
|
25
|
+
`},re=(e,n,t,a=new Set([e.name]),s=[])=>{const r=ee(e.name),i=te(e),o=new Map(C(e).map(l=>[l.name,l])),c=i.map(l=>{const g=o.get(l);if(g===void 0)return;const p=D({...g,nullable:!1},a,e.name,[]),{expression:E,known:A}=N(p,n);return!A&&p.references===void 0&&s.push(`${e.name}.${l}: filter falls back to \`v.any()\` (no mapping for SQL type \`${g.dataType}\`).`),` ${$(l)}: ${E},`}).filter(l=>l!==void 0),m=[b("_creationTime"),...i.map(l=>b(l))].join(", "),d=`ctx.db${Z(e.name)}`;return`/**
|
|
26
|
+
* Generated by \`lunora introspect\` for the \`${I(e.name)}\` table — a
|
|
27
|
+
* starting point you own and edit.
|
|
28
|
+
*
|
|
29
|
+
* Both procedures are RPC-only. Add \`.expose({ rest: true })\` once you've decided
|
|
30
|
+
* this data should be public, and gate them with your auth/RLS middleware first —
|
|
31
|
+
* \`introspect\` cannot know who is allowed to read this table.
|
|
32
|
+
*/
|
|
33
|
+
import { defineListArgs, v } from "${t.serverImport}";
|
|
34
|
+
|
|
35
|
+
import type { Doc } from "./_generated/dataModel";
|
|
36
|
+
import { c } from "./_generated/server";
|
|
37
|
+
|
|
38
|
+
const ${r}List = defineListArgs<Doc<${b(e.name)}>>()({
|
|
39
|
+
// Only index-backed columns are published as filterable, so a caller cannot
|
|
40
|
+
// reach a column you did not choose to expose. Note that \`contains\` and the
|
|
41
|
+
// negative operators still scan — narrow this list, and review it, before
|
|
42
|
+
// adding \`.expose({ rest: true })\`.
|
|
43
|
+
filter: {
|
|
44
|
+
${c.join(`
|
|
45
|
+
`)}
|
|
46
|
+
},
|
|
47
|
+
orderBy: [${m}],
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
export const list = c.query.input(${r}List.args).query(({ args, ctx }) => ${d}.findMany(${r}List.toQueryArgs(args)));
|
|
51
|
+
|
|
52
|
+
export const get = c.query.input({ id: v.id(${b(e.name)}) }).query(({ args, ctx }) => ${d}.get(args.id));
|
|
53
|
+
`},se=(e,n)=>{const t=[],a=new Set(e.tables.map(r=>r.name)),s=[{contents:ae(e,n,t),path:"schema.ts"}];if(n.procedures){const r=new Map([["schema","the generated schema module"]]);for(const i of e.tables){if(C(i).length===0){t.push(`${i.name}: no usable columns — procedure module skipped.`);continue}const o=V(i.name);o!==i.name&&t.push(`${i.name}: written as \`${o}.ts\` — the table name isn't usable as a filename.`);const c=r.get(o);if(c!==void 0){t.push(`${i.name}: procedure module skipped — its filename \`${o}.ts\` collides with table \`${c}\`.`);continue}r.set(o,i.name),s.push({contents:re(i,e.dialect,n,a,t),path:`${o}.ts`})}}return{files:s,warnings:t}},_=/^[A-Z_$][\w$]*$/i,ie=e=>e.startsWith("v.optional(")&&e.endsWith(")")?e.slice(11,-1):e,oe=(e,n,t)=>{const a=[],s=new Set(n?.columns.map(r=>r.name));for(const r of e.columns){if(h.has(r.name)||s.has(r.name))continue;if(!_.test(r.name)){t.warnings.push(`${e.name}.${r.name}: skipped — column names must be bare identifiers to merge.`);continue}const i=r.references!==void 0&&!t.present.has(r.references.table),{expression:o}=N(i?{...r,references:void 0}:r,t.dialect);a.push({column:r.name,kind:"addOptionalColumn",table:e.name,validator:ie(o)}),!r.nullable&&n!==void 0&&t.warnings.push(`${e.name}.${r.name}: added as \`v.optional(...)\` — a required column on an existing table needs a backfill migration.`)}return a},ce=(e,n,t)=>{const a=[],s=new Set(n?.indexes.map(r=>r.name));for(const r of e.indexes){const i=r.columns.filter(o=>!h.has(o));if(!(s.has(r.name)||i.length===0)){if(!_.test(r.name)||!i.every(o=>_.test(o))){t.push(`${e.name}: index \`${r.name}\` skipped — index and column names must be bare identifiers to merge.`);continue}a.push({fields:i,kind:"addIndex",name:r.name,table:e.name,...r.unique?{unique:!0}:{}})}}return a},me=(e,n,t)=>{const a=[],s=[],r=new Map(n.map(o=>[o.name,o])),i=new Set([...r.keys(),...e.tables.map(o=>o.name)]);for(const o of e.tables){if(!_.test(o.name)){s.push(`${o.name}: skipped — merging into an existing schema needs a table name that is a bare identifier.`);continue}const c=r.get(o.name);c===void 0&&a.push({global:{backend:"hyperdrive"},kind:"addTable",table:o.name}),a.push(...oe(o,c,{dialect:t,present:i,warnings:s}),...ce(o,c,s))}return{edits:a,warnings:s}},le=(e,n,t)=>{const a=U(e);if(!a.ok)return{applied:0,warnings:[`lunora/schema.ts could not be parsed (${a.reason}) — leave it alone and merge by hand, or pass --force.`]};const s=me(n,a.tables,t),r=[...s.warnings];let i=e,o=0;for(const c of s.edits){const m=F(i,c);m.ok?(i=m.text,o+=1):r.push(`${c.table}: skipped one edit (${m.reason}).`)}return{applied:o,warnings:r,...o===0?{}:{text:i}}},u=(e,n)=>{const t=e[n]??e[n.toLowerCase()]??e[n.toUpperCase()];return typeof t=="string"?t:typeof t=="number"||typeof t=="bigint"||typeof t=="boolean"?String(t):""},ue=`
|
|
54
|
+
SELECT c.table_name, c.column_name, c.is_nullable, c.data_type, c.udt_name
|
|
55
|
+
FROM information_schema.columns c
|
|
56
|
+
JOIN information_schema.tables t
|
|
57
|
+
ON t.table_schema = c.table_schema AND t.table_name = c.table_name
|
|
58
|
+
WHERE c.table_schema = $1 AND t.table_type = 'BASE TABLE'
|
|
59
|
+
ORDER BY c.table_name, c.ordinal_position`,de=`
|
|
60
|
+
SELECT tc.table_name, kcu.column_name
|
|
61
|
+
FROM information_schema.table_constraints tc
|
|
62
|
+
JOIN information_schema.key_column_usage kcu
|
|
63
|
+
ON kcu.constraint_name = tc.constraint_name AND kcu.table_schema = tc.table_schema
|
|
64
|
+
WHERE tc.table_schema = $1 AND tc.constraint_type = 'PRIMARY KEY'
|
|
65
|
+
ORDER BY tc.table_name, kcu.ordinal_position`,pe=`
|
|
66
|
+
SELECT tc.table_name, kcu.column_name, ccu.table_name AS foreign_table, ccu.column_name AS foreign_column
|
|
67
|
+
FROM information_schema.table_constraints tc
|
|
68
|
+
JOIN information_schema.key_column_usage kcu
|
|
69
|
+
ON kcu.constraint_name = tc.constraint_name AND kcu.table_schema = tc.table_schema
|
|
70
|
+
JOIN information_schema.constraint_column_usage ccu
|
|
71
|
+
ON ccu.constraint_name = tc.constraint_name AND ccu.table_schema = tc.table_schema
|
|
72
|
+
WHERE tc.table_schema = $1 AND tc.constraint_type = 'FOREIGN KEY'`,ge=`
|
|
73
|
+
SELECT t.relname AS table_name, i.relname AS index_name, ix.indisunique AS is_unique, a.attname AS column_name
|
|
74
|
+
FROM pg_class t
|
|
75
|
+
JOIN pg_index ix ON t.oid = ix.indrelid
|
|
76
|
+
JOIN pg_class i ON i.oid = ix.indexrelid
|
|
77
|
+
JOIN pg_namespace n ON n.oid = t.relnamespace
|
|
78
|
+
CROSS JOIN LATERAL unnest(ix.indkey) WITH ORDINALITY AS k(attnum, ord)
|
|
79
|
+
JOIN pg_attribute a ON a.attrelid = t.oid AND a.attnum = k.attnum
|
|
80
|
+
WHERE n.nspname = $1 AND t.relkind = 'r' AND NOT ix.indisprimary
|
|
81
|
+
ORDER BY t.relname, i.relname, k.ord`,be=`
|
|
82
|
+
SELECT c.TABLE_NAME, c.COLUMN_NAME, c.IS_NULLABLE, c.DATA_TYPE
|
|
83
|
+
FROM information_schema.COLUMNS c
|
|
84
|
+
JOIN information_schema.TABLES t
|
|
85
|
+
ON t.TABLE_SCHEMA = c.TABLE_SCHEMA AND t.TABLE_NAME = c.TABLE_NAME
|
|
86
|
+
WHERE c.TABLE_SCHEMA = ? AND t.TABLE_TYPE = 'BASE TABLE'
|
|
87
|
+
ORDER BY c.TABLE_NAME, c.ORDINAL_POSITION`,fe=`
|
|
88
|
+
SELECT TABLE_NAME, COLUMN_NAME
|
|
89
|
+
FROM information_schema.KEY_COLUMN_USAGE
|
|
90
|
+
WHERE TABLE_SCHEMA = ? AND CONSTRAINT_NAME = 'PRIMARY'
|
|
91
|
+
ORDER BY TABLE_NAME, ORDINAL_POSITION`,he=`
|
|
92
|
+
SELECT TABLE_NAME, COLUMN_NAME, REFERENCED_TABLE_NAME AS foreign_table, REFERENCED_COLUMN_NAME AS foreign_column
|
|
93
|
+
FROM information_schema.KEY_COLUMN_USAGE
|
|
94
|
+
WHERE TABLE_SCHEMA = ? AND REFERENCED_TABLE_NAME IS NOT NULL`,ve=`
|
|
95
|
+
SELECT TABLE_NAME, INDEX_NAME AS index_name, NON_UNIQUE, COLUMN_NAME
|
|
96
|
+
FROM information_schema.STATISTICS
|
|
97
|
+
WHERE TABLE_SCHEMA = ? AND INDEX_NAME <> 'PRIMARY'
|
|
98
|
+
ORDER BY TABLE_NAME, INDEX_NAME, SEQ_IN_INDEX`,y=e=>{const n=new Map;for(const t of e){const a=u(t,"table_name"),s=n.get(a);s===void 0?n.set(a,[t]):s.push(t)}return n},ye=(e,n)=>{const t=u(e,"data_type").toLowerCase();if(n!=="postgres")return{arrayDepth:0,dataType:t};const a=u(e,"udt_name").toLowerCase();return t==="array"&&a.startsWith("_")?{arrayDepth:1,dataType:a.slice(1)}:{arrayDepth:0,dataType:a===""?t:a}},_e=(e,n)=>{const t=new Map;for(const a of e){const s=u(a,"index_name"),r=n==="postgres"?u(a,"is_unique")==="true":u(a,"NON_UNIQUE")==="0",i=t.get(s);i===void 0?t.set(s,{columns:[u(a,"column_name")],unique:r}):i.columns.push(u(a,"column_name"))}return[...t.entries()].map(([a,s])=>({columns:s.columns,name:a,unique:s.unique}))},Ee=async(e,n,t)=>{const a=n==="postgres",[s,r,i,o]=await Promise.all([e(a?ue:be,[t]),e(a?de:fe,[t]),e(a?pe:he,[t]),e(a?ge:ve,[t])]),c=y(r),m=y(i),d=y(o),l=[];for(const[g,p]of y(s)){const E=new Map((m.get(g)??[]).map(f=>[u(f,"column_name"),{column:u(f,"foreign_column"),table:u(f,"foreign_table")}])),A=p.map(f=>{const S=u(f,"column_name"),L=E.get(S);return{...ye(f,n),name:S,nullable:u(f,"is_nullable").toUpperCase()==="YES",...L===void 0?{}:{references:L}}});l.push({columns:A,indexes:_e(d.get(g)??[],n),name:g,primaryKey:(c.get(g)??[]).map(f=>u(f,"column_name"))})}return l.sort((g,p)=>g.name.localeCompare(p.name)),{dialect:n,tables:l}},Ae=e=>{try{const n=JSON.parse(O(v(e,"package.json"),"utf8"));return n.dependencies?.lunorash===void 0&&n.devDependencies?.lunorash===void 0?"@lunora/server":"lunorash/server"}catch{return"@lunora/server"}},$e=async(e,n,t)=>{const a=v(n,e.path);return T(a)&&t.force!==!0?(t.logger.warn(`skipped lunora/${e.path} — it already exists (pass --force to overwrite)`),!1):t.dryRun===!0?(t.logger.info(`would write lunora/${e.path} (${String(e.contents.split(`
|
|
99
|
+
`).length)} lines)`),!1):(await k(n,{recursive:!0}),await x(a,e.contents,"utf8"),t.logger.info(`wrote lunora/${e.path}`),!0)},we=(e,n)=>{const t=n.tables;if(t===void 0||t.length===0)return e.tables;for(const a of t)e.tables.some(s=>s.name===a)||n.logger.warn(`--tables: no table named "${a}" exists in this schema — skipped.`);return e.tables.filter(a=>t.includes(a.name))},Ne=async(e,n,t,a)=>{const s=le(O(e,"utf8"),n,t);for(const r of s.warnings)a.logger.warn(r);return s.text===void 0?(a.logger.info("lunora/schema.ts is already up to date with the database."),!1):a.dryRun===!0?(a.logger.info(`would merge ${String(s.applied)} addition(s) into lunora/schema.ts`),!1):(await x(e,s.text,"utf8"),a.logger.info(`merged ${String(s.applied)} addition(s) into lunora/schema.ts`),!0)},Se=async e=>{const n=e.cwd??process.cwd();if(e.connection===void 0&&(e.url===void 0||e.url===""))return e.logger.error("`lunora introspect` needs a database URL: pass --url, or set DATABASE_URL."),{code:1,written:[]};const t=e.connection===void 0?j(e.url):e.dialect??"postgres",a=e.connection??await J(e.url,t,e.schema,n);let s;try{s=await Ee(a.execute,t,a.schema)}finally{e.connection===void 0&&await a.close()}const r=we(s,e);if(r.length===0)return e.logger.error("no tables found to introspect — check --schema and --tables."),{code:1,written:[]};const{files:i,warnings:o}=se({...s,tables:r},{procedures:e.procedures!==!1,serverImport:Ae(n)}),c=v(n,"lunora"),m=[],d=v(c,"schema.ts"),l=T(d)&&e.force!==!0,g=l?i.filter(p=>p.path!=="schema.ts"):i;l&&await Ne(d,{tables:r},t,e)&&m.push("schema.ts");for(const p of g)await $e(p,c,e)&&m.push(p.path);for(const p of o)e.logger.warn(p);return e.logger.info(`introspected ${String(r.length)} table(s) from ${t}. Review the generated files before running \`lunora dev\`.`),{code:0,written:m}},Ce=B(async({cwd:e,logger:n,options:t})=>({code:(await Se({cwd:e,dryRun:t.dryRun===!0,force:t.force===!0,logger:n,procedures:t.procedures!==!1,schema:t.schema,tables:t.tables===void 0?void 0:t.tables.split(",").map(a=>a.trim()),url:t.url??process.env.DATABASE_URL})).code}));export{Ce as execute,Ae as resolveServerImport,Se as runIntrospectCommand};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import{t as J}from"../packem_shared/cli-C6sRqIMQ.mjs";import{i as W}from"../packem_shared/command-Bjv4VmYA.mjs";import{existsSync as u,readFileSync as y,realpathSync as D,statSync as T,writeFileSync as z,chmodSync as H,renameSync as I,unlinkSync as K,mkdirSync as q}from"node:fs";import{homedir as w}from"node:os";import{findWranglerFile as G}from"@lunora/config/cloudflare";import{join as s,dirname as V,relative as Z}from"@visulima/path";import{P as B,M as Q}from"../packem_shared/detect-package-manager-B2eIuAiP.mjs";import{stringify as X}from"smol-toml";import{modify as x,applyEdits as C,parse as Y}from"jsonc-parser";import{readLiveDevServerState as b}from"@lunora/config";import{resolveAdminToken as oo}from"@lunora/config/studio-host";import{connectLocalStdio as to}from"@lunora/mcp";const m=o=>({args:[...o.args],command:o.command,...o.env===void 0?{}:{env:o.env}}),$=o=>o.transport==="http"?{type:"http",url:o.url}:m(o),eo=o=>o.transport==="http"?{httpUrl:o.url}:m(o),ro=o=>o.transport==="http"?{serverUrl:o.url}:m(o),no=o=>({args:["-y","mcp-remote",o],command:"npx"}),ao=o=>o.transport==="http"?no(o.url):m(o),io=o=>o.transport==="http"?{url:o.url}:m(o),lo=o=>o.transport==="http"?{enabled:!0,type:"remote",url:o.url}:{command:[o.command,...o.args],enabled:!0,type:"local",...o.env===void 0?{}:{environment:o.env}},so=o=>o.transport==="http"?{disabled:!1,type:"streamableHttp",url:o.url}:{disabled:!1,...m(o)},co=({home:o,platform:t})=>{if(t==="darwin")return{global:s(o,"Library","Application Support","Claude","claude_desktop_config.json")};if(t==="win32"){const e=process.env.APPDATA;return e===void 0||e===""?{}:{global:s(e,"Claude","claude_desktop_config.json")}}return t==="linux"?{global:s(o,".config","Claude","claude_desktop_config.json")}:{}},po=(o,t)=>X({mcp_servers:{[o]:t.transport==="http"?{url:t.url}:{args:[...t.args],command:t.command,...t.env===void 0?{}:{env:t.env}}}}),h=[{buildEntry:$,paths:({projectRoot:o})=>({project:s(o,".mcp.json")}),format:"json",id:"claude-code",key:"mcpServers",label:"Claude Code"},{buildEntry:$,paths:({home:o,projectRoot:t})=>({global:s(o,".cursor","mcp.json"),project:s(t,".cursor","mcp.json")}),format:"json",id:"cursor",key:"mcpServers",label:"Cursor"},{buildEntry:$,paths:({projectRoot:o})=>({project:s(o,".vscode","mcp.json")}),format:"json",id:"vscode",key:"servers",label:"VS Code (GitHub Copilot)"},{buildEntry:eo,paths:({home:o,projectRoot:t})=>({global:s(o,".gemini","settings.json"),project:s(t,".gemini","settings.json")}),format:"json",id:"gemini",key:"mcpServers",label:"Gemini CLI"},{buildEntry:ao,paths:co,format:"json",id:"claude-desktop",key:"mcpServers",label:"Claude Desktop"},{buildEntry:ro,paths:({home:o})=>({global:s(o,".codeium","windsurf","mcp_config.json")}),format:"json",id:"windsurf",key:"mcpServers",label:"Windsurf"},{buildEntry:lo,paths:({home:o,projectRoot:t})=>({global:s(o,".config","opencode","opencode.json"),project:s(t,"opencode.json")}),format:"json",id:"opencode",key:"mcp",label:"OpenCode"},{buildEntry:so,paths:({home:o})=>({global:s(o,".cline","mcp.json")}),format:"json",id:"cline",key:"mcpServers",label:"Cline"},{buildEntry:io,paths:({home:o})=>({global:s(o,".config","zed","settings.json")}),format:"json",id:"zed",key:"context_servers",label:"Zed"},{paths:({home:o,projectRoot:t})=>({global:s(o,".codex","config.toml"),project:s(t,".codex","config.toml")}),format:"manual",id:"codex",label:"Codex CLI",renderSnippet:po}],E=h.map(o=>o.id),uo=o=>h.find(t=>t.id===o.toLowerCase()),v=(o,t)=>{let e=o,r;try{e=D(o),r=T(e).mode}catch{}const n=`${e}.lunora-${Math.random().toString(36).slice(2,10)}.tmp`;try{z(n,t,"utf8"),r!==void 0&&H(n,r),I(n,e)}catch(a){try{K(n)}catch{}throw a}},R={formattingOptions:{insertSpaces:!0,tabSize:4}},k=o=>{const t=[],e=Y(o,t,{allowTrailingComma:!0});return{errors:t,value:e}},g=o=>typeof o=="object"&&o!==null&&!Array.isArray(o),j=(o,t,e)=>{if(!g(o))return;const r=o[t];return g(r)?r[e]:void 0},U=o=>{if(!u(o.path))return"absent";let t;try{t=y(o.path,"utf8")}catch{return"invalid"}if(t.trim().length===0)return"absent";const{errors:e,value:r}=k(t);return e.length>0||!g(r)?"invalid":j(r,o.key,o.name)===void 0?"absent":"present"},mo=o=>U(o)==="present",fo=o=>{const{entry:t,force:e=!1,key:r,name:n,path:a}=o;if(!u(a))return q(V(a),{recursive:!0}),v(a,`${JSON.stringify({[r]:{[n]:t}},void 0,4)}
|
|
2
|
+
`),{action:"created",path:a};const i=y(a,"utf8");if(i.trim().length===0)return v(a,`${JSON.stringify({[r]:{[n]:t}},void 0,4)}
|
|
3
|
+
`),{action:"created",path:a};const{errors:l,value:c}=k(i);if(l.length>0)return{action:"invalid",error:`parse error at offset ${String(l[0]?.offset??0)}`,path:a};if(!g(c))return{action:"invalid",error:"the file's root is not a JSON object",path:a};const f=c[r];if(f!==void 0&&!g(f))return{action:"invalid",error:`"${r}" is not an object`,path:a};if(j(c,r,n)!==void 0&&!e)return{action:"skipped",path:a};try{const d=x(i,[r,n],t,R);d.length>0&&v(a,C(i,d))}catch(d){return{action:"invalid",error:d instanceof Error?d.message:String(d),path:a}}return{action:"updated",path:a}},go=o=>{const{key:t,name:e,path:r}=o;if(!u(r))return{action:"absent",path:r};let n;try{n=y(r,"utf8")}catch(l){return{action:"invalid",error:l instanceof Error?l.message:String(l),path:r}}const{errors:a,value:i}=k(n);if(a.length>0)return{action:"invalid",error:`parse error at offset ${String(a[0]?.offset??0)}`,path:r};if(j(i,t,e)===void 0)return{action:"absent",path:r};try{const l=x(n,[t,e],void 0,R);l.length>0&&v(r,C(n,l))}catch(l){return{action:"invalid",error:l instanceof Error?l.message:String(l),path:r}}return{action:"removed",path:r}},ho=["global","project"],p=(o,t)=>{const e=Z(t,o);return e.length>0&&!e.startsWith("..")?e:o},vo=(o,t)=>{const e=o.paths(t);return ho.flatMap(r=>{const n=e[r];return n===void 0?[]:[{client:o,path:n,scope:r}]})},yo=(o,t,e,r)=>{const n=o.paths(t),a=e==="global"?"project":"global",i=n[e]??(r?void 0:n[a]);if(i!==void 0)return{client:o,path:i,scope:n[e]===void 0?a:e}},$o=o=>h.filter(t=>Object.values(t.paths(o)).some(e=>u(e))),N=(o,t,e,r)=>{if(o.length===0)return t();const n=[];for(const a of o){const i=uo(a);if(i===void 0){e.error(`mcp ${r}: unknown client "${a}". Known clients: ${E.join(", ")}.`);return}n.push(i)}return n},bo=o=>o.client.format==="json",wo="https://lunora.sh/mcp",_="lunora-docs",M="lunora",ko=o=>u(s(o,"lunora"))&&G(o)!==void 0,jo=o=>{const{args:t,command:e}=Q(o,"lunora",["mcp","serve"]);return{args:t,command:e,transport:"stdio"}},So=o=>({transport:"http",url:o}),Oo=o=>({home:o.home,platform:o.platform,projectRoot:o.cwd}),A=(o,t,e)=>yo(o,Oo(e),e.scope??t.preferredScope,e.scope!==void 0||!t.allowScopeFallback),xo=(o,t,e)=>{const r=A(o,t,e);if(r===void 0){e.logger.warn(`${o.label}: has no ${e.scope??t.preferredScope}-scoped config — skipped "${t.name}".`);return}const{path:n}=r,a=o.buildEntry(t.spec);if(e.print===!0){const c=p(n,e.cwd);return e.force!==!0&&mo({key:o.key,name:t.name,path:n})?(e.logger.info(`${o.label}: "${t.name}" already configured in ${c} — a real install would skip it (re-run with --force to replace).`),{action:"printed",path:n}):(e.logger.info(`${o.label} → ${c}
|
|
4
|
+
${JSON.stringify({[o.key]:{[t.name]:a}},void 0,4)}`),{action:"printed",path:n})}const i=fo({entry:a,force:e.force===!0,key:o.key,name:t.name,path:n}),l=p(n,e.cwd);return i.action==="invalid"?e.logger.error(`${o.label}: ${l} is not valid JSON (${i.error??"unknown error"}) — left untouched.`):i.action==="skipped"?e.logger.info(`${o.label}: "${t.name}" already configured in ${l} — re-run with --force to replace it.`):e.logger.success(`${o.label}: ${i.action==="created"?"created":"updated"} ${l} with "${t.name}".`),{action:i.action,path:n}},Co=(o,t,e)=>{const r=A(o,t,e)?.path;if(r===void 0){e.logger.warn(`${o.label}: no known config location on ${e.platform} — skipped.`);return}return e.logger.info(`${o.label}: add this to ${p(r,e.cwd)}
|
|
5
|
+
|
|
6
|
+
${o.renderSnippet(t.name,t.spec)}`),{action:"printed",path:r}},Eo=o=>{const t=[];return o.localOnly!==!0&&t.push({allowScopeFallback:!0,name:_,preferredScope:"global",spec:So(o.docsUrl??wo)}),o.docsOnly!==!0&&ko(o.cwd)&&t.push({allowScopeFallback:!1,name:M,preferredScope:"project",spec:jo(B(o.cwd))}),t},Ro=o=>{const t=o.home??w(),e=o.platform??process.platform;o.logger.info("Supported MCP clients:");for(const r of h){const n=r.paths({home:t,platform:e,projectRoot:o.cwd}),a=i=>{const l=n[i];return l===void 0?"—":p(l,o.cwd)};o.logger.info(` ${r.id.padEnd(15)} ${r.label.padEnd(24)} project: ${a("project").padEnd(30)} global: ${a("global")}`)}return{code:0,written:[]}},Uo=o=>o.docsOnly===!0&&o.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).",No=(o,t,e)=>{const r=[];for(const n of o)for(const a of t){const i=n.format==="json"?xo(n,a,e):Co(n,a,e);i!==void 0&&r.push({action:i.action,client:n.id,path:i.path,server:a.name})}return r},_o=o=>{const t=o.home??w(),e=o.platform??process.platform,r=N(o.clients,()=>$o({home:t,platform:e,projectRoot:o.cwd}),o.logger,"install");if(r===void 0)return{code:1,written:[]};if(r.length===0)return o.logger.error(`mcp install: no MCP client config found — name one explicitly, e.g. \`lunora mcp install claude-code\`. Known clients: ${E.join(", ")}.`),{code:1,written:[]};o.clients.length===0&&o.logger.info(`Detected ${String(r.length)} configured client(s): ${r.map(i=>i.label).join(", ")}.`);const n=Eo(o);if(n.length===0)return o.logger.error(`mcp install: nothing to install — ${Uo(o)}`),{code:1,written:[]};const a=No(r,n,{...o,home:t,platform:e});return a.some(i=>i.action==="created"||i.action==="updated")&&o.logger.info("Restart your editor (or reload its MCP servers) to pick up the change."),{code:a.some(i=>i.action==="invalid")?1:0,written:a}},L=100,F=1e3,Mo=o=>({content:[{text:JSON.stringify(o,void 0,2),type:"text"}]}),Ao=o=>({content:[{text:o,type:"text"}]}),Lo=o=>{const t=typeof o=="string"?Number(o):o;return typeof t!="number"||!Number.isFinite(t)?L:Math.min(F,Math.max(1,Math.floor(t)))},Fo=(o,t)=>{const e=y(o,"utf8").split(`
|
|
7
|
+
`);return e.at(-1)===""&&e.pop(),e.slice(-t).join(`
|
|
8
|
+
`)},Po=o=>[{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 t=b(o);return Mo(t===void 0?{hint:"Start it with `lunora dev` in the project directory.",running:!1}:{background:t.background===!0,logFile:t.logFile,mode:t.mode,pid:t.pid,running:!0,startedAt:t.startedAt,studioUrl:t.studioUrl,url:t.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(L)}, max ${String(F)})`,type:"number"}},type:"object"},name:"lunora_dev_logs"},handle:async t=>{const e=b(o);if(e===void 0)return{content:[{text:"no dev server is running — start one with `lunora dev`",type:"text"}],isError:!0};if(e.logFile===void 0||!u(e.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 r=Lo(t.lines),n=Fo(e.logFile,r);return Ao(n.length===0?"(the dev server log is empty)":n)}}],Jo=new Set(["127.0.0.1","::1","localhost"]),P=o=>{try{const{hostname:t}=new URL(o);return Jo.has(t.startsWith("[")?t.slice(1,-1):t)}catch{return!1}},S=o=>{const t=o.url??b(o.cwd)?.url;if(t===void 0||t.length===0)return;if(o.token!==void 0&&o.token.length>0)return{token:o.token,url:t};if(o.url!==void 0&&!P(o.url))return{url:t};const e=oo(o.cwd);return e===void 0||e.length===0?{url:t}:{token:e,url:t}},Wo=async o=>{await new Promise(t=>{const e=()=>{t()};o.onclose=e,process.stdin.once("close",e),process.stdin.once("end",e)})},Do=(o,t)=>{if(o===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(o.token!==void 0)return`lunora mcp serve: ready — deployment at ${o.url}
|
|
9
|
+
`;const e=t.url!==void 0&&!P(t.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 ${o.url} (${e})
|
|
10
|
+
`},To=async(o,t=to)=>{const e=o.writeError??(a=>{process.stderr.write(a)});let r;try{r=await t({allowWrites:o.allowWrites===!0,deployment:()=>S(o),docs:o.noDocs===!0?!1:{...o.docsUrl===void 0?{}:{baseUrl:o.docsUrl}},extraTools:Po(o.cwd),version:o.version})}catch(a){const i=a instanceof Error?a.message:String(a);return e(`lunora mcp serve: failed to start — ${i}
|
|
11
|
+
`),{code:1,deployment:void 0}}const n=S(o);return e(Do(n,o)),await Wo(r),{code:0,deployment:n}},zo=o=>{const t=[];return o.localOnly!==!0&&t.push(_),o.docsOnly!==!0&&t.push(M),t},Ho=(o,t,e,r)=>{const n=go({key:o.key,name:t,path:e}),a=p(e,r.cwd);return n.action==="removed"?r.logger.success(`${o.label}: removed "${t}" from ${a}.`):n.action==="invalid"&&r.logger.error(`${o.label}: ${a} is not valid JSON (${n.error??"unknown error"}) — left untouched.`),{action:n.action,path:e}},Io=(o,t,e,r)=>{const n=U({key:o.key,name:t,path:e}),a=p(e,r.cwd);return n==="invalid"?(r.logger.error(`${o.label}: ${a} is not valid JSON — a real run would report it and exit non-zero.`),{action:"invalid",path:e}):n==="absent"?{action:"absent",path:e}:(r.logger.info(`${o.label}: would remove "${t}" from ${a}.`),{action:"removed",path:e})},Ko=(o,t,e)=>o.flatMap(r=>vo(r,t)).filter(bo).filter(r=>e===void 0||r.scope===e),qo=o=>{const t=o.home??w(),e=o.platform??process.platform,r=N(o.clients,()=>h,o.logger,"uninstall");if(r===void 0)return{code:1,removed:[]};const n=zo(o);if(n.length===0)return o.logger.error("mcp uninstall: nothing to remove — `--docs-only` and `--local-only` are mutually exclusive, pass at most one."),{code:1,removed:[]};const a=[],i={home:t,platform:e,projectRoot:o.cwd};for(const l of Ko(r,i,o.scope))for(const c of n){const f=o.print===!0?Io(l.client,c,l.path,o):Ho(l.client,c,l.path,o);f.action!=="absent"&&a.push({...f,client:l.client.id,server:c})}return a.length===0?o.logger.info("Nothing to remove — no Lunora MCP servers were configured in the clients checked."):o.print===!0&&o.logger.info("Nothing was changed — re-run without --print to remove these."),{code:a.some(l=>l.action==="invalid")?1:0,removed:a}},O=o=>o.global===!0?"global":o.project===!0?"project":void 0,Go=async(o,t)=>{const{code:e}=await To({allowWrites:t.allowWrites===!0,cwd:o,noDocs:t.docs===!1,version:J,...t.docsUrl===void 0?{}:{docsUrl:t.docsUrl},...t.token===void 0?{}:{token:t.token},...t.url===void 0?{}:{url:t.url}});return{code:e}},it=W(async({argument:o,cwd:t,logger:e,options:r})=>{const[n,...a]=o;if(n==="serve")return Go(t,r);if(n==="uninstall"){const i=O(r),{code:l}=qo({clients:a,cwd:t,docsOnly:r.docsOnly===!0,localOnly:r.localOnly===!0,logger:e,print:r.print===!0,...i===void 0?{}:{scope:i}});return{code:l}}if(n==="install"){if(r.list===!0)return Ro({cwd:t,logger:e});const i=O(r),{code:l}=_o({clients:a,cwd:t,docsOnly:r.docsOnly===!0,force:r.force===!0,localOnly:r.localOnly===!0,logger:e,print:r.print===!0,...i===void 0?{}:{scope:i},...r.docsUrl===void 0?{}:{docsUrl:r.docsUrl}});return{code:l}}return e.error("mcp: unknown subcommand. Usage: lunora mcp <install|uninstall|serve>"),{code:1}});export{it as execute};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r
|
|
1
|
+
import{r}from"../packem_shared/api-spec-BENwiyUa.mjs";import{i as a}from"../packem_shared/command-Bjv4VmYA.mjs";import{runDeployCommand as c}from"./runDeployCommand.mjs";const i=".lunora/build",p=async o=>{const e=o.outDir??i,t=await c({apiSpec:o.apiSpec,cwd:o.cwd,dryRun:!0,format:o.format,logger:o.logger,outDir:e,spawner:o.spawner,target:o.target});return t.code===0&&o.logger.success(`build complete — bundle written to ${e}`),t},d=a(async({cwd:o,logger:e,options:t})=>({code:(await p({apiSpec:r(t.apiSpec),cwd:o,format:t.format,logger:e,outDir:t.outDir,target:t.target})).code}));export{d as execute,p as runBuildCommand};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{existsSync as g,readFileSync as m}from"node:fs";import{join as h}from"node:path";import{
|
|
1
|
+
import{existsSync as g,readFileSync as m}from"node:fs";import{join as h}from"node:path";import{isPlaceholderValue as v,DEV_VARS_FILE as p,parseDevVariableEntries as w,discoverSchemaInfo as $,inferLunoraBindings as x}from"@lunora/config";import{findWranglerFile as y,readWranglerJsonc as b,validateWranglerConfig as S}from"@lunora/config/cloudflare";import{i as _}from"../packem_shared/command-Bjv4VmYA.mjs";import{o as N,p as R}from"../packem_shared/vectorize-metadata-BvZbbqUD.mjs";const k=/(?:KEY|PASSWORD|SECRET|TOKEN)$/u,A=a=>{const e=a.trim();if(e==="")return!0;const n=e.toLowerCase();return n.includes("replace")||n.startsWith("<")&&n.endsWith(">")},j=a=>{const e=y(a);if(e===void 0)return{parsed:void 0,path:void 0};const{parsed:n}=b(e);return{parsed:n,path:e}},O=(a,e,n)=>{if(e===void 0){n.push({fix:"Run `lunora init` (or `lunora dev`) to scaffold and reconcile wrangler.jsonc.",level:"fail",message:"wrangler.jsonc not found."});return}if(a===void 0){n.push({fix:`Check ${e} is valid JSONC.`,level:"fail",message:`Could not parse ${e}.`});return}const r=S(a).errors.find(t=>t.includes("SHARD"));r===void 0?n.push({level:"pass",message:"wrangler.jsonc present with a SHARD durable-object binding."}):n.push({fix:"Run `lunora dev` to auto-reconcile, or add the binding manually.",level:"fail",message:r})},D=(a,e)=>{const{info:n}=$(a,"lunora");for(const r of n?.vectorMetadata??[]){const t=R(r.kind);if(t===void 0){e.push({fix:"Filter on a string, number or boolean column, or drop it from `metadata`.",level:"warn",message:`vector index "${r.index}" declares metadata "${r.property}", whose type Vectorize cannot filter on.`});continue}e.push({fix:`wrangler ${N({index:r.index,property:r.property,type:t}).join(" ")}`,level:"info",message:`vector index "${r.index}" filters on metadata "${r.property}" — that needs a Vectorize metadata index (\`lunora deploy\` creates it).`})}},E=(a,e)=>{if(a===void 0)return;const n=(a.d1_databases??[]).filter(Boolean);for(const r of n){const t=typeof r.database_id=="string"?r.database_id:"";if(A(t)){const o=typeof r.binding=="string"&&r.binding.length>0?r.binding:"<unnamed>";e.push({fix:"Run `wrangler d1 create <name>` and paste the returned database_id into wrangler.jsonc.",level:"fail",message:`D1 binding "${o}" has a placeholder database_id ("${t||"<empty>"}").`})}}},L=(a,e)=>{if(a===void 0)return;const n=(a.send_email??[]).filter(Boolean);for(const r of n){const t=typeof r.destination_address=="string"?r.destination_address:"";if(t!==""&&v(t)){const o=typeof r.name=="string"&&r.name.length>0?r.name:"send_email";e.push({fix:"Set destination_address to a verified Cloudflare Email Routing address.",level:"warn",message:`send_email binding "${o}" has a placeholder destination_address ("${t}").`})}}},I=(a,e)=>{const n=h(a,p);if(!g(n))return;let r;try{r=m(n,"utf8")}catch{return}const t=w(r).filter(o=>k.test(o.key)&&v(o.value)).map(o=>o.key);t.length>0&&e.push({fix:"Run `lunora dev` to auto-generate secrets, or fill them in by hand.",level:"warn",message:`${p} has unfilled secret value(s): ${t.join(", ")}.`})},C=a=>{const e=process.env.LUNORA_ADMIN_TOKEN;e===void 0||e.trim()===""?a.push({fix:"Set LUNORA_ADMIN_TOKEN (env or `.dev.vars`) to enable admin RPCs / studio.",level:"info",message:"LUNORA_ADMIN_TOKEN is not set."}):a.push({level:"pass",message:"LUNORA_ADMIN_TOKEN is set."})},W=async(a,e)=>{let n;try{({containers:n}=await x({projectRoot:a}))}catch{return}for(const r of n)r.exported?e.push({level:"pass",message:`container "${r.exportName}" is exported by the worker entry.`}):e.push({fix:'Add `export * from "./lunora/_generated/containers"` to your worker entry (or re-run `vis generate lunora-container`).',level:"fail",message:`container "${r.exportName}" is declared but ${r.className} is not exported by the worker entry.`})},M=/^[\^~><= ]+/u,z=/^(?<core>\d+\.\d+\.\d+)(?:-(?<channel>[a-z]+)\.(?<counter>\d+))?$/u,F=a=>{const e=a.replace(M,"").trim(),n=z.exec(e);if(!n?.groups)return;const{channel:r,core:t,counter:o}=n.groups;return{channel:r??"",core:t??"",counter:o===void 0?void 0:Number.parseInt(o,10),raw:e}},K=(a,e)=>{const n=h(a,"package.json");if(!g(n))return;let r;try{r=JSON.parse(m(n,"utf8"))}catch{return}const t={...r.devDependencies,...r.dependencies},o=[];for(const[s,i]of Object.entries(t)){if(s!=="lunorash"&&!s.startsWith("@lunora/"))continue;const f=F(i);f&&o.push({name:s,version:f})}if(o.length<2)return;const d=s=>s.map(i=>`${i.name}@${i.version.raw}`).join(", "),u=new Set(o.map(s=>s.version.core)),c=new Set(o.map(s=>s.version.channel));if(u.size>1){e.push({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(u.size)} different versions: ${d(o)}.`});return}if(c.size>1){e.push({fix:"Pick one channel (all stable, or all alpha/beta) and update the odd package out.",level:"warn",message:`Lunora packages mix release channels (${[...c].map(s=>s===""?"stable":s).join(" + ")}): ${d(o)}.`});return}const l=o.map(s=>s.version.counter).filter(s=>s!==void 0);if(l.length>1){const s=Math.min(...l),i=Math.max(...l);e.push({level:"info",message:l.length===o.length&&s===i?`Lunora packages are all at ${[...c][0]??""}.${String(i)}.`:`Lunora pre-release counters span ${String(s)}–${String(i)}: ${d(o)}.`})}},T=async a=>{const e=a.cwd??process.cwd(),n=[],{parsed:r,path:t}=j(e);return O(r,t,n),E(r,n),L(r,n),I(e,n),C(n),K(e,n),D(e,n),await W(e,n),{code:n.some(o=>o.level==="fail")?1:0,findings:n}},V={fail:"FAIL",info:"INFO",pass:"PASS",warn:"WARN"},P=(a,e)=>{e.info("lunora doctor — project preflight");for(const t of a.findings){const o=`[${V[t.level]}] ${t.message}`;t.level==="fail"?e.error(o):t.level==="warn"?e.warn(o):e.info(o),t.fix!==void 0&&t.level!=="pass"&&e.info(` fix: ${t.fix}`)}const n=a.findings.filter(t=>t.level==="fail").length,r=a.findings.filter(t=>t.level==="warn").length;n>0?e.error(`${String(n)} failure(s), ${String(r)} warning(s).`):r>0?e.warn(`0 failures, ${String(r)} warning(s).`):e.success("all checks passed.")},G=_(async({cwd:a,logger:e})=>{const n=await T({cwd:a});return P(n,e),{code:n.code}});export{G as execute,T as runDoctor};
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import{existsSync as f,readFileSync as m,writeFileSync as $}from"node:fs";import{join as S}from"node:path";import{DEV_VARS_FILE as
|
|
1
|
+
import{existsSync as f,readFileSync as m,writeFileSync as $}from"node:fs";import{join as S}from"node:path";import{DEV_VARS_FILE as u,DEV_VARS_KEY_PATTERN as b,resolveDeployDriver as R,resolveProjectTarget as _,generateSecretValue as x,DEV_VARS_EXAMPLE_FILE as v,parseDevVariableEntries as E,isPlaceholderValue as L,packageNamesFromBindings as z,inferLunoraBindings as K,requiredSecrets as Y,isMintableSecretKey as k}from"@lunora/config";import{i as j}from"../packem_shared/command-Bjv4VmYA.mjs";import{P as q,M as U}from"../packem_shared/detect-package-manager-B2eIuAiP.mjs";import{defaultSpawner as C}from"../packem_shared/createRecordingSpawner-ByIqBepG.mjs";import{R as D}from"../packem_shared/wrangler-secrets-DDDUuryf.mjs";const M=/[\r\n]/u,F=/["\\]/u,V=e=>{const o=new Map;for(const t of E(e))o.set(t.key,t);return o},Z=e=>e.replaceAll(/[.*+?^${}()|[\]\\]/gu,String.raw`\$&`),w=(e,o)=>new RegExp(String.raw`^[ \t]*${Z(e)}[ \t]*=.*(\r?\n|$)`,o?"gmu":"mu"),P=(e,o,t)=>{const r=`${o}="${t}"`;if(!w(o,!1).test(e))return e===""?`${r}
|
|
2
2
|
`:e.endsWith(`
|
|
3
3
|
`)?`${e}${r}
|
|
4
4
|
`:`${e}
|
|
5
5
|
${r}
|
|
6
|
-
`;let s=!1;return e.replace(w(o,!0),(i,n)=>s?"":(s=!0,`${r}${n}`))},
|
|
7
|
-
`),{code:0,descriptors:[]}):(t.error(`env: ${r.key} is not set in ${
|
|
8
|
-
`);return{code:0,descriptors:[]}},
|
|
6
|
+
`;let s=!1;return e.replace(w(o,!0),(i,n)=>s?"":(s=!0,`${r}${n}`))},T=(e,o)=>e.replaceAll(new RegExp(String.raw`^[ \t]*${o}[ \t]*=.*(?:\r?\n|$)`,"gmu"),""),A=e=>e.length<=4?"****":`${e.slice(0,4)}${"*".repeat(Math.min(8,e.length-4))}`,g=e=>f(e)?V(m(e,"utf8")):new Map,B=e=>{const o=g(e.devVariablesPath);if(o.size===0)return e.logger.info(`${u}: (empty)`),{code:0,descriptors:[]};for(const t of o.values())e.logger.info(`${t.key}=${A(t.value)}`);return{code:0,descriptors:[]}},I=e=>{const{devVariablesPath:o,logger:t,options:r}=e;if(!r.key)return t.error("env get requires a key. Usage: lunora env get <KEY>"),{code:1,descriptors:[]};const s=g(o).get(r.key);return s?(process.stdout.write(`${s.value}
|
|
7
|
+
`),{code:0,descriptors:[]}):(t.error(`env: ${r.key} is not set in ${u}`),{code:1,descriptors:[]})},N=e=>{const{devVariablesPath:o,logger:t,options:r}=e;if(!r.key)return t.error("env set requires a key. Usage: lunora env set <KEY> <VALUE>"),{code:1,descriptors:[]};if(!b.test(r.key))return t.error(`env: invalid key "${r.key}" — must match [A-Za-z_][A-Za-z0-9_]*`),{code:1,descriptors:[]};if(r.value===void 0)return t.error("env set requires a value. Usage: lunora env set <KEY> <VALUE>"),{code:1,descriptors:[]};if(M.test(r.value))return t.error(`env: value for "${r.key}" contains a newline, which .dev.vars cannot represent`),{code:1,descriptors:[]};if(F.test(r.value))return t.error(`env: value for "${r.key}" contains a double-quote or backslash, which .dev.vars cannot round-trip`),{code:1,descriptors:[]};const s=f(o)?m(o,"utf8"):"";return $(o,P(s,r.key,r.value),"utf8"),t.success(`env: set ${r.key} (${A(r.value)}) in ${u}`),{code:0,descriptors:[]}},W=e=>{const{devVariablesPath:o,logger:t,options:r}=e;if(!r.key)return t.error("env unset requires a key. Usage: lunora env unset <KEY>"),{code:1,descriptors:[]};const s=f(o)?m(o,"utf8"):"";return V(s).has(r.key)?($(o,T(s,r.key),"utf8"),t.success(`env: unset ${r.key} in ${u}`),{code:0,descriptors:[]}):(t.warn(`env: ${r.key} was not set in ${u}`),{code:0,descriptors:[]})},X=async e=>{const{devVariablesPath:o,logger:t,options:r}=e;if(!r.yes)return t.error("env push uploads secrets to Cloudflare. Re-run with --yes to confirm."),{code:1,descriptors:[]};const s=g(o);if(s.size===0)return t.warn(`${u}: nothing to push (empty)`),{code:0,descriptors:[]};const i=r.spawner??C,n=r.cwd??process.cwd(),d=q(n),p=[];for(const a of s.values()){const l=R(_(n)).toolchain?.secretPut({environment:r.prod===!0?"production":void 0,key:a.key,temporary:r.temporary});if(l===void 0)return t.error("deploy target has no command-line toolchain; cannot push secrets"),{code:1,descriptors:[]};const c=U(d,l.tool,l.args),h={args:c.args,command:c.command,cwd:n,input:a.value};p.push(h),t.info(`pushing ${a.key} -> wrangler secret${r.prod?" (production)":""}`);const y=await i(h);if(y.code!==0)return t.error(`env push: failed at ${a.key} (exit ${String(y.code)})`),{code:y.code,descriptors:p}}return t.success(`env: pushed ${String(s.size)} secret(s)`),{code:0,descriptors:p}},G=e=>(e.options.secretLister??D)({cwd:e.cwd,env:e.options.prod?"production":void 0,temporary:e.options.temporary}),H=async e=>{const{devVariablesPath:o,logger:t}=e,r=await G(e);if(!r.ok)return t.error(`env diff: ${r.error??"failed to list remote secrets"}`),{code:1,descriptors:[]};const s=new Set(g(o).keys()),i=new Set(r.names),n=[...s].filter(a=>!i.has(a)).toSorted((a,l)=>a.localeCompare(l)),d=r.names.filter(a=>!s.has(a)),p=[...s].filter(a=>i.has(a)).toSorted((a,l)=>a.localeCompare(l));for(const a of n)t.info(`local only (run \`lunora env push\`): ${a}`);for(const a of d)t.info(`remote only (in Cloudflare, not ${u}): ${a}`);return t.info(`in both: ${String(p.length)} secret(s)`),n.length===0&&d.length===0&&t.success("env diff: local and remote secret names match"),{code:0,descriptors:[]}},J=e=>{const{cwd:o,devVariablesPath:t,logger:r}=e,s=S(o,v);if(!f(s))return r.info(`env doctor: no ${v} to check against — nothing to validate.`),{code:0,descriptors:[]};const i=E(m(s,"utf8")).map(c=>c.key),n=g(t);if(!f(t))return r.error(`env doctor: ${u} is missing. Run \`lunora dev\` to scaffold it, or \`lunora env set <KEY> <VALUE>\`.`),r.info(`expected (from ${v}): ${i.join(", ")}`),{code:1,descriptors:[]};const d=i.filter(c=>!n.has(c)),p=[...n.values()].filter(c=>L(c.value)).map(c=>c.key),a=new Set(i),l=[...n.keys()].filter(c=>!a.has(c));for(const c of d)r.error(`missing: ${c} is in ${v} but not ${u}`);for(const c of p)r.error(`unset: ${c} still has a placeholder value`);for(const c of l)r.info(`extra: ${c} is set locally but not listed in ${v}`);return d.length===0&&p.length===0?(r.success(`env doctor: ${u} looks good (${String(n.size)} var(s)).`),{code:0,descriptors:[]}):{code:1,descriptors:[]}},Q=async e=>{let o=[];try{o=z(await K({projectRoot:e.cwd}))}catch{}const t=Y(o).map(s=>s.key).filter(s=>k(s)),r=[...g(e.devVariablesPath).keys()].filter(s=>k(s));return[...new Set([...t,...r])]},O=async e=>{const{devVariablesPath:o,logger:t,options:r}=e;let s;if(r.key===void 0){if(s=await Q(e),s.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(!b.test(r.key))return t.error(`env: invalid key "${r.key}" — must match [A-Za-z_][A-Za-z0-9_]*`),{code:1,descriptors:[]};s=[r.key]}const i=s.map(n=>({key:n,value:x()}));if(r.set===!0){let n=f(o)?m(o,"utf8"):"";for(const d of i)n=P(n,d.key,d.value);return $(o,n,"utf8"),t.success(`env: generated ${String(i.length)} secret(s) into ${u}: ${i.map(d=>d.key).join(", ")}`),{code:0,descriptors:[]}}for(const n of i)process.stdout.write(`${n.key}=${n.value}
|
|
8
|
+
`);return{code:0,descriptors:[]}},ee=async e=>{const o=e.cwd??process.cwd(),t={cwd:o,devVariablesPath:S(o,u),logger:e.logger,options:e};switch(e.subcommand){case"diff":return H(t);case"doctor":return J(t);case"generate":return O(t);case"get":return I(t);case"list":return B(t);case"push":return X(t);case"set":return N(t);case"unset":return W(t);default:return e.logger.error(`env: unknown subcommand "${e.subcommand}"`),{code:1,descriptors:[]}}},re=e=>e==="list"||e==="get"||e==="set"||e==="unset"||e==="push"||e==="diff"||e==="doctor"||e==="generate",de=j(({argument:e,cwd:o,logger:t,options:r})=>{const s=e[0];return re(s)?ee({cwd:o,key:e[1],logger:t,prod:r.prod===!0,set:r.set===!0,subcommand:s,temporary:r.temporary===!0,value:e[2],yes:r.yes===!0}):(t.error(`env: unknown subcommand "${s??""}" — expected list | get | set | unset | push | diff | doctor | generate`),{code:1})});export{de as execute,ee as runEnvCommand};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import{spawnSync as N,spawn as J}from"node:child_process";import{existsSync as L,watch as me,readFileSync as K,statSync as fe,openSync as z,readSync as ve,closeSync as Y,mkdirSync as we}from"node:fs";import{join as k,dirname as he}from"node:path";import{runCodegen as X}from"@lunora/codegen";import{detectAgentRules as Z,claimDevServerState as Q,clearDevServerState as f,readDevServerState as
|
|
2
|
-
`)),
|
|
3
|
-
`)+1)}finally{Y(
|
|
4
|
-
`);return
|
|
1
|
+
import{spawnSync as N,spawn as J}from"node:child_process";import{existsSync as L,watch as me,readFileSync as K,statSync as fe,openSync as z,readSync as ve,closeSync as Y,mkdirSync as we}from"node:fs";import{join as k,dirname as he}from"node:path";import{runCodegen as X}from"@lunora/codegen";import{detectAgentRules as Z,claimDevServerState as Q,clearDevServerState as f,readDevServerState as I,readLiveDevServerState as y,detectFramework as ee,readProjectDependencyNames as Se,DEV_HANDOFF_ENV as h,isRecordedProcessCurrent as ke,DEV_LOG_FILE as ye,DEV_LOG_FILE_ENV as re,DEV_DAEMON_ENV as O,updateDevServerState as te,detectAiAgent as be,readProjectRemotePreference as $e,resolveTargetOrThrow as Ee,inferLunoraBindings as Ne,packageNamesFromBindings as Le,ensureDevVarsExample as Ie,ensureDevVariables as Oe,isInteractive as Pe,DEV_VARS_FILE as x,DEV_VARS_EXAMPLE_FILE as Re,fillDevSecrets as Te,claimAgentRulesHint as De,AGENT_RULES_HINT as xe,resolveDeployDriver as Ce,resolveProjectTarget as _e,discoverContainerInfo as Ae,streamContainerLogs as je,formatLunoraEvent as Fe}from"@lunora/config";import{resolveRemoteEnabled as Me,findWranglerFile as oe,readWranglerJsonc as ne,materializeRemoteWranglerConfig as Ge}from"@lunora/config/cloudflare";import{r as He}from"../packem_shared/api-spec-BENwiyUa.mjs";import{l as Ue}from"../packem_shared/codegen-error-DJN6pTH5.mjs";import{a as Ve}from"../packem_shared/platform-diagnostics-C4TFj5Pu.mjs";import{i as We}from"../packem_shared/command-Bjv4VmYA.mjs";import{P as se,M as $,k as qe}from"../packem_shared/detect-package-manager-B2eIuAiP.mjs";import{createServer as Be,connect as Je}from"node:net";import{forceJsonLogging as Ke}from"../packem_shared/createLogger--C3x1FNE.mjs";import{networkInterfaces as ze}from"node:os";import{spawnShellCompat as ae}from"../packem_shared/createRecordingSpawner-ByIqBepG.mjs";import{createServer as Ye,request as Xe}from"node:http";import{loadStudioAssets as C,studioAssetsStamp as _,renderStudioHtml as Ze,resolveAdminToken as Qe,SCHEMA_EDIT_ENDPOINT as er,POLICY_SCAFFOLD_ENDPOINT as rr,SEED_ENDPOINT as tr,serveJsonHandler as or,isStandaloneModulePath as nr,readStandaloneAsset as sr,assetContentType as ar,handleSchemaEditRequest as ir,handlePolicyScaffoldRequest as dr,handleSeedRequest as cr}from"@lunora/config/studio-host";import{$ as lr}from"../packem_shared/tui-prompts-CCt3jm1k.mjs";import{d as v}from"../packem_shared/output-format-D7cKB-O5.mjs";const ur=100,pr=/[/\\]/u,A=(e,r,o)=>{const{apiSpec:t,logger:n,projectRoot:s,target:i}=e;try{const a=X({apiSpec:t,lunoraDirectory:r,projectRoot:s,target:i});n.success(`codegen: wrote ${r}/_generated (${o})`),Ve(a.platformDiagnostics,n)}catch(a){n.error(Ue(a,o))}},gr=e=>{const r=e.lunoraDirectory??"lunora",o=k(e.projectRoot,r),t=e.debounceMs??ur;A(e,r,"startup");let n,s;if(!L(o))return e.logger.warn(`codegen watch unavailable (no such directory: ${o}) — schema edits will NOT auto-regenerate. Run \`lunora codegen\` manually after each edit.`),{close:()=>{},watchAvailable:!1};try{s=me(o,{recursive:!0},(a,c)=>{typeof c=="string"&&c.split(pr).includes("_generated")||(n&&clearTimeout(n),n=setTimeout(()=>{A(e,r,`change: ${c??"?"}`)},t))})}catch(a){return e.logger.warn(`codegen watch unavailable (${a instanceof Error?a.message:String(a)}) — schema edits will NOT auto-regenerate. Run \`lunora codegen\` manually after each edit.`),{close:()=>{},watchAvailable:!1}}const i=s;return{close:()=>{n&&clearTimeout(n),i.close()},watchAvailable:!0}},mr=64,ie="127.0.0.1",fr=65535,vr=(e,r=ie)=>new Promise(o=>{const t=Be();t.once("error",()=>{o(!1)}),t.once("listening",()=>{t.close(()=>{o(!0)})}),t.listen(e,r)}),wr=async(e,r=ie,o=mr)=>{for(let t=e;t<e+o&&t<=fr;t+=1)if(await vr(t,r))return t;return e},j=(e=ze)=>Object.values(e()).some(r=>r?.some(o=>o.internal&&o.address==="::1")),F="/_lunora",M=e=>{const r=e.indexOf("?");return r===-1?e:e.slice(0,r)},hr=new Set(["127.0.0.1","::1","[::1]","localhost"]),G=e=>{if(e===void 0||e==="")return!1;const r=e.startsWith("[")?e.slice(0,e.indexOf("]")+1):e.split(":")[0]??e;return hr.has(r)},Sr=(e,r,o)=>{const t=Xe({headers:{...e.headers,host:o.host},hostname:o.hostname,method:e.method,path:e.url,port:o.port},n=>{r.writeHead(n.statusCode??502,n.headers),n.pipe(r)});t.on("error",n=>{r.statusCode=502,r.end(`lunora dev: worker unreachable (${n.message})`)}),e.pipe(t)},kr=5e3,yr=(e,r,o,t)=>{const n=Je({host:t.hostname,port:Number(t.port)},()=>{n.setTimeout(0);const s=[`${e.method??"GET"} ${e.url??"/"} HTTP/1.1`];for(const[i,a]of Object.entries(e.headers))if(i!=="host")for(const c of Array.isArray(a)?a:[a])c!==void 0&&s.push(`${i}: ${c}`);s.push(`host: ${t.host}`,"",""),n.write(s.join(`\r
|
|
2
|
+
`)),o.length>0&&n.write(o),n.pipe(r),r.pipe(n)});n.setTimeout(kr,()=>n.destroy()),n.on("error",()=>r.destroy()),r.on("error",()=>n.destroy())},br=async e=>{const r=e.host??"127.0.0.1",o=r==="127.0.0.1"||r==="localhost"||r==="::1",t=new URL(e.workerOrigin);let n=C(e.logger,import.meta.url),s=_(import.meta.url);const i=Ze({adminToken:o?Qe(e.cwd):void 0,basePath:"/",dataEditable:o,rulesInstalled:Z(e.cwd).installed,runAsIdentity:o,schemaEditable:o,scriptSrc:"/studio.js",styleHref:"/styles.css"}),a=(l,d,g)=>{l.statusCode=200,l.setHeader("Content-Type",g),l.end(d)},c=(l,d,g,b)=>{if(o){or(l,d,g,e.cwd);return}d.statusCode=403,d.setHeader("Content-Type","text/plain"),d.end(b)},u=(l,d)=>{const g=l==="/styles.css",b=nr(l);if(!g&&!b)return!1;const R=_(import.meta.url);if(R!==s&&(n=C(e.logger,import.meta.url),s=R),n===void 0)return d.statusCode=501,d.setHeader("Content-Type","text/plain"),d.end("Lunora studio assets not found — install and build @lunora/studio."),!0;if(g)return a(d,n.styles,"text/css; charset=utf-8"),!0;const T=l.slice(l.lastIndexOf("/")+1),D=sr(T,import.meta.url);return D===void 0?(d.statusCode=404,d.setHeader("Content-Type","text/plain"),d.end("Not found"),!0):(a(d,D,ar(T)),!0)},p=Buffer.from(i),m=Ye((l,d)=>{const g=M(l.url??"/");if(o&&!G(l.headers.host)){d.statusCode=403,d.setHeader("Content-Type","text/plain"),d.end("Lunora studio: refusing a request whose Host is not a loopback literal (DNS-rebinding guard).");return}if(g.startsWith(F)){if(!o){d.statusCode=403,d.setHeader("Content-Type","text/plain"),d.end("Lunora studio: the worker admin proxy is only available on a loopback bind.");return}Sr(l,d,t);return}if(g===er){c(l,d,ir,"Lunora schema editing is only available on loopback hosts in dev.");return}if(g===rr){c(l,d,dr,"Lunora policy scaffolding is only available on loopback hosts in dev.");return}if(g===tr){c(l,d,cr,"Lunora data seeding is only available on loopback hosts in dev.");return}u(g,d)||a(d,p,"text/html; charset=utf-8")});return m.on("upgrade",(l,d,g)=>{if(!o||!G(l.headers.host)){d.destroy();return}M(l.url??"").startsWith(F)?yr(l,d,g,t):d.destroy()}),await new Promise((l,d)=>{m.once("error",g=>{g.code==="EADDRINUSE"?d(new Error(`studio port ${String(e.port)} is already in use — pass a different port with --port, or stop the process using it`,{cause:g})):d(g)}),m.listen(e.port,r,()=>{l()})}),{close:()=>new Promise(l=>{m.close(()=>{l()})}),url:`http://${r==="0.0.0.0"||r==="::"?"localhost":r}:${String(e.port)}`}},$r=12e4,de=250,Er=1e4,Nr=100,Lr=40,w=256*1024,Ir="LUNORA_DEV_READY_TIMEOUT_MS",Or=new Set(["nuxt","sveltekit"]),P=e=>Or.has(ee(e).framework)?"framework-worker":Se(e).has("@lunora/vite")?"vite":"wrangler",ce=e=>{const r=se(e);let o;try{const t=K(k(e,"package.json"),"utf8");o=JSON.parse(t).scripts?.dev}catch{}if(o===void 0||o.trim()===""||o.includes("lunora")){const t=$(r,"vite",["dev"]);return{args:t.args,command:t.command}}return{args:["run","dev"],command:r}},E=e=>new Promise(r=>{setTimeout(r,e)}),Pr=async e=>{try{return await fetch(new URL("/_lunora/status",e),{signal:AbortSignal.timeout(1e3)}),!0}catch{return!1}},Rr=e=>{we(he(e.logPath),{recursive:!0});const r=z(e.logPath,"w",384);let o;const t=ae(e.command,e.args);try{o=J(t.command,t.args,{cwd:e.cwd,detached:!0,env:e.env,shell:t.shell,stdio:["ignore",r,r],windowsHide:!0})}finally{Y(r)}return o.unref(),{exited:new Promise(n=>{o.on("error",()=>{n(1)}),o.on("exit",(s,i)=>{n(s??(i?1:0))})}),pid:o.pid}},Tr=e=>{try{const{size:r}=fe(e);if(r<=w)return K(e,"utf8");const o=z(e,"r");try{const t=Buffer.alloc(w),n=ve(o,t,0,w,r-w),s=t.toString("utf8",0,n);return s.slice(s.indexOf(`
|
|
3
|
+
`)+1)}finally{Y(o)}}catch{return}},le=(e,r)=>{const o=Tr(e);if(o===void 0)return[];const t=o.split(`
|
|
4
|
+
`);return t.at(-1)===""&&t.pop(),r>0?t.slice(-r):t},ue=(e,r)=>r?.logFile??k(e,ye),pe=e=>{e.info(" Stop: lunora dev stop"),e.info(" Status: lunora dev status"),e.info(" Logs: lunora dev logs")},S=(e,r)=>{e.warn(`Dev server already running at ${r.url} (pid ${String(r.pid)})`),pe(e)},Dr=(e,r)=>{e.success(`Dev server running at ${r.url} (pid ${String(r.pid)})`),r.studioUrl!==void 0&&e.info(` Studio: ${r.studioUrl}`),pe(e)},xr=async e=>{const{child:r,cwd:o,deadline:t,pollIntervalMs:n,probe:s}=e,i=r.exited.then(a=>({exitCode:a}));for(;Date.now()<t;){const a=y(o);if(a!==void 0&&a.pid!==process.pid&&await s(a.url))return{state:a,status:"ready"};const c=await Promise.race([i,E(n)]);if(c!==void 0)return{...c,status:"exited"}}return{status:"timeout"}},Cr=async e=>{const{cwd:r,logger:o}=e,t=ue(r,void 0),n=Number(process.env[Ir]??""),s=e.readyTimeoutMs??(Number.isFinite(n)&&n>0?n:$r),i=(e.spawnDetached??Rr)({args:e.command.args,command:e.command.command,cwd:r,env:{...process.env,...e.env,[O]:"1",[re]:t,...process.env.FORCE_COLOR===void 0?{NO_COLOR:"1"}:{},...e.json?{LUNORA_LOG_JSON:"1"}:{}},logPath:t}),a=await xr({child:i,cwd:r,deadline:Date.now()+s,pollIntervalMs:e.pollIntervalMs??de,probe:e.probe??Pr});if(a.status==="ready")return Dr(o,a.state),{code:0};if(a.status==="exited"){o.error(`dev server exited before becoming ready (exit code ${String(a.exitCode)}). Last output:`);for(const u of le(t,Lr))o.error(` ${u}`);return f(r,i.pid??process.pid),{code:a.exitCode===0?1:a.exitCode}}i.pid!==void 0&&I(r)?.pid===process.pid&&te(r,{logFile:t,pid:i.pid});const c=i.pid===void 0?"":` (pid ${String(i.pid)})`;return o.warn(`dev server did not confirm ready within ${String(Math.round(s/1e3))}s — it may still be compiling${c}. Check \`lunora dev status\` and \`lunora dev logs\`; \`lunora dev stop\` shuts it down.`),{code:1}},_r=(e,r)=>{const o=["dev"];return e.apiSpec!==void 0&&o.push("--api-spec",e.apiSpec),e.port!==void 0&&o.push("--port",String(e.port)),e.workerPort!==void 0&&o.push("--worker-port",String(e.workerPort)),e.codegen===!1&&o.push("--no-codegen"),e.studio===!1&&o.push("--no-studio"),e.target!==void 0&&o.push("--target",e.target),r&&o.push("--remote"),o},Ar=async e=>{const{cwd:r,jsonLogs:o,logger:t,options:n,remote:s}=e,i=e.run??Cr,a=P(r),c=a==="wrangler"?`http://localhost:${String(n.workerPort??8787)}`:"http://localhost:5173",u=Q(r,{background:!0,mode:"cli",pid:process.pid,startedAt:new Date().toISOString(),url:c});if(!u.ok)return u.existing!==void 0&&S(t,u.existing),{code:0};const p={[h]:String(process.pid)};try{return a==="vite"?await i({command:ce(r),cwd:r,env:{...s?{LUNORA_REMOTE:"1"}:{},...p},json:o,logger:t}):await i({command:{args:[process.argv[1]??"lunora",..._r(n,s)],command:process.execPath},cwd:r,env:p,json:o,logger:t})}finally{f(r,process.pid)}},jr=e=>{try{const r=N("ps",["-o","pgid=","-p",String(e)],{encoding:"utf8"}),o=Number.parseInt(r.stdout.trim(),10);return Number.isInteger(o)&&o>0?o:void 0}catch{return}},Fr=(e,r,o=process.platform,t=N)=>{if(o==="win32"){try{t("taskkill",["/pid",String(e.pid),"/T","/F"],{stdio:"ignore"})}catch{}return}if(e.background===!0)try{r(-(jr(e.pid)??e.pid),"SIGKILL");return}catch{}try{r(e.pid,"SIGKILL")}catch{}},Mr=(e,r)=>(r.json?v({pid:e.pid,stopped:!1}):r.logger.error(`dev server (pid ${String(e.pid)}) survived the force-kill — record kept; retry \`lunora dev stop\` or kill the process manually.`),{code:1}),Gr=async e=>{const{cwd:r,logger:o}=e,t=I(r),n=e.alive??(m=>m===t?.pid&&ke(t)),s=e.signal??((m,l)=>{process.kill(m,l)}),i=e.pollIntervalMs??de,a=e.stopGraceMs??Er,c=e.platform??process.platform,u=e.spawnSyncImpl??N;if(t===void 0||!n(t.pid))return t!==void 0&&f(r,t.pid),e.json?v({running:!1,stopped:!1}):o.info("No dev server running."),{code:0};try{s(t.pid,"SIGTERM")}catch{}const p=Date.now()+a;for(;n(t.pid)&&Date.now()<p;)await E(i);return n(t.pid)&&(Fr(t,s,c,u),await E(i),n(t.pid))?Mr(t,e):(f(r,t.pid),e.json?v({pid:t.pid,stopped:!0}):o.success(`Stopped dev server (pid ${String(t.pid)}).`),{code:0})},Hr=e=>{const{cwd:r,logger:o}=e,t=y(r);if(t===void 0)return e.json?v({running:!1}):o.info("No dev server running."),{code:0};const n=e.now??Date.now,s=t.startedAt===void 0?Number.NaN:Date.parse(t.startedAt),i=Number.isFinite(s)?Math.max(0,Math.round((n()-s)/1e3)):void 0;if(e.json)return v({background:t.background===!0,logFile:t.logFile,mode:t.mode,pid:t.pid,running:!0,startedAt:t.startedAt,studioUrl:t.studioUrl,uptimeSeconds:i,url:t.url}),{code:0};const a=[`pid ${String(t.pid)}`,...i===void 0?[]:[`uptime ${String(i)}s`],t.background===!0?"background":"foreground"];return o.success(`Dev server running at ${t.url} (${a.join(", ")})`),t.studioUrl!==void 0&&o.info(` Studio: ${t.studioUrl}`),t.logFile!==void 0&&o.info(` Logs: lunora dev logs (${t.logFile})`),{code:0}},Ur=e=>{const{cwd:r,logger:o}=e,t=I(r),n=ue(r,t);if(!L(n))return o.info("No dev server logs found — output is captured when the server runs in background mode (`lunora dev --background`)."),{code:0};const s=le(n,e.lines??Nr);return s.length>0&&process.stdout.write(`${s.join(`
|
|
5
5
|
`)}
|
|
6
|
-
`),{code:0}},
|
|
7
|
-
`);i=c.pop()??"";for(const u of c)B(u.trimEnd(),r,s,
|
|
6
|
+
`),{code:0}},Vr=e=>{const{cwd:r,json:o,lines:t,logger:n,subcommand:s}=e;if(s==="stop")return Gr({cwd:r,json:o,logger:n});if(s==="status")return Hr({cwd:r,json:o,logger:n});if(s==="logs")return Ur({cwd:r,lines:t,logger:n});if(s!==void 0)return n.error(`dev: unknown subcommand "${s}" — expected stop | status | logs (or no subcommand to start the dev server)`),{code:1}},H="wrangler.dev.jsonc",U=6173,ge=8787,V=5173,Wr=5e3,qr=(e,r)=>{const o=()=>{};if(!e.remote)return{args:[],plan:{bindings:[],cleanup:o,enabled:!1}};const t=(e.materializeRemote??Ge)({enabled:!0,projectRoot:r}),n=t.remoteBindings.map(i=>`${i.binding} (${i.kind})`),{cleanup:s}=t;return t.configPath===void 0?{args:[],plan:{bindings:n,cleanup:s,enabled:!0,reason:t.reason}}:{args:["--config",t.configPath],plan:{bindings:n,cleanup:s,enabled:!0}}},W=e=>ne(e).parsed?.dev?.ip,q=(e,r,o)=>{if(o!==void 0){const n=k(e,o);if(L(n)&&W(n)!==void 0)return[]}const t=oe(e);return t!==void 0&&W(t)!==void 0?[]:r()?[]:["--ip","127.0.0.1"]},Br=async(e,r)=>{if(e.workerPort!==void 0)return e.workerPort;const o=oe(r);if(o!==void 0){const{parsed:t}=ne(o);if(typeof t?.dev?.port=="number")return t.dev.port}return(e.findFreePort??wr)(ge)},Jr=e=>{const r=e.cwd??process.cwd(),o=se(r),t=e.flavor??P(r);if(t==="vite"||t==="framework-worker"){const p=ce(r);let m;if(t==="framework-worker"){const l=q(r,e.hasIpv6Loopback??j,H),d=Ce(_e(r)).toolchain?.dev({configPath:H,extraArgs:[...l,"--var","WORKER_ENV:development"]}),g=$(o,d?.tool??"wrangler",d?.args??[]);m={args:g.args,command:g.command,cwd:r,tag:"worker"}}return{codegenEnabled:!1,flavor:t,ipv4LoopbackForced:!1,remote:{bindings:[],cleanup:()=>{},enabled:e.remote===!0},...m?{sidecar:m}:{},studioEnabled:!1,studioPort:e.port??U,workerOrigin:`http://localhost:${String(V)}`,workerPort:V,wrangler:{args:p.args,command:p.command,cwd:r,...e.remote===!0?{env:{LUNORA_REMOTE:"1"}}:{},tag:"vite"}}}const n=ee(r),s=n.framework==="none"?void 0:`this project uses ${n.framework} — the worker runs inside Vite there. run \`${qe(o,"dev")}\` for the full app (frontend + HMR); \`lunora dev\` starts only the worker.`,i=e.workerPort??ge,a=qr(e,r),c=q(r,e.hasIpv6Loopback??j),u=$(o,"wrangler",["dev","--port",String(i),...c,"--var","WORKER_ENV:development",...a.args]);return{codegenEnabled:e.codegen!==!1,flavor:t,frameworkHint:s,ipv4LoopbackForced:c.length>0,remote:a.plan,studioEnabled:e.studio!==!1,studioPort:e.port??U,workerOrigin:`http://localhost:${String(i)}`,workerPort:i,wrangler:{args:u.args,command:u.command,cwd:r,tag:"wrangler"}}},B=(e,r,o,t)=>{if(e.length===0)return;const n=Fe(e);if(n){t[n.level](`[lunora] ${n.text}`);return}const s=`[${r}] ${e}`;o==="stderr"?t.warn(s):t.info(s)},Kr=(e,r,o)=>{const t=(n,s)=>{if(!n)return;let i="";n.on("data",a=>{i+=a.toString("utf8");const c=i.split(`
|
|
7
|
+
`);i=c.pop()??"";for(const u of c)B(u.trimEnd(),r,s,o)}),n.on("end",()=>{B(i.trimEnd(),r,s,o),i=""})};t(e.stdout,"stdout"),t(e.stderr,"stderr")},zr=(e,r)=>{const o=ae(e.command,e.args),t=J(o.command,o.args,{cwd:e.cwd??process.cwd(),env:e.env?{...process.env,...e.env}:process.env,shell:o.shell,stdio:["inherit","pipe","pipe"]});return Kr(t,e.tag,r),{exited:new Promise(n=>{t.on("error",s=>{r.error(`[${e.tag}] failed to start: ${s.message}`),n(1)}),t.on("exit",s=>{n(s??0)})}),kill:n=>{try{t.kill(n)}catch{}}}},Yr=(e,r,o)=>{e.info(""),e.success("Lunora dev"),e.info(` ➜ Worker: ${r.workerOrigin}`),o!==void 0&&e.info(` ➜ Studio: ${o}`),r.codegenEnabled&&e.info(" ➜ Codegen: watching lunora/"),r.remote.enabled&&(r.remote.bindings.length>0?e.info(` ➜ Remote: ${r.remote.bindings.join(", ")} → deployed worker`):e.warn(` ➜ Remote: requested but inactive (${r.remote.reason??"no eligible bindings"}) — running fully local`)),e.info("")},Xr=(e,r)=>{Z(r).installed||!De()||(e.info(` ⓘ ${xe}`),e.info(""))},Zr=(e,r)=>{if(process.env.LUNORA_CONTAINER_LOGS==="0")return;const o=Ae(e,"lunora").containers.map(t=>({className:t.className,exportName:t.exportName}));if(o.length!==0)return je({containers:o,onLine:t=>{const n=`[container:${t.name}] ${t.text}`;t.level==="error"?r.warn(n):r.info(n)},onUnavailable:t=>{r.warn(`[container] Docker engine unreachable — container logs unavailable (${t})`)}})},Qr=async e=>{e.codegen?.close(),e.containerLogs?.close(),await e.studio?.close().catch(()=>{});try{e.remoteCleanup?.()}catch{}},et=async(e,r)=>{try{const o=await Ne({projectRoot:r}),t=Le(o),n=(e.ensureExample??Ie)(r,t);n.length>0&&e.logger.info(`Updated .dev.vars.example with secrets for: ${t.join(", ")} (${n.join(", ")})`)}catch{}(await(e.ensureEnv??Oe)({confirm:lr(),cwd:r,info:o=>{e.logger.info(o)}})).status==="declined"&&!Pe()&&e.logger.info(`hint: ${x} was not scaffolded (non-interactive run). Copy ${Re} → ${x} and fill in secrets, or run \`lunora dev\` in an interactive terminal to scaffold automatically.`);try{(e.fillSecrets??Te)({cwd:r,info:o=>{e.logger.info(o)}})}catch{}},rt=(e,r,o,t)=>{if(e.flavor!=="wrangler")return;t!==void 0&&te(r,{studioUrl:t});let n;try{n=Zr(r,o)}catch{}return Yr(o,e,t),n},tt=(e,r)=>{const o=Number(process.env[h]),t=Q(r,{background:process.env[O]==="1",logFile:process.env[re],mode:"cli",pid:process.pid,startedAt:new Date().toISOString(),url:e.workerOrigin},Number.isInteger(o)&&o>0?{supersedePid:o}:void 0);return t.ok?void 0:t.existing},ot=async e=>{const r=e.cwd??process.cwd(),o=e.flavor??P(r),t=o==="wrangler"?await Br(e,r):e.workerPort;return Jr({...e,cwd:r,flavor:o,workerPort:t})},nt=async(e,r,o)=>{let t=0,n;const s=p=>{e.kill(p),r?.kill(p)},i=()=>{t+=1,t===1?(o.info("received SIGINT — shutting down (press Ctrl-C again to force-kill)"),s("SIGTERM"),n=setTimeout(()=>{s("SIGKILL")},Wr),n.unref()):s("SIGKILL")},a=()=>{s("SIGTERM")};process.on("SIGINT",i),process.on("SIGTERM",a);const c=[e.exited.then(p=>({code:p,who:"worker"}))];r!==void 0&&c.push(r.exited.then(p=>({code:p,who:"sidecar"})));const u=await Promise.race(c);return r!==void 0&&(u.who==="sidecar"?(o.warn("[worker] the Lunora sidecar (wrangler dev) exited — shutting down the framework dev server"),e.kill("SIGTERM")):r.kill("SIGTERM"),await Promise.allSettled([e.exited,r.exited])),n&&clearTimeout(n),process.off("SIGINT",i),process.off("SIGTERM",a),u.code},st=async(e,r,o,t)=>{if(r.studioEnabled)try{return await(e.startStudio??br)({cwd:o,logger:{warnOnce:n=>{t.warn(n)}},port:r.studioPort,workerOrigin:r.workerOrigin})}catch(n){t.warn(`studio server failed to start (${n instanceof Error?n.message:String(n)}) — continuing without it`);return}},at=(e,r,o,t,n)=>{if(e.sidecar!==void 0)try{X({apiSpec:r.apiSpec,lunoraDirectory:"lunora",projectRoot:o,target:n})}catch(s){t.warn(`codegen (pre-sidecar) failed: ${s instanceof Error?s.message:String(s)} — the framework dev server will retry`)}},it=async e=>{const r=await ot(e),{logger:o}=e,t=r.wrangler.cwd??process.cwd(),n=Ee(t,e.target),s={remoteCleanup:r.remote.cleanup};try{const i=Number(process.env[h]),a=y(t);if(a!==void 0&&a.pid!==process.pid&&a.pid!==i)return S(o,a),{code:0,plan:r};const c=tt(r,t);if(c!==void 0)return S(o,c),{code:0,plan:r};(r.flavor==="vite"||r.flavor==="framework-worker")&&(r.wrangler.env={...r.wrangler.env,[h]:String(process.pid)}),await et(e,t),o.info(r.flavor==="vite"?"starting vite dev (worker + studio + codegen run inside Vite via @lunora/vite)":"starting wrangler dev + studio"),r.ipv4LoopbackForced&&o.info("no IPv6 loopback (::1) on this host — binding the worker to 127.0.0.1 (--ip) so wrangler dev doesn't crash. Pin `dev.ip` in wrangler.jsonc to override."),r.codegenEnabled&&(s.codegen=(e.startCodegen??gr)({apiSpec:e.apiSpec,logger:o,projectRoot:t,target:n})),s.studio=await st(e,r,t,o);const u=s.studio?.url;r.frameworkHint!==void 0&&o.warn(r.frameworkHint),at(r,e,t,o,n);const p=e.startWorker??zr,m=p(r.wrangler,o),l=r.sidecar===void 0?void 0:p(r.sidecar,o);return s.containerLogs=rt(r,t,o,u),Xr(o,t),{code:await nt(m,l,o),plan:r}}finally{f(t,process.pid),await Qr(s)}},It=We(async({argument:e,cwd:r,logger:o,options:t})=>{const n=t.json===!0,s=Vr({cwd:r,json:n,lines:t.lines,logger:o,subcommand:e[0]});if(s!==void 0)return s;const i=process.env[O]==="1",a=i?void 0:be(),c=n||a!==void 0;c&&Ke(),a!==void 0&&t.background!==!0&&o.info(`AI agent detected (${a.name} via ${a.variable}) — starting the dev server in background mode with JSON logs. Set LUNORA_AGENT_MODE=0 to opt out.`);const u=Me({configPreference:$e(r),envValue:process.env.LUNORA_REMOTE,flag:t.remote});if(!i&&(t.background===!0||a!==void 0)){const p=y(r);return p!==void 0?(S(o,p),{code:0}):Ar({cwd:r,jsonLogs:c,logger:o,options:t,remote:u})}return it({apiSpec:He(t.apiSpec),codegen:t.codegen===!1?!1:void 0,cwd:r,logger:o,port:t.port,remote:u,studio:t.studio===!1?!1:void 0,target:t.target,workerPort:t.workerPort})});export{P as detectDevFlavor,It as execute,Jr as planDevCommand,qr as resolveRemotePlan,Br as resolveWorkerPort,it as runDevCommand};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{runCodegen as
|
|
2
|
-
↳ ${
|
|
3
|
-
${
|
|
4
|
-
`)}`)}return e.cronTriggers.length>
|
|
1
|
+
import{runCodegen as u}from"@lunora/codegen";import{collectWranglerSecretVariables as f}from"@lunora/config/cloudflare";import{r as v}from"../packem_shared/api-spec-BENwiyUa.mjs";import{i as $}from"../packem_shared/command-Bjv4VmYA.mjs";import{i as w}from"../packem_shared/deploy-target-Dvr9vxpR.mjs";import{i as h,d as y,s as D,r as S}from"../packem_shared/output-format-D7cKB-O5.mjs";import{a as T}from"../packem_shared/platform-diagnostics-C4TFj5Pu.mjs";const l=3,C=r=>{const t=r.cwd??process.cwd(),i=S(r.format),a=D(r.format,r.logger),g=h("codegen",r.format);if(g!==void 0)return r.logger.error(g),{advisories:[],cronTriggers:[],error:g,outputDirectory:""};const s=w(t,r.target);if(s.target===void 0)return r.logger.error(s.error??"unknown deploy target"),{advisories:[],cronTriggers:[],error:s.error??"unknown deploy target",outputDirectory:""};const{target:m}=s,e=u({apiSpec:r.apiSpec,projectRoot:t,target:m,wranglerVariables:f(t)}),c={advisories:e.advisories.map(o=>({detail:o.detail,level:o.level,name:o.name,remediation:o.remediation})),cronTriggers:e.cronTriggers,outputDirectory:e.outputDirectory};if(a.success(`codegen wrote dataModel.ts, api.ts, server.ts to ${e.outputDirectory}`),e.advisories.length>0){const o=e.advisories.length,p=e.advisories.map(n=>` [${n.level}] ${n.name} — ${n.detail}
|
|
2
|
+
↳ ${n.remediation}`);a.warn(`${o.toString()} schema ${o===1?"advisory":"advisories"}:
|
|
3
|
+
${p.join(`
|
|
4
|
+
`)}`)}const d=T(e.platformDiagnostics,a);return d!==void 0&&(c.error=d),e.cronTriggers.length>l&&a.warn(`${e.cronTriggers.length.toString()} distinct cron expressions declared — Cloudflare allows at most ${l.toString()} Cron Triggers per Worker. Consolidate schedules (jobs can share one expression) or move finer-grained work to Durable Object alarms via @lunora/scheduler (runAfter/runAt).`),i&&y(c),c},M=$(({cwd:r,logger:t,options:i})=>({code:C({apiSpec:v(i.apiSpec),cwd:r,format:i.format,logger:t,target:i.target}).error===void 0?0:1}));export{M as execute,C as runCodegenCommand};
|