neex 0.1.8 → 0.2.5

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,190 +0,0 @@
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
- var __importDefault = (this && this.__importDefault) || function (mod) {
26
- return (mod && mod.__esModule) ? mod : { "default": mod };
27
- };
28
- Object.defineProperty(exports, "__esModule", { value: true });
29
- exports.addDevCommands = void 0;
30
- const dev_runner_js_1 = require("../dev-runner.js");
31
- 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 find default command from package.json
36
- async function findDefaultCommand() {
37
- var _a, _b;
38
- 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): npx ts-node ${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;
70
- }
71
- catch (error) {
72
- // package.json doesn't exist or other error, do nothing
73
- return null;
74
- }
75
- }
76
- function addDevCommands(program) {
77
- let devRunner = null;
78
- // Dev command (Nodemon functionality - formerly watch)
79
- program
80
- .command('dev [commands...]') // Made commands optional
81
- .alias('d')
82
- .description('Run commands with file watching and auto-restart (nodemon functionality)')
83
- .option('-c, --no-color', 'Disable colored output')
84
- .option('-t, --no-timing', 'Hide timing information')
85
- .option('-p, --no-prefix', 'Hide command prefix')
86
- .option('-s, --stop-on-error', 'Stop on first error')
87
- .option('-o, --no-output', 'Hide command output')
88
- .option('-m, --minimal', 'Use minimal output format')
89
- .option('-w, --watch <paths...>', 'Paths to watch (default: current directory)')
90
- .option('-i, --ignore <patterns...>', 'Patterns to ignore')
91
- .option('-e, --ext <extensions...>', 'File extensions to watch (default: js,mjs,json,ts,tsx,jsx)')
92
- .option('-d, --delay <ms>', 'Delay before restart in milliseconds', parseInt)
93
- .option('--clear', 'Clear console on restart')
94
- .option('--verbose', 'Verbose output')
95
- .option('--signal <signal>', 'Signal to send to processes on restart', 'SIGTERM')
96
- .action(async (commands, options) => {
97
- 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
- }
110
- }
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 = `npx ts-node ${firstArg}`;
126
- console.log(chalk_1.default.blue(`${figures_1.default.info} Detected .ts file, prepending with npx ts-node.`));
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
- }
140
- }
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 || ['./'];
143
- const ignorePatterns = options.ignore || [
144
- 'node_modules/**', '.git/**', '*.log', 'dist/**', 'build/**',
145
- 'coverage/**', '.nyc_output/**', '*.tmp', '*.temp'
146
- ];
147
- const extensions = options.ext || ['js', 'mjs', 'json', 'ts', 'tsx', 'jsx'];
148
- devRunner = new dev_runner_js_1.DevRunner({
149
- runnerName: 'neex dev',
150
- parallel: false,
151
- color: options.color,
152
- showTiming: options.timing,
153
- prefix: options.prefix,
154
- stopOnError: options.stopOnError,
155
- printOutput: options.output,
156
- minimalOutput: options.minimal,
157
- watch: watchPaths,
158
- ignore: ignorePatterns,
159
- ext: extensions,
160
- delay: options.delay || 1000,
161
- clearConsole: options.clear,
162
- verbose: options.verbose,
163
- signal: options.signal,
164
- restartOnChange: true,
165
- groupOutput: false,
166
- isServerMode: false
167
- });
168
- await devRunner.start(effectiveCommands);
169
- }
170
- catch (error) {
171
- if (error instanceof Error) {
172
- console.error(chalk_1.default.red(`${figures_1.default.cross} Dev Error: ${error.message}`));
173
- }
174
- else {
175
- console.error(chalk_1.default.red(`${figures_1.default.cross} An unknown dev error occurred`));
176
- }
177
- process.exit(1);
178
- }
179
- });
180
- // Return cleanup function for dev runner
181
- return {
182
- getDevRunner: () => devRunner,
183
- cleanupDev: () => {
184
- if (devRunner && devRunner.isActive()) {
185
- devRunner.stop();
186
- }
187
- }
188
- };
189
- }
190
- exports.addDevCommands = addDevCommands;
@@ -1,21 +0,0 @@
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 __exportStar = (this && this.__exportStar) || function(m, exports) {
14
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
- };
16
- Object.defineProperty(exports, "__esModule", { value: true });
17
- // src/commands/index.ts - Export all commands
18
- __exportStar(require("./run-commands.js"), exports);
19
- __exportStar(require("./dev-commands.js"), exports);
20
- __exportStar(require("./process-commands"), exports);
21
- __exportStar(require("./server-commands.js"), exports);