neex 0.6.12 → 0.6.13

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.
@@ -97,7 +97,6 @@ function addDevCommands(program) {
97
97
  .action(async (file, options) => {
98
98
  try {
99
99
  const devRunner = new dev_runner_js_1.DevRunner({
100
- showInfo: false,
101
100
  watch: options.watch,
102
101
  ignore: options.ignore,
103
102
  ext: options.ext,
@@ -111,9 +110,11 @@ function addDevCommands(program) {
111
110
  showTiming: true,
112
111
  prefix: true,
113
112
  stopOnError: false,
114
- minimalOutput: false,
113
+ minimalOutput: options.minimal,
115
114
  groupOutput: false,
116
- isServerMode: false
115
+ isServerMode: false,
116
+ restartOnChange: true,
117
+ verbose: false
117
118
  });
118
119
  devRunner.start([await getBestCommand(file, false)]);
119
120
  }
@@ -32,6 +32,7 @@ const chalk_1 = __importDefault(require("chalk"));
32
32
  const figures_1 = __importDefault(require("figures"));
33
33
  const path = __importStar(require("path"));
34
34
  const fs = __importStar(require("fs"));
35
+ const fs_1 = require("fs");
35
36
  // Helper function to format uptime
36
37
  function formatUptime(seconds) {
37
38
  if (seconds < 60) {
@@ -90,6 +91,8 @@ function addProcessCommands(program) {
90
91
  .option('--error <path>', 'Error log file path')
91
92
  .option('--time', 'Prefix logs with timestamp')
92
93
  .option('--merge-logs', 'Merge logs and errors')
94
+ .option('--typescript', 'Script is TypeScript (will use ts-node)')
95
+ .option('--build-dir <dir>', 'Build directory for TypeScript projects', 'dist')
93
96
  .action(async (script, options) => {
94
97
  try {
95
98
  const pm = await getOrCreateProcessManager();
@@ -99,6 +102,9 @@ function addProcessCommands(program) {
99
102
  console.error(chalk_1.default.red(`${figures_1.default.cross} Script file not found: ${scriptPath}`));
100
103
  process.exit(1);
101
104
  }
105
+ // If TypeScript flag is set, use ts-node
106
+ const interpreter = options.typescript ? 'ts-node' : options.interpreter || 'node';
107
+ const interpreterArgs = options.typescript ? ['--project', 'tsconfig.json'] : options.interpreterArgs ? options.interpreterArgs.split(' ') : undefined;
102
108
  const config = {
103
109
  id: '',
104
110
  name: options.name || path.basename(script, path.extname(script)),
@@ -112,8 +118,8 @@ function addProcessCommands(program) {
112
118
  watch: options.watch || false,
113
119
  ignore_watch: options.ignoreWatch,
114
120
  max_memory_restart: options.maxMemory,
115
- interpreter: options.interpreter,
116
- interpreter_args: options.interpreterArgs ? options.interpreterArgs.split(' ') : undefined,
121
+ interpreter,
122
+ interpreter_args: interpreterArgs,
117
123
  log_file: options.log,
118
124
  error_file: options.error,
119
125
  out_file: options.log,
@@ -125,6 +131,7 @@ function addProcessCommands(program) {
125
131
  console.log(chalk_1.default.blue(`${figures_1.default.info} Process ID: ${id}`));
126
132
  console.log(chalk_1.default.blue(`${figures_1.default.info} Process Name: ${config.name}`));
127
133
  console.log(chalk_1.default.blue(`${figures_1.default.info} Script: ${scriptPath}`));
134
+ console.log(chalk_1.default.blue(`${figures_1.default.info} Interpreter: ${interpreter}`));
128
135
  }
129
136
  catch (error) {
130
137
  if (error instanceof Error) {
@@ -613,6 +620,79 @@ function addProcessCommands(program) {
613
620
  process.exit(1);
614
621
  }
615
622
  });
623
+ // Build command - Compile TypeScript project
624
+ program
625
+ .command('build <entry>')
626
+ .description('Build TypeScript project from entry point')
627
+ .option('-o, --out <dir>', 'Output directory', 'dist')
628
+ .option('--tsconfig <path>', 'Path to tsconfig.json', 'tsconfig.json')
629
+ .option('--watch', 'Watch for changes and rebuild')
630
+ .action(async (entry, options) => {
631
+ try {
632
+ const entryPath = path.resolve(entry);
633
+ const tsConfigPath = path.resolve(options.tsconfig);
634
+ const outDir = path.resolve(options.out);
635
+ // Check if entry file exists
636
+ if (!fs.existsSync(entryPath)) {
637
+ console.error(chalk_1.default.red(`${figures_1.default.cross} Entry point not found: ${entryPath}`));
638
+ process.exit(1);
639
+ }
640
+ // Check if tsconfig exists
641
+ if (!fs.existsSync(tsConfigPath)) {
642
+ console.error(chalk_1.default.red(`${figures_1.default.cross} tsconfig.json not found at: ${tsConfigPath}`));
643
+ process.exit(1);
644
+ }
645
+ // Create output directory if it doesn't exist
646
+ if (!fs.existsSync(outDir)) {
647
+ fs.mkdirSync(outDir, { recursive: true });
648
+ }
649
+ // Read tsconfig
650
+ const tsConfig = JSON.parse(await fs_1.promises.readFile(tsConfigPath, 'utf8'));
651
+ // Update tsconfig with entry point
652
+ tsConfig.files = [entryPath];
653
+ // Write temporary tsconfig
654
+ const tempTsConfigPath = path.join(process.cwd(), '.neex.tsconfig.json');
655
+ await fs_1.promises.writeFile(tempTsConfigPath, JSON.stringify(tsConfig, null, 2));
656
+ console.log(chalk_1.default.blue(`${figures_1.default.info} Building TypeScript project...`));
657
+ console.log(chalk_1.default.blue(`${figures_1.default.info} Entry Point: ${entryPath}`));
658
+ console.log(chalk_1.default.blue(`${figures_1.default.info} Output: ${outDir}`));
659
+ console.log(chalk_1.default.blue(`${figures_1.default.info} Using tsconfig: ${tempTsConfigPath}`));
660
+ // Run tsc command
661
+ const { spawn } = require('child_process');
662
+ const tsc = spawn('tsc', [
663
+ '--build',
664
+ '--project', tempTsConfigPath,
665
+ ...(options.watch ? ['--watch'] : [])
666
+ ], {
667
+ stdio: 'inherit',
668
+ cwd: process.cwd()
669
+ });
670
+ tsc.on('close', (code) => {
671
+ // Clean up temporary tsconfig
672
+ fs.unlink(tempTsConfigPath, (err) => {
673
+ if (err)
674
+ console.error('Error cleaning up temporary tsconfig:', err);
675
+ });
676
+ if (code === 0) {
677
+ console.log(chalk_1.default.green(`${figures_1.default.tick} Build completed successfully!`));
678
+ console.log(chalk_1.default.blue(`${figures_1.default.info} Output files in: ${outDir}`));
679
+ }
680
+ else {
681
+ console.error(chalk_1.default.red(`${figures_1.default.cross} Build failed with code ${code}`));
682
+ process.exit(1);
683
+ }
684
+ });
685
+ }
686
+ catch (error) {
687
+ if (error instanceof Error) {
688
+ console.error(chalk_1.default.red(`${figures_1.default.cross} Build Error: ${error.message}`));
689
+ }
690
+ else {
691
+ console.error(chalk_1.default.red(`${figures_1.default.cross} An unknown build error occurred`));
692
+ }
693
+ process.exit(1);
694
+ }
695
+ });
616
696
  // Startup command - راه‌اندازی خودکار هنگام بوت
617
697
  program
618
698
  .command('startup')
@@ -44,8 +44,7 @@ class DevRunner {
44
44
  ext: ['js', 'mjs', 'json', 'ts', 'tsx', 'jsx'],
45
45
  delay: 1000,
46
46
  verbose: false,
47
- showInfo: false,
48
- runnerName: 'neex dev',
47
+ runnerName: 'watch', // Default runner name if not specified
49
48
  };
50
49
  this.options = {
51
50
  ...defaultOptions,
@@ -58,7 +57,7 @@ class DevRunner {
58
57
  ignore: this.options.ignore,
59
58
  ext: this.options.ext,
60
59
  delay: this.options.delay,
61
- verbose: false // Always hide watcher logs
60
+ verbose: this.options.verbose
62
61
  };
63
62
  this.fileWatcher = new watcher_1.FileWatcher(watchOptions);
64
63
  this.fileWatcher.on('change', (event) => {
@@ -68,6 +67,8 @@ class DevRunner {
68
67
  });
69
68
  }
70
69
  async handleFileChange(event) {
70
+ const prefix = chalk_1.default.cyan(`[${this.options.runnerName}]`);
71
+ logger_1.default.printLine(`${prefix} File changed: ${chalk_1.default.yellow(event.relativePath)}`, 'info');
71
72
  if (this.options.clearConsole) {
72
73
  console.clear();
73
74
  }
@@ -77,29 +78,31 @@ class DevRunner {
77
78
  if (this.commands.length === 0) {
78
79
  return [];
79
80
  }
80
- // Create a modified options object for the runner to clean up output
81
- const runnerOptions = {
82
- ...this.options,
83
- // Override prefix behavior to show "neex dev" instead of full command
84
- customPrefix: (command) => {
85
- return 'neex dev'; // Always show "neex dev" as prefix
86
- }
87
- };
88
- this.runner = new runner_1.Runner(runnerOptions);
81
+ this.runner = new runner_1.Runner(this.options);
89
82
  try {
90
83
  const results = await this.runner.run(this.commands);
91
84
  return results;
92
85
  }
93
86
  catch (error) {
94
- if (this.options.showInfo) {
95
- logger_1.default.printLine(`Execution failed: ${error.message}`, 'error');
96
- }
87
+ logger_1.default.printLine(`Execution failed: ${error.message}`, 'error');
97
88
  return [];
98
89
  }
99
90
  }
100
91
  printDevBanner() {
101
- // Don't show any banner info - keep it completely clean
102
- return;
92
+ var _a, _b;
93
+ const prefix = chalk_1.default.cyan(`[${this.options.runnerName}]`);
94
+ const uptime = Math.floor((Date.now() - this.startTime.getTime()) / 1000);
95
+ const uptimeStr = this.formatUptime(uptime);
96
+ console.log('\n' + chalk_1.default.bgGreen.black(` ${(_a = this.options.runnerName) === null || _a === void 0 ? void 0 : _a.toUpperCase()} MODE `) + '\n');
97
+ if (this.restartCount > 0) {
98
+ console.log(`${prefix} ${chalk_1.default.green(`${figures_1.default.arrowUp} Restarted ${this.restartCount} times`)}`);
99
+ }
100
+ console.log(`${prefix} ${chalk_1.default.blue(`${figures_1.default.info} Uptime: ${uptimeStr}`)}`);
101
+ console.log(`${prefix} ${chalk_1.default.blue(`${figures_1.default.info} Watching: ${((_b = this.options.watch) === null || _b === void 0 ? void 0 : _b.join(', ')) || 'current directory'}`)}`);
102
+ if (this.options.ext && this.options.ext.length > 0) {
103
+ console.log(`${prefix} ${chalk_1.default.blue(`${figures_1.default.info} Extensions: ${this.options.ext.join(', ')}`)}`);
104
+ }
105
+ console.log('');
103
106
  }
104
107
  formatUptime(seconds) {
105
108
  if (seconds < 60) {
@@ -122,20 +125,27 @@ class DevRunner {
122
125
  this.startTime = new Date();
123
126
  // Setup file watcher
124
127
  this.setupFileWatcher();
125
- // Don't print any development banner
128
+ // Print development banner
129
+ this.printDevBanner();
126
130
  // Start file watcher
127
131
  if (this.fileWatcher) {
128
132
  await this.fileWatcher.start();
129
133
  }
130
134
  // Run initial commands
135
+ const prefix = chalk_1.default.cyan(`[${this.options.runnerName}]`);
136
+ logger_1.default.printLine(`${prefix} Starting development server...`, 'info');
131
137
  await this.runCommands();
132
138
  // Set up graceful shutdown
133
139
  this.setupGracefulShutdown();
140
+ logger_1.default.printLine(`${prefix} Development server started. Watching for changes...`, 'info');
141
+ logger_1.default.printLine(`${prefix} Press ${chalk_1.default.cyan('Ctrl+C')} to stop`, 'info');
134
142
  }
135
143
  async restart() {
144
+ const prefix = chalk_1.default.cyan(`[${this.options.runnerName}]`);
136
145
  if (!this.isRunning) {
137
146
  return;
138
147
  }
148
+ logger_1.default.printLine(`${prefix} Restarting due to file changes...`, 'info');
139
149
  this.restartCount++;
140
150
  // Stop current processes
141
151
  if (this.runner) {
@@ -143,13 +153,18 @@ class DevRunner {
143
153
  }
144
154
  // Wait a moment before restarting
145
155
  await new Promise(resolve => setTimeout(resolve, 500));
156
+ // Print restart banner
157
+ this.printDevBanner();
146
158
  // Run commands again
147
159
  await this.runCommands();
160
+ logger_1.default.printLine(`${prefix} Restart completed. Watching for changes...`, 'info');
148
161
  }
149
162
  async stop() {
163
+ const prefix = chalk_1.default.cyan(`[${this.options.runnerName}]`);
150
164
  if (!this.isRunning) {
151
165
  return;
152
166
  }
167
+ logger_1.default.printLine(`${prefix} Stopping development server...`, 'info');
153
168
  this.isRunning = false;
154
169
  // Stop file watcher
155
170
  if (this.fileWatcher) {
@@ -161,18 +176,14 @@ class DevRunner {
161
176
  }
162
177
  const uptime = Math.floor((Date.now() - this.startTime.getTime()) / 1000);
163
178
  const uptimeStr = this.formatUptime(uptime);
164
- if (this.options.showInfo) {
165
- logger_1.default.printLine(`${this.options.runnerName} development server stopped after ${uptimeStr}`, 'info');
166
- if (this.restartCount > 0) {
167
- logger_1.default.printLine(`Total restarts: ${this.restartCount}`, 'info');
168
- }
179
+ logger_1.default.printLine(`${prefix} ${this.options.runnerName} development server stopped after ${uptimeStr}`, 'info');
180
+ if (this.restartCount > 0) {
181
+ logger_1.default.printLine(`${prefix} Total restarts: ${this.restartCount}`, 'info');
169
182
  }
170
183
  }
171
184
  setupGracefulShutdown() {
172
185
  const handleSignal = (signal) => {
173
- if (this.options.showInfo) {
174
- console.log(`\n${chalk_1.default.yellow(`${figures_1.default.warning} Received ${signal}. Shutting down development server...`)}`);
175
- }
186
+ console.log(`\n${chalk_1.default.yellow(`${figures_1.default.warning} Received ${signal}. Shutting down development server...`)}`);
176
187
  this.stop().then(() => {
177
188
  process.exit(0);
178
189
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "neex",
3
- "version": "0.6.12",
3
+ "version": "0.6.13",
4
4
  "description": "The Modern Build System for Polyrepo-in-Monorepo Architecture",
5
5
  "main": "dist/src/index.js",
6
6
  "types": "dist/src/index.d.ts",