miqro 7.0.10 → 7.2.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 +92 -24
- package/build/esm/editor/auth.js +1 -0
- package/build/esm/editor/auth.js.map +1 -0
- package/build/esm/editor/common/admin-interface.js +1 -0
- package/build/esm/editor/common/admin-interface.js.map +1 -0
- package/build/esm/editor/common/constants.js +1 -0
- package/build/esm/editor/common/constants.js.map +1 -0
- package/build/esm/editor/common/constants.server.js +1 -0
- package/build/esm/editor/common/constants.server.js.map +1 -0
- package/build/esm/editor/common/editor-index.js +1 -0
- package/build/esm/editor/common/editor-index.js.map +1 -0
- package/build/esm/editor/common/html-encode.js +1 -0
- package/build/esm/editor/common/html-encode.js.map +1 -0
- package/build/esm/editor/common/log-socket.js +1 -0
- package/build/esm/editor/common/log-socket.js.map +1 -0
- package/build/esm/editor/common/templates.js +1 -0
- package/build/esm/editor/common/templates.js.map +1 -0
- package/build/esm/editor/components/api-preview.js +1 -0
- package/build/esm/editor/components/api-preview.js.map +1 -0
- package/build/esm/editor/components/editor.js +1 -0
- package/build/esm/editor/components/editor.js.map +1 -0
- package/build/esm/editor/components/file-browser.js +1 -0
- package/build/esm/editor/components/file-browser.js.map +1 -0
- package/build/esm/editor/components/file-editor-toolbar.js +1 -0
- package/build/esm/editor/components/file-editor-toolbar.js.map +1 -0
- package/build/esm/editor/components/file-editor.js +1 -0
- package/build/esm/editor/components/file-editor.js.map +1 -0
- package/build/esm/editor/components/filter-query.js +1 -0
- package/build/esm/editor/components/filter-query.js.map +1 -0
- package/build/esm/editor/components/highlight-text-area.js +1 -0
- package/build/esm/editor/components/highlight-text-area.js.map +1 -0
- package/build/esm/editor/components/log-viewer.js +1 -0
- package/build/esm/editor/components/log-viewer.js.map +1 -0
- package/build/esm/editor/components/new-file.js +1 -0
- package/build/esm/editor/components/new-file.js.map +1 -0
- package/build/esm/editor/components/scroll-query.js +1 -0
- package/build/esm/editor/components/scroll-query.js.map +1 -0
- package/build/esm/editor/components/start-page.js +1 -0
- package/build/esm/editor/components/start-page.js.map +1 -0
- package/build/esm/editor/http/admin/editor/api/fs/delete.api.js +1 -0
- package/build/esm/editor/http/admin/editor/api/fs/delete.api.js.map +1 -0
- package/build/esm/editor/http/admin/editor/api/fs/read.api.js +1 -0
- package/build/esm/editor/http/admin/editor/api/fs/read.api.js.map +1 -0
- package/build/esm/editor/http/admin/editor/api/fs/rename.api.js +1 -0
- package/build/esm/editor/http/admin/editor/api/fs/rename.api.js.map +1 -0
- package/build/esm/editor/http/admin/editor/api/fs/scan.api.js +1 -0
- package/build/esm/editor/http/admin/editor/api/fs/scan.api.js.map +1 -0
- package/build/esm/editor/http/admin/editor/api/fs/write.api.js +1 -0
- package/build/esm/editor/http/admin/editor/api/fs/write.api.js.map +1 -0
- package/build/esm/editor/http/admin/editor/api/server/reload.api.js +1 -0
- package/build/esm/editor/http/admin/editor/api/server/reload.api.js.map +1 -0
- package/build/esm/editor/http/admin/editor/api/server/restart.api.js +1 -0
- package/build/esm/editor/http/admin/editor/api/server/restart.api.js.map +1 -0
- package/build/esm/editor/http/admin/editor/editor.js +1 -0
- package/build/esm/editor/http/admin/editor/editor.js.map +1 -0
- package/build/esm/editor/http/admin/editor/index.api.js +1 -0
- package/build/esm/editor/http/admin/editor/index.api.js.map +1 -0
- package/build/esm/editor/server.js +1 -0
- package/build/esm/editor/server.js.map +1 -0
- package/build/esm/editor/ws.js +1 -0
- package/build/esm/editor/ws.js.map +1 -0
- package/build/esm/src/bin/compile.js +1 -0
- package/build/esm/src/bin/compile.js.map +1 -0
- package/build/esm/src/bin/doc-md.js +1 -0
- package/build/esm/src/bin/doc-md.js.map +1 -0
- package/build/esm/src/bin/generate-doc.js +1 -0
- package/build/esm/src/bin/generate-doc.js.map +1 -0
- package/build/esm/src/bin/test.d.ts +2 -1
- package/build/esm/src/bin/test.js +3 -2
- package/build/esm/src/bin/test.js.map +1 -0
- package/build/esm/src/bin/types.js +1 -0
- package/build/esm/src/bin/types.js.map +1 -0
- package/build/esm/src/cluster.js +1 -0
- package/build/esm/src/cluster.js.map +1 -0
- package/build/esm/src/common/arguments.d.ts +8 -0
- package/build/esm/src/common/arguments.js +78 -1
- package/build/esm/src/common/arguments.js.map +1 -0
- package/build/esm/src/common/assets.d.ts +1 -1
- package/build/esm/src/common/assets.js +2 -1
- package/build/esm/src/common/assets.js.map +1 -0
- package/build/esm/src/common/checksum.js +1 -0
- package/build/esm/src/common/checksum.js.map +1 -0
- package/build/esm/src/common/constants.d.ts +1 -0
- package/build/esm/src/common/constants.js +2 -0
- package/build/esm/src/common/constants.js.map +1 -0
- package/build/esm/src/common/content-type.js +1 -0
- package/build/esm/src/common/content-type.js.map +1 -0
- package/build/esm/src/common/esbuild.js +1 -0
- package/build/esm/src/common/esbuild.js.map +1 -0
- package/build/esm/src/common/exit.js +1 -0
- package/build/esm/src/common/exit.js.map +1 -0
- package/build/esm/src/common/fs.js +1 -0
- package/build/esm/src/common/fs.js.map +1 -0
- package/build/esm/src/common/help.d.ts +1 -1
- package/build/esm/src/common/help.js +7 -1
- package/build/esm/src/common/help.js.map +1 -0
- package/build/esm/src/common/jsx.d.ts +20 -16
- package/build/esm/src/common/jsx.js +34 -29
- package/build/esm/src/common/jsx.js.map +1 -0
- package/build/esm/src/common/jwt.js +1 -0
- package/build/esm/src/common/jwt.js.map +1 -0
- package/build/esm/src/common/paths.js +1 -0
- package/build/esm/src/common/paths.js.map +1 -0
- package/build/esm/src/common/watch.js +1 -0
- package/build/esm/src/common/watch.js.map +1 -0
- package/build/esm/src/inflate/inflate-sea.js +16 -15
- package/build/esm/src/inflate/inflate-sea.js.map +1 -0
- package/build/esm/src/inflate/inflate.d.ts +5 -1
- package/build/esm/src/inflate/inflate.js +6 -5
- package/build/esm/src/inflate/inflate.js.map +1 -0
- package/build/esm/src/inflate/md.js +1 -0
- package/build/esm/src/inflate/md.js.map +1 -0
- package/build/esm/src/inflate/setup-auth.d.ts +2 -2
- package/build/esm/src/inflate/setup-auth.js +3 -2
- package/build/esm/src/inflate/setup-auth.js.map +1 -0
- package/build/esm/src/inflate/setup-cors.d.ts +2 -2
- package/build/esm/src/inflate/setup-cors.js +3 -2
- package/build/esm/src/inflate/setup-cors.js.map +1 -0
- package/build/esm/src/inflate/setup-db.d.ts +3 -3
- package/build/esm/src/inflate/setup-db.js +6 -5
- package/build/esm/src/inflate/setup-db.js.map +1 -0
- package/build/esm/src/inflate/setup-error.d.ts +2 -2
- package/build/esm/src/inflate/setup-error.js +3 -2
- package/build/esm/src/inflate/setup-error.js.map +1 -0
- package/build/esm/src/inflate/setup-http.d.ts +7 -2
- package/build/esm/src/inflate/setup-http.js +54 -45
- package/build/esm/src/inflate/setup-http.js.map +1 -0
- package/build/esm/src/inflate/setup-log.d.ts +2 -2
- package/build/esm/src/inflate/setup-log.js +3 -2
- package/build/esm/src/inflate/setup-log.js.map +1 -0
- package/build/esm/src/inflate/setup-middleware.d.ts +2 -2
- package/build/esm/src/inflate/setup-middleware.js +3 -2
- package/build/esm/src/inflate/setup-middleware.js.map +1 -0
- package/build/esm/src/inflate/setup-server-config.d.ts +2 -2
- package/build/esm/src/inflate/setup-server-config.js +3 -2
- package/build/esm/src/inflate/setup-server-config.js.map +1 -0
- package/build/esm/src/inflate/setup-test.d.ts +2 -1
- package/build/esm/src/inflate/setup-test.js +3 -2
- package/build/esm/src/inflate/setup-test.js.map +1 -0
- package/build/esm/src/inflate/setup-ws.d.ts +2 -2
- package/build/esm/src/inflate/setup-ws.js +3 -2
- package/build/esm/src/inflate/setup-ws.js.map +1 -0
- package/build/esm/src/inflate/setup.doc.d.ts +2 -2
- package/build/esm/src/inflate/setup.doc.js +5 -4
- package/build/esm/src/inflate/setup.doc.js.map +1 -0
- package/build/esm/src/inflate/utils/sea-utils.js +1 -0
- package/build/esm/src/inflate/utils/sea-utils.js.map +1 -0
- package/build/esm/src/lib.js +1 -0
- package/build/esm/src/lib.js.map +1 -0
- package/build/esm/src/main.js +9 -2
- package/build/esm/src/main.js.map +1 -0
- package/build/esm/src/services/app.d.ts +5 -2
- package/build/esm/src/services/app.js +19 -6
- package/build/esm/src/services/app.js.map +1 -0
- package/build/esm/src/services/editor.js +1 -0
- package/build/esm/src/services/editor.js.map +1 -0
- package/build/esm/src/services/hot-reload.d.ts +1 -0
- package/build/esm/src/services/hot-reload.js +9 -5
- package/build/esm/src/services/hot-reload.js.map +1 -0
- package/build/esm/src/services/migrations.d.ts +3 -2
- package/build/esm/src/services/migrations.js +5 -4
- package/build/esm/src/services/migrations.js.map +1 -0
- package/build/esm/src/services/utils/admin-interface.js +1 -0
- package/build/esm/src/services/utils/admin-interface.js.map +1 -0
- package/build/esm/src/services/utils/cache.js +1 -0
- package/build/esm/src/services/utils/cache.js.map +1 -0
- package/build/esm/src/services/utils/cluster-cache.js +1 -0
- package/build/esm/src/services/utils/cluster-cache.js.map +1 -0
- package/build/esm/src/services/utils/cluster-ws.js +1 -0
- package/build/esm/src/services/utils/cluster-ws.js.map +1 -0
- package/build/esm/src/services/utils/db-manager.js +1 -0
- package/build/esm/src/services/utils/db-manager.js.map +1 -0
- package/build/esm/src/services/utils/get-route.js +1 -0
- package/build/esm/src/services/utils/get-route.js.map +1 -0
- package/build/esm/src/services/utils/jwt.js +1 -0
- package/build/esm/src/services/utils/jwt.js.map +1 -0
- package/build/esm/src/services/utils/log-transport.js +1 -0
- package/build/esm/src/services/utils/log-transport.js.map +1 -0
- package/build/esm/src/services/utils/log.js +1 -0
- package/build/esm/src/services/utils/log.js.map +1 -0
- package/build/esm/src/services/utils/middleware.js +1 -0
- package/build/esm/src/services/utils/middleware.js.map +1 -0
- package/build/esm/src/services/utils/server-interface.js +1 -0
- package/build/esm/src/services/utils/server-interface.js.map +1 -0
- package/build/esm/src/services/utils/websocketmanager.js +1 -0
- package/build/esm/src/services/utils/websocketmanager.js.map +1 -0
- package/build/esm/src/types.js +1 -0
- package/build/esm/src/types.js.map +1 -0
- package/build/lib.cjs +239 -150
- package/package.json +5 -5
- package/sea/install-esbuild.sh +1 -1
- package/sea/install-nodejs.sh +1 -1
- package/sea/node.version.tag +1 -1
- package/src/bin/test.ts +3 -2
- package/src/common/arguments.ts +92 -1
- package/src/common/assets.ts +2 -2
- package/src/common/constants.ts +1 -0
- package/src/common/help.ts +6 -1
- package/src/common/jsx.ts +41 -30
- package/src/inflate/inflate-sea.ts +15 -15
- package/src/inflate/inflate.ts +9 -5
- package/src/inflate/setup-auth.ts +3 -3
- package/src/inflate/setup-cors.ts +4 -3
- package/src/inflate/setup-db.ts +6 -6
- package/src/inflate/setup-error.ts +3 -3
- package/src/inflate/setup-http.ts +61 -45
- package/src/inflate/setup-log.ts +3 -3
- package/src/inflate/setup-middleware.ts +3 -3
- package/src/inflate/setup-server-config.ts +3 -3
- package/src/inflate/setup-test.ts +3 -3
- package/src/inflate/setup-ws.ts +3 -3
- package/src/inflate/setup.doc.ts +5 -5
- package/src/main.ts +8 -2
- package/src/services/app.ts +24 -9
- package/src/services/hot-reload.ts +9 -5
- package/src/services/migrations.ts +5 -5
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "miqro",
|
|
3
|
-
"version": "7.0
|
|
3
|
+
"version": "7.2.0",
|
|
4
4
|
"description": "",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "build/esm/src/lib.js",
|
|
@@ -34,10 +34,10 @@
|
|
|
34
34
|
"miqro-cluster": "build/esm/src/cluster.js"
|
|
35
35
|
},
|
|
36
36
|
"devDependencies": {
|
|
37
|
-
"@types/node": "^
|
|
37
|
+
"@types/node": "^24.9.1",
|
|
38
38
|
"@types/showdown": "2.0.6",
|
|
39
39
|
"highlight.js": "11.11.1",
|
|
40
|
-
"typescript": "^5.
|
|
40
|
+
"typescript": "^5.9.3"
|
|
41
41
|
},
|
|
42
42
|
"dependencies": {
|
|
43
43
|
"postject": "1.0.0-alpha.6",
|
|
@@ -50,8 +50,8 @@
|
|
|
50
50
|
"@miqro/runner": "^2.0.1",
|
|
51
51
|
"@miqro/test": "^0.2.9",
|
|
52
52
|
"@miqro/test-http": "^0.1.2",
|
|
53
|
-
"esbuild": "0.25.
|
|
54
|
-
"jose": "6.0
|
|
53
|
+
"esbuild": "0.25.11",
|
|
54
|
+
"jose": "6.1.0",
|
|
55
55
|
"showdown": "2.1.0"
|
|
56
56
|
}
|
|
57
57
|
}
|
package/sea/install-esbuild.sh
CHANGED
package/sea/install-nodejs.sh
CHANGED
package/sea/node.version.tag
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
25.0.0
|
package/src/bin/test.ts
CHANGED
|
@@ -8,8 +8,9 @@ import { RuntimeOptions, RuntimeShadowRootInit, RuntimeURL } from "@miqro/jsx";
|
|
|
8
8
|
import { EXIT_CODES } from "../common/constants.js";
|
|
9
9
|
import { Miqro } from "../services/app.js";
|
|
10
10
|
import { setupTests } from "../inflate/setup-test.js";
|
|
11
|
+
import { ImportJSXFileOptions } from "../common/jsx.js";
|
|
11
12
|
|
|
12
|
-
export async function testMain(app: Miqro) {
|
|
13
|
+
export async function testMain(app: Miqro, options: ImportJSXFileOptions) {
|
|
13
14
|
const startMS = Date.now();
|
|
14
15
|
//resetTests();
|
|
15
16
|
resetGlobals();
|
|
@@ -51,7 +52,7 @@ export async function testMain(app: Miqro) {
|
|
|
51
52
|
|
|
52
53
|
for (const service of app.options.services) {
|
|
53
54
|
const servicePath = getServicePath(service);
|
|
54
|
-
await setupTests(app.logger, servicePath);
|
|
55
|
+
await setupTests(app.logger, servicePath, options);
|
|
55
56
|
}
|
|
56
57
|
|
|
57
58
|
console.log("");
|
package/src/common/arguments.ts
CHANGED
|
@@ -28,6 +28,10 @@ interface MiqroJSON {
|
|
|
28
28
|
serverOptions?: ServerOptions;
|
|
29
29
|
httpsRedirect?: number;
|
|
30
30
|
inflateParallel?: number;
|
|
31
|
+
noBuild?: boolean;
|
|
32
|
+
noMinify?: boolean;
|
|
33
|
+
inflateOnlyAssets?: boolean;
|
|
34
|
+
inflateFlat?: boolean;
|
|
31
35
|
}
|
|
32
36
|
|
|
33
37
|
const MiqroJSONSchema: Schema<MiqroJSON> = {
|
|
@@ -35,6 +39,10 @@ const MiqroJSONSchema: Schema<MiqroJSON> = {
|
|
|
35
39
|
properties: {
|
|
36
40
|
name: "string?",
|
|
37
41
|
services: "string[]?",
|
|
42
|
+
noBuild: "boolean?",
|
|
43
|
+
noMinify: "boolean?",
|
|
44
|
+
inflateOnlyAssets: "boolean?",
|
|
45
|
+
inflateFlat: "boolean?",
|
|
38
46
|
port: "number?|string?",
|
|
39
47
|
inflateDir: "string?",
|
|
40
48
|
browser: "boolean?|string?",
|
|
@@ -62,7 +70,11 @@ export function getPORT() {
|
|
|
62
70
|
}
|
|
63
71
|
|
|
64
72
|
export interface Arguments {
|
|
73
|
+
inflateOnlyAssets?: boolean;
|
|
74
|
+
inflateFlat?: boolean;
|
|
65
75
|
name?: string;
|
|
76
|
+
noBuild?: boolean;
|
|
77
|
+
noMinify?: boolean;
|
|
66
78
|
browser?: string | boolean;
|
|
67
79
|
logFile?: string | boolean;
|
|
68
80
|
// installTypes: boolean;
|
|
@@ -130,7 +142,13 @@ export function parseArguments(): Arguments {
|
|
|
130
142
|
inflateDir?: string | null;
|
|
131
143
|
hotreload?: boolean | null;
|
|
132
144
|
watch?: boolean | null;
|
|
145
|
+
noBuild?: boolean | null;
|
|
146
|
+
noMinify?: boolean | null;
|
|
147
|
+
inflateOnlyAssets?: boolean | null;
|
|
148
|
+
inflateFlat?: boolean | null;
|
|
133
149
|
} = {
|
|
150
|
+
inflateFlat: null,
|
|
151
|
+
inflateOnlyAssets: null,
|
|
134
152
|
inflateParallel: null,
|
|
135
153
|
httpsRedirect: null,
|
|
136
154
|
https: null,
|
|
@@ -151,6 +169,8 @@ export function parseArguments(): Arguments {
|
|
|
151
169
|
migrateDown: null,
|
|
152
170
|
inflateSEA: null,
|
|
153
171
|
compile: null,
|
|
172
|
+
noBuild: null,
|
|
173
|
+
noMinify: null,
|
|
154
174
|
test: null,
|
|
155
175
|
inflate: null,
|
|
156
176
|
generateDoc: null,
|
|
@@ -208,6 +228,38 @@ export function parseArguments(): Arguments {
|
|
|
208
228
|
}
|
|
209
229
|
i++;
|
|
210
230
|
continue;
|
|
231
|
+
case "--inflate-only-assets":
|
|
232
|
+
if (flags.inflateOnlyAssets !== null) {
|
|
233
|
+
console.error("bad arguments.");
|
|
234
|
+
console.error(usage);
|
|
235
|
+
process.exit(EXIT_CODES.BAD_ARGUMENTS);
|
|
236
|
+
}
|
|
237
|
+
flags.inflateOnlyAssets = true;
|
|
238
|
+
continue;
|
|
239
|
+
case "--inflate-flat":
|
|
240
|
+
if (flags.inflateFlat !== null) {
|
|
241
|
+
console.error("bad arguments.");
|
|
242
|
+
console.error(usage);
|
|
243
|
+
process.exit(EXIT_CODES.BAD_ARGUMENTS);
|
|
244
|
+
}
|
|
245
|
+
flags.inflateFlat = true;
|
|
246
|
+
continue;
|
|
247
|
+
case "--no-minify":
|
|
248
|
+
if (flags.noMinify !== null) {
|
|
249
|
+
console.error("bad arguments.");
|
|
250
|
+
console.error(usage);
|
|
251
|
+
process.exit(EXIT_CODES.BAD_ARGUMENTS);
|
|
252
|
+
}
|
|
253
|
+
flags.noMinify = true;
|
|
254
|
+
continue;
|
|
255
|
+
case "--no-build":
|
|
256
|
+
if (flags.noBuild !== null) {
|
|
257
|
+
console.error("bad arguments.");
|
|
258
|
+
console.error(usage);
|
|
259
|
+
process.exit(EXIT_CODES.BAD_ARGUMENTS);
|
|
260
|
+
}
|
|
261
|
+
flags.noBuild = true;
|
|
262
|
+
continue;
|
|
211
263
|
case "--install-tsconfig":
|
|
212
264
|
if (flags.inflate !== null || flags.installTSConfig !== null) {
|
|
213
265
|
console.error("bad arguments.");
|
|
@@ -562,6 +614,26 @@ export function parseArguments(): Arguments {
|
|
|
562
614
|
}
|
|
563
615
|
}
|
|
564
616
|
}
|
|
617
|
+
if (flags.noBuild === null) {
|
|
618
|
+
if (miqroRC.noBuild !== undefined) {
|
|
619
|
+
flags.noBuild = miqroRC.noBuild;
|
|
620
|
+
}
|
|
621
|
+
}
|
|
622
|
+
if (flags.inflateFlat === null) {
|
|
623
|
+
if (miqroRC.inflateFlat !== undefined) {
|
|
624
|
+
flags.inflateFlat = miqroRC.inflateFlat;
|
|
625
|
+
}
|
|
626
|
+
}
|
|
627
|
+
if (flags.inflateOnlyAssets === null) {
|
|
628
|
+
if (miqroRC.inflateOnlyAssets !== undefined) {
|
|
629
|
+
flags.inflateOnlyAssets = miqroRC.inflateOnlyAssets;
|
|
630
|
+
}
|
|
631
|
+
}
|
|
632
|
+
if (flags.noMinify === null) {
|
|
633
|
+
if (miqroRC.noMinify !== undefined) {
|
|
634
|
+
flags.noMinify = miqroRC.noMinify;
|
|
635
|
+
}
|
|
636
|
+
}
|
|
565
637
|
if (flags.https === null) {
|
|
566
638
|
if (miqroRC.https) {
|
|
567
639
|
flags.https = miqroRC.https;
|
|
@@ -596,7 +668,7 @@ export function parseArguments(): Arguments {
|
|
|
596
668
|
}
|
|
597
669
|
if (!flags.inflateDir && flags.inflate) {
|
|
598
670
|
if (miqroRC.inflateDir) {
|
|
599
|
-
flags.inflateDir = miqroRC.inflateDir;
|
|
671
|
+
flags.inflateDir = join(relative(cwd(), dirname(miqroJSONPath)), miqroRC.inflateDir);
|
|
600
672
|
}
|
|
601
673
|
}
|
|
602
674
|
if (flags.name === null) {
|
|
@@ -681,6 +753,21 @@ export function parseArguments(): Arguments {
|
|
|
681
753
|
process.exit(EXIT_CODES.BAD_ARGUMENTS);
|
|
682
754
|
}
|
|
683
755
|
|
|
756
|
+
if (flags.inflateFlat && !flags.inflate) {
|
|
757
|
+
console.error("bad arguments. cannot use --inflate-flat without --inflate");
|
|
758
|
+
process.exit(EXIT_CODES.BAD_ARGUMENTS);
|
|
759
|
+
}
|
|
760
|
+
|
|
761
|
+
if (flags.inflateOnlyAssets && !flags.inflate) {
|
|
762
|
+
console.error("bad arguments. cannot use --inflate-only-assets without --inflate");
|
|
763
|
+
process.exit(EXIT_CODES.BAD_ARGUMENTS);
|
|
764
|
+
}
|
|
765
|
+
|
|
766
|
+
if (flags.inflateOnlyAssets && flags.inflateSEA) {
|
|
767
|
+
console.error("bad arguments. cannot use --inflate-only-assets with --inflate-sea");
|
|
768
|
+
process.exit(EXIT_CODES.BAD_ARGUMENTS);
|
|
769
|
+
}
|
|
770
|
+
|
|
684
771
|
if (flags.editor && (/*flags.installTypes || */flags.installTSConfig || flags.installMiqroJSON)) {
|
|
685
772
|
console.error("bad arguments. cannot use --editor with--install-types, --install-tsconfig or --install-miqrojson");
|
|
686
773
|
process.exit(EXIT_CODES.BAD_ARGUMENTS);
|
|
@@ -729,6 +816,10 @@ export function parseArguments(): Arguments {
|
|
|
729
816
|
}
|
|
730
817
|
|
|
731
818
|
return {
|
|
819
|
+
inflateFlat: flags.inflateFlat === null ? false : flags.inflateFlat,
|
|
820
|
+
inflateOnlyAssets: flags.inflateOnlyAssets === null ? undefined : flags.inflateOnlyAssets,
|
|
821
|
+
noMinify: flags.noMinify === null ? false : flags.noMinify,
|
|
822
|
+
noBuild: flags.noBuild === null ? false : flags.noBuild,
|
|
732
823
|
inflateParallel: flags.inflateParallel ? flags.inflateParallel : undefined,
|
|
733
824
|
name: flags.name ? flags.name : undefined,
|
|
734
825
|
browser: flags.browser !== null ? flags.browser : undefined,
|
package/src/common/assets.ts
CHANGED
|
@@ -34,9 +34,9 @@ const ASSETS_ROUTER = {
|
|
|
34
34
|
"editor-assets/font.ttf": "build/font.ttf"
|
|
35
35
|
}
|
|
36
36
|
|
|
37
|
-
export function getAsset(key: string):
|
|
37
|
+
export function getAsset(key: string): Buffer {
|
|
38
38
|
if (isSea()) {
|
|
39
|
-
return seaGetAsset(key);
|
|
39
|
+
return Buffer.from(seaGetAsset(key));
|
|
40
40
|
} else {
|
|
41
41
|
if (!ASSETS_ROUTER[key]) {
|
|
42
42
|
if (key === "esbuild-binary") {
|
package/src/common/constants.ts
CHANGED
|
@@ -12,6 +12,7 @@ export const CLEAR_JSX_CACHE = (process.env["CLEAR_JSX_CACHE"] !== undefined ? p
|
|
|
12
12
|
export const EDITOR_CONFIG_KEY = "$$editor$$";
|
|
13
13
|
|
|
14
14
|
export const HOT_RELOAD_PATH = "/hot-reload";
|
|
15
|
+
export const HOT_RELOAD_SCRIPT_PATH = "/hot-reload.js";
|
|
15
16
|
|
|
16
17
|
//export const SERVER_IDENTIFIER = cluster.isPrimary ? "SERVER" : process.env["CLUSTER_NODE_NUMBER"] ? `WORKER_${process.env["CLUSTER_NODE_NUMBER"]}` : "WORKER";
|
|
17
18
|
|
package/src/common/help.ts
CHANGED
|
@@ -23,7 +23,7 @@ export const help = `
|
|
|
23
23
|
--test\n\trun the tests for a service.
|
|
24
24
|
--migrate-up\n\tmigrations up.
|
|
25
25
|
--migrate-down\n\tmigrations down.
|
|
26
|
-
--inflate\n\tinflates the application.
|
|
26
|
+
--inflate\n\tinflates the application into a directory using esbuild.
|
|
27
27
|
--inflate-dir\n\tto set the output directory of the --inflate command. default value is inflated/.
|
|
28
28
|
--editor\n\truns the application with a built-in editor.
|
|
29
29
|
--generate-doc\n\tgenerates a documentation for the api endpoints of the service.
|
|
@@ -31,9 +31,14 @@ export const help = `
|
|
|
31
31
|
--generate-doc-type\n\tthe format of the generated documentation. it can be JSON or MD. default value is MD.
|
|
32
32
|
--generate-doc-all\n\toutputs all the server routes in the documentation output.
|
|
33
33
|
--compile\n\tinflates the application and tries to create a NODE SEA binary.
|
|
34
|
+
--no-build\n\tdisables calling esbuild during imports in runtime. Notice that to use jsx you will need to run tsc or esbuild on your jsx files to transpile them to js.
|
|
35
|
+
--no-minify\n\tdisables calling minifing min.js files.
|
|
36
|
+
--inflate-only-assets\n\tinflates ONLY the application assets. must be used with --inflate.
|
|
37
|
+
--inflate-flat\n\tinflates files into the inflate-dir directly.
|
|
34
38
|
--inflate-sea\n\tinflates the application with sea compilation scripts.
|
|
35
39
|
--install-tsconfig\n\tcreates a tsconfig.json configured to use with --install-types.
|
|
36
40
|
--install-miqrojson\n\tcreates a default miqro.json file.
|
|
41
|
+
--install\n\tcreates a node_modules folder from binary cache (only available in sea binary).
|
|
37
42
|
--disable-miqrojson\n\tdisables the load of miqro.json file.
|
|
38
43
|
--log-file\n\toverrides the default log file from LOG_FILE.
|
|
39
44
|
--browser\n\toverrides the default browser from BROWSER.
|
package/src/common/jsx.ts
CHANGED
|
@@ -46,7 +46,7 @@ export interface InflateError {
|
|
|
46
46
|
error: Error;
|
|
47
47
|
}
|
|
48
48
|
|
|
49
|
-
|
|
49
|
+
interface InflateOptions {
|
|
50
50
|
// embemedJSX: boolean;
|
|
51
51
|
minify: boolean;
|
|
52
52
|
useExport: boolean;
|
|
@@ -331,9 +331,9 @@ export const DocConfigSchema: Schema<DocConfig> = {
|
|
|
331
331
|
}
|
|
332
332
|
}
|
|
333
333
|
|
|
334
|
-
export async function importAPIRoute(inFile: string, logger?: Logger) {
|
|
334
|
+
export async function importAPIRoute(inFile: string, options: ImportJSXFileOptions, logger?: Logger) {
|
|
335
335
|
const isCJS = extname(inFile) === ".cjs";
|
|
336
|
-
const mod = isCJS ? (await importJSXFile(inFile, logger)).default.default : (await importJSXFile(inFile, logger)).default;
|
|
336
|
+
const mod = isCJS ? (await importJSXFile(inFile, options, logger)).default.default : (await importJSXFile(inFile, options, logger)).default;
|
|
337
337
|
const module = typeof mod === "function" ? { handler: mod } : parser.parse(mod, APIRouteSchema, basename(inFile));
|
|
338
338
|
if (module !== undefined) {
|
|
339
339
|
return module as APIRoute;
|
|
@@ -342,9 +342,9 @@ export async function importAPIRoute(inFile: string, logger?: Logger) {
|
|
|
342
342
|
}
|
|
343
343
|
}
|
|
344
344
|
|
|
345
|
-
export async function importMigrationModule(inFile: string, logger?: Logger) {
|
|
345
|
+
export async function importMigrationModule(inFile: string, options: ImportJSXFileOptions, logger?: Logger) {
|
|
346
346
|
const isCJS = extname(inFile) === ".cjs";
|
|
347
|
-
const mod = isCJS ? (await importJSXFile(inFile, logger)).default.default : (await importJSXFile(inFile, logger)).default;
|
|
347
|
+
const mod = isCJS ? (await importJSXFile(inFile, options, logger)).default.default : (await importJSXFile(inFile, options, logger)).default;
|
|
348
348
|
const module = parser.parse(mod, MigrationSchema, basename(inFile));
|
|
349
349
|
if (module !== undefined) {
|
|
350
350
|
return module;
|
|
@@ -353,8 +353,8 @@ export async function importMigrationModule(inFile: string, logger?: Logger) {
|
|
|
353
353
|
}
|
|
354
354
|
}
|
|
355
355
|
|
|
356
|
-
export async function importHTMLModule(inFile: string, logger?: Logger) {
|
|
357
|
-
const module = (await importJSXFile(inFile, logger));
|
|
356
|
+
export async function importHTMLModule(inFile: string, options: ImportJSXFileOptions, logger?: Logger) {
|
|
357
|
+
const module = (await importJSXFile(inFile, options, logger));
|
|
358
358
|
parser.parse(module.default, HTMLModuleSchema.properties.default, `${basename(inFile)}.default`);
|
|
359
359
|
parser.parse(module.apiOptions, APIOptionsSchema, `${basename(inFile)}.apiOptions`);
|
|
360
360
|
if (module !== undefined) {
|
|
@@ -364,8 +364,8 @@ export async function importHTMLModule(inFile: string, logger?: Logger) {
|
|
|
364
364
|
}
|
|
365
365
|
}
|
|
366
366
|
|
|
367
|
-
export async function importJSONModule(inFile: string, logger?: Logger) {
|
|
368
|
-
const module = (await importJSXFile(inFile, logger));
|
|
367
|
+
export async function importJSONModule(inFile: string, options: ImportJSXFileOptions, logger?: Logger) {
|
|
368
|
+
const module = (await importJSXFile(inFile, options, logger));
|
|
369
369
|
parser.parse(module.default, JSONModuleSchema.properties.default, `${basename(inFile)}.default`);
|
|
370
370
|
parser.parse(module.apiOptions, APIOptionsSchema, `${basename(inFile)}.apiOptions`);
|
|
371
371
|
if (module !== undefined) {
|
|
@@ -375,9 +375,9 @@ export async function importJSONModule(inFile: string, logger?: Logger) {
|
|
|
375
375
|
}
|
|
376
376
|
}
|
|
377
377
|
|
|
378
|
-
export async function importAuthModule(inFile: string, logger?: Logger) {
|
|
378
|
+
export async function importAuthModule(inFile: string, options: ImportJSXFileOptions, logger?: Logger) {
|
|
379
379
|
const isCJS = extname(inFile) === ".cjs";
|
|
380
|
-
const mod = isCJS ? (await importJSXFile(inFile, logger)).default.default : (await importJSXFile(inFile, logger)).default;
|
|
380
|
+
const mod = isCJS ? (await importJSXFile(inFile, options, logger)).default.default : (await importJSXFile(inFile, options, logger)).default;
|
|
381
381
|
|
|
382
382
|
const module = parser.parse(mod, AuthConfigSchema, basename(inFile));
|
|
383
383
|
if (module !== undefined) {
|
|
@@ -387,9 +387,9 @@ export async function importAuthModule(inFile: string, logger?: Logger) {
|
|
|
387
387
|
}
|
|
388
388
|
}
|
|
389
389
|
|
|
390
|
-
export async function importMiddlewareConfigModule(inFile: string, logger?: Logger) {
|
|
390
|
+
export async function importMiddlewareConfigModule(inFile: string, options: ImportJSXFileOptions, logger?: Logger) {
|
|
391
391
|
const isCJS = extname(inFile) === ".cjs";
|
|
392
|
-
const mod = isCJS ? (await importJSXFile(inFile, logger)).default.default : (await importJSXFile(inFile, logger)).default;
|
|
392
|
+
const mod = isCJS ? (await importJSXFile(inFile, options, logger)).default.default : (await importJSXFile(inFile, options, logger)).default;
|
|
393
393
|
|
|
394
394
|
const module = parser.parse(mod, MiddlewareConfigSchema, basename(inFile));
|
|
395
395
|
if (module !== undefined) {
|
|
@@ -399,9 +399,9 @@ export async function importMiddlewareConfigModule(inFile: string, logger?: Logg
|
|
|
399
399
|
}
|
|
400
400
|
}
|
|
401
401
|
|
|
402
|
-
export async function importErrorConfigModule(inFile: string, logger?: Logger) {
|
|
402
|
+
export async function importErrorConfigModule(inFile: string, options: ImportJSXFileOptions, logger?: Logger) {
|
|
403
403
|
const isCJS = extname(inFile) === ".cjs";
|
|
404
|
-
const mod = isCJS ? (await importJSXFile(inFile, logger)).default.default : (await importJSXFile(inFile, logger)).default;
|
|
404
|
+
const mod = isCJS ? (await importJSXFile(inFile, options, logger)).default.default : (await importJSXFile(inFile, options, logger)).default;
|
|
405
405
|
|
|
406
406
|
const module = parser.parse(mod, ErrorConfigSchema, basename(inFile));
|
|
407
407
|
if (module !== undefined) {
|
|
@@ -411,9 +411,9 @@ export async function importErrorConfigModule(inFile: string, logger?: Logger) {
|
|
|
411
411
|
}
|
|
412
412
|
}
|
|
413
413
|
|
|
414
|
-
export async function importDocConfigModule(inFile: string, logger?: Logger) {
|
|
414
|
+
export async function importDocConfigModule(inFile: string, options: ImportJSXFileOptions, logger?: Logger) {
|
|
415
415
|
const isCJS = extname(inFile) === ".cjs";
|
|
416
|
-
const mod = isCJS ? (await importJSXFile(inFile, logger)).default.default : (await importJSXFile(inFile, logger)).default;
|
|
416
|
+
const mod = isCJS ? (await importJSXFile(inFile, options, logger)).default.default : (await importJSXFile(inFile, options, logger)).default;
|
|
417
417
|
|
|
418
418
|
const module = parser.parse(mod, DocConfigSchema, basename(inFile));
|
|
419
419
|
if (module !== undefined) {
|
|
@@ -423,9 +423,9 @@ export async function importDocConfigModule(inFile: string, logger?: Logger) {
|
|
|
423
423
|
}
|
|
424
424
|
}
|
|
425
425
|
|
|
426
|
-
export async function importConfigConfigModule(inFile: string, logger?: Logger) {
|
|
426
|
+
export async function importConfigConfigModule(inFile: string, options: ImportJSXFileOptions, logger?: Logger) {
|
|
427
427
|
const isCJS = extname(inFile) === ".cjs";
|
|
428
|
-
const mod = isCJS ? (await importJSXFile(inFile, logger)).default.default : (await importJSXFile(inFile, logger)).default;
|
|
428
|
+
const mod = isCJS ? (await importJSXFile(inFile, options, logger)).default.default : (await importJSXFile(inFile, options, logger)).default;
|
|
429
429
|
|
|
430
430
|
const module = parser.parse(mod, MiddlewareConfigSchema, basename(inFile));
|
|
431
431
|
if (module !== undefined) {
|
|
@@ -435,9 +435,9 @@ export async function importConfigConfigModule(inFile: string, logger?: Logger)
|
|
|
435
435
|
}
|
|
436
436
|
}
|
|
437
437
|
|
|
438
|
-
export async function importCORSModule(inFile: string, logger?: Logger) {
|
|
438
|
+
export async function importCORSModule(inFile: string, options: ImportJSXFileOptions, logger?: Logger) {
|
|
439
439
|
const isCJS = extname(inFile) === ".cjs";
|
|
440
|
-
const mod = isCJS ? (await importJSXFile(inFile, logger)).default.default : (await importJSXFile(inFile, logger)).default;
|
|
440
|
+
const mod = isCJS ? (await importJSXFile(inFile, options, logger)).default.default : (await importJSXFile(inFile, options, logger)).default;
|
|
441
441
|
|
|
442
442
|
const module = parser.parse(mod, CORSOptionsSchema, basename(inFile));
|
|
443
443
|
if (module !== undefined) {
|
|
@@ -447,9 +447,9 @@ export async function importCORSModule(inFile: string, logger?: Logger) {
|
|
|
447
447
|
}
|
|
448
448
|
}
|
|
449
449
|
|
|
450
|
-
export async function importWSConfigModule(inFile: string, logger?: Logger) {
|
|
450
|
+
export async function importWSConfigModule(inFile: string, options: ImportJSXFileOptions, logger?: Logger) {
|
|
451
451
|
const isCJS = extname(inFile) === ".cjs";
|
|
452
|
-
const mod = isCJS ? (await importJSXFile(inFile, logger)).default.default : (await importJSXFile(inFile, logger)).default;
|
|
452
|
+
const mod = isCJS ? (await importJSXFile(inFile, options, logger)).default.default : (await importJSXFile(inFile, options, logger)).default;
|
|
453
453
|
|
|
454
454
|
const module = parser.parse(mod, WSConfigSchema, basename(inFile));
|
|
455
455
|
if (module !== undefined) {
|
|
@@ -459,9 +459,9 @@ export async function importWSConfigModule(inFile: string, logger?: Logger) {
|
|
|
459
459
|
}
|
|
460
460
|
}
|
|
461
461
|
|
|
462
|
-
export async function importDBConfigModule(inFile: string, logger?: Logger) {
|
|
462
|
+
export async function importDBConfigModule(inFile: string, options: ImportJSXFileOptions, logger?: Logger) {
|
|
463
463
|
const isCJS = extname(inFile) === ".cjs";
|
|
464
|
-
const mod = isCJS ? (await importJSXFile(inFile, logger)).default.default : (await importJSXFile(inFile, logger)).default;
|
|
464
|
+
const mod = isCJS ? (await importJSXFile(inFile, options, logger)).default.default : (await importJSXFile(inFile, options, logger)).default;
|
|
465
465
|
|
|
466
466
|
const module = parser.parse(mod, DBConfigSchema, basename(inFile));
|
|
467
467
|
if (module !== undefined) {
|
|
@@ -471,8 +471,8 @@ export async function importDBConfigModule(inFile: string, logger?: Logger) {
|
|
|
471
471
|
}
|
|
472
472
|
}
|
|
473
473
|
|
|
474
|
-
export async function importLogConfigModule(inFile: string, logger?: Logger) {
|
|
475
|
-
const module = parser.parse((await importJSXFile(inFile, logger)).default, LogConfigSchema, basename(inFile));
|
|
474
|
+
export async function importLogConfigModule(inFile: string, options: ImportJSXFileOptions, logger?: Logger) {
|
|
475
|
+
const module = parser.parse((await importJSXFile(inFile, options, logger)).default, LogConfigSchema, basename(inFile));
|
|
476
476
|
if (module !== undefined) {
|
|
477
477
|
return module;
|
|
478
478
|
} else {
|
|
@@ -480,9 +480,9 @@ export async function importLogConfigModule(inFile: string, logger?: Logger) {
|
|
|
480
480
|
}
|
|
481
481
|
}
|
|
482
482
|
|
|
483
|
-
export async function importServerConfigModule(inFile: string, logger?: Logger) {
|
|
483
|
+
export async function importServerConfigModule(inFile: string, options: ImportJSXFileOptions, logger?: Logger) {
|
|
484
484
|
const isCJS = extname(inFile) === ".cjs";
|
|
485
|
-
const mod = isCJS ? (await importJSXFile(inFile, logger)).default.default : (await importJSXFile(inFile, logger)).default;
|
|
485
|
+
const mod = isCJS ? (await importJSXFile(inFile, options, logger)).default.default : (await importJSXFile(inFile, options, logger)).default;
|
|
486
486
|
|
|
487
487
|
const module = parser.parse(mod, ServerConfigSchema, basename(inFile));
|
|
488
488
|
if (module !== undefined) {
|
|
@@ -492,7 +492,18 @@ export async function importServerConfigModule(inFile: string, logger?: Logger)
|
|
|
492
492
|
}
|
|
493
493
|
}
|
|
494
494
|
|
|
495
|
-
export
|
|
495
|
+
export interface ImportJSXFileOptions {
|
|
496
|
+
noBuild: boolean;
|
|
497
|
+
}
|
|
498
|
+
|
|
499
|
+
export async function importJSXFile(inFile: string, options: ImportJSXFileOptions, logger?: Logger | Console): Promise<any> {
|
|
500
|
+
|
|
501
|
+
if (options.noBuild) {
|
|
502
|
+
const module = await import(resolve(inFile));
|
|
503
|
+
return module;
|
|
504
|
+
}
|
|
505
|
+
|
|
506
|
+
|
|
496
507
|
const inflatedCode = await inflateJSX(inFile, {
|
|
497
508
|
// embemedJSX: false,
|
|
498
509
|
minify: false,
|
|
@@ -47,15 +47,15 @@ export async function inflateAppForSea(logger: Logger, inflateDir: string, servi
|
|
|
47
47
|
writeFile(logger, resolve(inflateDir, "sea", "lib.cjs"), Buffer.from(getAsset("lib.cjs")));
|
|
48
48
|
|
|
49
49
|
const WSLIST = services.filter(service => getWSConfigPath(resolve(cwd(), service))).map(service => {
|
|
50
|
-
return `(await require("
|
|
50
|
+
return `(await require("./../${service}/ws.cjs")).default`;
|
|
51
51
|
}).join(",");
|
|
52
52
|
|
|
53
53
|
const LOGCONFIGLIST = services.filter(service => getLogConfigPath(resolve(cwd(), service))).map(service => {
|
|
54
|
-
return `{config: (await require("
|
|
54
|
+
return `{config: (await require("./../${service}/log.cjs")).default, service: "${service}" }`;
|
|
55
55
|
}).join(",");
|
|
56
56
|
|
|
57
57
|
const SERVERCONFIGLIST = services.filter(service => getServerConfigPath(resolve(cwd(), service))).map(service => {
|
|
58
|
-
return `(await require("
|
|
58
|
+
return `(await require("./../${service}/server.cjs")).default`;
|
|
59
59
|
}).join(",\n");
|
|
60
60
|
|
|
61
61
|
const DBCONFIGLIST = services.filter(service => getDBConfigPath(resolve(cwd(), service))).map(service => {
|
|
@@ -159,20 +159,20 @@ export async function inflateServiceForSea(logger: Logger, inflateDir: string, s
|
|
|
159
159
|
const migrationsFolderPath = getMigrationsPath(servicePath);
|
|
160
160
|
|
|
161
161
|
const serviceMigrations: string[] = migrationsFolderPath ? migration.getSortedMigrations(migrationsFolderPath) : [];
|
|
162
|
-
writeFile(logger, join(inflateDir, "sea", service, "router.cjs"), `const { appendAPIModule, Router, middleware } = require("
|
|
162
|
+
writeFile(logger, join(inflateDir, "sea", service, "router.cjs"), `const { appendAPIModule, Router, middleware } = require("./${relative(service, "")}/lib.cjs");\n
|
|
163
163
|
async function setupRouter() {
|
|
164
164
|
const router = new Router();
|
|
165
165
|
${getErrorConfigPath(servicePath) ? `
|
|
166
|
-
const errorConfig = (await require("
|
|
166
|
+
const errorConfig = (await require("../${relative(service, "")}/${service}/catch.cjs")).default;
|
|
167
167
|
if(errorConfig && errorConfig.catch) {
|
|
168
168
|
for(const m of errorConfig.catch) {
|
|
169
169
|
router.catch(m);
|
|
170
170
|
}
|
|
171
171
|
}` : ""}
|
|
172
|
-
${getCORSConfigPath(servicePath) ? ` router.use(middleware.cors((await require("
|
|
173
|
-
${getAuthConfigPath(servicePath) ? ` router.use(middleware.session((await require("
|
|
172
|
+
${getCORSConfigPath(servicePath) ? ` router.use(middleware.cors((await require("../${relative(service, "")}/${service}/cors.cjs")).default));` : ""}
|
|
173
|
+
${getAuthConfigPath(servicePath) ? ` router.use(middleware.session((await require("../${relative(service, "")}/${service}/auth.cjs")).default));` : ""}
|
|
174
174
|
${getMiddlewareConfigPath(servicePath) ? `
|
|
175
|
-
const middlewareConfig = (await require("
|
|
175
|
+
const middlewareConfig = (await require("../${relative(service, "")}/${service}/middleware.cjs")).default;
|
|
176
176
|
if(middlewareConfig && middlewareConfig.middleware) {
|
|
177
177
|
for(const m of middlewareConfig.middleware) {
|
|
178
178
|
router.use(m);
|
|
@@ -185,8 +185,8 @@ ${Object.keys(serviceRouteFileMap)
|
|
|
185
185
|
const rPath = join(relative(cwd(), dirname(data.filePath)), basename(data.filePath));
|
|
186
186
|
if (rPath) {
|
|
187
187
|
const rPathExt = extname(rPath);
|
|
188
|
-
const apiInflatedPath = join("..", "
|
|
189
|
-
return ` await appendAPIModule(router, "
|
|
188
|
+
const apiInflatedPath = join("..", relative(service, ""), rPath.substring(0, rPath.length - rPathExt.length) + ".cjs");
|
|
189
|
+
return ` await appendAPIModule(router, "../${relative(service, "")}/${service}/http", "./${apiInflatedPath}", (await require("./${apiInflatedPath}")).default);`;
|
|
190
190
|
} else {
|
|
191
191
|
return "";
|
|
192
192
|
}
|
|
@@ -207,24 +207,24 @@ module.exports = {
|
|
|
207
207
|
setupRouter
|
|
208
208
|
}`);
|
|
209
209
|
|
|
210
|
-
writeFile(logger, join(inflateDir, "sea", service, "migration-up.cjs"), `const { migration } = require("
|
|
210
|
+
writeFile(logger, join(inflateDir, "sea", service, "migration-up.cjs"), `const { migration } = require("./${relative(service, "")}/lib.cjs");\n
|
|
211
211
|
async function runMigrations(db) {
|
|
212
212
|
await migration.init(db);
|
|
213
213
|
${serviceMigrations.map(file => {
|
|
214
214
|
const name = `${file.substring(0, file.length - extname(file).length)}`;
|
|
215
|
-
return ` await migration.up.module(db, "${file}", (await require("
|
|
215
|
+
return ` await migration.up.module(db, "${file}", (await require("../${relative(service, "")}/${service}/migration/${name}.cjs")).default)`;
|
|
216
216
|
}).join("\n")}
|
|
217
217
|
}
|
|
218
218
|
module.exports = {
|
|
219
219
|
runMigrations
|
|
220
220
|
}`);
|
|
221
221
|
|
|
222
|
-
writeFile(logger, join(inflateDir, "sea", service, "migration-down.cjs"), `const { migration } = require("
|
|
222
|
+
writeFile(logger, join(inflateDir, "sea", service, "migration-down.cjs"), `const { migration } = require("./${relative(service, "")}/lib.cjs");\n
|
|
223
223
|
async function runMigrations(db) {
|
|
224
224
|
await migration.init(db);
|
|
225
225
|
${serviceMigrations.reverse().map(file => {
|
|
226
226
|
const name = `${file.substring(0, file.length - extname(file).length)}`;
|
|
227
|
-
return ` await migration.down.module(db, "${file}", (await require("
|
|
227
|
+
return ` await migration.down.module(db, "${file}", (await require("../${relative(service, "")}/${service}/migration/${name}.cjs")).default)`;
|
|
228
228
|
}).join("\n")}
|
|
229
229
|
}
|
|
230
230
|
module.exports = {
|
|
@@ -235,7 +235,7 @@ module.exports = {
|
|
|
235
235
|
/*if (staticFiles.length !== 0) {
|
|
236
236
|
writeFile(logger, join(inflateDir, "sea", service, "static.base64.json"), JSON.stringify(serviceStaticFileMap));
|
|
237
237
|
}*/
|
|
238
|
-
writeFile(logger, join(inflateDir, "sea", service, "static-router.cjs"), `const { appendAPIModule, Router } = require("
|
|
238
|
+
writeFile(logger, join(inflateDir, "sea", service, "static-router.cjs"), `const { appendAPIModule, Router } = require("./${relative(service, "")}/lib.cjs");\n
|
|
239
239
|
async function setupRouter() {
|
|
240
240
|
const router = new Router();
|
|
241
241
|
${staticFiles.length === 0 ? "" : `
|
package/src/inflate/inflate.ts
CHANGED
|
@@ -23,9 +23,13 @@ export interface InflateAppOptions {
|
|
|
23
23
|
port: string;
|
|
24
24
|
serverInterface: ServerInterface;
|
|
25
25
|
inflateParallel?: number;
|
|
26
|
+
noBuild?: boolean;
|
|
27
|
+
noMinify?: boolean;
|
|
28
|
+
inflateOnlyAssets?: boolean;
|
|
29
|
+
inflateFlat?: boolean;
|
|
26
30
|
}
|
|
27
31
|
|
|
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]> {
|
|
32
|
+
export async function inflateApp({ inflateParallel, serverInterface, logger, hotreload, services/*, dbManager*/, inflateDir, inflateSea/*, editor, inflateTests*/, port, noBuild, noMinify, inflateOnlyAssets, inflateFlat }: InflateAppOptions): Promise<[Router, InflateError[] | null, RouteFileMap, WSConfig[]/*, ServerConfigMap*/, LogConfigMap]> {
|
|
29
33
|
logger.trace("inflateApp");
|
|
30
34
|
const errors: InflateError[] = [];
|
|
31
35
|
//const migrations: string[] = [];
|
|
@@ -68,17 +72,17 @@ export async function inflateApp({ inflateParallel, serverInterface, logger, hot
|
|
|
68
72
|
|
|
69
73
|
//await setupDB(logger, service, dbConfigList, inflateDir);
|
|
70
74
|
|
|
71
|
-
await setupLogConfig(logger, servicePath, service, logConfigMap, inflateSea ? inflateDir : false, errors);
|
|
75
|
+
await setupLogConfig(logger, servicePath, service, logConfigMap, inflateSea ? inflateDir : false, { noBuild }, errors);
|
|
72
76
|
|
|
73
|
-
router.use(await setupHTTPRouter(serverInterface, logger, hotreload ? hotreload : false, servicePath, service, serviceRouteFileMap, serviceStaticFileMap, inflateDir, inflateSea, errors, inflateParallel));
|
|
77
|
+
router.use(await setupHTTPRouter({ noBuild }, { noMinify, inflateOnlyAssets, inflateFlat }, serverInterface, logger, hotreload ? hotreload : false, servicePath, service, serviceRouteFileMap, serviceStaticFileMap, inflateDir, inflateSea, errors, inflateParallel));
|
|
74
78
|
routeFileMap = {
|
|
75
79
|
...routeFileMap,
|
|
76
80
|
...serviceRouteFileMap
|
|
77
81
|
};
|
|
78
82
|
|
|
79
|
-
await setupDoc(logger, servicePath, service, router, routeFileMap, serviceStaticFileMap, inflateDir, errors);
|
|
83
|
+
await setupDoc(logger, servicePath, service, router, routeFileMap, serviceStaticFileMap, inflateDir, errors, { noBuild }, inflateFlat);
|
|
80
84
|
|
|
81
|
-
await inflateWSConfig(logger, servicePath, service, wsConfigList, inflateSea ? inflateDir : undefined, errors);
|
|
85
|
+
await inflateWSConfig(logger, servicePath, service, wsConfigList, inflateSea ? inflateDir : undefined, errors, { noBuild });
|
|
82
86
|
|
|
83
87
|
//await setupServerConfig(logger, servicePath, service, serverConfigMap, inflateSea ? inflateDir : undefined, errors);
|
|
84
88
|
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
import { Logger, Router, SessionHandler } from "@miqro/core";
|
|
2
|
-
import { importAuthModule, InflateError, inflateJSX } from "../common/jsx.js";
|
|
2
|
+
import { importAuthModule, ImportJSXFileOptions, InflateError, inflateJSX } from "../common/jsx.js";
|
|
3
3
|
import { getAuthConfigPath } from "../common/paths.js";
|
|
4
4
|
import { basename, dirname, join, relative, resolve } from "node:path";
|
|
5
5
|
import { mkdirSync, writeFileSync } from "node:fs";
|
|
6
6
|
import { cwd } from "node:process";
|
|
7
7
|
|
|
8
|
-
export async function setupAUTH(logger: Logger, servicePath: string, service: string, mainRouter: Router, inflateDir: string | undefined | false, inflateSea: boolean, errors: InflateError[]) {
|
|
8
|
+
export async function setupAUTH(logger: Logger, servicePath: string, service: string, mainRouter: Router, inflateDir: string | undefined | false, inflateSea: boolean, options: ImportJSXFileOptions, errors: InflateError[]) {
|
|
9
9
|
const authPath = getAuthConfigPath(servicePath); //resolve(process.cwd(), service, "auth.ts");
|
|
10
10
|
|
|
11
11
|
if (authPath) {
|
|
12
12
|
try {
|
|
13
|
-
const authModule = await importAuthModule(authPath, logger);
|
|
13
|
+
const authModule = await importAuthModule(authPath, options, logger);
|
|
14
14
|
logger.debug("setting up authentication from [%s]", join(service, basename(authPath)));
|
|
15
15
|
mainRouter.use(SessionHandler(authModule));
|
|
16
16
|
|
|
@@ -1,17 +1,18 @@
|
|
|
1
1
|
import { mkdirSync, writeFileSync } from "node:fs";
|
|
2
|
-
import { importCORSModule, InflateError, inflateJSX } from "../common/jsx.js";
|
|
2
|
+
import { importCORSModule, ImportJSXFileOptions, InflateError, inflateJSX } from "../common/jsx.js";
|
|
3
3
|
import { getCORSConfigPath } from "../common/paths.js";
|
|
4
4
|
import { CORS, Logger, Router } from "@miqro/core";
|
|
5
5
|
import { basename, dirname, join, relative, resolve } from "node:path";
|
|
6
6
|
import { cwd } from "node:process";
|
|
7
7
|
|
|
8
|
-
export async function setupCORS(logger: Logger, servicePath: string, service: string, mainRouter: Router, inflateDir: string | undefined | false, inflateSea: boolean, errors: InflateError[]) {
|
|
8
|
+
export async function setupCORS(logger: Logger, servicePath: string, service: string, mainRouter: Router, inflateDir: string | undefined | false, inflateSea: boolean, options: ImportJSXFileOptions, errors: InflateError[]) {
|
|
9
9
|
const corsPath = getCORSConfigPath(servicePath);
|
|
10
10
|
|
|
11
11
|
if (corsPath) {
|
|
12
12
|
try {
|
|
13
|
-
const corsOptions = await importCORSModule(corsPath, logger);
|
|
14
13
|
logger.debug("setting up cors from [%s]", join(service, basename(corsPath)));
|
|
14
|
+
const corsOptions = await importCORSModule(corsPath, options, logger);
|
|
15
|
+
|
|
15
16
|
mainRouter.use(CORS(corsOptions));
|
|
16
17
|
|
|
17
18
|
if (inflateDir && inflateSea) {
|