miqro 6.2.12 → 6.3.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/build/esm/src/common/arguments.d.ts +3 -0
- package/build/esm/src/common/arguments.js +45 -5
- package/build/esm/src/common/fs.d.ts +6 -0
- package/build/esm/src/common/fs.js +69 -0
- package/build/esm/src/common/help.d.ts +1 -1
- package/build/esm/src/common/help.js +3 -1
- package/build/esm/src/common/jsx.js +22 -22
- package/build/esm/src/common/watch.js +3 -0
- package/build/esm/src/inflate/inflate-sea.js +6 -2
- package/build/esm/src/inflate/inflate.d.ts +2 -1
- package/build/esm/src/inflate/inflate.js +2 -2
- package/build/esm/src/inflate/setup-http.d.ts +1 -1
- package/build/esm/src/inflate/setup-http.js +125 -89
- package/build/esm/src/main.js +14 -5
- package/build/esm/src/services/app.d.ts +2 -0
- package/build/esm/src/services/app.js +4 -2
- package/build/lib.cjs +306 -194
- package/package.json +1 -1
- package/src/common/arguments.ts +50 -5
- package/src/common/fs.ts +65 -0
- package/src/common/help.ts +3 -1
- package/src/common/jsx.ts +22 -22
- package/src/common/watch.ts +3 -0
- package/src/inflate/inflate-sea.ts +6 -2
- package/src/inflate/inflate.ts +3 -2
- package/src/inflate/setup-http.ts +127 -91
- package/src/main.ts +14 -5
- package/src/services/app.ts +6 -2
package/package.json
CHANGED
package/src/common/arguments.ts
CHANGED
|
@@ -27,6 +27,7 @@ interface MiqroJSON {
|
|
|
27
27
|
https?: boolean;
|
|
28
28
|
serverOptions?: ServerOptions;
|
|
29
29
|
httpsRedirect?: number;
|
|
30
|
+
inflateParallel?: number;
|
|
30
31
|
}
|
|
31
32
|
|
|
32
33
|
const MiqroJSONSchema: Schema<MiqroJSON> = {
|
|
@@ -41,7 +42,8 @@ const MiqroJSONSchema: Schema<MiqroJSON> = {
|
|
|
41
42
|
editor: "boolean?",
|
|
42
43
|
https: "boolean?",
|
|
43
44
|
serverOptions: "any?",
|
|
44
|
-
httpsRedirect: "number?"
|
|
45
|
+
httpsRedirect: "number?",
|
|
46
|
+
inflateParallel: "number?"
|
|
45
47
|
}
|
|
46
48
|
}
|
|
47
49
|
|
|
@@ -83,9 +85,11 @@ export interface Arguments {
|
|
|
83
85
|
services: string[];
|
|
84
86
|
editor: boolean;
|
|
85
87
|
hotreload: boolean;
|
|
88
|
+
watch: boolean;
|
|
86
89
|
https: boolean;
|
|
87
90
|
serverOptions: ServerOptions;
|
|
88
91
|
httpsRedirect?: number;
|
|
92
|
+
inflateParallel?: number;
|
|
89
93
|
}
|
|
90
94
|
|
|
91
95
|
/**
|
|
@@ -97,6 +101,7 @@ export function parseArguments(): Arguments {
|
|
|
97
101
|
|
|
98
102
|
const args = cluster.isPrimary ? process.argv.slice(2, process.argv.length) : process.argv.slice(3, process.argv.length);
|
|
99
103
|
const flags: {
|
|
104
|
+
inflateParallel: number | null;
|
|
100
105
|
httpsRedirect: number | null;
|
|
101
106
|
https: boolean | null;
|
|
102
107
|
serverOptions: ServerOptions;
|
|
@@ -122,7 +127,9 @@ export function parseArguments(): Arguments {
|
|
|
122
127
|
editor: boolean | null;
|
|
123
128
|
inflateDir?: string | null;
|
|
124
129
|
hotreload?: boolean | null;
|
|
130
|
+
watch?: boolean | null;
|
|
125
131
|
} = {
|
|
132
|
+
inflateParallel: null,
|
|
126
133
|
httpsRedirect: null,
|
|
127
134
|
https: null,
|
|
128
135
|
serverOptions: {},
|
|
@@ -130,6 +137,7 @@ export function parseArguments(): Arguments {
|
|
|
130
137
|
browser: null,
|
|
131
138
|
logFile: null,
|
|
132
139
|
hotreload: null,
|
|
140
|
+
watch: null,
|
|
133
141
|
miqroJSONPath: null,
|
|
134
142
|
installMiqroJSON: null,
|
|
135
143
|
disableMiqroJSON: null,
|
|
@@ -206,6 +214,14 @@ export function parseArguments(): Arguments {
|
|
|
206
214
|
flags.installTSConfig = true;
|
|
207
215
|
continue;
|
|
208
216
|
case "--watch":
|
|
217
|
+
if (flags.watch !== null) {
|
|
218
|
+
console.error("bad arguments.");
|
|
219
|
+
console.error(usage);
|
|
220
|
+
process.exit(EXIT_CODES.BAD_ARGUMENTS);
|
|
221
|
+
}
|
|
222
|
+
flags.watch = true;
|
|
223
|
+
continue;
|
|
224
|
+
case "--hot-reload":
|
|
209
225
|
if (flags.hotreload !== null) {
|
|
210
226
|
console.error("bad arguments.");
|
|
211
227
|
console.error(usage);
|
|
@@ -466,6 +482,27 @@ export function parseArguments(): Arguments {
|
|
|
466
482
|
services.push(args[i + 1]);
|
|
467
483
|
i++;
|
|
468
484
|
continue;
|
|
485
|
+
case "--inflate-parallel":
|
|
486
|
+
if (args[i + 1] === undefined) {
|
|
487
|
+
console.error("bad arguments. service directory not provided.");
|
|
488
|
+
console.error(usage);
|
|
489
|
+
process.exit(EXIT_CODES.BAD_ARGUMENTS);
|
|
490
|
+
}
|
|
491
|
+
if (typeof args[i + 1] !== "string") {
|
|
492
|
+
console.error("bad arguments. --inflate-parallel must be a number.");
|
|
493
|
+
console.error(usage);
|
|
494
|
+
process.exit(EXIT_CODES.BAD_ARGUMENTS);
|
|
495
|
+
} else {
|
|
496
|
+
const cParallel = parseInt(String(args[i + 1]), 10);
|
|
497
|
+
if (isNaN(cParallel)) {
|
|
498
|
+
console.error("bad arguments. --inflate-parallel must be a number.");
|
|
499
|
+
console.error(usage);
|
|
500
|
+
process.exit(EXIT_CODES.BAD_ARGUMENTS);
|
|
501
|
+
}
|
|
502
|
+
flags.inflateParallel = cParallel;
|
|
503
|
+
}
|
|
504
|
+
i++;
|
|
505
|
+
continue;
|
|
469
506
|
case "--inflate-dir":
|
|
470
507
|
if (flags.inflateDir !== null && flags.compile === null) {
|
|
471
508
|
console.error("bad arguments. --inflate-dir already set.");
|
|
@@ -571,6 +608,12 @@ export function parseArguments(): Arguments {
|
|
|
571
608
|
flags.editor = miqroRC.editor;
|
|
572
609
|
}
|
|
573
610
|
}
|
|
611
|
+
|
|
612
|
+
if (flags.inflateParallel === null) {
|
|
613
|
+
if (miqroRC.inflateParallel !== undefined) {
|
|
614
|
+
flags.inflateParallel = miqroRC.inflateParallel;
|
|
615
|
+
}
|
|
616
|
+
}
|
|
574
617
|
}
|
|
575
618
|
|
|
576
619
|
flags.editor = flags.editor ? flags.editor : false;
|
|
@@ -627,22 +670,22 @@ export function parseArguments(): Arguments {
|
|
|
627
670
|
process.exit(EXIT_CODES.BAD_ARGUMENTS);
|
|
628
671
|
}
|
|
629
672
|
|
|
630
|
-
if (flags.test && (flags.hotreload || flags.editor || flags.compile || flags.inflate)) {
|
|
673
|
+
if (flags.test && (flags.watch || flags.hotreload || flags.editor || flags.compile || flags.inflate)) {
|
|
631
674
|
console.error("bad arguments. cannot use --editor with --test");
|
|
632
675
|
process.exit(EXIT_CODES.BAD_ARGUMENTS);
|
|
633
676
|
}
|
|
634
677
|
|
|
635
|
-
if (flags.migrateUp && (flags.hotreload || flags.editor || flags.compile || flags.test || flags.migrateDown || flags.inflate)) {
|
|
678
|
+
if (flags.migrateUp && (flags.watch || flags.hotreload || flags.editor || flags.compile || flags.test || flags.migrateDown || flags.inflate)) {
|
|
636
679
|
console.error("bad arguments. cannot use with --migrate-up");
|
|
637
680
|
process.exit(EXIT_CODES.BAD_ARGUMENTS);
|
|
638
681
|
}
|
|
639
682
|
|
|
640
|
-
if (flags.migrateDown && (flags.hotreload || flags.editor || flags.compile || flags.test || flags.migrateUp || flags.inflate)) {
|
|
683
|
+
if (flags.migrateDown && (flags.watch || flags.hotreload || flags.editor || flags.compile || flags.test || flags.migrateUp || flags.inflate)) {
|
|
641
684
|
console.error("bad arguments. cannot use with --migrate-down");
|
|
642
685
|
process.exit(EXIT_CODES.BAD_ARGUMENTS);
|
|
643
686
|
}
|
|
644
687
|
|
|
645
|
-
if (flags.generateDoc && (flags.hotreload || flags.editor || flags.compile || flags.test || flags.migrateUp || flags.inflate || flags.migrateDown)) {
|
|
688
|
+
if (flags.generateDoc && (flags.watch || flags.hotreload || flags.editor || flags.compile || flags.test || flags.migrateUp || flags.inflate || flags.migrateDown)) {
|
|
646
689
|
console.error("bad arguments. cannot use with --generate-doc");
|
|
647
690
|
process.exit(EXIT_CODES.BAD_ARGUMENTS);
|
|
648
691
|
}
|
|
@@ -670,11 +713,13 @@ export function parseArguments(): Arguments {
|
|
|
670
713
|
}
|
|
671
714
|
|
|
672
715
|
return {
|
|
716
|
+
inflateParallel: flags.inflateParallel ? flags.inflateParallel : undefined,
|
|
673
717
|
name: flags.name ? flags.name : undefined,
|
|
674
718
|
browser: flags.browser !== null ? flags.browser : undefined,
|
|
675
719
|
logFile: flags.logFile !== null ? flags.logFile : undefined,
|
|
676
720
|
generateDocAll: flags.generateDocAll ? true : false,
|
|
677
721
|
hotreload: flags.hotreload ? true : false,
|
|
722
|
+
watch: flags.watch ? true : false,
|
|
678
723
|
disableMiqroJSON: flags.disableMiqroJSON !== null ? flags.disableMiqroJSON : false,
|
|
679
724
|
miqroJSONPath: miqroJSONPath ? miqroJSONPath : false,
|
|
680
725
|
installTypes: flags.installTypes ? true : false,
|
package/src/common/fs.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { mkdir, rmdir, unlink, writeFile } from "node:fs";
|
|
1
2
|
import { basename, extname } from "node:path";
|
|
2
3
|
|
|
3
4
|
export function describeFilePath(filePath: string) {
|
|
@@ -15,3 +16,67 @@ export function describeFilePath(filePath: string) {
|
|
|
15
16
|
filePath
|
|
16
17
|
};
|
|
17
18
|
}
|
|
19
|
+
|
|
20
|
+
export async function mkdirASync(path: string, options?: Partial<{ recursive: true; }>) {
|
|
21
|
+
return new Promise<void>((resolve, reject) => {
|
|
22
|
+
try {
|
|
23
|
+
mkdir(path, options, (err) => {
|
|
24
|
+
if (err) {
|
|
25
|
+
reject(err);
|
|
26
|
+
} else {
|
|
27
|
+
resolve();
|
|
28
|
+
}
|
|
29
|
+
});
|
|
30
|
+
} catch (e) {
|
|
31
|
+
reject(e);
|
|
32
|
+
}
|
|
33
|
+
})
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export async function writeFileASync(path: string, body?) {
|
|
37
|
+
return new Promise<void>((resolve, reject) => {
|
|
38
|
+
try {
|
|
39
|
+
writeFile(path, body, (err) => {
|
|
40
|
+
if (err) {
|
|
41
|
+
reject(err);
|
|
42
|
+
} else {
|
|
43
|
+
resolve();
|
|
44
|
+
}
|
|
45
|
+
});
|
|
46
|
+
} catch (e) {
|
|
47
|
+
reject(e);
|
|
48
|
+
}
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export async function rmdirASync(path: string) {
|
|
53
|
+
return new Promise<void>((resolve, reject) => {
|
|
54
|
+
try {
|
|
55
|
+
rmdir(path, (err) => {
|
|
56
|
+
if (err) {
|
|
57
|
+
reject(err);
|
|
58
|
+
} else {
|
|
59
|
+
resolve();
|
|
60
|
+
}
|
|
61
|
+
});
|
|
62
|
+
} catch (e) {
|
|
63
|
+
reject(e);
|
|
64
|
+
}
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
export async function unlinkASync(path: string) {
|
|
69
|
+
return new Promise<void>((resolve, reject) => {
|
|
70
|
+
try {
|
|
71
|
+
unlink(path, (err) => {
|
|
72
|
+
if (err) {
|
|
73
|
+
reject(err);
|
|
74
|
+
} else {
|
|
75
|
+
resolve();
|
|
76
|
+
}
|
|
77
|
+
});
|
|
78
|
+
} catch (e) {
|
|
79
|
+
reject(e);
|
|
80
|
+
}
|
|
81
|
+
});
|
|
82
|
+
}
|
package/src/common/help.ts
CHANGED
|
@@ -18,7 +18,8 @@ export const help = `
|
|
|
18
18
|
|
|
19
19
|
-v, --version\n\toutputs the version number
|
|
20
20
|
-h, --help\n\toutputs this page.
|
|
21
|
-
--watch\n\tuse to
|
|
21
|
+
--watch\n\tuse to auto reload the server when files change.
|
|
22
|
+
--hot-reload\n\tenables the hot-reload functionality use with --watch.
|
|
22
23
|
--test\n\trun the tests for a service.
|
|
23
24
|
--migrate-up\n\tmigrations up.
|
|
24
25
|
--migrate-down\n\tmigrations down.
|
|
@@ -44,6 +45,7 @@ export const help = `
|
|
|
44
45
|
--https-key\n\tpoint to a server.key file for https.
|
|
45
46
|
--https-cert\n\tpoint to a server.cert file for https.
|
|
46
47
|
--https-redirect\n\tserves an aditional http server that redirects to https. it needs a port number.
|
|
48
|
+
--inflate-parallel\n\tsets the max parallel esbuild instances. defaults to 1.
|
|
47
49
|
|
|
48
50
|
==environment variables==
|
|
49
51
|
|
package/src/common/jsx.ts
CHANGED
|
@@ -2,7 +2,6 @@ import { Runtime } from "@miqro/jsx";
|
|
|
2
2
|
import { createNodeRuntime } from "@miqro/jsx-node";
|
|
3
3
|
import { basename, dirname, extname, relative, resolve } from "node:path";
|
|
4
4
|
import { randomUUID } from "node:crypto";
|
|
5
|
-
import { mkdirSync, readFileSync, rmdirSync, unlinkSync, writeFileSync } from "node:fs";
|
|
6
5
|
import { Request, Response, CORSOptions, Logger, APIRoute } from "@miqro/core";
|
|
7
6
|
import { Parser, Schema } from "@miqro/parser";
|
|
8
7
|
import { APIRouteSchema, SessionHandlerOptionsSchema } from "@miqro/core";
|
|
@@ -17,6 +16,7 @@ import { getAsset, initAsset, validateAsset } from "./assets.js";
|
|
|
17
16
|
import { calculateChecksumFromBuffer } from "./checksum.js";
|
|
18
17
|
import { HandlerWithOptionsSchema, RouteOptionsSchema } from "@miqro/core/build/types.js";
|
|
19
18
|
import { Migration } from "@miqro/query";
|
|
19
|
+
import { mkdirASync, rmdirASync, unlinkASync, writeFileASync } from "./fs.js";
|
|
20
20
|
|
|
21
21
|
let jsxJSBuffer: null | Buffer = null; // Buffer.from(getAsset("jsx.dom.js"));
|
|
22
22
|
let jsxJSBufferChecksumPromise: null | Promise<string> = null; // calculateChecksumFromBuffer(jsxJSBuffer);
|
|
@@ -70,11 +70,11 @@ export async function inflateJSX(inFile: string, options: InflateOptions): Promi
|
|
|
70
70
|
try {
|
|
71
71
|
|
|
72
72
|
if (!options.embemedJSX) {
|
|
73
|
-
|
|
73
|
+
await mkdirASync(tmpBuildDir, {
|
|
74
74
|
recursive: true
|
|
75
75
|
});
|
|
76
|
-
|
|
77
|
-
//
|
|
76
|
+
await writeFileASync(inFileTmp, browserJSXGlobals(inFile, false, options.useExport));
|
|
77
|
+
//await writeFileASync(inFileTmp, browserJSXGlobals(relative(tmpBuildDir, inFile), false));
|
|
78
78
|
logger?.trace("inflating [%s] from [%s]. to change the import folder set JSX_TMP", relative(cwd(), inFile), dirname(relative(JSX_TMP_DIR, inFileTmp)));
|
|
79
79
|
const { outputFiles: [{ contents }] } = await esBuild({
|
|
80
80
|
...DEFAULT_ESOPTION,
|
|
@@ -84,17 +84,17 @@ export async function inflateJSX(inFile: string, options: InflateOptions): Promi
|
|
|
84
84
|
});
|
|
85
85
|
if (CLEAR_JSX_CACHE) {
|
|
86
86
|
logger?.trace("clearing cache at [%s] to change this behaivor set CLEAR_JSX_CACHE to 0", tmpBuildDir);
|
|
87
|
-
|
|
88
|
-
|
|
87
|
+
await unlinkASync(inFileTmp);
|
|
88
|
+
await rmdirASync(tmpBuildDir);
|
|
89
89
|
}
|
|
90
90
|
return contents;
|
|
91
91
|
} else {
|
|
92
|
-
|
|
92
|
+
await mkdirASync(tmpBuildDir, {
|
|
93
93
|
recursive: true
|
|
94
94
|
});
|
|
95
|
-
//
|
|
96
|
-
|
|
97
|
-
//
|
|
95
|
+
//await writeFileASync(jsxJSPath, Buffer.from(getAsset("jsx-dom-bundle")));
|
|
96
|
+
await writeFileASync(inFileTmp, browserJSXGlobals(inFile, jsxJSPath));
|
|
97
|
+
//await writeFileASync(inFileTmp, browserJSXGlobals(relative(tmpBuildDir, inFile), relative(tmpBuildDir, jsxJSPath)));
|
|
98
98
|
logger?.trace("inflating [%s] from [%s] with jsx.js embedded. to change the import folder set JSX_TMP", relative(cwd(), inFile), dirname(relative(JSX_TMP_DIR, inFileTmp)));
|
|
99
99
|
const { outputFiles: [{ contents }] } = await esBuild({
|
|
100
100
|
...DEFAULT_ESOPTION,
|
|
@@ -104,9 +104,9 @@ export async function inflateJSX(inFile: string, options: InflateOptions): Promi
|
|
|
104
104
|
});
|
|
105
105
|
if (CLEAR_JSX_CACHE) {
|
|
106
106
|
logger?.trace("clearing cache at [%s] to change this behaivor set CLEAR_JSX_CACHE to 0", tmpBuildDir);
|
|
107
|
-
|
|
108
|
-
//
|
|
109
|
-
|
|
107
|
+
await unlinkASync(inFileTmp);
|
|
108
|
+
//await unlinkASync(jsxJSPath);
|
|
109
|
+
await rmdirASync(tmpBuildDir);
|
|
110
110
|
}
|
|
111
111
|
return contents;
|
|
112
112
|
}
|
|
@@ -116,9 +116,9 @@ export async function inflateJSX(inFile: string, options: InflateOptions): Promi
|
|
|
116
116
|
if (options.embemedJSX) {
|
|
117
117
|
if (CLEAR_JSX_CACHE) {
|
|
118
118
|
logger?.trace("clearing cache at [%s] to change this behaivor set CLEAR_JSX_CACHE to 0", tmpBuildDir);
|
|
119
|
-
|
|
120
|
-
//
|
|
121
|
-
|
|
119
|
+
await unlinkASync(inFileTmp);
|
|
120
|
+
//await unlinkASync(jsxJSPath);
|
|
121
|
+
await rmdirASync(tmpBuildDir);
|
|
122
122
|
} else {
|
|
123
123
|
//console.error("errors on: " + tmpBuildDir);
|
|
124
124
|
logger?.error("error with: %s", inFileTmp);
|
|
@@ -489,11 +489,11 @@ export async function importJSXFile(inFile: string, logger?: Logger | Console):
|
|
|
489
489
|
//const inFileTmp = resolve(tmpBuildDir, basename(inFile) + ".mjs");
|
|
490
490
|
const inFileTmp = resolve(tmpBuildDir, basename(inFile) + ".cjs");
|
|
491
491
|
//const logger = getLogger(`${SERVER_IDENTIFIER}_JSX`);
|
|
492
|
-
|
|
492
|
+
await mkdirASync(tmpBuildDir, {
|
|
493
493
|
recursive: true
|
|
494
494
|
});
|
|
495
495
|
try {
|
|
496
|
-
|
|
496
|
+
await writeFileASync(inFileTmp, inflatedCode);
|
|
497
497
|
assertGlobalTampered();
|
|
498
498
|
logger?.trace("importing [%s] from [%s]. to change the import folder set JSX_TMP", relative(cwd(), inFile), dirname(relative(JSX_TMP_DIR, inFileTmp)));
|
|
499
499
|
logger?.debug("importing [%s]", relative(cwd(), inFile));
|
|
@@ -501,8 +501,8 @@ export async function importJSXFile(inFile: string, logger?: Logger | Console):
|
|
|
501
501
|
assertGlobalTampered();
|
|
502
502
|
if (CLEAR_JSX_CACHE) {
|
|
503
503
|
logger?.trace("clearing cache at [%s]. to change this behaivor set CLEAR_JSX_CACHE to 0", tmpBuildDir);
|
|
504
|
-
|
|
505
|
-
|
|
504
|
+
await unlinkASync(inFileTmp);
|
|
505
|
+
await rmdirASync(tmpBuildDir);
|
|
506
506
|
}
|
|
507
507
|
return module.default;
|
|
508
508
|
} catch (e) {
|
|
@@ -510,8 +510,8 @@ export async function importJSXFile(inFile: string, logger?: Logger | Console):
|
|
|
510
510
|
logger?.error("error with2: " + inFile);
|
|
511
511
|
if (CLEAR_JSX_CACHE) {
|
|
512
512
|
logger?.trace("clearing cache at [%s] to change this behaivor set CLEAR_JSX_CACHE to 0", tmpBuildDir);
|
|
513
|
-
|
|
514
|
-
|
|
513
|
+
await unlinkASync(inFileTmp);
|
|
514
|
+
await rmdirASync(tmpBuildDir);
|
|
515
515
|
} else {
|
|
516
516
|
//console.error("errors on: " + tmpBuildDir);
|
|
517
517
|
logger?.error("error with: %s", inFileTmp);
|
package/src/common/watch.ts
CHANGED
|
@@ -47,6 +47,7 @@ export async function watchAndServer(app: Miqro) {
|
|
|
47
47
|
}
|
|
48
48
|
|
|
49
49
|
function watchDir(toWatch: string) {
|
|
50
|
+
clearTimeout(timeout);
|
|
50
51
|
const files = existsSync(toWatch) ? readdirSync(toWatch) : [];
|
|
51
52
|
for (const file of files) {
|
|
52
53
|
const filePath = resolve(toWatch, file);
|
|
@@ -60,6 +61,7 @@ export async function watchAndServer(app: Miqro) {
|
|
|
60
61
|
}
|
|
61
62
|
|
|
62
63
|
function stopWatch() {
|
|
64
|
+
clearTimeout(timeout);
|
|
63
65
|
const toClose = watchers.splice(0, watchers.length);
|
|
64
66
|
for (const watcher of toClose) {
|
|
65
67
|
watcher.close();
|
|
@@ -69,6 +71,7 @@ export async function watchAndServer(app: Miqro) {
|
|
|
69
71
|
|
|
70
72
|
function reWatch() {
|
|
71
73
|
stopWatch();
|
|
74
|
+
clearTimeout(timeout);
|
|
72
75
|
for (const service of app.options.services) {
|
|
73
76
|
const toWatch = resolve(process.cwd(), service);
|
|
74
77
|
watchDir(toWatch);
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { Logger } from "@miqro/core";
|
|
2
|
-
import { chmodSync, constants, mkdirSync, writeFileSync } from "node:fs";
|
|
2
|
+
import { chmodSync, constants, mkdirSync, readFileSync, writeFileSync } from "node:fs";
|
|
3
3
|
import { basename, dirname, extname, join, relative, resolve } from "node:path";
|
|
4
4
|
import { cwd, platform } from "node:process";
|
|
5
5
|
|
|
6
6
|
import { RouteFileMap, StaticFileMap } from "./setup-http.js";
|
|
7
|
-
import { getAuthConfigPath, getCORSConfigPath, getDBConfigPath, getErrorConfigPath, getMiddlewareConfigPath, getMigrationsPath, getServerConfigPath, getServicePath, getWSConfigPath } from "../common/paths.js";
|
|
7
|
+
import { getAuthConfigPath, getCORSConfigPath, getDBConfigPath, getErrorConfigPath, getMiddlewareConfigPath, getMigrationsPath, getMiqroJSONPath, getServerConfigPath, getServicePath, getWSConfigPath } from "../common/paths.js";
|
|
8
8
|
import { getAsset } from "../common/assets.js";
|
|
9
9
|
import { migration } from "@miqro/query";
|
|
10
10
|
import { esBuild } from "../common/esbuild.js";
|
|
@@ -119,6 +119,10 @@ main().catch(e=>console.error(e));
|
|
|
119
119
|
platform: "node",
|
|
120
120
|
outfile: join(inflateDir, "sea", "app.bundle.cjs")
|
|
121
121
|
});
|
|
122
|
+
const miqroRCPath = getMiqroJSONPath();
|
|
123
|
+
if (miqroRCPath) {
|
|
124
|
+
writeFile(logger, join(inflateDir, "miqro.json"), readFileSync(miqroRCPath));
|
|
125
|
+
}
|
|
122
126
|
}
|
|
123
127
|
|
|
124
128
|
export async function inflateServiceForSea(logger: Logger, inflateDir: string, service: string, servicePath: string/*, serviceMigrations: string[]*/, serviceRouteFileMap: RouteFileMap, serviceStaticFileMap: StaticFileMap) {
|
package/src/inflate/inflate.ts
CHANGED
|
@@ -22,9 +22,10 @@ export interface InflateAppOptions {
|
|
|
22
22
|
hotreload?: boolean;
|
|
23
23
|
port: string;
|
|
24
24
|
serverInterface: ServerInterface;
|
|
25
|
+
inflateParallel?: number;
|
|
25
26
|
}
|
|
26
27
|
|
|
27
|
-
export async function inflateApp({ serverInterface, logger, hotreload, services/*, dbManager*/, inflateDir, inflateSea/*, editor, inflateTests*/, port }: InflateAppOptions): Promise<[Router, InflateError[] | null, RouteFileMap, WSConfig[]/*, ServerConfigMap*/, LogConfigMap]> {
|
|
28
|
+
export async function inflateApp({ inflateParallel, serverInterface, logger, hotreload, services/*, dbManager*/, inflateDir, inflateSea/*, editor, inflateTests*/, port }: InflateAppOptions): Promise<[Router, InflateError[] | null, RouteFileMap, WSConfig[]/*, ServerConfigMap*/, LogConfigMap]> {
|
|
28
29
|
logger.trace("inflateApp");
|
|
29
30
|
const errors: InflateError[] = [];
|
|
30
31
|
//const migrations: string[] = [];
|
|
@@ -69,7 +70,7 @@ export async function inflateApp({ serverInterface, logger, hotreload, services/
|
|
|
69
70
|
|
|
70
71
|
await setupLogConfig(logger, servicePath, service, logConfigMap, inflateSea ? inflateDir : false, errors);
|
|
71
72
|
|
|
72
|
-
router.use(await setupHTTPRouter(serverInterface, logger, hotreload ? hotreload : false, servicePath, service, serviceRouteFileMap, serviceStaticFileMap, inflateDir, inflateSea, errors));
|
|
73
|
+
router.use(await setupHTTPRouter(serverInterface, logger, hotreload ? hotreload : false, servicePath, service, serviceRouteFileMap, serviceStaticFileMap, inflateDir, inflateSea, errors, inflateParallel));
|
|
73
74
|
routeFileMap = {
|
|
74
75
|
...routeFileMap,
|
|
75
76
|
...serviceRouteFileMap
|