neex 0.5.9 → 0.6.0

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/README.md CHANGED
@@ -6,7 +6,7 @@
6
6
  </picture>
7
7
  </a>
8
8
 
9
- # Neex v0.5.7
9
+ # Neex v0.6.0
10
10
 
11
11
  ### 🚀 Neex: The Modern Build System for Polyrepo-in-Monorepo Architecture
12
12
 
@@ -32,119 +32,111 @@ 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/promises"));
35
- // Helper function to find default command from package.json
36
- async function findDefaultCommand() {
37
- var _a, _b;
35
+ // Helper function to check if file exists
36
+ async function fileExists(filePath) {
38
37
  try {
39
- const packageJsonPath = path.join(process.cwd(), 'package.json');
40
- await fs.access(packageJsonPath);
41
- const packageJsonContent = await fs.readFile(packageJsonPath, 'utf-8');
42
- const packageJson = JSON.parse(packageJsonContent);
43
- if ((_a = packageJson.scripts) === null || _a === void 0 ? void 0 : _a.dev) {
44
- console.log(chalk_1.default.blue(`${figures_1.default.info} No command provided. Using "dev" script from package.json: npm run dev`));
45
- return 'npm run dev';
46
- }
47
- if ((_b = packageJson.scripts) === null || _b === void 0 ? void 0 : _b.start) {
48
- console.log(chalk_1.default.blue(`${figures_1.default.info} No command provided. Using "start" script from package.json: npm run start`));
49
- return 'npm run start';
50
- }
51
- if (packageJson.main) {
52
- const mainFile = packageJson.main;
53
- const mainFilePath = path.resolve(process.cwd(), mainFile);
54
- try {
55
- await fs.access(mainFilePath);
56
- if (mainFile.endsWith('.ts') || mainFile.endsWith('.mts') || mainFile.endsWith('.cts')) {
57
- console.log(chalk_1.default.blue(`${figures_1.default.info} No command or script found. Using "main" field (TypeScript): neex dev ${mainFile}`));
58
- return `npx ts-node ${mainFile}`;
59
- }
60
- else {
61
- console.log(chalk_1.default.blue(`${figures_1.default.info} No command or script found. Using "main" field (JavaScript): node ${mainFile}`));
62
- return `node ${mainFile}`;
63
- }
64
- }
65
- catch (e) {
66
- // Main file doesn't exist, do nothing, will fall through to return null
67
- }
68
- }
69
- return null;
38
+ await fs.access(filePath);
39
+ return true;
40
+ }
41
+ catch (_a) {
42
+ return false;
70
43
  }
71
- catch (error) {
72
- // package.json doesn't exist or other error, do nothing
73
- return null;
44
+ }
45
+ // Helper function to determine the best command to run the file
46
+ async function getBestCommand(filePath) {
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
+ console.log(chalk_1.default.blue(`${figures_1.default.info} neex dev: Analyzing file type for ${chalk_1.default.cyan(filePath)}`));
54
+ switch (ext) {
55
+ case '.ts':
56
+ case '.mts':
57
+ case '.cts':
58
+ console.log(chalk_1.default.green(`${figures_1.default.tick} neex dev: Detected TypeScript file, using ts-node for execution`));
59
+ return `npx ts-node ${filePath}`;
60
+ case '.js':
61
+ case '.mjs':
62
+ case '.cjs':
63
+ console.log(chalk_1.default.green(`${figures_1.default.tick} neex dev: Detected JavaScript file, using node for execution`));
64
+ return `node ${filePath}`;
65
+ default:
66
+ console.log(chalk_1.default.yellow(`${figures_1.default.warning} neex dev: Unknown file extension ${ext}, attempting to run with node`));
67
+ return `node ${filePath}`;
74
68
  }
75
69
  }
76
70
  function addDevCommands(program) {
77
71
  let devRunner = null;
78
- // Dev command (Nodemon functionality - formerly watch)
72
+ // Dev command - file watching and auto-restart like nodemon/ts-node-dev
79
73
  program
80
- .command('dev [commands...]') // Made commands optional
74
+ .command('dev <file>') // Made file mandatory
81
75
  .alias('d')
82
- .description('Run commands with file watching and auto-restart (nodemon functionality)')
76
+ .description('Run TypeScript/JavaScript files with file watching and auto-restart (like nodemon/ts-node-dev but better)')
83
77
  .option('-c, --no-color', 'Disable colored output')
84
78
  .option('-t, --no-timing', 'Hide timing information')
85
79
  .option('-p, --no-prefix', 'Hide command prefix')
86
80
  .option('-s, --stop-on-error', 'Stop on first error')
87
81
  .option('-o, --no-output', 'Hide command output')
88
82
  .option('-m, --minimal', 'Use minimal output format')
89
- .option('-w, --watch <paths...>', 'Paths to watch (default: current directory)')
83
+ .option('-w, --watch <paths...>', 'Additional paths to watch (default: current directory)')
90
84
  .option('-i, --ignore <patterns...>', 'Patterns to ignore')
91
85
  .option('-e, --ext <extensions...>', 'File extensions to watch (default: js,mjs,json,ts,tsx,jsx)')
92
86
  .option('-d, --delay <ms>', 'Delay before restart in milliseconds', parseInt)
93
87
  .option('--clear', 'Clear console on restart')
94
88
  .option('--verbose', 'Verbose output')
95
89
  .option('--signal <signal>', 'Signal to send to processes on restart', 'SIGTERM')
96
- .action(async (commands, options) => {
90
+ .action(async (file, options) => {
97
91
  try {
98
- let effectiveCommands = commands;
99
- if (!effectiveCommands || effectiveCommands.length === 0) {
100
- const foundCommand = await findDefaultCommand();
101
- if (foundCommand) {
102
- effectiveCommands = [foundCommand];
103
- console.log(chalk_1.default.blue(`${figures_1.default.info} No command specified for 'neex dev', using default: "${foundCommand}"`));
104
- }
105
- else {
106
- console.error(chalk_1.default.red(`${figures_1.default.cross} No command specified for 'neex dev' and no default script (dev, start) or main file found in package.json.`));
107
- console.error(chalk_1.default.yellow(`${figures_1.default.pointer} Please specify a command to run (e.g., neex dev "npm run dev") or define a "dev" or "start" script in your package.json.`));
108
- process.exit(1);
109
- }
92
+ console.log(chalk_1.default.blue(`${figures_1.default.info} neex dev: Starting enhanced development server...`));
93
+ console.log(chalk_1.default.blue(`${figures_1.default.info} neex dev: Target file: ${chalk_1.default.cyan(file)}`));
94
+ // Validate file parameter
95
+ if (!file || file.trim() === '') {
96
+ console.error(chalk_1.default.red(`${figures_1.default.cross} neex dev: Error - No file specified!`));
97
+ console.error(chalk_1.default.yellow(`${figures_1.default.pointer} Usage: neex dev <file>`));
98
+ console.error(chalk_1.default.yellow(`${figures_1.default.pointer} Example: neex dev src/server.ts`));
99
+ process.exit(1);
110
100
  }
111
- else { // At least one command/argument is provided
112
- const firstArg = effectiveCommands[0];
113
- const remainingArgs = effectiveCommands.slice(1);
114
- const isLikelyCommandOrScript = firstArg.includes(' ') || firstArg.startsWith('npm') || firstArg.startsWith('yarn') || firstArg.startsWith('pnpm');
115
- if (!isLikelyCommandOrScript) {
116
- const filePath = path.resolve(process.cwd(), firstArg);
117
- try {
118
- await fs.access(filePath); // Check if file exists
119
- let commandToExecute = '';
120
- if (firstArg.endsWith('.js') || firstArg.endsWith('.mjs') || firstArg.endsWith('.cjs')) {
121
- commandToExecute = `node ${firstArg}`;
122
- console.log(chalk_1.default.blue(`${figures_1.default.info} Detected .js file, prepending with node.`));
123
- }
124
- else if (firstArg.endsWith('.ts') || firstArg.endsWith('.mts') || firstArg.endsWith('.cts')) {
125
- commandToExecute = `neex dev ${firstArg}`;
126
- console.log(chalk_1.default.blue(`${figures_1.default.info} Detected .ts file, prepending with neex dev.`));
127
- }
128
- if (commandToExecute) {
129
- effectiveCommands = [commandToExecute, ...remainingArgs];
130
- console.log(chalk_1.default.cyan(`${figures_1.default.pointer} Executing: ${effectiveCommands.join(' ')}`));
131
- }
132
- else {
133
- console.log(chalk_1.default.yellow(`${figures_1.default.warning} First argument "${firstArg}" is not a recognized .js/.ts file and doesn't look like a script. Attempting to run as is.`));
134
- }
135
- }
136
- catch (e) {
137
- console.log(chalk_1.default.yellow(`${figures_1.default.warning} File "${firstArg}" not found. Attempting to run as command.`));
138
- }
139
- }
101
+ // Get the best command to run the file
102
+ let commandToExecute;
103
+ try {
104
+ commandToExecute = await getBestCommand(file);
105
+ }
106
+ catch (error) {
107
+ console.error(chalk_1.default.red(`${figures_1.default.cross} neex dev: ${error instanceof Error ? error.message : 'Unknown error occurred'}`));
108
+ process.exit(1);
140
109
  }
141
- console.log(chalk_1.default.blue(`${figures_1.default.info} Starting development server with file watching (neex dev) for command(s): ${effectiveCommands.map(cmd => `"${cmd}"`).join(' && ')}...`));
142
- const watchPaths = options.watch || ['./'];
110
+ // Setup watch configuration
111
+ const watchPaths = options.watch ? [...options.watch, './'] : ['./'];
143
112
  const ignorePatterns = options.ignore || [
144
- 'node_modules/**', '.git/**', '*.log', 'dist/**', 'build/**',
145
- 'coverage/**', '.nyc_output/**', '*.tmp', '*.temp'
113
+ 'node_modules/**',
114
+ '.git/**',
115
+ '*.log',
116
+ 'dist/**',
117
+ 'build/**',
118
+ 'coverage/**',
119
+ '.nyc_output/**',
120
+ '*.tmp',
121
+ '*.temp',
122
+ '.DS_Store',
123
+ 'Thumbs.db'
146
124
  ];
147
- const extensions = options.ext || ['js', 'mjs', 'json', 'ts', 'tsx', 'jsx'];
125
+ const extensions = options.ext || ['js', 'mjs', 'json', 'ts', 'tsx', 'jsx', 'vue', 'svelte'];
126
+ // Log configuration
127
+ console.log(chalk_1.default.blue(`${figures_1.default.info} neex dev: Configuration:`));
128
+ console.log(chalk_1.default.blue(` ${figures_1.default.arrowRight} Command: ${chalk_1.default.cyan(commandToExecute)}`));
129
+ console.log(chalk_1.default.blue(` ${figures_1.default.arrowRight} Watch paths: ${chalk_1.default.cyan(watchPaths.join(', '))}`));
130
+ console.log(chalk_1.default.blue(` ${figures_1.default.arrowRight} Extensions: ${chalk_1.default.cyan(extensions.join(', '))}`));
131
+ console.log(chalk_1.default.blue(` ${figures_1.default.arrowRight} Ignore patterns: ${chalk_1.default.cyan(ignorePatterns.length)} patterns`));
132
+ console.log(chalk_1.default.blue(` ${figures_1.default.arrowRight} Restart delay: ${chalk_1.default.cyan(options.delay || 1000)}ms`));
133
+ console.log(chalk_1.default.blue(` ${figures_1.default.arrowRight} Clear console: ${chalk_1.default.cyan(options.clear ? 'Yes' : 'No')}`));
134
+ console.log(chalk_1.default.blue(` ${figures_1.default.arrowRight} Signal: ${chalk_1.default.cyan(options.signal)}`));
135
+ if (options.verbose) {
136
+ console.log(chalk_1.default.blue(`${figures_1.default.info} neex dev: Verbose mode enabled - showing detailed logs`));
137
+ }
138
+ console.log(chalk_1.default.green(`${figures_1.default.tick} neex dev: Starting file watcher and process manager...`));
139
+ // Create DevRunner instance
148
140
  devRunner = new dev_runner_js_1.DevRunner({
149
141
  runnerName: 'neex dev',
150
142
  parallel: false,
@@ -165,15 +157,24 @@ function addDevCommands(program) {
165
157
  groupOutput: false,
166
158
  isServerMode: false
167
159
  });
168
- await devRunner.start(effectiveCommands);
160
+ // Start the development server
161
+ console.log(chalk_1.default.green(`${figures_1.default.tick} neex dev: Launching ${chalk_1.default.cyan(path.basename(file))} with auto-restart capability...`));
162
+ console.log(chalk_1.default.blue(`${figures_1.default.info} neex dev: Press Ctrl+C to stop the development server`));
163
+ console.log(chalk_1.default.gray(`${'='.repeat(60)}`));
164
+ await devRunner.start([commandToExecute]);
169
165
  }
170
166
  catch (error) {
167
+ console.error(chalk_1.default.red(`${figures_1.default.cross} neex dev: Fatal error occurred`));
171
168
  if (error instanceof Error) {
172
- console.error(chalk_1.default.red(`${figures_1.default.cross} Dev Error: ${error.message}`));
169
+ console.error(chalk_1.default.red(`${figures_1.default.cross} Details: ${error.message}`));
170
+ if (options.verbose && error.stack) {
171
+ console.error(chalk_1.default.gray(`Stack trace:\n${error.stack}`));
172
+ }
173
173
  }
174
174
  else {
175
- console.error(chalk_1.default.red(`${figures_1.default.cross} An unknown dev error occurred`));
175
+ console.error(chalk_1.default.red(`${figures_1.default.cross} Unknown error occurred`));
176
176
  }
177
+ console.error(chalk_1.default.yellow(`${figures_1.default.pointer} Try running with --verbose flag for more details`));
177
178
  process.exit(1);
178
179
  }
179
180
  });
@@ -182,7 +183,9 @@ function addDevCommands(program) {
182
183
  getDevRunner: () => devRunner,
183
184
  cleanupDev: () => {
184
185
  if (devRunner && devRunner.isActive()) {
186
+ console.log(chalk_1.default.blue(`${figures_1.default.info} neex dev: Stopping development server...`));
185
187
  devRunner.stop();
188
+ console.log(chalk_1.default.green(`${figures_1.default.tick} neex dev: Development server stopped successfully`));
186
189
  }
187
190
  }
188
191
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "neex",
3
- "version": "0.5.9",
3
+ "version": "0.6.0",
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",