@veloxts/cli 0.6.26 → 0.6.29
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/CHANGELOG.md +759 -0
- package/GUIDE.md +239 -0
- package/dist/cli.js +2 -0
- package/dist/cli.js.map +1 -1
- package/dist/commands/tenant.d.ts +19 -0
- package/dist/commands/tenant.d.ts.map +1 -0
- package/dist/commands/tenant.js +635 -0
- package/dist/commands/tenant.js.map +1 -0
- package/dist/generators/templates/model.js +2 -2
- package/dist/generators/templates/model.js.map +1 -1
- package/dist/generators/templates/procedure.js +4 -4
- package/dist/generators/templates/procedure.js.map +1 -1
- package/dist/generators/templates/resource.js +4 -4
- package/dist/generators/templates/resource.js.map +1 -1
- package/package.json +12 -7
package/GUIDE.md
ADDED
|
@@ -0,0 +1,239 @@
|
|
|
1
|
+
# @veloxts/cli
|
|
2
|
+
|
|
3
|
+
Command-line interface for VeloxTS Framework.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
Automatically installed when creating a new VeloxTS project:
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
npx create-velox-app my-app
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
Or add to an existing project:
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
npm install -D @veloxts/cli
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
## Commands
|
|
20
|
+
|
|
21
|
+
### velox dev
|
|
22
|
+
|
|
23
|
+
Start development server with Hot Module Replacement (HMR):
|
|
24
|
+
|
|
25
|
+
```bash
|
|
26
|
+
velox dev # Start with HMR (default port: 3030)
|
|
27
|
+
velox dev --port 4000 # Custom port
|
|
28
|
+
velox dev --no-hmr # Disable HMR
|
|
29
|
+
velox dev --verbose # Enable debug output
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
HMR features:
|
|
33
|
+
- Fast, efficient reloads with sub-second restart times
|
|
34
|
+
- Precise timing metrics (startup, reload, total uptime)
|
|
35
|
+
- Smart error classification with actionable suggestions
|
|
36
|
+
- Automatic `velox:ready` IPC integration
|
|
37
|
+
|
|
38
|
+
Configure HMR boundaries in `package.json`:
|
|
39
|
+
|
|
40
|
+
```json
|
|
41
|
+
{
|
|
42
|
+
"hotHook": {
|
|
43
|
+
"boundaries": [
|
|
44
|
+
"src/procedures/**/*.ts",
|
|
45
|
+
"src/schemas/**/*.ts",
|
|
46
|
+
"src/handlers/**/*.ts"
|
|
47
|
+
]
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
Add server ready signal for accurate timing:
|
|
53
|
+
|
|
54
|
+
```typescript
|
|
55
|
+
await app.start();
|
|
56
|
+
|
|
57
|
+
// Send ready signal to CLI
|
|
58
|
+
if (process.send) {
|
|
59
|
+
process.send({ type: 'velox:ready' });
|
|
60
|
+
}
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
### velox migrate
|
|
64
|
+
|
|
65
|
+
Run database migrations using Prisma:
|
|
66
|
+
|
|
67
|
+
```bash
|
|
68
|
+
velox migrate # Apply pending migrations
|
|
69
|
+
velox migrate --force # Force push schema (dev only)
|
|
70
|
+
velox migrate --deploy # Deploy migrations (production)
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
### velox db:seed
|
|
74
|
+
|
|
75
|
+
Seed database with test or initial data:
|
|
76
|
+
|
|
77
|
+
```bash
|
|
78
|
+
velox db:seed # Run all seeders
|
|
79
|
+
velox db:seed UserSeeder # Run specific seeder
|
|
80
|
+
velox db:seed --fresh # Truncate tables first
|
|
81
|
+
velox db:seed --dry-run # Preview without executing
|
|
82
|
+
velox db:seed --verbose # Show debug output
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
### velox make
|
|
86
|
+
|
|
87
|
+
Generate code from templates:
|
|
88
|
+
|
|
89
|
+
```bash
|
|
90
|
+
velox make procedure users # Scaffold procedure
|
|
91
|
+
velox make schema user # Scaffold Zod schema
|
|
92
|
+
velox make seeder user # Scaffold database seeder
|
|
93
|
+
velox make factory user # Scaffold model factory
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
## Database Seeding
|
|
97
|
+
|
|
98
|
+
### Creating Seeders
|
|
99
|
+
|
|
100
|
+
```bash
|
|
101
|
+
velox make seeder user
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
Creates `src/database/seeders/UserSeeder.ts`:
|
|
105
|
+
|
|
106
|
+
```typescript
|
|
107
|
+
import type { Seeder, SeederContext } from '@veloxts/cli';
|
|
108
|
+
|
|
109
|
+
export const UserSeeder: Seeder = {
|
|
110
|
+
name: 'UserSeeder',
|
|
111
|
+
dependencies: [],
|
|
112
|
+
environments: ['development', 'test'],
|
|
113
|
+
|
|
114
|
+
async run({ db, factory, log }) {
|
|
115
|
+
log.info('Seeding users...');
|
|
116
|
+
|
|
117
|
+
await db.user.createMany({
|
|
118
|
+
data: [
|
|
119
|
+
{ email: 'admin@example.com', name: 'Admin', role: 'admin' },
|
|
120
|
+
{ email: 'user@example.com', name: 'User', role: 'user' },
|
|
121
|
+
],
|
|
122
|
+
});
|
|
123
|
+
|
|
124
|
+
log.success('Created 2 users');
|
|
125
|
+
},
|
|
126
|
+
|
|
127
|
+
async truncate({ db, log }) {
|
|
128
|
+
await db.user.deleteMany();
|
|
129
|
+
},
|
|
130
|
+
};
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
### Creating Factories
|
|
134
|
+
|
|
135
|
+
```bash
|
|
136
|
+
velox make factory user
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
Creates `src/database/factories/UserFactory.ts`:
|
|
140
|
+
|
|
141
|
+
```typescript
|
|
142
|
+
import { BaseFactory, type PrismaClientLike } from '@veloxts/cli';
|
|
143
|
+
import { faker } from '@faker-js/faker';
|
|
144
|
+
|
|
145
|
+
export class UserFactory extends BaseFactory<UserInput> {
|
|
146
|
+
readonly modelName = 'user';
|
|
147
|
+
|
|
148
|
+
constructor(prisma: PrismaClientLike) {
|
|
149
|
+
super(prisma);
|
|
150
|
+
|
|
151
|
+
this.registerState('admin', (attrs) => ({
|
|
152
|
+
...attrs,
|
|
153
|
+
role: 'admin',
|
|
154
|
+
}));
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
definition(): UserInput {
|
|
158
|
+
return {
|
|
159
|
+
email: faker.internet.email(),
|
|
160
|
+
name: faker.person.fullName(),
|
|
161
|
+
role: 'user',
|
|
162
|
+
};
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
```
|
|
166
|
+
|
|
167
|
+
Usage in seeders:
|
|
168
|
+
|
|
169
|
+
```typescript
|
|
170
|
+
async run({ factory, log }) {
|
|
171
|
+
// Create 50 users
|
|
172
|
+
await factory.get(UserFactory).createMany(50);
|
|
173
|
+
|
|
174
|
+
// Create 5 admins
|
|
175
|
+
await factory.get(UserFactory)
|
|
176
|
+
.state('admin')
|
|
177
|
+
.createMany(5);
|
|
178
|
+
}
|
|
179
|
+
```
|
|
180
|
+
|
|
181
|
+
### Seeder Dependencies
|
|
182
|
+
|
|
183
|
+
Ensure correct execution order:
|
|
184
|
+
|
|
185
|
+
```typescript
|
|
186
|
+
export const PostSeeder: Seeder = {
|
|
187
|
+
name: 'PostSeeder',
|
|
188
|
+
dependencies: ['UserSeeder'], // Runs after UserSeeder
|
|
189
|
+
|
|
190
|
+
async run({ db, factory, log }) {
|
|
191
|
+
const users = await db.user.findMany();
|
|
192
|
+
|
|
193
|
+
for (const user of users) {
|
|
194
|
+
await factory.get(PostFactory).createMany(5, {
|
|
195
|
+
authorId: user.id,
|
|
196
|
+
});
|
|
197
|
+
}
|
|
198
|
+
},
|
|
199
|
+
};
|
|
200
|
+
```
|
|
201
|
+
|
|
202
|
+
## HMR Configuration
|
|
203
|
+
|
|
204
|
+
Add to `package.json`:
|
|
205
|
+
|
|
206
|
+
```json
|
|
207
|
+
{
|
|
208
|
+
"hotHook": {
|
|
209
|
+
"boundaries": [
|
|
210
|
+
"src/procedures/**/*.ts",
|
|
211
|
+
"src/schemas/**/*.ts",
|
|
212
|
+
"src/config/**/*.ts"
|
|
213
|
+
]
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
```
|
|
217
|
+
|
|
218
|
+
Add graceful shutdown:
|
|
219
|
+
|
|
220
|
+
```typescript
|
|
221
|
+
const shutdown = async () => {
|
|
222
|
+
await prisma.$disconnect();
|
|
223
|
+
process.exit(0);
|
|
224
|
+
};
|
|
225
|
+
|
|
226
|
+
process.on('SIGTERM', shutdown);
|
|
227
|
+
process.on('SIGINT', shutdown);
|
|
228
|
+
```
|
|
229
|
+
|
|
230
|
+
## Learn More
|
|
231
|
+
|
|
232
|
+
- [@veloxts/core](https://www.npmjs.com/package/@veloxts/core) - Application framework
|
|
233
|
+
- [@veloxts/router](https://www.npmjs.com/package/@veloxts/router) - Procedures
|
|
234
|
+
- [@veloxts/orm](https://www.npmjs.com/package/@veloxts/orm) - Database
|
|
235
|
+
- [VeloxTS Framework](https://www.npmjs.com/package/@veloxts/velox) - Complete framework
|
|
236
|
+
|
|
237
|
+
## License
|
|
238
|
+
|
|
239
|
+
MIT
|
package/dist/cli.js
CHANGED
|
@@ -15,6 +15,7 @@ import { createIntrospectCommand } from './commands/introspect.js';
|
|
|
15
15
|
import { createMakeCommand } from './commands/make.js';
|
|
16
16
|
import { createMigrateCommand } from './commands/migrate.js';
|
|
17
17
|
import { createProceduresCommand } from './commands/procedures.js';
|
|
18
|
+
import { createTenantCommand } from './commands/tenant.js';
|
|
18
19
|
import { CLI_VERSION } from './index.js';
|
|
19
20
|
/**
|
|
20
21
|
* Create the main CLI program
|
|
@@ -33,6 +34,7 @@ function createCLI() {
|
|
|
33
34
|
program.addCommand(createMakeCommand());
|
|
34
35
|
program.addCommand(createMigrateCommand());
|
|
35
36
|
program.addCommand(createProceduresCommand());
|
|
37
|
+
program.addCommand(createTenantCommand());
|
|
36
38
|
return program;
|
|
37
39
|
}
|
|
38
40
|
/**
|
package/dist/cli.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";AAEA;;;;;;;;GAQG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEpC,OAAO,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AACnD,OAAO,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AACrD,OAAO,EAAE,uBAAuB,EAAE,MAAM,0BAA0B,CAAC;AACnE,OAAO,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AACvD,OAAO,EAAE,oBAAoB,EAAE,MAAM,uBAAuB,CAAC;AAC7D,OAAO,EAAE,uBAAuB,EAAE,MAAM,0BAA0B,CAAC;AACnE,OAAO,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAEzC;;GAEG;AACH,SAAS,SAAS;IAChB,MAAM,OAAO,GAAG,IAAI,OAAO,EAAE,CAAC;IAE9B,OAAO;SACJ,IAAI,CAAC,OAAO,CAAC;SACb,WAAW,CAAC,sEAAsE,CAAC;SACnF,OAAO,CAAC,WAAW,EAAE,eAAe,EAAE,4BAA4B,CAAC;SACnE,UAAU,CAAC,YAAY,EAAE,0BAA0B,CAAC,CAAC;IAExD,oBAAoB;IACpB,OAAO,CAAC,UAAU,CAAC,eAAe,EAAE,CAAC,CAAC;IACtC,OAAO,CAAC,UAAU,CAAC,gBAAgB,CAAC,WAAW,CAAC,CAAC,CAAC;IAClD,OAAO,CAAC,UAAU,CAAC,uBAAuB,EAAE,CAAC,CAAC;IAC9C,OAAO,CAAC,UAAU,CAAC,iBAAiB,EAAE,CAAC,CAAC;IACxC,OAAO,CAAC,UAAU,CAAC,oBAAoB,EAAE,CAAC,CAAC;IAC3C,OAAO,CAAC,UAAU,CAAC,uBAAuB,EAAE,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";AAE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AU,IAAI;IACjB,MAAM,OAAO,GAAG,SAAS,EAAE,CAAC;IAE5B,IAAI,CAAC;QACH,MAAM,OAAO,CAAC,UAAU,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;IACzC,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,IAAI,KAAK,YAAY,KAAK,EAAE,CAAC;YAC3B,OAAO,CAAC,KAAK,CAAC,UAAU,KAAK,CAAC,OAAO,EAAE,CAAC,CAAC;QAC3C,CAAC;aAAM,CAAC;YACN,OAAO,CAAC,KAAK,CAAC,2BAA2B,CAAC,CAAC;QAC7C,CAAC;QACD,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC;AACH,CAAC;AAED,cAAc;AACd,IAAI,EAAE,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Tenant command - Multi-tenancy management commands
|
|
3
|
+
*
|
|
4
|
+
* Provides subcommands for managing tenant schemas:
|
|
5
|
+
* - tenant:create - Create a new tenant with PostgreSQL schema
|
|
6
|
+
* - tenant:list - List all tenants
|
|
7
|
+
* - tenant:migrate - Run migrations on tenant schemas
|
|
8
|
+
* - tenant:status - Show tenant status
|
|
9
|
+
* - tenant:suspend - Suspend a tenant
|
|
10
|
+
* - tenant:activate - Activate a suspended tenant
|
|
11
|
+
*
|
|
12
|
+
* SECURITY: All SQL queries use parameterized queries to prevent SQL injection
|
|
13
|
+
*/
|
|
14
|
+
import { Command } from 'commander';
|
|
15
|
+
/**
|
|
16
|
+
* Create the tenant command with subcommands
|
|
17
|
+
*/
|
|
18
|
+
export declare function createTenantCommand(): Command;
|
|
19
|
+
//# sourceMappingURL=tenant.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tenant.d.ts","sourceRoot":"","sources":["../../src/commands/tenant.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AASH,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAszBpC;;GAEG;AACH,wBAAgB,mBAAmB,IAAI,OAAO,CAW7C"}
|