@lunora/cli 1.0.0-alpha.171 → 1.0.0-alpha.172
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/index.mjs +1 -1
- package/dist/packem_chunks/handler.mjs +1 -1
- package/dist/packem_chunks/handler14.mjs +1 -1
- package/dist/packem_chunks/runInitCommand.mjs +1 -1
- package/dist/packem_shared/commands-BOgN2nF7.mjs +19 -0
- package/dist/packem_shared/{lint-ignore-report-0sVOnXcO.mjs → lint-ignore-report-BZjT7jyY.mjs} +1 -1
- package/dist/packem_shared/{runAddCommand-BZty6_vX.mjs → runAddCommand-BXz-PXbb.mjs} +1 -1
- package/package.json +9 -9
- package/dist/packem_shared/commands-B-YnEi2t.mjs +0 -19
package/dist/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{C as o,V as a,r as n}from"./packem_shared/cli-oqj4ysM9.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-
|
|
1
|
+
import{C as o,V as a,r as n}from"./packem_shared/cli-oqj4ysM9.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-BOgN2nF7.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 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-
|
|
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-BZjT7jyY.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-BOgN2nF7.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 +1 @@
|
|
|
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-
|
|
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-BOgN2nF7.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,4 +1,4 @@
|
|
|
1
|
-
import{existsSync as m,mkdirSync as M,writeFileSync as v,readFileSync as b,readdirSync as re,rmSync as $,mkdtempSync as oe,cpSync as G,renameSync as Re,lstatSync as Oe}from"node:fs";import{tmpdir as se}from"node:os";import{detectFramework as Te,isInteractive as g,LUNA_ART as Pe,LUNA_NAME as De,LUNA_SIGNOFF as Be,BADGES as f,paintAnswer as je,detectLintTools as Ve,applyLintIgnores as Ue}from"@lunora/config";import{walkSync as Fe}from"@visulima/fs";import{join as u,dirname as A,basename as E,resolve as ne,relative as He}from"@visulima/path";import{downloadTemplate as ie}from"giget";import{modify as We,applyEdits as ze}from"jsonc-parser";import{join as V,dirname as qe}from"node:path";import{i as le,e as Ke,d as U,c as Ge,b as Je,a as Ye}from"../packem_shared/detect-package-manager-DSaAqRof.mjs";import{d as Xe}from"../packem_shared/command-DwC11Cwe.mjs";import Qe from"magic-string";import{Project as Ze,SyntaxKind as w}from"ts-morph";import{P as F}from"../packem_shared/prompt-cancelled-C8Sj7OqI.mjs";import{h as ce,d as de,i as ue,b as et}from"../packem_shared/resolve-DZAGzg67.mjs";import{defaultSpawner as pe}from"../packem_shared/createRecordingSpawner-DJlNacZ6.mjs";import{d as tt,e as at,f as rt,a as he,t as H,g as me,h as ot,b as fe,i as ve,w as st,j as nt,k as ge,l as it}from"../packem_shared/tui-prompts-Dd0pDuNr.mjs";import{E as we,p as lt,w as ct,M as dt,r as ut,k as pt,f as ht,c as ye,l as be,e as mt,g as ft}from"../packem_shared/lint-ignore-report-
|
|
1
|
+
import{existsSync as m,mkdirSync as M,writeFileSync as v,readFileSync as b,readdirSync as re,rmSync as $,mkdtempSync as oe,cpSync as G,renameSync as Re,lstatSync as Oe}from"node:fs";import{tmpdir as se}from"node:os";import{detectFramework as Te,isInteractive as g,LUNA_ART as Pe,LUNA_NAME as De,LUNA_SIGNOFF as Be,BADGES as f,paintAnswer as je,detectLintTools as Ve,applyLintIgnores as Ue}from"@lunora/config";import{walkSync as Fe}from"@visulima/fs";import{join as u,dirname as A,basename as E,resolve as ne,relative as He}from"@visulima/path";import{downloadTemplate as ie}from"giget";import{modify as We,applyEdits as ze}from"jsonc-parser";import{join as V,dirname as qe}from"node:path";import{i as le,e as Ke,d as U,c as Ge,b as Je,a as Ye}from"../packem_shared/detect-package-manager-DSaAqRof.mjs";import{d as Xe}from"../packem_shared/command-DwC11Cwe.mjs";import Qe from"magic-string";import{Project as Ze,SyntaxKind as w}from"ts-morph";import{P as F}from"../packem_shared/prompt-cancelled-C8Sj7OqI.mjs";import{h as ce,d as de,i as ue,b as et}from"../packem_shared/resolve-DZAGzg67.mjs";import{defaultSpawner as pe}from"../packem_shared/createRecordingSpawner-DJlNacZ6.mjs";import{d as tt,e as at,f as rt,a as he,t as H,g as me,h as ot,b as fe,i as ve,w as st,j as nt,k as ge,l as it}from"../packem_shared/tui-prompts-Dd0pDuNr.mjs";import{E as we,p as lt,w as ct,M as dt,r as ut,k as pt,f as ht,c as ye,l as be,e as mt,g as ft}from"../packem_shared/lint-ignore-report-BZjT7jyY.mjs";import{logStep as J}from"../packem_shared/createLogger-hGafwf-3.mjs";import vt from"node:dns/promises";import{r as gt}from"../packem_shared/commands-BOgN2nF7.mjs";const W={bun:{githubCacheKey:void 0,githubSetupStep:` - uses: oven-sh/setup-bun@v2
|
|
2
2
|
`,gitlabImage:"oven/bun:1",gitlabProvisionScript:[],installCmd:"bun install --frozen-lockfile",lockfile:"bun.lockb"},npm:{githubCacheKey:"npm",githubSetupStep:"",gitlabImage:"node:22",gitlabProvisionScript:[],installCmd:"npm ci",lockfile:"package-lock.json"},pnpm:{githubCacheKey:"pnpm",githubSetupStep:` - uses: pnpm/action-setup@v4
|
|
3
3
|
`,gitlabImage:"node:22",gitlabProvisionScript:["corepack enable"],installCmd:"pnpm install --frozen-lockfile",lockfile:"pnpm-lock.yaml"},yarn:{githubCacheKey:"yarn",githubSetupStep:"",gitlabImage:"node:22",gitlabProvisionScript:["corepack enable"],installCmd:"yarn install --frozen-lockfile",lockfile:"yarn.lock"}},C=(e,t)=>{const a=Ke(e,"lunora",t);return[a.command,...a.args].join(" ")},Y=e=>` - uses: actions/checkout@v4
|
|
4
4
|
${e.githubSetupStep} - uses: actions/setup-node@v4
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import{existsSync as m,readFileSync as h,writeFileSync as $,mkdirSync as S,lstatSync as q}from"node:fs";import{join as l,relative as J,dirname as w}from"@visulima/path";import{i as U,d as G}from"./detect-package-manager-DSaAqRof.mjs";import{DEV_VARS_FILE as H,parseDevVariableEntries as Y,writeDevVariablesFileAtomically as z}from"@lunora/config";import{modify as F,applyEdits as T,parse as X}from"jsonc-parser";import{d as Q,s as j,e as Z,f as K,c as ee,g as ne}from"./resolve-DZAGzg67.mjs";import{b as te}from"./tui-prompts-Dd0pDuNr.mjs";import{collectCatalog as re,buildRegistryIndex as se}from"./buildRegistryIndex-Zi3bBqpc.mjs";import{findWranglerFile as ie,readWranglerJsonc as oe}from"@lunora/config/cloudflare";import{LunoraError as x}from"@lunora/errors";import{insertSchemaExtension as ae}from"./insertSchemaExtension-DY4pA8wE.mjs";import{createHash as ce}from"node:crypto";const C=e=>{if(!e.startsWith("workspace:"))return e;const n=e.slice(10);return n===""||n==="*"||n==="^"||n==="~"?Q():n},de=new Set(["@lunora/client","@lunora/do","@lunora/ratelimit","@lunora/runtime","@lunora/server","@lunora/values"]),ue=/(['"])@lunora\/(client|do|ratelimit|runtime|server|values)(\/[^'"]*)?\1/gu,fe=e=>{const n=l(e,"package.json");if(!m(n))return!1;try{const t=JSON.parse(h(n,"utf8"));return t.dependencies?.lunorash!==void 0||t.devDependencies?.lunorash!==void 0}catch{return!1}},le=e=>e.replaceAll(ue,(n,t,i,r)=>`${t}lunorash/${i}${r??""}${t}`),O=(e,n,t,i="dependencies",r=!1)=>{const s=Object.entries(e);if(s.length===0)return[];const o=l(n,"package.json");if(!m(o))return t.warn(`package.json not found at ${o} — skipping dependency updates`),[];let a=h(o,"utf8");const c=JSON.parse(a),d=[];for(const[u,f]of s){if(r&&de.has(u)){t.info(`dep provided by the lunorash umbrella, skipping: ${u}`);continue}if(c.dependencies?.[u]!==void 0||c.devDependencies?.[u]!==void 0){t.info(`dep already present: ${u}`);continue}const p=F(a,[i,u],C(f),{formattingOptions:{insertSpaces:!0,tabSize:4}});a=T(a,p),d.push(u)}return d.length>0&&($(o,a,"utf8"),t.success(`added ${String(d.length)} ${i==="devDependencies"?"devDependency(ies)":"dependency(ies)"} to package.json: ${d.join(", ")}`)),d},pe=(e,n,t)=>{if(e.length===0)return[];const i=l(n,H),r=m(i)?h(i,"utf8"):"",s=new Set(Y(r).map(d=>d.key)),o=[],a=[],c=[];for(const d of e)d.secret&&a.push(d.name),!s.has(d.name)&&(d.description&&c.push(`# ${d.description}`),c.push(`${d.name}=${d.secret?"":d.value??""}`),o.push(d.name));if(o.length>0){const d=r===""||r.endsWith(`
|
|
2
|
+
`)?r:`${r}
|
|
3
|
+
`;z(i,`${d}${c.join(`
|
|
4
|
+
`)}
|
|
5
|
+
`),t.success(`scaffolded ${String(o.length)} env var(s) into .dev.vars: ${o.join(", ")}`)}return a.length>0&&t.info(`set secret value(s) locally in .dev.vars, then for production: ${a.map(d=>`wrangler secret put ${d}`).join("; ")}`),o},R=new Set(["ai","analytics_engine_datasets","browser","d1_databases","durable_objects","hyperdrive","kv_namespaces","mtls_certificates","queues","r2_buckets","send_email","services","vars","vectorize","version_metadata","workflows"]),me=["binding","name","queue","pattern"],D=e=>{if(!(typeof e!="object"||e===null))for(const n of me){const t=e[n];if(typeof t=="string"&&t.length>0)return`${n}:${t}`}},he=(e,n,t,i)=>{const r=new Set(e.map(a=>JSON.stringify(a))),s=new Set(e.map(a=>D(a)).filter(a=>a!==void 0)),o=[];for(const a of n){if(r.has(JSON.stringify(a)))continue;const c=D(a);if(c!==void 0&&s.has(c)){i.warn(`${c.replace(":"," ")} already exists in ${t} — keeping the project's entry and skipping the registry item's. Reconcile by hand if the item needs different settings.`);continue}c!==void 0&&s.add(c),o.push(a)}return o},N=e=>Array.isArray(e),ge=(e,n)=>{let t=X(e);for(const i of n){if(typeof t!="object"||t===null)return;t=t[i]}return t},$e=(e,n)=>{const t=e[0];return t!==void 0&&R.has(t)?!0:(n.warn(`skipping binding "${e.join(".")}" — only resource bindings (${[...R].join(", ")}) may be written, not exec/entrypoint keys`),!1)},B=Symbol("skip-binding"),ve=(e,n,t)=>{const{value:i}=n;if(!N(i))return i;const r=ge(e,n.path);if(!N(r))return i;const s=he(r,i,n.path.join("."),t);return s.length===0?B:[...r,...s]},ye=(e,n,t)=>{if(e.length===0)return[];const r=["wrangler.jsonc","wrangler.json"].map(a=>l(n,a)).find(a=>m(a));if(!r)return t.warn("wrangler.jsonc not found — skipping binding updates"),[];let s=h(r,"utf8");const o=[];for(const a of e){if(!$e(a.path,t))continue;const c=ve(s,a,t);if(c===B)continue;const d=F(s,[...a.path],c,{formattingOptions:{insertSpaces:!0,tabSize:4}});d.length!==0&&(s=T(s,d),o.push(a.path.join(".")))}return o.length>0&&($(r,s,"utf8"),t.success(`applied ${String(o.length)} binding(s) to ${r}: ${o.join(", ")}`)),o},we=(e,n,t,i=!1)=>{const r=[],s=[];return e.deps&&r.push(...O(e.deps,n,t,"dependencies",i)),e.devDependencies&&r.push(...O(e.devDependencies,n,t,"devDependencies",i)),e.bindings&&s.push(...ye(e.bindings,n,t)),e.envVars&&pe(e.envVars,n,t),{bindings:s,deps:r}},ke=async(e,n)=>{const t=e.some(({manifest:d})=>Object.keys(d.deps??{}).length>0||Object.keys(d.devDependencies??{}).length>0),i=e.some(({manifest:d})=>(d.bindings??[]).length>0),r=n.source!==void 0&&n.source.length>0;if(!t&&!i&&!r||n.yes)return!0;const s=[];t&&s.push("add dependencies to package.json"),i&&s.push("write wrangler.jsonc bindings"),r&&s.push(`come from a non-default source (${String(n.source)})`);const o=s.join(", ");if(!process.stdin.isTTY&&n.confirm===void 0)return n.logger.error(`add: stdin is not a TTY and the requested items ${o} — re-run with --yes to confirm`),!1;const c=await(n.confirm??te)(`The requested items ${o}. Continue?`);return c||n.logger.info("add: aborted"),c},b=1,be=".lunora-registry.json",V=e=>l(e,"lunora",be),Se=e=>typeof e!="object"||e===null||!("items"in e)?!1:typeof e.items=="object"&&e.items!==null,y=e=>ce("sha256").update(e).digest("hex"),xe=e=>{const n=V(e);if(!m(n))return{items:{},version:b};try{const t=JSON.parse(h(n,"utf8"));if(Se(t))return{items:t.items,version:b}}catch{}return{items:{},version:b}},je=(e,n)=>{$(V(e),`${JSON.stringify(n,void 0,2)}
|
|
6
|
+
`,"utf8")},A=(e,n,t,i)=>{const r=e.items[n]??{files:{}};e.items[n]=r,r.files[t]=y(i)},Ee=(e,n,t)=>e.items[n]?.files[t],_=3,L=e=>e===""?[]:e.split(`
|
|
7
|
+
`),Oe=(e,n)=>{const t=L(e),i=L(n);let r=0;for(;r<t.length&&r<i.length&&t[r]===i[r];)r+=1;let s=t.length,o=i.length;for(;s>r&&o>r&&t[s-1]===i[o-1];)s-=1,o-=1;if(r===s&&r===o)return[];const a=[];for(let c=Math.max(0,r-_);c<r;c+=1)a.push(` ${t[c]??""}`);for(let c=r;c<s;c+=1)a.push(`- ${t[c]??""}`);for(let c=r;c<o;c+=1)a.push(`+ ${i[c]??""}`);for(let c=o;c<Math.min(i.length,o+_);c+=1)a.push(` ${i[c]??""}`);return a},Re=/\.[cm]?[jt]sx?$/u,E=(e,n,t,i)=>{const r=l(e,n.from);if(q(r).isSymbolicLink())throw new x("INTERNAL",`registry item "${i}": refusing to read "${n.from}" — it is a symlink, not a regular file`);const s=h(r,"utf8");return t&&Re.test(n.to)?le(s):s},De=(e,n,t,i,r,s,o)=>{const a=l(i,"lunora","schema.ts");if(s)return r.info(`~ would merge .extend(${n}.extension) into lunora/schema.ts (and create ${e.to} if absent)`),{kind:"skipped",path:a};const c=l(i,e.to);m(c)||(S(w(c),{recursive:!0}),$(c,E(t,e,o,n),"utf8"));const d=o?"lunorash/server":"@lunora/server",u=m(a)?h(a,"utf8"):`import { defineSchema } from "${d}";
|
|
8
|
+
|
|
9
|
+
export const schema = defineSchema({});
|
|
10
|
+
`,f=ae(u,n);if(f.ok)return S(w(a),{recursive:!0}),$(a,f.text,"utf8"),r.success(`merged .extend(${n}.extension) into lunora/schema.ts`),{kind:"written",path:a};if(f.reason==="already-applied")return r.warn(`lunora/schema.ts already extends "${n}" — skipping`),{kind:"skipped",path:a};throw f.reason==="invalid-identifier"?new x("INTERNAL",`schema-extension item "${n}" is not a valid JS identifier — it is spliced into lunora/schema.ts as \`import { ${n} }\` / \`.extend(${n}.extension)\`. Rename the item to a valid identifier (no leading digit, no "-").`):new x("INTERNAL",`schema-extension merge failed for "${n}": ${f.reason}`)},Ne=(e,n,t,i,r)=>{const s=Oe(n,t);if(s.length===0){r.info(`= ${e.to} (unchanged)`);return}r.info(`${i?"~":"+"} ${e.to}`);for(const o of s)r.info(` ${o}`)},Ae=(e,n,t,i,r,s,o,a)=>{const c=l(i,e.to),d=E(t,e,a,n),u=m(c),f=u?h(c,"utf8"):"",p=M=>(S(w(c),{recursive:!0}),$(c,d,"utf8"),A(s,n,e.to,d),r.success(`${M}: ${e.to}`),{kind:"written",path:c});if(o.diff)return Ne(e,f,d,u,r),{kind:"skipped",path:c};if(!u)return p("write");const g=y(f);if(g===y(d))return A(s,n,e.to,d),r.warn(`skip (exists): ${e.to}`),{kind:"skipped",path:c};if(o.overwrite)return p("overwrite");const v=Ee(s,n,e.to);return v===void 0?(r.warn(`skip (exists, untracked): ${e.to} — refusing to overwrite a file lunora didn't add (use --overwrite to force)`),{kind:"skipped",path:c}):v===g?p("update"):v===y(d)?(r.warn(`skip (locally edited): ${e.to}`),{kind:"skipped",path:c}):($(`${c}.new`,d,"utf8"),r.warn(`conflict: ${e.to} has local edits and an upstream update — wrote ${e.to}.new (use --overwrite to take theirs)`),{kind:"skipped",path:c})},_e=(e,n,t,i,r,s,o={},a=!1)=>e.merge==="schema-extension"?De(e,n,t,i,r,o.diff===!0,a):Ae(e,n,t,i,r,s,o,a),P=["src/server.ts","src/server/index.ts","src/server/index.tsx","src/index.ts","src/worker.ts"],Le=e=>{const n=ie(e);if(n===void 0)return;const{parsed:t}=oe(n);return typeof t?.main=="string"?t.main:void 0},Pe=e=>{const n=Le(e),t=n===void 0?P:[n,...P];for(const i of t){const r=l(e,i);if(!m(r))continue;const s=h(r,"utf8");if(!s.includes("createShardDO(")){if(i===n)break;continue}return{entryPath:r,main:i,source:s}}},Ie=(e,n,t)=>{const i=J(w(e),l(n,"lunora",t)).replaceAll("\\","/");return i.startsWith(".")?i:`./${i}`},Je=(e,n)=>{for(const t of e){const r=`Add \`export * from "${`./lunora/${t.module}.js`}"\` to your worker entry`,s=t.comment?` (${t.comment})`:"";n.warn(`${r}${s}`)}return 0},Fe=(e,n,t,i)=>{const r=[];for(const s of e){const o=Ie(n,t,s.module),a=o.replaceAll(/[.*+?^${}()|[\]\\]/g,String.raw`\$&`);new RegExp(String.raw`export\s+\*\s+from\s+["']${a}\.js["']`,"u").test(i)||(s.comment&&r.push(`
|
|
11
|
+
// ${s.comment}`),r.push(`export * from "${o}.js";`))}return r},Te=(e,n,t,i)=>{if(e.length===0)return 0;const r=Pe(n);if(r===void 0)return Je(e,t);const s=Fe(e,r.entryPath,n,r.source);if(s.length===0)return 0;if(i){for(const a of s)a!==""&&t.info(`~ entrypoint: ${a}`);return s.length}const o=r.source.endsWith(`
|
|
12
|
+
`)?"":`
|
|
13
|
+
`;return $(r.entryPath,`${r.source}${o}${s.join(`
|
|
14
|
+
`)}
|
|
15
|
+
`,"utf8"),t.success(`wrote ${String(s.length)} entrypoint re-export(s) to ${J(n,r.entryPath)}`),s.length},I=(e,n,t,i={})=>{const r=[],s=[],o=[],a=[],c=xe(n),d=fe(n);for(const{directory:u,manifest:f}of e){for(const g of f.files){const v=_e(g,f.name,u,n,t,c,i,d);(v.kind==="written"?r:s).push(v.path)}if(f.entrypointReexports!==void 0&&Te(f.entrypointReexports,n,t,i.diff===!0),i.diff)continue;const p=we(f,n,t,d);o.push(...p.deps),a.push(...p.bindings)}return!i.diff&&Object.keys(c.items).length>0&&je(n,c),{bindings:a,deps:o,skipped:s,written:r}},k=()=>({bindings:[],code:0,deps:[],skipped:[],written:[]}),nn=(e,n,t,i,r)=>e.bindings?{...e,bindings:e.bindings.map(s=>{if(s.path[0]!==n||!Array.isArray(s.value))return s;const o=s.value;return{...s,value:o.map(a=>typeof a=="object"&&a!==null&&a[t.key]===t.value?{...a,[i]:r}:a)}})}:e,W=(e,n)=>{const t=n.title??n.description;e.info(`plan: ${n.name}${t?` — ${t}`:""}`);for(const s of n.files)e.info(` file ${s.to} (${s.merge})`);const i=new Map,r=s=>{const o=i.get(s);if(o!==void 0)return o;const a=C(s);return i.set(s,a),a};for(const[s,o]of Object.entries(n.deps??{}))e.info(` dep ${s}@${r(o)}`);for(const[s,o]of Object.entries(n.devDependencies??{}))e.info(` dev ${s}@${r(o)}`);for(const s of n.bindings??[])e.info(` bind ${s.path.join(".")} = ${JSON.stringify(s.value)}`);for(const s of n.envVars??[]){const o=s.secret?" (secret)":` = ${JSON.stringify(s.value??"")}`;e.info(` env ${s.name}${o}`)}for(const s of n.entrypointReexports??[]){const o=`./lunora/${s.module}`,a=s.comment?` // ${s.comment}`:"";e.info(` entry ${o}${a}`)}},Ce=e=>{const n=e.map(({manifest:t})=>({bindings:(t.bindings??[]).map(i=>({path:i.path.join("."),value:i.value})),deps:Object.keys(t.deps??{}),devDependencies:Object.keys(t.devDependencies??{}),entrypointReexports:(t.entrypointReexports??[]).map(i=>({module:i.module,...i.comment?{comment:i.comment}:{}})),envVars:(t.envVars??[]).map(i=>({name:i.name,...i.secret?{secret:!0}:{value:i.value??""}})),files:t.files.map(i=>({merge:i.merge,to:i.to})),name:t.name,requires:t.requires??[],title:t.title}));process.stdout.write(`${JSON.stringify({items:n},void 0,2)}
|
|
16
|
+
`)},Be=e=>{try{const{args:n,command:t}=U(G(e));return`${t} ${n.join(" ")}`}catch{return"<your-package-manager> install"}},Ve=(e,n,t,i,r,s)=>{r.success(`add complete: ${String(t)} written, ${String(i)} skipped`),r.info("next steps:"),r.info(" lunora codegen # regenerate _generated/ so the new tables/functions appear"),n.length>0&&r.info(` ${Be(s)} # install newly-added dependencies`);for(const{manifest:o}of e)o.docs&&r.info(`${o.name}: ${o.docs}`)},We=async e=>{const n=k(),t=j("list",e);if(t)return e.logger.error(t),{...n,code:1};let i=()=>{};try{const r=await K(e);i=r.cleanup;const s=re(r.root);if(e.json)return process.stdout.write(`${JSON.stringify(s,void 0,2)}
|
|
17
|
+
`),n;e.logger.info(`available registry items (${String(s.length)}):`);for(const o of s)e.logger.info(` ${o.name}${o.description?` — ${o.description}`:""}`);return n}catch(r){return e.logger.error(`list failed: ${r instanceof Error?r.message:String(r)}`),{...n,code:1}}finally{i()}},tn=async e=>{const n=e.cwd??process.cwd(),t=k();if(e.list)return We(e);if(e.names.length===0)return e.logger.error("add requires at least one item name. Usage: lunora registry add <name> [...names]"),{...t,code:1};const i=j("add",e);if(i)return e.logger.error(i),{...t,code:1};let r=[];try{const{cleanups:s,items:o}=await Z(e.names,e);r=s;const{transformManifest:a}=e,c=a?o.map(g=>({...g,manifest:a(g.manifest)})):o;for(const{manifest:g}of c)W(e.logger,g);if(e.json&&Ce(c),e.dryRun)return e.logger.info("dry-run: stopping before any files are written"),t;if(e.diff)return I(c,n,e.logger,{diff:!0}),e.logger.info("diff: preview only — re-run without --diff to apply"),t;if(!await ke(c,e))return{...t,code:1};const{bindings:d,deps:u,skipped:f,written:p}=I(c,n,e.logger,{overwrite:e.overwrite});return Ve(c,u,p.length,f.length,e.logger,n),{bindings:d,code:0,deps:u,skipped:f,written:p}}catch(s){return e.logger.error(`add failed: ${s instanceof Error?s.message:String(s)}`),{...t,code:1}}finally{for(const s of r)s()}},rn=async e=>{const n=k();if(e.names.length===0)return e.logger.error("view requires an item name. Usage: lunora registry view <name>"),{...n,code:1};const t=j("view",e);if(t)return e.logger.error(t),{...n,code:1};const i=[];try{for(const r of e.names){const{cleanup:s,directory:o}=await ee(r,e);i.push(s);const a=ne(o,r);W(e.logger,a);for(const c of a.files){e.logger.info(`--- ${c.to} (${c.merge}) ---`);const d=E(o,c,!1,r);for(const u of d.split(`
|
|
18
|
+
`))e.logger.info(u)}}return n}catch(r){return e.logger.error(`view failed: ${r instanceof Error?r.message:String(r)}`),{...n,code:1}}finally{for(const r of i)r()}},sn=async e=>{const n=k(),t=e.from;if(t===void 0)return e.logger.error("registry build requires --from <registry root>"),{...n,code:1};if(!m(t))return e.logger.error(`registry root not found: ${t}`),{...n,code:1};const i=se(t),r=e.out??l(t,"index.json");if(e.check){const s=m(r)?JSON.parse(h(r,"utf8")):{items:[]};return JSON.stringify(s.items??[])!==JSON.stringify(i.items)?(e.logger.error(`registry: ${r} is stale — run \`lunora registry build\` to regenerate it`),{...n,code:1}):(e.logger.success(`registry: ${r} is up to date (${String(i.items.length)} items)`),n)}return $(r,`${JSON.stringify({$schema:"./schema/registry.schema.json",...i},void 0,4)}
|
|
19
|
+
`,"utf8"),e.logger.success(`registry: wrote ${r} (${String(i.items.length)} items)`),n};export{sn as a,rn as b,tn as r,nn as s};
|
package/dist/packem_shared/{lint-ignore-report-0sVOnXcO.mjs → lint-ignore-report-BZjT7jyY.mjs}
RENAMED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{s}from"./commands-
|
|
1
|
+
import{s}from"./commands-BOgN2nF7.mjs";const l=[{description:"Email + password on better-auth (default)",label:"Email & password",value:"auth"},{description:"Clerk-hosted auth",label:"Clerk",value:"auth-clerk"},{description:"Auth0 (OIDC)",label:"Auth0",value:"auth-auth0"}],i="auth",w=async a=>await a("Which auth provider?",l,{default:i})??i,I="mail",D=[{description:"Next, react-router, TanStack Start, Astro islands",label:"React",value:"auth-ui-react"},{description:"Nuxt, Vue + Vite",label:"Vue",value:"auth-ui-vue"},{description:"SvelteKit, Svelte + Vite",label:"Svelte",value:"auth-ui-svelte"},{description:"TanStack Start Solid, Solid + Vite",label:"Solid",value:"auth-ui-solid"},{description:"Analog",label:"Angular",value:"auth-ui-angular"}],O="auth-ui-react",c=a=>Object.hasOwn(a,"react-native")||Object.hasOwn(a,"@lunora/react-native")||Object.hasOwn(a,"expo"),T=a=>{const e=t=>Object.hasOwn(a,t);if(!c(a)){if(e("@lunora/react"))return"auth-ui-react";if(e("@lunora/vue"))return"auth-ui-vue";if(e("@lunora/svelte"))return"auth-ui-svelte";if(e("@lunora/solid"))return"auth-ui-solid";if(e("@lunora/angular"))return"auth-ui-angular";if(e("react")||e("next"))return"auth-ui-react";if(e("vue")||e("nuxt"))return"auth-ui-vue";if(e("svelte")||e("@sveltejs/kit"))return"auth-ui-svelte";if(e("solid-js"))return"auth-ui-solid";if(e("@angular/core"))return"auth-ui-angular"}},S=a=>{const e=a.trim();if(e==="")return;const t=e.toLowerCase();return t==="auth-ui"||t==="auth-ui-"?{kind:"auth-ui"}:t==="auth"?{kind:"auth"}:t==="email"||t==="mail"?{kind:"email"}:{item:t,kind:"item"}},d=/[^a-z0-9]+/u,r=(a,e,t)=>{let n=a.toLowerCase().split(d).filter(Boolean).join("-").slice(0,t);return n.endsWith("-")&&(n=n.slice(0,-1)),n.length>=e?n:void 0},h="DB",f="Name your D1 database (run `wrangler d1 create` to get its id, then put it in wrangler.jsonc)",u=a=>r(a,1,64),m="lunora-db",v=a=>u(`${a}-db`)??m,E=async(a,e)=>{const t=v(e);return u(await a(f,{default:t,placeholder:t}))??t},L=(a,e)=>s(a,"d1_databases",{key:"binding",value:h},"database_name",e),p="SEND_EMAIL",B="Verified destination email for production delivery (blank = set it later in wrangler.jsonc)",A=a=>{const e=a.trim();if(e.length===0||e.includes(" "))return!1;const t=e.indexOf("@");if(t<=0||t!==e.lastIndexOf("@"))return!1;const n=e.slice(t+1);return n.length>=3&&n.includes(".")&&!n.startsWith(".")&&!n.endsWith(".")},U=(a,e)=>{const t=a.trim();if(t!==""){if(!A(t)){e(`"${t}" doesn't look like an email — leaving the placeholder; set destination_address in wrangler.jsonc.`);return}return t}},M=(a,e)=>s(a,"send_email",{key:"name",value:p},"destination_address",e),b="UPLOADS",_="Name your R2 bucket (you can rename it in wrangler.jsonc later)",o=a=>r(a,3,63),k="lunora-uploads",N=a=>o(`${a}-uploads`)??k,j=async(a,e)=>{const t=N(e);return o(await a(_,{default:t,placeholder:t}))??t},y=(a,e)=>s(a,"r2_buckets",{key:"binding",value:b},"bucket_name",e),P=(a,e)=>{for(const t of a)(t.status==="created"||t.status==="updated")&&e.success(`${t.status} ${t.path} — ${t.tool} now skips Lunora's generated files`),t.status==="failed"&&e.warn(`could not configure ${t.tool} to skip Lunora's generated files: ${t.message??"unknown error"}. Add the entries by hand, or re-run once the path is writable.`),t.status==="manual"&&t.snippet!==void 0&&e.warn(`${t.path} needs an entry so ${t.tool} skips Lunora's generated files — add:
|
|
2
2
|
${t.snippet}`)};export{D as A,i as D,I as E,B as M,u as a,v as b,E as c,N as d,P as e,w as f,T as g,O as h,c as i,l as j,M as k,L as l,S as n,j as p,U as r,o as s,y as w};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import"./detect-package-manager-DSaAqRof.mjs";import{r as n,a as i,b as t}from"./commands-
|
|
1
|
+
import"./detect-package-manager-DSaAqRof.mjs";import{r as n,a as i,b as t}from"./commands-BOgN2nF7.mjs";import"./buildRegistryIndex-Zi3bBqpc.mjs";import"./resolve-DZAGzg67.mjs";export{n as runAddCommand,i as runBuildIndexCommand,t as runRegistryViewCommand};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lunora/cli",
|
|
3
|
-
"version": "1.0.0-alpha.
|
|
3
|
+
"version": "1.0.0-alpha.172",
|
|
4
4
|
"description": "The Lunora CLI: init, dev, deploy, codegen, migrate, seed, doctor, insights, logs, registry, and the rest of the project commands",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"agent-skills",
|
|
@@ -52,16 +52,16 @@
|
|
|
52
52
|
},
|
|
53
53
|
"dependencies": {
|
|
54
54
|
"@bomb.sh/tab": "0.0.22",
|
|
55
|
-
"@lunora/advisor": "1.0.0-alpha.
|
|
56
|
-
"@lunora/bindings": "1.0.0-alpha.
|
|
57
|
-
"@lunora/codegen": "1.0.0-alpha.
|
|
58
|
-
"@lunora/config": "1.0.0-alpha.
|
|
55
|
+
"@lunora/advisor": "1.0.0-alpha.84",
|
|
56
|
+
"@lunora/bindings": "1.0.0-alpha.32",
|
|
57
|
+
"@lunora/codegen": "1.0.0-alpha.115",
|
|
58
|
+
"@lunora/config": "1.0.0-alpha.145",
|
|
59
59
|
"@lunora/container": "1.0.0-alpha.32",
|
|
60
|
-
"@lunora/d1": "1.0.0-alpha.
|
|
60
|
+
"@lunora/d1": "1.0.0-alpha.81",
|
|
61
61
|
"@lunora/errors": "1.0.0-alpha.22",
|
|
62
|
-
"@lunora/mcp": "1.0.0-alpha.
|
|
63
|
-
"@lunora/runtime": "1.0.0-alpha.
|
|
64
|
-
"@lunora/seed": "1.0.0-alpha.
|
|
62
|
+
"@lunora/mcp": "1.0.0-alpha.76",
|
|
63
|
+
"@lunora/runtime": "1.0.0-alpha.67",
|
|
64
|
+
"@lunora/seed": "1.0.0-alpha.77",
|
|
65
65
|
"@visulima/cerebro": "3.0.6",
|
|
66
66
|
"@visulima/error": "6.1.0",
|
|
67
67
|
"@visulima/fs": "6.0.0",
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import{existsSync as m,readFileSync as h,writeFileSync as $,mkdirSync as S}from"node:fs";import{join as l,relative as L,dirname as w}from"@visulima/path";import{i as q,d as U}from"./detect-package-manager-DSaAqRof.mjs";import{DEV_VARS_FILE as G,parseDevVariableEntries as H,writeDevVariablesFileAtomically as Y}from"@lunora/config";import{modify as J,applyEdits as F,parse as z}from"jsonc-parser";import{d as X,s as x,e as Q,f as Z,c as K,g as ee}from"./resolve-DZAGzg67.mjs";import{b as ne}from"./tui-prompts-Dd0pDuNr.mjs";import{collectCatalog as te,buildRegistryIndex as re}from"./buildRegistryIndex-Zi3bBqpc.mjs";import{findWranglerFile as se,readWranglerJsonc as ie}from"@lunora/config/cloudflare";import{LunoraError as j}from"@lunora/errors";import{insertSchemaExtension as oe}from"./insertSchemaExtension-DY4pA8wE.mjs";import{createHash as ae}from"node:crypto";const T=e=>{if(!e.startsWith("workspace:"))return e;const n=e.slice(10);return n===""||n==="*"||n==="^"||n==="~"?X():n},ce=new Set(["@lunora/client","@lunora/do","@lunora/ratelimit","@lunora/runtime","@lunora/server","@lunora/values"]),de=/(['"])@lunora\/(client|do|ratelimit|runtime|server|values)(\/[^'"]*)?\1/gu,ue=e=>{const n=l(e,"package.json");if(!m(n))return!1;try{const t=JSON.parse(h(n,"utf8"));return t.dependencies?.lunorash!==void 0||t.devDependencies?.lunorash!==void 0}catch{return!1}},fe=e=>e.replaceAll(de,(n,t,i,r)=>`${t}lunorash/${i}${r??""}${t}`),E=(e,n,t,i="dependencies",r=!1)=>{const s=Object.entries(e);if(s.length===0)return[];const o=l(n,"package.json");if(!m(o))return t.warn(`package.json not found at ${o} — skipping dependency updates`),[];let a=h(o,"utf8");const c=JSON.parse(a),d=[];for(const[u,f]of s){if(r&&ce.has(u)){t.info(`dep provided by the lunorash umbrella, skipping: ${u}`);continue}if(c.dependencies?.[u]!==void 0||c.devDependencies?.[u]!==void 0){t.info(`dep already present: ${u}`);continue}const p=J(a,[i,u],T(f),{formattingOptions:{insertSpaces:!0,tabSize:4}});a=F(a,p),d.push(u)}return d.length>0&&($(o,a,"utf8"),t.success(`added ${String(d.length)} ${i==="devDependencies"?"devDependency(ies)":"dependency(ies)"} to package.json: ${d.join(", ")}`)),d},le=(e,n,t)=>{if(e.length===0)return[];const i=l(n,G),r=m(i)?h(i,"utf8"):"",s=new Set(H(r).map(d=>d.key)),o=[],a=[],c=[];for(const d of e)d.secret&&a.push(d.name),!s.has(d.name)&&(d.description&&c.push(`# ${d.description}`),c.push(`${d.name}=${d.secret?"":d.value??""}`),o.push(d.name));if(o.length>0){const d=r===""||r.endsWith(`
|
|
2
|
-
`)?r:`${r}
|
|
3
|
-
`;Y(i,`${d}${c.join(`
|
|
4
|
-
`)}
|
|
5
|
-
`),t.success(`scaffolded ${String(o.length)} env var(s) into .dev.vars: ${o.join(", ")}`)}return a.length>0&&t.info(`set secret value(s) locally in .dev.vars, then for production: ${a.map(d=>`wrangler secret put ${d}`).join("; ")}`),o},O=new Set(["ai","analytics_engine_datasets","browser","d1_databases","durable_objects","hyperdrive","kv_namespaces","mtls_certificates","queues","r2_buckets","send_email","services","vars","vectorize","version_metadata","workflows"]),pe=["binding","name","queue","pattern"],R=e=>{if(!(typeof e!="object"||e===null))for(const n of pe){const t=e[n];if(typeof t=="string"&&t.length>0)return`${n}:${t}`}},me=(e,n,t,i)=>{const r=new Set(e.map(a=>JSON.stringify(a))),s=new Set(e.map(a=>R(a)).filter(a=>a!==void 0)),o=[];for(const a of n){if(r.has(JSON.stringify(a)))continue;const c=R(a);if(c!==void 0&&s.has(c)){i.warn(`${c.replace(":"," ")} already exists in ${t} — keeping the project's entry and skipping the registry item's. Reconcile by hand if the item needs different settings.`);continue}c!==void 0&&s.add(c),o.push(a)}return o},D=e=>Array.isArray(e),he=(e,n)=>{let t=z(e);for(const i of n){if(typeof t!="object"||t===null)return;t=t[i]}return t},ge=(e,n)=>{const t=e[0];return t!==void 0&&O.has(t)?!0:(n.warn(`skipping binding "${e.join(".")}" — only resource bindings (${[...O].join(", ")}) may be written, not exec/entrypoint keys`),!1)},C=Symbol("skip-binding"),$e=(e,n,t)=>{const{value:i}=n;if(!D(i))return i;const r=he(e,n.path);if(!D(r))return i;const s=me(r,i,n.path.join("."),t);return s.length===0?C:[...r,...s]},ve=(e,n,t)=>{if(e.length===0)return[];const r=["wrangler.jsonc","wrangler.json"].map(a=>l(n,a)).find(a=>m(a));if(!r)return t.warn("wrangler.jsonc not found — skipping binding updates"),[];let s=h(r,"utf8");const o=[];for(const a of e){if(!ge(a.path,t))continue;const c=$e(s,a,t);if(c===C)continue;const d=J(s,[...a.path],c,{formattingOptions:{insertSpaces:!0,tabSize:4}});d.length!==0&&(s=F(s,d),o.push(a.path.join(".")))}return o.length>0&&($(r,s,"utf8"),t.success(`applied ${String(o.length)} binding(s) to ${r}: ${o.join(", ")}`)),o},ye=(e,n,t,i=!1)=>{const r=[],s=[];return e.deps&&r.push(...E(e.deps,n,t,"dependencies",i)),e.devDependencies&&r.push(...E(e.devDependencies,n,t,"devDependencies",i)),e.bindings&&s.push(...ve(e.bindings,n,t)),e.envVars&&le(e.envVars,n,t),{bindings:s,deps:r}},we=async(e,n)=>{const t=e.some(({manifest:d})=>Object.keys(d.deps??{}).length>0||Object.keys(d.devDependencies??{}).length>0),i=e.some(({manifest:d})=>(d.bindings??[]).length>0),r=n.source!==void 0&&n.source.length>0;if(!t&&!i&&!r||n.yes)return!0;const s=[];t&&s.push("add dependencies to package.json"),i&&s.push("write wrangler.jsonc bindings"),r&&s.push(`come from a non-default source (${String(n.source)})`);const o=s.join(", ");if(!process.stdin.isTTY&&n.confirm===void 0)return n.logger.error(`add: stdin is not a TTY and the requested items ${o} — re-run with --yes to confirm`),!1;const c=await(n.confirm??ne)(`The requested items ${o}. Continue?`);return c||n.logger.info("add: aborted"),c},b=1,ke=".lunora-registry.json",B=e=>l(e,"lunora",ke),be=e=>typeof e!="object"||e===null||!("items"in e)?!1:typeof e.items=="object"&&e.items!==null,y=e=>ae("sha256").update(e).digest("hex"),Se=e=>{const n=B(e);if(!m(n))return{items:{},version:b};try{const t=JSON.parse(h(n,"utf8"));if(be(t))return{items:t.items,version:b}}catch{}return{items:{},version:b}},xe=(e,n)=>{$(B(e),`${JSON.stringify(n,void 0,2)}
|
|
6
|
-
`,"utf8")},A=(e,n,t,i)=>{const r=e.items[n]??{files:{}};e.items[n]=r,r.files[t]=y(i)},je=(e,n,t)=>e.items[n]?.files[t],N=3,_=e=>e===""?[]:e.split(`
|
|
7
|
-
`),Ee=(e,n)=>{const t=_(e),i=_(n);let r=0;for(;r<t.length&&r<i.length&&t[r]===i[r];)r+=1;let s=t.length,o=i.length;for(;s>r&&o>r&&t[s-1]===i[o-1];)s-=1,o-=1;if(r===s&&r===o)return[];const a=[];for(let c=Math.max(0,r-N);c<r;c+=1)a.push(` ${t[c]??""}`);for(let c=r;c<s;c+=1)a.push(`- ${t[c]??""}`);for(let c=r;c<o;c+=1)a.push(`+ ${i[c]??""}`);for(let c=o;c<Math.min(i.length,o+N);c+=1)a.push(` ${i[c]??""}`);return a},Oe=/\.[cm]?[jt]sx?$/u,V=(e,n,t)=>{const i=h(l(e,n.from),"utf8");return t&&Oe.test(n.to)?fe(i):i},Re=(e,n,t,i,r,s,o)=>{const a=l(i,"lunora","schema.ts");if(s)return r.info(`~ would merge .extend(${n}.extension) into lunora/schema.ts (and create ${e.to} if absent)`),{kind:"skipped",path:a};const c=l(i,e.to);m(c)||(S(w(c),{recursive:!0}),$(c,V(t,e,o),"utf8"));const d=o?"lunorash/server":"@lunora/server",u=m(a)?h(a,"utf8"):`import { defineSchema } from "${d}";
|
|
8
|
-
|
|
9
|
-
export const schema = defineSchema({});
|
|
10
|
-
`,f=oe(u,n);if(f.ok)return S(w(a),{recursive:!0}),$(a,f.text,"utf8"),r.success(`merged .extend(${n}.extension) into lunora/schema.ts`),{kind:"written",path:a};if(f.reason==="already-applied")return r.warn(`lunora/schema.ts already extends "${n}" — skipping`),{kind:"skipped",path:a};throw f.reason==="invalid-identifier"?new j("INTERNAL",`schema-extension item "${n}" is not a valid JS identifier — it is spliced into lunora/schema.ts as \`import { ${n} }\` / \`.extend(${n}.extension)\`. Rename the item to a valid identifier (no leading digit, no "-").`):new j("INTERNAL",`schema-extension merge failed for "${n}": ${f.reason}`)},De=(e,n,t,i,r)=>{const s=Ee(n,t);if(s.length===0){r.info(`= ${e.to} (unchanged)`);return}r.info(`${i?"~":"+"} ${e.to}`);for(const o of s)r.info(` ${o}`)},Ae=(e,n,t,i,r,s,o,a)=>{const c=l(i,e.to),d=V(t,e,a),u=m(c),f=u?h(c,"utf8"):"",p=M=>(S(w(c),{recursive:!0}),$(c,d,"utf8"),A(s,n,e.to,d),r.success(`${M}: ${e.to}`),{kind:"written",path:c});if(o.diff)return De(e,f,d,u,r),{kind:"skipped",path:c};if(!u)return p("write");const g=y(f);if(g===y(d))return A(s,n,e.to,d),r.warn(`skip (exists): ${e.to}`),{kind:"skipped",path:c};if(o.overwrite)return p("overwrite");const v=je(s,n,e.to);return v===void 0?(r.warn(`skip (exists, untracked): ${e.to} — refusing to overwrite a file lunora didn't add (use --overwrite to force)`),{kind:"skipped",path:c}):v===g?p("update"):v===y(d)?(r.warn(`skip (locally edited): ${e.to}`),{kind:"skipped",path:c}):($(`${c}.new`,d,"utf8"),r.warn(`conflict: ${e.to} has local edits and an upstream update — wrote ${e.to}.new (use --overwrite to take theirs)`),{kind:"skipped",path:c})},Ne=(e,n,t,i,r,s,o={},a=!1)=>e.merge==="schema-extension"?Re(e,n,t,i,r,o.diff===!0,a):Ae(e,n,t,i,r,s,o,a),P=["src/server.ts","src/server/index.ts","src/server/index.tsx","src/index.ts","src/worker.ts"],_e=e=>{const n=se(e);if(n===void 0)return;const{parsed:t}=ie(n);return typeof t?.main=="string"?t.main:void 0},Pe=e=>{const n=_e(e),t=n===void 0?P:[n,...P];for(const i of t){const r=l(e,i);if(!m(r))continue;const s=h(r,"utf8");if(!s.includes("createShardDO(")){if(i===n)break;continue}return{entryPath:r,main:i,source:s}}},Ie=(e,n,t)=>{const i=L(w(e),l(n,"lunora",t)).replaceAll("\\","/");return i.startsWith(".")?i:`./${i}`},Le=(e,n)=>{for(const t of e){const r=`Add \`export * from "${`./lunora/${t.module}.js`}"\` to your worker entry`,s=t.comment?` (${t.comment})`:"";n.warn(`${r}${s}`)}return 0},Je=(e,n,t,i)=>{const r=[];for(const s of e){const o=Ie(n,t,s.module),a=o.replaceAll(/[.*+?^${}()|[\]\\]/g,String.raw`\$&`);new RegExp(String.raw`export\s+\*\s+from\s+["']${a}\.js["']`,"u").test(i)||(s.comment&&r.push(`
|
|
11
|
-
// ${s.comment}`),r.push(`export * from "${o}.js";`))}return r},Fe=(e,n,t,i)=>{if(e.length===0)return 0;const r=Pe(n);if(r===void 0)return Le(e,t);const s=Je(e,r.entryPath,n,r.source);if(s.length===0)return 0;if(i){for(const a of s)a!==""&&t.info(`~ entrypoint: ${a}`);return s.length}const o=r.source.endsWith(`
|
|
12
|
-
`)?"":`
|
|
13
|
-
`;return $(r.entryPath,`${r.source}${o}${s.join(`
|
|
14
|
-
`)}
|
|
15
|
-
`,"utf8"),t.success(`wrote ${String(s.length)} entrypoint re-export(s) to ${L(n,r.entryPath)}`),s.length},I=(e,n,t,i={})=>{const r=[],s=[],o=[],a=[],c=Se(n),d=ue(n);for(const{directory:u,manifest:f}of e){for(const g of f.files){const v=Ne(g,f.name,u,n,t,c,i,d);(v.kind==="written"?r:s).push(v.path)}if(f.entrypointReexports!==void 0&&Fe(f.entrypointReexports,n,t,i.diff===!0),i.diff)continue;const p=ye(f,n,t,d);o.push(...p.deps),a.push(...p.bindings)}return!i.diff&&Object.keys(c.items).length>0&&xe(n,c),{bindings:a,deps:o,skipped:s,written:r}},k=()=>({bindings:[],code:0,deps:[],skipped:[],written:[]}),en=(e,n,t,i,r)=>e.bindings?{...e,bindings:e.bindings.map(s=>{if(s.path[0]!==n||!Array.isArray(s.value))return s;const o=s.value;return{...s,value:o.map(a=>typeof a=="object"&&a!==null&&a[t.key]===t.value?{...a,[i]:r}:a)}})}:e,W=(e,n)=>{const t=n.title??n.description;e.info(`plan: ${n.name}${t?` — ${t}`:""}`);for(const s of n.files)e.info(` file ${s.to} (${s.merge})`);const i=new Map,r=s=>{const o=i.get(s);if(o!==void 0)return o;const a=T(s);return i.set(s,a),a};for(const[s,o]of Object.entries(n.deps??{}))e.info(` dep ${s}@${r(o)}`);for(const[s,o]of Object.entries(n.devDependencies??{}))e.info(` dev ${s}@${r(o)}`);for(const s of n.bindings??[])e.info(` bind ${s.path.join(".")} = ${JSON.stringify(s.value)}`);for(const s of n.envVars??[]){const o=s.secret?" (secret)":` = ${JSON.stringify(s.value??"")}`;e.info(` env ${s.name}${o}`)}for(const s of n.entrypointReexports??[]){const o=`./lunora/${s.module}`,a=s.comment?` // ${s.comment}`:"";e.info(` entry ${o}${a}`)}},Te=e=>{const n=e.map(({manifest:t})=>({bindings:(t.bindings??[]).map(i=>({path:i.path.join("."),value:i.value})),deps:Object.keys(t.deps??{}),devDependencies:Object.keys(t.devDependencies??{}),entrypointReexports:(t.entrypointReexports??[]).map(i=>({module:i.module,...i.comment?{comment:i.comment}:{}})),envVars:(t.envVars??[]).map(i=>({name:i.name,...i.secret?{secret:!0}:{value:i.value??""}})),files:t.files.map(i=>({merge:i.merge,to:i.to})),name:t.name,requires:t.requires??[],title:t.title}));process.stdout.write(`${JSON.stringify({items:n},void 0,2)}
|
|
16
|
-
`)},Ce=e=>{try{const{args:n,command:t}=q(U(e));return`${t} ${n.join(" ")}`}catch{return"<your-package-manager> install"}},Be=(e,n,t,i,r,s)=>{r.success(`add complete: ${String(t)} written, ${String(i)} skipped`),r.info("next steps:"),r.info(" lunora codegen # regenerate _generated/ so the new tables/functions appear"),n.length>0&&r.info(` ${Ce(s)} # install newly-added dependencies`);for(const{manifest:o}of e)o.docs&&r.info(`${o.name}: ${o.docs}`)},Ve=async e=>{const n=k(),t=x("list",e);if(t)return e.logger.error(t),{...n,code:1};let i=()=>{};try{const r=await Z(e);i=r.cleanup;const s=te(r.root);if(e.json)return process.stdout.write(`${JSON.stringify(s,void 0,2)}
|
|
17
|
-
`),n;e.logger.info(`available registry items (${String(s.length)}):`);for(const o of s)e.logger.info(` ${o.name}${o.description?` — ${o.description}`:""}`);return n}catch(r){return e.logger.error(`list failed: ${r instanceof Error?r.message:String(r)}`),{...n,code:1}}finally{i()}},nn=async e=>{const n=e.cwd??process.cwd(),t=k();if(e.list)return Ve(e);if(e.names.length===0)return e.logger.error("add requires at least one item name. Usage: lunora registry add <name> [...names]"),{...t,code:1};const i=x("add",e);if(i)return e.logger.error(i),{...t,code:1};let r=[];try{const{cleanups:s,items:o}=await Q(e.names,e);r=s;const{transformManifest:a}=e,c=a?o.map(g=>({...g,manifest:a(g.manifest)})):o;for(const{manifest:g}of c)W(e.logger,g);if(e.json&&Te(c),e.dryRun)return e.logger.info("dry-run: stopping before any files are written"),t;if(e.diff)return I(c,n,e.logger,{diff:!0}),e.logger.info("diff: preview only — re-run without --diff to apply"),t;if(!await we(c,e))return{...t,code:1};const{bindings:d,deps:u,skipped:f,written:p}=I(c,n,e.logger,{overwrite:e.overwrite});return Be(c,u,p.length,f.length,e.logger,n),{bindings:d,code:0,deps:u,skipped:f,written:p}}catch(s){return e.logger.error(`add failed: ${s instanceof Error?s.message:String(s)}`),{...t,code:1}}finally{for(const s of r)s()}},tn=async e=>{const n=k();if(e.names.length===0)return e.logger.error("view requires an item name. Usage: lunora registry view <name>"),{...n,code:1};const t=x("view",e);if(t)return e.logger.error(t),{...n,code:1};const i=[];try{for(const r of e.names){const{cleanup:s,directory:o}=await K(r,e);i.push(s);const a=ee(o,r);W(e.logger,a);for(const c of a.files){e.logger.info(`--- ${c.to} (${c.merge}) ---`);const d=h(l(o,c.from),"utf8");for(const u of d.split(`
|
|
18
|
-
`))e.logger.info(u)}}return n}catch(r){return e.logger.error(`view failed: ${r instanceof Error?r.message:String(r)}`),{...n,code:1}}finally{for(const r of i)r()}},rn=async e=>{const n=k(),t=e.from;if(t===void 0)return e.logger.error("registry build requires --from <registry root>"),{...n,code:1};if(!m(t))return e.logger.error(`registry root not found: ${t}`),{...n,code:1};const i=re(t),r=e.out??l(t,"index.json");if(e.check){const s=m(r)?JSON.parse(h(r,"utf8")):{items:[]};return JSON.stringify(s.items??[])!==JSON.stringify(i.items)?(e.logger.error(`registry: ${r} is stale — run \`lunora registry build\` to regenerate it`),{...n,code:1}):(e.logger.success(`registry: ${r} is up to date (${String(i.items.length)} items)`),n)}return $(r,`${JSON.stringify({$schema:"./schema/registry.schema.json",...i},void 0,4)}
|
|
19
|
-
`,"utf8"),e.logger.success(`registry: wrote ${r} (${String(i.items.length)} items)`),n};export{rn as a,tn as b,nn as r,en as s};
|