neex 0.4.6 → 0.5.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 +226 -39
- package/dist/src/cli.js +24 -13
- package/dist/src/commands/dev-commands.js +190 -0
- package/dist/src/commands/index.js +21 -0
- package/dist/src/commands/process-commands.js +679 -0
- package/dist/src/commands/run-commands.js +94 -0
- package/dist/src/commands/server-commands.js +50 -0
- package/dist/src/dev-runner.js +209 -0
- package/dist/src/index.js +3 -1
- package/dist/src/logger.js +36 -0
- package/dist/src/process-manager.js +669 -0
- package/dist/src/runner.js +112 -78
- package/dist/src/utils.js +10 -0
- package/dist/src/watcher.js +245 -0
- package/feet.txt +16 -0
- package/package.json +4 -4
- package/bun.lock +0 -621
- package/dist/src/commands/run-commands/run.js +0 -81
- package/dist/src/project-manager.js +0 -208
|
@@ -1,81 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.registerRunCommands = void 0;
|
|
7
|
-
const chalk_1 = __importDefault(require("chalk"));
|
|
8
|
-
const figures_1 = __importDefault(require("figures"));
|
|
9
|
-
const index_js_1 = require("../../index.js");
|
|
10
|
-
function registerRunCommands(program) {
|
|
11
|
-
// Sequential execution command
|
|
12
|
-
program
|
|
13
|
-
.command('sequential <commands...>')
|
|
14
|
-
.alias('s')
|
|
15
|
-
.description('Run commands sequentially')
|
|
16
|
-
.option('-c, --no-color', 'Disable colored output')
|
|
17
|
-
.option('-t, --no-timing', 'Hide timing information')
|
|
18
|
-
.option('-p, --no-prefix', 'Hide command prefix')
|
|
19
|
-
.option('-s, --stop-on-error', 'Stop on first error')
|
|
20
|
-
.option('-o, --no-output', 'Hide command output')
|
|
21
|
-
.option('-m, --minimal', 'Use minimal output format')
|
|
22
|
-
.action(async (commands, options) => {
|
|
23
|
-
try {
|
|
24
|
-
await (0, index_js_1.run)(commands, {
|
|
25
|
-
parallel: false,
|
|
26
|
-
color: options.color,
|
|
27
|
-
showTiming: options.timing,
|
|
28
|
-
prefix: options.prefix,
|
|
29
|
-
stopOnError: options.stopOnError,
|
|
30
|
-
printOutput: options.output,
|
|
31
|
-
minimalOutput: options.minimal
|
|
32
|
-
});
|
|
33
|
-
}
|
|
34
|
-
catch (error) {
|
|
35
|
-
if (error instanceof Error) {
|
|
36
|
-
console.error(chalk_1.default.red(`${figures_1.default.cross} Error: ${error.message}`));
|
|
37
|
-
}
|
|
38
|
-
else {
|
|
39
|
-
console.error(chalk_1.default.red(`${figures_1.default.cross} An unknown error occurred`));
|
|
40
|
-
}
|
|
41
|
-
process.exit(1);
|
|
42
|
-
}
|
|
43
|
-
});
|
|
44
|
-
// Parallel execution command
|
|
45
|
-
program
|
|
46
|
-
.command('parallel <commands...>', { isDefault: true })
|
|
47
|
-
.alias('p')
|
|
48
|
-
.description('Run commands in parallel (default) or sequentially with -q. Alias: p')
|
|
49
|
-
.option('-c, --no-color', 'Disable colored output')
|
|
50
|
-
.option('-t, --no-timing', 'Hide timing information')
|
|
51
|
-
.option('-p, --no-prefix', 'Hide command prefix')
|
|
52
|
-
.option('-s, --stop-on-error', 'Stop on first error')
|
|
53
|
-
.option('-o, --no-output', 'Hide command output')
|
|
54
|
-
.option('-m, --minimal', 'Use minimal output format')
|
|
55
|
-
.option('-x, --max-parallel <number>', 'Maximum number of parallel processes', parseInt)
|
|
56
|
-
.option('-q, --sequential', 'Run commands sequentially instead of in parallel')
|
|
57
|
-
.action(async (commands, options) => {
|
|
58
|
-
try {
|
|
59
|
-
await (0, index_js_1.run)(commands, {
|
|
60
|
-
parallel: !options.sequential,
|
|
61
|
-
maxParallel: options.maxParallel,
|
|
62
|
-
color: options.color,
|
|
63
|
-
showTiming: options.timing,
|
|
64
|
-
prefix: options.prefix,
|
|
65
|
-
stopOnError: options.stopOnError,
|
|
66
|
-
printOutput: options.output,
|
|
67
|
-
minimalOutput: options.minimal
|
|
68
|
-
});
|
|
69
|
-
}
|
|
70
|
-
catch (error) {
|
|
71
|
-
if (error instanceof Error) {
|
|
72
|
-
console.error(chalk_1.default.red(`${figures_1.default.cross} Error: ${error.message}`));
|
|
73
|
-
}
|
|
74
|
-
else {
|
|
75
|
-
console.error(chalk_1.default.red(`${figures_1.default.cross} An unknown error occurred`));
|
|
76
|
-
}
|
|
77
|
-
process.exit(1);
|
|
78
|
-
}
|
|
79
|
-
});
|
|
80
|
-
}
|
|
81
|
-
exports.registerRunCommands = registerRunCommands;
|
|
@@ -1,208 +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.ProjectManager = void 0;
|
|
30
|
-
const dotenv_1 = __importDefault(require("dotenv"));
|
|
31
|
-
const logger_js_1 = __importDefault(require("./logger.js"));
|
|
32
|
-
const index_js_1 = require("./index.js");
|
|
33
|
-
const path = __importStar(require("path"));
|
|
34
|
-
const chalk_1 = __importDefault(require("chalk"));
|
|
35
|
-
dotenv_1.default.config();
|
|
36
|
-
class ProjectManager {
|
|
37
|
-
constructor(program) {
|
|
38
|
-
this.cacheDir = path.join(process.cwd(), '.neex_cache');
|
|
39
|
-
this.program = program;
|
|
40
|
-
this.registerCommands();
|
|
41
|
-
}
|
|
42
|
-
registerCommands() {
|
|
43
|
-
this.registerDevCommand();
|
|
44
|
-
this.registerBuildCommand();
|
|
45
|
-
this.registerStartCommand();
|
|
46
|
-
this.registerCacheCommands();
|
|
47
|
-
}
|
|
48
|
-
registerDevCommand() {
|
|
49
|
-
this.program
|
|
50
|
-
.command('dev <entry-file>')
|
|
51
|
-
.description('Run the development server')
|
|
52
|
-
.option('-p, --port <port>', 'Set the port for the development server', '8000')
|
|
53
|
-
.option('-w, --watch', 'Watch files for changes (Neex will restart on changes)')
|
|
54
|
-
.option('-i, --ignore <files...>', 'Files to ignore for watching')
|
|
55
|
-
.option('-e, --ext <extensions...>', 'File extensions to watch')
|
|
56
|
-
.option('-d, --delay <milliseconds>', 'Delay before restart (ms)', '0')
|
|
57
|
-
.option('-c, --clear', 'Clear console before restart')
|
|
58
|
-
.option('--cache', 'Enable caching (Neex will use cache)')
|
|
59
|
-
.option('--compiler <compiler>', 'Select compiler (esbuild, swc, tsc)', 'esbuild')
|
|
60
|
-
.option('--inspect', 'Enable Node.js inspector')
|
|
61
|
-
.option('--inspect-brk', 'Enable Node.js inspector with breakpoint')
|
|
62
|
-
.action(async (entryFile, options) => {
|
|
63
|
-
const port = this.getPort(options.port);
|
|
64
|
-
logger_js_1.default.printLine(`Running development server with entry file: ${entryFile} on port: ${port}`, 'info');
|
|
65
|
-
let commandToRun;
|
|
66
|
-
let nodeFlags = '';
|
|
67
|
-
if (options.inspect)
|
|
68
|
-
nodeFlags += ' --inspect';
|
|
69
|
-
if (options.inspectBrk)
|
|
70
|
-
nodeFlags += ' --inspect-brk';
|
|
71
|
-
switch (options.compiler) {
|
|
72
|
-
case 'esbuild':
|
|
73
|
-
commandToRun = `node ${nodeFlags} ${entryFile} --port ${port}`;
|
|
74
|
-
logger_js_1.default.printLine(chalk_1.default.yellow('Note: Esbuild dev server integration requires more advanced logic.'), 'warn');
|
|
75
|
-
break;
|
|
76
|
-
case 'swc':
|
|
77
|
-
commandToRun = `node ${nodeFlags} -r @swc/register ${entryFile} --port ${port}`;
|
|
78
|
-
break;
|
|
79
|
-
case 'tsc':
|
|
80
|
-
commandToRun = `node ${nodeFlags} -r ts-node/register ${entryFile} --port ${port}`;
|
|
81
|
-
break;
|
|
82
|
-
default:
|
|
83
|
-
commandToRun = `node ${nodeFlags} ${entryFile} --port ${port}`;
|
|
84
|
-
break;
|
|
85
|
-
}
|
|
86
|
-
if (options.watch) {
|
|
87
|
-
logger_js_1.default.printLine(chalk_1.default.yellow(`Warning: Watch mode for '${options.compiler}' is not fully implemented yet. Neex currently just runs the command.`), 'warn');
|
|
88
|
-
}
|
|
89
|
-
if (options.ignore || options.ext || options.delay || options.clear) {
|
|
90
|
-
logger_js_1.default.printLine(chalk_1.default.yellow(`Warning: Options like --ignore, --ext, --delay, --clear are not fully implemented for dev command.`), 'warn');
|
|
91
|
-
}
|
|
92
|
-
if (options.cache) {
|
|
93
|
-
logger_js_1.default.printLine(chalk_1.default.yellow(`Warning: Caching for dev command is not fully implemented yet.`), 'warn');
|
|
94
|
-
}
|
|
95
|
-
const neexRunOptions = {
|
|
96
|
-
isServerMode: true,
|
|
97
|
-
printOutput: true,
|
|
98
|
-
};
|
|
99
|
-
await (0, index_js_1.runServers)(commandToRun, neexRunOptions);
|
|
100
|
-
});
|
|
101
|
-
}
|
|
102
|
-
registerBuildCommand() {
|
|
103
|
-
this.program
|
|
104
|
-
.command('build')
|
|
105
|
-
.description('Build the project')
|
|
106
|
-
.option('-o, --out-dir <dir>', 'Output directory', 'dist')
|
|
107
|
-
.option('-m, --minify', 'Minify code')
|
|
108
|
-
.option('-s, --sourcemap', 'Generate sourcemaps')
|
|
109
|
-
.option('-w, --watch', 'Build in watch mode')
|
|
110
|
-
.option('-c, --compiler <compiler>', 'Select compiler (esbuild, swc, tsc)', 'esbuild')
|
|
111
|
-
.option('-t, --target <target>', 'JavaScript target version (e.g., ES2022)', 'ES2022')
|
|
112
|
-
.action(async (options) => {
|
|
113
|
-
logger_js_1.default.printLine(`Building project to output directory: ${options.outDir}`, 'info');
|
|
114
|
-
let buildCommand;
|
|
115
|
-
let buildArgs = [];
|
|
116
|
-
switch (options.compiler) {
|
|
117
|
-
case 'esbuild':
|
|
118
|
-
buildCommand = 'esbuild';
|
|
119
|
-
buildArgs.push('.');
|
|
120
|
-
buildArgs.push(`--outdir=${options.outDir}`);
|
|
121
|
-
if (options.minify)
|
|
122
|
-
buildArgs.push('--minify');
|
|
123
|
-
if (options.sourcemap)
|
|
124
|
-
buildArgs.push('--sourcemap');
|
|
125
|
-
if (options.target)
|
|
126
|
-
buildArgs.push(`--target=${options.target}`);
|
|
127
|
-
if (options.watch)
|
|
128
|
-
buildArgs.push('--watch');
|
|
129
|
-
break;
|
|
130
|
-
case 'swc':
|
|
131
|
-
buildCommand = 'swc';
|
|
132
|
-
buildArgs.push('src');
|
|
133
|
-
buildArgs.push(`-d ${options.outDir}`);
|
|
134
|
-
if (options.minify)
|
|
135
|
-
buildArgs.push('--minify');
|
|
136
|
-
if (options.sourcemap)
|
|
137
|
-
buildArgs.push('--source-maps');
|
|
138
|
-
if (options.watch)
|
|
139
|
-
buildArgs.push('--watch');
|
|
140
|
-
logger_js_1.default.printLine(chalk_1.default.yellow('Note: SWC build command options might need more specific mapping.'), 'warn');
|
|
141
|
-
break;
|
|
142
|
-
case 'tsc':
|
|
143
|
-
buildCommand = 'tsc';
|
|
144
|
-
buildArgs.push(`--outDir ${options.outDir}`);
|
|
145
|
-
if (options.sourcemap)
|
|
146
|
-
buildArgs.push('--sourceMap');
|
|
147
|
-
if (options.watch)
|
|
148
|
-
buildArgs.push('--watch');
|
|
149
|
-
if (options.target)
|
|
150
|
-
buildArgs.push(`--target ${options.target}`);
|
|
151
|
-
break;
|
|
152
|
-
default:
|
|
153
|
-
logger_js_1.default.printLine(chalk_1.default.red(`Error: Unknown compiler '${options.compiler}'.`), 'error');
|
|
154
|
-
return;
|
|
155
|
-
}
|
|
156
|
-
const fullCommand = `${buildCommand} ${buildArgs.join(' ')}`;
|
|
157
|
-
// TODO: Implement build logic
|
|
158
|
-
});
|
|
159
|
-
}
|
|
160
|
-
registerStartCommand() {
|
|
161
|
-
this.program
|
|
162
|
-
.command('start')
|
|
163
|
-
.description('Start the application')
|
|
164
|
-
.option('-p, --port <port>', 'Set the port for the application', '8000')
|
|
165
|
-
.option('-o, --out-dir <dir>', 'Output directory', 'dist')
|
|
166
|
-
.option('-e, --entry <file>', 'Entry file for the application')
|
|
167
|
-
.option('--inspect', 'Enable Node.js inspector')
|
|
168
|
-
.option('--cluster', 'Run in cluster mode')
|
|
169
|
-
.option('--workers <number>', 'Number of workers', '1')
|
|
170
|
-
.option('--max-memory <memory>', 'Maximum memory (e.g., 512M)', '512M')
|
|
171
|
-
.option('--health-check', 'Enable health check')
|
|
172
|
-
.action((options) => {
|
|
173
|
-
const port = this.getPort(options.port);
|
|
174
|
-
logger_js_1.default.printLine(`Starting application from entry file: ${options.entry} on port: ${port}`, 'info');
|
|
175
|
-
// TODO: Implement start logic
|
|
176
|
-
});
|
|
177
|
-
}
|
|
178
|
-
registerCacheCommands() {
|
|
179
|
-
const cacheCommand = this.program.command('cache').description('Manage cache');
|
|
180
|
-
cacheCommand
|
|
181
|
-
.command('clear')
|
|
182
|
-
.description('Clear cache')
|
|
183
|
-
.action(() => {
|
|
184
|
-
logger_js_1.default.printLine('Cache cleared.', 'info');
|
|
185
|
-
// TODO: Implement cache clear logic
|
|
186
|
-
});
|
|
187
|
-
cacheCommand
|
|
188
|
-
.command('stats')
|
|
189
|
-
.description('Display cache status')
|
|
190
|
-
.action(() => {
|
|
191
|
-
logger_js_1.default.printLine('Displaying cache status.', 'info');
|
|
192
|
-
// TODO: Implement cache stats logic
|
|
193
|
-
});
|
|
194
|
-
}
|
|
195
|
-
getPort(portOption) {
|
|
196
|
-
const envPort = process.env.PORT;
|
|
197
|
-
if (portOption) {
|
|
198
|
-
return parseInt(portOption, 10);
|
|
199
|
-
}
|
|
200
|
-
else if (envPort) {
|
|
201
|
-
return parseInt(envPort, 10);
|
|
202
|
-
}
|
|
203
|
-
else {
|
|
204
|
-
return 8000;
|
|
205
|
-
}
|
|
206
|
-
}
|
|
207
|
-
}
|
|
208
|
-
exports.ProjectManager = ProjectManager;
|