@vaiftech/cli 1.8.0 → 1.8.1
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/cli.cjs +9 -9
- package/dist/cli.js +9 -9
- package/package.json +1 -1
package/dist/cli.cjs
CHANGED
|
@@ -3787,10 +3787,10 @@ Use --force to overwrite existing configuration.`)),process.exit(1));try{if(U__d
|
|
|
3787
3787
|
DATABASE_URL=postgresql://user:password@localhost:5432/database
|
|
3788
3788
|
VAIF_API_KEY=your-api-key
|
|
3789
3789
|
`,"utf-8"),console.log(f__default.default.gray("Created .env.example"))),t.typescript){let r=S__default.default.resolve("src/types");U__default.default.existsSync(r)||(U__default.default.mkdirSync(r,{recursive:!0}),console.log(f__default.default.gray("Created src/types directory")));}console.log(""),console.log(f__default.default.green("VAIF initialized successfully!")),console.log(""),console.log(f__default.default.gray("Next steps:")),console.log(f__default.default.gray(" 1. Update vaif.config.json with your project ID")),console.log(f__default.default.gray(" 2. Set DATABASE_URL in your environment")),console.log(f__default.default.gray(" 3. Run: npx vaif generate")),console.log("");}}catch(n){e.fail("Failed to initialize"),n instanceof Error&&console.error(f__default.default.red(`
|
|
3790
|
-
Error: ${n.message}`)),process.exit(1);}}var Kt=process.env.VAIF_API_URL||"https://api.vaif.studio";async function zt(t,e,o="public"){let n=await fetch(`${Kt}/
|
|
3790
|
+
Error: ${n.message}`)),process.exit(1);}}var Kt=process.env.VAIF_API_URL||"https://api.vaif.studio";async function zt(t,e,o="public"){let n=await fetch(`${Kt}/projects/${e}/schema?schema=${o}`,{headers:{Authorization:`Bearer ${t}`,"Content-Type":"application/json"}});if(!n.ok){let r=await n.text();throw new Error(`Failed to fetch schema: ${r}`)}return n.json()}async function Ne(t){let e=Q__default.default(),o=I();(!o||!o.token)&&(console.log(f__default.default.red("Not logged in")),console.log(f__default.default.gray("Run `vaif login` first to authenticate")),process.exit(1));let n=t.config||"vaif.config.json",r=null;e.start("Loading configuration...");try{r=await A(n);}catch(s){e.fail("Failed to load config"),console.log(f__default.default.red(`
|
|
3791
3791
|
Error: ${s}`)),process.exit(1);}r||(e.fail("No configuration found"),console.log(f__default.default.yellow("\nRun `vaif init` to create a configuration file.")),process.exit(1));let i=t.projectId||r.projectId||process.env.VAIF_PROJECT_ID||o.projectId;i||(e.fail("No project ID specified"),console.log(f__default.default.yellow(`
|
|
3792
3792
|
Set projectId in vaif.config.json or use --project-id flag.`)),process.exit(1)),e.text="Fetching remote schema...";try{let s=t.schema||r.database?.schema||"public",a=await zt(o.token,i,s);e.succeed("Schema fetched successfully");let l=t.output||S__default.default.resolve("vaif.schema.json"),d={$schema:"https://vaif.studio/schemas/schema.json",projectId:i,schema:s,pulledAt:new Date().toISOString(),...a};U__default.default.writeFileSync(l,JSON.stringify(d,null,2),"utf-8"),console.log(""),console.log(f__default.default.green(`Schema saved to: ${l}`)),console.log(""),console.log(f__default.default.gray("Schema summary:")),console.log(f__default.default.gray(` Tables: ${(a.tables||[]).length}`)),console.log(f__default.default.gray(` Enums: ${(a.enums||[]).length}`)),console.log(f__default.default.gray(` Functions: ${(a.functions||[]).length}`)),console.log(""),console.log(f__default.default.gray("Next steps:")),console.log(f__default.default.gray(" - Run `vaif generate` to generate TypeScript types")),console.log(f__default.default.gray(" - Edit the schema and run `vaif push` to deploy changes")),console.log("");}catch(s){e.fail("Failed to fetch schema"),s instanceof Error&&console.log(f__default.default.red(`
|
|
3793
|
-
Error: ${s.message}`)),process.exit(1);}}var Ue=process.env.VAIF_API_URL||"https://api.vaif.studio";function Jt(t){let e=Ee__default.default.createInterface({input:process.stdin,output:process.stdout});return new Promise(o=>{e.question(t,n=>{e.close(),o(n);});})}async function Gt(t,e,o){let n=await fetch(`${Ue}/
|
|
3793
|
+
Error: ${s.message}`)),process.exit(1);}}var Ue=process.env.VAIF_API_URL||"https://api.vaif.studio";function Jt(t){let e=Ee__default.default.createInterface({input:process.stdin,output:process.stdout});return new Promise(o=>{e.question(t,n=>{e.close(),o(n);});})}async function Gt(t,e,o){let n=await fetch(`${Ue}/projects/${e}/schema/preview`,{method:"POST",headers:{Authorization:`Bearer ${t}`,"Content-Type":"application/json"},body:JSON.stringify({schema:o})});if(!n.ok){let r=await n.text();throw new Error(`Failed to preview changes: ${r}`)}return n.json()}async function Wt(t,e,o){let n=await fetch(`${Ue}/projects/${e}/schema/apply`,{method:"POST",headers:{Authorization:`Bearer ${t}`,"Content-Type":"application/json"},body:JSON.stringify({schema:o})});if(!n.ok){let r=await n.text();throw new Error(`Failed to apply changes: ${r}`)}return n.json()}function Ht(t){if(console.log(""),console.log(f__default.default.bold("Schema Changes:")),console.log(""),t.added.length===0&&t.modified.length===0&&t.removed.length===0){console.log(f__default.default.gray(" No changes detected. Schema is up to date."));return}if(t.added.length>0){console.log(f__default.default.green.bold(" + Added:"));for(let e of t.added)console.log(f__default.default.green(` + ${e.type}: ${e.name}`));console.log("");}if(t.modified.length>0){console.log(f__default.default.yellow.bold(" ~ Modified:"));for(let e of t.modified){console.log(f__default.default.yellow(` ~ ${e.type}: ${e.name}`));for(let o of e.changes)console.log(f__default.default.gray(` ${o}`));}console.log("");}if(t.removed.length>0){console.log(f__default.default.red.bold(" - Removed:"));for(let e of t.removed)console.log(f__default.default.red(` - ${e.type}: ${e.name}`));console.log("");}}async function $e(t){let e=Q__default.default(),o=I();(!o||!o.token)&&(console.log(f__default.default.red("Not logged in")),console.log(f__default.default.gray("Run `vaif login` first to authenticate")),process.exit(1));let n=t.config||"vaif.config.json",r=null;e.start("Loading configuration...");try{r=await A(n);}catch(l){e.fail("Failed to load config"),console.log(f__default.default.red(`
|
|
3794
3794
|
Error: ${l}`)),process.exit(1);}r||(e.fail("No configuration found"),console.log(f__default.default.yellow("\nRun `vaif init` to create a configuration file.")),process.exit(1));let i=t.projectId||r.projectId||process.env.VAIF_PROJECT_ID||o.projectId;i||(e.fail("No project ID specified"),console.log(f__default.default.yellow(`
|
|
3795
3795
|
Set projectId in vaif.config.json or use --project-id flag.`)),process.exit(1));let s=t.schema||S__default.default.resolve("vaif.schema.json");U__default.default.existsSync(s)||(e.fail("No local schema found"),console.log(f__default.default.yellow(`
|
|
3796
3796
|
Expected schema file at: ${s}`)),console.log(f__default.default.gray("Run `vaif pull` first to fetch the current schema.")),process.exit(1));let a;try{let l=U__default.default.readFileSync(s,"utf-8");a=JSON.parse(l);}catch(l){e.fail("Failed to parse schema file"),l instanceof Error&&console.log(f__default.default.red(`
|
|
@@ -3801,23 +3801,23 @@ Place your functions in:`)),console.log(f__default.default.gray(" - ./functions
|
|
|
3801
3801
|
Or specify an entrypoint with --entrypoint`)),process.exit(1)),e.succeed(`Found ${l.length} function(s)`),t.name&&(l=l.filter(c=>S__default.default.basename(c,S__default.default.extname(c)).includes(t.name)),l.length===0&&(console.log(f__default.default.yellow(`
|
|
3802
3802
|
No functions matching "${t.name}" found`)),process.exit(1))),console.log(""),console.log(f__default.default.gray("Functions to deploy:"));for(let c of l){let g=S__default.default.basename(S__default.default.dirname(c)),h=g==="functions"||g==="src"?S__default.default.basename(c,S__default.default.extname(c)):g,E=t.runtime||Oe(c);console.log(f__default.default.gray(` - ${h} (${E})`));}if(console.log(""),t.dryRun){console.log(f__default.default.yellow("Dry run mode - no functions deployed."));return}let d=[];for(let c of l){let g=S__default.default.basename(S__default.default.dirname(c)),h=g==="functions"||g==="src"?S__default.default.basename(c,S__default.default.extname(c)):g,E=t.runtime||Oe(c);e.start(`Deploying ${h}...`);try{let N=U__default.default.readFileSync(c,"utf-8"),$=await Xt(o.token,i,h,t.envId);$||(e.text=`Creating ${h}...`,$=await Qt(o.token,i,{name:h,runtime:E,entrypoint:S__default.default.basename(c),envId:t.envId})),e.text=`Deploying ${h}...`,await Zt(o.token,$.id,N),e.succeed(`Deployed ${h}`),d.push({name:h,success:!0});}catch(N){let $=N instanceof Error?N.message:"Unknown error";e.fail(`Failed to deploy ${h}`),d.push({name:h,success:false,error:$});}}console.log("");let u=d.filter(c=>c.success).length;if(d.filter(c=>!c.success).length===0)console.log(f__default.default.green(`\u2713 Successfully deployed ${u} function(s)`));else {console.log(f__default.default.yellow(`Deployed ${u}/${d.length} function(s)`)),console.log(""),console.log(f__default.default.red("Failed deployments:"));for(let c of d.filter(g=>!g.success))console.log(f__default.default.red(` - ${c.name}: ${c.error}`));}console.log("");}async function Be(t){let e=Q__default.default(),o=I();(!o||!o.token)&&(console.log(f__default.default.red("Not logged in")),console.log(f__default.default.gray("Run `vaif login` first to authenticate")),process.exit(1));let n=t.config||"vaif.config.json",r=null;try{r=await A(n);}catch{}let i=t.projectId||r?.projectId||process.env.VAIF_PROJECT_ID||o.projectId;i||(console.log(f__default.default.red("No project ID specified")),process.exit(1)),e.start("Fetching functions...");try{let s=await eo(o.token,i,t.envId);if(e.stop(),s.length===0){console.log(f__default.default.yellow(`
|
|
3803
3803
|
No functions found`)),console.log(f__default.default.gray("Deploy your first function with: vaif functions deploy"));return}console.log(""),console.log(f__default.default.bold(`Functions (${s.length}):`)),console.log(""),console.log(f__default.default.gray(" "+"NAME".padEnd(25)+"RUNTIME".padEnd(15)+"STATUS".padEnd(12)+"INVOCATIONS".padEnd(14)+"LAST DEPLOYED")),console.log(f__default.default.gray(" "+"-".repeat(80)));for(let a of s){let l=a.deployStatus==="deployed"?f__default.default.green:a.deployStatus==="deploying"?f__default.default.yellow:a.deployStatus==="failed"?f__default.default.red:f__default.default.gray;console.log(" "+a.name.padEnd(25)+a.runtime.padEnd(15)+l(a.deployStatus.padEnd(12))+String(a.invocationCount??0).padEnd(14)+(a.deployedAt?new Date(a.deployedAt).toLocaleDateString():"-"));}console.log("");}catch(s){e.fail("Failed to fetch functions"),s instanceof Error&&console.log(f__default.default.red(`
|
|
3804
|
-
Error: ${s.message}`)),process.exit(1);}}var Z=process.env.VAIF_API_URL||"https://api.vaif.studio";async function to(t,e,o,n,r){let i=await fetch(`${Z}/
|
|
3804
|
+
Error: ${s.message}`)),process.exit(1);}}var Z=process.env.VAIF_API_URL||"https://api.vaif.studio";async function to(t,e,o,n,r){let i=await fetch(`${Z}/projects/${e}/db/seed`,{method:"POST",headers:{Authorization:`Bearer ${t}`,"Content-Type":"application/json"},body:JSON.stringify({table:o,records:n,truncate:r?.truncate??false})});if(!i.ok){let s=await i.text();throw new Error(`Failed to seed ${o}: ${s}`)}return i.json()}async function oo(t,e){let o=await fetch(`${Z}/projects/${e}/db/reset`,{method:"POST",headers:{Authorization:`Bearer ${t}`,"Content-Type":"application/json"}});if(!o.ok){let n=await o.text();throw new Error(`Failed to reset database: ${n}`)}return o.json()}function ge(t){let e=[];if(!U__default.default.existsSync(t))return e;let o=U__default.default.readdirSync(t,{withFileTypes:true});for(let n of o)if(n.isFile()){let r=S__default.default.extname(n.name).toLowerCase();(r===".json"||r===".ts"||r===".js")&&e.push(S__default.default.join(t,n.name));}return e.sort()}async function qe(t){let e=S__default.default.extname(t).toLowerCase();if(e===".json"){let o=U__default.default.readFileSync(t,"utf-8"),n=JSON.parse(o);return Array.isArray(n)?[{table:S__default.default.basename(t,e),data:n}]:n.table&&n.data?[n]:Object.entries(n).map(([r,i])=>({table:r,data:i}))}else if(e===".ts"||e===".js"){let o=await import(t),n=o.default||o;return typeof n=="function"?n():n}throw new Error(`Unsupported file format: ${e}`)}async function Ye(t){let e=Q__default.default(),o=I();(!o||!o.token)&&(console.log(f__default.default.red("Not logged in")),console.log(f__default.default.gray("Run `vaif login` first to authenticate")),process.exit(1));let n=t.config||"vaif.config.json",r=null;try{r=await A(n);}catch{}let i=t.projectId||r?.projectId||process.env.VAIF_PROJECT_ID||o.projectId;i||(console.log(f__default.default.red("No project ID specified")),console.log(f__default.default.yellow("Set projectId in vaif.config.json or use --project-id flag.")),process.exit(1)),console.log(""),console.log(f__default.default.bold("VAIF Database Seed")),console.log("");let s=[];if(t.file){let u=S__default.default.resolve(t.file);U__default.default.existsSync(u)||(console.log(f__default.default.red(`File not found: ${t.file}`)),process.exit(1)),s=[u];}else {let u=S__default.default.resolve("seeds"),p=S__default.default.resolve("prisma/seed"),c=S__default.default.resolve("db/seeds");s=[...ge(u),...ge(p),...ge(c)];}s.length===0&&(console.log(f__default.default.yellow("No seed files found")),console.log(f__default.default.gray(`
|
|
3805
3805
|
Place your seed files in one of these directories:`)),console.log(f__default.default.gray(" - ./seeds/")),console.log(f__default.default.gray(" - ./prisma/seed/")),console.log(f__default.default.gray(" - ./db/seeds/")),console.log(f__default.default.gray(`
|
|
3806
3806
|
Or specify a file with --file`)),console.log(f__default.default.gray(`
|
|
3807
3807
|
Example seed file (seeds/users.json):`)),console.log(f__default.default.gray(" [")),console.log(f__default.default.gray(' { "name": "John Doe", "email": "john@example.com" },')),console.log(f__default.default.gray(' { "name": "Jane Doe", "email": "jane@example.com" }')),console.log(f__default.default.gray(" ]")),process.exit(1)),console.log(f__default.default.gray("Seed files found:"));for(let u of s)console.log(f__default.default.gray(` - ${S__default.default.relative(process.cwd(),u)}`));if(console.log(""),t.truncate&&(console.log(f__default.default.yellow("\u26A0\uFE0F Tables will be truncated before seeding")),console.log("")),t.dryRun){console.log(f__default.default.yellow("Dry run mode - no data will be inserted.")),console.log("");for(let u of s){e.start(`Loading ${S__default.default.basename(u)}...`);try{let p=await qe(u);e.stop();for(let c of p)t.table&&c.table!==t.table||(console.log(f__default.default.cyan(`Table: ${c.table}`)),console.log(f__default.default.gray(` Records: ${c.data.length}`)),c.data.length>0&&console.log(f__default.default.gray(` Sample: ${JSON.stringify(c.data[0],null,2).slice(0,100)}...`)),console.log(""));}catch(p){e.fail(`Failed to load ${S__default.default.basename(u)}`),p instanceof Error&&console.log(f__default.default.red(` Error: ${p.message}`));}}return}let a=[];for(let u of s){e.start(`Processing ${S__default.default.basename(u)}...`);try{let p=await qe(u);e.stop();for(let c of p)if(!(t.table&&c.table!==t.table)){if(c.data.length===0){console.log(f__default.default.gray(` Skipping ${c.table} (no records)`));continue}e.start(`Seeding ${c.table} (${c.data.length} records)...`);try{let g=await to(o.token,i,c.table,c.data,{truncate:t.truncate});e.succeed(`Seeded ${c.table}: ${g.inserted} records`),a.push({table:c.table,inserted:g.inserted});}catch(g){let h=g instanceof Error?g.message:"Unknown error";e.fail(`Failed to seed ${c.table}`),a.push({table:c.table,inserted:0,error:h});}}}catch(p){e.fail(`Failed to load ${S__default.default.basename(u)}`),p instanceof Error&&console.log(f__default.default.red(` Error: ${p.message}`));}}console.log("");let l=a.reduce((u,p)=>u+p.inserted,0),d=a.filter(u=>u.error).length;if(d===0)console.log(f__default.default.green(`\u2713 Successfully seeded ${l} records across ${a.length} table(s)`));else {console.log(f__default.default.yellow(`Seeded ${l} records with ${d} error(s)`)),console.log(""),console.log(f__default.default.red("Errors:"));for(let u of a.filter(p=>p.error))console.log(f__default.default.red(` - ${u.table}: ${u.error}`));}console.log("");}async function Je(t){let e=Q__default.default(),o=I();(!o||!o.token)&&(console.log(f__default.default.red("Not logged in")),console.log(f__default.default.gray("Run `vaif login` first to authenticate")),process.exit(1));let n=t.config||"vaif.config.json",r=null;try{r=await A(n);}catch{}let i=t.projectId||r?.projectId||process.env.VAIF_PROJECT_ID||o.projectId;i||(console.log(f__default.default.red("No project ID specified")),console.log(f__default.default.yellow("Set projectId in vaif.config.json or use --project-id flag.")),process.exit(1));let s=S__default.default.resolve(t.dir||"./drizzle");if(console.log(""),console.log(f__default.default.bold("VAIF Database Push")),console.log(""),!U__default.default.existsSync(s)){let p=S__default.default.resolve("./migrations");U__default.default.existsSync(p)?console.log(f__default.default.gray(`Using migrations from: ${p}`)):(console.log(f__default.default.red(`Migrations directory not found: ${s}`)),console.log(f__default.default.gray(`
|
|
3808
3808
|
Expected one of:`)),console.log(f__default.default.gray(" - ./drizzle/")),console.log(f__default.default.gray(" - ./migrations/")),console.log(f__default.default.gray(`
|
|
3809
3809
|
Or specify with: vaif db push --dir <path>`)),process.exit(1));}let a=[],l=U__default.default.readdirSync(s,{withFileTypes:true});for(let p of l)if(p.isFile()&&p.name.endsWith(".sql"))a.push(S__default.default.join(s,p.name));else if(p.isDirectory()){let c=U__default.default.readdirSync(S__default.default.join(s,p.name),{withFileTypes:true});for(let g of c)g.isFile()&&g.name.endsWith(".sql")&&a.push(S__default.default.join(s,p.name,g.name));}a.sort(),a.length===0&&(console.log(f__default.default.yellow("No SQL migration files found")),process.exit(1)),console.log(f__default.default.gray(`Found ${a.length} migration(s):`));for(let p of a)console.log(f__default.default.gray(` - ${S__default.default.relative(process.cwd(),p)}`));if(console.log(""),t.dryRun){console.log(f__default.default.yellow("Dry run mode - no migrations will be applied.")),console.log("");for(let p of a){let c=U__default.default.readFileSync(p,"utf-8");console.log(f__default.default.cyan(`--- ${S__default.default.basename(p)} ---`)),console.log(f__default.default.gray(c.slice(0,500))),c.length>500&&console.log(f__default.default.gray("...")),console.log("");}return}let d=0,u=0;for(let p of a){let c=U__default.default.readFileSync(p,"utf-8"),g=S__default.default.relative(process.cwd(),p);e.start(`Applying ${g}...`);try{let h=await fetch(`${Z}/schema-engine/query/${i}`,{method:"POST",headers:{Authorization:`Bearer ${o.token}`,"Content-Type":"application/json"},body:JSON.stringify({sql:c})});if(!h.ok){let E=await h.text();throw new Error(E)}e.succeed(`Applied ${g}`),d++;}catch(h){let E=h instanceof Error?h.message:"Unknown error";e.fail(`Failed ${g}: ${E}`),u++;}}console.log(""),console.log(u===0?f__default.default.green(`Successfully applied ${d} migration(s)`):f__default.default.yellow(`Applied ${d}, failed ${u} migration(s)`)),console.log("");}async function Ge(t){let e=Q__default.default(),o=I();(!o||!o.token)&&(console.log(f__default.default.red("Not logged in")),console.log(f__default.default.gray("Run `vaif login` first to authenticate")),process.exit(1));let n=t.config||"vaif.config.json",r=null;try{r=await A(n);}catch{}let i=t.projectId||r?.projectId||process.env.VAIF_PROJECT_ID||o.projectId;i||(console.log(f__default.default.red("No project ID specified")),console.log(f__default.default.yellow("Set projectId in vaif.config.json or use --project-id flag.")),process.exit(1));let s=S__default.default.resolve(t.output||"vaif.schema.json");console.log(""),console.log(f__default.default.bold("VAIF Database Pull")),console.log(""),e.start("Pulling schema from remote...");try{let a=await fetch(`${Z}/schema-engine/introspect/${i}`,{headers:{Authorization:`Bearer ${o.token}`}});if(!a.ok){let u=await a.text();throw new Error(`Failed to pull schema: ${u}`)}let l=await a.json();U__default.default.writeFileSync(s,JSON.stringify(l,null,2),"utf-8"),e.succeed(`Schema written to ${S__default.default.relative(process.cwd(),s)}`);let d=l.tables?.length??Object.keys(l).length;console.log(f__default.default.gray(` ${d} table(s) pulled`)),console.log("");}catch(a){e.fail("Failed to pull schema"),a instanceof Error&&console.log(f__default.default.red(`
|
|
3810
3810
|
Error: ${a.message}`)),process.exit(1);}}async function We(t){let e=Q__default.default(),o=I();(!o||!o.token)&&(console.log(f__default.default.red("Not logged in")),console.log(f__default.default.gray("Run `vaif login` first to authenticate")),process.exit(1));let n=t.config||"vaif.config.json",r=null;try{r=await A(n);}catch{}let i=t.projectId||r?.projectId||process.env.VAIF_PROJECT_ID||o.projectId;i||(console.log(f__default.default.red("No project ID specified")),process.exit(1)),console.log(""),console.log(f__default.default.red.bold("\u26A0\uFE0F DATABASE RESET")),console.log(""),console.log(f__default.default.red("This will:")),console.log(f__default.default.red(" - Drop all tables")),console.log(f__default.default.red(" - Delete all data")),console.log(f__default.default.red(" - Reset migrations")),console.log(""),console.log(f__default.default.red.bold("This action cannot be undone!")),console.log(""),t.force||(console.log(f__default.default.yellow("Use --force to confirm this action.")),process.exit(1)),e.start("Resetting database...");try{await oo(o.token,i),e.succeed("Database reset complete"),console.log(""),console.log(f__default.default.gray("Your database is now empty.")),console.log(f__default.default.gray("Run `vaif push` to apply your schema, then `vaif db seed` to seed data.")),console.log("");}catch(s){e.fail("Failed to reset database"),s instanceof Error&&console.log(f__default.default.red(`
|
|
3811
|
-
Error: ${s.message}`)),process.exit(1);}}var Xe=process.env.VAIF_API_URL||"https://api.vaif.studio";function Qe(t,e,o){return t.projectId||e?.projectId||process.env.VAIF_PROJECT_ID||o.projectId||null}async function Ze(t){let e=Q__default.default(),o=I();(!o||!o.token)&&(console.log(f__default.default.red("Not logged in")),console.log(f__default.default.gray("Run `vaif login` first to authenticate")),process.exit(1));let n=t.config||"vaif.config.json",r=null;try{r=await A(n);}catch{}let i=Qe(t,r,o);i||(console.log(f__default.default.red("No project ID specified")),console.log(f__default.default.yellow("Set projectId in vaif.config.json or use --project-id flag.")),process.exit(1));let s=t.name||`cli-key-${Date.now()}`;console.log(""),console.log(f__default.default.bold("VAIF Generate API Key")),console.log(""),e.start("Generating API key...");try{let a=await fetch(`${Xe}/
|
|
3812
|
-
Error: ${a.message}`)),process.exit(1);}}async function et(t){let e=Q__default.default(),o=I();(!o||!o.token)&&(console.log(f__default.default.red("Not logged in")),console.log(f__default.default.gray("Run `vaif login` first to authenticate")),process.exit(1));let n=t.config||"vaif.config.json",r=null;try{r=await A(n);}catch{}let i=Qe(t,r,o);i||(console.log(f__default.default.red("No project ID specified")),console.log(f__default.default.yellow("Set projectId in vaif.config.json or use --project-id flag.")),process.exit(1)),console.log(""),console.log(f__default.default.bold("VAIF API Keys")),console.log(""),e.start("Fetching API keys...");try{let s=await fetch(`${Xe}/
|
|
3811
|
+
Error: ${s.message}`)),process.exit(1);}}var Xe=process.env.VAIF_API_URL||"https://api.vaif.studio";function Qe(t,e,o){return t.projectId||e?.projectId||process.env.VAIF_PROJECT_ID||o.projectId||null}async function Ze(t){let e=Q__default.default(),o=I();(!o||!o.token)&&(console.log(f__default.default.red("Not logged in")),console.log(f__default.default.gray("Run `vaif login` first to authenticate")),process.exit(1));let n=t.config||"vaif.config.json",r=null;try{r=await A(n);}catch{}let i=Qe(t,r,o);i||(console.log(f__default.default.red("No project ID specified")),console.log(f__default.default.yellow("Set projectId in vaif.config.json or use --project-id flag.")),process.exit(1));let s=t.name||`cli-key-${Date.now()}`;console.log(""),console.log(f__default.default.bold("VAIF Generate API Key")),console.log(""),e.start("Generating API key...");try{let a=await fetch(`${Xe}/projects/${i}/api-keys`,{method:"POST",headers:{Authorization:`Bearer ${o.token}`,"Content-Type":"application/json"},body:JSON.stringify({name:s})});if(!a.ok){let d=await a.text();throw new Error(`Failed to generate key: ${d}`)}let l=await a.json();e.succeed("API key generated"),console.log(""),console.log(f__default.default.green(` Name: ${l.name}`)),console.log(f__default.default.green(` Key: ${l.key}`)),console.log(""),console.log(f__default.default.yellow.bold(" Save this key now - it will not be shown again!")),console.log("");}catch(a){e.fail("Failed to generate API key"),a instanceof Error&&console.log(f__default.default.red(`
|
|
3812
|
+
Error: ${a.message}`)),process.exit(1);}}async function et(t){let e=Q__default.default(),o=I();(!o||!o.token)&&(console.log(f__default.default.red("Not logged in")),console.log(f__default.default.gray("Run `vaif login` first to authenticate")),process.exit(1));let n=t.config||"vaif.config.json",r=null;try{r=await A(n);}catch{}let i=Qe(t,r,o);i||(console.log(f__default.default.red("No project ID specified")),console.log(f__default.default.yellow("Set projectId in vaif.config.json or use --project-id flag.")),process.exit(1)),console.log(""),console.log(f__default.default.bold("VAIF API Keys")),console.log(""),e.start("Fetching API keys...");try{let s=await fetch(`${Xe}/projects/${i}/api-keys`,{headers:{Authorization:`Bearer ${o.token}`}});if(!s.ok){let p=await s.text();throw new Error(`Failed to list keys: ${p}`)}let a=await s.json(),l=a.keys||a;if(e.stop(),!Array.isArray(l)||l.length===0){console.log(f__default.default.yellow("No API keys found")),console.log(f__default.default.gray(`
|
|
3813
3813
|
Generate one with: vaif keys generate`));return}let d=Math.max(8,...l.map(p=>(p.name||"").length)),u=` ${"Name".padEnd(d)} ${"Key".padEnd(24)} Created`;console.log(f__default.default.gray(u)),console.log(f__default.default.gray(" "+"-".repeat(u.length-2)));for(let p of l){let c=(p.name||"unnamed").padEnd(d),g=p.maskedKey||p.prefix||`${(p.key||"").slice(0,12)}...`,h=p.createdAt?new Date(p.createdAt).toLocaleDateString():"N/A";console.log(` ${c} ${g.padEnd(24)} ${h}`);}console.log(""),console.log(f__default.default.gray(` ${l.length} key(s) total`)),console.log("");}catch(s){e.fail("Failed to list API keys"),s instanceof Error&&console.log(f__default.default.red(`
|
|
3814
3814
|
Error: ${s.message}`)),process.exit(1);}}var z=process.env.VAIF_API_URL||"https://api.vaif.studio";function ao(t,e,o){return t.projectId||e?.projectId||process.env.VAIF_PROJECT_ID||o.projectId||null}function te(){let t=I();return (!t||!t.token)&&(console.log(f__default.default.red("Not logged in")),console.log(f__default.default.gray("Run `vaif login` first to authenticate")),process.exit(1)),t}async function oe(t){try{return await A(t||"vaif.config.json")}catch{return null}}function ne(t,e,o){let n=ao(t,e,o);return n||(console.log(f__default.default.red("No project ID specified")),console.log(f__default.default.yellow("Set projectId in vaif.config.json or use --project-id flag.")),process.exit(1)),n}async function tt(t,e,o){let n=Q__default.default(),r=te(),i=await oe(o.config),s=ne(o,i,r),a=e;if(o.fromFile)try{a=U__default.default.readFileSync(o.fromFile,"utf-8");}catch(l){console.log(f__default.default.red(`Failed to read file: ${o.fromFile}`)),l instanceof Error&&console.log(f__default.default.gray(l.message)),process.exit(1);}a||(console.log(f__default.default.red("No value provided")),console.log(f__default.default.gray("Provide a value as argument or use --from-file <path>")),process.exit(1)),console.log(""),console.log(f__default.default.bold("VAIF Set Secret")),console.log(""),n.start("Checking for existing secret...");try{let l=new URL(`${z}/functions/secrets/project/${s}`);o.envId&&l.searchParams.set("envId",o.envId);let d=await fetch(l.toString(),{headers:{Authorization:`Bearer ${r.token}`}});if(!d.ok)throw new Error(`Failed to check existing secrets: ${await d.text()}`);let p=(await d.json()).find(c=>c.key===t);if(p){n.text=`Updating secret "${t}"...`;let c=await fetch(`${z}/functions/secrets/${p.id}`,{method:"PUT",headers:{Authorization:`Bearer ${r.token}`,"Content-Type":"application/json"},body:JSON.stringify({value:a})});if(!c.ok)throw new Error(`Failed to update secret: ${await c.text()}`);n.succeed(`Updated secret "${t}"`);}else {n.text=`Creating secret "${t}"...`;let c=await fetch(`${z}/functions/secrets`,{method:"POST",headers:{Authorization:`Bearer ${r.token}`,"Content-Type":"application/json"},body:JSON.stringify({projectId:s,envId:o.envId,key:t,value:a})});if(!c.ok)throw new Error(`Failed to create secret: ${await c.text()}`);n.succeed(`Created secret "${t}"`);}console.log("");}catch(l){n.fail("Failed to set secret"),l instanceof Error&&console.log(f__default.default.red(`
|
|
3815
3815
|
Error: ${l.message}`)),process.exit(1);}}async function ot(t){let e=Q__default.default(),o=te(),n=await oe(t.config),r=ne(t,n,o);console.log(""),console.log(f__default.default.bold("VAIF Secrets")),console.log(""),e.start("Fetching secrets...");try{let i=new URL(`${z}/functions/secrets/project/${r}`);t.envId&&i.searchParams.set("envId",t.envId);let s=await fetch(i.toString(),{headers:{Authorization:`Bearer ${o.token}`}});if(!s.ok)throw new Error(`Failed to list secrets: ${await s.text()}`);let a=await s.json();if(e.stop(),a.length===0){console.log(f__default.default.yellow("No secrets found")),console.log(f__default.default.gray(`
|
|
3816
3816
|
Create one with: vaif secrets set <name> <value>`));return}let l=Math.max(8,...a.map(u=>u.key.length)),d=` ${"Name".padEnd(l)} Created`;console.log(f__default.default.gray(d)),console.log(f__default.default.gray(" "+"-".repeat(d.length-2)));for(let u of a){let p=u.key.padEnd(l),c=u.createdAt?new Date(u.createdAt).toLocaleDateString():"N/A";console.log(` ${p} ${c}`);}console.log(""),console.log(f__default.default.gray(` ${a.length} secret(s) total`)),console.log(f__default.default.gray(" Values are hidden. Use `vaif secrets get <name>` to reveal.")),console.log("");}catch(i){e.fail("Failed to list secrets"),i instanceof Error&&console.log(f__default.default.red(`
|
|
3817
3817
|
Error: ${i.message}`)),process.exit(1);}}async function nt(t,e){let o=Q__default.default(),n=te(),r=await oe(e.config),i=ne(e,r,n);console.log(""),o.start("Fetching secret...");try{let s=new URL(`${z}/functions/secrets/project/${i}`);e.envId&&s.searchParams.set("envId",e.envId);let a=await fetch(s.toString(),{headers:{Authorization:`Bearer ${n.token}`}});if(!a.ok)throw new Error(`Failed to fetch secrets: ${await a.text()}`);let d=(await a.json()).find(c=>c.key===t);d||(o.fail(`Secret "${t}" not found`),process.exit(1));let u=await fetch(`${z}/functions/secrets/${d.id}/value`,{headers:{Authorization:`Bearer ${n.token}`}});if(!u.ok)throw new Error(`Failed to get secret value: ${await u.text()}`);let p=await u.json();o.stop(),console.log(p.value);}catch(s){o.fail("Failed to get secret"),s instanceof Error&&console.log(f__default.default.red(`
|
|
3818
3818
|
Error: ${s.message}`)),process.exit(1);}}async function at(t,e){let o=Q__default.default(),n=te(),r=await oe(e.config),i=ne(e,r,n);console.log(""),console.log(f__default.default.bold("VAIF Delete Secret")),console.log(""),o.start("Finding secret...");try{let s=new URL(`${z}/functions/secrets/project/${i}`);e.envId&&s.searchParams.set("envId",e.envId);let a=await fetch(s.toString(),{headers:{Authorization:`Bearer ${n.token}`}});if(!a.ok)throw new Error(`Failed to fetch secrets: ${await a.text()}`);let d=(await a.json()).find(p=>p.key===t);d||(o.fail(`Secret "${t}" not found`),process.exit(1)),o.text=`Deleting secret "${t}"...`;let u=await fetch(`${z}/functions/secrets/${d.id}`,{method:"DELETE",headers:{Authorization:`Bearer ${n.token}`}});if(!u.ok)throw new Error(`Failed to delete secret: ${await u.text()}`);o.succeed(`Deleted secret "${t}"`),console.log("");}catch(s){o.fail("Failed to delete secret"),s instanceof Error&&console.log(f__default.default.red(`
|
|
3819
|
-
Error: ${s.message}`)),process.exit(1);}}var it=process.env.VAIF_API_URL||"https://api.vaif.studio";function so(t){try{let e=new URL(t);return e.password&&(e.password="****"),e.toString()}catch{return t.replace(/:[^@/]+@/,":****@")}}async function st(t){let e=Q__default.default(),o=I();(!o||!o.token)&&(console.log(f__default.default.red("Not logged in")),console.log(f__default.default.gray("Run `vaif login` first to authenticate")),process.exit(1));let n=t.config||"vaif.config.json",r=null;try{r=await A(n);}catch{}let i=t.projectId||r?.projectId||process.env.VAIF_PROJECT_ID||o.projectId;i||(console.log(f__default.default.red("No project ID specified")),console.log(f__default.default.yellow("Set projectId in vaif.config.json or use --project-id flag.")),process.exit(1)),e.start("Fetching project info...");try{let s=await fetch(`${it}/
|
|
3820
|
-
Error: ${s.message}`)),process.exit(1);}}var lo=process.env.VAIF_API_URL||"https://api.vaif.studio";async function rt(t){let e=Q__default.default(),o=I();(!o||!o.token)&&(console.log(f__default.default.red("Not logged in")),console.log(f__default.default.gray("Run `vaif login` first to authenticate")),process.exit(1));let n=t.config||"vaif.config.json",r=null;try{r=await A(n);}catch{}let i=t.projectId||r?.projectId||process.env.VAIF_PROJECT_ID||o.projectId;i||(console.log(f__default.default.red("No project ID specified")),console.log(f__default.default.yellow("Set projectId in vaif.config.json or use --project-id flag.")),process.exit(1)),e.start("Fetching project status...");try{let s=await fetch(`${lo}/
|
|
3819
|
+
Error: ${s.message}`)),process.exit(1);}}var it=process.env.VAIF_API_URL||"https://api.vaif.studio";function so(t){try{let e=new URL(t);return e.password&&(e.password="****"),e.toString()}catch{return t.replace(/:[^@/]+@/,":****@")}}async function st(t){let e=Q__default.default(),o=I();(!o||!o.token)&&(console.log(f__default.default.red("Not logged in")),console.log(f__default.default.gray("Run `vaif login` first to authenticate")),process.exit(1));let n=t.config||"vaif.config.json",r=null;try{r=await A(n);}catch{}let i=t.projectId||r?.projectId||process.env.VAIF_PROJECT_ID||o.projectId;i||(console.log(f__default.default.red("No project ID specified")),console.log(f__default.default.yellow("Set projectId in vaif.config.json or use --project-id flag.")),process.exit(1)),e.start("Fetching project info...");try{let s=await fetch(`${it}/projects/${i}`,{headers:{Authorization:`Bearer ${o.token}`}});if(!s.ok){let u=await s.text();throw new Error(`Failed to fetch project: ${u}`)}let a=await s.json();e.stop(),console.log(""),console.log(f__default.default.bold("VAIF Project Info")),console.log("");let l=16,d=(u,p)=>{console.log(` ${f__default.default.gray(u.padEnd(l))} ${p}`);};d("Name:",f__default.default.white(a.name||"N/A")),d("Project ID:",f__default.default.white(i)),d("Region:",f__default.default.white(a.region||"us-east-1")),d("Plan:",f__default.default.white(a.plan||a.tier||"free")),d("Created:",f__default.default.white(a.createdAt?new Date(a.createdAt).toLocaleDateString():"N/A")),console.log(""),d("API URL:",f__default.default.cyan(a.apiUrl||`${it}/v1`)),d("WS URL:",f__default.default.cyan(a.wsUrl||a.realtimeUrl||"N/A")),d("DB URL:",f__default.default.cyan(a.databaseUrl?so(a.databaseUrl):"N/A")),d("Storage URL:",f__default.default.cyan(a.storageUrl||"N/A")),console.log("");}catch(s){e.fail("Failed to fetch project info"),s instanceof Error&&console.log(f__default.default.red(`
|
|
3820
|
+
Error: ${s.message}`)),process.exit(1);}}var lo=process.env.VAIF_API_URL||"https://api.vaif.studio";async function rt(t){let e=Q__default.default(),o=I();(!o||!o.token)&&(console.log(f__default.default.red("Not logged in")),console.log(f__default.default.gray("Run `vaif login` first to authenticate")),process.exit(1));let n=t.config||"vaif.config.json",r=null;try{r=await A(n);}catch{}let i=t.projectId||r?.projectId||process.env.VAIF_PROJECT_ID||o.projectId;i||(console.log(f__default.default.red("No project ID specified")),console.log(f__default.default.yellow("Set projectId in vaif.config.json or use --project-id flag.")),process.exit(1)),e.start("Fetching project status...");try{let s=await fetch(`${lo}/projects/${i}?include=tables,functions,storage,connections`,{headers:{Authorization:`Bearer ${o.token}`}});if(!s.ok){let h=await s.text();throw new Error(`Failed to fetch project status: ${h}`)}let a=await s.json();e.stop(),console.log(""),console.log(f__default.default.bold("VAIF Project Status")),console.log("");let l=22,d=(h,E)=>{console.log(` ${f__default.default.gray(h.padEnd(l))} ${E}`);};d("Project:",f__default.default.white(a.name||i)),d("Plan:",f__default.default.white(a.plan||a.tier||"free")),console.log(""),console.log(f__default.default.gray(" --- Resources ---")),console.log("");let u=a.tableCount??a.tables?.length??"N/A",p=a.functionCount??a.functions?.length??"N/A",c=a.bucketCount??a.storage?.buckets?.length??"N/A",g=a.activeConnections??a.connections??"N/A";d("Tables:",f__default.default.white(String(u))),d("Functions:",f__default.default.white(String(p))),d("Storage Buckets:",f__default.default.white(String(c))),d("Active Connections:",f__default.default.white(String(g))),a.usage&&(console.log(""),console.log(f__default.default.gray(" --- Usage ---")),console.log(""),a.usage.dbSize&&d("Database Size:",f__default.default.white(a.usage.dbSize)),a.usage.storageSize&&d("Storage Size:",f__default.default.white(a.usage.storageSize)),a.usage.bandwidth&&d("Bandwidth:",f__default.default.white(a.usage.bandwidth)),a.usage.functionInvocations!=null&&d("Function Invocations:",f__default.default.white(String(a.usage.functionInvocations)))),console.log("");}catch(s){e.fail("Failed to fetch project status"),s instanceof Error&&console.log(f__default.default.red(`
|
|
3821
3821
|
Error: ${s.message}`)),process.exit(1);}}var G=process.env.VAIF_API_URL||"https://api.vaif.studio";function po(t,e,o){return t.projectId||e?.projectId||process.env.VAIF_PROJECT_ID||o.projectId||null}function uo(t){if(!t||t.length===0)return "*No tables found. Create tables in the VAIF Studio dashboard.*";let e="";for(let o of t){e+=`### \`${o.name}\`
|
|
3822
3822
|
|
|
3823
3823
|
`,e+=`| Column | Type | Nullable | Default | Constraints |
|
|
@@ -4010,5 +4010,5 @@ All authenticated requests require:
|
|
|
4010
4010
|
- \`Authorization: Bearer <jwt_token>\` \u2014 for user-scoped requests
|
|
4011
4011
|
- \`x-api-key: <api_key>\` \u2014 for server-side / service-role requests
|
|
4012
4012
|
- \`x-project-id: ${e}\` \u2014 identifies the project
|
|
4013
|
-
`}async function ct(t){let e=Q__default.default(),o=I();(!o||!o.token)&&(console.log(f__default.default.red("Not logged in")),console.log(f__default.default.gray("Run `vaif login` first to authenticate")),process.exit(1));let n=t.config||"vaif.config.json",r=null;try{r=await A(n);}catch{}let i=po(t,r,o);i||(console.log(f__default.default.red("No project ID specified")),console.log(f__default.default.yellow("Set projectId in vaif.config.json or use --project-id flag.")),process.exit(1));let s=S__default.default.resolve(t.outputDir||".");console.log(""),console.log(f__default.default.bold("VAIF Claude Code Setup")),console.log(f__default.default.gray(` Project: ${i}`)),console.log(""),e.start("Fetching database schema...");let a={tables:[]};try{let p=await fetch(`${G}/schema-engine/introspect/${i}`,{headers:{Authorization:`Bearer ${o.token}`}});p.ok?(a=await p.json(),e.succeed(`Fetched schema (${a.tables?.length||0} tables)`)):e.warn("Could not fetch schema \u2014 continuing without it");}catch{e.warn("Could not fetch schema \u2014 continuing without it");}e.start("Fetching project info...");let l=i,d=G;try{let p=await fetch(`${G}/
|
|
4014
|
-
`,"utf-8"),e.succeed(`Written ${f__default.default.cyan(".mcp.json")}`);}if(!t.skipClaudeMd){e.start("Writing CLAUDE.md...");let p=mo({projectId:i,apiKey:u,apiUrl:d,projectName:l,schema:a}),c=S__default.default.join(s,"CLAUDE.md");U__default.default.writeFileSync(c,p,"utf-8"),e.succeed(`Written ${f__default.default.cyan("CLAUDE.md")}`);}console.log(""),console.log(f__default.default.green.bold(" Claude Code integration configured!")),console.log(""),t.skipMcp||console.log(f__default.default.gray(" MCP Server: ")+f__default.default.white(".mcp.json")),t.skipClaudeMd||console.log(f__default.default.gray(" Context: ")+f__default.default.white("CLAUDE.md")),console.log(""),console.log(f__default.default.bold(" Next steps:")),console.log(f__default.default.gray(" 1. Open this project in Claude Code")),console.log(f__default.default.gray(" 2. The MCP server auto-connects to your VAIF project")),console.log(f__default.default.gray(" 3. Ask Claude to query, modify, or build against your schema")),console.log("");}var dt="1.8.0",he=f__default.default.hex("#00f0ff"),ye=f__default.default.hex("#7b61ff"),ve=f__default.default.hex("#ff3dff"),be=f__default.default.hex("#00ff9d"),w=f__default.default.hex("#555570"),B=f__default.default.hex("#00f0ff");function ho(){console.log(""),console.log(he(" \u2566 \u2566")+ye("\u2554\u2550\u2557\u2566")+ve("\u2554\u2550\u2557 ")+be("\u2554\u2550\u2557\u2566 \u2566")),console.log(he(" \u255A\u2557\u2554\u255D")+ye("\u2560\u2550\u2563\u2551")+ve("\u2560\u2563 ")+be("\u2551 \u2551 \u2551")),console.log(he(" \u255A\u255D ")+ye("\u2569 \u2569\u2569")+ve("\u255A ")+be("\u255A\u2550\u255D\u2569\u2550\u255D\u2569")),console.log(""),console.log(w(" \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500")),console.log(B(" VAIF Studio CLI")+w(` v${dt}`)),console.log(w(" Build full-stack apps at lightning speed")),console.log(w(" \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500")),console.log(""),console.log(f__default.default.bold(" Quick Start")),console.log(w(" $ ")+B("vaif login")+w(" Authenticate")),console.log(w(" $ ")+B("vaif init -t react-spa")+w(" Scaffold project")),console.log(w(" $ ")+B("vaif db push")+w(" Push migrations")),console.log(w(" $ ")+B("vaif generate")+w(" Generate types")),console.log(w(" $ ")+B("vaif functions deploy")+w(" Deploy functions")),console.log(""),console.log(f__default.default.bold(" Categories")),console.log(w(" auth ")+f__default.default.white("login, logout, whoami")),console.log(w(" project ")+f__default.default.white("init, templates, info, status")),console.log(w(" schema ")+f__default.default.white("pull, push, generate")),console.log(w(" database ")+f__default.default.white("db push, db pull, db seed, db reset")),console.log(w(" deploy ")+f__default.default.white("functions deploy, functions list")),console.log(w(" security ")+f__default.default.white("keys, secrets")),console.log(w(" ai ")+f__default.default.white("claude-setup")),console.log(""),console.log(w(" Run ")+B("vaif <command> --help")+w(" for details")),console.log(w(" Docs: ")+f__default.default.underline("https://docs.vaif.studio")),console.log("");}commander.program.name("vaif").description("VAIF CLI - Type generation and development tools").version(dt);commander.program.command("login").description("Authenticate with VAIF (opens browser)").option("-e, --email","Login with email/password instead of browser").option("-p, --project-id <id>","Default project ID").action(Te);commander.program.command("logout").description("Log out and remove stored credentials").action(Pe);commander.program.command("whoami").description("Show current authenticated user").action(Fe);commander.program.command("init").description("Initialize VAIF configuration in your project").option("--typescript","Setup for TypeScript project").option("-f, --force","Overwrite existing config").option("-t, --template <name>","Scaffold from a template (run vaif templates for list)").option("--features <features>","Comma-separated features to include: auth,database,realtime,storage,functions").option("--add-features <features>","Add features to an existing project (requires --template)").action(Le);commander.program.command("templates").alias("tpl").description("List available project templates").action(ke);commander.program.command("info").description("Show project information (name, region, URLs)").option("-c, --config <path>","Config file path","vaif.config.json").option("-p, --project-id <id>","Project ID (overrides config)").action(st);commander.program.command("status").description("Show project status (tables, functions, storage, connections)").option("-c, --config <path>","Config file path","vaif.config.json").option("-p, --project-id <id>","Project ID (overrides config)").action(rt);commander.program.command("pull").description("Pull database schema from your VAIF project").option("-c, --config <path>","Config file path","vaif.config.json").option("-o, --output <path>","Output file path","vaif.schema.json").option("-s, --schema <name>","Schema name","public").option("-p, --project-id <id>","Project ID (overrides config)").action(Ne);commander.program.command("push").description("Push local schema changes to your VAIF project").option("-c, --config <path>","Config file path","vaif.config.json").option("-s, --schema <path>","Schema file path","vaif.schema.json").option("-p, --project-id <id>","Project ID (overrides config)").option("--dry-run","Preview changes without applying").option("-f, --force","Apply changes without confirmation").action($e);commander.program.command("generate").alias("gen").description("Generate TypeScript types from your database schema").option("-c, --connection <url>","Database connection string").option("-o, --output <path>","Output file path","./src/types/database.ts").option("--schema <name>","Schema name","public").option("--config <path>","Config file path","vaif.config.json").option("--dry-run","Preview generated types without writing").action(je);var pt=commander.program.command("functions").alias("fn").description("Manage serverless functions");pt.command("deploy").description("Deploy functions to your VAIF project").option("-c, --config <path>","Config file path","vaif.config.json").option("-p, --project-id <id>","Project ID (overrides config)").option("-e, --env-id <id>","Environment ID").option("-n, --name <name>","Function name filter").option("-r, --runtime <runtime>","Runtime (nodejs, typescript, python)").option("--entrypoint <file>","Specific entrypoint file").option("--dry-run","Preview deployment without deploying").action(ze);pt.command("list").alias("ls").description("List deployed functions").option("-c, --config <path>","Config file path","vaif.config.json").option("-p, --project-id <id>","Project ID (overrides config)").option("-e, --env-id <id>","Environment ID").action(Be);var ae=commander.program.command("db").description("Database management commands");ae.command("push").description("Push local Drizzle migrations to VAIF project").option("-c, --config <path>","Config file path","vaif.config.json").option("-p, --project-id <id>","Project ID (overrides config)").option("-d, --dir <path>","Migrations directory","./drizzle").option("--dry-run","Preview without applying").action(Je);ae.command("pull").description("Pull schema from VAIF project").option("-c, --config <path>","Config file path","vaif.config.json").option("-p, --project-id <id>","Project ID (overrides config)").option("-o, --output <path>","Output file","vaif.schema.json").action(Ge);ae.command("seed").description("Seed your database with test data").option("-c, --config <path>","Config file path","vaif.config.json").option("-p, --project-id <id>","Project ID (overrides config)").option("-f, --file <path>","Specific seed file").option("-t, --table <name>","Seed specific table only").option("--truncate","Truncate tables before seeding").option("--dry-run","Preview seeding without inserting data").action(Ye);ae.command("reset").description("Reset database (drop all tables and data)").option("-c, --config <path>","Config file path","vaif.config.json").option("-p, --project-id <id>","Project ID (overrides config)").option("-f, --force","Confirm reset (required)").action(We);var ut=commander.program.command("keys").description("Manage API keys");ut.command("generate").description("Generate a new API key").option("-c, --config <path>","Config file path","vaif.config.json").option("-p, --project-id <id>","Project ID (overrides config)").option("-n, --name <name>","Key name").action(Ze);ut.command("list").alias("ls").description("List API keys").option("-c, --config <path>","Config file path","vaif.config.json").option("-p, --project-id <id>","Project ID (overrides config)").action(et);var ie=commander.program.command("secrets").alias("sec").description("Manage function secrets");ie.command("set <name> [value]").description("Create or update a secret").option("-c, --config <path>","Config file path","vaif.config.json").option("-p, --project-id <id>","Project ID (overrides config)").option("-e, --env-id <id>","Environment ID or name").option("--from-file <path>","Read secret value from a file").action(tt);ie.command("list").alias("ls").description("List all secrets (names only)").option("-c, --config <path>","Config file path","vaif.config.json").option("-p, --project-id <id>","Project ID (overrides config)").option("-e, --env-id <id>","Environment ID or name").action(ot);ie.command("get <name>").description("Reveal a secret value").option("-c, --config <path>","Config file path","vaif.config.json").option("-p, --project-id <id>","Project ID (overrides config)").option("-e, --env-id <id>","Environment ID or name").action(nt);ie.command("delete <name>").description("Delete a secret").option("-c, --config <path>","Config file path","vaif.config.json").option("-p, --project-id <id>","Project ID (overrides config)").option("-e, --env-id <id>","Environment ID or name").action(at);commander.program.command("claude-setup").description("Configure Claude Code integration (MCP server + CLAUDE.md)").option("-c, --config <path>","Config file path","vaif.config.json").option("-p, --project-id <id>","Project ID").option("-k, --api-key <key>","API key for MCP server").option("--skip-mcp","Skip generating .mcp.json").option("--skip-claude-md","Skip generating CLAUDE.md").option("-o, --output-dir <dir>","Output directory",".").action(ct);process.argv.slice(2).length||(ho(),process.exit(0));commander.program.parse(process.argv);
|
|
4013
|
+
`}async function ct(t){let e=Q__default.default(),o=I();(!o||!o.token)&&(console.log(f__default.default.red("Not logged in")),console.log(f__default.default.gray("Run `vaif login` first to authenticate")),process.exit(1));let n=t.config||"vaif.config.json",r=null;try{r=await A(n);}catch{}let i=po(t,r,o);i||(console.log(f__default.default.red("No project ID specified")),console.log(f__default.default.yellow("Set projectId in vaif.config.json or use --project-id flag.")),process.exit(1));let s=S__default.default.resolve(t.outputDir||".");console.log(""),console.log(f__default.default.bold("VAIF Claude Code Setup")),console.log(f__default.default.gray(` Project: ${i}`)),console.log(""),e.start("Fetching database schema...");let a={tables:[]};try{let p=await fetch(`${G}/schema-engine/introspect/${i}`,{headers:{Authorization:`Bearer ${o.token}`}});p.ok?(a=await p.json(),e.succeed(`Fetched schema (${a.tables?.length||0} tables)`)):e.warn("Could not fetch schema \u2014 continuing without it");}catch{e.warn("Could not fetch schema \u2014 continuing without it");}e.start("Fetching project info...");let l=i,d=G;try{let p=await fetch(`${G}/projects/${i}`,{headers:{Authorization:`Bearer ${o.token}`}});if(p.ok){let c=await p.json();l=c.name||i,d=c.apiUrl||G,e.succeed(`Project: ${l}`);}else e.warn("Could not fetch project info \u2014 using defaults");}catch{e.warn("Could not fetch project info \u2014 using defaults");}let u=t.apiKey||r?.api?.apiKey||"";if(!u){e.start("Generating API key for Claude Code...");try{let p=`claude-code-${Date.now()}`,c=await fetch(`${G}/projects/${i}/api-keys`,{method:"POST",headers:{Authorization:`Bearer ${o.token}`,"Content-Type":"application/json"},body:JSON.stringify({name:p})});c.ok?(u=(await c.json()).key,e.succeed(`Generated API key: ${p}`)):(e.fail("Could not auto-generate API key"),console.log(f__default.default.yellow(" Pass one with --api-key or generate via `vaif keys generate`")),process.exit(1));}catch{e.fail("Could not auto-generate API key"),console.log(f__default.default.yellow(" Pass one with --api-key or generate via `vaif keys generate`")),process.exit(1);}}if(!t.skipMcp){e.start("Writing .mcp.json...");let p={mcpServers:{"vaif-studio":{command:"npx",args:["@vaiftech/mcp"],env:{VAIF_API_KEY:u,VAIF_PROJECT_ID:i,VAIF_API_URL:d,VAIF_AUTH_TOKEN:o.token}}}},c=S__default.default.join(s,".mcp.json");U__default.default.writeFileSync(c,JSON.stringify(p,null,2)+`
|
|
4014
|
+
`,"utf-8"),e.succeed(`Written ${f__default.default.cyan(".mcp.json")}`);}if(!t.skipClaudeMd){e.start("Writing CLAUDE.md...");let p=mo({projectId:i,apiKey:u,apiUrl:d,projectName:l,schema:a}),c=S__default.default.join(s,"CLAUDE.md");U__default.default.writeFileSync(c,p,"utf-8"),e.succeed(`Written ${f__default.default.cyan("CLAUDE.md")}`);}console.log(""),console.log(f__default.default.green.bold(" Claude Code integration configured!")),console.log(""),t.skipMcp||console.log(f__default.default.gray(" MCP Server: ")+f__default.default.white(".mcp.json")),t.skipClaudeMd||console.log(f__default.default.gray(" Context: ")+f__default.default.white("CLAUDE.md")),console.log(""),console.log(f__default.default.bold(" Next steps:")),console.log(f__default.default.gray(" 1. Open this project in Claude Code")),console.log(f__default.default.gray(" 2. The MCP server auto-connects to your VAIF project")),console.log(f__default.default.gray(" 3. Ask Claude to query, modify, or build against your schema")),console.log("");}var dt="1.8.1",he=f__default.default.hex("#00f0ff"),ye=f__default.default.hex("#7b61ff"),ve=f__default.default.hex("#ff3dff"),be=f__default.default.hex("#00ff9d"),w=f__default.default.hex("#555570"),B=f__default.default.hex("#00f0ff");function ho(){console.log(""),console.log(he(" \u2566 \u2566")+ye("\u2554\u2550\u2557\u2566")+ve("\u2554\u2550\u2557 ")+be("\u2554\u2550\u2557\u2566 \u2566")),console.log(he(" \u255A\u2557\u2554\u255D")+ye("\u2560\u2550\u2563\u2551")+ve("\u2560\u2563 ")+be("\u2551 \u2551 \u2551")),console.log(he(" \u255A\u255D ")+ye("\u2569 \u2569\u2569")+ve("\u255A ")+be("\u255A\u2550\u255D\u2569\u2550\u255D\u2569")),console.log(""),console.log(w(" \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500")),console.log(B(" VAIF Studio CLI")+w(` v${dt}`)),console.log(w(" Build full-stack apps at lightning speed")),console.log(w(" \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500")),console.log(""),console.log(f__default.default.bold(" Quick Start")),console.log(w(" $ ")+B("vaif login")+w(" Authenticate")),console.log(w(" $ ")+B("vaif init -t react-spa")+w(" Scaffold project")),console.log(w(" $ ")+B("vaif db push")+w(" Push migrations")),console.log(w(" $ ")+B("vaif generate")+w(" Generate types")),console.log(w(" $ ")+B("vaif functions deploy")+w(" Deploy functions")),console.log(""),console.log(f__default.default.bold(" Categories")),console.log(w(" auth ")+f__default.default.white("login, logout, whoami")),console.log(w(" project ")+f__default.default.white("init, templates, info, status")),console.log(w(" schema ")+f__default.default.white("pull, push, generate")),console.log(w(" database ")+f__default.default.white("db push, db pull, db seed, db reset")),console.log(w(" deploy ")+f__default.default.white("functions deploy, functions list")),console.log(w(" security ")+f__default.default.white("keys, secrets")),console.log(w(" ai ")+f__default.default.white("claude-setup")),console.log(""),console.log(w(" Run ")+B("vaif <command> --help")+w(" for details")),console.log(w(" Docs: ")+f__default.default.underline("https://docs.vaif.studio")),console.log("");}commander.program.name("vaif").description("VAIF CLI - Type generation and development tools").version(dt);commander.program.command("login").description("Authenticate with VAIF (opens browser)").option("-e, --email","Login with email/password instead of browser").option("-p, --project-id <id>","Default project ID").action(Te);commander.program.command("logout").description("Log out and remove stored credentials").action(Pe);commander.program.command("whoami").description("Show current authenticated user").action(Fe);commander.program.command("init").description("Initialize VAIF configuration in your project").option("--typescript","Setup for TypeScript project").option("-f, --force","Overwrite existing config").option("-t, --template <name>","Scaffold from a template (run vaif templates for list)").option("--features <features>","Comma-separated features to include: auth,database,realtime,storage,functions").option("--add-features <features>","Add features to an existing project (requires --template)").action(Le);commander.program.command("templates").alias("tpl").description("List available project templates").action(ke);commander.program.command("info").description("Show project information (name, region, URLs)").option("-c, --config <path>","Config file path","vaif.config.json").option("-p, --project-id <id>","Project ID (overrides config)").action(st);commander.program.command("status").description("Show project status (tables, functions, storage, connections)").option("-c, --config <path>","Config file path","vaif.config.json").option("-p, --project-id <id>","Project ID (overrides config)").action(rt);commander.program.command("pull").description("Pull database schema from your VAIF project").option("-c, --config <path>","Config file path","vaif.config.json").option("-o, --output <path>","Output file path","vaif.schema.json").option("-s, --schema <name>","Schema name","public").option("-p, --project-id <id>","Project ID (overrides config)").action(Ne);commander.program.command("push").description("Push local schema changes to your VAIF project").option("-c, --config <path>","Config file path","vaif.config.json").option("-s, --schema <path>","Schema file path","vaif.schema.json").option("-p, --project-id <id>","Project ID (overrides config)").option("--dry-run","Preview changes without applying").option("-f, --force","Apply changes without confirmation").action($e);commander.program.command("generate").alias("gen").description("Generate TypeScript types from your database schema").option("-c, --connection <url>","Database connection string").option("-o, --output <path>","Output file path","./src/types/database.ts").option("--schema <name>","Schema name","public").option("--config <path>","Config file path","vaif.config.json").option("--dry-run","Preview generated types without writing").action(je);var pt=commander.program.command("functions").alias("fn").description("Manage serverless functions");pt.command("deploy").description("Deploy functions to your VAIF project").option("-c, --config <path>","Config file path","vaif.config.json").option("-p, --project-id <id>","Project ID (overrides config)").option("-e, --env-id <id>","Environment ID").option("-n, --name <name>","Function name filter").option("-r, --runtime <runtime>","Runtime (nodejs, typescript, python)").option("--entrypoint <file>","Specific entrypoint file").option("--dry-run","Preview deployment without deploying").action(ze);pt.command("list").alias("ls").description("List deployed functions").option("-c, --config <path>","Config file path","vaif.config.json").option("-p, --project-id <id>","Project ID (overrides config)").option("-e, --env-id <id>","Environment ID").action(Be);var ae=commander.program.command("db").description("Database management commands");ae.command("push").description("Push local Drizzle migrations to VAIF project").option("-c, --config <path>","Config file path","vaif.config.json").option("-p, --project-id <id>","Project ID (overrides config)").option("-d, --dir <path>","Migrations directory","./drizzle").option("--dry-run","Preview without applying").action(Je);ae.command("pull").description("Pull schema from VAIF project").option("-c, --config <path>","Config file path","vaif.config.json").option("-p, --project-id <id>","Project ID (overrides config)").option("-o, --output <path>","Output file","vaif.schema.json").action(Ge);ae.command("seed").description("Seed your database with test data").option("-c, --config <path>","Config file path","vaif.config.json").option("-p, --project-id <id>","Project ID (overrides config)").option("-f, --file <path>","Specific seed file").option("-t, --table <name>","Seed specific table only").option("--truncate","Truncate tables before seeding").option("--dry-run","Preview seeding without inserting data").action(Ye);ae.command("reset").description("Reset database (drop all tables and data)").option("-c, --config <path>","Config file path","vaif.config.json").option("-p, --project-id <id>","Project ID (overrides config)").option("-f, --force","Confirm reset (required)").action(We);var ut=commander.program.command("keys").description("Manage API keys");ut.command("generate").description("Generate a new API key").option("-c, --config <path>","Config file path","vaif.config.json").option("-p, --project-id <id>","Project ID (overrides config)").option("-n, --name <name>","Key name").action(Ze);ut.command("list").alias("ls").description("List API keys").option("-c, --config <path>","Config file path","vaif.config.json").option("-p, --project-id <id>","Project ID (overrides config)").action(et);var ie=commander.program.command("secrets").alias("sec").description("Manage function secrets");ie.command("set <name> [value]").description("Create or update a secret").option("-c, --config <path>","Config file path","vaif.config.json").option("-p, --project-id <id>","Project ID (overrides config)").option("-e, --env-id <id>","Environment ID or name").option("--from-file <path>","Read secret value from a file").action(tt);ie.command("list").alias("ls").description("List all secrets (names only)").option("-c, --config <path>","Config file path","vaif.config.json").option("-p, --project-id <id>","Project ID (overrides config)").option("-e, --env-id <id>","Environment ID or name").action(ot);ie.command("get <name>").description("Reveal a secret value").option("-c, --config <path>","Config file path","vaif.config.json").option("-p, --project-id <id>","Project ID (overrides config)").option("-e, --env-id <id>","Environment ID or name").action(nt);ie.command("delete <name>").description("Delete a secret").option("-c, --config <path>","Config file path","vaif.config.json").option("-p, --project-id <id>","Project ID (overrides config)").option("-e, --env-id <id>","Environment ID or name").action(at);commander.program.command("claude-setup").description("Configure Claude Code integration (MCP server + CLAUDE.md)").option("-c, --config <path>","Config file path","vaif.config.json").option("-p, --project-id <id>","Project ID").option("-k, --api-key <key>","API key for MCP server").option("--skip-mcp","Skip generating .mcp.json").option("--skip-claude-md","Skip generating CLAUDE.md").option("-o, --output-dir <dir>","Output directory",".").action(ct);process.argv.slice(2).length||(ho(),process.exit(0));commander.program.parse(process.argv);
|
package/dist/cli.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import {c,d,e,h,g,f as f$1,b,a}from'./chunk-T7GOLIY4.js';import'dotenv/config';import {program}from'commander';import f from'chalk';import D from'fs';import I from'path';import K from'ora';import qe from'readline';var Ke=process.env.VAIF_API_URL||"https://api.vaif.studio";async function Be(o,e,t="public"){let s=await fetch(`${Ke}/
|
|
2
|
+
import {c,d,e,h,g,f as f$1,b,a}from'./chunk-T7GOLIY4.js';import'dotenv/config';import {program}from'commander';import f from'chalk';import D from'fs';import I from'path';import K from'ora';import qe from'readline';var Ke=process.env.VAIF_API_URL||"https://api.vaif.studio";async function Be(o,e,t="public"){let s=await fetch(`${Ke}/projects/${e}/schema?schema=${t}`,{headers:{Authorization:`Bearer ${o}`,"Content-Type":"application/json"}});if(!s.ok){let r=await s.text();throw new Error(`Failed to fetch schema: ${r}`)}return s.json()}async function ce(o){let e=K(),t=b();(!t||!t.token)&&(console.log(f.red("Not logged in")),console.log(f.gray("Run `vaif login` first to authenticate")),process.exit(1));let s=o.config||"vaif.config.json",r=null;e.start("Loading configuration...");try{r=await a(s);}catch(i){e.fail("Failed to load config"),console.log(f.red(`
|
|
3
3
|
Error: ${i}`)),process.exit(1);}r||(e.fail("No configuration found"),console.log(f.yellow("\nRun `vaif init` to create a configuration file.")),process.exit(1));let a$1=o.projectId||r.projectId||process.env.VAIF_PROJECT_ID||t.projectId;a$1||(e.fail("No project ID specified"),console.log(f.yellow(`
|
|
4
4
|
Set projectId in vaif.config.json or use --project-id flag.`)),process.exit(1)),e.text="Fetching remote schema...";try{let i=o.schema||r.database?.schema||"public",n=await Be(t.token,a$1,i);e.succeed("Schema fetched successfully");let c=o.output||I.resolve("vaif.schema.json"),d={$schema:"https://vaif.studio/schemas/schema.json",projectId:a$1,schema:i,pulledAt:new Date().toISOString(),...n};D.writeFileSync(c,JSON.stringify(d,null,2),"utf-8"),console.log(""),console.log(f.green(`Schema saved to: ${c}`)),console.log(""),console.log(f.gray("Schema summary:")),console.log(f.gray(` Tables: ${(n.tables||[]).length}`)),console.log(f.gray(` Enums: ${(n.enums||[]).length}`)),console.log(f.gray(` Functions: ${(n.functions||[]).length}`)),console.log(""),console.log(f.gray("Next steps:")),console.log(f.gray(" - Run `vaif generate` to generate TypeScript types")),console.log(f.gray(" - Edit the schema and run `vaif push` to deploy changes")),console.log("");}catch(i){e.fail("Failed to fetch schema"),i instanceof Error&&console.log(f.red(`
|
|
5
|
-
Error: ${i.message}`)),process.exit(1);}}var ge=process.env.VAIF_API_URL||"https://api.vaif.studio";function We(o){let e=qe.createInterface({input:process.stdin,output:process.stdout});return new Promise(t=>{e.question(o,s=>{e.close(),t(s);});})}async function Ge(o,e,t){let s=await fetch(`${ge}/
|
|
5
|
+
Error: ${i.message}`)),process.exit(1);}}var ge=process.env.VAIF_API_URL||"https://api.vaif.studio";function We(o){let e=qe.createInterface({input:process.stdin,output:process.stdout});return new Promise(t=>{e.question(o,s=>{e.close(),t(s);});})}async function Ge(o,e,t){let s=await fetch(`${ge}/projects/${e}/schema/preview`,{method:"POST",headers:{Authorization:`Bearer ${o}`,"Content-Type":"application/json"},body:JSON.stringify({schema:t})});if(!s.ok){let r=await s.text();throw new Error(`Failed to preview changes: ${r}`)}return s.json()}async function Ye(o,e,t){let s=await fetch(`${ge}/projects/${e}/schema/apply`,{method:"POST",headers:{Authorization:`Bearer ${o}`,"Content-Type":"application/json"},body:JSON.stringify({schema:t})});if(!s.ok){let r=await s.text();throw new Error(`Failed to apply changes: ${r}`)}return s.json()}function Qe(o){if(console.log(""),console.log(f.bold("Schema Changes:")),console.log(""),o.added.length===0&&o.modified.length===0&&o.removed.length===0){console.log(f.gray(" No changes detected. Schema is up to date."));return}if(o.added.length>0){console.log(f.green.bold(" + Added:"));for(let e of o.added)console.log(f.green(` + ${e.type}: ${e.name}`));console.log("");}if(o.modified.length>0){console.log(f.yellow.bold(" ~ Modified:"));for(let e of o.modified){console.log(f.yellow(` ~ ${e.type}: ${e.name}`));for(let t of e.changes)console.log(f.gray(` ${t}`));}console.log("");}if(o.removed.length>0){console.log(f.red.bold(" - Removed:"));for(let e of o.removed)console.log(f.red(` - ${e.type}: ${e.name}`));console.log("");}}async function fe(o){let e=K(),t=b();(!t||!t.token)&&(console.log(f.red("Not logged in")),console.log(f.gray("Run `vaif login` first to authenticate")),process.exit(1));let s=o.config||"vaif.config.json",r=null;e.start("Loading configuration...");try{r=await a(s);}catch(c){e.fail("Failed to load config"),console.log(f.red(`
|
|
6
6
|
Error: ${c}`)),process.exit(1);}r||(e.fail("No configuration found"),console.log(f.yellow("\nRun `vaif init` to create a configuration file.")),process.exit(1));let a$1=o.projectId||r.projectId||process.env.VAIF_PROJECT_ID||t.projectId;a$1||(e.fail("No project ID specified"),console.log(f.yellow(`
|
|
7
7
|
Set projectId in vaif.config.json or use --project-id flag.`)),process.exit(1));let i=o.schema||I.resolve("vaif.schema.json");D.existsSync(i)||(e.fail("No local schema found"),console.log(f.yellow(`
|
|
8
8
|
Expected schema file at: ${i}`)),console.log(f.gray("Run `vaif pull` first to fetch the current schema.")),process.exit(1));let n;try{let c=D.readFileSync(i,"utf-8");n=JSON.parse(c);}catch(c){e.fail("Failed to parse schema file"),c instanceof Error&&console.log(f.red(`
|
|
@@ -13,23 +13,23 @@ Place your functions in:`)),console.log(f.gray(" - ./functions/")),console.log(
|
|
|
13
13
|
Or specify an entrypoint with --entrypoint`)),process.exit(1)),e.succeed(`Found ${c.length} function(s)`),o.name&&(c=c.filter(l=>I.basename(l,I.extname(l)).includes(o.name)),c.length===0&&(console.log(f.yellow(`
|
|
14
14
|
No functions matching "${o.name}" found`)),process.exit(1))),console.log(""),console.log(f.gray("Functions to deploy:"));for(let l of c){let h=I.basename(I.dirname(l)),y=h==="functions"||h==="src"?I.basename(l,I.extname(l)):h,E=o.runtime||de(l);console.log(f.gray(` - ${y} (${E})`));}if(console.log(""),o.dryRun){console.log(f.yellow("Dry run mode - no functions deployed."));return}let d=[];for(let l of c){let h=I.basename(I.dirname(l)),y=h==="functions"||h==="src"?I.basename(l,I.extname(l)):h,E=o.runtime||de(l);e.start(`Deploying ${y}...`);try{let _=D.readFileSync(l,"utf-8"),T=await He(t.token,a$1,y,o.envId);T||(e.text=`Creating ${y}...`,T=await Xe(t.token,a$1,{name:y,runtime:E,entrypoint:I.basename(l),envId:o.envId})),e.text=`Deploying ${y}...`,await Ze(t.token,T.id,_),e.succeed(`Deployed ${y}`),d.push({name:y,success:!0});}catch(_){let T=_ instanceof Error?_.message:"Unknown error";e.fail(`Failed to deploy ${y}`),d.push({name:y,success:false,error:T});}}console.log("");let p=d.filter(l=>l.success).length;if(d.filter(l=>!l.success).length===0)console.log(f.green(`\u2713 Successfully deployed ${p} function(s)`));else {console.log(f.yellow(`Deployed ${p}/${d.length} function(s)`)),console.log(""),console.log(f.red("Failed deployments:"));for(let l of d.filter(h=>!h.success))console.log(f.red(` - ${l.name}: ${l.error}`));}console.log("");}async function he(o){let e=K(),t=b();(!t||!t.token)&&(console.log(f.red("Not logged in")),console.log(f.gray("Run `vaif login` first to authenticate")),process.exit(1));let s=o.config||"vaif.config.json",r=null;try{r=await a(s);}catch{}let a$1=o.projectId||r?.projectId||process.env.VAIF_PROJECT_ID||t.projectId;a$1||(console.log(f.red("No project ID specified")),process.exit(1)),e.start("Fetching functions...");try{let i=await eo(t.token,a$1,o.envId);if(e.stop(),i.length===0){console.log(f.yellow(`
|
|
15
15
|
No functions found`)),console.log(f.gray("Deploy your first function with: vaif functions deploy"));return}console.log(""),console.log(f.bold(`Functions (${i.length}):`)),console.log(""),console.log(f.gray(" "+"NAME".padEnd(25)+"RUNTIME".padEnd(15)+"STATUS".padEnd(12)+"INVOCATIONS".padEnd(14)+"LAST DEPLOYED")),console.log(f.gray(" "+"-".repeat(80)));for(let n of i){let c=n.deployStatus==="deployed"?f.green:n.deployStatus==="deploying"?f.yellow:n.deployStatus==="failed"?f.red:f.gray;console.log(" "+n.name.padEnd(25)+n.runtime.padEnd(15)+c(n.deployStatus.padEnd(12))+String(n.invocationCount??0).padEnd(14)+(n.deployedAt?new Date(n.deployedAt).toLocaleDateString():"-"));}console.log("");}catch(i){e.fail("Failed to fetch functions"),i instanceof Error&&console.log(f.red(`
|
|
16
|
-
Error: ${i.message}`)),process.exit(1);}}var B=process.env.VAIF_API_URL||"https://api.vaif.studio";async function oo(o,e,t,s,r){let a=await fetch(`${B}/
|
|
16
|
+
Error: ${i.message}`)),process.exit(1);}}var B=process.env.VAIF_API_URL||"https://api.vaif.studio";async function oo(o,e,t,s,r){let a=await fetch(`${B}/projects/${e}/db/seed`,{method:"POST",headers:{Authorization:`Bearer ${o}`,"Content-Type":"application/json"},body:JSON.stringify({table:t,records:s,truncate:r?.truncate??false})});if(!a.ok){let i=await a.text();throw new Error(`Failed to seed ${t}: ${i}`)}return a.json()}async function to(o,e){let t=await fetch(`${B}/projects/${e}/db/reset`,{method:"POST",headers:{Authorization:`Bearer ${o}`,"Content-Type":"application/json"}});if(!t.ok){let s=await t.text();throw new Error(`Failed to reset database: ${s}`)}return t.json()}function Q(o){let e=[];if(!D.existsSync(o))return e;let t=D.readdirSync(o,{withFileTypes:true});for(let s of t)if(s.isFile()){let r=I.extname(s.name).toLowerCase();(r===".json"||r===".ts"||r===".js")&&e.push(I.join(o,s.name));}return e.sort()}async function ye(o){let e=I.extname(o).toLowerCase();if(e===".json"){let t=D.readFileSync(o,"utf-8"),s=JSON.parse(t);return Array.isArray(s)?[{table:I.basename(o,e),data:s}]:s.table&&s.data?[s]:Object.entries(s).map(([r,a])=>({table:r,data:a}))}else if(e===".ts"||e===".js"){let t=await import(o),s=t.default||t;return typeof s=="function"?s():s}throw new Error(`Unsupported file format: ${e}`)}async function we(o){let e=K(),t=b();(!t||!t.token)&&(console.log(f.red("Not logged in")),console.log(f.gray("Run `vaif login` first to authenticate")),process.exit(1));let s=o.config||"vaif.config.json",r=null;try{r=await a(s);}catch{}let a$1=o.projectId||r?.projectId||process.env.VAIF_PROJECT_ID||t.projectId;a$1||(console.log(f.red("No project ID specified")),console.log(f.yellow("Set projectId in vaif.config.json or use --project-id flag.")),process.exit(1)),console.log(""),console.log(f.bold("VAIF Database Seed")),console.log("");let i=[];if(o.file){let p=I.resolve(o.file);D.existsSync(p)||(console.log(f.red(`File not found: ${o.file}`)),process.exit(1)),i=[p];}else {let p=I.resolve("seeds"),g=I.resolve("prisma/seed"),l=I.resolve("db/seeds");i=[...Q(p),...Q(g),...Q(l)];}i.length===0&&(console.log(f.yellow("No seed files found")),console.log(f.gray(`
|
|
17
17
|
Place your seed files in one of these directories:`)),console.log(f.gray(" - ./seeds/")),console.log(f.gray(" - ./prisma/seed/")),console.log(f.gray(" - ./db/seeds/")),console.log(f.gray(`
|
|
18
18
|
Or specify a file with --file`)),console.log(f.gray(`
|
|
19
19
|
Example seed file (seeds/users.json):`)),console.log(f.gray(" [")),console.log(f.gray(' { "name": "John Doe", "email": "john@example.com" },')),console.log(f.gray(' { "name": "Jane Doe", "email": "jane@example.com" }')),console.log(f.gray(" ]")),process.exit(1)),console.log(f.gray("Seed files found:"));for(let p of i)console.log(f.gray(` - ${I.relative(process.cwd(),p)}`));if(console.log(""),o.truncate&&(console.log(f.yellow("\u26A0\uFE0F Tables will be truncated before seeding")),console.log("")),o.dryRun){console.log(f.yellow("Dry run mode - no data will be inserted.")),console.log("");for(let p of i){e.start(`Loading ${I.basename(p)}...`);try{let g=await ye(p);e.stop();for(let l of g)o.table&&l.table!==o.table||(console.log(f.cyan(`Table: ${l.table}`)),console.log(f.gray(` Records: ${l.data.length}`)),l.data.length>0&&console.log(f.gray(` Sample: ${JSON.stringify(l.data[0],null,2).slice(0,100)}...`)),console.log(""));}catch(g){e.fail(`Failed to load ${I.basename(p)}`),g instanceof Error&&console.log(f.red(` Error: ${g.message}`));}}return}let n=[];for(let p of i){e.start(`Processing ${I.basename(p)}...`);try{let g=await ye(p);e.stop();for(let l of g)if(!(o.table&&l.table!==o.table)){if(l.data.length===0){console.log(f.gray(` Skipping ${l.table} (no records)`));continue}e.start(`Seeding ${l.table} (${l.data.length} records)...`);try{let h=await oo(t.token,a$1,l.table,l.data,{truncate:o.truncate});e.succeed(`Seeded ${l.table}: ${h.inserted} records`),n.push({table:l.table,inserted:h.inserted});}catch(h){let y=h instanceof Error?h.message:"Unknown error";e.fail(`Failed to seed ${l.table}`),n.push({table:l.table,inserted:0,error:y});}}}catch(g){e.fail(`Failed to load ${I.basename(p)}`),g instanceof Error&&console.log(f.red(` Error: ${g.message}`));}}console.log("");let c=n.reduce((p,g)=>p+g.inserted,0),d=n.filter(p=>p.error).length;if(d===0)console.log(f.green(`\u2713 Successfully seeded ${c} records across ${n.length} table(s)`));else {console.log(f.yellow(`Seeded ${c} records with ${d} error(s)`)),console.log(""),console.log(f.red("Errors:"));for(let p of n.filter(g=>g.error))console.log(f.red(` - ${p.table}: ${p.error}`));}console.log("");}async function je(o){let e=K(),t=b();(!t||!t.token)&&(console.log(f.red("Not logged in")),console.log(f.gray("Run `vaif login` first to authenticate")),process.exit(1));let s=o.config||"vaif.config.json",r=null;try{r=await a(s);}catch{}let a$1=o.projectId||r?.projectId||process.env.VAIF_PROJECT_ID||t.projectId;a$1||(console.log(f.red("No project ID specified")),console.log(f.yellow("Set projectId in vaif.config.json or use --project-id flag.")),process.exit(1));let i=I.resolve(o.dir||"./drizzle");if(console.log(""),console.log(f.bold("VAIF Database Push")),console.log(""),!D.existsSync(i)){let g=I.resolve("./migrations");D.existsSync(g)?console.log(f.gray(`Using migrations from: ${g}`)):(console.log(f.red(`Migrations directory not found: ${i}`)),console.log(f.gray(`
|
|
20
20
|
Expected one of:`)),console.log(f.gray(" - ./drizzle/")),console.log(f.gray(" - ./migrations/")),console.log(f.gray(`
|
|
21
21
|
Or specify with: vaif db push --dir <path>`)),process.exit(1));}let n=[],c=D.readdirSync(i,{withFileTypes:true});for(let g of c)if(g.isFile()&&g.name.endsWith(".sql"))n.push(I.join(i,g.name));else if(g.isDirectory()){let l=D.readdirSync(I.join(i,g.name),{withFileTypes:true});for(let h of l)h.isFile()&&h.name.endsWith(".sql")&&n.push(I.join(i,g.name,h.name));}n.sort(),n.length===0&&(console.log(f.yellow("No SQL migration files found")),process.exit(1)),console.log(f.gray(`Found ${n.length} migration(s):`));for(let g of n)console.log(f.gray(` - ${I.relative(process.cwd(),g)}`));if(console.log(""),o.dryRun){console.log(f.yellow("Dry run mode - no migrations will be applied.")),console.log("");for(let g of n){let l=D.readFileSync(g,"utf-8");console.log(f.cyan(`--- ${I.basename(g)} ---`)),console.log(f.gray(l.slice(0,500))),l.length>500&&console.log(f.gray("...")),console.log("");}return}let d=0,p=0;for(let g of n){let l=D.readFileSync(g,"utf-8"),h=I.relative(process.cwd(),g);e.start(`Applying ${h}...`);try{let y=await fetch(`${B}/schema-engine/query/${a$1}`,{method:"POST",headers:{Authorization:`Bearer ${t.token}`,"Content-Type":"application/json"},body:JSON.stringify({sql:l})});if(!y.ok){let E=await y.text();throw new Error(E)}e.succeed(`Applied ${h}`),d++;}catch(y){let E=y instanceof Error?y.message:"Unknown error";e.fail(`Failed ${h}: ${E}`),p++;}}console.log(""),console.log(p===0?f.green(`Successfully applied ${d} migration(s)`):f.yellow(`Applied ${d}, failed ${p} migration(s)`)),console.log("");}async function ve(o){let e=K(),t=b();(!t||!t.token)&&(console.log(f.red("Not logged in")),console.log(f.gray("Run `vaif login` first to authenticate")),process.exit(1));let s=o.config||"vaif.config.json",r=null;try{r=await a(s);}catch{}let a$1=o.projectId||r?.projectId||process.env.VAIF_PROJECT_ID||t.projectId;a$1||(console.log(f.red("No project ID specified")),console.log(f.yellow("Set projectId in vaif.config.json or use --project-id flag.")),process.exit(1));let i=I.resolve(o.output||"vaif.schema.json");console.log(""),console.log(f.bold("VAIF Database Pull")),console.log(""),e.start("Pulling schema from remote...");try{let n=await fetch(`${B}/schema-engine/introspect/${a$1}`,{headers:{Authorization:`Bearer ${t.token}`}});if(!n.ok){let p=await n.text();throw new Error(`Failed to pull schema: ${p}`)}let c=await n.json();D.writeFileSync(i,JSON.stringify(c,null,2),"utf-8"),e.succeed(`Schema written to ${I.relative(process.cwd(),i)}`);let d=c.tables?.length??Object.keys(c).length;console.log(f.gray(` ${d} table(s) pulled`)),console.log("");}catch(n){e.fail("Failed to pull schema"),n instanceof Error&&console.log(f.red(`
|
|
22
22
|
Error: ${n.message}`)),process.exit(1);}}async function Ie(o){let e=K(),t=b();(!t||!t.token)&&(console.log(f.red("Not logged in")),console.log(f.gray("Run `vaif login` first to authenticate")),process.exit(1));let s=o.config||"vaif.config.json",r=null;try{r=await a(s);}catch{}let a$1=o.projectId||r?.projectId||process.env.VAIF_PROJECT_ID||t.projectId;a$1||(console.log(f.red("No project ID specified")),process.exit(1)),console.log(""),console.log(f.red.bold("\u26A0\uFE0F DATABASE RESET")),console.log(""),console.log(f.red("This will:")),console.log(f.red(" - Drop all tables")),console.log(f.red(" - Delete all data")),console.log(f.red(" - Reset migrations")),console.log(""),console.log(f.red.bold("This action cannot be undone!")),console.log(""),o.force||(console.log(f.yellow("Use --force to confirm this action.")),process.exit(1)),e.start("Resetting database...");try{await to(t.token,a$1),e.succeed("Database reset complete"),console.log(""),console.log(f.gray("Your database is now empty.")),console.log(f.gray("Run `vaif push` to apply your schema, then `vaif db seed` to seed data.")),console.log("");}catch(i){e.fail("Failed to reset database"),i instanceof Error&&console.log(f.red(`
|
|
23
|
-
Error: ${i.message}`)),process.exit(1);}}var be=process.env.VAIF_API_URL||"https://api.vaif.studio";function Se(o,e,t){return o.projectId||e?.projectId||process.env.VAIF_PROJECT_ID||t.projectId||null}async function Ae(o){let e=K(),t=b();(!t||!t.token)&&(console.log(f.red("Not logged in")),console.log(f.gray("Run `vaif login` first to authenticate")),process.exit(1));let s=o.config||"vaif.config.json",r=null;try{r=await a(s);}catch{}let a$1=Se(o,r,t);a$1||(console.log(f.red("No project ID specified")),console.log(f.yellow("Set projectId in vaif.config.json or use --project-id flag.")),process.exit(1));let i=o.name||`cli-key-${Date.now()}`;console.log(""),console.log(f.bold("VAIF Generate API Key")),console.log(""),e.start("Generating API key...");try{let n=await fetch(`${be}/
|
|
24
|
-
Error: ${n.message}`)),process.exit(1);}}async function Pe(o){let e=K(),t=b();(!t||!t.token)&&(console.log(f.red("Not logged in")),console.log(f.gray("Run `vaif login` first to authenticate")),process.exit(1));let s=o.config||"vaif.config.json",r=null;try{r=await a(s);}catch{}let a$1=Se(o,r,t);a$1||(console.log(f.red("No project ID specified")),console.log(f.yellow("Set projectId in vaif.config.json or use --project-id flag.")),process.exit(1)),console.log(""),console.log(f.bold("VAIF API Keys")),console.log(""),e.start("Fetching API keys...");try{let i=await fetch(`${be}/
|
|
23
|
+
Error: ${i.message}`)),process.exit(1);}}var be=process.env.VAIF_API_URL||"https://api.vaif.studio";function Se(o,e,t){return o.projectId||e?.projectId||process.env.VAIF_PROJECT_ID||t.projectId||null}async function Ae(o){let e=K(),t=b();(!t||!t.token)&&(console.log(f.red("Not logged in")),console.log(f.gray("Run `vaif login` first to authenticate")),process.exit(1));let s=o.config||"vaif.config.json",r=null;try{r=await a(s);}catch{}let a$1=Se(o,r,t);a$1||(console.log(f.red("No project ID specified")),console.log(f.yellow("Set projectId in vaif.config.json or use --project-id flag.")),process.exit(1));let i=o.name||`cli-key-${Date.now()}`;console.log(""),console.log(f.bold("VAIF Generate API Key")),console.log(""),e.start("Generating API key...");try{let n=await fetch(`${be}/projects/${a$1}/api-keys`,{method:"POST",headers:{Authorization:`Bearer ${t.token}`,"Content-Type":"application/json"},body:JSON.stringify({name:i})});if(!n.ok){let d=await n.text();throw new Error(`Failed to generate key: ${d}`)}let c=await n.json();e.succeed("API key generated"),console.log(""),console.log(f.green(` Name: ${c.name}`)),console.log(f.green(` Key: ${c.key}`)),console.log(""),console.log(f.yellow.bold(" Save this key now - it will not be shown again!")),console.log("");}catch(n){e.fail("Failed to generate API key"),n instanceof Error&&console.log(f.red(`
|
|
24
|
+
Error: ${n.message}`)),process.exit(1);}}async function Pe(o){let e=K(),t=b();(!t||!t.token)&&(console.log(f.red("Not logged in")),console.log(f.gray("Run `vaif login` first to authenticate")),process.exit(1));let s=o.config||"vaif.config.json",r=null;try{r=await a(s);}catch{}let a$1=Se(o,r,t);a$1||(console.log(f.red("No project ID specified")),console.log(f.yellow("Set projectId in vaif.config.json or use --project-id flag.")),process.exit(1)),console.log(""),console.log(f.bold("VAIF API Keys")),console.log(""),e.start("Fetching API keys...");try{let i=await fetch(`${be}/projects/${a$1}/api-keys`,{headers:{Authorization:`Bearer ${t.token}`}});if(!i.ok){let g=await i.text();throw new Error(`Failed to list keys: ${g}`)}let n=await i.json(),c=n.keys||n;if(e.stop(),!Array.isArray(c)||c.length===0){console.log(f.yellow("No API keys found")),console.log(f.gray(`
|
|
25
25
|
Generate one with: vaif keys generate`));return}let d=Math.max(8,...c.map(g=>(g.name||"").length)),p=` ${"Name".padEnd(d)} ${"Key".padEnd(24)} Created`;console.log(f.gray(p)),console.log(f.gray(" "+"-".repeat(p.length-2)));for(let g of c){let l=(g.name||"unnamed").padEnd(d),h=g.maskedKey||g.prefix||`${(g.key||"").slice(0,12)}...`,y=g.createdAt?new Date(g.createdAt).toLocaleDateString():"N/A";console.log(` ${l} ${h.padEnd(24)} ${y}`);}console.log(""),console.log(f.gray(` ${c.length} key(s) total`)),console.log("");}catch(i){e.fail("Failed to list API keys"),i instanceof Error&&console.log(f.red(`
|
|
26
26
|
Error: ${i.message}`)),process.exit(1);}}var V=process.env.VAIF_API_URL||"https://api.vaif.studio";function so(o,e,t){return o.projectId||e?.projectId||process.env.VAIF_PROJECT_ID||t.projectId||null}function M(){let o=b();return (!o||!o.token)&&(console.log(f.red("Not logged in")),console.log(f.gray("Run `vaif login` first to authenticate")),process.exit(1)),o}async function q(o){try{return await a(o||"vaif.config.json")}catch{return null}}function W(o,e,t){let s=so(o,e,t);return s||(console.log(f.red("No project ID specified")),console.log(f.yellow("Set projectId in vaif.config.json or use --project-id flag.")),process.exit(1)),s}async function Ce(o,e,t){let s=K(),r=M(),a=await q(t.config),i=W(t,a,r),n=e;if(t.fromFile)try{n=D.readFileSync(t.fromFile,"utf-8");}catch(c){console.log(f.red(`Failed to read file: ${t.fromFile}`)),c instanceof Error&&console.log(f.gray(c.message)),process.exit(1);}n||(console.log(f.red("No value provided")),console.log(f.gray("Provide a value as argument or use --from-file <path>")),process.exit(1)),console.log(""),console.log(f.bold("VAIF Set Secret")),console.log(""),s.start("Checking for existing secret...");try{let c=new URL(`${V}/functions/secrets/project/${i}`);t.envId&&c.searchParams.set("envId",t.envId);let d=await fetch(c.toString(),{headers:{Authorization:`Bearer ${r.token}`}});if(!d.ok)throw new Error(`Failed to check existing secrets: ${await d.text()}`);let g=(await d.json()).find(l=>l.key===o);if(g){s.text=`Updating secret "${o}"...`;let l=await fetch(`${V}/functions/secrets/${g.id}`,{method:"PUT",headers:{Authorization:`Bearer ${r.token}`,"Content-Type":"application/json"},body:JSON.stringify({value:n})});if(!l.ok)throw new Error(`Failed to update secret: ${await l.text()}`);s.succeed(`Updated secret "${o}"`);}else {s.text=`Creating secret "${o}"...`;let l=await fetch(`${V}/functions/secrets`,{method:"POST",headers:{Authorization:`Bearer ${r.token}`,"Content-Type":"application/json"},body:JSON.stringify({projectId:i,envId:t.envId,key:o,value:n})});if(!l.ok)throw new Error(`Failed to create secret: ${await l.text()}`);s.succeed(`Created secret "${o}"`);}console.log("");}catch(c){s.fail("Failed to set secret"),c instanceof Error&&console.log(f.red(`
|
|
27
27
|
Error: ${c.message}`)),process.exit(1);}}async function ke(o){let e=K(),t=M(),s=await q(o.config),r=W(o,s,t);console.log(""),console.log(f.bold("VAIF Secrets")),console.log(""),e.start("Fetching secrets...");try{let a=new URL(`${V}/functions/secrets/project/${r}`);o.envId&&a.searchParams.set("envId",o.envId);let i=await fetch(a.toString(),{headers:{Authorization:`Bearer ${t.token}`}});if(!i.ok)throw new Error(`Failed to list secrets: ${await i.text()}`);let n=await i.json();if(e.stop(),n.length===0){console.log(f.yellow("No secrets found")),console.log(f.gray(`
|
|
28
28
|
Create one with: vaif secrets set <name> <value>`));return}let c=Math.max(8,...n.map(p=>p.key.length)),d=` ${"Name".padEnd(c)} Created`;console.log(f.gray(d)),console.log(f.gray(" "+"-".repeat(d.length-2)));for(let p of n){let g=p.key.padEnd(c),l=p.createdAt?new Date(p.createdAt).toLocaleDateString():"N/A";console.log(` ${g} ${l}`);}console.log(""),console.log(f.gray(` ${n.length} secret(s) total`)),console.log(f.gray(" Values are hidden. Use `vaif secrets get <name>` to reveal.")),console.log("");}catch(a){e.fail("Failed to list secrets"),a instanceof Error&&console.log(f.red(`
|
|
29
29
|
Error: ${a.message}`)),process.exit(1);}}async function Fe(o,e){let t=K(),s=M(),r=await q(e.config),a=W(e,r,s);console.log(""),t.start("Fetching secret...");try{let i=new URL(`${V}/functions/secrets/project/${a}`);e.envId&&i.searchParams.set("envId",e.envId);let n=await fetch(i.toString(),{headers:{Authorization:`Bearer ${s.token}`}});if(!n.ok)throw new Error(`Failed to fetch secrets: ${await n.text()}`);let d=(await n.json()).find(l=>l.key===o);d||(t.fail(`Secret "${o}" not found`),process.exit(1));let p=await fetch(`${V}/functions/secrets/${d.id}/value`,{headers:{Authorization:`Bearer ${s.token}`}});if(!p.ok)throw new Error(`Failed to get secret value: ${await p.text()}`);let g=await p.json();t.stop(),console.log(g.value);}catch(i){t.fail("Failed to get secret"),i instanceof Error&&console.log(f.red(`
|
|
30
30
|
Error: ${i.message}`)),process.exit(1);}}async function xe(o,e){let t=K(),s=M(),r=await q(e.config),a=W(e,r,s);console.log(""),console.log(f.bold("VAIF Delete Secret")),console.log(""),t.start("Finding secret...");try{let i=new URL(`${V}/functions/secrets/project/${a}`);e.envId&&i.searchParams.set("envId",e.envId);let n=await fetch(i.toString(),{headers:{Authorization:`Bearer ${s.token}`}});if(!n.ok)throw new Error(`Failed to fetch secrets: ${await n.text()}`);let d=(await n.json()).find(g=>g.key===o);d||(t.fail(`Secret "${o}" not found`),process.exit(1)),t.text=`Deleting secret "${o}"...`;let p=await fetch(`${V}/functions/secrets/${d.id}`,{method:"DELETE",headers:{Authorization:`Bearer ${s.token}`}});if(!p.ok)throw new Error(`Failed to delete secret: ${await p.text()}`);t.succeed(`Deleted secret "${o}"`),console.log("");}catch(i){t.fail("Failed to delete secret"),i instanceof Error&&console.log(f.red(`
|
|
31
|
-
Error: ${i.message}`)),process.exit(1);}}var De=process.env.VAIF_API_URL||"https://api.vaif.studio";function ro(o){try{let e=new URL(o);return e.password&&(e.password="****"),e.toString()}catch{return o.replace(/:[^@/]+@/,":****@")}}async function Ee(o){let e=K(),t=b();(!t||!t.token)&&(console.log(f.red("Not logged in")),console.log(f.gray("Run `vaif login` first to authenticate")),process.exit(1));let s=o.config||"vaif.config.json",r=null;try{r=await a(s);}catch{}let a$1=o.projectId||r?.projectId||process.env.VAIF_PROJECT_ID||t.projectId;a$1||(console.log(f.red("No project ID specified")),console.log(f.yellow("Set projectId in vaif.config.json or use --project-id flag.")),process.exit(1)),e.start("Fetching project info...");try{let i=await fetch(`${De}/
|
|
32
|
-
Error: ${i.message}`)),process.exit(1);}}var co=process.env.VAIF_API_URL||"https://api.vaif.studio";async function Re(o){let e=K(),t=b();(!t||!t.token)&&(console.log(f.red("Not logged in")),console.log(f.gray("Run `vaif login` first to authenticate")),process.exit(1));let s=o.config||"vaif.config.json",r=null;try{r=await a(s);}catch{}let a$1=o.projectId||r?.projectId||process.env.VAIF_PROJECT_ID||t.projectId;a$1||(console.log(f.red("No project ID specified")),console.log(f.yellow("Set projectId in vaif.config.json or use --project-id flag.")),process.exit(1)),e.start("Fetching project status...");try{let i=await fetch(`${co}/
|
|
31
|
+
Error: ${i.message}`)),process.exit(1);}}var De=process.env.VAIF_API_URL||"https://api.vaif.studio";function ro(o){try{let e=new URL(o);return e.password&&(e.password="****"),e.toString()}catch{return o.replace(/:[^@/]+@/,":****@")}}async function Ee(o){let e=K(),t=b();(!t||!t.token)&&(console.log(f.red("Not logged in")),console.log(f.gray("Run `vaif login` first to authenticate")),process.exit(1));let s=o.config||"vaif.config.json",r=null;try{r=await a(s);}catch{}let a$1=o.projectId||r?.projectId||process.env.VAIF_PROJECT_ID||t.projectId;a$1||(console.log(f.red("No project ID specified")),console.log(f.yellow("Set projectId in vaif.config.json or use --project-id flag.")),process.exit(1)),e.start("Fetching project info...");try{let i=await fetch(`${De}/projects/${a$1}`,{headers:{Authorization:`Bearer ${t.token}`}});if(!i.ok){let p=await i.text();throw new Error(`Failed to fetch project: ${p}`)}let n=await i.json();e.stop(),console.log(""),console.log(f.bold("VAIF Project Info")),console.log("");let c=16,d=(p,g)=>{console.log(` ${f.gray(p.padEnd(c))} ${g}`);};d("Name:",f.white(n.name||"N/A")),d("Project ID:",f.white(a$1)),d("Region:",f.white(n.region||"us-east-1")),d("Plan:",f.white(n.plan||n.tier||"free")),d("Created:",f.white(n.createdAt?new Date(n.createdAt).toLocaleDateString():"N/A")),console.log(""),d("API URL:",f.cyan(n.apiUrl||`${De}/v1`)),d("WS URL:",f.cyan(n.wsUrl||n.realtimeUrl||"N/A")),d("DB URL:",f.cyan(n.databaseUrl?ro(n.databaseUrl):"N/A")),d("Storage URL:",f.cyan(n.storageUrl||"N/A")),console.log("");}catch(i){e.fail("Failed to fetch project info"),i instanceof Error&&console.log(f.red(`
|
|
32
|
+
Error: ${i.message}`)),process.exit(1);}}var co=process.env.VAIF_API_URL||"https://api.vaif.studio";async function Re(o){let e=K(),t=b();(!t||!t.token)&&(console.log(f.red("Not logged in")),console.log(f.gray("Run `vaif login` first to authenticate")),process.exit(1));let s=o.config||"vaif.config.json",r=null;try{r=await a(s);}catch{}let a$1=o.projectId||r?.projectId||process.env.VAIF_PROJECT_ID||t.projectId;a$1||(console.log(f.red("No project ID specified")),console.log(f.yellow("Set projectId in vaif.config.json or use --project-id flag.")),process.exit(1)),e.start("Fetching project status...");try{let i=await fetch(`${co}/projects/${a$1}?include=tables,functions,storage,connections`,{headers:{Authorization:`Bearer ${t.token}`}});if(!i.ok){let y=await i.text();throw new Error(`Failed to fetch project status: ${y}`)}let n=await i.json();e.stop(),console.log(""),console.log(f.bold("VAIF Project Status")),console.log("");let c=22,d=(y,E)=>{console.log(` ${f.gray(y.padEnd(c))} ${E}`);};d("Project:",f.white(n.name||a$1)),d("Plan:",f.white(n.plan||n.tier||"free")),console.log(""),console.log(f.gray(" --- Resources ---")),console.log("");let p=n.tableCount??n.tables?.length??"N/A",g=n.functionCount??n.functions?.length??"N/A",l=n.bucketCount??n.storage?.buckets?.length??"N/A",h=n.activeConnections??n.connections??"N/A";d("Tables:",f.white(String(p))),d("Functions:",f.white(String(g))),d("Storage Buckets:",f.white(String(l))),d("Active Connections:",f.white(String(h))),n.usage&&(console.log(""),console.log(f.gray(" --- Usage ---")),console.log(""),n.usage.dbSize&&d("Database Size:",f.white(n.usage.dbSize)),n.usage.storageSize&&d("Storage Size:",f.white(n.usage.storageSize)),n.usage.bandwidth&&d("Bandwidth:",f.white(n.usage.bandwidth)),n.usage.functionInvocations!=null&&d("Function Invocations:",f.white(String(n.usage.functionInvocations)))),console.log("");}catch(i){e.fail("Failed to fetch project status"),i instanceof Error&&console.log(f.red(`
|
|
33
33
|
Error: ${i.message}`)),process.exit(1);}}var L=process.env.VAIF_API_URL||"https://api.vaif.studio";function go(o,e,t){return o.projectId||e?.projectId||process.env.VAIF_PROJECT_ID||t.projectId||null}function fo(o){if(!o||o.length===0)return "*No tables found. Create tables in the VAIF Studio dashboard.*";let e="";for(let t of o){e+=`### \`${t.name}\`
|
|
34
34
|
|
|
35
35
|
`,e+=`| Column | Type | Nullable | Default | Constraints |
|
|
@@ -222,5 +222,5 @@ All authenticated requests require:
|
|
|
222
222
|
- \`Authorization: Bearer <jwt_token>\` \u2014 for user-scoped requests
|
|
223
223
|
- \`x-api-key: <api_key>\` \u2014 for server-side / service-role requests
|
|
224
224
|
- \`x-project-id: ${e}\` \u2014 identifies the project
|
|
225
|
-
`}async function Ve(o){let e=K(),t=b();(!t||!t.token)&&(console.log(f.red("Not logged in")),console.log(f.gray("Run `vaif login` first to authenticate")),process.exit(1));let s=o.config||"vaif.config.json",r=null;try{r=await a(s);}catch{}let a$1=go(o,r,t);a$1||(console.log(f.red("No project ID specified")),console.log(f.yellow("Set projectId in vaif.config.json or use --project-id flag.")),process.exit(1));let i=I.resolve(o.outputDir||".");console.log(""),console.log(f.bold("VAIF Claude Code Setup")),console.log(f.gray(` Project: ${a$1}`)),console.log(""),e.start("Fetching database schema...");let n={tables:[]};try{let g=await fetch(`${L}/schema-engine/introspect/${a$1}`,{headers:{Authorization:`Bearer ${t.token}`}});g.ok?(n=await g.json(),e.succeed(`Fetched schema (${n.tables?.length||0} tables)`)):e.warn("Could not fetch schema \u2014 continuing without it");}catch{e.warn("Could not fetch schema \u2014 continuing without it");}e.start("Fetching project info...");let c=a$1,d=L;try{let g=await fetch(`${L}/
|
|
226
|
-
`,"utf-8"),e.succeed(`Written ${f.cyan(".mcp.json")}`);}if(!o.skipClaudeMd){e.start("Writing CLAUDE.md...");let g=mo({projectId:a$1,apiKey:p,apiUrl:d,projectName:c,schema:n}),l=I.join(i,"CLAUDE.md");D.writeFileSync(l,g,"utf-8"),e.succeed(`Written ${f.cyan("CLAUDE.md")}`);}console.log(""),console.log(f.green.bold(" Claude Code integration configured!")),console.log(""),o.skipMcp||console.log(f.gray(" MCP Server: ")+f.white(".mcp.json")),o.skipClaudeMd||console.log(f.gray(" Context: ")+f.white("CLAUDE.md")),console.log(""),console.log(f.bold(" Next steps:")),console.log(f.gray(" 1. Open this project in Claude Code")),console.log(f.gray(" 2. The MCP server auto-connects to your VAIF project")),console.log(f.gray(" 3. Ask Claude to query, modify, or build against your schema")),console.log("");}var Oe="1.8.0",X=f.hex("#00f0ff"),Z=f.hex("#7b61ff"),ee=f.hex("#ff3dff"),oe=f.hex("#00ff9d"),w=f.hex("#555570"),O=f.hex("#00f0ff");function ho(){console.log(""),console.log(X(" \u2566 \u2566")+Z("\u2554\u2550\u2557\u2566")+ee("\u2554\u2550\u2557 ")+oe("\u2554\u2550\u2557\u2566 \u2566")),console.log(X(" \u255A\u2557\u2554\u255D")+Z("\u2560\u2550\u2563\u2551")+ee("\u2560\u2563 ")+oe("\u2551 \u2551 \u2551")),console.log(X(" \u255A\u255D ")+Z("\u2569 \u2569\u2569")+ee("\u255A ")+oe("\u255A\u2550\u255D\u2569\u2550\u255D\u2569")),console.log(""),console.log(w(" \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500")),console.log(O(" VAIF Studio CLI")+w(` v${Oe}`)),console.log(w(" Build full-stack apps at lightning speed")),console.log(w(" \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500")),console.log(""),console.log(f.bold(" Quick Start")),console.log(w(" $ ")+O("vaif login")+w(" Authenticate")),console.log(w(" $ ")+O("vaif init -t react-spa")+w(" Scaffold project")),console.log(w(" $ ")+O("vaif db push")+w(" Push migrations")),console.log(w(" $ ")+O("vaif generate")+w(" Generate types")),console.log(w(" $ ")+O("vaif functions deploy")+w(" Deploy functions")),console.log(""),console.log(f.bold(" Categories")),console.log(w(" auth ")+f.white("login, logout, whoami")),console.log(w(" project ")+f.white("init, templates, info, status")),console.log(w(" schema ")+f.white("pull, push, generate")),console.log(w(" database ")+f.white("db push, db pull, db seed, db reset")),console.log(w(" deploy ")+f.white("functions deploy, functions list")),console.log(w(" security ")+f.white("keys, secrets")),console.log(w(" ai ")+f.white("claude-setup")),console.log(""),console.log(w(" Run ")+O("vaif <command> --help")+w(" for details")),console.log(w(" Docs: ")+f.underline("https://docs.vaif.studio")),console.log("");}program.name("vaif").description("VAIF CLI - Type generation and development tools").version(Oe);program.command("login").description("Authenticate with VAIF (opens browser)").option("-e, --email","Login with email/password instead of browser").option("-p, --project-id <id>","Default project ID").action(c);program.command("logout").description("Log out and remove stored credentials").action(d);program.command("whoami").description("Show current authenticated user").action(e);program.command("init").description("Initialize VAIF configuration in your project").option("--typescript","Setup for TypeScript project").option("-f, --force","Overwrite existing config").option("-t, --template <name>","Scaffold from a template (run vaif templates for list)").option("--features <features>","Comma-separated features to include: auth,database,realtime,storage,functions").option("--add-features <features>","Add features to an existing project (requires --template)").action(h);program.command("templates").alias("tpl").description("List available project templates").action(g);program.command("info").description("Show project information (name, region, URLs)").option("-c, --config <path>","Config file path","vaif.config.json").option("-p, --project-id <id>","Project ID (overrides config)").action(Ee);program.command("status").description("Show project status (tables, functions, storage, connections)").option("-c, --config <path>","Config file path","vaif.config.json").option("-p, --project-id <id>","Project ID (overrides config)").action(Re);program.command("pull").description("Pull database schema from your VAIF project").option("-c, --config <path>","Config file path","vaif.config.json").option("-o, --output <path>","Output file path","vaif.schema.json").option("-s, --schema <name>","Schema name","public").option("-p, --project-id <id>","Project ID (overrides config)").action(ce);program.command("push").description("Push local schema changes to your VAIF project").option("-c, --config <path>","Config file path","vaif.config.json").option("-s, --schema <path>","Schema file path","vaif.schema.json").option("-p, --project-id <id>","Project ID (overrides config)").option("--dry-run","Preview changes without applying").option("-f, --force","Apply changes without confirmation").action(fe);program.command("generate").alias("gen").description("Generate TypeScript types from your database schema").option("-c, --connection <url>","Database connection string").option("-o, --output <path>","Output file path","./src/types/database.ts").option("--schema <name>","Schema name","public").option("--config <path>","Config file path","vaif.config.json").option("--dry-run","Preview generated types without writing").action(f$1);var Te=program.command("functions").alias("fn").description("Manage serverless functions");Te.command("deploy").description("Deploy functions to your VAIF project").option("-c, --config <path>","Config file path","vaif.config.json").option("-p, --project-id <id>","Project ID (overrides config)").option("-e, --env-id <id>","Environment ID").option("-n, --name <name>","Function name filter").option("-r, --runtime <runtime>","Runtime (nodejs, typescript, python)").option("--entrypoint <file>","Specific entrypoint file").option("--dry-run","Preview deployment without deploying").action(me);Te.command("list").alias("ls").description("List deployed functions").option("-c, --config <path>","Config file path","vaif.config.json").option("-p, --project-id <id>","Project ID (overrides config)").option("-e, --env-id <id>","Environment ID").action(he);var G=program.command("db").description("Database management commands");G.command("push").description("Push local Drizzle migrations to VAIF project").option("-c, --config <path>","Config file path","vaif.config.json").option("-p, --project-id <id>","Project ID (overrides config)").option("-d, --dir <path>","Migrations directory","./drizzle").option("--dry-run","Preview without applying").action(je);G.command("pull").description("Pull schema from VAIF project").option("-c, --config <path>","Config file path","vaif.config.json").option("-p, --project-id <id>","Project ID (overrides config)").option("-o, --output <path>","Output file","vaif.schema.json").action(ve);G.command("seed").description("Seed your database with test data").option("-c, --config <path>","Config file path","vaif.config.json").option("-p, --project-id <id>","Project ID (overrides config)").option("-f, --file <path>","Specific seed file").option("-t, --table <name>","Seed specific table only").option("--truncate","Truncate tables before seeding").option("--dry-run","Preview seeding without inserting data").action(we);G.command("reset").description("Reset database (drop all tables and data)").option("-c, --config <path>","Config file path","vaif.config.json").option("-p, --project-id <id>","Project ID (overrides config)").option("-f, --force","Confirm reset (required)").action(Ie);var Ue=program.command("keys").description("Manage API keys");Ue.command("generate").description("Generate a new API key").option("-c, --config <path>","Config file path","vaif.config.json").option("-p, --project-id <id>","Project ID (overrides config)").option("-n, --name <name>","Key name").action(Ae);Ue.command("list").alias("ls").description("List API keys").option("-c, --config <path>","Config file path","vaif.config.json").option("-p, --project-id <id>","Project ID (overrides config)").action(Pe);var Y=program.command("secrets").alias("sec").description("Manage function secrets");Y.command("set <name> [value]").description("Create or update a secret").option("-c, --config <path>","Config file path","vaif.config.json").option("-p, --project-id <id>","Project ID (overrides config)").option("-e, --env-id <id>","Environment ID or name").option("--from-file <path>","Read secret value from a file").action(Ce);Y.command("list").alias("ls").description("List all secrets (names only)").option("-c, --config <path>","Config file path","vaif.config.json").option("-p, --project-id <id>","Project ID (overrides config)").option("-e, --env-id <id>","Environment ID or name").action(ke);Y.command("get <name>").description("Reveal a secret value").option("-c, --config <path>","Config file path","vaif.config.json").option("-p, --project-id <id>","Project ID (overrides config)").option("-e, --env-id <id>","Environment ID or name").action(Fe);Y.command("delete <name>").description("Delete a secret").option("-c, --config <path>","Config file path","vaif.config.json").option("-p, --project-id <id>","Project ID (overrides config)").option("-e, --env-id <id>","Environment ID or name").action(xe);program.command("claude-setup").description("Configure Claude Code integration (MCP server + CLAUDE.md)").option("-c, --config <path>","Config file path","vaif.config.json").option("-p, --project-id <id>","Project ID").option("-k, --api-key <key>","API key for MCP server").option("--skip-mcp","Skip generating .mcp.json").option("--skip-claude-md","Skip generating CLAUDE.md").option("-o, --output-dir <dir>","Output directory",".").action(Ve);process.argv.slice(2).length||(ho(),process.exit(0));program.parse(process.argv);
|
|
225
|
+
`}async function Ve(o){let e=K(),t=b();(!t||!t.token)&&(console.log(f.red("Not logged in")),console.log(f.gray("Run `vaif login` first to authenticate")),process.exit(1));let s=o.config||"vaif.config.json",r=null;try{r=await a(s);}catch{}let a$1=go(o,r,t);a$1||(console.log(f.red("No project ID specified")),console.log(f.yellow("Set projectId in vaif.config.json or use --project-id flag.")),process.exit(1));let i=I.resolve(o.outputDir||".");console.log(""),console.log(f.bold("VAIF Claude Code Setup")),console.log(f.gray(` Project: ${a$1}`)),console.log(""),e.start("Fetching database schema...");let n={tables:[]};try{let g=await fetch(`${L}/schema-engine/introspect/${a$1}`,{headers:{Authorization:`Bearer ${t.token}`}});g.ok?(n=await g.json(),e.succeed(`Fetched schema (${n.tables?.length||0} tables)`)):e.warn("Could not fetch schema \u2014 continuing without it");}catch{e.warn("Could not fetch schema \u2014 continuing without it");}e.start("Fetching project info...");let c=a$1,d=L;try{let g=await fetch(`${L}/projects/${a$1}`,{headers:{Authorization:`Bearer ${t.token}`}});if(g.ok){let l=await g.json();c=l.name||a$1,d=l.apiUrl||L,e.succeed(`Project: ${c}`);}else e.warn("Could not fetch project info \u2014 using defaults");}catch{e.warn("Could not fetch project info \u2014 using defaults");}let p=o.apiKey||r?.api?.apiKey||"";if(!p){e.start("Generating API key for Claude Code...");try{let g=`claude-code-${Date.now()}`,l=await fetch(`${L}/projects/${a$1}/api-keys`,{method:"POST",headers:{Authorization:`Bearer ${t.token}`,"Content-Type":"application/json"},body:JSON.stringify({name:g})});l.ok?(p=(await l.json()).key,e.succeed(`Generated API key: ${g}`)):(e.fail("Could not auto-generate API key"),console.log(f.yellow(" Pass one with --api-key or generate via `vaif keys generate`")),process.exit(1));}catch{e.fail("Could not auto-generate API key"),console.log(f.yellow(" Pass one with --api-key or generate via `vaif keys generate`")),process.exit(1);}}if(!o.skipMcp){e.start("Writing .mcp.json...");let g={mcpServers:{"vaif-studio":{command:"npx",args:["@vaiftech/mcp"],env:{VAIF_API_KEY:p,VAIF_PROJECT_ID:a$1,VAIF_API_URL:d,VAIF_AUTH_TOKEN:t.token}}}},l=I.join(i,".mcp.json");D.writeFileSync(l,JSON.stringify(g,null,2)+`
|
|
226
|
+
`,"utf-8"),e.succeed(`Written ${f.cyan(".mcp.json")}`);}if(!o.skipClaudeMd){e.start("Writing CLAUDE.md...");let g=mo({projectId:a$1,apiKey:p,apiUrl:d,projectName:c,schema:n}),l=I.join(i,"CLAUDE.md");D.writeFileSync(l,g,"utf-8"),e.succeed(`Written ${f.cyan("CLAUDE.md")}`);}console.log(""),console.log(f.green.bold(" Claude Code integration configured!")),console.log(""),o.skipMcp||console.log(f.gray(" MCP Server: ")+f.white(".mcp.json")),o.skipClaudeMd||console.log(f.gray(" Context: ")+f.white("CLAUDE.md")),console.log(""),console.log(f.bold(" Next steps:")),console.log(f.gray(" 1. Open this project in Claude Code")),console.log(f.gray(" 2. The MCP server auto-connects to your VAIF project")),console.log(f.gray(" 3. Ask Claude to query, modify, or build against your schema")),console.log("");}var Oe="1.8.1",X=f.hex("#00f0ff"),Z=f.hex("#7b61ff"),ee=f.hex("#ff3dff"),oe=f.hex("#00ff9d"),w=f.hex("#555570"),O=f.hex("#00f0ff");function ho(){console.log(""),console.log(X(" \u2566 \u2566")+Z("\u2554\u2550\u2557\u2566")+ee("\u2554\u2550\u2557 ")+oe("\u2554\u2550\u2557\u2566 \u2566")),console.log(X(" \u255A\u2557\u2554\u255D")+Z("\u2560\u2550\u2563\u2551")+ee("\u2560\u2563 ")+oe("\u2551 \u2551 \u2551")),console.log(X(" \u255A\u255D ")+Z("\u2569 \u2569\u2569")+ee("\u255A ")+oe("\u255A\u2550\u255D\u2569\u2550\u255D\u2569")),console.log(""),console.log(w(" \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500")),console.log(O(" VAIF Studio CLI")+w(` v${Oe}`)),console.log(w(" Build full-stack apps at lightning speed")),console.log(w(" \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500")),console.log(""),console.log(f.bold(" Quick Start")),console.log(w(" $ ")+O("vaif login")+w(" Authenticate")),console.log(w(" $ ")+O("vaif init -t react-spa")+w(" Scaffold project")),console.log(w(" $ ")+O("vaif db push")+w(" Push migrations")),console.log(w(" $ ")+O("vaif generate")+w(" Generate types")),console.log(w(" $ ")+O("vaif functions deploy")+w(" Deploy functions")),console.log(""),console.log(f.bold(" Categories")),console.log(w(" auth ")+f.white("login, logout, whoami")),console.log(w(" project ")+f.white("init, templates, info, status")),console.log(w(" schema ")+f.white("pull, push, generate")),console.log(w(" database ")+f.white("db push, db pull, db seed, db reset")),console.log(w(" deploy ")+f.white("functions deploy, functions list")),console.log(w(" security ")+f.white("keys, secrets")),console.log(w(" ai ")+f.white("claude-setup")),console.log(""),console.log(w(" Run ")+O("vaif <command> --help")+w(" for details")),console.log(w(" Docs: ")+f.underline("https://docs.vaif.studio")),console.log("");}program.name("vaif").description("VAIF CLI - Type generation and development tools").version(Oe);program.command("login").description("Authenticate with VAIF (opens browser)").option("-e, --email","Login with email/password instead of browser").option("-p, --project-id <id>","Default project ID").action(c);program.command("logout").description("Log out and remove stored credentials").action(d);program.command("whoami").description("Show current authenticated user").action(e);program.command("init").description("Initialize VAIF configuration in your project").option("--typescript","Setup for TypeScript project").option("-f, --force","Overwrite existing config").option("-t, --template <name>","Scaffold from a template (run vaif templates for list)").option("--features <features>","Comma-separated features to include: auth,database,realtime,storage,functions").option("--add-features <features>","Add features to an existing project (requires --template)").action(h);program.command("templates").alias("tpl").description("List available project templates").action(g);program.command("info").description("Show project information (name, region, URLs)").option("-c, --config <path>","Config file path","vaif.config.json").option("-p, --project-id <id>","Project ID (overrides config)").action(Ee);program.command("status").description("Show project status (tables, functions, storage, connections)").option("-c, --config <path>","Config file path","vaif.config.json").option("-p, --project-id <id>","Project ID (overrides config)").action(Re);program.command("pull").description("Pull database schema from your VAIF project").option("-c, --config <path>","Config file path","vaif.config.json").option("-o, --output <path>","Output file path","vaif.schema.json").option("-s, --schema <name>","Schema name","public").option("-p, --project-id <id>","Project ID (overrides config)").action(ce);program.command("push").description("Push local schema changes to your VAIF project").option("-c, --config <path>","Config file path","vaif.config.json").option("-s, --schema <path>","Schema file path","vaif.schema.json").option("-p, --project-id <id>","Project ID (overrides config)").option("--dry-run","Preview changes without applying").option("-f, --force","Apply changes without confirmation").action(fe);program.command("generate").alias("gen").description("Generate TypeScript types from your database schema").option("-c, --connection <url>","Database connection string").option("-o, --output <path>","Output file path","./src/types/database.ts").option("--schema <name>","Schema name","public").option("--config <path>","Config file path","vaif.config.json").option("--dry-run","Preview generated types without writing").action(f$1);var Te=program.command("functions").alias("fn").description("Manage serverless functions");Te.command("deploy").description("Deploy functions to your VAIF project").option("-c, --config <path>","Config file path","vaif.config.json").option("-p, --project-id <id>","Project ID (overrides config)").option("-e, --env-id <id>","Environment ID").option("-n, --name <name>","Function name filter").option("-r, --runtime <runtime>","Runtime (nodejs, typescript, python)").option("--entrypoint <file>","Specific entrypoint file").option("--dry-run","Preview deployment without deploying").action(me);Te.command("list").alias("ls").description("List deployed functions").option("-c, --config <path>","Config file path","vaif.config.json").option("-p, --project-id <id>","Project ID (overrides config)").option("-e, --env-id <id>","Environment ID").action(he);var G=program.command("db").description("Database management commands");G.command("push").description("Push local Drizzle migrations to VAIF project").option("-c, --config <path>","Config file path","vaif.config.json").option("-p, --project-id <id>","Project ID (overrides config)").option("-d, --dir <path>","Migrations directory","./drizzle").option("--dry-run","Preview without applying").action(je);G.command("pull").description("Pull schema from VAIF project").option("-c, --config <path>","Config file path","vaif.config.json").option("-p, --project-id <id>","Project ID (overrides config)").option("-o, --output <path>","Output file","vaif.schema.json").action(ve);G.command("seed").description("Seed your database with test data").option("-c, --config <path>","Config file path","vaif.config.json").option("-p, --project-id <id>","Project ID (overrides config)").option("-f, --file <path>","Specific seed file").option("-t, --table <name>","Seed specific table only").option("--truncate","Truncate tables before seeding").option("--dry-run","Preview seeding without inserting data").action(we);G.command("reset").description("Reset database (drop all tables and data)").option("-c, --config <path>","Config file path","vaif.config.json").option("-p, --project-id <id>","Project ID (overrides config)").option("-f, --force","Confirm reset (required)").action(Ie);var Ue=program.command("keys").description("Manage API keys");Ue.command("generate").description("Generate a new API key").option("-c, --config <path>","Config file path","vaif.config.json").option("-p, --project-id <id>","Project ID (overrides config)").option("-n, --name <name>","Key name").action(Ae);Ue.command("list").alias("ls").description("List API keys").option("-c, --config <path>","Config file path","vaif.config.json").option("-p, --project-id <id>","Project ID (overrides config)").action(Pe);var Y=program.command("secrets").alias("sec").description("Manage function secrets");Y.command("set <name> [value]").description("Create or update a secret").option("-c, --config <path>","Config file path","vaif.config.json").option("-p, --project-id <id>","Project ID (overrides config)").option("-e, --env-id <id>","Environment ID or name").option("--from-file <path>","Read secret value from a file").action(Ce);Y.command("list").alias("ls").description("List all secrets (names only)").option("-c, --config <path>","Config file path","vaif.config.json").option("-p, --project-id <id>","Project ID (overrides config)").option("-e, --env-id <id>","Environment ID or name").action(ke);Y.command("get <name>").description("Reveal a secret value").option("-c, --config <path>","Config file path","vaif.config.json").option("-p, --project-id <id>","Project ID (overrides config)").option("-e, --env-id <id>","Environment ID or name").action(Fe);Y.command("delete <name>").description("Delete a secret").option("-c, --config <path>","Config file path","vaif.config.json").option("-p, --project-id <id>","Project ID (overrides config)").option("-e, --env-id <id>","Environment ID or name").action(xe);program.command("claude-setup").description("Configure Claude Code integration (MCP server + CLAUDE.md)").option("-c, --config <path>","Config file path","vaif.config.json").option("-p, --project-id <id>","Project ID").option("-k, --api-key <key>","API key for MCP server").option("--skip-mcp","Skip generating .mcp.json").option("--skip-claude-md","Skip generating CLAUDE.md").option("-o, --output-dir <dir>","Output directory",".").action(Ve);process.argv.slice(2).length||(ho(),process.exit(0));program.parse(process.argv);
|