@veloxts/cli 0.2.0 → 0.2.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/dist/cli.d.ts ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * VeloxTS CLI - Main entry point
4
+ *
5
+ * A beautiful, Laravel-inspired command-line interface for the VeloxTS Framework
6
+ */
7
+ export {};
8
+ //# sourceMappingURL=cli.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";AAEA;;;;GAIG"}
package/dist/cli.js ADDED
@@ -0,0 +1,46 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * VeloxTS CLI - Main entry point
4
+ *
5
+ * A beautiful, Laravel-inspired command-line interface for the VeloxTS Framework
6
+ */
7
+ import { Command } from 'commander';
8
+ import { createDevCommand } from './commands/dev.js';
9
+ import { createMigrateCommand } from './commands/migrate.js';
10
+ import { CLI_VERSION } from './index.js';
11
+ /**
12
+ * Create the main CLI program
13
+ */
14
+ function createCLI() {
15
+ const program = new Command();
16
+ program
17
+ .name('velox')
18
+ .description('VeloxTS Framework - Laravel-inspired TypeScript full-stack framework')
19
+ .version(CLI_VERSION, '-v, --version', 'Output the current version')
20
+ .helpOption('-h, --help', 'Display help for command');
21
+ // Register commands
22
+ program.addCommand(createDevCommand(CLI_VERSION));
23
+ program.addCommand(createMigrateCommand());
24
+ return program;
25
+ }
26
+ /**
27
+ * Main entry point
28
+ */
29
+ async function main() {
30
+ const program = createCLI();
31
+ try {
32
+ await program.parseAsync(process.argv);
33
+ }
34
+ catch (error) {
35
+ if (error instanceof Error) {
36
+ console.error(`Error: ${error.message}`);
37
+ }
38
+ else {
39
+ console.error('An unknown error occurred');
40
+ }
41
+ process.exit(1);
42
+ }
43
+ }
44
+ // Run the CLI
45
+ main();
46
+ //# sourceMappingURL=cli.js.map
@@ -0,0 +1 @@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}
@@ -0,0 +1,11 @@
1
+ /**
2
+ * Dev command - Start development server with hot reload
3
+ *
4
+ * Inspired by Laravel's `php artisan serve` and Vite's dev server
5
+ */
6
+ import { Command } from 'commander';
7
+ /**
8
+ * Create the dev command
9
+ */
10
+ export declare function createDevCommand(version: string): Command;
11
+ //# sourceMappingURL=dev.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dev.d.ts","sourceRoot":"","sources":["../../src/commands/dev.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAKH,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAmBpC;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CASzD"}
@@ -0,0 +1,156 @@
1
+ /**
2
+ * Dev command - Start development server with hot reload
3
+ *
4
+ * Inspired by Laravel's `php artisan serve` and Vite's dev server
5
+ */
6
+ import { spawn } from 'node:child_process';
7
+ import * as p from '@clack/prompts';
8
+ import { Command } from 'commander';
9
+ import pc from 'picocolors';
10
+ import { error, formatCommand, formatPath, info, instruction, printBanner, } from '../utils/output.js';
11
+ import { findEntryPoint, isVeloxProject, validateEntryPath } from '../utils/paths.js';
12
+ /**
13
+ * Create the dev command
14
+ */
15
+ export function createDevCommand(version) {
16
+ return new Command('dev')
17
+ .description('Start the development server with hot reload')
18
+ .option('-p, --port <port>', 'Port to listen on', '3210')
19
+ .option('-H, --host <host>', 'Host to bind to', 'localhost')
20
+ .option('-e, --entry <file>', 'Entry point file (auto-detected if not specified)')
21
+ .action(async (options) => {
22
+ await runDevServer(options, version);
23
+ });
24
+ }
25
+ /**
26
+ * Run the development server
27
+ */
28
+ async function runDevServer(options, version) {
29
+ const s = p.spinner();
30
+ try {
31
+ // Check if we're in a VeloxTS project
32
+ s.start('Checking project...');
33
+ const isVelox = await isVeloxProject();
34
+ if (!isVelox) {
35
+ s.stop('Project check failed');
36
+ error('This does not appear to be a VeloxTS project.');
37
+ instruction(`Run ${formatCommand('npx create-velox-app')} to create a new project.`);
38
+ process.exit(1);
39
+ }
40
+ s.stop('Project validated');
41
+ // Find and validate entry point
42
+ let entryPoint;
43
+ if (options.entry) {
44
+ // User specified an entry point - validate it
45
+ s.start('Validating entry point...');
46
+ try {
47
+ entryPoint = validateEntryPath(options.entry);
48
+ s.stop(`Entry point: ${formatPath(entryPoint)}`);
49
+ }
50
+ catch (err) {
51
+ s.stop('Invalid entry point');
52
+ error(err instanceof Error ? err.message : 'Invalid entry point');
53
+ process.exit(1);
54
+ }
55
+ }
56
+ else {
57
+ // Auto-detect entry point
58
+ s.start('Detecting entry point...');
59
+ const detected = findEntryPoint();
60
+ if (!detected) {
61
+ s.stop('Entry point not found');
62
+ error('Could not find application entry point.');
63
+ instruction('Try specifying the entry point with --entry flag:');
64
+ console.log(` ${formatCommand('velox dev --entry src/index.ts')}`);
65
+ process.exit(1);
66
+ }
67
+ entryPoint = detected;
68
+ s.stop(`Entry point: ${formatPath(entryPoint)}`);
69
+ }
70
+ // Validate port and host
71
+ const port = options.port || '3210';
72
+ const host = options.host || 'localhost';
73
+ // Validate port is a valid number
74
+ const portNum = Number.parseInt(port, 10);
75
+ if (Number.isNaN(portNum) || portNum < 1 || portNum > 65535) {
76
+ error(`Invalid port: ${port}. Port must be a number between 1 and 65535.`);
77
+ process.exit(1);
78
+ }
79
+ // Validate host doesn't contain dangerous characters
80
+ const validHostPattern = /^[a-zA-Z0-9.-]+$/;
81
+ if (!validHostPattern.test(host)) {
82
+ error(`Invalid host: ${host}. Host should only contain alphanumeric characters, dots, and dashes.`);
83
+ process.exit(1);
84
+ }
85
+ // Print startup banner
86
+ printBanner(version);
87
+ info('Starting development server...');
88
+ console.log('');
89
+ // Set environment variables for the app
90
+ const env = {
91
+ ...process.env,
92
+ PORT: port,
93
+ HOST: host,
94
+ NODE_ENV: 'development',
95
+ };
96
+ // Spawn tsx in watch mode
97
+ const devProcess = spawn('npx', ['tsx', 'watch', entryPoint], {
98
+ stdio: 'inherit',
99
+ env,
100
+ shell: true,
101
+ });
102
+ // Handle process termination
103
+ let isShuttingDown = false;
104
+ const shutdown = (signal) => {
105
+ if (isShuttingDown)
106
+ return;
107
+ isShuttingDown = true;
108
+ console.log(`\n\n${pc.yellow('⚠')} ${pc.dim(`Received ${signal}, shutting down gracefully...`)}`);
109
+ devProcess.kill('SIGTERM');
110
+ // Force kill after 5 seconds if process doesn't exit
111
+ const forceKillTimeout = setTimeout(() => {
112
+ console.log(pc.red('✗ Force killing process...'));
113
+ devProcess.kill('SIGKILL');
114
+ process.exit(1);
115
+ }, 5000);
116
+ devProcess.on('exit', () => {
117
+ clearTimeout(forceKillTimeout);
118
+ console.log(pc.dim('Development server stopped.'));
119
+ process.exit(0);
120
+ });
121
+ };
122
+ // Handle Ctrl+C and other termination signals
123
+ process.on('SIGINT', () => shutdown('SIGINT'));
124
+ process.on('SIGTERM', () => shutdown('SIGTERM'));
125
+ // Handle dev process errors
126
+ devProcess.on('error', (err) => {
127
+ error(`Failed to start development server: ${err.message}`);
128
+ process.exit(1);
129
+ });
130
+ devProcess.on('exit', (code) => {
131
+ if (!isShuttingDown && code !== 0) {
132
+ error(`Development server exited with code ${code}`);
133
+ process.exit(code || 1);
134
+ }
135
+ });
136
+ }
137
+ catch (err) {
138
+ s.stop('Failed to start development server');
139
+ if (err instanceof Error) {
140
+ error(err.message);
141
+ // Provide helpful suggestions based on error
142
+ if (err.message.includes('EADDRINUSE')) {
143
+ instruction(`Port ${options.port} is already in use. Try a different port:`);
144
+ console.log(` ${formatCommand(`velox dev --port ${Number(options.port || 3210) + 1}`)}`);
145
+ }
146
+ else if (err.message.includes('EACCES')) {
147
+ instruction('Permission denied. Try using a port above 1024.');
148
+ }
149
+ }
150
+ else {
151
+ error('An unknown error occurred');
152
+ }
153
+ process.exit(1);
154
+ }
155
+ }
156
+ //# sourceMappingURL=dev.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dev.js","sourceRoot":"","sources":["../../src/commands/dev.ts"],"names":[],"mappings":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ravel-inspired output
5
+ */
6
+ import { Command } from 'commander';
7
+ /**
8
+ * Create the migrate command
9
+ */
10
+ export declare function createMigrateCommand(): Command;
11
+ //# sourceMappingURL=migrate.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"migrate.d.ts","sourceRoot":"","sources":["../../src/commands/migrate.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAMH,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAWpC;;GAEG;AACH,wBAAgB,oBAAoB,IAAI,OAAO,CAQ9C"}
@@ -0,0 +1,132 @@
1
+ /**
2
+ * Migrate command - Run database migrations
3
+ *
4
+ * Wrapper around Prisma migrations with beautiful Laravel-inspired output
5
+ */
6
+ import { spawn } from 'node:child_process';
7
+ import path from 'node:path';
8
+ import * as p from '@clack/prompts';
9
+ import { Command } from 'commander';
10
+ import pc from 'picocolors';
11
+ import { error, formatCommand, info, instruction, success } from '../utils/output.js';
12
+ import { fileExists } from '../utils/paths.js';
13
+ /**
14
+ * Create the migrate command
15
+ */
16
+ export function createMigrateCommand() {
17
+ return new Command('migrate')
18
+ .description('Run database migrations')
19
+ .option('--deploy', 'Run migrations in production mode (prisma migrate deploy)')
20
+ .option('--force', 'Force push schema without migration (development only)')
21
+ .action(async (options) => {
22
+ await runMigrations(options);
23
+ });
24
+ }
25
+ /**
26
+ * Run database migrations
27
+ */
28
+ async function runMigrations(options) {
29
+ const s = p.spinner();
30
+ try {
31
+ // Check if Prisma schema exists
32
+ const schemaPath = path.join(process.cwd(), 'prisma', 'schema.prisma');
33
+ if (!fileExists(schemaPath)) {
34
+ error('Prisma schema not found.');
35
+ instruction('Expected to find prisma/schema.prisma in the current directory.');
36
+ instruction(`Initialize Prisma with: ${formatCommand('npx prisma init')}`);
37
+ process.exit(1);
38
+ }
39
+ // Determine which command to run
40
+ let command;
41
+ let description;
42
+ if (options.deploy) {
43
+ // Production: Apply pending migrations
44
+ command = ['prisma', 'migrate', 'deploy'];
45
+ description = 'Applying production migrations';
46
+ }
47
+ else if (options.force) {
48
+ // Development: Force push schema
49
+ command = ['prisma', 'db', 'push', '--skip-generate'];
50
+ description = 'Pushing database schema (development mode)';
51
+ }
52
+ else {
53
+ // Development: Push with generate
54
+ command = ['prisma', 'db', 'push'];
55
+ description = 'Synchronizing database schema';
56
+ }
57
+ info(description);
58
+ console.log('');
59
+ s.start('Running Prisma...');
60
+ // Run the Prisma command
61
+ await new Promise((resolve, reject) => {
62
+ const prismaProcess = spawn('npx', command, {
63
+ stdio: 'inherit',
64
+ shell: true,
65
+ env: process.env,
66
+ });
67
+ prismaProcess.on('error', (err) => {
68
+ reject(new Error(`Failed to run Prisma: ${err.message}`));
69
+ });
70
+ prismaProcess.on('exit', (code) => {
71
+ if (code === 0) {
72
+ resolve();
73
+ }
74
+ else {
75
+ reject(new Error(`Prisma exited with code ${code}`));
76
+ }
77
+ });
78
+ });
79
+ s.stop('Migration completed');
80
+ console.log('');
81
+ success('Database schema synchronized successfully!');
82
+ // Show next steps for production migrations
83
+ if (options.deploy) {
84
+ instruction('Your database is now up to date with the latest migrations.');
85
+ }
86
+ else {
87
+ console.log('');
88
+ info('Development tips:');
89
+ console.log(` ${pc.dim('•')} Use ${formatCommand('velox migrate')} to sync schema changes during development`);
90
+ console.log(` ${pc.dim('•')} Use ${formatCommand('velox migrate --deploy')} in production to apply migrations`);
91
+ console.log(` ${pc.dim('•')} Use ${formatCommand('npx prisma studio')} to explore your database`);
92
+ console.log('');
93
+ }
94
+ }
95
+ catch (err) {
96
+ s.stop('Migration failed');
97
+ console.log('');
98
+ if (err instanceof Error) {
99
+ error(err.message);
100
+ // Provide helpful suggestions based on error
101
+ if (err.message.includes('P1001')) {
102
+ instruction('Cannot reach database server. Check your connection:');
103
+ console.log(` ${pc.dim('1.')} Verify DATABASE_URL in .env file`);
104
+ console.log(` ${pc.dim('2.')} Ensure database server is running`);
105
+ console.log(` ${pc.dim('3.')} Check network connectivity`);
106
+ }
107
+ else if (err.message.includes('P3009')) {
108
+ instruction('Migration failed. Your changes may conflict with existing data.');
109
+ console.log(` ${pc.dim('•')} Review the Prisma error above`);
110
+ console.log(` ${pc.dim('•')} Consider creating a manual migration`);
111
+ }
112
+ else if (err.message.includes('P1003')) {
113
+ instruction('Database does not exist. Create it first:');
114
+ console.log(` ${pc.dim('•')} Check your DATABASE_URL`);
115
+ console.log(` ${pc.dim('•')} Create the database manually if needed`);
116
+ }
117
+ else {
118
+ instruction('Common solutions:');
119
+ console.log(` ${pc.dim('1.')} Check your DATABASE_URL in .env`);
120
+ console.log(` ${pc.dim('2.')} Ensure Prisma schema is valid: ${formatCommand('npx prisma validate')}`);
121
+ console.log(` ${pc.dim('3.')} Review Prisma logs above for specific errors`);
122
+ }
123
+ console.log('');
124
+ instruction(`For more help, see: ${pc.cyan('https://www.prisma.io/docs/reference/api-reference/command-reference')}`);
125
+ }
126
+ else {
127
+ error('An unknown error occurred');
128
+ }
129
+ process.exit(1);
130
+ }
131
+ }
132
+ //# sourceMappingURL=migrate.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"migrate.js","sourceRoot":"","sources":["../../src/commands/migrate.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAC3C,OAAO,IAAI,MAAM,WAAW,CAAC;AAE7B,OAAO,KAAK,CAAC,MAAM,gBAAgB,CAAC;AACpC,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,MAAM,YAAY,CAAC;AAE5B,OAAO,EAAE,KAAK,EAAE,aAAa,EAAE,IAAI,EAAE,WAAW,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AACtF,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAO/C;;GAEG;AACH,MAAM,UAAU,oBAAoB;IAClC,OAAO,IAAI,OAAO,CAAC,SAAS,CAAC;SAC1B,WAAW,CAAC,yBAAyB,CAAC;SACtC,MAAM,CAAC,U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CLI for the VeloxTS Framework that provides
5
+ * commands for development, database migrations, and other developer workflows.
6
+ *
7
+ * @example
8
+ * ```bash
9
+ * # Start development server
10
+ * velox dev
11
+ *
12
+ * # Run database migrations
13
+ * velox migrate
14
+ *
15
+ * # Show help
16
+ * velox --help
17
+ * ```
18
+ */
19
+ /**
20
+ * CLI version (synchronized with package.json)
21
+ */
22
+ export declare const CLI_VERSION = "0.1.0";
23
+ /**
24
+ * Export command functions for programmatic usage
25
+ */
26
+ export { createDevCommand } from './commands/dev.js';
27
+ export { createMigrateCommand } from './commands/migrate.js';
28
+ /**
29
+ * Export utilities for reuse in other packages
30
+ */
31
+ export * from './utils/output.js';
32
+ export * from './utils/paths.js';
33
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH;;GAEG;AACH,eAAO,MAAM,WAAW,UAAU,CAAC;AAEnC;;GAEG;AACH,OAAO,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AACrD,OAAO,EAAE,oBAAoB,EAAE,MAAM,uBAAuB,CAAC;AAC7D;;GAEG;AACH,cAAc,mBAAmB,CAAC;AAClC,cAAc,kBAAkB,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,33 @@
1
+ /**
2
+ * @veloxts/cli - Developer tooling and command-line interface
3
+ *
4
+ * A beautiful, Laravel-inspired CLI for the VeloxTS Framework that provides
5
+ * commands for development, database migrations, and other developer workflows.
6
+ *
7
+ * @example
8
+ * ```bash
9
+ * # Start development server
10
+ * velox dev
11
+ *
12
+ * # Run database migrations
13
+ * velox migrate
14
+ *
15
+ * # Show help
16
+ * velox --help
17
+ * ```
18
+ */
19
+ /**
20
+ * CLI version (synchronized with package.json)
21
+ */
22
+ export const CLI_VERSION = '0.1.0';
23
+ /**
24
+ * Export command functions for programmatic usage
25
+ */
26
+ export { createDevCommand } from './commands/dev.js';
27
+ export { createMigrateCommand } from './commands/migrate.js';
28
+ /**
29
+ * Export utilities for reuse in other packages
30
+ */
31
+ export * from './utils/output.js';
32
+ export * from './utils/paths.js';
33
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH;;GAEG;AACH,MAAM,CAAC,MAAM,WAAW,GAAG,OAAO,CAAC;AAEnC;;GAEG;AACH,OAAO,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AACrD,OAAO,EAAE,oBAAoB,EAAE,MAAM,uBAAuB,CAAC;AAC7D;;GAEG;AACH,cAAc,mBAAmB,CAAC;AAClC,cAAc,kBAAkB,CAAC"}
@@ -0,0 +1,50 @@
1
+ /**
2
+ * Terminal output utilities
3
+ *
4
+ * Provides beautiful, Laravel-inspired terminal output formatting
5
+ */
6
+ /**
7
+ * Print a beautiful VeloxTS banner
8
+ */
9
+ export declare function printBanner(version: string): void;
10
+ /**
11
+ * Print server listening information
12
+ */
13
+ export declare function printServerInfo(url: string): void;
14
+ /**
15
+ * Print a success message
16
+ */
17
+ export declare function success(message: string): void;
18
+ /**
19
+ * Print an error message
20
+ */
21
+ export declare function error(message: string): void;
22
+ /**
23
+ * Print a warning message
24
+ */
25
+ export declare function warning(message: string): void;
26
+ /**
27
+ * Print an info message
28
+ */
29
+ export declare function info(message: string): void;
30
+ /**
31
+ * Print a step in a process
32
+ */
33
+ export declare function step(message: string): void;
34
+ /**
35
+ * Print instructions for user
36
+ */
37
+ export declare function instruction(message: string): void;
38
+ /**
39
+ * Format a file path for display
40
+ */
41
+ export declare function formatPath(path: string): string;
42
+ /**
43
+ * Format a command for display
44
+ */
45
+ export declare function formatCommand(command: string): string;
46
+ /**
47
+ * Format a URL for display
48
+ */
49
+ export declare function formatUrl(url: string): string;
50
+ //# sourceMappingURL=output.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"output.d.ts","sourceRoot":"","sources":["../../src/utils/output.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAIH;;GAEG;AACH,wBAAgB,WAAW,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAKjD;AAED;;GAEG;AACH,wBAAgB,eAAe,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,CAIjD;AAED;;GAEG;AACH,wBAAgB,OAAO,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAE7C;AAED;;GAEG;AACH,wBAAgB,KAAK,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAE3C;AAED;;GAEG;AACH,wBAAgB,OAAO,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAE7C;AAED;;GAEG;AACH,wBAAgB,IAAI,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAE1C;AAED;;GAEG;AACH,wBAAgB,IAAI,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAE1C;AAED;;GAEG;AACH,wBAAgB,WAAW,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAEjD;AAED;;GAEG;AACH,wBAAgB,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAE/C;AAED;;GAEG;AACH,wBAAgB,aAAa,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAErD;AAED;;GAEG;AACH,wBAAgB,SAAS,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAE7C"}
@@ -0,0 +1,78 @@
1
+ /**
2
+ * Terminal output utilities
3
+ *
4
+ * Provides beautiful, Laravel-inspired terminal output formatting
5
+ */
6
+ import pc from 'picocolors';
7
+ /**
8
+ * Print a beautiful VeloxTS banner
9
+ */
10
+ export function printBanner(version) {
11
+ const divider = '═'.repeat(50);
12
+ console.log(`\n${pc.cyan(divider)}`);
13
+ console.log(pc.cyan(` VELOX ${pc.bold(`v${version}`)}`));
14
+ console.log(pc.cyan(divider));
15
+ }
16
+ /**
17
+ * Print server listening information
18
+ */
19
+ export function printServerInfo(url) {
20
+ console.log('');
21
+ console.log(` ${pc.green('➜')} Local: ${pc.cyan(url)}`);
22
+ console.log('');
23
+ }
24
+ /**
25
+ * Print a success message
26
+ */
27
+ export function success(message) {
28
+ console.log(`${pc.green('✓')} ${message}`);
29
+ }
30
+ /**
31
+ * Print an error message
32
+ */
33
+ export function error(message) {
34
+ console.error(`${pc.red('✗')} ${pc.red(message)}`);
35
+ }
36
+ /**
37
+ * Print a warning message
38
+ */
39
+ export function warning(message) {
40
+ console.warn(`${pc.yellow('⚠')} ${pc.yellow(message)}`);
41
+ }
42
+ /**
43
+ * Print an info message
44
+ */
45
+ export function info(message) {
46
+ console.log(`${pc.blue('ℹ')} ${message}`);
47
+ }
48
+ /**
49
+ * Print a step in a process
50
+ */
51
+ export function step(message) {
52
+ console.log(` ${pc.dim('→')} ${message}`);
53
+ }
54
+ /**
55
+ * Print instructions for user
56
+ */
57
+ export function instruction(message) {
58
+ console.log(`\n ${pc.dim(message)}\n`);
59
+ }
60
+ /**
61
+ * Format a file path for display
62
+ */
63
+ export function formatPath(path) {
64
+ return pc.cyan(path);
65
+ }
66
+ /**
67
+ * Format a command for display
68
+ */
69
+ export function formatCommand(command) {
70
+ return pc.cyan(command);
71
+ }
72
+ /**
73
+ * Format a URL for display
74
+ */
75
+ export function formatUrl(url) {
76
+ return pc.cyan(url);
77
+ }
78
+ //# sourceMappingURL=output.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"output.js","sourceRoot":"","sources":["../../src/utils/output.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,MAAM,YAAY,CAAC;AAE5B;;GAEG;AACH,MAAM,UAAU,WAAW,CAAC,OAAe;IACzC,MAAM,OAAO,GAAG,GAAG,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;IAC/B,OAAO,CAAC,GAAG,CAAC,KAAK,EAAE,CAAC,IAAI,CAAC,OAAO,CAAC,EAAE,CAAC,CAA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EG;AACH,MAAM,UAAU,IAAI,CAAC,OAAe;IAClC,OAAO,CAAC,GAAG,CAAC,KAAK,EAAE,CAAC,GAAG,CAAC,GAAG,CAAC,IAAI,OAAO,EAAE,CAAC,CAAC;AAC7C,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,WAAW,CAAC,OAAe;IACzC,OAAO,CAAC,GAAG,CAAC,OAAO,EAAE,CAAC,GAAG,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;AAC1C,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,UAAU,CAAC,IAAY;IACrC,OAAO,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AACvB,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,aAAa,CAAC,OAAe;IAC3C,OAAO,EAAE,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;AAC1B,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,SAAS,CAAC,GAAW;IACnC,OAAO,EAAE,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AACtB,CAAC"}
@@ -0,0 +1,36 @@
1
+ /**
2
+ * Path utilities for finding project files
3
+ */
4
+ /**
5
+ * Find the project entry point
6
+ * Looks for common entry points in order of preference
7
+ */
8
+ export declare function findEntryPoint(cwd?: string): string | null;
9
+ /**
10
+ * Check if a file exists at the given path
11
+ */
12
+ export declare function fileExists(filePath: string): boolean;
13
+ /**
14
+ * Get the absolute path from a relative path
15
+ */
16
+ export declare function getAbsolutePath(relativePath: string, cwd?: string): string;
17
+ /**
18
+ * Validate that a path is safe for use in shell commands
19
+ *
20
+ * This prevents command injection attacks by ensuring:
21
+ * 1. Path is within the current working directory (no path traversal)
22
+ * 2. Path doesn't contain shell metacharacters
23
+ * 3. File exists and is a TypeScript/JavaScript file
24
+ *
25
+ * @param filePath - The path to validate
26
+ * @param cwd - The current working directory
27
+ * @returns The normalized, validated path
28
+ * @throws Error if the path is invalid or unsafe
29
+ */
30
+ export declare function validateEntryPath(filePath: string, cwd?: string): string;
31
+ /**
32
+ * Check if we're in a VeloxTS project
33
+ * Looks for package.json with @veloxts dependencies
34
+ */
35
+ export declare function isVeloxProject(cwd?: string): Promise<boolean>;
36
+ //# sourceMappingURL=paths.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"paths.d.ts","sourceRoot":"","sources":["../../src/utils/paths.ts"],"names":[],"mappings":"AAAA;;GAEG;AAKH;;;GAGG;AACH,wBAAgB,cAAc,CAAC,GAAG,GAAE,MAAsB,GAAG,MAAM,GAAG,IAAI,CAWzE;AAED;;GAEG;AACH,wBAAgB,UAAU,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAEpD;AAED;;GAEG;AACH,wBAAgB,eAAe,CAAC,YAAY,EAAE,MAAM,EAAE,GAAG,GAAE,MAAsB,GAAG,MAAM,CAEzF;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,iBAAiB,CAAC,QAAQ,EAAE,MAAM,EAAE,GAAG,GAAE,MAAsB,GAAG,MAAM,CAuCvF;AAED;;;GAGG;AACH,wBAAsB,cAAc,CAAC,GAAG,GAAE,MAAsB,GAAG,OAAO,CAAC,OAAO,CAAC,CAkBlF"}
@@ -0,0 +1,95 @@
1
+ /**
2
+ * Path utilities for finding project files
3
+ */
4
+ import { existsSync } from 'node:fs';
5
+ import path from 'node:path';
6
+ /**
7
+ * Find the project entry point
8
+ * Looks for common entry points in order of preference
9
+ */
10
+ export function findEntryPoint(cwd = process.cwd()) {
11
+ const candidates = ['src/index.ts', 'src/main.ts', 'src/app.ts', 'index.ts', 'main.ts'];
12
+ for (const candidate of candidates) {
13
+ const fullPath = path.join(cwd, candidate);
14
+ if (existsSync(fullPath)) {
15
+ return fullPath;
16
+ }
17
+ }
18
+ return null;
19
+ }
20
+ /**
21
+ * Check if a file exists at the given path
22
+ */
23
+ export function fileExists(filePath) {
24
+ return existsSync(filePath);
25
+ }
26
+ /**
27
+ * Get the absolute path from a relative path
28
+ */
29
+ export function getAbsolutePath(relativePath, cwd = process.cwd()) {
30
+ return path.isAbsolute(relativePath) ? relativePath : path.join(cwd, relativePath);
31
+ }
32
+ /**
33
+ * Validate that a path is safe for use in shell commands
34
+ *
35
+ * This prevents command injection attacks by ensuring:
36
+ * 1. Path is within the current working directory (no path traversal)
37
+ * 2. Path doesn't contain shell metacharacters
38
+ * 3. File exists and is a TypeScript/JavaScript file
39
+ *
40
+ * @param filePath - The path to validate
41
+ * @param cwd - The current working directory
42
+ * @returns The normalized, validated path
43
+ * @throws Error if the path is invalid or unsafe
44
+ */
45
+ export function validateEntryPath(filePath, cwd = process.cwd()) {
46
+ // Normalize the path to resolve any .. or . segments
47
+ const absolutePath = path.isAbsolute(filePath)
48
+ ? path.normalize(filePath)
49
+ : path.normalize(path.join(cwd, filePath));
50
+ // Ensure the path is within the current working directory
51
+ const normalizedCwd = path.normalize(cwd);
52
+ if (!absolutePath.startsWith(normalizedCwd)) {
53
+ throw new Error(`Entry path must be within the project directory. ` +
54
+ `Got: ${filePath}, which resolves to: ${absolutePath}`);
55
+ }
56
+ // Check for dangerous shell characters that could enable command injection
57
+ const dangerousChars = /[;&|`$(){}[\]<>!#*?\\'"\n\r\t]/;
58
+ if (dangerousChars.test(filePath)) {
59
+ throw new Error(`Entry path contains invalid characters. ` +
60
+ `Path should only contain alphanumeric characters, slashes, dots, and dashes.`);
61
+ }
62
+ // Verify the file exists
63
+ if (!existsSync(absolutePath)) {
64
+ throw new Error(`Entry point file not found: ${absolutePath}`);
65
+ }
66
+ // Verify it's a TypeScript or JavaScript file
67
+ const ext = path.extname(absolutePath).toLowerCase();
68
+ const validExtensions = ['.ts', '.tsx', '.js', '.jsx', '.mts', '.mjs', '.cts', '.cjs'];
69
+ if (!validExtensions.includes(ext)) {
70
+ throw new Error(`Entry point must be a TypeScript or JavaScript file. Got: ${ext || 'no extension'}`);
71
+ }
72
+ return absolutePath;
73
+ }
74
+ /**
75
+ * Check if we're in a VeloxTS project
76
+ * Looks for package.json with @veloxts dependencies
77
+ */
78
+ export async function isVeloxProject(cwd = process.cwd()) {
79
+ const packageJsonPath = path.join(cwd, 'package.json');
80
+ if (!existsSync(packageJsonPath)) {
81
+ return false;
82
+ }
83
+ try {
84
+ const fs = await import('node:fs/promises');
85
+ const content = await fs.readFile(packageJsonPath, 'utf-8');
86
+ const pkg = JSON.parse(content);
87
+ // Check if any @veloxts packages are in dependencies
88
+ const deps = { ...pkg.dependencies, ...pkg.devDependencies };
89
+ return Object.keys(deps).some((dep) => dep.startsWith('@veloxts/'));
90
+ }
91
+ catch {
92
+ return false;
93
+ }
94
+ }
95
+ //# sourceMappingURL=paths.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"paths.js","sourceRoot":"","sources":["../../src/utils/paths.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,IAAI,MAAM,WAAW,CAAC;AAE7B;;;GAGG;AACH,MAAM,UAAU,cAAc,CAAC,MAAc,OAAO,CAAC,GAAG,EAAE;IACxD,MAAM,UAAU,GAAG,CAAC,cAAc,EAAE,aAAa,EAAE,YAAY,EAAE,UAAU,EAAE,SAAS,CAAC,CAAC;IAExF,KAAK,MAAM,SAAS,IAAI,UAAU,EAAE,CAAC;QACnC,MAAM,QAAQ,GAAG,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,SAAS,CAAC,CAAC;QAC3C,IAAI,UAAU,CAAC,QAAQ,CAAC,EAAE,CAAC;YACzB,OAAO,QAAQ,CAAC;QAClB,CAAC;IACH,CAAC;IAED,OAAO,IAAI,CAAC;AACd,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,UAAU,CAAC,QAAgB;IACzC,OAAO,UAAU,CAAC,QAAQ,CAAC,CAAC;AAC9B,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,eAAe,CAAC,YAAoB,EAAE,MAAc,OAAO,CAAC,GAAG,EAAE;IAC/E,OAAO,IAAI,CAAC,UAAU,CAAC,YAAY,CAAC,CA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AAM,EAAE,MAAM,CAAC,CAAC;IACvF,IAAI,CAAC,eAAe,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE,CAAC;QACnC,MAAM,IAAI,KAAK,CACb,6DAA6D,GAAG,IAAI,cAAc,EAAE,CACrF,CAAC;IACJ,CAAC;IAED,OAAO,YAAY,CAAC;AACtB,CAAC;AAED;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,cAAc,CAAC,MAAc,OAAO,CAAC,GAAG,EAAE;IAC9D,MAAM,eAAe,GAAG,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,cAAc,CAAC,CAAC;IAEvD,IAAI,CAAC,UAAU,CAAC,eAAe,CAAC,EAAE,CAAC;QACjC,OAAO,KAAK,CAAC;IACf,CAAC;IAED,IAAI,CAAC;QACH,MAAM,EAAE,GAAG,MAAM,MAAM,CAAC,kBAAkB,CAAC,CAAC;QAC5C,MAAM,OAAO,GAAG,MAAM,EAAE,CAAC,QAAQ,CAAC,eAAe,EAAE,OAAO,CAAC,CAAC;QAC5D,MAAM,GAAG,GAAG,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;QAEhC,qDAAqD;QACrD,MAAM,IAAI,GAAG,EAAE,GAAG,GAAG,CAAC,YAAY,EAAE,GAAG,GAAG,CAAC,eAAe,EAAE,CAAC;QAC7D,OAAO,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,UAAU,CAAC,WAAW,CAAC,CAAC,CAAC;IACtE,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,KAAK,CAAC;IACf,CAAC;AACH,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@veloxts/cli",
3
- "version": "0.2.0",
3
+ "version": "0.2.2",
4
4
  "description": "Developer tooling and CLI commands for VeloxTS framework",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -23,11 +23,11 @@
23
23
  "@clack/prompts": "0.11.0",
24
24
  "picocolors": "1.1.1",
25
25
  "tsx": "4.21.0",
26
- "@veloxts/core": "0.2.0",
27
- "@veloxts/router": "0.2.0",
28
- "@veloxts/validation": "0.2.0",
29
- "@veloxts/orm": "0.2.0",
30
- "@veloxts/auth": "0.2.0"
26
+ "@veloxts/core": "0.2.2",
27
+ "@veloxts/router": "0.2.2",
28
+ "@veloxts/validation": "0.2.2",
29
+ "@veloxts/orm": "0.2.2",
30
+ "@veloxts/auth": "0.2.2"
31
31
  },
32
32
  "devDependencies": {
33
33
  "@types/node": "24.10.1",