neex 0.6.45 → 0.6.47

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.
@@ -1,191 +1,72 @@
1
1
  "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
25
2
  var __importDefault = (this && this.__importDefault) || function (mod) {
26
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
27
4
  };
28
5
  Object.defineProperty(exports, "__esModule", { value: true });
29
6
  exports.addBuildCommands = void 0;
30
7
  const build_manager_js_1 = require("../build-manager.js");
8
+ const logger_manager_js_1 = require("../logger-manager.js");
31
9
  const chalk_1 = __importDefault(require("chalk"));
32
- const figures_1 = __importDefault(require("figures"));
33
- const path = __importStar(require("path"));
34
- const fs = __importStar(require("fs/promises"));
35
- // Helper function to check if file exists
36
- async function fileExists(filePath) {
37
- try {
38
- await fs.access(filePath);
39
- return true;
40
- }
41
- catch (_a) {
42
- return false;
43
- }
44
- }
45
- // Helper function to determine build configuration
46
- async function getBuildConfig(filePath, outputDir, showInfo) {
47
- const ext = path.extname(filePath).toLowerCase();
48
- const absolutePath = path.resolve(process.cwd(), filePath);
49
- const fileName = path.basename(filePath, ext);
50
- const outputPath = path.resolve(process.cwd(), outputDir);
51
- // Check if file exists
52
- if (!(await fileExists(absolutePath))) {
53
- throw new Error(`File not found: ${filePath}`);
54
- }
55
- if (showInfo) {
56
- console.log(chalk_1.default.blue(`${figures_1.default.info} neex build: Analyzing ${chalk_1.default.cyan(path.basename(filePath))}`));
57
- }
58
- switch (ext) {
59
- case '.ts':
60
- case '.mts':
61
- case '.cts':
62
- if (showInfo) {
63
- console.log(chalk_1.default.green(`${figures_1.default.tick} neex build: TypeScript detected, compiling to JavaScript`));
64
- }
65
- return {
66
- inputFile: absolutePath,
67
- outputFile: path.join(outputPath, `${fileName}.js`),
68
- buildCommand: `npx tsc ${filePath} --outDir ${outputDir} --target es2020 --module commonjs --moduleResolution node --esModuleInterop --allowSyntheticDefaultImports --strict --skipLibCheck`,
69
- buildType: 'typescript'
70
- };
71
- case '.js':
72
- case '.mjs':
73
- case '.cjs':
74
- if (showInfo) {
75
- console.log(chalk_1.default.green(`${figures_1.default.tick} neex build: JavaScript detected, copying to output directory`));
76
- }
77
- return {
78
- inputFile: absolutePath,
79
- outputFile: path.join(outputPath, path.basename(filePath)),
80
- buildCommand: `cp ${filePath} ${path.join(outputDir, path.basename(filePath))}`,
81
- buildType: 'copy'
82
- };
83
- default:
84
- if (showInfo) {
85
- console.log(chalk_1.default.yellow(`${figures_1.default.warning} neex build: Unknown file type, copying as-is`));
86
- }
87
- return {
88
- inputFile: absolutePath,
89
- outputFile: path.join(outputPath, path.basename(filePath)),
90
- buildCommand: `cp ${filePath} ${path.join(outputDir, path.basename(filePath))}`,
91
- buildType: 'copy'
92
- };
93
- }
94
- }
95
10
  function addBuildCommands(program) {
96
11
  let buildManager = null;
97
- // Build command - compile TypeScript/JavaScript projects
12
+ // Build command for TypeScript projects
98
13
  program
99
- .command('build <file>') // Made file mandatory
100
- .alias('b')
101
- .description('Build TypeScript/JavaScript files for production')
14
+ .command('build [source]')
15
+ .description('Build TypeScript project for production (default: src)')
102
16
  .option('-o, --output <dir>', 'Output directory', 'dist')
103
- .option('-c, --no-color', 'Disable colored output')
104
- .option('-t, --no-timing', 'Hide timing information')
105
- .option('-p, --no-prefix', 'Hide command prefix')
106
- .option('-s, --stop-on-error', 'Stop on first error')
107
- .option('-m, --minimal', 'Use minimal output format')
108
- .option('-w, --watch', 'Watch for changes and rebuild')
109
- .option('-i, --ignore <patterns...>', 'Patterns to ignore when watching')
110
- .option('-d, --delay <ms>', 'Delay before rebuild in milliseconds', parseInt)
111
- .option('--clean', 'Clean output directory before build')
112
- .option('--verbose', 'Verbose output')
113
- .option('--info', 'Show detailed build information')
114
- .option('--source-map', 'Generate source maps')
115
- .option('--target <target>', 'Target ECMAScript version', 'es2020')
116
- .option('--module <module>', 'Module system', 'commonjs')
117
- .action(async (file, options) => {
17
+ .option('-w, --watch', 'Watch mode for continuous building')
18
+ .option('-c, --clean', 'Clean output directory before build')
19
+ .option('-m, --minify', 'Minify output')
20
+ .option('-s, --sourcemap', 'Generate source maps')
21
+ .option('-t, --target <target>', 'TypeScript target (es2020, es2022, etc.)', 'es2020')
22
+ .option('-f, --format <format>', 'Output format (cjs, esm)', 'cjs')
23
+ .option('--no-bundle', 'Don\'t bundle, just compile')
24
+ .option('--external <packages>', 'External packages (comma-separated)')
25
+ .option('--tsconfig <file>', 'TypeScript config file', 'tsconfig.json')
26
+ .option('-v, --verbose', 'Verbose output')
27
+ .option('-q, --quiet', 'Quiet output')
28
+ .option('--no-color', 'Disable colored output')
29
+ .option('--analyze', 'Analyze bundle size')
30
+ .action(async (source, options) => {
118
31
  try {
119
- const showInfo = options.info || options.verbose || false;
120
- // Validate file parameter
121
- if (!file || file.trim() === '') {
122
- console.error(chalk_1.default.red(`${figures_1.default.cross} neex build: Error - No file specified!`));
123
- console.error(chalk_1.default.yellow(`${figures_1.default.pointer} Usage: neex build <file>`));
124
- console.error(chalk_1.default.yellow(`${figures_1.default.pointer} Example: neex build src/server.ts`));
125
- process.exit(1);
126
- }
127
- // Get build configuration
128
- const buildConfig = await getBuildConfig(file, options.output, showInfo);
129
- // Create BuildManager instance with clean output settings
32
+ const sourceDir = source || 'src';
33
+ logger_manager_js_1.loggerManager.printLine(`Building TypeScript project from ${chalk_1.default.cyan(sourceDir)}`, 'info');
130
34
  buildManager = new build_manager_js_1.BuildManager({
131
- runnerName: 'neex build',
132
- inputFile: file,
133
- outputDir: options.output,
134
- buildType: buildConfig.buildType,
135
- buildCommand: buildConfig.buildCommand,
136
- showInfo: showInfo,
137
- color: !options.noColor,
138
- showTiming: false,
35
+ source: sourceDir,
36
+ output: options.output,
139
37
  watch: options.watch,
140
- delay: parseInt(options.delay) || 1000,
141
- verbose: options.verbose,
142
38
  clean: options.clean,
143
- sourceMap: options.sourceMap,
39
+ minify: options.minify,
40
+ sourcemap: options.sourcemap,
144
41
  target: options.target,
145
- module: options.module,
146
- parallel: false,
147
- groupOutput: false,
148
- isServerMode: false,
149
- printOutput: false,
150
- prefix: false,
151
- stopOnError: true,
152
- minimalOutput: true // Use minimal output
42
+ format: options.format,
43
+ bundle: options.bundle,
44
+ external: options.external ? options.external.split(',').map((p) => p.trim()) : [],
45
+ tsconfig: options.tsconfig,
46
+ verbose: options.verbose,
47
+ quiet: options.quiet,
48
+ color: options.color,
49
+ analyze: options.analyze
153
50
  });
154
- // Start the build process
155
- try {
156
- await buildManager.start();
157
- // Only show success message, no extra logs
158
- console.log(chalk_1.default.green(`${figures_1.default.tick} Build completed`));
159
- }
160
- catch (error) {
161
- // Only show error message, no extra logs
162
- console.error(chalk_1.default.red(`${figures_1.default.cross} Build failed`));
163
- if (error instanceof Error) {
164
- console.error(chalk_1.default.red(`Error: ${error.message}`));
165
- }
166
- process.exit(1);
167
- }
51
+ await buildManager.build();
168
52
  }
169
53
  catch (error) {
170
- // Only show fatal error, no extra logs
171
- console.error(chalk_1.default.red(`${figures_1.default.cross} Build failed`));
172
54
  if (error instanceof Error) {
173
- console.error(chalk_1.default.red(`Error: ${error.message}`));
174
- if (options.verbose && error.stack) {
175
- console.error(chalk_1.default.gray(`Stack trace:\n${error.stack}`));
176
- }
55
+ logger_manager_js_1.loggerManager.printLine(`Build error: ${error.message}`, 'error');
56
+ }
57
+ else {
58
+ logger_manager_js_1.loggerManager.printLine('An unknown build error occurred', 'error');
177
59
  }
178
60
  process.exit(1);
179
61
  }
180
62
  });
181
- // Return cleanup function for build manager
182
- return {
183
- getBuildManager: () => buildManager,
184
- cleanupBuild: () => {
185
- if (buildManager && buildManager.isActive()) {
186
- buildManager.stop();
187
- }
63
+ // Cleanup function
64
+ const cleanupBuild = () => {
65
+ if (buildManager) {
66
+ buildManager.stop();
67
+ buildManager = null;
188
68
  }
189
69
  };
70
+ return { cleanupBuild };
190
71
  }
191
72
  exports.addBuildCommands = addBuildCommands;
@@ -27,181 +27,146 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
27
27
  };
28
28
  Object.defineProperty(exports, "__esModule", { value: true });
29
29
  exports.addDevCommands = void 0;
30
- const dev_runner_js_1 = require("../dev-runner.js");
30
+ const dev_manager_js_1 = require("../dev-manager.js");
31
+ const logger_manager_js_1 = require("../logger-manager.js");
31
32
  const chalk_1 = __importDefault(require("chalk"));
32
- const figures_1 = __importDefault(require("figures"));
33
- const path = __importStar(require("path"));
34
- const fs = __importStar(require("fs/promises"));
35
- // Helper function to check if file exists
36
- async function fileExists(filePath) {
33
+ // Helper function to run the development server
34
+ async function runDevServer(file, options) {
37
35
  try {
38
- await fs.access(filePath);
39
- return true;
40
- }
41
- catch (_a) {
42
- return false;
43
- }
44
- }
45
- // Helper function to determine the best command to run the file
46
- async function getBestCommand(filePath, showInfo) {
47
- const ext = path.extname(filePath).toLowerCase();
48
- const absolutePath = path.resolve(process.cwd(), filePath);
49
- // Check if file exists
50
- if (!(await fileExists(absolutePath))) {
51
- throw new Error(`File not found: ${filePath}`);
52
- }
53
- if (showInfo) {
54
- console.log(chalk_1.default.blue(`${figures_1.default.info} neex dev: Analyzing ${chalk_1.default.cyan(path.basename(filePath))}`));
55
- }
56
- switch (ext) {
57
- case '.ts':
58
- case '.mts':
59
- case '.cts':
60
- if (showInfo) {
61
- console.log(chalk_1.default.green(`${figures_1.default.tick} neex dev: TypeScript detected, ready to run`));
36
+ let targetFile = file || 'src/index.ts';
37
+ logger_manager_js_1.loggerManager.printLine(`Starting development server for ${chalk_1.default.cyan(targetFile)}`, 'info');
38
+ // Check if file exists and suggest alternatives
39
+ const fs = await Promise.resolve().then(() => __importStar(require('fs')));
40
+ if (!fs.existsSync(targetFile)) {
41
+ // Try common alternatives
42
+ const alternatives = [
43
+ 'src/index.js',
44
+ 'src/app.ts',
45
+ 'src/app.js',
46
+ 'src/server.ts',
47
+ 'src/server.js',
48
+ 'index.ts',
49
+ 'index.js',
50
+ 'app.ts',
51
+ 'app.js',
52
+ 'server.ts',
53
+ 'server.js'
54
+ ];
55
+ let found = false;
56
+ for (const alt of alternatives) {
57
+ if (fs.existsSync(alt)) {
58
+ logger_manager_js_1.loggerManager.printLine(`File ${targetFile} not found. Using ${alt} instead.`, 'warn');
59
+ targetFile = alt;
60
+ found = true;
61
+ break;
62
+ }
63
+ }
64
+ if (!found) {
65
+ logger_manager_js_1.loggerManager.printLine(`File ${targetFile} not found. Common alternatives also not found.`, 'error');
66
+ logger_manager_js_1.loggerManager.printLine(`Please specify the correct file path or create ${targetFile}`, 'error');
67
+ process.exit(1);
62
68
  }
63
- return `npx ts-node ${filePath}`;
64
- case '.js':
65
- case '.mjs':
66
- case '.cjs':
67
- if (showInfo) {
68
- console.log(chalk_1.default.green(`${figures_1.default.tick} neex dev: JavaScript detected, ready to run`));
69
+ }
70
+ const devManager = new dev_manager_js_1.DevManager({
71
+ file: targetFile,
72
+ watch: options.watch.split(',').map((p) => p.trim()),
73
+ ignore: options.ignore.split(',').map((p) => p.trim()),
74
+ extensions: options.ext.split(',').map((e) => e.trim()),
75
+ delay: options.delay,
76
+ color: options.color,
77
+ quiet: options.quiet,
78
+ verbose: options.verbose,
79
+ clearConsole: options.clear,
80
+ inspect: options.inspect,
81
+ inspectBrk: options.inspectBrk,
82
+ envFile: options.env,
83
+ execCommand: options.exec,
84
+ useTypeScript: options.typescript
85
+ });
86
+ await devManager.start();
87
+ return devManager; // Return for cleanup
88
+ }
89
+ catch (error) {
90
+ if (error instanceof Error) {
91
+ logger_manager_js_1.loggerManager.printLine(`Development server error: ${error.message}`, 'error');
92
+ // Provide helpful suggestions based on error type
93
+ if (error.message.includes('TypeScript execution not available')) {
94
+ logger_manager_js_1.loggerManager.printLine('', 'info');
95
+ logger_manager_js_1.loggerManager.printLine('To run TypeScript files, install one of the following:', 'info');
96
+ logger_manager_js_1.loggerManager.printLine(' npm install --save-dev tsx', 'info');
97
+ logger_manager_js_1.loggerManager.printLine(' npm install --save-dev ts-node', 'info');
98
+ logger_manager_js_1.loggerManager.printLine('', 'info');
99
+ logger_manager_js_1.loggerManager.printLine('Or use --exec to specify a custom command:', 'info');
100
+ logger_manager_js_1.loggerManager.printLine(' neex dev --exec "bun run" src/server.ts', 'info');
69
101
  }
70
- return `node ${filePath}`;
71
- default:
72
- if (showInfo) {
73
- console.log(chalk_1.default.yellow(`${figures_1.default.warning} neex dev: Unknown file type, using Node.js`));
102
+ else if (error.message.includes('ENOENT')) {
103
+ logger_manager_js_1.loggerManager.printLine('', 'info');
104
+ logger_manager_js_1.loggerManager.printLine('Make sure the required runtime is installed and in PATH', 'info');
74
105
  }
75
- return `node ${filePath}`;
106
+ }
107
+ else {
108
+ logger_manager_js_1.loggerManager.printLine('An unknown development server error occurred', 'error');
109
+ }
110
+ process.exit(1);
76
111
  }
77
112
  }
78
113
  function addDevCommands(program) {
79
- let devRunner = null;
80
- // Dev command - file watching and auto-restart like nodemon/ts-node-dev
114
+ let devManager = null;
115
+ // Dev command for hot reloading development
81
116
  program
82
- .command('dev <file>') // Made file mandatory
83
- .alias('d')
84
- .description('Run TypeScript/JavaScript files with file watching and auto-restart (like nodemon/ts-node-dev but better)')
117
+ .command('dev [file]')
118
+ .description('Start development server with hot reloading (default: src/index.ts)')
119
+ .option('-w, --watch <patterns>', 'Watch additional patterns (comma-separated)', 'src/**/*')
120
+ .option('-i, --ignore <patterns>', 'Ignore patterns (comma-separated)', 'node_modules,dist,build,.git')
121
+ .option('-e, --ext <extensions>', 'File extensions to watch (comma-separated)', 'ts,js,json')
122
+ .option('-d, --delay <ms>', 'Delay before restart (ms)', parseInt, 1000)
85
123
  .option('-c, --no-color', 'Disable colored output')
86
- .option('-t, --no-timing', 'Hide timing information')
87
- .option('-p, --no-prefix', 'Hide command prefix')
88
- .option('-s, --stop-on-error', 'Stop on first error')
89
- .option('-o, --no-output', 'Hide command output')
90
- .option('-m, --minimal', 'Use minimal output format')
91
- .option('-w, --watch <paths...>', 'Additional paths to watch (default: current directory)')
92
- .option('-i, --ignore <patterns...>', 'Patterns to ignore')
93
- .option('-e, --ext <extensions...>', 'File extensions to watch (default: js,mjs,json,ts,tsx,jsx)')
94
- .option('-d, --delay <ms>', 'Delay before restart in milliseconds', parseInt)
95
- .option('--clear', 'Clear console on restart')
96
- .option('--verbose', 'Verbose output')
97
- .option('--info', 'Show detailed information during startup')
98
- .option('--signal <signal>', 'Signal to send to processes on restart', 'SIGTERM')
124
+ .option('-q, --quiet', 'Reduce output verbosity')
125
+ .option('-v, --verbose', 'Verbose output')
126
+ .option('--no-clear', 'Don\'t clear console on restart')
127
+ .option('--inspect', 'Enable Node.js inspector')
128
+ .option('--inspect-brk', 'Enable Node.js inspector with break')
129
+ .option('--env <file>', 'Load environment variables from file', '.env')
130
+ .option('--exec <command>', 'Command to execute instead of auto-detection')
131
+ .option('--typescript', 'Force TypeScript mode')
99
132
  .action(async (file, options) => {
100
- try {
101
- const showInfo = options.info || false;
102
- if (showInfo) {
103
- console.log(chalk_1.default.blue(`${figures_1.default.info} neex dev: Starting enhanced development server...`));
104
- console.log(chalk_1.default.blue(`${figures_1.default.info} neex dev: Target file: ${chalk_1.default.cyan(file)}`));
105
- }
106
- // Validate file parameter
107
- if (!file || file.trim() === '') {
108
- console.error(chalk_1.default.red(`${figures_1.default.cross} neex dev: Error - No file specified!`));
109
- console.error(chalk_1.default.yellow(`${figures_1.default.pointer} Usage: neex dev <file>`));
110
- console.error(chalk_1.default.yellow(`${figures_1.default.pointer} Example: neex dev src/server.ts`));
111
- process.exit(1);
112
- }
113
- // Get the best command to run the file
114
- let commandToExecute;
115
- let fileExtension;
116
- try {
117
- commandToExecute = await getBestCommand(file, showInfo);
118
- fileExtension = path.extname(file).toLowerCase();
119
- }
120
- catch (error) {
121
- console.error(chalk_1.default.red(`${figures_1.default.cross} neex dev: ${error instanceof Error ? error.message : 'Unknown error occurred'}`));
122
- process.exit(1);
123
- }
124
- // Setup watch configuration
125
- const watchPaths = options.watch ? [...options.watch, './'] : ['./'];
126
- const ignorePatterns = options.ignore || [
127
- 'node_modules/**',
128
- '.git/**',
129
- '*.log',
130
- 'dist/**',
131
- 'build/**',
132
- 'coverage/**',
133
- '.nyc_output/**',
134
- '*.tmp',
135
- '*.temp',
136
- '.DS_Store',
137
- 'Thumbs.db'
138
- ];
139
- const extensions = options.ext || ['js', 'mjs', 'json', 'ts', 'tsx', 'jsx', 'vue', 'svelte'];
140
- // Log configuration only if --info flag is set
141
- if (showInfo) {
142
- console.log(chalk_1.default.blue(`${figures_1.default.info} neex dev: Configuration:`));
143
- console.log(chalk_1.default.blue(` ${figures_1.default.arrowRight} Target: ${chalk_1.default.cyan(file)}`));
144
- console.log(chalk_1.default.blue(` ${figures_1.default.arrowRight} Runtime: ${chalk_1.default.cyan(fileExtension === '.ts' || fileExtension === '.mts' || fileExtension === '.cts' ? 'TypeScript' : 'JavaScript')}`));
145
- console.log(chalk_1.default.blue(` ${figures_1.default.arrowRight} Watch paths: ${chalk_1.default.cyan(watchPaths.join(', '))}`));
146
- console.log(chalk_1.default.blue(` ${figures_1.default.arrowRight} Extensions: ${chalk_1.default.cyan(extensions.join(', '))}`));
147
- console.log(chalk_1.default.blue(` ${figures_1.default.arrowRight} Restart delay: ${chalk_1.default.cyan(options.delay || 1000)}ms`));
148
- console.log(chalk_1.default.blue(` ${figures_1.default.arrowRight} Clear console: ${chalk_1.default.cyan(options.clear ? 'Yes' : 'No')}`));
149
- if (options.verbose) {
150
- console.log(chalk_1.default.blue(`${figures_1.default.info} neex dev: Verbose mode enabled - showing detailed logs`));
151
- }
152
- console.log(chalk_1.default.green(`${figures_1.default.tick} neex dev: Starting file watcher and process manager...`));
153
- console.log(chalk_1.default.green(`${figures_1.default.tick} neex dev: Launching ${chalk_1.default.cyan(path.basename(file))} with auto-restart capability...`));
154
- console.log(chalk_1.default.blue(`${figures_1.default.info} neex dev: Press Ctrl+C to stop the development server`));
155
- console.log(chalk_1.default.gray(`${'='.repeat(60)}`));
156
- }
157
- // Create DevRunner instance
158
- devRunner = new dev_runner_js_1.DevRunner({
159
- runnerName: 'neex dev',
160
- parallel: false,
161
- color: options.color,
162
- showTiming: options.timing,
163
- prefix: options.prefix,
164
- stopOnError: options.stopOnError,
165
- printOutput: options.output,
166
- minimalOutput: options.minimal,
167
- watch: watchPaths,
168
- ignore: ignorePatterns,
169
- ext: extensions,
170
- delay: options.delay || 1000,
171
- clearConsole: options.clear,
172
- verbose: options.verbose,
173
- showInfo: showInfo,
174
- signal: options.signal,
175
- restartOnChange: true,
176
- groupOutput: false,
177
- isServerMode: false
178
- });
179
- // Start the development server
180
- await devRunner.start([commandToExecute]);
181
- }
182
- catch (error) {
183
- console.error(chalk_1.default.red(`${figures_1.default.cross} neex dev: Fatal error occurred`));
184
- if (error instanceof Error) {
185
- console.error(chalk_1.default.red(`${figures_1.default.cross} Details: ${error.message}`));
186
- if (options.verbose && error.stack) {
187
- console.error(chalk_1.default.gray(`Stack trace:\n${error.stack}`));
188
- }
189
- }
190
- else {
191
- console.error(chalk_1.default.red(`${figures_1.default.cross} Unknown error occurred`));
192
- }
193
- console.error(chalk_1.default.yellow(`${figures_1.default.pointer} Try running with --verbose flag for more details`));
194
- process.exit(1);
195
- }
133
+ devManager = await runDevServer(file, options);
196
134
  });
197
- // Return cleanup function for dev runner
198
- return {
199
- getDevRunner: () => devRunner,
200
- cleanupDev: () => {
201
- if (devRunner && devRunner.isActive()) {
202
- devRunner.stop();
203
- }
135
+ // Add a convenience command for TypeScript projects
136
+ program
137
+ .command('dev:ts [file]')
138
+ .description('Start development server with TypeScript support')
139
+ .option('-w, --watch <patterns>', 'Watch additional patterns (comma-separated)', 'src/**/*')
140
+ .option('-i, --ignore <patterns>', 'Ignore patterns (comma-separated)', 'node_modules,dist,build,.git')
141
+ .option('-d, --delay <ms>', 'Delay before restart (ms)', parseInt, 1000)
142
+ .option('-q, --quiet', 'Reduce output verbosity')
143
+ .option('-v, --verbose', 'Verbose output')
144
+ .option('--env <file>', 'Load environment variables from file', '.env')
145
+ .action(async (file, options) => {
146
+ // Call the main dev command with TypeScript forced
147
+ const newOptions = {
148
+ ...options,
149
+ typescript: true,
150
+ color: true,
151
+ clear: true,
152
+ // Set defaults for options that might not be present in the dev:ts command
153
+ watch: options.watch || 'src/**/*',
154
+ ignore: options.ignore || 'node_modules,dist,build,.git',
155
+ ext: options.ext || 'ts,js,json',
156
+ delay: options.delay || 1000,
157
+ inspect: options.inspect || false,
158
+ inspectBrk: options.inspectBrk || false,
159
+ exec: options.exec || undefined
160
+ };
161
+ devManager = await runDevServer(file, newOptions);
162
+ });
163
+ // Cleanup function
164
+ const cleanupDev = () => {
165
+ if (devManager) {
166
+ devManager.stop();
167
+ devManager = null;
204
168
  }
205
169
  };
170
+ return { cleanupDev };
206
171
  }
207
172
  exports.addDevCommands = addDevCommands;