@vaiftech/cli 1.3.0 → 1.3.2

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/README.md CHANGED
@@ -3,7 +3,7 @@
3
3
  [![npm version](https://img.shields.io/npm/v/@vaiftech/cli)](https://www.npmjs.com/package/@vaiftech/cli)
4
4
  [![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](https://opensource.org/licenses/MIT)
5
5
 
6
- Command-line tools for [VAIF Studio](https://vaif.studio) - scaffold projects from templates, manage schemas, deploy functions, generate TypeScript types, and more.
6
+ Command-line tools for [VAIF Studio](https://vaif.studio) scaffold full projects from templates, manage schemas, deploy functions, generate TypeScript types, and more.
7
7
 
8
8
  ## Installation
9
9
 
@@ -16,14 +16,14 @@ npx @vaiftech/cli init --template react-spa
16
16
  ## Quick Start
17
17
 
18
18
  ```bash
19
- # Scaffold a new project from a template
20
- npx @vaiftech/cli init --template nextjs-fullstack
19
+ # Authenticate (opens browser)
20
+ vaif login
21
21
 
22
- # Or initialize a plain config
23
- vaif init
22
+ # Scaffold a new project from a template
23
+ vaif init --template nextjs-fullstack
24
24
 
25
- # Authenticate with your VAIF account
26
- vaif login
25
+ # Scaffold with specific features
26
+ vaif init --template react-spa --features auth,realtime,storage
27
27
 
28
28
  # Pull your database schema and generate types
29
29
  vaif pull
@@ -33,6 +33,32 @@ vaif generate
33
33
  vaif functions deploy
34
34
  ```
35
35
 
36
+ ## Authentication
37
+
38
+ VAIF CLI uses **browser-based authentication** by default. Running `vaif login` opens your browser to authenticate with your VAIF account, then the CLI receives the session automatically.
39
+
40
+ ```bash
41
+ # Default: browser-based login (recommended)
42
+ vaif login
43
+
44
+ # Fallback: email/password login
45
+ vaif login --email
46
+
47
+ # Check current session
48
+ vaif whoami
49
+
50
+ # Log out
51
+ vaif logout
52
+ ```
53
+
54
+ The browser flow works by:
55
+ 1. CLI requests a temporary auth code from the VAIF API
56
+ 2. Your browser opens to the VAIF login/authorization page
57
+ 3. After you approve, the CLI receives your session token
58
+ 4. Credentials are saved securely to `~/.vaif/auth.json`
59
+
60
+ If the browser doesn't open automatically, the CLI prints the URL for you to copy.
61
+
36
62
  ## Templates
37
63
 
38
64
  Scaffold a fully configured VAIF Studio project with one command:
@@ -41,8 +67,6 @@ Scaffold a fully configured VAIF Studio project with one command:
41
67
  vaif init --template <name>
42
68
  ```
43
69
 
44
- Each template creates `vaif.config.json` plus platform-specific integration files (client setup, auth helpers, environment config).
45
-
46
70
  ### Available Templates
47
71
 
48
72
  | Template | Description | Ecosystem |
@@ -60,35 +84,67 @@ Each template creates `vaif.config.json` plus platform-specific integration file
60
84
  | `ecommerce-api` | E-commerce backend with products, orders, Stripe webhooks, and inventory | Node.js |
61
85
 
62
86
  ```bash
63
- # List all templates
87
+ # List all templates with descriptions
64
88
  vaif templates
65
89
 
66
90
  # Scaffold and overwrite existing files
67
91
  vaif init --template expo-mobile-app --force
68
92
  ```
69
93
 
70
- ### What Templates Create
94
+ ### Feature Selection
95
+
96
+ Templates support **feature selection** to include only the VAIF modules you need. Specify features with `--features` or use the interactive selector:
97
+
98
+ ```bash
99
+ # Specify features directly
100
+ vaif init --template react-spa --features auth,realtime,storage
101
+
102
+ # Interactive feature selection (prompted when --features is omitted)
103
+ vaif init --template nextjs-fullstack
104
+ # → Presents checkbox UI to pick: Database, Auth, Realtime, Storage, Functions
105
+ ```
106
+
107
+ #### Available Features
108
+
109
+ | Feature | What it adds |
110
+ |---------|-------------|
111
+ | `database` | CRUD queries, type-safe database operations |
112
+ | `auth` | Login, signup, OAuth, session management pages |
113
+ | `realtime` | Live subscriptions, presence tracking hooks |
114
+ | `storage` | File upload/download, signed URL helpers |
115
+ | `functions` | Serverless function invocation utilities |
116
+
117
+ Each template has sensible defaults (e.g. `nextjs-fullstack` defaults to `database` + `auth`), but you can customize freely. Feature-specific files are only generated when the feature is selected — for example, selecting `auth` adds login/signup pages, selecting `storage` adds upload hooks.
118
+
119
+ ### What Templates Generate
120
+
121
+ Templates generate **complete project scaffolding**, not just config files:
71
122
 
72
123
  **JavaScript/TypeScript templates** (nextjs-fullstack, react-spa, etc.):
73
- - `vaif.config.json` - Project configuration
74
- - `lib/vaif.ts` or `src/lib/vaif.ts` - Client initialization
75
- - `.env.example` or `.env.local.example` - Environment variables
76
- - Platform-specific files (middleware, providers, hooks)
77
- - Prints `npm install` command with required dependencies
124
+ - `package.json` with all VAIF SDK dependencies pre-configured
125
+ - `tsconfig.json` TypeScript configuration
126
+ - `vaif.config.json` VAIF project configuration
127
+ - `src/lib/vaif.ts` Client initialization
128
+ - `.env.example` Environment variables template
129
+ - `app/` or `src/` — Full app structure (layout, pages, components)
130
+ - Feature-conditional files (auth pages, storage hooks, realtime hooks)
131
+ - Prints next steps after scaffolding
78
132
 
79
133
  **Native/Backend templates** (ios-swift-app, flutter-app, python-fastapi-backend, go-backend-api):
80
- - `vaif.config.json` - Project configuration
81
- - Platform integration files (VaifManager.swift, vaif_client.py, etc.)
82
- - `.env.example` - Environment variables
83
- - `requirements.txt` / `README-VAIF.md` with setup instructions
134
+ - `vaif.config.json` Project configuration
135
+ - Platform-specific project files (Package.swift, pubspec.yaml, requirements.txt, go.mod)
136
+ - Client initialization and integration files
137
+ - `.env.example` Environment variables
138
+ - Setup instructions
84
139
 
85
140
  ## Commands
86
141
 
87
142
  ### Authentication
88
143
 
89
144
  ```bash
90
- vaif login # Interactive login
91
- vaif login --token <api-token> # Login with token
145
+ vaif login # Browser-based login (opens browser)
146
+ vaif login --email # Email/password login
147
+ vaif login --project-id <id> # Login and set default project
92
148
  vaif whoami # Show current user
93
149
  vaif logout # Log out
94
150
  ```
@@ -98,10 +154,18 @@ vaif logout # Log out
98
154
  ```bash
99
155
  vaif init # Create vaif.config.json
100
156
  vaif init --template react-spa # Scaffold from template
157
+ vaif init --template nextjs-fullstack --features auth,storage
101
158
  vaif init --typescript # Setup for TypeScript
102
159
  vaif init --force # Overwrite existing config
103
160
  ```
104
161
 
162
+ ### Templates
163
+
164
+ ```bash
165
+ vaif templates # List all available templates
166
+ vaif tpl # Alias
167
+ ```
168
+
105
169
  ### Project Info
106
170
 
107
171
  ```bash
@@ -186,9 +250,9 @@ vaif keys list # List all keys
186
250
 
187
251
  | Package | Description |
188
252
  |---------|-------------|
189
- | [@vaiftech/client](https://www.npmjs.com/package/@vaiftech/client) | TypeScript SDK - database, auth, realtime, storage, functions |
190
- | [@vaiftech/auth](https://www.npmjs.com/package/@vaiftech/auth) | Standalone auth SDK - OAuth, MFA, sessions |
191
- | [@vaiftech/react](https://www.npmjs.com/package/@vaiftech/react) | React hooks - useAuth, useQuery, useRealtime |
253
+ | [@vaiftech/client](https://www.npmjs.com/package/@vaiftech/client) | TypeScript SDK database, auth, realtime, storage, functions |
254
+ | [@vaiftech/auth](https://www.npmjs.com/package/@vaiftech/auth) | Standalone auth SDK OAuth, MFA, sessions |
255
+ | [@vaiftech/react](https://www.npmjs.com/package/@vaiftech/react) | React hooks useAuth, useQuery, useRealtime |
192
256
  | [@vaiftech/sdk-expo](https://www.npmjs.com/package/@vaiftech/sdk-expo) | React Native / Expo SDK |
193
257
  | [@vaiftechnologies/vaif-client](https://www.npmjs.com/package/@vaiftechnologies/vaif-client) | JavaScript SDK |
194
258
 
package/dist/cli.cjs CHANGED
@@ -2100,4 +2100,4 @@ Error: ${r.message}`)),process.exit(1);}}async function ke(t){let e=K__default.d
2100
2100
  Generate one with: vaif keys generate`));return}let c=Math.max(8,...s.map(u=>(u.name||"").length)),f=` ${"Name".padEnd(c)} ${"Key".padEnd(24)} Created`;console.log(d__default.default.gray(f)),console.log(d__default.default.gray(" "+"-".repeat(f.length-2)));for(let u of s){let p=(u.name||"unnamed").padEnd(c),h=u.maskedKey||u.prefix||`${(u.key||"").slice(0,12)}...`,x=u.createdAt?new Date(u.createdAt).toLocaleDateString():"N/A";console.log(` ${p} ${h.padEnd(24)} ${x}`);}console.log(""),console.log(d__default.default.gray(` ${s.length} key(s) total`)),console.log("");}catch(a){e.fail("Failed to list API keys"),a instanceof Error&&console.log(d__default.default.red(`
2101
2101
  Error: ${a.message}`)),process.exit(1);}}var Ve=process.env.VAIF_API_URL||"https://api.vaif.studio";function At(t){try{let e=new URL(t);return e.password&&(e.password="****"),e.toString()}catch{return t.replace(/:[^@/]+@/,":****@")}}async function De(t){let e=K__default.default(),o=w();(!o||!o.token)&&(console.log(d__default.default.red("Not logged in")),console.log(d__default.default.gray("Run `vaif login` first to authenticate")),process.exit(1));let n=t.config||"vaif.config.json",i=null;try{i=await I(n);}catch{}let l=t.projectId||i?.projectId||o.projectId;l||(console.log(d__default.default.red("No project ID specified")),console.log(d__default.default.yellow("Set projectId in vaif.config.json or use --project-id flag.")),process.exit(1)),e.start("Fetching project info...");try{let a=await fetch(`${Ve}/v1/projects/${l}`,{headers:{Authorization:`Bearer ${o.token}`}});if(!a.ok){let f=await a.text();throw new Error(`Failed to fetch project: ${f}`)}let r=await a.json();e.stop(),console.log(""),console.log(d__default.default.bold("VAIF Project Info")),console.log("");let s=16,c=(f,u)=>{console.log(` ${d__default.default.gray(f.padEnd(s))} ${u}`);};c("Name:",d__default.default.white(r.name||"N/A")),c("Project ID:",d__default.default.white(l)),c("Region:",d__default.default.white(r.region||"us-east-1")),c("Plan:",d__default.default.white(r.plan||r.tier||"free")),c("Created:",d__default.default.white(r.createdAt?new Date(r.createdAt).toLocaleDateString():"N/A")),console.log(""),c("API URL:",d__default.default.cyan(r.apiUrl||`${Ve}/v1`)),c("WS URL:",d__default.default.cyan(r.wsUrl||r.realtimeUrl||"N/A")),c("DB URL:",d__default.default.cyan(r.databaseUrl?At(r.databaseUrl):"N/A")),c("Storage URL:",d__default.default.cyan(r.storageUrl||"N/A")),console.log("");}catch(a){e.fail("Failed to fetch project info"),a instanceof Error&&console.log(d__default.default.red(`
2102
2102
  Error: ${a.message}`)),process.exit(1);}}var Pt=process.env.VAIF_API_URL||"https://api.vaif.studio";async function $e(t){let e=K__default.default(),o=w();(!o||!o.token)&&(console.log(d__default.default.red("Not logged in")),console.log(d__default.default.gray("Run `vaif login` first to authenticate")),process.exit(1));let n=t.config||"vaif.config.json",i=null;try{i=await I(n);}catch{}let l=t.projectId||i?.projectId||o.projectId;l||(console.log(d__default.default.red("No project ID specified")),console.log(d__default.default.yellow("Set projectId in vaif.config.json or use --project-id flag.")),process.exit(1)),e.start("Fetching project status...");try{let a=await fetch(`${Pt}/v1/projects/${l}?include=tables,functions,storage,connections`,{headers:{Authorization:`Bearer ${o.token}`}});if(!a.ok){let x=await a.text();throw new Error(`Failed to fetch project status: ${x}`)}let r=await a.json();e.stop(),console.log(""),console.log(d__default.default.bold("VAIF Project Status")),console.log("");let s=22,c=(x,R)=>{console.log(` ${d__default.default.gray(x.padEnd(s))} ${R}`);};c("Project:",d__default.default.white(r.name||l)),c("Plan:",d__default.default.white(r.plan||r.tier||"free")),console.log(""),console.log(d__default.default.gray(" --- Resources ---")),console.log("");let f=r.tableCount??r.tables?.length??"N/A",u=r.functionCount??r.functions?.length??"N/A",p=r.bucketCount??r.storage?.buckets?.length??"N/A",h=r.activeConnections??r.connections??"N/A";c("Tables:",d__default.default.white(String(f))),c("Functions:",d__default.default.white(String(u))),c("Storage Buckets:",d__default.default.white(String(p))),c("Active Connections:",d__default.default.white(String(h))),r.usage&&(console.log(""),console.log(d__default.default.gray(" --- Usage ---")),console.log(""),r.usage.dbSize&&c("Database Size:",d__default.default.white(r.usage.dbSize)),r.usage.storageSize&&c("Storage Size:",d__default.default.white(r.usage.storageSize)),r.usage.bandwidth&&c("Bandwidth:",d__default.default.white(r.usage.bandwidth)),r.usage.functionInvocations!=null&&c("Function Invocations:",d__default.default.white(String(r.usage.functionInvocations)))),console.log("");}catch(a){e.fail("Failed to fetch project status"),a instanceof Error&&console.log(d__default.default.red(`
2103
- Error: ${a.message}`)),process.exit(1);}}commander.program.name("vaif").description("VAIF CLI - Type generation and development tools").version("1.3.0");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(pe);commander.program.command("logout").description("Log out and remove stored credentials").action(ue);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").action(se);commander.program.command("templates").alias("tpl").description("List available project templates").action(ae);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(De);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($e);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(ge);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(ye);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(te);var Ue=commander.program.command("functions").alias("fn").description("Manage serverless functions");Ue.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(_e);Ue.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(xe);var z=commander.program.command("db").description("Database management commands");z.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(Ee);z.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(Pe);z.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(Ae);z.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(Te);var Ne=commander.program.command("keys").description("Manage API keys");Ne.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(Re);Ne.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(ke);commander.program.parse(process.argv);process.argv.slice(2).length||commander.program.outputHelp();
2103
+ Error: ${a.message}`)),process.exit(1);}}commander.program.name("vaif").description("VAIF CLI - Type generation and development tools").version("1.3.2");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(pe);commander.program.command("logout").description("Log out and remove stored credentials").action(ue);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").action(se);commander.program.command("templates").alias("tpl").description("List available project templates").action(ae);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(De);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($e);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(ge);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(ye);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(te);var Ue=commander.program.command("functions").alias("fn").description("Manage serverless functions");Ue.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(_e);Ue.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(xe);var z=commander.program.command("db").description("Database management commands");z.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(Ee);z.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(Pe);z.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(Ae);z.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(Te);var Ne=commander.program.command("keys").description("Manage API keys");Ne.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(Re);Ne.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(ke);commander.program.parse(process.argv);process.argv.slice(2).length||commander.program.outputHelp();
package/dist/cli.js CHANGED
@@ -34,4 +34,4 @@ Error: ${n.message}`)),process.exit(1);}}async function wo(e){let o=V(),t=j();(!
34
34
  Generate one with: vaif keys generate`));return}let d=Math.max(8,...a.map(f=>(f.name||"").length)),p=` ${"Name".padEnd(d)} ${"Key".padEnd(24)} Created`;console.log(c$1.gray(p)),console.log(c$1.gray(" "+"-".repeat(p.length-2)));for(let f of a){let g=(f.name||"unnamed").padEnd(d),y=f.maskedKey||f.prefix||`${(f.key||"").slice(0,12)}...`,$=f.createdAt?new Date(f.createdAt).toLocaleDateString():"N/A";console.log(` ${g} ${y.padEnd(24)} ${$}`);}console.log(""),console.log(c$1.gray(` ${a.length} key(s) total`)),console.log("");}catch(s){o.fail("Failed to list API keys"),s instanceof Error&&console.log(c$1.red(`
35
35
  Error: ${s.message}`)),process.exit(1);}}var jo=process.env.VAIF_API_URL||"https://api.vaif.studio";function Qo(e){try{let o=new URL(e);return o.password&&(o.password="****"),o.toString()}catch{return e.replace(/:[^@/]+@/,":****@")}}async function vo(e){let o=V(),t=j();(!t||!t.token)&&(console.log(c$1.red("Not logged in")),console.log(c$1.gray("Run `vaif login` first to authenticate")),process.exit(1));let i=e.config||"vaif.config.json",r=null;try{r=await a(i);}catch{}let l=e.projectId||r?.projectId||t.projectId;l||(console.log(c$1.red("No project ID specified")),console.log(c$1.yellow("Set projectId in vaif.config.json or use --project-id flag.")),process.exit(1)),o.start("Fetching project info...");try{let s=await fetch(`${jo}/v1/projects/${l}`,{headers:{Authorization:`Bearer ${t.token}`}});if(!s.ok){let p=await s.text();throw new Error(`Failed to fetch project: ${p}`)}let n=await s.json();o.stop(),console.log(""),console.log(c$1.bold("VAIF Project Info")),console.log("");let a=16,d=(p,f)=>{console.log(` ${c$1.gray(p.padEnd(a))} ${f}`);};d("Name:",c$1.white(n.name||"N/A")),d("Project ID:",c$1.white(l)),d("Region:",c$1.white(n.region||"us-east-1")),d("Plan:",c$1.white(n.plan||n.tier||"free")),d("Created:",c$1.white(n.createdAt?new Date(n.createdAt).toLocaleDateString():"N/A")),console.log(""),d("API URL:",c$1.cyan(n.apiUrl||`${jo}/v1`)),d("WS URL:",c$1.cyan(n.wsUrl||n.realtimeUrl||"N/A")),d("DB URL:",c$1.cyan(n.databaseUrl?Qo(n.databaseUrl):"N/A")),d("Storage URL:",c$1.cyan(n.storageUrl||"N/A")),console.log("");}catch(s){o.fail("Failed to fetch project info"),s instanceof Error&&console.log(c$1.red(`
36
36
  Error: ${s.message}`)),process.exit(1);}}var Zo=process.env.VAIF_API_URL||"https://api.vaif.studio";async function Io(e){let o=V(),t=j();(!t||!t.token)&&(console.log(c$1.red("Not logged in")),console.log(c$1.gray("Run `vaif login` first to authenticate")),process.exit(1));let i=e.config||"vaif.config.json",r=null;try{r=await a(i);}catch{}let l=e.projectId||r?.projectId||t.projectId;l||(console.log(c$1.red("No project ID specified")),console.log(c$1.yellow("Set projectId in vaif.config.json or use --project-id flag.")),process.exit(1)),o.start("Fetching project status...");try{let s=await fetch(`${Zo}/v1/projects/${l}?include=tables,functions,storage,connections`,{headers:{Authorization:`Bearer ${t.token}`}});if(!s.ok){let $=await s.text();throw new Error(`Failed to fetch project status: ${$}`)}let n=await s.json();o.stop(),console.log(""),console.log(c$1.bold("VAIF Project Status")),console.log("");let a=22,d=($,k)=>{console.log(` ${c$1.gray($.padEnd(a))} ${k}`);};d("Project:",c$1.white(n.name||l)),d("Plan:",c$1.white(n.plan||n.tier||"free")),console.log(""),console.log(c$1.gray(" --- Resources ---")),console.log("");let p=n.tableCount??n.tables?.length??"N/A",f=n.functionCount??n.functions?.length??"N/A",g=n.bucketCount??n.storage?.buckets?.length??"N/A",y=n.activeConnections??n.connections??"N/A";d("Tables:",c$1.white(String(p))),d("Functions:",c$1.white(String(f))),d("Storage Buckets:",c$1.white(String(g))),d("Active Connections:",c$1.white(String(y))),n.usage&&(console.log(""),console.log(c$1.gray(" --- Usage ---")),console.log(""),n.usage.dbSize&&d("Database Size:",c$1.white(n.usage.dbSize)),n.usage.storageSize&&d("Storage Size:",c$1.white(n.usage.storageSize)),n.usage.bandwidth&&d("Bandwidth:",c$1.white(n.usage.bandwidth)),n.usage.functionInvocations!=null&&d("Function Invocations:",c$1.white(String(n.usage.functionInvocations)))),console.log("");}catch(s){o.fail("Failed to fetch project status"),s instanceof Error&&console.log(c$1.red(`
37
- Error: ${s.message}`)),process.exit(1);}}program.name("vaif").description("VAIF CLI - Type generation and development tools").version("1.3.0");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(Y);program.command("logout").description("Log out and remove stored credentials").action(H);program.command("whoami").description("Show current authenticated user").action(Q);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").action(d);program.command("templates").alias("tpl").description("List available project templates").action(c);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(vo);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(Io);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(X);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(eo);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(b);var bo=program.command("functions").alias("fn").description("Manage serverless functions");bo.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(ro);bo.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(co);var U=program.command("db").description("Database management commands");U.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(go);U.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(fo);U.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(lo);U.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(po);var $o=program.command("keys").description("Manage API keys");$o.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(yo);$o.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(wo);program.parse(process.argv);process.argv.slice(2).length||program.outputHelp();
37
+ Error: ${s.message}`)),process.exit(1);}}program.name("vaif").description("VAIF CLI - Type generation and development tools").version("1.3.2");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(Y);program.command("logout").description("Log out and remove stored credentials").action(H);program.command("whoami").description("Show current authenticated user").action(Q);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").action(d);program.command("templates").alias("tpl").description("List available project templates").action(c);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(vo);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(Io);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(X);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(eo);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(b);var bo=program.command("functions").alias("fn").description("Manage serverless functions");bo.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(ro);bo.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(co);var U=program.command("db").description("Database management commands");U.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(go);U.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(fo);U.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(lo);U.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(po);var $o=program.command("keys").description("Manage API keys");$o.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(yo);$o.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(wo);program.parse(process.argv);process.argv.slice(2).length||program.outputHelp();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vaiftech/cli",
3
- "version": "1.3.0",
3
+ "version": "1.3.2",
4
4
  "description": "VAIF CLI - Type generation and development tools",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",