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