@lunora/cli 1.0.0-alpha.227 → 1.0.0-alpha.228
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
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{C as o,V as a,r as n}from"./packem_shared/cli-DIb5Ay4K.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 C}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-DuiV6cba.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-DtC5Cs4Z.mjs";import{default as F}from"./packem_shared/schemaIrToSnapshot-
|
|
1
|
+
import{C as o,V as a,r as n}from"./packem_shared/cli-DIb5Ay4K.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 C}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-DuiV6cba.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-DtC5Cs4Z.mjs";import{default as F}from"./packem_shared/schemaIrToSnapshot-e5fO6GRg.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-Dqd1MOOv.mjs";import{REQUIRED_COMPATIBILITY_DATE as H,REQUIRED_FLAG as K,validateWranglerProject as Y,validateWranglerConfig as Z}from"@lunora/config/cloudflare";import{b as z}from"./packem_shared/catalog-Cbzph90w.mjs";import{r as X,a as $,b as rr}from"./packem_shared/commands-I18aR_DJ.mjs";import{runExportCommand as or}from"./packem_shared/runExportCommand-Dq-SpjAe.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,C 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,4 +1,4 @@
|
|
|
1
|
-
import{existsSync as f,mkdirSync as _,writeFileSync as b,mkdtempSync as N,rmSync as M,readFileSync as k}from"node:fs";import{tmpdir as x}from"node:os";import{discoverSchema as U,readPackageDependencies as C,discoverMigrations as F}from"@lunora/codegen";import{isInteractive as O,promptSelect as P,promptText as D}from"@lunora/config";import{LunoraError as $}from"@lunora/errors";import{join as c}from"@visulima/path";import{Project as v}from"ts-morph";import{r as z,t as j}from"../packem_shared/admin-token-VdUnvnKW.mjs";import{n as q,r as L}from"../packem_shared/admin-url-BhF5ufg1.mjs";import{d as B}from"../packem_shared/command-DwC11Cwe.mjs";import{diffSnapshots as H,renderMigrationFile as G}from"../packem_shared/diffSnapshots-DtC5Cs4Z.mjs";import{r as W}from"../packem_shared/resolve-target-BRvw8Pf7.mjs";import J from"../packem_shared/schemaIrToSnapshot-
|
|
1
|
+
import{existsSync as f,mkdirSync as _,writeFileSync as b,mkdtempSync as N,rmSync as M,readFileSync as k}from"node:fs";import{tmpdir as x}from"node:os";import{discoverSchema as U,readPackageDependencies as C,discoverMigrations as F}from"@lunora/codegen";import{isInteractive as O,promptSelect as P,promptText as D}from"@lunora/config";import{LunoraError as $}from"@lunora/errors";import{join as c}from"@visulima/path";import{Project as v}from"ts-morph";import{r as z,t as j}from"../packem_shared/admin-token-VdUnvnKW.mjs";import{n as q,r as L}from"../packem_shared/admin-url-BhF5ufg1.mjs";import{d as B}from"../packem_shared/command-DwC11Cwe.mjs";import{diffSnapshots as H,renderMigrationFile as G}from"../packem_shared/diffSnapshots-DtC5Cs4Z.mjs";import{r as W}from"../packem_shared/resolve-target-BRvw8Pf7.mjs";import J from"../packem_shared/schemaIrToSnapshot-e5fO6GRg.mjs";import{readAndLogBody as V}from"./runRpcCommand.mjs";import{runExportCommand as Z}from"../packem_shared/runExportCommand-Dq-SpjAe.mjs";import{r as K}from"../packem_shared/import-Dqd1MOOv.mjs";const m="__lunora_reproject__",X=e=>{if(!e.startsWith(m))return;const r=e.slice(m.length);return r===""?void 0:r},Q=".snapshot.json",A=/[^\da-z]+/gu,E=(e,r)=>{let a=0,t=e.length;for(;a<t&&e[a]===r;)a+=1;for(;t>a&&e[t-1]===r;)t-=1;return e.slice(a,t)},Y=e=>{const r=E(e.toLowerCase().replaceAll(A,"_"),"_");return r===""?"auto":r},ee=e=>{const r=(a,t=2)=>a.toString().padStart(t,"0");return`${String(e.getUTCFullYear())}${r(e.getUTCMonth()+1)}${r(e.getUTCDate())}${r(e.getUTCHours())}${r(e.getUTCMinutes())}${r(e.getUTCSeconds())}`},re=e=>{if(f(e))try{const r=k(e,"utf8"),a=JSON.parse(r);if(a.version!==1)throw new $("INTERNAL",`unsupported snapshot version: ${a.version}`);return a}catch(r){const a=r instanceof Error?r.message:String(r);throw new $("INTERNAL",`failed to read ${e}: ${a}`,{cause:r})}},te=e=>{const r=e.cwd??process.cwd(),a=c(r,"lunora","schema.ts");if(!f(a))return e.logger.error(`schema not found: ${a} — run \`vis generate lunora-table --name=<name>\` to create one`),{code:1,empty:!0,migrationFile:""};const t=new v({skipAddingFilesFromTsConfig:!0}),n=U(t,a),s=J(n),o=c(r,"lunora","migrations"),i=c(o,Q);let l;try{l=re(i)}catch(h){return e.logger.error(h instanceof Error?h.message:String(h)),{code:1,empty:!0,migrationFile:""}}const d=H(l,s);if(d.empty)return e.logger.info("no schema changes detected — snapshot is already up to date"),{code:0,empty:!0,migrationFile:""};const p=(e.now??(()=>new Date))(),w=Y(e.name??"auto"),y=`${ee(p)}_${w}.sql`,g=c(o,y);_(o,{recursive:!0});const R=G(w,d,p.toISOString());return b(g,R,"utf8"),b(i,`${JSON.stringify(s,void 0,4)}
|
|
2
2
|
`,"utf8"),e.logger.success(`wrote ${g}`),d.unsupported.length>0&&e.logger.warn(`${String(d.unsupported.length)} unsupported diff(s) — see the comment block in ${y} and write the SQL manually`),{code:0,empty:!1,migrationFile:g}},ae="migrations.ts",S=/^[A-Za-z_]\w*$/u,ne=new Set(["await","break","case","catch","class","const","continue","debugger","default","delete","do","else","enum","export","extends","false","finally","for","function","if","implements","import","in","instanceof","interface","let","new","null","package","private","protected","public","return","static","super","switch","this","throw","true","try","typeof","var","void","while","with","yield"]),T=/^import\s*\{\s*defineMigration\s*\}\s*from\s*["'](?:@lunora\/server|lunorash\/server)["'][^\n]*$/mu,oe=e=>`import { defineMigration } from "${C(e)?.has("lunorash")??!1?"lunorash/server":"@lunora/server"}";`,ie="__lunora_admin__:runMigration",se="__lunora_admin__:migrationStatus",ce="/_lunora/migrate",le=e=>E(e.trim().toLowerCase().replaceAll(A,"-"),"-"),de=e=>e.split("-").filter(r=>r.length>0).map((r,a)=>a===0?r:r.charAt(0).toUpperCase()+r.slice(1)).join(""),ue=e=>{const r=c(e,"lunora","schema.ts");if(!f(r))return[];try{const a=new v({skipAddingFilesFromTsConfig:!0});return U(a,r).tables.map(t=>t.name)}catch{return[]}},me=async e=>e.length>0?P("Which table does this migration iterate?",e.map(r=>({label:r,value:r}))):D("Target table for the migration: "),fe=async(e,r)=>{if(r.table!==void 0)return r.table;const a=r.promptTable??(O()?me:void 0);if(a===void 0){r.logger.error("migrate create requires a target table when not running interactively — re-run with --table <table>");return}const n=(await a(ue(e)))?.trim();if(n===void 0||n===""){r.logger.error("no table selected — re-run with --table <table>");return}return n},ge=async e=>{const r=e.cwd??process.cwd(),a=le(e.name);if(a==="")return e.logger.error(`invalid migration name: "${e.name}" — must contain at least one alphanumeric character`),{code:1,file:""};const t=de(a);if(!S.test(t)||ne.has(t))return e.logger.error(`invalid migration name: "${e.name}" derives the export \`${t}\`, which is not a valid identifier — pick a name that starts with a letter and isn't a reserved word`),{code:1,file:""};const n=await fe(r,e);if(n===void 0)return{code:1,file:""};if(!S.test(n))return e.logger.error(`invalid table: "${n}" — must be a valid identifier ([A-Za-z_][A-Za-z0-9_]*)`),{code:1,file:""};const s=c(r,"lunora"),o=c(s,ae);let i=f(o)?k(o,"utf8"):"";if(i.includes(`id: "${a}"`)||new RegExp(String.raw`\bexport const ${t}\b`,"u").test(i))return e.logger.error(`a migration with id "${a}" (export \`${t}\`) already exists in ${o}`),{code:1,file:""};const l=oe(r);i.trim()===""?i=`${l}
|
|
3
3
|
`:T.test(i)?i=i.replace(T,l):i=`${l}
|
|
4
4
|
${i}`;const d=`export const ${t} = defineMigration({
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{buildSchemaSnapshot as u}from"@lunora/codegen";import{validatorKindToSqlType as d}from"./diffSnapshots-DtC5Cs4Z.mjs";const f=n=>d(n.kind==="optional"&&n.inner?n.inner.kind:n.kind),m=(n,s)=>n.kind==="optional"?!0:s===void 0?!1:s.nullable===!0,p=n=>n.shardMode==="global"&&n.globalBackend!=="hyperdrive",k=n=>{const s={},c=u(n,[]);for(const o of n.tables){if(!p(o))continue;const t={};for(const[e,i]of Object.entries(o.shape)){const l=c.tables[o.name]?.fields[e],r={nullable:m(i,l),sqlType:f(i)};t[e]=l===void 0?r:{...r,field:l}}const a={};for(const e of o.indexes)a[e.name]={fields:[...e.fields],name:e.name,unique:e.unique??!1};s[o.name]={columns:t,indexes:a,name:o.name}}return{tables:s,version:1}};export{k as default};
|
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.228",
|
|
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.111",
|
|
56
|
+
"@lunora/bindings": "1.0.0-alpha.51",
|
|
57
|
+
"@lunora/codegen": "1.0.0-alpha.159",
|
|
58
|
+
"@lunora/config": "1.0.0-alpha.195",
|
|
59
59
|
"@lunora/container": "1.0.0-alpha.45",
|
|
60
|
-
"@lunora/d1": "1.0.0-alpha.
|
|
60
|
+
"@lunora/d1": "1.0.0-alpha.110",
|
|
61
61
|
"@lunora/errors": "1.0.0-alpha.32",
|
|
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.116",
|
|
63
|
+
"@lunora/runtime": "1.0.0-alpha.96",
|
|
64
|
+
"@lunora/seed": "1.0.0-alpha.109",
|
|
65
65
|
"@visulima/cerebro": "3.0.6",
|
|
66
66
|
"@visulima/error": "6.1.0",
|
|
67
67
|
"@visulima/fs": "6.0.0",
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{buildSchemaSnapshot as u}from"@lunora/codegen";import{validatorKindToSqlType as r}from"./diffSnapshots-DtC5Cs4Z.mjs";const c=e=>e.kind==="optional"&&e.inner?{nullable:!0,sqlType:r(e.inner.kind)}:{nullable:!1,sqlType:r(e.kind)},f=e=>e.shardMode==="global"&&e.globalBackend!=="hyperdrive",b=e=>{const s={},d=u(e,[]);for(const o of e.tables){if(!f(o))continue;const l={};for(const[n,a]of Object.entries(o.shape)){const i=d.tables[o.name]?.fields[n];l[n]=i===void 0?c(a):{...c(a),field:i}}const t={};for(const n of o.indexes)t[n.name]={fields:[...n.fields],name:n.name,unique:n.unique??!1};s[o.name]={columns:l,indexes:t,name:o.name}}return{tables:s,version:1}};export{b as default};
|