neex 0.7.20 → 0.7.31
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 +13 -31
- package/dist/bin/neex.d.ts +26 -0
- package/dist/bin/neex.d.ts.map +1 -0
- package/dist/src/build-manager.d.ts +41 -0
- package/dist/src/build-manager.d.ts.map +1 -0
- package/dist/src/build-manager.js +26 -24
- package/dist/src/cli.d.ts +2 -0
- package/dist/src/cli.d.ts.map +1 -0
- package/dist/src/commands/build-commands.d.ts +5 -0
- package/dist/src/commands/build-commands.d.ts.map +1 -0
- package/dist/src/commands/build-commands.js +2 -2
- package/dist/src/commands/dev-commands.d.ts +5 -0
- package/dist/src/commands/dev-commands.d.ts.map +1 -0
- package/dist/src/commands/dev-commands.js +5 -3
- package/dist/src/commands/index.d.ts +7 -0
- package/dist/src/commands/index.d.ts.map +1 -0
- package/dist/src/commands/init-commands.d.ts +2 -0
- package/dist/src/commands/init-commands.d.ts.map +1 -0
- package/dist/src/commands/init-commands.js +4 -4
- package/dist/src/commands/run-commands.d.ts +3 -0
- package/dist/src/commands/run-commands.d.ts.map +1 -0
- package/dist/src/commands/run-commands.js +26 -26
- package/dist/src/commands/server-commands.d.ts +3 -0
- package/dist/src/commands/server-commands.d.ts.map +1 -0
- package/dist/src/commands/server-commands.js +4 -2
- package/dist/src/commands/start-commands.d.ts +5 -0
- package/dist/src/commands/start-commands.d.ts.map +1 -0
- package/dist/src/commands/start-commands.js +2 -2
- package/dist/src/dev-manager.d.ts +51 -0
- package/dist/src/dev-manager.d.ts.map +1 -0
- package/dist/src/dev-manager.js +29 -21
- package/dist/src/index.d.ts +41 -0
- package/dist/src/index.d.ts.map +1 -0
- package/dist/src/index.js +15 -16
- package/dist/src/logger-manager.d.ts +4 -0
- package/dist/src/logger-manager.d.ts.map +1 -0
- package/dist/src/logger-manager.js +4 -4
- package/dist/src/logger.d.ts +34 -0
- package/dist/src/logger.d.ts.map +1 -0
- package/dist/src/logger.js +21 -15
- package/dist/src/runner.d.ts +21 -0
- package/dist/src/runner.d.ts.map +1 -0
- package/dist/src/runner.js +38 -25
- package/dist/src/start-manager.d.ts +49 -0
- package/dist/src/start-manager.d.ts.map +1 -0
- package/dist/src/start-manager.js +34 -29
- package/dist/src/types.d.ts +41 -0
- package/dist/src/types.d.ts.map +1 -0
- package/dist/src/utils.d.ts +2 -0
- package/dist/src/utils.d.ts.map +1 -0
- package/package.json +14 -9
- package/dist/src/cli-init.js +0 -1
- package/dist/src/commands/process-commands.js +0 -759
- package/dist/src/config.js +0 -59
- package/dist/src/dev-runner.js +0 -234
- package/dist/src/logger-process.js +0 -17
- package/dist/src/process-manager.js +0 -669
- package/dist/src/watcher.js +0 -245
package/dist/src/watcher.js
DELETED
|
@@ -1,245 +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.FileWatcher = void 0;
|
|
30
|
-
// src/watcher.ts - File watcher for development (nodemon functionality)
|
|
31
|
-
const fs = __importStar(require("fs"));
|
|
32
|
-
const path = __importStar(require("path"));
|
|
33
|
-
const events_1 = require("events");
|
|
34
|
-
const chalk_1 = __importDefault(require("chalk"));
|
|
35
|
-
const logger_process_1 = require("./logger-process");
|
|
36
|
-
class FileWatcher extends events_1.EventEmitter {
|
|
37
|
-
constructor(options) {
|
|
38
|
-
super();
|
|
39
|
-
this.watchers = [];
|
|
40
|
-
this.watchedFiles = new Set();
|
|
41
|
-
this.debounceTimer = null;
|
|
42
|
-
this.isWatching = false;
|
|
43
|
-
this.ignorePatterns = [];
|
|
44
|
-
// Initialize with a copy of user-provided options.
|
|
45
|
-
const processedOptions = { ...options };
|
|
46
|
-
// Apply defaults if properties were not set in the provided 'options'.
|
|
47
|
-
if (processedOptions.watch === undefined) {
|
|
48
|
-
processedOptions.watch = ['./'];
|
|
49
|
-
}
|
|
50
|
-
if (processedOptions.ignore === undefined) {
|
|
51
|
-
processedOptions.ignore = [
|
|
52
|
-
'node_modules/**',
|
|
53
|
-
'.git/**',
|
|
54
|
-
'*.log',
|
|
55
|
-
'dist/**',
|
|
56
|
-
'build/**',
|
|
57
|
-
'coverage/**',
|
|
58
|
-
'.nyc_output/**',
|
|
59
|
-
'*.tmp',
|
|
60
|
-
'*.temp'
|
|
61
|
-
];
|
|
62
|
-
}
|
|
63
|
-
if (processedOptions.ext === undefined) {
|
|
64
|
-
processedOptions.ext = ['js', 'mjs', 'json', 'ts', 'tsx', 'jsx'];
|
|
65
|
-
}
|
|
66
|
-
if (processedOptions.delay === undefined) {
|
|
67
|
-
processedOptions.delay = 1000;
|
|
68
|
-
}
|
|
69
|
-
if (processedOptions.verbose === undefined) {
|
|
70
|
-
processedOptions.verbose = false;
|
|
71
|
-
}
|
|
72
|
-
if (processedOptions.legacyWatch === undefined) {
|
|
73
|
-
processedOptions.legacyWatch = false;
|
|
74
|
-
}
|
|
75
|
-
if (processedOptions.pollingInterval === undefined) {
|
|
76
|
-
processedOptions.pollingInterval = 1000;
|
|
77
|
-
}
|
|
78
|
-
// 'cwd' and 'env' are optional and don't have explicit defaults in this setup;
|
|
79
|
-
// they will be taken from 'options' or remain undefined if not provided.
|
|
80
|
-
this.options = processedOptions;
|
|
81
|
-
this.setupIgnorePatterns();
|
|
82
|
-
}
|
|
83
|
-
setupIgnorePatterns() {
|
|
84
|
-
this.ignorePatterns = (this.options.ignore || []).map(pattern => {
|
|
85
|
-
// Convert glob patterns to regex
|
|
86
|
-
const regexPattern = pattern
|
|
87
|
-
.replace(/\*\*/g, '.*')
|
|
88
|
-
.replace(/\*/g, '[^/]*')
|
|
89
|
-
.replace(/\?/g, '[^/]')
|
|
90
|
-
.replace(/\./g, '\\.');
|
|
91
|
-
return new RegExp(regexPattern, 'i');
|
|
92
|
-
});
|
|
93
|
-
}
|
|
94
|
-
shouldIgnoreFile(filePath) {
|
|
95
|
-
const relativePath = path.relative(process.cwd(), filePath);
|
|
96
|
-
// Check ignore patterns
|
|
97
|
-
for (const pattern of this.ignorePatterns) {
|
|
98
|
-
if (pattern.test(relativePath) || pattern.test(filePath)) {
|
|
99
|
-
return true;
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
// Check file extension
|
|
103
|
-
if (this.options.ext && this.options.ext.length > 0) {
|
|
104
|
-
const ext = path.extname(filePath).slice(1);
|
|
105
|
-
if (!this.options.ext.includes(ext)) {
|
|
106
|
-
return true;
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
return false;
|
|
110
|
-
}
|
|
111
|
-
async isValidFile(filePath) {
|
|
112
|
-
try {
|
|
113
|
-
const stats = await fs.promises.stat(filePath);
|
|
114
|
-
return stats.isFile();
|
|
115
|
-
}
|
|
116
|
-
catch (_a) {
|
|
117
|
-
return false;
|
|
118
|
-
}
|
|
119
|
-
}
|
|
120
|
-
async watchDirectory(dirPath) {
|
|
121
|
-
try {
|
|
122
|
-
const absolutePath = path.resolve(dirPath);
|
|
123
|
-
if (this.options.verbose) {
|
|
124
|
-
logger_process_1.logger.printLine(`Watching directory: ${chalk_1.default.cyan(absolutePath)}`, 'info');
|
|
125
|
-
}
|
|
126
|
-
const watcher = fs.watch(absolutePath, { recursive: true }, async (eventType, filename) => {
|
|
127
|
-
if (!filename)
|
|
128
|
-
return;
|
|
129
|
-
const fullPath = path.join(absolutePath, filename);
|
|
130
|
-
if (this.shouldIgnoreFile(fullPath)) {
|
|
131
|
-
return;
|
|
132
|
-
}
|
|
133
|
-
if (!(await this.isValidFile(fullPath))) {
|
|
134
|
-
return;
|
|
135
|
-
}
|
|
136
|
-
this.handleFileChange(fullPath, eventType);
|
|
137
|
-
});
|
|
138
|
-
this.watchers.push(watcher);
|
|
139
|
-
}
|
|
140
|
-
catch (error) {
|
|
141
|
-
if (this.options.verbose) {
|
|
142
|
-
logger_process_1.logger.printLine(`Failed to watch directory ${dirPath}: ${error.message}`, 'warn');
|
|
143
|
-
}
|
|
144
|
-
}
|
|
145
|
-
}
|
|
146
|
-
async watchFile(filePath) {
|
|
147
|
-
try {
|
|
148
|
-
const absolutePath = path.resolve(filePath);
|
|
149
|
-
if (this.shouldIgnoreFile(absolutePath)) {
|
|
150
|
-
return;
|
|
151
|
-
}
|
|
152
|
-
if (!(await this.isValidFile(absolutePath))) {
|
|
153
|
-
return;
|
|
154
|
-
}
|
|
155
|
-
if (this.options.verbose) {
|
|
156
|
-
logger_process_1.logger.printLine(`Watching file: ${chalk_1.default.cyan(absolutePath)}`, 'info');
|
|
157
|
-
}
|
|
158
|
-
const watcher = fs.watch(absolutePath, (eventType) => {
|
|
159
|
-
this.handleFileChange(absolutePath, eventType);
|
|
160
|
-
});
|
|
161
|
-
this.watchers.push(watcher);
|
|
162
|
-
this.watchedFiles.add(absolutePath);
|
|
163
|
-
}
|
|
164
|
-
catch (error) {
|
|
165
|
-
if (this.options.verbose) {
|
|
166
|
-
logger_process_1.logger.printLine(`Failed to watch file ${filePath}: ${error.message}`, 'warn');
|
|
167
|
-
}
|
|
168
|
-
}
|
|
169
|
-
}
|
|
170
|
-
handleFileChange(filePath, eventType) {
|
|
171
|
-
if (this.options.verbose) {
|
|
172
|
-
logger_process_1.logger.printLine(`File ${eventType}: ${chalk_1.default.yellow(path.relative(process.cwd(), filePath))}`, 'info');
|
|
173
|
-
}
|
|
174
|
-
// Debounce file changes
|
|
175
|
-
if (this.debounceTimer) {
|
|
176
|
-
clearTimeout(this.debounceTimer);
|
|
177
|
-
}
|
|
178
|
-
this.debounceTimer = setTimeout(() => {
|
|
179
|
-
this.emit('change', {
|
|
180
|
-
path: filePath,
|
|
181
|
-
event: eventType,
|
|
182
|
-
relativePath: path.relative(process.cwd(), filePath)
|
|
183
|
-
});
|
|
184
|
-
}, this.options.delay);
|
|
185
|
-
}
|
|
186
|
-
async start() {
|
|
187
|
-
if (this.isWatching) {
|
|
188
|
-
return;
|
|
189
|
-
}
|
|
190
|
-
this.isWatching = true;
|
|
191
|
-
logger_process_1.logger.printLine('Starting file watcher...', 'info');
|
|
192
|
-
for (const watchPath of this.options.watch) {
|
|
193
|
-
const absolutePath = path.resolve(watchPath);
|
|
194
|
-
try {
|
|
195
|
-
const stats = await fs.promises.stat(absolutePath);
|
|
196
|
-
if (stats.isDirectory()) {
|
|
197
|
-
await this.watchDirectory(absolutePath);
|
|
198
|
-
}
|
|
199
|
-
else if (stats.isFile()) {
|
|
200
|
-
await this.watchFile(absolutePath);
|
|
201
|
-
}
|
|
202
|
-
}
|
|
203
|
-
catch (error) {
|
|
204
|
-
logger_process_1.logger.printLine(`Cannot watch ${watchPath}: ${error.message}`, 'warn');
|
|
205
|
-
}
|
|
206
|
-
}
|
|
207
|
-
const watchedCount = this.watchers.length;
|
|
208
|
-
logger_process_1.logger.printLine(`File watcher started. Monitoring ${chalk_1.default.green(watchedCount)} locations`, 'info');
|
|
209
|
-
if (this.options.ext && this.options.ext.length > 0) {
|
|
210
|
-
logger_process_1.logger.printLine(`Watching extensions: ${chalk_1.default.cyan(this.options.ext.join(', '))}`, 'info');
|
|
211
|
-
}
|
|
212
|
-
}
|
|
213
|
-
stop() {
|
|
214
|
-
if (!this.isWatching) {
|
|
215
|
-
return;
|
|
216
|
-
}
|
|
217
|
-
logger_process_1.logger.printLine('Stopping file watcher...', 'info');
|
|
218
|
-
this.watchers.forEach(watcher => {
|
|
219
|
-
try {
|
|
220
|
-
watcher.close();
|
|
221
|
-
}
|
|
222
|
-
catch (error) {
|
|
223
|
-
// Ignore errors when closing watchers
|
|
224
|
-
}
|
|
225
|
-
});
|
|
226
|
-
this.watchers = [];
|
|
227
|
-
this.watchedFiles.clear();
|
|
228
|
-
this.isWatching = false;
|
|
229
|
-
if (this.debounceTimer) {
|
|
230
|
-
clearTimeout(this.debounceTimer);
|
|
231
|
-
this.debounceTimer = null;
|
|
232
|
-
}
|
|
233
|
-
logger_process_1.logger.printLine('File watcher stopped', 'info');
|
|
234
|
-
}
|
|
235
|
-
isActive() {
|
|
236
|
-
return this.isWatching;
|
|
237
|
-
}
|
|
238
|
-
getWatchedFiles() {
|
|
239
|
-
return Array.from(this.watchedFiles);
|
|
240
|
-
}
|
|
241
|
-
getOptions() {
|
|
242
|
-
return { ...this.options };
|
|
243
|
-
}
|
|
244
|
-
}
|
|
245
|
-
exports.FileWatcher = FileWatcher;
|