create-velox-app 0.1.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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 VeloxTS Framework Contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,366 @@
1
+ # create-velox-app
2
+
3
+ Interactive project scaffolder for the VeloxTS framework.
4
+
5
+ ## Usage
6
+
7
+ Create a new VeloxTS project with a single command:
8
+
9
+ ```bash
10
+ # Using npx (recommended)
11
+ npx create-velox-app my-app
12
+
13
+ # Using pnpm
14
+ pnpm create velox-app my-app
15
+
16
+ # Using npm
17
+ npm create velox-app my-app
18
+
19
+ # Using yarn
20
+ yarn create velox-app my-app
21
+ ```
22
+
23
+ ## Interactive Mode
24
+
25
+ Run without a project name for interactive setup:
26
+
27
+ ```bash
28
+ npx create-velox-app
29
+ ```
30
+
31
+ You'll be prompted for:
32
+ - **Project name** - Must use lowercase letters, numbers, and hyphens only
33
+
34
+ The scaffolder automatically detects your package manager (npm, pnpm, or yarn) based on which command you used.
35
+
36
+ ## What Gets Created
37
+
38
+ The scaffolder generates a complete, ready-to-run VeloxTS application with:
39
+
40
+ ### Project Structure
41
+
42
+ ```
43
+ my-app/
44
+ ├── src/
45
+ │ ├── config/
46
+ │ │ ├── app.ts # Application configuration
47
+ │ │ └── index.ts # Config exports
48
+ │ ├── database/
49
+ │ │ ├── index.ts # Database plugin setup
50
+ │ │ └── prisma.ts # Prisma client initialization
51
+ │ ├── procedures/
52
+ │ │ ├── health.ts # Health check endpoint
53
+ │ │ ├── users.ts # Example user CRUD procedures
54
+ │ │ └── index.ts # Procedure exports
55
+ │ ├── schemas/
56
+ │ │ ├── user.ts # User validation schemas
57
+ │ │ └── index.ts # Schema exports
58
+ │ └── index.ts # Application entry point
59
+ ├── prisma/
60
+ │ └── schema.prisma # Database schema
61
+ ├── public/
62
+ │ └── index.html # Welcome page
63
+ ├── .env.example # Environment variables template
64
+ ├── .gitignore # Git ignore rules
65
+ ├── package.json # Dependencies and scripts
66
+ ├── tsconfig.json # TypeScript configuration
67
+ ├── tsup.config.ts # Build configuration
68
+ └── README.md # Project documentation
69
+ ```
70
+
71
+ ### Included Features
72
+
73
+ **Core Setup:**
74
+ - VeloxTS framework with all core packages (@veloxts/core, @veloxts/router, @veloxts/validation, @veloxts/orm)
75
+ - TypeScript configuration with strict mode
76
+ - Build setup using tsup (fast esbuild-based bundler)
77
+ - Hot reload development server via `velox dev`
78
+
79
+ **Database Integration:**
80
+ - Prisma ORM with example User model
81
+ - SQLite database (zero configuration for development)
82
+ - Database migrations ready to run
83
+ - Example CRUD procedures
84
+
85
+ **Example Code:**
86
+ - Health check endpoint (`GET /health`)
87
+ - Complete user CRUD API:
88
+ - `GET /users/:id` - Get user by ID
89
+ - `GET /users` - List users with pagination
90
+ - `POST /users` - Create new user
91
+ - `GET /users/search` - Search users by name/email
92
+ - Type-safe validation with Zod schemas
93
+ - Context-based database access
94
+
95
+ **Developer Experience:**
96
+ - Pre-configured scripts for development, build, and migrations
97
+ - Environment variable template (.env.example)
98
+ - Git initialization with .gitignore
99
+ - Welcome page at root URL
100
+ - Comprehensive README with getting started instructions
101
+
102
+ ## Generated Scripts
103
+
104
+ The scaffolded project includes these npm scripts:
105
+
106
+ ```bash
107
+ # Development
108
+ npm run dev # Start development server with hot reload (default: port 3210)
109
+
110
+ # Build
111
+ npm run build # Build for production
112
+ npm run start # Start production server
113
+
114
+ # Database
115
+ npm run db:migrate # Run database migrations
116
+ npm run db:generate # Generate Prisma client after schema changes
117
+
118
+ # Type checking
119
+ npm run type-check # Run TypeScript type checker
120
+ ```
121
+
122
+ ## Quick Start After Scaffolding
123
+
124
+ Once your project is created:
125
+
126
+ ```bash
127
+ # Navigate to project directory
128
+ cd my-app
129
+
130
+ # Set up database (creates SQLite file and applies schema)
131
+ npm run db:migrate
132
+
133
+ # Start development server
134
+ npm run dev
135
+ ```
136
+
137
+ Your VeloxTS app will be running at `http://localhost:3210`
138
+
139
+ Test the endpoints:
140
+
141
+ ```bash
142
+ # Health check
143
+ curl http://localhost:3210/health
144
+
145
+ # Create a user
146
+ curl -X POST http://localhost:3210/users \
147
+ -H "Content-Type: application/json" \
148
+ -d '{"name": "Alice", "email": "alice@example.com"}'
149
+
150
+ # List users
151
+ curl http://localhost:3210/users
152
+
153
+ # Get user by ID
154
+ curl http://localhost:3210/users/{id}
155
+
156
+ # Search users
157
+ curl http://localhost:3210/users/search?q=alice
158
+ ```
159
+
160
+ ## Configuration
161
+
162
+ ### Environment Variables
163
+
164
+ Copy `.env.example` to `.env` and customize:
165
+
166
+ ```env
167
+ # Application
168
+ NODE_ENV=development
169
+ PORT=3210
170
+ HOST=localhost
171
+
172
+ # Database
173
+ DATABASE_URL="file:./dev.db"
174
+ ```
175
+
176
+ ### Database Provider
177
+
178
+ The default template uses SQLite for zero-configuration development. To use PostgreSQL or MySQL:
179
+
180
+ 1. Update `prisma/schema.prisma`:
181
+
182
+ ```prisma
183
+ datasource db {
184
+ provider = "postgresql" // or "mysql"
185
+ url = env("DATABASE_URL")
186
+ }
187
+ ```
188
+
189
+ 2. Update `DATABASE_URL` in `.env`:
190
+
191
+ ```env
192
+ # PostgreSQL
193
+ DATABASE_URL="postgresql://user:password@localhost:5432/mydb?schema=public"
194
+
195
+ # MySQL
196
+ DATABASE_URL="mysql://user:password@localhost:3306/mydb"
197
+ ```
198
+
199
+ 3. Regenerate Prisma client:
200
+
201
+ ```bash
202
+ npm run db:generate
203
+ npm run db:migrate
204
+ ```
205
+
206
+ ## Project Templates
207
+
208
+ The current v0.1.0 release includes a single default template with:
209
+ - REST API endpoints
210
+ - Prisma database integration
211
+ - Example CRUD operations
212
+ - TypeScript strict mode
213
+
214
+ Future versions will include additional templates:
215
+ - Minimal template (barebone setup)
216
+ - Full-stack template (with frontend React app)
217
+ - Microservice template (optimized for containers)
218
+
219
+ ## Development
220
+
221
+ ### Building the Scaffolder
222
+
223
+ ```bash
224
+ # Clone the VeloxTS repository
225
+ git clone https://github.com/veloxts/velox-ts-framework.git
226
+ cd velox-framework
227
+
228
+ # Install dependencies
229
+ pnpm install
230
+
231
+ # Build create-velox-app
232
+ cd packages/create
233
+ pnpm build
234
+
235
+ # Test locally
236
+ node dist/cli.js my-test-app
237
+ ```
238
+
239
+ ### Smoke Testing
240
+
241
+ The scaffolder includes a smoke test script that validates the generated project:
242
+
243
+ ```bash
244
+ pnpm smoke-test
245
+ ```
246
+
247
+ This creates a temporary project, installs dependencies, runs type checking, and cleans up.
248
+
249
+ ## Command-Line Options
250
+
251
+ ```bash
252
+ npx create-velox-app [project-name] [options]
253
+ ```
254
+
255
+ **Arguments:**
256
+ - `project-name` - Name of the project to create (optional, will prompt if not provided)
257
+
258
+ **Options:**
259
+ - `-h, --help` - Display help message
260
+ - `-v, --version` - Display version number
261
+
262
+ **Examples:**
263
+
264
+ ```bash
265
+ # Create with explicit name
266
+ npx create-velox-app my-awesome-app
267
+
268
+ # Interactive mode (prompts for name)
269
+ npx create-velox-app
270
+
271
+ # Show help
272
+ npx create-velox-app --help
273
+
274
+ # Show version
275
+ npx create-velox-app --version
276
+ ```
277
+
278
+ ## Naming Rules
279
+
280
+ Project names must follow these rules:
281
+ - Use lowercase letters only
282
+ - Numbers are allowed
283
+ - Hyphens (-) are allowed for word separation
284
+ - No spaces, underscores, or special characters
285
+
286
+ **Valid names:**
287
+ - `my-app`
288
+ - `blog-api`
289
+ - `project123`
290
+ - `user-management-service`
291
+
292
+ **Invalid names:**
293
+ - `MyApp` (uppercase)
294
+ - `my_app` (underscore)
295
+ - `my app` (space)
296
+ - `my.app` (special character)
297
+
298
+ ## Troubleshooting
299
+
300
+ ### Directory Already Exists
301
+
302
+ ```
303
+ Error: Directory my-app already exists
304
+ ```
305
+
306
+ **Solution:** Choose a different project name or remove the existing directory.
307
+
308
+ ### Permission Denied
309
+
310
+ ```
311
+ Error: EACCES: permission denied
312
+ ```
313
+
314
+ **Solution:** Check directory permissions or run with appropriate permissions. Avoid using `sudo` with npm.
315
+
316
+ ### Installation Failed
317
+
318
+ ```
319
+ Error: npm install failed
320
+ ```
321
+
322
+ **Solution:** Try clearing npm cache and running again:
323
+
324
+ ```bash
325
+ npm cache clean --force
326
+ npx create-velox-app my-app
327
+ ```
328
+
329
+ ### Prisma Generation Failed
330
+
331
+ ```
332
+ Error: Prisma schema validation failed
333
+ ```
334
+
335
+ **Solution:** Ensure `DATABASE_URL` is set correctly in `.env`. For SQLite, the default `file:./dev.db` should work.
336
+
337
+ ## What's Next?
338
+
339
+ After creating your project:
340
+
341
+ 1. **Explore the generated code** - Check `src/procedures/users.ts` to see how procedures work
342
+ 2. **Modify the database schema** - Edit `prisma/schema.prisma` and run migrations
343
+ 3. **Add new procedures** - Create additional API endpoints following the user example
344
+ 4. **Connect a frontend** - Use `@veloxts/client` for type-safe API calls
345
+ 5. **Read the documentation** - Visit the [VeloxTS documentation](https://github.com/veloxts/velox-ts-framework/tree/main/docs) for guides
346
+
347
+ ## Learn More
348
+
349
+ - [VeloxTS Framework Documentation](https://github.com/veloxts/velox-ts-framework)
350
+ - [@veloxts/core](../core) - Core framework concepts
351
+ - [@veloxts/router](../router) - Procedure-based routing
352
+ - [@veloxts/validation](../validation) - Schema validation with Zod
353
+ - [@veloxts/orm](../orm) - Prisma integration
354
+ - [@veloxts/client](../client) - Type-safe frontend client
355
+
356
+ ## Contributing
357
+
358
+ Found a bug or want to improve the scaffolder? Contributions are welcome!
359
+
360
+ 1. Report issues at [GitHub Issues](https://github.com/veloxts/velox-ts-framework/issues)
361
+ 2. Submit pull requests with improvements
362
+ 3. Share feedback on the generated project structure
363
+
364
+ ## License
365
+
366
+ MIT
package/dist/cli.d.ts ADDED
@@ -0,0 +1,9 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * create-velox-app CLI entry point
4
+ *
5
+ * Executable entry point for the project scaffolder.
6
+ * Handles command-line arguments and initiates the scaffolding process.
7
+ */
8
+ export {};
9
+ //# sourceMappingURL=cli.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";AAEA;;;;;GAKG"}
package/dist/cli.js ADDED
@@ -0,0 +1,65 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * create-velox-app CLI entry point
4
+ *
5
+ * Executable entry point for the project scaffolder.
6
+ * Handles command-line arguments and initiates the scaffolding process.
7
+ */
8
+ import { CREATE_VERSION, createVeloxApp } from './index.js';
9
+ // ============================================================================
10
+ // Help & Version
11
+ // ============================================================================
12
+ const HELP_TEXT = `
13
+ create-velox-app v${CREATE_VERSION}
14
+
15
+ Usage:
16
+ npx create-velox-app [project-name]
17
+ pnpm create velox-app [project-name]
18
+
19
+ Options:
20
+ -h, --help Show this help message
21
+ -v, --version Show version number
22
+
23
+ Examples:
24
+ npx create-velox-app my-app
25
+ npx create-velox-app # Interactive mode
26
+ `;
27
+ // ============================================================================
28
+ // Main Entry Point
29
+ // ============================================================================
30
+ /**
31
+ * Parse arguments and run scaffolder
32
+ */
33
+ async function main() {
34
+ try {
35
+ // Get arguments
36
+ const args = process.argv.slice(2);
37
+ // Handle --help
38
+ if (args.includes('-h') || args.includes('--help')) {
39
+ console.log(HELP_TEXT);
40
+ process.exit(0);
41
+ }
42
+ // Handle --version
43
+ if (args.includes('-v') || args.includes('--version')) {
44
+ console.log(CREATE_VERSION);
45
+ process.exit(0);
46
+ }
47
+ // Get project name (first non-flag argument)
48
+ const projectName = args.find((arg) => !arg.startsWith('-'));
49
+ // Run scaffolder
50
+ await createVeloxApp(projectName);
51
+ }
52
+ catch (error) {
53
+ // Handle unexpected errors
54
+ if (error instanceof Error) {
55
+ console.error(`\nError: ${error.message}`);
56
+ }
57
+ else {
58
+ console.error('\nAn unexpected error occurred');
59
+ }
60
+ process.exit(1);
61
+ }
62
+ }
63
+ // Run the CLI
64
+ main();
65
+ //# sourceMappingURL=cli.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";AAEA;;;;;GAKG;AAEH,OAAO,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAE5D,+EAA+E;AAC/E,iBAAiB;AACjB,+EAA+E;AAE/E,MAAM,SAAS,GAAG;oBACE,cAAc;;;;;;;;;;;;;CAajC,CAAC;AAEF,+EAA+E;AAC/E,mBAAmB;AACnB,+EAA+E;AAE/E;;GAEG;AACH,KAAK,UAAU,IAAI;IACjB,IAAI,CAAC;QACH,gBAAgB;QAChB,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;QAEnC,gBAAgB;QAChB,IAAI,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,EAAE,CAAC;YACnD,OAAO,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;YACvB,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QAClB,CAAC;QAED,mBAAmB;QACnB,IAAI,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,IAAI,CAAC,QAAQ,CAAC,WAAW,CAAC,EAAE,CAAC;YACtD,OAAO,CAAC,GAAG,CAAC,cAAc,CAAC,CAAC;YAC5B,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QAClB,CAAC;QAED,6CAA6C;QAC7C,MAAM,WAAW,GAAG,IAAI,CAAC,IAAI,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC,GAAG,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,CAAC;QAE7D,iBAAiB;QACjB,MAAM,cAAc,CAAC,WAAW,CAAC,CAAC;IACpC,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,2BAA2B;QAC3B,IAAI,KAAK,YAAY,KAAK,EAAE,CAAC;YAC3B,OAAO,CAAC,KAAK,CAAC,YAAY,KAAK,CAAC,OAAO,EAAE,CAAC,CAAC;QAC7C,CAAC;aAAM,CAAC;YACN,OAAO,CAAC,KAAK,CAAC,gCAAgC,CAAC,CAAC;QAClD,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
+ * create-velox-app - Project scaffolding tool
3
+ *
4
+ * CLI tool for bootstrapping new VeloxTS applications with a default template.
5
+ * Provides an interactive setup experience similar to create-next-app.
6
+ */
7
+ export declare const CREATE_VERSION = "0.1.0";
8
+ /**
9
+ * Main scaffolding function that creates a new VeloxTS project
10
+ */
11
+ export declare function createVeloxApp(initialProjectName?: string): Promise<void>;
12
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAmCH,eAAO,MAAM,cAAc,UAAU,CAAC;AAgBtC;;GAEG;AACH,wBAAsB,cAAc,CAAC,kBAAkB,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAuC/E"}