@vaiftech/cli 1.1.0 → 1.3.0

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
@@ -1,120 +1,200 @@
1
1
  # @vaiftech/cli
2
2
 
3
- Command-line tools for VAIF Studio - a Backend-as-a-Service platform.
3
+ [![npm version](https://img.shields.io/npm/v/@vaiftech/cli)](https://www.npmjs.com/package/@vaiftech/cli)
4
+ [![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](https://opensource.org/licenses/MIT)
5
+
6
+ Command-line tools for [VAIF Studio](https://vaif.studio) - scaffold projects from templates, manage schemas, deploy functions, generate TypeScript types, and more.
4
7
 
5
8
  ## Installation
6
9
 
7
10
  ```bash
8
- npm install -D @vaiftech/cli
9
- # or
10
- pnpm add -D @vaiftech/cli
11
- # or
12
- yarn add -D @vaiftech/cli
11
+ npm install -g @vaiftech/cli
12
+ # or use directly with npx
13
+ npx @vaiftech/cli init --template react-spa
13
14
  ```
14
15
 
15
- ## Features
16
+ ## Quick Start
16
17
 
17
- ### Type Generation
18
+ ```bash
19
+ # Scaffold a new project from a template
20
+ npx @vaiftech/cli init --template nextjs-fullstack
21
+
22
+ # Or initialize a plain config
23
+ vaif init
24
+
25
+ # Authenticate with your VAIF account
26
+ vaif login
18
27
 
19
- Generate TypeScript types from your VAIF database schema.
28
+ # Pull your database schema and generate types
29
+ vaif pull
30
+ vaif generate
31
+
32
+ # Deploy functions
33
+ vaif functions deploy
34
+ ```
35
+
36
+ ## Templates
37
+
38
+ Scaffold a fully configured VAIF Studio project with one command:
20
39
 
21
40
  ```bash
22
- npx vaif types generate --project <project-id> --output ./src/types/database.ts
41
+ vaif init --template <name>
23
42
  ```
24
43
 
25
- #### Options
44
+ Each template creates `vaif.config.json` plus platform-specific integration files (client setup, auth helpers, environment config).
45
+
46
+ ### Available Templates
26
47
 
27
- | Flag | Description | Default |
28
- |------|-------------|---------|
29
- | `--project` | Project ID | Required |
30
- | `--output` | Output file path | `./vaif.types.ts` |
31
- | `--env` | Environment (development, staging, production) | `development` |
48
+ | Template | Description | Ecosystem |
49
+ |----------|-------------|-----------|
50
+ | `nextjs-fullstack` | Next.js app with server/client VAIF client, auth middleware, and React hooks | Next.js |
51
+ | `react-spa` | React SPA with VaifProvider, hooks for queries/mutations, and env setup | React / Vite |
52
+ | `ios-swift-app` | iOS app with VaifManager singleton, SwiftUI auth, and database helpers | Swift / iOS |
53
+ | `expo-mobile-app` | React Native / Expo with realtime hooks, storage uploads, and push notifications | Expo |
54
+ | `flutter-app` | Flutter app with VaifClient, auth flows, and typed database queries | Flutter / Dart |
55
+ | `python-fastapi-backend` | FastAPI server with VAIF auth middleware, database queries, and storage uploads | Python |
56
+ | `go-backend-api` | Go HTTP server with VAIF client, auth verification, and webhook handling | Go |
57
+ | `todo-app` | Minimal React + VAIF starter for learning the basics | React |
58
+ | `realtime-chat` | Real-time messaging app with presence tracking and live subscriptions | React |
59
+ | `saas-starter` | SaaS foundation with teams, org management, auth, and billing hooks | React / Node.js |
60
+ | `ecommerce-api` | E-commerce backend with products, orders, Stripe webhooks, and inventory | Node.js |
32
61
 
33
- #### Example Output
62
+ ```bash
63
+ # List all templates
64
+ vaif templates
34
65
 
35
- ```typescript
36
- // Generated by @vaiftech/cli
66
+ # Scaffold and overwrite existing files
67
+ vaif init --template expo-mobile-app --force
68
+ ```
37
69
 
38
- export interface User {
39
- id: string;
40
- email: string;
41
- name: string | null;
42
- avatar_url: string | null;
43
- created_at: string;
44
- updated_at: string;
45
- }
70
+ ### What Templates Create
46
71
 
47
- export interface Post {
48
- id: string;
49
- title: string;
50
- content: string;
51
- author_id: string;
52
- published: boolean;
53
- created_at: string;
54
- updated_at: string;
55
- }
72
+ **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
56
78
 
57
- export interface Database {
58
- users: User;
59
- posts: Post;
60
- }
79
+ **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
84
+
85
+ ## Commands
86
+
87
+ ### Authentication
88
+
89
+ ```bash
90
+ vaif login # Interactive login
91
+ vaif login --token <api-token> # Login with token
92
+ vaif whoami # Show current user
93
+ vaif logout # Log out
61
94
  ```
62
95
 
63
- ### Programmatic Usage
96
+ ### Project Setup
64
97
 
65
- ```typescript
66
- import { generateTypes } from '@vaiftech/cli';
98
+ ```bash
99
+ vaif init # Create vaif.config.json
100
+ vaif init --template react-spa # Scaffold from template
101
+ vaif init --typescript # Setup for TypeScript
102
+ vaif init --force # Overwrite existing config
103
+ ```
67
104
 
68
- const types = await generateTypes({
69
- projectId: 'proj-123',
70
- apiKey: 'vaif_sk_xxx',
71
- baseUrl: 'https://api.vaif.io',
72
- });
105
+ ### Project Info
73
106
 
74
- // types is a string containing TypeScript definitions
75
- console.log(types);
107
+ ```bash
108
+ vaif info # Project details (name, region, URLs)
109
+ vaif status # Tables, functions, storage, connections
76
110
  ```
77
111
 
78
- ## Configuration
112
+ ### Schema Management
113
+
114
+ ```bash
115
+ vaif pull # Pull database schema from remote
116
+ vaif push # Push local schema changes
117
+ vaif push --dry-run # Preview changes without applying
118
+ ```
79
119
 
80
- Create a `vaif.config.js` file in your project root:
120
+ ### Type Generation
81
121
 
82
- ```javascript
83
- module.exports = {
84
- projectId: 'proj-123',
85
- output: './src/types/vaif.ts',
86
- };
122
+ ```bash
123
+ vaif generate # Generate TypeScript types
124
+ vaif generate --output ./types.ts # Custom output path
125
+ vaif generate --dry-run # Preview without writing
126
+ vaif gen # Alias
87
127
  ```
88
128
 
89
- Then run without flags:
129
+ ### Functions
90
130
 
91
131
  ```bash
92
- npx vaif types generate
132
+ vaif functions deploy # Deploy all functions
133
+ vaif functions deploy --name myFunc # Deploy specific function
134
+ vaif functions list # List deployed functions
135
+ vaif fn ls # Alias
93
136
  ```
94
137
 
95
- ## Usage with @vaiftech/client
138
+ ### Database
96
139
 
97
- Use generated types with the client SDK:
140
+ ```bash
141
+ vaif db push # Push Drizzle migrations
142
+ vaif db pull # Pull remote schema
143
+ vaif db seed # Seed with test data
144
+ vaif db seed --truncate # Truncate before seeding
145
+ vaif db reset --force # Reset database (destructive)
146
+ ```
98
147
 
99
- ```typescript
100
- import { createVaifClient } from '@vaiftech/client';
101
- import type { User, Post, Database } from './types/vaif';
148
+ ### API Keys
102
149
 
103
- const vaif = createVaifClient({
104
- baseUrl: 'https://api.myproject.vaif.io',
105
- apiKey: 'vaif_pk_xxx',
106
- });
150
+ ```bash
151
+ vaif keys generate # Generate new API key
152
+ vaif keys generate --name "Prod" # Named key
153
+ vaif keys list # List all keys
154
+ ```
107
155
 
108
- // Fully typed queries
109
- const users = await vaif.from<User>('users').list();
110
- const post = await vaif.from<Post>('posts').eq('id', 'post-123').single();
156
+ ## Configuration
157
+
158
+ `vaif.config.json` (created by `vaif init`):
159
+
160
+ ```json
161
+ {
162
+ "$schema": "https://vaif.studio/schemas/config.json",
163
+ "projectId": "your-project-id",
164
+ "database": {
165
+ "url": "${DATABASE_URL}",
166
+ "schema": "public"
167
+ },
168
+ "types": {
169
+ "output": "./src/types/database.ts"
170
+ },
171
+ "api": {
172
+ "baseUrl": "https://api.vaif.studio"
173
+ }
174
+ }
111
175
  ```
112
176
 
177
+ ## Environment Variables
178
+
179
+ | Variable | Description |
180
+ |----------|-------------|
181
+ | `VAIF_API_URL` | API base URL (default: `https://api.vaif.studio`) |
182
+ | `VAIF_TOKEN` | API token (alternative to `vaif login`) |
183
+ | `VAIF_PROJECT_ID` | Default project ID |
184
+
113
185
  ## Related Packages
114
186
 
115
- - [@vaiftech/client](https://www.npmjs.com/package/@vaiftech/client) - Core client SDK
116
- - [@vaiftech/react](https://www.npmjs.com/package/@vaiftech/react) - React hooks
117
- - [@vaiftech/sdk-expo](https://www.npmjs.com/package/@vaiftech/sdk-expo) - React Native/Expo SDK
187
+ | Package | Description |
188
+ |---------|-------------|
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 |
192
+ | [@vaiftech/sdk-expo](https://www.npmjs.com/package/@vaiftech/sdk-expo) | React Native / Expo SDK |
193
+ | [@vaiftechnologies/vaif-client](https://www.npmjs.com/package/@vaiftechnologies/vaif-client) | JavaScript SDK |
194
+
195
+ ## Documentation
196
+
197
+ Full documentation at [docs.vaif.studio](https://docs.vaif.studio).
118
198
 
119
199
  ## License
120
200