neex 0.6.12 → 0.6.14

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')
@@ -58,7 +58,7 @@ class DevRunner {
58
58
  ignore: this.options.ignore,
59
59
  ext: this.options.ext,
60
60
  delay: this.options.delay,
61
- verbose: false // Always hide watcher logs
61
+ verbose: false // Always set to false to hide watcher logs
62
62
  };
63
63
  this.fileWatcher = new watcher_1.FileWatcher(watchOptions);
64
64
  this.fileWatcher.on('change', (event) => {
@@ -80,9 +80,16 @@ class DevRunner {
80
80
  // Create a modified options object for the runner to clean up output
81
81
  const runnerOptions = {
82
82
  ...this.options,
83
- // Override prefix behavior to show "neex dev" instead of full command
83
+ // Override prefix behavior to show clean command name
84
84
  customPrefix: (command) => {
85
- return 'neex dev'; // Always show "neex dev" as prefix
85
+ // Extract just the filename from the command
86
+ const match = command.match(/(?:npx ts-node|node)\s+(.+)/);
87
+ if (match) {
88
+ const filePath = match[1];
89
+ const fileName = filePath.split('/').pop() || filePath;
90
+ return `${fileName}`;
91
+ }
92
+ return command;
86
93
  }
87
94
  };
88
95
  this.runner = new runner_1.Runner(runnerOptions);
@@ -98,8 +105,24 @@ class DevRunner {
98
105
  }
99
106
  }
100
107
  printDevBanner() {
101
- // Don't show any banner info - keep it completely clean
102
- return;
108
+ var _a, _b, _c;
109
+ if (!this.options.showInfo) {
110
+ return; // Don't show banner if showInfo is false
111
+ }
112
+ const prefix = chalk_1.default.cyan(`[${this.options.runnerName}]`);
113
+ const uptime = Math.floor((Date.now() - this.startTime.getTime()) / 1000);
114
+ const uptimeStr = this.formatUptime(uptime);
115
+ if (this.options.showInfo) {
116
+ console.log(chalk_1.default.blue(`${prefix} ${figures_1.default.info} Starting file watcher...`));
117
+ console.log(chalk_1.default.blue(`${prefix} ${figures_1.default.info} File watcher started. Monitoring ${((_a = this.options.watch) === null || _a === void 0 ? void 0 : _a.length) || 1} locations`));
118
+ console.log(chalk_1.default.blue(`${prefix} ${figures_1.default.info} Watching extensions: ${((_b = this.options.ext) === null || _b === void 0 ? void 0 : _b.join(', ')) || 'js, mjs, json, ts, tsx, jsx, vue, svelte'}`));
119
+ console.log(chalk_1.default.blue(`${prefix} ${figures_1.default.info} Uptime: ${uptimeStr}`));
120
+ console.log(chalk_1.default.blue(`${prefix} ${figures_1.default.info} Watching: ${((_c = this.options.watch) === null || _c === void 0 ? void 0 : _c.join(', ')) || 'current directory'}`));
121
+ if (this.restartCount > 0) {
122
+ console.log(chalk_1.default.blue(`${prefix} ${figures_1.default.info} Restarted ${this.restartCount} times`));
123
+ }
124
+ console.log('');
125
+ }
103
126
  }
104
127
  formatUptime(seconds) {
105
128
  if (seconds < 60) {
@@ -122,20 +145,33 @@ class DevRunner {
122
145
  this.startTime = new Date();
123
146
  // Setup file watcher
124
147
  this.setupFileWatcher();
125
- // Don't print any development banner
148
+ // Print development banner only if showInfo is true
149
+ this.printDevBanner();
126
150
  // Start file watcher
127
151
  if (this.fileWatcher) {
128
152
  await this.fileWatcher.start();
129
153
  }
130
154
  // Run initial commands
155
+ const prefix = chalk_1.default.cyan(`[${this.options.runnerName}]`);
156
+ if (this.options.showInfo) {
157
+ logger_1.default.printLine(`${prefix} Starting development server...`, 'info');
158
+ }
131
159
  await this.runCommands();
132
160
  // Set up graceful shutdown
133
161
  this.setupGracefulShutdown();
162
+ if (this.options.showInfo) {
163
+ logger_1.default.printLine(`${prefix} Development server started. Watching for changes...`, 'info');
164
+ logger_1.default.printLine(`${prefix} Press ${chalk_1.default.cyan('Ctrl+C')} to stop`, 'info');
165
+ }
134
166
  }
135
167
  async restart() {
168
+ const prefix = chalk_1.default.cyan(`[${this.options.runnerName}]`);
136
169
  if (!this.isRunning) {
137
170
  return;
138
171
  }
172
+ if (this.options.showInfo) {
173
+ logger_1.default.printLine(`${prefix} Restarting due to file changes...`, 'info');
174
+ }
139
175
  this.restartCount++;
140
176
  // Stop current processes
141
177
  if (this.runner) {
@@ -143,13 +179,22 @@ class DevRunner {
143
179
  }
144
180
  // Wait a moment before restarting
145
181
  await new Promise(resolve => setTimeout(resolve, 500));
182
+ // Print restart banner only if showInfo is true
183
+ this.printDevBanner();
146
184
  // Run commands again
147
185
  await this.runCommands();
186
+ if (this.options.showInfo) {
187
+ logger_1.default.printLine(`${prefix} Restart completed. Watching for changes...`, 'info');
188
+ }
148
189
  }
149
190
  async stop() {
191
+ const prefix = chalk_1.default.cyan(`[${this.options.runnerName}]`);
150
192
  if (!this.isRunning) {
151
193
  return;
152
194
  }
195
+ if (this.options.showInfo) {
196
+ logger_1.default.printLine(`${prefix} Stopping development server...`, 'info');
197
+ }
153
198
  this.isRunning = false;
154
199
  // Stop file watcher
155
200
  if (this.fileWatcher) {
@@ -162,9 +207,9 @@ class DevRunner {
162
207
  const uptime = Math.floor((Date.now() - this.startTime.getTime()) / 1000);
163
208
  const uptimeStr = this.formatUptime(uptime);
164
209
  if (this.options.showInfo) {
165
- logger_1.default.printLine(`${this.options.runnerName} development server stopped after ${uptimeStr}`, 'info');
210
+ logger_1.default.printLine(`${prefix} ${this.options.runnerName} development server stopped after ${uptimeStr}`, 'info');
166
211
  if (this.restartCount > 0) {
167
- logger_1.default.printLine(`Total restarts: ${this.restartCount}`, 'info');
212
+ logger_1.default.printLine(`${prefix} Total restarts: ${this.restartCount}`, 'info');
168
213
  }
169
214
  }
170
215
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "neex",
3
- "version": "0.6.12",
3
+ "version": "0.6.14",
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",