millas 0.2.26 → 0.2.28
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/package.json +1 -1
- package/src/cli.js +0 -4
- package/src/commands/serve.js +15 -45
- package/src/container/Application.js +36 -1
- package/src/container/HttpServer.js +1 -1
package/package.json
CHANGED
package/src/cli.js
CHANGED
package/src/commands/serve.js
CHANGED
|
@@ -8,40 +8,6 @@ const {fork} = require('child_process');
|
|
|
8
8
|
const chokidar = require('chokidar');
|
|
9
9
|
const patchConsole = require("../logger/patchConsole");
|
|
10
10
|
const Logger = require("../logger/internal");
|
|
11
|
-
// ── ASCII banner ───────────────────────────────────────────────────────────────
|
|
12
|
-
|
|
13
|
-
const BANNER_LINES = [
|
|
14
|
-
' ███╗ ███╗██╗██╗ ██╗ █████╗ ███████╗',
|
|
15
|
-
' ████╗ ████║██║██║ ██║ ██╔══██╗██╔════╝',
|
|
16
|
-
' ██╔████╔██║██║██║ ██║ ███████║███████╗',
|
|
17
|
-
' ██║╚██╔╝██║██║██║ ██║ ██╔══██║╚════██║',
|
|
18
|
-
' ██║ ╚═╝ ██║██║███████╗███████╗██║ ██║███████║',
|
|
19
|
-
' ╚═╝ ╚═╝╚═╝╚══════╝╚══════╝╚═╝ ╚═╝╚══════╝',
|
|
20
|
-
];
|
|
21
|
-
|
|
22
|
-
function printBanner(host, port) {
|
|
23
|
-
const env = process.env.NODE_ENV || 'development';
|
|
24
|
-
const ver = 'v' + (require('../../package.json').version || '0.1.0');
|
|
25
|
-
const url = `http://${host}:${port}`;
|
|
26
|
-
const hr = chalk.dim(' ' + '─'.repeat(54));
|
|
27
|
-
const envColour = env === 'production' ? chalk.red
|
|
28
|
-
: env === 'staging' ? chalk.yellow
|
|
29
|
-
: chalk.green;
|
|
30
|
-
|
|
31
|
-
process.stdout.write('\n');
|
|
32
|
-
for (const line of BANNER_LINES) {
|
|
33
|
-
process.stdout.write(chalk.bold.cyan(line) + '\n');
|
|
34
|
-
}
|
|
35
|
-
process.stdout.write('\n' + hr + '\n');
|
|
36
|
-
process.stdout.write(
|
|
37
|
-
' ' + chalk.dim(ver.padEnd(8)) +
|
|
38
|
-
chalk.dim('│') + ' ' + envColour('⬤ ' + env) + ' ' +
|
|
39
|
-
chalk.dim('│') + ' ' + chalk.bold.white(url) + '\n'
|
|
40
|
-
);
|
|
41
|
-
process.stdout.write(hr + '\n\n');
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
// ── Constants ─────────────────────────────────────────────────────────────────
|
|
45
11
|
|
|
46
12
|
const WATCH_DIRS = ['app', 'routes', 'config', 'bootstrap', 'providers', 'middleware'];
|
|
47
13
|
const WATCH_EXTS = new Set(['.js', '.mjs', '.cjs', '.json', '.njk', '.env']);
|
|
@@ -81,11 +47,14 @@ class HotReloader {
|
|
|
81
47
|
extra["MILLAS_START_UP"] = true
|
|
82
48
|
this._initialised = true
|
|
83
49
|
}
|
|
50
|
+
|
|
84
51
|
this._child = fork(this._bootstrap, [], {
|
|
85
52
|
env: {
|
|
86
53
|
...extra,
|
|
87
54
|
MILLAS_CHILD: '1',
|
|
88
55
|
DEBUG: process.env.APP_DEBUG,
|
|
56
|
+
MILLAS_HOST: process.env.MILLAS_HOST,
|
|
57
|
+
MILLAS_PORT: process.env.MILLAS_PORT,
|
|
89
58
|
},
|
|
90
59
|
stdio: 'inherit',
|
|
91
60
|
});
|
|
@@ -199,7 +168,7 @@ module.exports = function (program) {
|
|
|
199
168
|
.command('serve')
|
|
200
169
|
.description('Start the development server with hot reload')
|
|
201
170
|
.option('-p, --port <port>', 'Port to listen on')
|
|
202
|
-
.option('-h, --host <host>', 'Host to bind to'
|
|
171
|
+
.option('-h, --host <host>', 'Host to bind to')
|
|
203
172
|
.option('--no-reload', 'Disable hot reload (run once, like production)')
|
|
204
173
|
.action((options) => {
|
|
205
174
|
|
|
@@ -214,18 +183,19 @@ module.exports = function (program) {
|
|
|
214
183
|
process.exit(1);
|
|
215
184
|
}
|
|
216
185
|
|
|
217
|
-
const publicPort = parseInt(options.port ||process.env.APP_PORT, 10)
|
|
218
|
-
const publicHost = options.host
|
|
186
|
+
const publicPort = parseInt(options.port ||process.env.APP_PORT, 10);
|
|
187
|
+
const publicHost = options.host;
|
|
219
188
|
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
189
|
+
const env = Object.fromEntries(
|
|
190
|
+
Object.entries({
|
|
191
|
+
NODE_ENV: process.env.APP_ENV,
|
|
192
|
+
MILLERS_NODE_ENV: true,
|
|
193
|
+
MILLAS_HOST: publicHost,
|
|
194
|
+
MILLAS_PORT: String(publicPort),
|
|
195
|
+
}).filter(([, v]) => v !== undefined)
|
|
196
|
+
);
|
|
226
197
|
|
|
227
|
-
|
|
228
|
-
printBanner(publicHost, publicPort);
|
|
198
|
+
Object.assign(process.env, env)
|
|
229
199
|
|
|
230
200
|
if (options.reload !== false) {
|
|
231
201
|
new HotReloader(appBootstrap, publicPort, publicHost).start();
|
|
@@ -174,9 +174,11 @@ class Application {
|
|
|
174
174
|
|| parseInt(process.env.MILLAS_INTERNAL_PORT, 10)
|
|
175
175
|
|| parseInt(process.env.APP_PORT, 10)
|
|
176
176
|
|| 3000;
|
|
177
|
-
const _host = host ||
|
|
177
|
+
const _host = host || 'localhost';
|
|
178
|
+
|
|
178
179
|
|
|
179
180
|
await this._adapter.listen(_port, _host);
|
|
181
|
+
console.log(_host,_port)
|
|
180
182
|
|
|
181
183
|
if (process.env.APP_ENV === "development" && process.env.MILLAS_START_UP && !process.env.MILLERS_NODE_ENV) {
|
|
182
184
|
this._printStartupLog(_host, _port);
|
|
@@ -190,7 +192,9 @@ class Application {
|
|
|
190
192
|
}
|
|
191
193
|
|
|
192
194
|
_printStartupLog(host, port) {
|
|
195
|
+
|
|
193
196
|
const chalk = _tryChalk();
|
|
197
|
+
printBanner(host,port,chalk)
|
|
194
198
|
const routeCount = this._route.list().length;
|
|
195
199
|
const url = `http://${host}:${port}`;
|
|
196
200
|
|
|
@@ -344,4 +348,35 @@ function _tryChalk() {
|
|
|
344
348
|
p.white = id;
|
|
345
349
|
return p;
|
|
346
350
|
}
|
|
351
|
+
}
|
|
352
|
+
|
|
353
|
+
const BANNER_LINES = [
|
|
354
|
+
' ███╗ ███╗██╗██╗ ██╗ █████╗ ███████╗',
|
|
355
|
+
' ████╗ ████║██║██║ ██║ ██╔══██╗██╔════╝',
|
|
356
|
+
' ██╔████╔██║██║██║ ██║ ███████║███████╗',
|
|
357
|
+
' ██║╚██╔╝██║██║██║ ██║ ██╔══██║╚════██║',
|
|
358
|
+
' ██║ ╚═╝ ██║██║███████╗███████╗██║ ██║███████║',
|
|
359
|
+
' ╚═╝ ╚═╝╚═╝╚══════╝╚══════╝╚═╝ ╚═╝╚══════╝',
|
|
360
|
+
];
|
|
361
|
+
|
|
362
|
+
function printBanner(host, port,chalk) {
|
|
363
|
+
const env = process.env.NODE_ENV || 'development';
|
|
364
|
+
const ver = 'v' + (require('../../package.json').version || '0.1.0');
|
|
365
|
+
const url = `http://${host}:${port}`;
|
|
366
|
+
const hr = chalk.dim(' ' + '─'.repeat(54));
|
|
367
|
+
const envColour = env === 'production' ? chalk.red
|
|
368
|
+
: env === 'staging' ? chalk.yellow
|
|
369
|
+
: chalk.green;
|
|
370
|
+
|
|
371
|
+
process.stdout.write('\n');
|
|
372
|
+
for (const line of BANNER_LINES) {
|
|
373
|
+
process.stdout.write(chalk.bold.cyan(line) + '\n');
|
|
374
|
+
}
|
|
375
|
+
process.stdout.write('\n' + hr + '\n');
|
|
376
|
+
process.stdout.write(
|
|
377
|
+
' ' + chalk.dim(ver.padEnd(8)) +
|
|
378
|
+
chalk.dim('│') + ' ' + envColour('⬤ ' + env) + ' ' +
|
|
379
|
+
chalk.dim('│') + ' ' + chalk.bold.white(url) + '\n'
|
|
380
|
+
);
|
|
381
|
+
process.stdout.write(hr + '\n\n');
|
|
347
382
|
}
|