@lunora/cli 1.0.0-alpha.164 → 1.0.0-alpha.166
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 +0 -2
- package/dist/index.d.ts +0 -2
- package/dist/index.mjs +1 -1
- package/dist/packem_chunks/handler.mjs +1 -1
- package/dist/packem_chunks/handler10.mjs +2 -2
- package/dist/packem_chunks/handler11.mjs +2 -2
- package/dist/packem_chunks/handler12.mjs +1 -1
- package/dist/packem_chunks/handler13.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 +2 -2
- package/dist/packem_chunks/handler17.mjs +1 -1
- package/dist/packem_chunks/handler18.mjs +1 -1
- package/dist/packem_chunks/handler19.mjs +7 -7
- package/dist/packem_chunks/handler2.mjs +2 -2
- package/dist/packem_chunks/handler20.mjs +2 -2
- package/dist/packem_chunks/handler21.mjs +2 -2
- package/dist/packem_chunks/handler22.mjs +3 -3
- package/dist/packem_chunks/handler23.mjs +3 -3
- package/dist/packem_chunks/handler24.mjs +1 -1
- package/dist/packem_chunks/handler25.mjs +19 -19
- package/dist/packem_chunks/handler26.mjs +9 -9
- package/dist/packem_chunks/handler3.mjs +1 -1
- package/dist/packem_chunks/handler4.mjs +1 -1
- package/dist/packem_chunks/handler5.mjs +1 -1
- package/dist/packem_chunks/handler6.mjs +1 -1
- package/dist/packem_chunks/handler7.mjs +3 -3
- package/dist/packem_chunks/handler8.mjs +1 -1
- package/dist/packem_chunks/handler9.mjs +1 -1
- package/dist/packem_chunks/planDevCommand.mjs +6 -6
- package/dist/packem_chunks/runCodegenCommand.mjs +3 -3
- package/dist/packem_chunks/runDeployCommand.mjs +1 -1
- package/dist/packem_chunks/runInitCommand.mjs +46 -46
- package/dist/packem_chunks/runMigrateGenerateCommand.mjs +8 -8
- package/dist/packem_chunks/runResetCommand.mjs +1 -1
- package/dist/packem_chunks/runRpcCommand.mjs +1 -1
- package/dist/packem_shared/COMMANDS-BWf5k_qi.mjs +1 -0
- package/dist/packem_shared/DEFAULT_IMPORT_BATCH_SIZE-D5cNE-NH.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-ULexksQd.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-B-YnEi2t.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-CKvYE9YF.mjs → docker-DpVxvYpL.mjs} +1 -1
- package/dist/packem_shared/health-probe-QEPfFdgJ.mjs +1 -0
- package/dist/packem_shared/import-Db3Gk4mx.mjs +12 -0
- package/dist/packem_shared/insertSchemaExtension-DY4pA8wE.mjs +8 -0
- package/dist/packem_shared/lint-ignore-report-0sVOnXcO.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/resolve-DZAGzg67.mjs +1 -0
- package/dist/packem_shared/resolve-target-C_ZloTvd.mjs +1 -0
- package/dist/packem_shared/runAddCommand-BZty6_vX.mjs +1 -0
- package/dist/packem_shared/runExportCommand-DmXKEWSq.mjs +5 -0
- package/dist/packem_shared/{schema-drift-gate-d12lMICD.mjs → schema-drift-gate-AscQpYH5.mjs} +1 -1
- 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-Cs8ycNaL.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 +23 -22
- package/dist/packem_shared/COMMANDS-BJhEvtLN.mjs +0 -1
- package/dist/packem_shared/DEFAULT_IMPORT_BATCH_SIZE-D7L8R74L.mjs +0 -1
- package/dist/packem_shared/admin-token-BKmc3AUm.mjs +0 -1
- package/dist/packem_shared/admin-url-Ca-KI3d_.mjs +0 -1
- package/dist/packem_shared/advisory-gate-yaOOyUQl.mjs +0 -1
- package/dist/packem_shared/api-spec-BENwiyUa.mjs +0 -1
- package/dist/packem_shared/buildRegistryIndex-DwySASBu.mjs +0 -1
- package/dist/packem_shared/cli-Cu92injU.mjs +0 -3
- package/dist/packem_shared/codegen-error-DJN6pTH5.mjs +0 -3
- package/dist/packem_shared/command-0l-ZPhIX.mjs +0 -1
- package/dist/packem_shared/commands-DB63_8xW.mjs +0 -19
- package/dist/packem_shared/createLogger-BoSxdb2T.mjs +0 -2
- package/dist/packem_shared/createRecordingSpawner-SKs4R1fc.mjs +0 -1
- package/dist/packem_shared/deploy-target-Dvr9vxpR.mjs +0 -1
- package/dist/packem_shared/detect-package-manager-DXDstphE.mjs +0 -1
- package/dist/packem_shared/diffSnapshots-cgOtkd-G.mjs +0 -5
- package/dist/packem_shared/health-probe-CiFgh1hn.mjs +0 -1
- package/dist/packem_shared/import-C9in1wC3.mjs +0 -12
- package/dist/packem_shared/insertSchemaExtension-DZReBZ4_.mjs +0 -8
- package/dist/packem_shared/lint-ignore-report-m43j10IE.mjs +0 -2
- package/dist/packem_shared/open-url-zbbAo_D7.mjs +0 -1
- package/dist/packem_shared/output-format-Cv3aLqhP.mjs +0 -2
- package/dist/packem_shared/parseManifest-x3WsxKHz.mjs +0 -1
- package/dist/packem_shared/path-containment-CcTCKfzV.mjs +0 -1
- package/dist/packem_shared/platform-diagnostics-C4TFj5Pu.mjs +0 -4
- package/dist/packem_shared/post-codegen-hook-DhL1RH5u.mjs +0 -1
- package/dist/packem_shared/resolve-BZp6jitE.mjs +0 -1
- package/dist/packem_shared/resolve-target-CeiNrCAx.mjs +0 -1
- package/dist/packem_shared/runAddCommand-DiEQBX7C.mjs +0 -1
- package/dist/packem_shared/runExportCommand-BpE4AbuX.mjs +0 -5
- package/dist/packem_shared/schemaIrToSnapshot-DV2DilTz.mjs +0 -1
- package/dist/packem_shared/shared-Ce9bKz5c.mjs +0 -1
- package/dist/packem_shared/tui-prompts-BU3irGxV.mjs +0 -4
- package/dist/packem_shared/vectorize-metadata-BvZbbqUD.mjs +0 -1
- package/dist/packem_shared/wrangler-name-CHDf3rMP.mjs +0 -1
- package/dist/packem_shared/wrangler-secrets-D0Tv5GWn.mjs +0 -1
package/dist/bin.mjs
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import{
|
|
2
|
+
import{r as e}from"./packem_shared/cli-ULexksQd.mjs";try{const r=await e();process.exit(r)}catch(r){process.stderr.write(`${r instanceof Error?r.message:String(r)}
|
|
3
3
|
`),process.exit(1)}
|
package/dist/index.d.mts
CHANGED
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
import { CodegenOptions, Finding, SchemaIR } from '@lunora/codegen';
|
|
2
|
-
import '@visulima/cerebro';
|
|
3
2
|
import { ensureDevVariables, ensureDevVarsExample, fillDevSecrets, LintTool, LintIgnoreOutcome } from '@lunora/config';
|
|
4
|
-
import 'adm-zip';
|
|
5
3
|
import { materializeRemoteWranglerConfig } from '@lunora/config/cloudflare';
|
|
6
4
|
export { REQUIRED_COMPATIBILITY_DATE, REQUIRED_FLAG, type WranglerProjectValidationOptions as WranglerValidationOptions, type WranglerValidationReport, type WranglerProjectValidationResult as WranglerValidationResult, validateWranglerProject as validateWrangler, validateWranglerConfig } from '@lunora/config/cloudflare';
|
|
7
5
|
/** Every command name the CLI registers (drives the `CommandName` type + tests). */
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
import { CodegenOptions, Finding, SchemaIR } from '@lunora/codegen';
|
|
2
|
-
import '@visulima/cerebro';
|
|
3
2
|
import { ensureDevVariables, ensureDevVarsExample, fillDevSecrets, LintTool, LintIgnoreOutcome } from '@lunora/config';
|
|
4
|
-
import 'adm-zip';
|
|
5
3
|
import { materializeRemoteWranglerConfig } from '@lunora/config/cloudflare';
|
|
6
4
|
export { REQUIRED_COMPATIBILITY_DATE, REQUIRED_FLAG, type WranglerProjectValidationOptions as WranglerValidationOptions, type WranglerValidationReport, type WranglerProjectValidationResult as WranglerValidationResult, validateWranglerProject as validateWrangler, validateWranglerConfig } from '@lunora/config/cloudflare';
|
|
7
5
|
/** Every command name the CLI registers (drives the `CommandName` type + tests). */
|
package/dist/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{C as o,V as a,r as n}from"./packem_shared/cli-ULexksQd.mjs";import{runCodegenCommand as t}from"./packem_chunks/runCodegenCommand.mjs";import{runDeployCommand as p}from"./packem_chunks/runDeployCommand.mjs";import{planDevCommand as x,runDevCommand as i}from"./packem_chunks/planDevCommand.mjs";import{runInitCommand as s}from"./packem_chunks/runInitCommand.mjs";import{runMigrateGenerateCommand as u}from"./packem_chunks/runMigrateGenerateCommand.mjs";import{runResetCommand as g}from"./packem_chunks/runResetCommand.mjs";import{runRpcCommand as R}from"./packem_chunks/runRpcCommand.mjs";import{insertSchemaExtension as E}from"./packem_shared/insertSchemaExtension-DY4pA8wE.mjs";import{createLogger as A,pail as c}from"./packem_shared/createLogger-hGafwf-3.mjs";import{diffSnapshots as v,renderAddColumn as _,renderCreateIndex as b,renderCreateTable as h,renderDropIndex as y,renderDropTable as L,renderMigrationFile as O,validatorKindToSqlType as w}from"./packem_shared/diffSnapshots-CIOFQN_a.mjs";import{default as F}from"./packem_shared/schemaIrToSnapshot-qpRoV7HY.mjs";import{createRecordingSpawner as U,defaultSpawner as V}from"./packem_shared/createRecordingSpawner-DJlNacZ6.mjs";import{default as G}from"./packem_shared/parseManifest-CwPTKdtS.mjs";import{D as Q,r as j}from"./packem_shared/import-Db3Gk4mx.mjs";import{REQUIRED_COMPATIBILITY_DATE as H,REQUIRED_FLAG as K,validateWranglerProject as Y,validateWranglerConfig as Z}from"@lunora/config/cloudflare";import{buildRegistryIndex as z}from"./packem_shared/buildRegistryIndex-Zi3bBqpc.mjs";import{r as X,a as $,b as rr}from"./packem_shared/commands-B-YnEi2t.mjs";import{runExportCommand as or}from"./packem_shared/runExportCommand-DmXKEWSq.mjs";export{o as COMMANDS,Q as DEFAULT_IMPORT_BATCH_SIZE,H as REQUIRED_COMPATIBILITY_DATE,K as REQUIRED_FLAG,a as VERSION,z as buildRegistryIndex,A as createLogger,U as createRecordingSpawner,V as defaultSpawner,v as diffSnapshots,E as insertSchemaExtension,c as pail,G as parseManifest,x as planDevCommand,_ as renderAddColumn,b as renderCreateIndex,h as renderCreateTable,y as renderDropIndex,L as renderDropTable,O as renderMigrationFile,X as runAddCommand,$ as runBuildIndexCommand,n as runCli,t as runCodegenCommand,p as runDeployCommand,i as runDevCommand,or as runExportCommand,j as runImportCommand,s as runInitCommand,u as runMigrateGenerateCommand,rr as runRegistryViewCommand,g as runResetCommand,R as runRpcCommand,F as schemaIrToSnapshot,Y as validateWrangler,Z as validateWranglerConfig,w as validatorKindToSqlType};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{existsSync as
|
|
1
|
+
import{existsSync as k,readFileSync as T}from"node:fs";import{applyLintIgnores as N,detectLintTools as I}from"@lunora/config";import{findWranglerFile as A}from"@lunora/config/cloudflare";import{join as v,basename as g}from"@visulima/path";import{d as D}from"../packem_shared/command-DwC11Cwe.mjs";import{n as S,i as U,E as L,s as M,d as m,p as _,r as f,M as F,a as O,b as h,c as E,e as P,D as o,f as j,g as R,h as d,A as $,j as p,w as x,k as B,l as z}from"../packem_shared/lint-ignore-report-0sVOnXcO.mjs";import{v as H,l as C,i as J,p as W}from"../packem_shared/output-format-DfogXx0p.mjs";import{t as w,a as q}from"../packem_shared/tui-prompts-Dd0pDuNr.mjs";import{r as V}from"../packem_shared/commands-B-YnEi2t.mjs";const G=e=>{const r=e.trim().toLowerCase();return p.find(a=>a.value===r||a.label.toLowerCase()===r||r==="auth0"&&a.value==="auth-auth0"||r==="clerk"&&a.value==="auth-clerk")?.value},y=e=>{try{const r=JSON.parse(T(v(e,"package.json"),"utf8"));return{...r.dependencies,...r.devDependencies}}catch{return{}}},K=async e=>{const r=e.cwd??process.cwd(),t=R(y(r));return t!==void 0?t:e.yes===!0?(e.logger.warn(`add: couldn't detect your framework — using "${d}". Pass a specific item (e.g. \`lunora add auth-ui-vue\`) to override.`),d):await(e.promptSelect??((s,i,n)=>w(s,i,n)))("Which framework is your app?",$,{default:d})??d},Q=async e=>{if(e.provider!==void 0&&e.provider!==""){const t=G(e.provider);return t===void 0?(e.logger.warn(`add: unknown --provider "${e.provider}" — using "${o}" (email & password).`),o):t}if(e.yes===!0)return o;const r=e.promptSelect??((t,a,s)=>w(t,a,s));return j(r)},l=e=>e.promptText??((r,t)=>q(r,t)),X=async e=>{const r=g(e.cwd??process.cwd());if(e.bucket!==void 0&&e.bucket!==""){const t=M(e.bucket);if(t!==void 0)return t;const a=m(r);return e.logger.warn(`add: "${e.bucket}" isn't a valid R2 bucket name (lowercase alphanumeric + hyphens, 3–63 chars) — using "${a}".`),a}return e.yes===!0?m(r):_(l(e),r)},Y=async e=>{const r=t=>{e.logger.warn(`add: ${t}`)};if(e.mailTo!==void 0&&e.mailTo!=="")return f(e.mailTo,r);if(e.yes!==!0)return f(await l(e)(F,{placeholder:"you@yourdomain.com"}),r)},Z=async e=>{const r=g(e.cwd??process.cwd());if(e.db!==void 0&&e.db!==""){const t=O(e.db);if(t!==void 0)return t;const a=h(r);return e.logger.warn(`add: "${e.db}" isn't a usable D1 database name — using "${a}".`),a}return e.yes===!0?h(r):E(l(e),r)},ee=async(e,r)=>e.kind==="auth"?[await Q(r)]:e.kind==="auth-ui"?[await K(r)]:e.kind==="email"?[L]:[e.item],re=(e,r)=>{P(N(e,I(e)),r)},ae=async e=>{const r=e.cwd??process.cwd(),t=e.feature===void 0?void 0:S(e.feature);if(t===void 0)return e.logger.error("add requires a feature or registry item. Usage: lunora add <auth|email|storage|crons|presence|…>"),{code:1,items:[]};if(!k(v(r,"lunora"))||A(r)===void 0)return e.logger.error("add: not a Lunora project here (need a lunora/ directory and a wrangler.jsonc). Run `lunora init` first."),{code:1,items:[]};if(t.kind==="auth-ui"&&U(y(r)))return e.logger.error("add: auth-ui has no React Native port — the screens render DOM elements and a stylesheet, which Metro has nothing to mount. Build the screens with React Native primitives against the same better-auth client (`@lunora/react-native/auth`); `lunora add auth` still installs the server half."),{code:1,items:[]};const a=await ee(t,e),s=[];if(a.includes("storage")){const c=await X(e);s.push(u=>x(u,c))}if(a.includes("mail")){const c=await Y(e);c!==void 0&&s.push(u=>B(u,c))}if(a.some(c=>c==="auth"||c.startsWith("auth-"))){const c=await Z(e);s.push(u=>z(u,c))}const i=s.length>0?c=>{let u=c;for(const b of s)u=b(u);return u}:void 0,n=await V({allowUnsafeSource:e.allowUnsafeSource,cwd:r,from:e.from,logger:e.logger,names:[...a],ref:e.ref,source:e.source,transformManifest:i,yes:!0});return n.code===0&&re(r,e.logger),{code:n.code,items:a}},me=D(async({argument:e,cwd:r,logger:t,options:a})=>{const s=H("add",a.format);if(s!==void 0)return t.error(s),{code:1};const i=C(a.format,t),n=await ae({allowUnsafeSource:a.allowUnsafeSource===!0,bucket:a.bucket,cwd:r,db:a.db,feature:e[0],from:a.from,logger:i,mailTo:a.mailTo,provider:a.provider,ref:a.ref,source:a.source,yes:a.yes===!0});return J(a.format)&&W({code:n.code,items:n.items}),{code:n.code}});export{me as execute,ae as runAddFeature};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{readFileSync as
|
|
2
|
-
`):
|
|
1
|
+
import{readFileSync as d,existsSync as m}from"node:fs";import{join as u}from"node:path";import{discoverSchema as b}from"@lunora/codegen";import{readLinkedProject as y}from"@lunora/config";import{findWranglerFile as p}from"@lunora/config/cloudflare";import{parse as k}from"jsonc-parser";import{Project as v}from"ts-morph";import{d as j}from"../packem_shared/command-DwC11Cwe.mjs";const s=(e,n)=>{if(e===null||typeof e!="object")return;const i=e[n];return typeof i=="string"&&i.length>0?i:void 0},l=(e,n)=>{if(e===null||typeof e!="object")return[];const i=e[n];return Array.isArray(i)?i:[]},$=e=>{const n=l(e.durable_objects??{},"bindings"),i=l(e,"d1_databases"),c=l(e,"vectorize");return{bindings:{d1:i.map(r=>s(r,"binding")??"<unnamed>"),durableObjects:n.map(r=>s(r,"name")??"<unnamed>"),vectorize:c.map(r=>s(r,"binding")??"<unnamed>")},compatibilityDate:s(e,"compatibility_date"),compatibilityFlags:l(e,"compatibility_flags").filter(r=>typeof r=="string"),main:s(e,"main"),name:s(e,"name")}},w=e=>({tables:e.tables.map(n=>{let i="root";return n.shardMode==="global"?i="global":typeof n.shardMode=="object"&&(i=`shardBy(${n.shardMode.field})`),{indexes:n.indexes.length,name:n.name,shard:i}}),vectorIndexes:e.vectorIndexes.length}),h=e=>{const n=u(e,"package.json");if(!m(n))return[];let i;try{i=JSON.parse(d(n,"utf8"))}catch{return[]}if(i===null||typeof i!="object")return[];const c=["dependencies","devDependencies","peerDependencies","optionalDependencies"],r=new Map;for(const a of c){const t=i[a];if(!(t===null||typeof t!="object"))for(const[o,f]of Object.entries(t))o.startsWith("@lunora/")&&typeof f=="string"&&!r.has(o)&&r.set(o,f)}return[...r.entries()].toSorted(([a],[t])=>a.localeCompare(t)).map(([a,t])=>({name:a,version:t}))},x=e=>{const n=h(e),i=p(e);let c;if(i)try{c=$(k(d(i,"utf8")))}catch{c=void 0}const r=u(e,"lunora","schema.ts");let a,t;if(m(r))try{const o=new v({skipAddingFilesFromTsConfig:!0,useInMemoryFileSystem:!1});a=w(b(o,r))}catch(o){t=o instanceof Error?o.message:String(o)}return{link:y(e),lunoraPackages:n,projectRoot:e,schema:a,schemaError:t,wrangler:c,wranglerPath:i}},g=(e,n)=>{if(n.info(`project: ${e.projectRoot}`),n.info(""),n.info("@lunora/* packages:"),e.lunoraPackages.length===0)n.info(" (none found in package.json)");else for(const i of e.lunoraPackages)n.info(` ${i.name}@${i.version}`);if(n.info(""),e.wrangler?(n.info(`wrangler: ${e.wranglerPath??""}`),n.info(` name: ${e.wrangler.name??"<unset>"}`),n.info(` main: ${e.wrangler.main??"<unset>"}`),n.info(` compatibility_date: ${e.wrangler.compatibilityDate??"<unset>"}`),n.info(` compatibility_flags: ${e.wrangler.compatibilityFlags.join(", ")||"<none>"}`),n.info(` durable objects: ${e.wrangler.bindings.durableObjects.join(", ")||"<none>"}`),n.info(` d1 databases: ${e.wrangler.bindings.d1.join(", ")||"<none>"}`),n.info(` vectorize indexes: ${e.wrangler.bindings.vectorize.join(", ")||"<none>"}`)):n.info("wrangler: (not found)"),n.info(""),e.link?(n.info(`link: ${e.link.workerName??"(unnamed)"} -> ${e.link.workerUrl??"<no url>"}`),e.link.env!==void 0&&n.info(` env: ${e.link.env}`)):n.info("link: (not linked — run `lunora link --url <https://your-worker>`)"),n.info(""),e.schemaError!==void 0)n.warn(`schema: parse error — ${e.schemaError}`);else if(e.schema){n.info(`schema: ${String(e.schema.tables.length)} table(s), ${String(e.schema.vectorIndexes)} vector index(es)`);for(const i of e.schema.tables)n.info(` ${i.name} [${i.shard}, ${String(i.indexes)} index(es)]`)}else n.info("schema: (no lunora/schema.ts)")},S=e=>{const n=e.cwd??process.cwd(),i=x(n);return e.json?process.stdout.write(`${JSON.stringify(i,void 0,2)}
|
|
2
|
+
`):g(i,e.logger),{code:0,snapshot:i}},E=j(({cwd:e,logger:n,options:i})=>S({cwd:e,json:i.json===!0,logger:n}));export{x as collectInfo,E as execute,S as runInfoCommand};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{
|
|
2
|
-
`)},O=
|
|
1
|
+
import{r as $}from"../packem_shared/admin-url-Cil3Or6N.mjs";import{d as p}from"../packem_shared/command-DwC11Cwe.mjs";import{a as S}from"../packem_shared/resolve-target-C_ZloTvd.mjs";const v="__lunora_admin__:getFunctionStats",M=10,d=(r,o)=>({calls:r.calls,conflicts:r.conflicts??0,errors:r.errors,lastErrorMessage:r.lastErrorMessage,maxDurationMs:r.maxDurationMs,meanDurationMs:r.calls===0?0:r.totalDurationMs/r.calls,path:r.path,rate:o}),y=(r,o)=>{const e=r.filter(t=>(t.conflicts??0)>0).map(t=>d(t,t.calls===0?0:(t.conflicts??0)/t.calls)).toSorted((t,n)=>n.rate-t.rate||n.conflicts-t.conflicts).slice(0,o),s=r.filter(t=>t.errors>0).map(t=>d(t,t.calls===0?0:t.errors/t.calls)).toSorted((t,n)=>n.rate-t.rate||n.errors-t.errors).slice(0,o),l=r.map(t=>d(t,0)).toSorted((t,n)=>n.maxDurationMs-t.maxDurationMs).slice(0,o);return{errorHotspots:s,latencyOutliers:l,totalFunctions:r.length,writeContention:e}},f=r=>`${(r*100).toFixed(1)}%`,h=r=>r<1e3?`${Math.round(r).toString()}ms`:`${(r/1e3).toFixed(2)}s`,u=(r,o,e,s)=>[r,...o.length===0?[` ${e}`]:o.map(l=>` ${s(l)}`)],N=r=>{const o=e=>e.lastErrorMessage?` — ${e.lastErrorMessage}`:"";return[`Insights over ${r.totalFunctions.toString()} function${r.totalFunctions===1?"":"s"}`,"",...u("Write-conflict hot-spots (OCC contention — candidates for sharding):",r.writeContention,"none — no write conflicts observed",e=>`${e.path} ${e.conflicts.toString()}/${e.calls.toString()} calls (${f(e.rate)})`),"",...u("Error hot-spots:",r.errorHotspots,"none — no errors observed",e=>`${e.path} ${e.errors.toString()}/${e.calls.toString()} calls (${f(e.rate)})${o(e)}`),"",...u("Latency outliers (slowest single call):",r.latencyOutliers,"none — no functions have run",e=>`${e.path} max ${h(e.maxDurationMs)}, mean ${h(e.meanDurationMs)} over ${e.calls.toString()} calls`)].join(`
|
|
2
|
+
`)},O=r=>r===void 0||!Number.isFinite(r)||r<=0?M:Math.floor(r),T=async r=>{if(r.prod&&r.url===void 0)return r.logger.error("--prod requires an explicit --url (refusing to report from the implicit localhost worker)"),{code:1};const o=r.token??process.env.LUNORA_ADMIN_TOKEN;if(!o)return r.logger.error("admin token required — pass --token or set LUNORA_ADMIN_TOKEN"),{code:1};const e=$(r.url,r.logger,r.cwd);if(e===void 0)return{code:1};const s=`${e}/_lunora/rpc`,l=globalThis.fetch;if(typeof l!="function")throw new TypeError("no fetch implementation available — pass fetchImpl or run on Node >= 18");const t={args:{},functionPath:v};r.shard!==void 0&&(t.shardKey=r.shard),r.logger.info(`POST ${s} -> insights`);const n=await l(s,{body:JSON.stringify(t),headers:{authorization:`Bearer ${o}`,"content-type":"application/json"},method:"POST"}),a=await n.text();if(!n.ok)return r.logger.error(`insights failed: HTTP ${String(n.status)}: ${a}`),{code:1};let i;try{i=JSON.parse(a)}catch{return r.logger.error(`insights failed: worker returned non-JSON: ${a}`),{code:1}}const m=i.result??i,{functions:g}=m;if(!Array.isArray(g))return r.logger.error("insights failed: response carried no `functions` array"),{code:1};const c=y(g,O(r.limit));return r.logger.info(r.json?JSON.stringify(c,void 0,2):N(c)),{code:0,report:c}},D=p(({cwd:r,logger:o,options:e})=>{const s=e.limit===void 0?void 0:Number.parseInt(e.limit,10);return T({cwd:r,fetchImpl:void 0,json:e.json,limit:s,logger:o,prod:e.prod,shard:e.shard,token:e.token,url:S({cwd:r,prod:e.prod===!0,url:e.url})})});export{y as buildInsightsReport,D as execute,N as formatInsightsReport,T as runInsightsCommand};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{existsSync as
|
|
1
|
+
import{existsSync as u,rmSync as m}from"node:fs";import{join as a}from"node:path";import{writeLinkedProject as d,LINKED_PROJECT_FILE as o}from"@lunora/config";import{d as i}from"../packem_shared/command-DwC11Cwe.mjs";import{r as k}from"../packem_shared/wrangler-name-Dsk5K1f-.mjs";const s=r=>{try{const{protocol:n}=new URL(r);return n==="http:"||n==="https:"}catch{return!1}},v=(r,n)=>{const e=a(r,o);return u(e)?(m(e),n.success(`link: removed ${o}`),{code:0}):(n.warn(`link: no ${o} to remove`),{code:0})},w=r=>{const n=r.cwd??process.cwd(),{logger:e}=r;if(r.remove)return v(n,e);if(r.url===void 0||r.url==="")return e.error("link requires a deployed Worker URL. Usage: lunora link --url <https://your-worker>"),{code:1};if(!s(r.url))return e.error(`link: invalid --url "${r.url}" — expected an http(s) URL`),{code:1};const c=r.now??(()=>new Date().toISOString()),t={env:r.env,linkedAt:c(),workerName:r.name??k(n),workerUrl:r.url},l=d(n,t);return e.success(`link: ${t.workerName??"(unnamed worker)"} -> ${r.url}`),e.info(`link: wrote ${l}`),t.env!==void 0&&e.info(`link: environment "${t.env}"`),{code:0,link:t}},y=i(({cwd:r,logger:n,options:e})=>w({cwd:r,env:e.env,logger:n,name:e.name,remove:e.remove===!0,url:e.url}));export{y as execute,w as runLinkCommand};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{runCodegen as g}from"@lunora/codegen";import{resolveTargetOrThrow as d,resolveDeployDriver as
|
|
1
|
+
import{runCodegen as g}from"@lunora/codegen";import{resolveTargetOrThrow as d,resolveDeployDriver as m}from"@lunora/config";import{p as f}from"../packem_shared/api-spec-lYyq4vL6.mjs";import{r as p}from"../packem_shared/codegen-error-C04fGQjf.mjs";import{d as u}from"../packem_shared/command-DwC11Cwe.mjs";import{r as h}from"../packem_shared/platform-diagnostics-uOXqysk3.mjs";import{r as w}from"../packem_shared/post-codegen-hook-DRdEoTsQ.mjs";import{r as v}from"../packem_shared/schema-drift-gate-AscQpYH5.mjs";import{validateWranglerProject as S}from"@lunora/config/cloudflare";const b=async(e,o,a=[],c)=>{const i={crons:a,projectRoot:e},n=m(c);try{const r=await n.infer(i),s=[r.shardNamespaces.length>0?`${String(r.shardNamespaces.length)} shard namespace(s)`:void 0,r.queues.length>0?`${String(r.queues.length)} queue(s)`:void 0,r.workflows.length>0?`${String(r.workflows.length)} workflow(s)`:void 0,r.containers.length>0?`${String(r.containers.length)} container(s)`:void 0,r.globalDatabase?"global database":void 0,r.objectStorage?"object storage":void 0,r.keyValueStore?"key-value store":void 0].filter(l=>l!==void 0);s.length>0&&o.info(`${n.name} target requires: ${s.join(", ")}`)}catch{}const t=await n.provision(i);t.changed&&o.success(`provisioned: ${t.added.join(", ")} → ${t.configPath??"wrangler.jsonc"}`);for(const r of t.warnings)o.warn(r)},j=async e=>{const o=e.cwd??process.cwd(),a=d(o,e.target);e.logger.info("running codegen");let c;try{c=g({apiSpec:e.apiSpec,projectRoot:o,target:a}),e.logger.success("codegen complete"),h(c.platformDiagnostics,e.logger)}catch(r){const s=r instanceof Error?r.message:String(r);return e.logger.error(p(r)),{code:1,error:`codegen failed: ${s}`,validation:{problems:[],wranglerPath:void 0}}}const i=await w({cwd:o,logger:e.logger,spawner:e.spawner});if(i.error!==void 0)return e.logger.error(i.error),{code:1,error:i.error,validation:{problems:[],wranglerPath:void 0}};const n=v({allowDrift:e.allowSchemaDrift===!0,codegen:c,command:"prepare",logger:e.logger,updateBaseline:e.updateSchemaBaseline===!0});if(n.blocked)return{code:1,error:"schema drift gate blocked prepare",schemaDrift:{blocked:!0,reason:n.reason},validation:{problems:[],wranglerPath:void 0}};await b(o,e.logger,c.cronTriggers,a);const t=S({projectRoot:o});if(t.problems.length>0){e.logger.error("wrangler.jsonc validation failed:");for(const r of t.problems)e.logger.error(` - ${r}`);return{code:1,error:"wrangler validation failed",validation:t}}return n.rebless?.(),e.logger.success("project is ready to deploy"),{code:0,validation:t}},R=u(({cwd:e,logger:o,options:a})=>j({allowSchemaDrift:a.allowSchemaDrift===!0,apiSpec:f(a.apiSpec),cwd:e,logger:o,target:a.target,updateSchemaBaseline:a.updateSchemaBaseline===!0}));export{R as execute,j as runPrepareCommand};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{d as c}from"../packem_shared/command-DwC11Cwe.mjs";import{r as d,b as s,a as n}from"../packem_shared/commands-B-YnEi2t.mjs";const w=c(({argument:a,cwd:u,logger:e,options:r})=>{const f=a[0],m=a.slice(1);return f==="add"?d({allowUnsafeSource:r.allowUnsafeSource===!0,cwd:u,diff:r.diff===!0,dryRun:r.dryRun===!0,from:r.from,json:r.json===!0,logger:e,names:m,overwrite:r.overwrite===!0,ref:r.ref,source:r.source,yes:r.yes===!0}):f==="list"?d({cwd:u,from:r.from,json:r.json===!0,list:!0,logger:e,names:[],ref:r.ref,source:r.source}):f==="view"?s({allowUnsafeSource:r.allowUnsafeSource===!0,cwd:u,from:r.from,logger:e,names:m,ref:r.ref,source:r.source}):f==="build"?n({check:r.check===!0,cwd:u,from:r.from,logger:e,names:[],out:r.out}):(e.error("registry: unknown subcommand. Usage: lunora registry <add|list|view|build> [names…]"),{code:1})});export{w as execute};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{existsSync as c,readFileSync as g,readdirSync as
|
|
1
|
+
import{existsSync as c,readFileSync as g,readdirSync as f,statSync as k,mkdirSync as w,writeFileSync as y}from"node:fs";import{fileURLToPath as R}from"node:url";import{AGENT_RULES_DIR as u,detectAgentRules as v,LUNORA_SKILL_NAMES as L}from"@lunora/config";import{join as i,relative as A,resolve as $,dirname as d}from"@visulima/path";import{d as b}from"../packem_shared/command-DwC11Cwe.mjs";const I=(e=d(R(import.meta.url)))=>{let r=e;for(let n=0;n<6;n+=1){const t=i(r,"package.json");if(c(t))try{if(JSON.parse(g(t,"utf8")).name==="@lunora/cli"){const l=i(r,"skills");return c(l)?l:void 0}}catch{}const s=d(r);if(s===r)break;r=s}},j=e=>f(e).filter(r=>{const n=i(e,r);return k(n).isDirectory()&&c(i(n,"SKILL.md"))}),m=(e,r,n)=>{w(r,{recursive:!0});let t=!1;for(const s of f(e)){const o=i(e,s),l=i(r,s);if(k(o).isDirectory()){t=m(o,l,n)||t;continue}c(l)&&!n||(y(l,g(o)),t=!0)}return t},_=["pnpm-workspace.yaml","pnpm-lock.yaml","yarn.lock","package-lock.json","bun.lock","bun.lockb",".git"],x=e=>{let r=e;for(;;){if(_.some(t=>c(i(r,t))))return r;const n=d(r);if(n===r)return e;r=n}},p=(e,r)=>r===void 0?x(e):$(e,r),E=e=>{const r=e.cwd??process.cwd(),n=p(r,e.dir),t=e.overwrite===!0,s=I();if(s===void 0)return e.logger.error("rules: could not locate the bundled skills (is @lunora/cli installed correctly?)."),{code:1,installed:[],skipped:[]};const o=[],l=[];for(const a of j(s)){const S=i(n,u,a);m(i(s,a),S,t)?o.push(a):l.push(a)}const h=A(r,i(n,u))||u;return o.length>0&&e.logger.success(`Installed ${String(o.length)} Lunora skill(s) into ${h}/: ${o.join(", ")}.`),l.length>0&&e.logger.info(`Skipped ${String(l.length)} existing skill(s) (re-run with --overwrite to replace): ${l.join(", ")}.`),e.logger.info("Your AI coding agent will pick these up automatically. Start with the `lunora` skill."),{code:0,installed:o,skipped:l}},O=e=>{const r=e.cwd??process.cwd(),n=p(r,e.dir),t=v(n);return t.installed?(e.logger.success(`Lunora agent rules are installed (${String(t.present.length)}/${String(L.length)} skills).`),t.missing.length>0&&e.logger.info(`Missing: ${t.missing.join(", ")}. Run \`lunora rules install\` to add them.`),{code:0,installed:t.present,skipped:[]}):(e.logger.warn("Lunora agent rules are not installed. Run `lunora rules install` so your AI agent knows how to use Lunora."),{code:e.strict===!0?1:0,installed:t.present,skipped:[]})},T=b(({argument:e,cwd:r,logger:n,options:t})=>{const s=e[0]??"check";return s==="install"?E({cwd:r,dir:t.dir,logger:n,overwrite:t.overwrite===!0}):s==="check"?O({cwd:r,dir:t.dir,logger:n,strict:t.strict===!0}):(n.error("rules: unknown subcommand. Usage: lunora rules <install|check>"),{code:1})});export{T as execute,I as resolveBundledSkillsDirectory,O as runRulesCheck,E as runRulesInstall};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import{existsSync as
|
|
1
|
+
import{existsSync as S}from"node:fs";import{mkdtemp as k,writeFile as v,rm as R}from"node:fs/promises";import{tmpdir as T}from"node:os";import{discoverSchema as $,schemaFromIr as j}from"@lunora/codegen";import{seedPlan as C}from"@lunora/seed";import{join as m}from"@visulima/path";import{Project as F}from"ts-morph";import{i as x}from"../packem_shared/admin-token-rxXZbVMZ.mjs";import{d as z}from"../packem_shared/command-DwC11Cwe.mjs";import{a as I}from"../packem_shared/resolve-target-C_ZloTvd.mjs";import{b as A}from"../packem_shared/tui-prompts-Dd0pDuNr.mjs";import{runResetCommand as P}from"./runResetCommand.mjs";import{r as U}from"../packem_shared/import-Db3Gk4mx.mjs";const b=e=>e===""?!1:x(e),L=(e,r)=>typeof r=="bigint"?Number(r):r instanceof ArrayBuffer?[...new Uint8Array(r)]:r,l=e=>({code:e,conflicts:0,generated:0,inserted:0,ndjson:""}),N=(e,r)=>{if(!S(r))return e.logger.error(`schema not found: ${r} — run \`vis generate lunora-table --name=<name>\` to create one`),l(1);if(e.reset===!0&&(e.prod===!0||!b(e.url)))return e.logger.error("--reset only clears local .wrangler/state and cannot be combined with --prod or a remote --url"),l(1)},_=async(e,r,t,n)=>{const i=await k(m(T(),"lunora-seed-")),s=m(i,"rows.ndjson");await v(s,e,"utf8");try{const o=await U({batchSize:n.batchSize,cwd:t,fetchImpl:n.fetchImpl,file:s,logger:n.logger,prod:n.prod,token:n.token,url:n.url}),d=o.body?.conflicts??0;return d>0&&n.logger.warn(`${String(d)} row(s) skipped — their _id already exists. Seeding is deterministic; re-run with --reset to wipe local state first, or a different --seed for fresh ids.`),{code:o.code,conflicts:d,generated:r,inserted:o.inserted,ndjson:e}}finally{await R(i,{force:!0,recursive:!0}).catch(()=>{})}},B=(e,r)=>{if(e.table===void 0||r.tables.some(n=>n.name===e.table))return;const t=r.tables.map(n=>n.name).join(", ");return e.logger.error(`unknown table "${e.table}" — schema defines: ${t||"(no tables)"}`),l(1)},D=async(e,r)=>{if(!(e.prod===!0||!b(e.url))||e.yes===!0)return;if(!process.stdin.isTTY&&e.confirm===void 0)return e.logger.error("seed: refusing to insert into a non-local target without confirmation — re-run with --yes"),l(1);if(!await(e.confirm??A)(`This will insert ${String(r)} generated row(s) into ${e.url??"the production worker"}. Continue?`))return e.logger.info("seed: aborted"),l(1)},H=async e=>{const r=e.cwd??process.cwd(),t=m(r,"lunora","schema.ts"),n=N(e,t);if(n!==void 0)return n;const i=new F({skipAddingFilesFromTsConfig:!0}),s=$(i,t),o=B(e,s);if(o!==void 0)return o;const d=j(s),g=C(d,{defaultCount:e.count??10,now:e.now,only:e.table===void 0?void 0:[e.table],seed:e.seed??0}),u=[];for(const{rows:f,table:h}of g)for(const y of f)u.push(JSON.stringify({doc:y,table:h},L));const a=u.length>0?`${u.join(`
|
|
2
2
|
`)}
|
|
3
|
-
`:"",
|
|
3
|
+
`:"",c=u.length;if(e.dryRun===!0)return a.length>0&&process.stdout.write(a),e.logger.info(`generated ${String(c)} row(s) across ${String(g.length)} table(s) — dry run, nothing inserted`),{code:0,conflicts:0,generated:c,inserted:0,ndjson:a};if(e.reset===!0){const f=await P({cwd:r,logger:e.logger,yes:!0});if(f.code!==0)return{code:f.code,conflicts:0,generated:c,inserted:0,ndjson:a}}if(c===0)return e.logger.warn("no rows generated — nothing to insert"),{code:0,conflicts:0,generated:0,inserted:0,ndjson:a};const w=await D(e,c);return w!==void 0?w:_(a,c,r,e)},p=z(async({cwd:e,logger:r,options:t})=>({code:(await H({batchSize:t.batchSize,count:t.count,cwd:e,dryRun:t.dryRun===!0,logger:r,prod:t.prod===!0,reset:t.reset===!0,now:t.now,seed:t.seed,table:t.table,token:t.token,url:I({cwd:e,prod:t.prod===!0,url:t.url}),yes:t.yes===!0})).code}));export{p as execute,H as runSeedCommand};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{existsSync as
|
|
1
|
+
import{existsSync as p}from"node:fs";import{join as h}from"node:path";import{runCodegen as u}from"@lunora/codegen";import{p as g}from"../packem_shared/api-spec-lYyq4vL6.mjs";import{a as v}from"../packem_shared/codegen-error-C04fGQjf.mjs";import{d as y}from"../packem_shared/command-DwC11Cwe.mjs";import{r as w}from"../packem_shared/deploy-target-D9GPy_tq.mjs";import{e as S,d as k}from"../packem_shared/detect-package-manager-DSaAqRof.mjs";import{p as j}from"../packem_shared/health-probe-QEPfFdgJ.mjs";import{v as b,i as x,p as E,l as F}from"../packem_shared/output-format-DfogXx0p.mjs";import{r as U}from"../packem_shared/schema-drift-gate-AscQpYH5.mjs";import{defaultSpawner as D}from"../packem_shared/createRecordingSpawner-DJlNacZ6.mjs";import{validateWranglerProject as R}from"@lunora/config/cloudflare";const $=async(r,t)=>{if(!p(h(r,"tsconfig.json")))return{warning:"no tsconfig.json found — skipping TypeScript type-check"};const e=S(k(r),"tsc",["--noEmit","-p","tsconfig.json"]),a=await t({args:e.args,command:e.command,cwd:r});return a.code===0?{}:{error:`type errors: tsc --noEmit exited ${String(a.code)}`}},H=async(r,t)=>{if(r.healthUrl===void 0||r.healthUrl==="")return;const e=await j({baseUrl:r.healthUrl,fetchImpl:r.healthFetch});if(e.error===void 0){t.success(`verify: health probe ok (${e.url})`);return}return e.error},T=(r,t,e,a)=>{if(t.length===0&&e.length===0)return r.success("verify: project is valid"),{code:0,errors:[],warnings:[],wranglerPath:a};if(e.length>0){r.warn("verify: warnings:");for(const c of e)r.warn(` - ${c}`)}if(t.length>0){r.error("verify: errors:");for(const c of t){r.error(` - ${c}`);const n=v(c);n!==void 0&&r.error(n)}return{code:1,errors:t,warnings:e,wranglerPath:a}}return r.success("verify: project is valid (with warnings)"),{code:0,errors:[],warnings:e,wranglerPath:a}},C=async r=>{const t=r.cwd??process.cwd(),e=F(r.format,r.logger),a=b("verify",r.format);if(a!==void 0)return r.logger.error(a),{code:1,error:a,errors:[],warnings:[],wranglerPath:void 0};const c=R({projectRoot:t}),n=[...c.report.errors],f=[...c.report.warnings];try{const o=w(t,r.target);if(o.target===void 0){const i=o.error??"unknown deploy target";return e.error(i),{code:1,error:i,errors:[i],warnings:[],wranglerPath:void 0}}const s=u({apiSpec:r.apiSpec,dryRun:!0,projectRoot:t,target:o.target}),l=U({allowDrift:r.allowSchemaDrift===!0,codegen:s,command:"verify",logger:e,readOnly:!0});l.blocked&&n.push(l.reason)}catch(o){const s=o instanceof Error?o.message:String(o);n.push(`codegen failed: ${s}`)}if(r.typecheck!==!1){const o=await $(t,r.spawner??D);o.error!==void 0&&n.push(o.error),o.warning!==void 0&&f.push(o.warning)}const m=await H(r,e);m!==void 0&&n.push(m);const d=T(e,n,f,c.wranglerPath);return x(r.format)&&E(d),d},L=y(async({cwd:r,logger:t,options:e})=>({code:(await C({allowSchemaDrift:e.allowSchemaDrift===!0,apiSpec:g(e.apiSpec),cwd:r,format:e.format,healthUrl:e.healthUrl,logger:t,target:e.target,typecheck:e.typecheck===!1?!1:void 0})).code}));export{L as execute,C as runVerifyCommand};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{readFileSync as
|
|
1
|
+
import{readFileSync as l,existsSync as u}from"node:fs";import{join as a}from"node:path";import{parse as d}from"jsonc-parser";import{d as m}from"../packem_shared/command-DwC11Cwe.mjs";import{o as p}from"../packem_shared/open-url-EnKy--w-.mjs";const c=8787,s="/_lunora/studio",g=r=>{for(const t of["wrangler.jsonc","wrangler.json"]){const e=a(r,t);if(u(e))return e}},v=r=>{const t=g(r);if(t)try{const e=d(l(t,"utf8"));return e!==null&&typeof e=="object"?e:void 0}catch{return}},y=r=>{if(!r)return c;const{dev:t}=r;if(t!==null&&typeof t=="object"){const{port:e}=t;if(typeof e=="number"&&Number.isFinite(e))return e}return c},h=r=>{if(!r)return;const{routes:t}=r;if(Array.isArray(t)&&t.length>0){const n=t[0];if(typeof n=="string")return`https://${n.split("/")[0]??n}${s}`;if(n!==null&&typeof n=="object"){const{pattern:o}=n;if(typeof o=="string"&&o.length>0)return`https://${o.split("/")[0]??o}${s}`}}const{name:e}=r;if(typeof e=="string"&&e.length>0)return`https://${e}.workers.dev${s}`},$=async r=>{const t=r.cwd??process.cwd(),e=v(t),{logger:n}=r;let o;if(r.remote){if(o=h(e),!o)return n.error("view --remote: could not determine the remote URL from wrangler config (set `routes` or `name`)."),{code:1,url:void 0}}else o=`http://localhost:${String(y(e))}${s}`;n.info(`opening ${o}`);try{await p(o,{opener:r.opener})}catch(i){const f=i instanceof Error?i.message:String(i);return n.error(`view: failed to open URL: ${f}`),{code:1,url:o}}return{code:0,url:o}},A=m(({cwd:r,logger:t,options:e})=>$({cwd:r,logger:t,remote:e.remote===!0}));export{A as execute,$ as runViewCommand};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import{writeFileSync as h,existsSync as
|
|
2
|
-
`)},
|
|
3
|
-
`)},
|
|
4
|
-
`)}const
|
|
5
|
-
`);
|
|
6
|
-
`)},
|
|
7
|
-
`,"utf8"),
|
|
1
|
+
import{writeFileSync as h,existsSync as S,readFileSync as b}from"node:fs";import{isAbsolute as w,join as p}from"node:path";import{byCodepoint as y,scoreAdvisor as x,parseAdvisorMap as j,compareToBaseline as A}from"@lunora/advisor";import{runCodegen as F}from"@lunora/codegen";import{d as M}from"../packem_shared/command-DwC11Cwe.mjs";import{v as R,p as D,l as k,i as E}from"../packem_shared/output-format-DfogXx0p.mjs";import{D as f}from"../packem_shared/cli-ULexksQd.mjs";const l={clean:"·",exempt:"–",failing:"✗",warned:"!"},u=(e,r)=>e.length>=r?e:e+" ".repeat(r-e.length),B=e=>`${e.id} (${e.visibility} ${e.kind})`,g=e=>{let r=0;for(const n of e)r=Math.max(r,n.id.length);return r},m=(e,r)=>` ${u(String(e.score),3)} ${l[e.coverage]} ${u(e.id,r)} ${e.visibility} ${e.kind}`,T=e=>{if(!e.comparable)return[` baseline not comparable (${e.reason}) — regenerate it; this run cannot verify anything`];if(!e.regressed)return[` no regression against baseline (score ${e.scoreDelta>=0?"+":""}${String(e.scoreDelta)})`];const r=[` REGRESSED against baseline (score ${e.scoreDelta>=0?"+":""}${String(e.scoreDelta)})`];for(const n of e.dropped)r.push(` ${n.id}: ${String(n.before)} → ${String(n.after)}`);for(const n of e.newFailing)r.push(` ${n}: now failing`);for(const n of e.worsened)r.push(` ${n}: more findings than the baseline`);return e.projectRegressed&&r.push(" project: new schema/config rules fired"),r},C=(e,r)=>{const n=e.procedures.filter(i=>i.coverage!=="clean"&&i.coverage!=="exempt"),o=g(n),t=[`advisor health ${String(e.score)}/100 — ${e.grade}`,` ${String(e.summary.clean)} clean · ${String(e.summary.warned)} warned · ${String(e.summary.failing)} failing · ${String(e.summary.exempt)} exempt (${String(e.summary.procedures)} procedures, ${String(e.summary.rulesFired)} rules fired)`];return e.project.checks.length>0&&t.push("",` project ${String(e.project.score)}/100 — ${e.project.checks.map(i=>i.name).join(", ")}`),n.length>0&&t.push("",...n.map(i=>m(i,o)),""," run with --all for every procedure, or --entry <file#export> for one"),r!==void 0&&t.push("",...T(r)),t.join(`
|
|
2
|
+
`)},J=e=>e.coverage==="exempt"?[` exempt: ${e.exemptReason===void 0||e.exemptReason===""?"no reason given":e.exemptReason}`]:e.checks.map(r=>{const n=r.occurrences>1?`, ×${String(r.occurrences)}`:"";return` ${r.name} (−${String(r.weight)}${n})`}),L=e=>{const r=new Map;for(const n of e){const o=r.get(n.file);o===void 0?r.set(n.file,[n]):o.push(n)}return[...r].toSorted(([n],[o])=>y(n,o))},N=e=>{const r=g(e.procedures),n=[`advisor health ${String(e.score)}/100 — ${e.grade}`,"",` legend: ${l.clean} clean ${l.warned} warned ${l.failing} failing ${l.exempt} exempt`];for(const[o,t]of L(e.procedures)){n.push("",` ${o}`);for(const i of t)n.push(m(i,r),...J(i))}return n.join(`
|
|
3
|
+
`)},P=(e,r)=>{const n=e.procedures.find(t=>t.id===r);if(n===void 0){const t=e.procedures.slice(0,10).map(i=>` ${i.id}`);return[`no procedure ${r} in the map. Known ids:`,...t,e.procedures.length>10?" …":""].filter(Boolean).join(`
|
|
4
|
+
`)}const o=[`${B(n)} — ${String(n.score)}/100, ${n.coverage}`,` weight in the global mean: ${String(n.weight)}`];if(n.checks.length===0)return o.push(""," no rule fired"),o.join(`
|
|
5
|
+
`);o.push(""," rules fired:");for(const t of n.checks)o.push(` [${t.level}] ${t.name} −${String(t.weight)}${t.occurrences>1?` (×${String(t.occurrences)})`:""}`);return o.join(`
|
|
6
|
+
`)},I=new Date(0).toISOString(),$=(e,r)=>w(r)?r:p(e,r),_=e=>{if(e===void 0)return{value:void 0};if(e===null||e==="")return{error:"--min-score needs a value between 0 and 100"};const r=Number(e);return Number.isFinite(r)&&r>=0&&r<=100?{value:r}:{error:"--min-score must be a number between 0 and 100"}},H=(e,r,n)=>{const o=$(r,n===null||n===""?f:n);if(!S(o))return{error:`baseline not found at ${o} — generate one with \`lunora advisor\` and commit it`};const t=j(JSON.parse(b(o,"utf8")));return t===void 0?{error:`baseline at ${o} is malformed — regenerate it with \`lunora advisor\``}:{comparison:A(e,t)}},K=e=>`baseline is not comparable (${e}) — regenerate it; this run verified nothing`,O=(e,r,n)=>r.entry!==void 0?P(e,r.entry):r.all===!0?N(e):C(e,n),q=e=>{const r=e.cwd??process.cwd(),n=E(e.format),o=k(e.format,e.logger),t=R("advisor",e.format);if(t!==void 0)return e.logger.error(t),{error:t};const i=_(e.minScore);if("error"in i)return e.logger.error(i.error),{error:i.error};const{advisorContext:d,advisories:v}=F({dryRun:!0,projectRoot:r});if(d===void 0){const s="advisor evidence unavailable — codegen ran with linting disabled";return e.logger.error(s),{error:s}}const a=x(d.procedureProtections??[],v,{generatedAt:e.generatedAt??I}),c={map:a};if(e.baseline!==void 0){const s=H(a,r,e.baseline);if("error"in s)return e.logger.error(s.error),{...c,error:s.error};c.comparison=s.comparison,s.comparison.comparable||e.logger.error(K(s.comparison.reason))}if(e.write!==!1){const s=$(r,e.out??f);h(s,`${JSON.stringify(a,void 0,4)}
|
|
7
|
+
`,"utf8"),c.written=s}return c.belowMinScore=i.value!==void 0&&a.score<i.value,c.belowMinScore&&o.error(`advisor score ${String(a.score)} is below the required ${String(i.value)}`),n?(D(c),c):(o.info(O(a,e,c.comparison)),c.written!==void 0&&o.success(`wrote ${c.written}`),c)},G=e=>e.error!==void 0||e.belowMinScore===!0?!0:e.comparison!==void 0&&(!e.comparison.comparable||e.comparison.regressed),Z=M(({cwd:e,logger:r,options:n})=>{const o=q({all:n.all,baseline:n.baseline,cwd:e,entry:n.entry,format:n.format,logger:r,minScore:n.minScore,out:n.out,write:n.write});return{code:G(o)?1:0}});export{Z as execute,q as runAdvisorCommand};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{mkdtempSync as
|
|
2
|
-
`):
|
|
1
|
+
import{mkdtempSync as u,rmSync as d,existsSync as l,readdirSync as y,statSync as m}from"node:fs";import{tmpdir as p}from"node:os";import{join as f,relative as $}from"node:path";import{d as S}from"../packem_shared/command-DwC11Cwe.mjs";import{e as g,d as w}from"../packem_shared/detect-package-manager-DSaAqRof.mjs";import{defaultSpawner as z}from"../packem_shared/createRecordingSpawner-DJlNacZ6.mjs";const B=e=>{const t=[],r=n=>{for(const i of y(n)){const s=f(n,i),o=m(s);o.isDirectory()?r(s):o.isFile()&&t.push({path:$(e,s),sizeBytes:o.size})}};return r(e),t},c=e=>e<1024?`${String(e)} B`:e<1024*1024?`${(e/1024).toFixed(1)} KiB`:`${(e/(1024*1024)).toFixed(2)} MiB`,F=e=>{const t=B(e),r=t.toSorted((s,o)=>o.sizeBytes-s.sizeBytes),n=t.reduce((s,o)=>s+o.sizeBytes,0);return{generatedFiles:t.filter(s=>s.path.includes("_generated")),outdir:e,topModules:r.slice(0,10),totalBytes:n,totalFiles:t.length}},h=(e,t)=>{if(t.info(`outdir: ${e.outdir}`),t.info(`total: ${String(e.totalFiles)} files, ${c(e.totalBytes)}`),e.topModules.length>0){t.info(""),t.info("top modules by size:");for(const r of e.topModules)t.info(` ${c(r.sizeBytes).padStart(10," ")} ${r.path}`)}if(e.generatedFiles.length>0){t.info(""),t.info(`_generated/ files: ${String(e.generatedFiles.length)}`);for(const r of e.generatedFiles)t.info(` ${c(r.sizeBytes).padStart(10," ")} ${r.path}`)}},x=async e=>{const t=e.cwd??process.cwd(),{logger:r}=e;let n,i,s=!1;if(e.inspectOnly)n=e.inspectOnly;else{n=u(f(p(),"lunora-analyze-")),s=!0;const o=g(w(t),"wrangler",["deploy","--dry-run","--outdir",n]);i={args:o.args,command:o.command,cwd:t},r.info(`analyze: building via ${i.command} ${i.args.join(" ")}`);const a=await(e.spawner??z)(i);if(a.code!==0)return r.error(`analyze: wrangler dry-run failed (exit ${String(a.code)})`),d(n,{force:!0,recursive:!0}),{code:a.code,descriptor:i,report:void 0}}try{if(!l(n))return r.error(`analyze: outdir not found at ${n}`),{code:1,descriptor:i,report:void 0};const o=F(n);return e.json?process.stdout.write(`${JSON.stringify(o,void 0,2)}
|
|
2
|
+
`):h(o,r),{code:0,descriptor:i,report:o}}finally{if(s&&l(n))try{d(n,{force:!0,recursive:!0})}catch{}}},C=S(({cwd:e,logger:t,options:r})=>x({cwd:e,json:r.json===!0,logger:t}));export{C as execute,x as runAnalyzeCommand};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{readdirSync as
|
|
2
|
-
`,"utf8"),r.success(`binding manifest written to ${
|
|
1
|
+
import{readdirSync as u,readFileSync as m,mkdirSync as f,writeFileSync as g}from"node:fs";import{join as p,resolve as l,isAbsolute as w,dirname as y}from"node:path";import{findWranglerFile as b,readWranglerJsonc as h,buildBindingManifest as v}from"@lunora/config/cloudflare";import{p as S}from"../packem_shared/api-spec-lYyq4vL6.mjs";import{d as B}from"../packem_shared/command-DwC11Cwe.mjs";import{v as F,l as $,i as D,p as k}from"../packem_shared/output-format-DfogXx0p.mjs";import{defaultSpawner as z}from"../packem_shared/createRecordingSpawner-DJlNacZ6.mjs";import{runDeployCommand as M}from"./runDeployCommand.mjs";import{gzipSync as A}from"node:zlib";const T=e=>!e.endsWith(".map")&&e!=="bundle-meta.json"&&e!=="README.md",W=e=>{let n;try{n=u(e,{recursive:!0,withFileTypes:!0})}catch{return}let r=0,i=0,s=0;for(const t of n){if(!t.isFile()||!T(t.name))continue;const o=m(p(t.parentPath,t.name));r+=1,s+=o.byteLength,i+=A(o).byteLength}return r===0?void 0:{files:r,gzipBytes:i,rawBytes:s}},E=".lunora/build",J=async e=>z({...e,stdoutToStderr:!0}),c=e=>`${(e/1024).toFixed(1)} KiB`,O=(e,n,r)=>{const i=b(e),s=i===void 0?void 0:h(i).parsed;if(s===void 0)return{error:`--emit-bindings found no readable wrangler config in ${e}. The manifest is derived from it, and an empty one would tell a deployer this Worker needs nothing.`};const t=v(s),o=w(n)?n:l(e,n);return f(y(o),{recursive:!0}),g(o,`${JSON.stringify(t,void 0,2)}
|
|
2
|
+
`,"utf8"),r.success(`binding manifest written to ${o} (${t.bindings.length.toString()} bindings, ${t.crons.length.toString()} crons)`),t.unknown.length>0&&r.warn(`binding manifest does not model these wrangler sections: ${t.unknown.join(", ")}. Anything they bind must be provisioned by hand — please report them so the manifest can cover them.`),{}},P=async e=>{const n=e.outDir??E,r=D(e.format),i=$(e.format,e.logger),s=a=>(r&&k(a),a),t=F("build",e.format);if(t!==void 0)return e.logger.error(t),{code:1,descriptor:void 0,error:t,validation:{problems:[],wranglerPath:void 0}};const o=await M({apiSpec:e.apiSpec,cwd:e.cwd,dryRun:!0,format:void 0,interactive:r?!1:void 0,logger:i,outDir:n,spawner:e.spawner??(r?J:void 0),target:e.target});if(o.code!==0)return s(o);i.success(`build complete — bundle written to ${n}`);const d=W(l(e.cwd??process.cwd(),n));if(d===void 0?i.warn(`could not weigh the bundle — nothing uploadable was found in ${n}`):i.info(`bundle: ${c(d.rawBytes)} raw, ${c(d.gzipBytes)} gzipped across ${String(d.files)} file(s) — Cloudflare's Worker size limit (3 MB Free, 10 MB Paid) applies to the gzipped number`),e.emitBindings!==void 0){const{error:a}=O(e.cwd??process.cwd(),e.emitBindings,i);if(a!==void 0)return i.error(a),s({...o,bundle:d,code:1})}return s({...o,bundle:d})},N=B(async({cwd:e,logger:n,options:r})=>({code:(await P({apiSpec:S(r.apiSpec),cwd:e,emitBindings:r.emitBindings,format:r.format,logger:n,outDir:r.outDir,target:r.target})).code}));export{N as execute,P as runBuildCommand};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{readLinkedProject as g,resolveDeployDriver as
|
|
2
|
-
`);return
|
|
1
|
+
import{readLinkedProject as g,resolveDeployDriver as v}from"@lunora/config";import{d as h}from"../packem_shared/command-DwC11Cwe.mjs";import{e as y,d as b}from"../packem_shared/detect-package-manager-DSaAqRof.mjs";import{defaultSpawner as w}from"../packem_shared/createRecordingSpawner-DJlNacZ6.mjs";import{createR2Sql as L}from"@lunora/bindings/r2sql";import{createPipelineLogReader as S}from"@lunora/runtime";const _=new Set(["debug","error","fatal","info","log","trace","warn"]),m=/^\d+$/,d=(e,t)=>{if(e===void 0)return;const a=e.trim();if(m.test(a))return Number(a);const r=Date.parse(a);if(Number.isNaN(r))throw new TypeError(`logs: invalid ${t} "${e}" — pass epoch-millis or an ISO 8601 date`);return r},T=e=>Buffer.from(JSON.stringify(e),"utf8").toString("base64url"),C=e=>{const t=e.trim();if(m.test(t))return{ts:Number(t)};let a;try{a=JSON.parse(Buffer.from(t,"base64url").toString("utf8"))}catch{throw new TypeError(`logs: invalid --cursor "${e}" — expected the token printed by the previous page (or a bare epoch-millis ts)`)}if(typeof a!="object"||a===null||typeof a.ts!="number"||!Number.isFinite(a.ts))throw new TypeError(`logs: invalid --cursor "${e}" — expected the token printed by the previous page (or a bare epoch-millis ts)`);const{ts:r}=a,s=a.seen,n=Array.isArray(s)?s.filter(i=>typeof i=="string"):void 0;return n!==void 0&&n.length>0?{seen:n,ts:r}:{ts:r}},u=(e,t)=>{if(e!==void 0){if(!_.has(e))throw new TypeError(`logs: invalid ${t} "${e}" — expected one of trace, debug, log, info, warn, error, fatal`);return e}},I=e=>{const t={},a=d(e.since,"--since");a!==void 0&&(t.sinceTs=a);const r=d(e.until,"--until");r!==void 0&&(t.untilTs=r);const s=u(e.level,"--level");s!==void 0&&(t.level=s);const n=u(e.minLevel,"--min-level");if(n!==void 0&&(t.minLevel=n),e.functionPrefix!==void 0&&(t.functionPathPrefix=e.functionPrefix),e.traceId!==void 0&&(t.traceId=e.traceId),e.shardKey!==void 0&&(t.shardKey=e.shardKey),e.userId!==void 0&&(t.userId=e.userId),e.limit!==void 0){const i=Number(e.limit);if(!Number.isFinite(i))throw new TypeError(`logs: invalid --limit "${e.limit}" — expected a number`);t.limit=i}return e.cursor!==void 0&&(t.cursor=C(e.cursor)),t},$=e=>{const t=new Date(e.ts).toISOString(),a=e.level.toUpperCase().padEnd(5);return`${t} ${a} ${e.functionPath} ${e.message}`},p=async e=>{const t=e.environment??process.env,a=t.R2_SQL_ACCOUNT_ID,r=t.R2_SQL_TOKEN,s=t.R2_SQL_BUCKET,n=[];if((a===void 0||a.length===0)&&n.push("R2_SQL_ACCOUNT_ID"),(r===void 0||r.length===0)&&n.push("R2_SQL_TOKEN"),(s===void 0||s.length===0)&&n.push("R2_SQL_BUCKET"),(e.table===void 0||e.table.length===0)&&n.push("--table"),n.length>0)return e.logger.error(`logs --durable: R2 SQL not configured (missing ${n.join(", ")}). The Pipeline must write to an R2 Data Catalog (Iceberg) table, and you must supply R2_SQL_ACCOUNT_ID / R2_SQL_TOKEN / R2_SQL_BUCKET plus --table — see the observability docs.`),{code:1,error:"not configured"};let i;try{i=I(e)}catch(o){return e.logger.error(o instanceof Error?o.message:String(o)),{code:1,error:"invalid option"}}const l=L({accountId:a,apiToken:r,bucket:s,fetch:e.fetch}),c=await S(l,{namespace:e.namespace,table:e.table}).query(i);for(const o of c.rows)process.stdout.write(`${e.ndjson===!0?JSON.stringify(o):$(o)}
|
|
2
|
+
`);return c.rows.length===0?e.logger.info("logs --durable: no matching log records"):c.nextCursor!==void 0&&e.logger.info(`logs --durable: more rows available — pass --cursor ${T(c.nextCursor)} for the next page`),{code:0,rows:c.rows}},x=new Set(["json","pretty"]),E=async e=>{const t=e.cwd??process.cwd();if(e.format!==void 0&&!x.has(e.format))return e.logger.error(`logs: unknown --format "${e.format}" — expected pretty | json`),{code:1,descriptor:void 0,error:"invalid format"};const a=e.env??g(t)?.env,r=v(e.target);if(r.toolchain===void 0)return e.logger.error(`logs: deploy target "${r.id}" has no command-line toolchain`),{code:1,descriptor:void 0,error:"no toolchain"};const s=r.toolchain.tail({environment:a,format:e.format,search:e.search,status:e.status,temporary:e.temporary,worker:e.worker}),n=y(b(t),s.tool,s.args),i={args:n.args,command:n.command,cwd:t};return e.logger.info(`tailing logs via ${i.command} ${i.args.join(" ")}`),{code:(await(e.spawner??w)(i)).code,descriptor:i}},k=h(({argument:e,cwd:t,logger:a,options:r})=>r.durable===!0?p({cursor:r.cursor,functionPrefix:r.functionPrefix,level:r.level,limit:r.limit,logger:a,minLevel:r.minLevel,namespace:r.namespace,ndjson:r.ndjson===!0,shardKey:r.shardKey,since:r.since,table:r.table,traceId:r.traceId,until:r.until,userId:r.userId}):E({cwd:t,env:r.env,format:r.format,logger:a,search:r.search,status:r.status,target:r.target,temporary:r.temporary===!0,worker:e[0]}));export{k as execute,E as runLogsCommand};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import{writeFileSync as
|
|
2
|
-
`)[0]??i.message:String(i);
|
|
3
|
-
`,"utf8")},Y=f("lunora","_generated","openrpc.json"),Z=r=>{if(!
|
|
1
|
+
import{writeFileSync as E,existsSync as y,cpSync as C,statSync as b,readdirSync as F,mkdirSync as D,readFileSync as L}from"node:fs";import{join as f,sep as j,resolve as O,dirname as I}from"node:path";import{SDK_TARGETS as M,SDK_LANGUAGES as x,generateSdk as B,isTypedSchema as K}from"@lunora/codegen";import{LunoraError as l}from"@lunora/errors";import{d as V}from"../packem_shared/command-DwC11Cwe.mjs";import{r as _,a as U,b as G,c as P,s as Q}from"../packem_shared/resolve-DZAGzg67.mjs";const S="gh:anolilab/lunora/sdks",v="lunora-transport.json",J=/_test\.|Tests?\./u,q=r=>r.startsWith("test_")||J.test(r),N=(r,s="")=>F(r).toSorted((e,t)=>e.localeCompare(t)).flatMap(e=>{const t=f(r,e),a=s.length>0?`${s}/${e}`:e;return b(t).isDirectory()?N(t,a):[a]}),A=(r,s,e,t)=>{const a=f(r,e);if(!y(a))throw new l("NOT_FOUND",`transport is missing ${e}`);const n=f(s,t);return C(a,n,{filter:o=>!q(o.slice(o.lastIndexOf(j)+1)),force:!0,recursive:!0}),b(n).isDirectory()?N(n).map(o=>`${t}/${o}`):[t]},k=(r,s)=>s.vendor.every(e=>y(f(r,e.from))),H=async(r,s)=>{const{language:e,logger:t,outputDirectory:a,registryOptions:n,target:o}=s,{cleanup:u,directory:h}=await P(e,{...n,ref:r},S);try{if(!k(h,o)){t.warn(`${S}/${e} does not exist at ${r}.`);return}return{files:o.vendor.flatMap(c=>A(h,a,c.from,c.to)).toSorted((c,d)=>c.localeCompare(d)),ref:r,source:`${S}/${e}`,versionMatched:r===_()}}finally{u()}},W=(r,s)=>{const{language:e,outputDirectory:t,target:a}=s,n=f(r,e);if(!y(n))throw new l("NOT_FOUND",`no transport at ${n} — --from must point at a directory of per-language transports (the repo's \`sdks/\`)`);if(!k(n,a)){const o=a.vendor.map(u=>u.from).join(", ");throw new l("NOT_FOUND",`${n} is not a ${e} transport — expected it to contain ${o}`)}return{files:a.vendor.flatMap(o=>A(n,t,o.from,o.to)).toSorted((o,u)=>o.localeCompare(u)),ref:"local",source:n,versionMatched:!1}},X=async r=>{const{allowUnsafeSource:s,from:e,language:t,logger:a,outputDirectory:n,ref:o,source:u,target:h}=r;if(e!==void 0)return W(e,{language:t,outputDirectory:n,target:h});const c={allowUnsafeSource:s,logger:a,names:[],source:u},d=async i=>H(await G(i,a),{language:t,logger:a,outputDirectory:n,registryOptions:c,target:h});if(o!==void 0&&o.length>0){const i=await d(o);if(i===void 0)throw new l("NOT_FOUND",`--ref ${o} carries no ${t} transport — pick a ref that does, or pass --from <dir> to copy a local one`);return i}const m=_(),g=await d(m).catch(i=>{const w=i instanceof Error?i.message.split(`
|
|
2
|
+
`)[0]??i.message:String(i);a.warn(`could not fetch the transport at ${m} (${w}).`)});if(g!==void 0)return g;const p=await d(void 0);if(p===void 0)throw new l("NOT_FOUND",`no ${t} transport at ${m} or on the release branch. This language may not be released yet — pass --from <dir> to copy one from a checkout, or --ref <tag> to name a ref that has it.`);return a.warn(`FALLBACK: the transport is NOT version-matched to this CLI (${U()}). Wanted ${m}, used ${p.ref}. The vendored wire protocol may not be the one this surface was generated against; ${v} records what was actually copied.`),p},z=(r,s,e)=>{const t={cliVersion:U(),files:e.files,language:s,note:e.versionMatched?"Vendored by `lunora sdk generate` at the ref matching the CLI that generated the surface beside it. Regenerate with a newer CLI to upgrade.":"Vendored by `lunora sdk generate` from a ref that is NOT this CLI's release tag, so the transport and the generated surface may be different protocol vintages.",ref:e.ref,source:e.source,versionMatched:e.versionMatched};E(f(r,v),`${JSON.stringify(t,void 0,4)}
|
|
3
|
+
`,"utf8")},Y=f("lunora","_generated","openrpc.json"),Z=r=>{if(!y(r))throw new l("NOT_FOUND",`no OpenRPC document at ${r} — run \`lunora codegen --api-spec openrpc\` (or \`--api-spec both\`) first, or pass --spec`);let s;try{s=JSON.parse(L(r,"utf8"))}catch(e){throw new l("BAD_REQUEST",`${r} is not valid JSON: ${e instanceof Error?e.message:String(e)}`)}if(s===null||typeof s!="object"||!Array.isArray(s.methods))throw new l("BAD_REQUEST",`${r} is not an OpenRPC document (no \`methods\` array)`);return s},ae=V(async({argument:r,cwd:s,logger:e,options:t})=>{const a=r[0]??"generate";if(a!=="generate")throw new l("BAD_REQUEST",`unknown subcommand "${a}" — the only one is \`lunora sdk generate\``);const n=t.lang??"python",o=M[n];if(o===void 0)throw new l("BAD_REQUEST",`unsupported --lang "${n}" — expected one of: ${x.join(" | ")}`);const u=Q("sdk generate",{allowUnsafeSource:t.allowUnsafeSource,logger:e,names:[],source:t.source});if(u!==void 0)throw new l("BAD_REQUEST",u);const h=O(s,t.spec??Y),c=O(s,t.out??f("sdk",n)),d=Z(h);d.methods.length===0&&e.warn(`${h} declares no methods — writing an empty SDK.`);const{files:m,undeclared:g,unrepresentable:p}=await B(d,o);D(c,{recursive:!0});const i=await X({allowUnsafeSource:t.allowUnsafeSource,from:t.from,language:n,logger:e,outputDirectory:c,ref:t.ref,source:t.source,target:o});z(c,n,i);for(const[$,R]of Object.entries(m)){const T=f(c,$);D(I(T),{recursive:!0}),E(T,R,"utf8")}const w=d.methods.filter($=>!K($.result?.schema)).length;return e.success(`Generated ${n} SDK for ${String(d.methods.length)} function(s) → ${c}`),e.info(`Vendored the ${n} transport (${String(i.files.length)} file(s)) from ${i.source} @ ${i.ref}${i.versionMatched?" — version-matched to this CLI":""}; see ${v}.`),e.info(o.requires.length>0?`Install in the consuming project: ${o.requires.join(", ")}.`:"Nothing to install — the transport is vendored and needs only the standard library."),g.length>0&&e.warn(`${String(g.length)} schema(s) are not expressible as a named ${n} model, so those arguments or returns stay untyped: ${g.join(", ")}`),p.length>0&&e.warn(`${String(p.length)} function(s) take or return a \`v.bigint()\`/\`v.bytes()\`, which no generated model can carry — their parameters stay untyped, so pass wire values directly: ${p.join(", ")}`),w>0&&e.warn(`${String(w)} of ${String(d.methods.length)} function(s) return an untyped result — declare \`.output()\` on them for typed returns.`),{code:0}});export{ae as execute};
|