@veloxts/cli 0.4.1 → 0.4.3
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 +23 -144
- package/dist/cli.js +4 -0
- package/dist/cli.js.map +1 -1
- package/dist/commands/db.d.ts +12 -0
- package/dist/commands/db.d.ts.map +1 -0
- package/dist/commands/db.js +18 -0
- package/dist/commands/db.js.map +1 -0
- package/dist/commands/procedures.d.ts +12 -0
- package/dist/commands/procedures.d.ts.map +1 -0
- package/dist/commands/procedures.js +153 -0
- package/dist/commands/procedures.js.map +1 -0
- package/dist/generators/generators/factory.d.ts +36 -0
- package/dist/generators/generators/factory.d.ts.map +1 -0
- package/dist/generators/generators/factory.js +85 -0
- package/dist/generators/generators/factory.js.map +1 -0
- package/dist/generators/generators/index.d.ts +2 -0
- package/dist/generators/generators/index.d.ts.map +1 -1
- package/dist/generators/generators/index.js +8 -0
- package/dist/generators/generators/index.js.map +1 -1
- package/dist/generators/generators/seeder.d.ts +36 -0
- package/dist/generators/generators/seeder.d.ts.map +1 -0
- package/dist/generators/generators/seeder.js +99 -0
- package/dist/generators/generators/seeder.js.map +1 -0
- package/dist/generators/templates/factory.d.ts +26 -0
- package/dist/generators/templates/factory.d.ts.map +1 -0
- package/dist/generators/templates/factory.js +125 -0
- package/dist/generators/templates/factory.js.map +1 -0
- package/dist/generators/templates/seeder.d.ts +34 -0
- package/dist/generators/templates/seeder.d.ts.map +1 -0
- package/dist/generators/templates/seeder.js +129 -0
- package/dist/generators/templates/seeder.js.map +1 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +5 -0
- package/dist/index.js.map +1 -1
- package/dist/migrations/rollback-runner.d.ts.map +1 -1
- package/dist/migrations/rollback-runner.js +13 -1
- package/dist/migrations/rollback-runner.js.map +1 -1
- package/dist/seeding/commands/seed.d.ts +11 -0
- package/dist/seeding/commands/seed.d.ts.map +1 -0
- package/dist/seeding/commands/seed.js +268 -0
- package/dist/seeding/commands/seed.js.map +1 -0
- package/dist/seeding/errors.d.ts +119 -0
- package/dist/seeding/errors.d.ts.map +1 -0
- package/dist/seeding/errors.js +191 -0
- package/dist/seeding/errors.js.map +1 -0
- package/dist/seeding/factory.d.ts +162 -0
- package/dist/seeding/factory.d.ts.map +1 -0
- package/dist/seeding/factory.js +250 -0
- package/dist/seeding/factory.js.map +1 -0
- package/dist/seeding/index.d.ts +31 -0
- package/dist/seeding/index.d.ts.map +1 -0
- package/dist/seeding/index.js +41 -0
- package/dist/seeding/index.js.map +1 -0
- package/dist/seeding/loader.d.ts +41 -0
- package/dist/seeding/loader.d.ts.map +1 -0
- package/dist/seeding/loader.js +210 -0
- package/dist/seeding/loader.js.map +1 -0
- package/dist/seeding/registry.d.ts +116 -0
- package/dist/seeding/registry.d.ts.map +1 -0
- package/dist/seeding/registry.js +298 -0
- package/dist/seeding/registry.js.map +1 -0
- package/dist/seeding/runner.d.ts +88 -0
- package/dist/seeding/runner.d.ts.map +1 -0
- package/dist/seeding/runner.js +254 -0
- package/dist/seeding/runner.js.map +1 -0
- package/dist/seeding/types.d.ts +247 -0
- package/dist/seeding/types.d.ts.map +1 -0
- package/dist/seeding/types.js +7 -0
- package/dist/seeding/types.js.map +1 -0
- package/package.json +6 -6
package/README.md
CHANGED
|
@@ -1,175 +1,54 @@
|
|
|
1
1
|
# @veloxts/cli
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
**Pre-Alpha Notice:** This framework is in early development (v0.4.x). APIs are subject to change. Not recommended for production use.
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
## What is this?
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
The CLI is installed automatically when you create a new VeloxTS project:
|
|
10
|
-
|
|
11
|
-
```bash
|
|
12
|
-
npx create-velox-app my-app
|
|
13
|
-
cd my-app
|
|
14
|
-
```
|
|
15
|
-
|
|
16
|
-
Or add it to an existing project:
|
|
17
|
-
|
|
18
|
-
```bash
|
|
19
|
-
npm install -D @veloxts/cli
|
|
20
|
-
# or
|
|
21
|
-
pnpm add -D @veloxts/cli
|
|
22
|
-
```
|
|
23
|
-
|
|
24
|
-
## Commands
|
|
25
|
-
|
|
26
|
-
### `velox dev`
|
|
27
|
-
|
|
28
|
-
Start the development server with hot reload.
|
|
29
|
-
|
|
30
|
-
```bash
|
|
31
|
-
velox dev
|
|
32
|
-
```
|
|
33
|
-
|
|
34
|
-
**Options:**
|
|
35
|
-
|
|
36
|
-
- `-p, --port <port>` - Port to listen on (default: 3210)
|
|
37
|
-
- `-H, --host <host>` - Host to bind to (default: localhost)
|
|
38
|
-
- `-e, --entry <file>` - Entry point file (auto-detected if not specified)
|
|
39
|
-
|
|
40
|
-
**Examples:**
|
|
41
|
-
|
|
42
|
-
```bash
|
|
43
|
-
# Start on default port 3210
|
|
44
|
-
velox dev
|
|
45
|
-
|
|
46
|
-
# Start on custom port
|
|
47
|
-
velox dev --port 8080
|
|
48
|
-
|
|
49
|
-
# Specify custom entry point
|
|
50
|
-
velox dev --entry src/main.ts
|
|
51
|
-
```
|
|
52
|
-
|
|
53
|
-
### `velox migrate`
|
|
54
|
-
|
|
55
|
-
Run database migrations using Prisma.
|
|
56
|
-
|
|
57
|
-
```bash
|
|
58
|
-
velox migrate
|
|
59
|
-
```
|
|
7
|
+
Command-line interface for the VeloxTS Framework, providing development server, migration commands, and code generators.
|
|
60
8
|
|
|
61
|
-
|
|
9
|
+
## Part of @veloxts/velox
|
|
62
10
|
|
|
63
|
-
|
|
64
|
-
- `--force` - Force push schema without migration (development only)
|
|
65
|
-
|
|
66
|
-
**Examples:**
|
|
11
|
+
This package is part of the VeloxTS Framework. For the complete framework experience, install:
|
|
67
12
|
|
|
68
13
|
```bash
|
|
69
|
-
|
|
70
|
-
velox migrate
|
|
71
|
-
|
|
72
|
-
# Production: Apply pending migrations
|
|
73
|
-
velox migrate --deploy
|
|
74
|
-
|
|
75
|
-
# Force push schema changes (dev only)
|
|
76
|
-
velox migrate --force
|
|
14
|
+
npm install @veloxts/velox
|
|
77
15
|
```
|
|
78
16
|
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
### Building
|
|
17
|
+
Visit [@veloxts/velox](https://www.npmjs.com/package/@veloxts/velox) for the complete framework documentation.
|
|
82
18
|
|
|
83
|
-
|
|
84
|
-
pnpm build
|
|
85
|
-
```
|
|
19
|
+
## Installation
|
|
86
20
|
|
|
87
|
-
|
|
21
|
+
The CLI is installed automatically when you create a new VeloxTS project:
|
|
88
22
|
|
|
89
23
|
```bash
|
|
90
|
-
|
|
24
|
+
npx create-velox-app my-app
|
|
91
25
|
```
|
|
92
26
|
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
- Beautiful terminal output with colors and spinners
|
|
96
|
-
- Automatic entry point detection
|
|
97
|
-
- Graceful shutdown handling (Ctrl+C)
|
|
98
|
-
- Helpful error messages with suggestions
|
|
99
|
-
- Intuitive command design
|
|
100
|
-
- Built with Commander.js and Clack
|
|
101
|
-
|
|
102
|
-
## Architecture
|
|
103
|
-
|
|
104
|
-
The CLI is built with:
|
|
105
|
-
|
|
106
|
-
- **Commander.js** - Command-line parsing and routing
|
|
107
|
-
- **Clack** - Beautiful interactive prompts
|
|
108
|
-
- **picocolors** - Terminal colors without dependencies
|
|
109
|
-
- **tsx** - TypeScript execution with hot reload
|
|
110
|
-
|
|
111
|
-
## Troubleshooting
|
|
112
|
-
|
|
113
|
-
### Entry Point Not Found
|
|
114
|
-
|
|
115
|
-
If the CLI can't find your entry point:
|
|
27
|
+
Or add it to an existing project:
|
|
116
28
|
|
|
117
29
|
```bash
|
|
118
|
-
|
|
30
|
+
npm install -D @veloxts/cli
|
|
119
31
|
```
|
|
120
32
|
|
|
121
|
-
|
|
122
|
-
- `src/index.ts`
|
|
123
|
-
- `src/main.ts`
|
|
124
|
-
- `index.ts`
|
|
33
|
+
## Documentation
|
|
125
34
|
|
|
126
|
-
|
|
35
|
+
For detailed documentation, usage examples, and API reference, see [GUIDE.md](./GUIDE.md).
|
|
127
36
|
|
|
128
|
-
|
|
129
|
-
Error: Port 3210 is already in use
|
|
130
|
-
```
|
|
131
|
-
|
|
132
|
-
**Solution:** Use a different port:
|
|
37
|
+
## Quick Example
|
|
133
38
|
|
|
134
39
|
```bash
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
### Module Resolution Errors
|
|
139
|
-
|
|
140
|
-
Ensure all dependencies are installed:
|
|
40
|
+
# Start development server
|
|
41
|
+
velox dev
|
|
141
42
|
|
|
142
|
-
|
|
143
|
-
|
|
43
|
+
# Run database migrations
|
|
44
|
+
velox migrate
|
|
144
45
|
```
|
|
145
46
|
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
## MVP Limitations
|
|
149
|
-
|
|
150
|
-
The current v0.1.0 release includes:
|
|
151
|
-
|
|
152
|
-
**Included:**
|
|
153
|
-
- `velox dev` - Development server with hot reload
|
|
154
|
-
- `velox migrate` - Database migrations (wraps Prisma)
|
|
155
|
-
|
|
156
|
-
**Deferred to v1.1+:**
|
|
157
|
-
- Code generators (`velox generate controller`, etc.)
|
|
158
|
-
- Database seeding command (`velox db:seed`)
|
|
159
|
-
- Migration rollback command
|
|
160
|
-
- Interactive project scaffolding
|
|
161
|
-
- Custom command plugins
|
|
162
|
-
|
|
163
|
-
## Related Packages
|
|
164
|
-
|
|
165
|
-
- [@veloxts/core](/packages/core) - Core framework
|
|
166
|
-
- [@veloxts/router](/packages/router) - Procedure-based routing
|
|
167
|
-
- [@veloxts/orm](/packages/orm) - Prisma integration
|
|
168
|
-
- [create-velox-app](/packages/create) - Project scaffolder
|
|
169
|
-
|
|
170
|
-
## TypeScript Support
|
|
47
|
+
## Learn More
|
|
171
48
|
|
|
172
|
-
|
|
49
|
+
- [Full Documentation](./GUIDE.md)
|
|
50
|
+
- [VeloxTS Framework](https://www.npmjs.com/package/@veloxts/velox)
|
|
51
|
+
- [GitHub Repository](https://github.com/veloxts/velox-ts-framework)
|
|
173
52
|
|
|
174
53
|
## License
|
|
175
54
|
|
package/dist/cli.js
CHANGED
|
@@ -5,9 +5,11 @@
|
|
|
5
5
|
* A beautiful, Laravel-inspired command-line interface for the VeloxTS Framework
|
|
6
6
|
*/
|
|
7
7
|
import { Command } from 'commander';
|
|
8
|
+
import { createDbCommand } from './commands/db.js';
|
|
8
9
|
import { createDevCommand } from './commands/dev.js';
|
|
9
10
|
import { createGenerateCommand } from './commands/generate.js';
|
|
10
11
|
import { createMigrateCommand } from './commands/migrate.js';
|
|
12
|
+
import { createProceduresCommand } from './commands/procedures.js';
|
|
11
13
|
import { CLI_VERSION } from './index.js';
|
|
12
14
|
/**
|
|
13
15
|
* Create the main CLI program
|
|
@@ -20,9 +22,11 @@ function createCLI() {
|
|
|
20
22
|
.version(CLI_VERSION, '-v, --version', 'Output the current version')
|
|
21
23
|
.helpOption('-h, --help', 'Display help for command');
|
|
22
24
|
// Register commands
|
|
25
|
+
program.addCommand(createDbCommand());
|
|
23
26
|
program.addCommand(createDevCommand(CLI_VERSION));
|
|
24
27
|
program.addCommand(createGenerateCommand());
|
|
25
28
|
program.addCommand(createMigrateCommand());
|
|
29
|
+
program.addCommand(createProceduresCommand());
|
|
26
30
|
return program;
|
|
27
31
|
}
|
|
28
32
|
/**
|
package/dist/cli.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";AAEA;;;;GAIG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEpC,OAAO,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AACrD,OAAO,EAAE,qBAAqB,EAAE,MAAM,wBAAwB,CAAC;AAC/D,OAAO,EAAE,oBAAoB,EAAE,MAAM,uBAAuB,CAAC;AAC7D,OAAO,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAEzC;;GAEG;AACH,SAAS,SAAS;IAChB,MAAM,OAAO,GAAG,IAAI,OAAO,EA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AAC;IAClD,OAAO,CAAC,UAAU,CAAC,qBAAqB,EAAE,CAAC,CAAC;IAC5C,OAAO,CAAC,UAAU,CAAC,oBAAoB,EAAE,CAAC,CAAC;IAC3C,OAAO,CAAC,UAAU,CAAC,uBAAuB,EAAE,CAAC,CAAC;IAE9C,OAAO,OAAO,CAAC;AACjB,CAAC;AAED;;GAEG;AACH,KAAK,UAAU,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,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* DB command - Database seeding commands
|
|
3
|
+
*
|
|
4
|
+
* Provides subcommands for managing database seeding:
|
|
5
|
+
* - db:seed - Run database seeders
|
|
6
|
+
*/
|
|
7
|
+
import { Command } from 'commander';
|
|
8
|
+
/**
|
|
9
|
+
* Create the db command with subcommands
|
|
10
|
+
*/
|
|
11
|
+
export declare function createDbCommand(): Command;
|
|
12
|
+
//# sourceMappingURL=db.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"db.d.ts","sourceRoot":"","sources":["../../src/commands/db.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAIpC;;GAEG;AACH,wBAAgB,eAAe,IAAI,OAAO,CAMzC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* DB command - Database seeding commands
|
|
3
|
+
*
|
|
4
|
+
* Provides subcommands for managing database seeding:
|
|
5
|
+
* - db:seed - Run database seeders
|
|
6
|
+
*/
|
|
7
|
+
import { Command } from 'commander';
|
|
8
|
+
import { createSeedCommand } from '../seeding/commands/seed.js';
|
|
9
|
+
/**
|
|
10
|
+
* Create the db command with subcommands
|
|
11
|
+
*/
|
|
12
|
+
export function createDbCommand() {
|
|
13
|
+
const db = new Command('db')
|
|
14
|
+
.description('Database seeding commands')
|
|
15
|
+
.addCommand(createSeedCommand());
|
|
16
|
+
return db;
|
|
17
|
+
}
|
|
18
|
+
//# sourceMappingURL=db.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"db.js","sourceRoot":"","sources":["../../src/commands/db.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEpC,OAAO,EAAE,iBAAiB,EAAE,MAAM,6BAA6B,CAAC;AAEhE;;GAEG;AACH,MAAM,UAAU,eAAe;IAC7B,MAAM,EAAE,GAAG,IAAI,OAAO,CAAC,IAAI,CAAC;SACzB,WAAW,CAAC,2BAA2B,CAAC;SACxC,UAAU,CAAC,iBAAiB,EAAE,CAAC,CAAC;IAEnC,OAAO,EAAE,CAAC;AACZ,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Procedures command - Discover and list procedures
|
|
3
|
+
*
|
|
4
|
+
* Provides subcommands for managing procedures:
|
|
5
|
+
* - procedures:list - List all discovered procedures
|
|
6
|
+
*/
|
|
7
|
+
import { Command } from 'commander';
|
|
8
|
+
/**
|
|
9
|
+
* Create the procedures command with subcommands
|
|
10
|
+
*/
|
|
11
|
+
export declare function createProceduresCommand(): Command;
|
|
12
|
+
//# sourceMappingURL=procedures.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"procedures.d.ts","sourceRoot":"","sources":["../../src/commands/procedures.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAQH,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AA0LpC;;GAEG;AACH,wBAAgB,uBAAuB,IAAI,OAAO,CAMjD"}
|
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Procedures command - Discover and list procedures
|
|
3
|
+
*
|
|
4
|
+
* Provides subcommands for managing procedures:
|
|
5
|
+
* - procedures:list - List all discovered procedures
|
|
6
|
+
*/
|
|
7
|
+
import { discoverProceduresVerbose, isDiscoveryError, } from '@veloxts/router';
|
|
8
|
+
import { Command } from 'commander';
|
|
9
|
+
import pc from 'picocolors';
|
|
10
|
+
// ============================================================================
|
|
11
|
+
// Helper Functions
|
|
12
|
+
// ============================================================================
|
|
13
|
+
/**
|
|
14
|
+
* Extract procedure info from a collection
|
|
15
|
+
*/
|
|
16
|
+
function extractProcedureInfo(collection) {
|
|
17
|
+
const procedures = [];
|
|
18
|
+
for (const [name, proc] of Object.entries(collection.procedures)) {
|
|
19
|
+
const procedure = proc;
|
|
20
|
+
procedures.push({
|
|
21
|
+
name,
|
|
22
|
+
type: procedure.type,
|
|
23
|
+
hasInput: procedure.inputSchema !== undefined,
|
|
24
|
+
hasOutput: procedure.outputSchema !== undefined,
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
// Sort by name for consistent output
|
|
28
|
+
procedures.sort((a, b) => a.name.localeCompare(b.name));
|
|
29
|
+
return {
|
|
30
|
+
namespace: collection.namespace,
|
|
31
|
+
procedures,
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Format HTTP method label based on procedure type and name
|
|
36
|
+
*/
|
|
37
|
+
function formatMethodLabel(name, type) {
|
|
38
|
+
// Infer HTTP method from procedure name
|
|
39
|
+
if (name.startsWith('get') || name.startsWith('find'))
|
|
40
|
+
return pc.green('GET ');
|
|
41
|
+
if (name.startsWith('list'))
|
|
42
|
+
return pc.green('GET ');
|
|
43
|
+
if (name.startsWith('create') || name.startsWith('add'))
|
|
44
|
+
return pc.yellow('POST ');
|
|
45
|
+
if (name.startsWith('update') || name.startsWith('edit'))
|
|
46
|
+
return pc.blue('PUT ');
|
|
47
|
+
if (name.startsWith('patch'))
|
|
48
|
+
return pc.cyan('PATCH ');
|
|
49
|
+
if (name.startsWith('delete') || name.startsWith('remove'))
|
|
50
|
+
return pc.red('DELETE ');
|
|
51
|
+
// Fallback to procedure type
|
|
52
|
+
return type === 'query' ? pc.green('GET ') : pc.yellow('POST ');
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Print human-readable output
|
|
56
|
+
*/
|
|
57
|
+
function printPrettyOutput(result) {
|
|
58
|
+
const totalProcedures = result.collections.reduce((sum, c) => sum + c.procedures.length, 0);
|
|
59
|
+
console.log();
|
|
60
|
+
console.log(pc.bold('Discovered Procedures'));
|
|
61
|
+
console.log(pc.dim(`─`.repeat(50)));
|
|
62
|
+
console.log();
|
|
63
|
+
for (const collection of result.collections) {
|
|
64
|
+
console.log(pc.bold(pc.cyan(`/${collection.namespace}`)));
|
|
65
|
+
for (const proc of collection.procedures) {
|
|
66
|
+
const method = formatMethodLabel(proc.name, proc.type);
|
|
67
|
+
const schemas = [];
|
|
68
|
+
if (proc.hasInput)
|
|
69
|
+
schemas.push('input');
|
|
70
|
+
if (proc.hasOutput)
|
|
71
|
+
schemas.push('output');
|
|
72
|
+
const schemaInfo = schemas.length > 0 ? pc.dim(` (${schemas.join(', ')})`) : '';
|
|
73
|
+
console.log(` ${method} ${proc.name}${schemaInfo}`);
|
|
74
|
+
}
|
|
75
|
+
console.log();
|
|
76
|
+
}
|
|
77
|
+
// Summary
|
|
78
|
+
console.log(pc.dim(`─`.repeat(50)));
|
|
79
|
+
console.log(`${pc.bold(totalProcedures.toString())} procedures in ${pc.bold(result.collections.length.toString())} collections`);
|
|
80
|
+
console.log(pc.dim(`Scanned ${result.scannedFiles} files, loaded ${result.loadedFiles} files`));
|
|
81
|
+
// Warnings
|
|
82
|
+
if (result.warnings.length > 0) {
|
|
83
|
+
console.log();
|
|
84
|
+
console.log(pc.yellow(`${result.warnings.length} warning(s):`));
|
|
85
|
+
for (const warning of result.warnings) {
|
|
86
|
+
console.log(pc.yellow(` • ${warning}`));
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
console.log();
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* Print JSON output
|
|
93
|
+
*/
|
|
94
|
+
function printJsonOutput(result) {
|
|
95
|
+
console.log(JSON.stringify(result, null, 2));
|
|
96
|
+
}
|
|
97
|
+
// ============================================================================
|
|
98
|
+
// Command Implementation
|
|
99
|
+
// ============================================================================
|
|
100
|
+
/**
|
|
101
|
+
* Create the procedures:list command
|
|
102
|
+
*/
|
|
103
|
+
function createListCommand() {
|
|
104
|
+
return new Command('list')
|
|
105
|
+
.description('List all discovered procedures')
|
|
106
|
+
.option('-p, --path <path>', 'Path to procedures directory', './src/procedures')
|
|
107
|
+
.option('-r, --recursive', 'Scan subdirectories', false)
|
|
108
|
+
.option('--json', 'Output as JSON', false)
|
|
109
|
+
.action(async (options) => {
|
|
110
|
+
const proceduresPath = options.path ?? './src/procedures';
|
|
111
|
+
const discoveryOptions = {
|
|
112
|
+
recursive: options.recursive ?? false,
|
|
113
|
+
onInvalidExport: 'warn',
|
|
114
|
+
};
|
|
115
|
+
try {
|
|
116
|
+
const discovery = await discoverProceduresVerbose(proceduresPath, discoveryOptions);
|
|
117
|
+
const result = {
|
|
118
|
+
collections: discovery.collections.map(extractProcedureInfo),
|
|
119
|
+
scannedFiles: discovery.scannedFiles.length,
|
|
120
|
+
loadedFiles: discovery.loadedFiles.length,
|
|
121
|
+
warnings: discovery.warnings.map((w) => `${w.filePath}: ${w.message}`),
|
|
122
|
+
};
|
|
123
|
+
if (options.json) {
|
|
124
|
+
printJsonOutput(result);
|
|
125
|
+
}
|
|
126
|
+
else {
|
|
127
|
+
printPrettyOutput(result);
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
catch (error) {
|
|
131
|
+
if (isDiscoveryError(error)) {
|
|
132
|
+
if (options.json) {
|
|
133
|
+
console.log(JSON.stringify({ error: error.toJSON() }, null, 2));
|
|
134
|
+
}
|
|
135
|
+
else {
|
|
136
|
+
console.error(pc.red(error.format()));
|
|
137
|
+
}
|
|
138
|
+
process.exit(1);
|
|
139
|
+
}
|
|
140
|
+
throw error;
|
|
141
|
+
}
|
|
142
|
+
});
|
|
143
|
+
}
|
|
144
|
+
/**
|
|
145
|
+
* Create the procedures command with subcommands
|
|
146
|
+
*/
|
|
147
|
+
export function createProceduresCommand() {
|
|
148
|
+
const procedures = new Command('procedures')
|
|
149
|
+
.description('Procedure discovery and management commands')
|
|
150
|
+
.addCommand(createListCommand());
|
|
151
|
+
return procedures;
|
|
152
|
+
}
|
|
153
|
+
//# sourceMappingURL=procedures.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"procedures.js","sourceRoot":"","sources":["../../src/commands/procedures.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAEL,yBAAyB,EACzB,gBAAgB,GAEjB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,MAAM,YAAY,CAAC;AA+B5B,+EAA+E;AAC/E,mBAAmB;AACnB,+EAA+E;AAE/E;;GAEG;AACH,SAAS,oBAAoB,CAAC,UAA+B;IAC3D,MAAM,UAAU,GAAoB,EAAE,CAAC;IAEvC,KAAK,MAAM,CAAC,IAAI,EAAE,IAAI,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,UAAU,CAAC,UAAU,CAAC,EAAE,CAAC;QACjE,MAAM,SAAS,GAAG,IAIjB,CAAC;QAEF,UAAU,CAAC,IAAI,CAAC;Y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AAM,CAAC,CAAC;YAC1B,CAAC;iBAAM,CAAC;gBACN,iBAAiB,CAAC,MAAM,CAAC,CAAC;YAC5B,CAAC;QACH,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,IAAI,gBAAgB,CAAC,KAAK,CAAC,EAAE,CAAC;gBAC5B,IAAI,OAAO,CAAC,IAAI,EAAE,CAAC;oBACjB,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,SAAS,CAAC,EAAE,KAAK,EAAE,KAAK,CAAC,MAAM,EAAE,EAAE,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC;gBAClE,CAAC;qBAAM,CAAC;oBACN,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC,GAAG,CAAC,KAAK,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC;gBACxC,CAAC;gBACD,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;YAClB,CAAC;YAED,MAAM,KAAK,CAAC;QACd,CAAC;IACH,CAAC,CAAC,CAAC;AACP,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,uBAAuB;IACrC,MAAM,UAAU,GAAG,IAAI,OAAO,CAAC,YAAY,CAAC;SACzC,WAAW,CAAC,6CAA6C,CAAC;SAC1D,UAAU,CAAC,iBAAiB,EAAE,CAAC,CAAC;IAEnC,OAAO,UAAU,CAAC;AACpB,CAAC"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Factory Generator
|
|
3
|
+
*
|
|
4
|
+
* Generates factory files for VeloxTS applications.
|
|
5
|
+
*
|
|
6
|
+
* Usage:
|
|
7
|
+
* velox generate factory <name> [options]
|
|
8
|
+
* velox g f <name> [options]
|
|
9
|
+
*
|
|
10
|
+
* Examples:
|
|
11
|
+
* velox generate factory user # Creates UserFactory
|
|
12
|
+
* velox g f post # Creates PostFactory
|
|
13
|
+
*/
|
|
14
|
+
import { BaseGenerator } from '../base.js';
|
|
15
|
+
import { type FactoryOptions } from '../templates/factory.js';
|
|
16
|
+
import type { GeneratorConfig, GeneratorMetadata, GeneratorOption, GeneratorOutput } from '../types.js';
|
|
17
|
+
/**
|
|
18
|
+
* Factory generator - creates factory files for generating fake data
|
|
19
|
+
*/
|
|
20
|
+
export declare class FactoryGenerator extends BaseGenerator<FactoryOptions> {
|
|
21
|
+
readonly metadata: GeneratorMetadata;
|
|
22
|
+
readonly options: ReadonlyArray<GeneratorOption>;
|
|
23
|
+
/**
|
|
24
|
+
* Validate and transform raw options
|
|
25
|
+
*/
|
|
26
|
+
validateOptions(raw: Record<string, unknown>): FactoryOptions;
|
|
27
|
+
/**
|
|
28
|
+
* Generate factory files
|
|
29
|
+
*/
|
|
30
|
+
generate(config: GeneratorConfig<FactoryOptions>): Promise<GeneratorOutput>;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Create a new factory generator instance
|
|
34
|
+
*/
|
|
35
|
+
export declare function createFactoryGenerator(): FactoryGenerator;
|
|
36
|
+
//# sourceMappingURL=factory.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"factory.d.ts","sourceRoot":"","sources":["../../../src/generators/generators/factory.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAC3C,OAAO,EACL,KAAK,cAAc,EAIpB,MAAM,yBAAyB,CAAC;AACjC,OAAO,KAAK,EAEV,eAAe,EACf,iBAAiB,EACjB,eAAe,EACf,eAAe,EAChB,MAAM,aAAa,CAAC;AAMrB;;GAEG;AACH,qBAAa,gBAAiB,SAAQ,aAAa,CAAC,cAAc,CAAC;IACjE,QAAQ,CAAC,QAAQ,EAAE,iBAAiB,CAgBlC;IAEF,QAAQ,CAAC,OAAO,EAAE,aAAa,CAAC,eAAe,CAAC,CAO9C;IAEF;;OAEG;IACH,eAAe,CAAC,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,cAAc;IAM7D;;OAEG;IACG,QAAQ,CAAC,MAAM,EAAE,eAAe,CAAC,cAAc,CAAC,GAAG,OAAO,CAAC,eAAe,CAAC;CAoBlF;AAMD;;GAEG;AACH,wBAAgB,sBAAsB,IAAI,gBAAgB,CAEzD"}
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Factory Generator
|
|
3
|
+
*
|
|
4
|
+
* Generates factory files for VeloxTS applications.
|
|
5
|
+
*
|
|
6
|
+
* Usage:
|
|
7
|
+
* velox generate factory <name> [options]
|
|
8
|
+
* velox g f <name> [options]
|
|
9
|
+
*
|
|
10
|
+
* Examples:
|
|
11
|
+
* velox generate factory user # Creates UserFactory
|
|
12
|
+
* velox g f post # Creates PostFactory
|
|
13
|
+
*/
|
|
14
|
+
import { BaseGenerator } from '../base.js';
|
|
15
|
+
import { factoryTemplate, getFactoryInstructions, getFactoryPath, } from '../templates/factory.js';
|
|
16
|
+
// ============================================================================
|
|
17
|
+
// Generator Implementation
|
|
18
|
+
// ============================================================================
|
|
19
|
+
/**
|
|
20
|
+
* Factory generator - creates factory files for generating fake data
|
|
21
|
+
*/
|
|
22
|
+
export class FactoryGenerator extends BaseGenerator {
|
|
23
|
+
metadata = {
|
|
24
|
+
name: 'factory',
|
|
25
|
+
description: 'Generate a model factory for fake data generation',
|
|
26
|
+
longDescription: `
|
|
27
|
+
Generate a VeloxTS factory file for creating model instances with fake data.
|
|
28
|
+
|
|
29
|
+
Factories are stored in src/database/factories/ and extend BaseFactory.
|
|
30
|
+
They use @faker-js/faker to generate realistic test data and support
|
|
31
|
+
named states for common variations (e.g., admin, verified).
|
|
32
|
+
|
|
33
|
+
Examples:
|
|
34
|
+
velox generate factory user # Creates UserFactory.ts
|
|
35
|
+
velox g f post # Creates PostFactory.ts
|
|
36
|
+
`,
|
|
37
|
+
aliases: ['f', 'fac'],
|
|
38
|
+
category: 'database',
|
|
39
|
+
};
|
|
40
|
+
options = [
|
|
41
|
+
{
|
|
42
|
+
name: 'model',
|
|
43
|
+
short: 'm',
|
|
44
|
+
description: 'Path to model file for type inference (optional)',
|
|
45
|
+
type: 'string',
|
|
46
|
+
},
|
|
47
|
+
];
|
|
48
|
+
/**
|
|
49
|
+
* Validate and transform raw options
|
|
50
|
+
*/
|
|
51
|
+
validateOptions(raw) {
|
|
52
|
+
return {
|
|
53
|
+
model: raw.model,
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Generate factory files
|
|
58
|
+
*/
|
|
59
|
+
async generate(config) {
|
|
60
|
+
const context = this.createContext(config);
|
|
61
|
+
const { entity } = context;
|
|
62
|
+
// Generate factory file
|
|
63
|
+
const content = factoryTemplate(context);
|
|
64
|
+
const file = {
|
|
65
|
+
path: getFactoryPath(entity.pascal),
|
|
66
|
+
content,
|
|
67
|
+
};
|
|
68
|
+
// Generate post-creation instructions
|
|
69
|
+
const postInstructions = getFactoryInstructions(entity.pascal);
|
|
70
|
+
return {
|
|
71
|
+
files: [file],
|
|
72
|
+
postInstructions,
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
// ============================================================================
|
|
77
|
+
// Export
|
|
78
|
+
// ============================================================================
|
|
79
|
+
/**
|
|
80
|
+
* Create a new factory generator instance
|
|
81
|
+
*/
|
|
82
|
+
export function createFactoryGenerator() {
|
|
83
|
+
return new FactoryGenerator();
|
|
84
|
+
}
|
|
85
|
+
//# sourceMappingURL=factory.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"factory.js","sourceRoot":"","sources":["../../../src/generators/generators/factory.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAC3C,OAAO,EAEL,eAAe,EACf,sBAAsB,EACtB,cAAc,GACf,MAAM,yBAAyB,CAAC;AASjC,+EAA+E;AAC/E,2BAA2B;AAC3B,+EAA+E;AAE/E;;GAEG;AACH,MAAM,OAA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, FactoryGenerator } from './factory.js';
|
|
6
7
|
export { createMigrationGenerator, MigrationGenerator } from './migration.js';
|
|
7
8
|
export { createModelGenerator, ModelGenerator } from './model.js';
|
|
8
9
|
export { createProcedureGenerator, ProcedureGenerator } from './procedure.js';
|
|
9
10
|
export { createResourceGenerator, ResourceGenerator } from './resource.js';
|
|
10
11
|
export { createSchemaGenerator, SchemaGenerator } from './schema.js';
|
|
12
|
+
export { createSeederGenerator, SeederGenerator } from './seeder.js';
|
|
11
13
|
export { createTestGenerator, TestGenerator } from './test.js';
|
|
12
14
|
/**
|
|
13
15
|
* Register all built-in generators with the global registry.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/generators/generators/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/generators/generators/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAgBH,OAAO,EAAE,sBAAsB,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AACxE,OAAO,EAAE,wBAAwB,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AAC9E,OAAO,EAAE,oBAAoB,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAClE,OAAO,EAAE,wBAAwB,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AAC9E,OAAO,EAAE,uBAAuB,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAC3E,OAAO,EAAE,qBAAqB,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AACrE,OAAO,EAAE,qBAAqB,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AACrE,OAAO,EAAE,mBAAmB,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAM/D;;;GAGG;AACH,wBAAgB,yBAAyB,IAAI,IAAI,CAwBhD"}
|
|
@@ -4,20 +4,24 @@
|
|
|
4
4
|
* Re-exports all built-in generators and provides auto-registration.
|
|
5
5
|
*/
|
|
6
6
|
import { registerGenerator } from '../registry.js';
|
|
7
|
+
import { createFactoryGenerator } from './factory.js';
|
|
7
8
|
import { createMigrationGenerator } from './migration.js';
|
|
8
9
|
import { createModelGenerator } from './model.js';
|
|
9
10
|
import { createProcedureGenerator } from './procedure.js';
|
|
10
11
|
import { createResourceGenerator } from './resource.js';
|
|
11
12
|
import { createSchemaGenerator } from './schema.js';
|
|
13
|
+
import { createSeederGenerator } from './seeder.js';
|
|
12
14
|
import { createTestGenerator } from './test.js';
|
|
13
15
|
// ============================================================================
|
|
14
16
|
// Generator Exports
|
|
15
17
|
// ============================================================================
|
|
18
|
+
export { createFactoryGenerator, FactoryGenerator } from './factory.js';
|
|
16
19
|
export { createMigrationGenerator, MigrationGenerator } from './migration.js';
|
|
17
20
|
export { createModelGenerator, ModelGenerator } from './model.js';
|
|
18
21
|
export { createProcedureGenerator, ProcedureGenerator } from './procedure.js';
|
|
19
22
|
export { createResourceGenerator, ResourceGenerator } from './resource.js';
|
|
20
23
|
export { createSchemaGenerator, SchemaGenerator } from './schema.js';
|
|
24
|
+
export { createSeederGenerator, SeederGenerator } from './seeder.js';
|
|
21
25
|
export { createTestGenerator, TestGenerator } from './test.js';
|
|
22
26
|
// ============================================================================
|
|
23
27
|
// Auto-Registration
|
|
@@ -39,5 +43,9 @@ export function registerBuiltinGenerators() {
|
|
|
39
43
|
registerGenerator(createTestGenerator());
|
|
40
44
|
// Register resource generator (full stack)
|
|
41
45
|
registerGenerator(createResourceGenerator());
|
|
46
|
+
// Register seeder generator
|
|
47
|
+
registerGenerator(createSeederGenerator());
|
|
48
|
+
// Register factory generator
|
|
49
|
+
registerGenerator(createFactoryGenerator());
|
|
42
50
|
}
|
|
43
51
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/generators/generators/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;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