neex 0.5.7 → 0.5.9
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.
|
@@ -33,7 +33,7 @@ const figures_1 = __importDefault(require("figures"));
|
|
|
33
33
|
const path = __importStar(require("path"));
|
|
34
34
|
const fs = __importStar(require("fs/promises"));
|
|
35
35
|
// Helper function to find default command from package.json
|
|
36
|
-
async function findDefaultCommand(
|
|
36
|
+
async function findDefaultCommand() {
|
|
37
37
|
var _a, _b;
|
|
38
38
|
try {
|
|
39
39
|
const packageJsonPath = path.join(process.cwd(), 'package.json');
|
|
@@ -41,15 +41,11 @@ async function findDefaultCommand(verbose = false) {
|
|
|
41
41
|
const packageJsonContent = await fs.readFile(packageJsonPath, 'utf-8');
|
|
42
42
|
const packageJson = JSON.parse(packageJsonContent);
|
|
43
43
|
if ((_a = packageJson.scripts) === null || _a === void 0 ? void 0 : _a.dev) {
|
|
44
|
-
|
|
45
|
-
console.log(chalk_1.default.blue(`${figures_1.default.info} Using "dev" script from package.json: npm run dev`));
|
|
46
|
-
}
|
|
44
|
+
console.log(chalk_1.default.blue(`${figures_1.default.info} No command provided. Using "dev" script from package.json: npm run dev`));
|
|
47
45
|
return 'npm run dev';
|
|
48
46
|
}
|
|
49
47
|
if ((_b = packageJson.scripts) === null || _b === void 0 ? void 0 : _b.start) {
|
|
50
|
-
|
|
51
|
-
console.log(chalk_1.default.blue(`${figures_1.default.info} Using "start" script from package.json: npm run start`));
|
|
52
|
-
}
|
|
48
|
+
console.log(chalk_1.default.blue(`${figures_1.default.info} No command provided. Using "start" script from package.json: npm run start`));
|
|
53
49
|
return 'npm run start';
|
|
54
50
|
}
|
|
55
51
|
if (packageJson.main) {
|
|
@@ -58,26 +54,22 @@ async function findDefaultCommand(verbose = false) {
|
|
|
58
54
|
try {
|
|
59
55
|
await fs.access(mainFilePath);
|
|
60
56
|
if (mainFile.endsWith('.ts') || mainFile.endsWith('.mts') || mainFile.endsWith('.cts')) {
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
}
|
|
64
|
-
return `neex dev ${mainFile}`;
|
|
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}`;
|
|
65
59
|
}
|
|
66
60
|
else {
|
|
67
|
-
|
|
68
|
-
console.log(chalk_1.default.blue(`${figures_1.default.info} Using "main" field (JavaScript): node ${mainFile}`));
|
|
69
|
-
}
|
|
61
|
+
console.log(chalk_1.default.blue(`${figures_1.default.info} No command or script found. Using "main" field (JavaScript): node ${mainFile}`));
|
|
70
62
|
return `node ${mainFile}`;
|
|
71
63
|
}
|
|
72
64
|
}
|
|
73
65
|
catch (e) {
|
|
74
|
-
// Main file doesn't exist, do nothing
|
|
66
|
+
// Main file doesn't exist, do nothing, will fall through to return null
|
|
75
67
|
}
|
|
76
68
|
}
|
|
77
69
|
return null;
|
|
78
70
|
}
|
|
79
71
|
catch (error) {
|
|
80
|
-
// package.json doesn't exist or other error
|
|
72
|
+
// package.json doesn't exist or other error, do nothing
|
|
81
73
|
return null;
|
|
82
74
|
}
|
|
83
75
|
}
|
|
@@ -99,23 +91,20 @@ function addDevCommands(program) {
|
|
|
99
91
|
.option('-e, --ext <extensions...>', 'File extensions to watch (default: js,mjs,json,ts,tsx,jsx)')
|
|
100
92
|
.option('-d, --delay <ms>', 'Delay before restart in milliseconds', parseInt)
|
|
101
93
|
.option('--clear', 'Clear console on restart')
|
|
102
|
-
.option('--
|
|
94
|
+
.option('--verbose', 'Verbose output')
|
|
103
95
|
.option('--signal <signal>', 'Signal to send to processes on restart', 'SIGTERM')
|
|
104
96
|
.action(async (commands, options) => {
|
|
105
97
|
try {
|
|
106
|
-
const verbose = options.log;
|
|
107
98
|
let effectiveCommands = commands;
|
|
108
99
|
if (!effectiveCommands || effectiveCommands.length === 0) {
|
|
109
|
-
const foundCommand = await findDefaultCommand(
|
|
100
|
+
const foundCommand = await findDefaultCommand();
|
|
110
101
|
if (foundCommand) {
|
|
111
102
|
effectiveCommands = [foundCommand];
|
|
112
|
-
|
|
113
|
-
console.log(chalk_1.default.cyan(`${figures_1.default.play} neex dev`));
|
|
114
|
-
}
|
|
103
|
+
console.log(chalk_1.default.blue(`${figures_1.default.info} No command specified for 'neex dev', using default: "${foundCommand}"`));
|
|
115
104
|
}
|
|
116
105
|
else {
|
|
117
|
-
console.error(chalk_1.default.red(`${figures_1.default.cross} No command specified and no default script found.`));
|
|
118
|
-
console.error(chalk_1.default.yellow(`${figures_1.default.pointer}
|
|
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.`));
|
|
119
108
|
process.exit(1);
|
|
120
109
|
}
|
|
121
110
|
}
|
|
@@ -130,37 +119,26 @@ function addDevCommands(program) {
|
|
|
130
119
|
let commandToExecute = '';
|
|
131
120
|
if (firstArg.endsWith('.js') || firstArg.endsWith('.mjs') || firstArg.endsWith('.cjs')) {
|
|
132
121
|
commandToExecute = `node ${firstArg}`;
|
|
133
|
-
|
|
134
|
-
console.log(chalk_1.default.blue(`${figures_1.default.info} Detected .js file, using node.`));
|
|
135
|
-
}
|
|
122
|
+
console.log(chalk_1.default.blue(`${figures_1.default.info} Detected .js file, prepending with node.`));
|
|
136
123
|
}
|
|
137
124
|
else if (firstArg.endsWith('.ts') || firstArg.endsWith('.mts') || firstArg.endsWith('.cts')) {
|
|
138
|
-
commandToExecute = `
|
|
139
|
-
|
|
140
|
-
console.log(chalk_1.default.blue(`${figures_1.default.info} Detected .ts file, using node with ts-node loader.`));
|
|
141
|
-
}
|
|
125
|
+
commandToExecute = `neex dev ${firstArg}`;
|
|
126
|
+
console.log(chalk_1.default.blue(`${figures_1.default.info} Detected .ts file, prepending with neex dev.`));
|
|
142
127
|
}
|
|
143
128
|
if (commandToExecute) {
|
|
144
129
|
effectiveCommands = [commandToExecute, ...remainingArgs];
|
|
130
|
+
console.log(chalk_1.default.cyan(`${figures_1.default.pointer} Executing: ${effectiveCommands.join(' ')}`));
|
|
145
131
|
}
|
|
146
|
-
else
|
|
147
|
-
console.log(chalk_1.default.yellow(`${figures_1.default.warning}
|
|
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.`));
|
|
148
134
|
}
|
|
149
135
|
}
|
|
150
136
|
catch (e) {
|
|
151
|
-
|
|
152
|
-
console.log(chalk_1.default.yellow(`${figures_1.default.warning} File "${firstArg}" not found, running as command.`));
|
|
153
|
-
}
|
|
137
|
+
console.log(chalk_1.default.yellow(`${figures_1.default.warning} File "${firstArg}" not found. Attempting to run as command.`));
|
|
154
138
|
}
|
|
155
139
|
}
|
|
156
140
|
}
|
|
157
|
-
|
|
158
|
-
if (verbose) {
|
|
159
|
-
console.log(chalk_1.default.blue(`${figures_1.default.info} Starting file watcher for: ${effectiveCommands.map(cmd => `"${cmd}"`).join(' && ')}`));
|
|
160
|
-
}
|
|
161
|
-
else {
|
|
162
|
-
console.log(chalk_1.default.cyan(`${figures_1.default.play} neex dev`));
|
|
163
|
-
}
|
|
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(' && ')}...`));
|
|
164
142
|
const watchPaths = options.watch || ['./'];
|
|
165
143
|
const ignorePatterns = options.ignore || [
|
|
166
144
|
'node_modules/**', '.git/**', '*.log', 'dist/**', 'build/**',
|
|
@@ -181,7 +159,7 @@ function addDevCommands(program) {
|
|
|
181
159
|
ext: extensions,
|
|
182
160
|
delay: options.delay || 1000,
|
|
183
161
|
clearConsole: options.clear,
|
|
184
|
-
verbose: verbose,
|
|
162
|
+
verbose: options.verbose,
|
|
185
163
|
signal: options.signal,
|
|
186
164
|
restartOnChange: true,
|
|
187
165
|
groupOutput: false,
|