neex 0.6.44 → 0.6.46

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;
@@ -1,207 +1,68 @@
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.addDevCommands = void 0;
30
- const dev_runner_js_1 = require("../dev-runner.js");
7
+ const dev_manager_js_1 = require("../dev-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 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`));
62
- }
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
- 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`));
74
- }
75
- return `node ${filePath}`;
76
- }
77
- }
78
10
  function addDevCommands(program) {
79
- let devRunner = null;
80
- // Dev command - file watching and auto-restart like nodemon/ts-node-dev
11
+ let devManager = null;
12
+ // Dev command for hot reloading development
81
13
  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)')
14
+ .command('dev [file]')
15
+ .description('Start development server with hot reloading (default: src/index.ts)')
16
+ .option('-w, --watch <patterns>', 'Watch additional patterns (comma-separated)', 'src/**/*')
17
+ .option('-i, --ignore <patterns>', 'Ignore patterns (comma-separated)', 'node_modules,dist,build,.git')
18
+ .option('-e, --ext <extensions>', 'File extensions to watch (comma-separated)', 'ts,js,json')
19
+ .option('-d, --delay <ms>', 'Delay before restart (ms)', parseInt, 1000)
85
20
  .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')
21
+ .option('-q, --quiet', 'Reduce output verbosity')
22
+ .option('-v, --verbose', 'Verbose output')
23
+ .option('--no-clear', 'Don\'t clear console on restart')
24
+ .option('--inspect', 'Enable Node.js inspector')
25
+ .option('--inspect-brk', 'Enable Node.js inspector with break')
26
+ .option('--env <file>', 'Load environment variables from file', '.env')
27
+ .option('--exec <command>', 'Command to execute instead of tsx')
99
28
  .action(async (file, options) => {
100
29
  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,
30
+ const targetFile = file || 'src/index.ts';
31
+ logger_manager_js_1.loggerManager.printLine(`Starting development server for ${chalk_1.default.cyan(targetFile)}`, 'info');
32
+ devManager = new dev_manager_js_1.DevManager({
33
+ file: targetFile,
34
+ watch: options.watch.split(',').map((p) => p.trim()),
35
+ ignore: options.ignore.split(',').map((p) => p.trim()),
36
+ extensions: options.ext.split(',').map((e) => e.trim()),
37
+ delay: options.delay,
161
38
  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,
39
+ quiet: options.quiet,
172
40
  verbose: options.verbose,
173
- showInfo: showInfo,
174
- signal: options.signal,
175
- restartOnChange: true,
176
- groupOutput: false,
177
- isServerMode: false
41
+ clearConsole: options.clear,
42
+ inspect: options.inspect,
43
+ inspectBrk: options.inspectBrk,
44
+ envFile: options.env,
45
+ execCommand: options.exec
178
46
  });
179
- // Start the development server
180
- await devRunner.start([commandToExecute]);
47
+ await devManager.start();
181
48
  }
182
49
  catch (error) {
183
- console.error(chalk_1.default.red(`${figures_1.default.cross} neex dev: Fatal error occurred`));
184
50
  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
- }
51
+ logger_manager_js_1.loggerManager.printLine(`Development server error: ${error.message}`, 'error');
189
52
  }
190
53
  else {
191
- console.error(chalk_1.default.red(`${figures_1.default.cross} Unknown error occurred`));
54
+ logger_manager_js_1.loggerManager.printLine('An unknown development server error occurred', 'error');
192
55
  }
193
- console.error(chalk_1.default.yellow(`${figures_1.default.pointer} Try running with --verbose flag for more details`));
194
56
  process.exit(1);
195
57
  }
196
58
  });
197
- // Return cleanup function for dev runner
198
- return {
199
- getDevRunner: () => devRunner,
200
- cleanupDev: () => {
201
- if (devRunner && devRunner.isActive()) {
202
- devRunner.stop();
203
- }
59
+ // Cleanup function
60
+ const cleanupDev = () => {
61
+ if (devManager) {
62
+ devManager.stop();
63
+ devManager = null;
204
64
  }
205
65
  };
66
+ return { cleanupDev };
206
67
  }
207
68
  exports.addDevCommands = addDevCommands;