miqro 6.0.3 → 6.0.4

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/bin/miqro ADDED
@@ -0,0 +1,34 @@
1
+ #!/usr/bin/env sh
2
+
3
+ SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
4
+ BIN_NAME="miqro"
5
+ ARGS="$@"
6
+
7
+ export NODE_OPTIONS="--disable-warning=ExperimentalWarning"
8
+ #export NODE_OPTIONS="--experimental-sqlite --disable-warning=ExperimentalWarning"
9
+
10
+ case $(uname -s) in
11
+ Linux)
12
+ case $(uname -m) in
13
+ aarch64)
14
+ ${SCRIPT_DIR}/linux-arm64/${BIN_NAME} ${ARGS}
15
+ ;;
16
+ x64)
17
+ ${SCRIPT_DIR}/linux-x64/${BIN_NAME} ${ARGS}
18
+ ;;
19
+ *) echo "unsopported architecture"; exit 99; ;;
20
+ esac
21
+ ;;
22
+ Darwin)
23
+ case $(uname -m) in
24
+ arm64)
25
+ ${SCRIPT_DIR}/darwin-arm64/${BIN_NAME} ${ARGS}
26
+ ;;
27
+ x64)
28
+ ${SCRIPT_DIR}/darwin-arm64/${BIN_NAME} ${ARGS}
29
+ ;;
30
+ *) echo "unsopported architecture"; exit 99; ;;
31
+ esac
32
+ ;;
33
+ *) echo "unsopported architecture"; exit 99; ;;
34
+ esac
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env node
2
+ import { Arguments } from "../common/arguments.js";
3
+ export declare function compileSH(args: Arguments): Promise<void>;
@@ -0,0 +1,31 @@
1
+ #!/usr/bin/env node
2
+ import { spawn } from "node:child_process";
3
+ import { EXIT_CODES } from "../common/constants.js";
4
+ export async function compileSH(args) {
5
+ return new Promise((resolve, reject) => {
6
+ try {
7
+ process.chdir(args.inflateDir);
8
+ const proc = spawn(`sh`, ["./compile.sh"]);
9
+ proc.stdout.on('data', (data) => {
10
+ console.log(`${data}`);
11
+ });
12
+ proc.stderr.on('data', (data) => {
13
+ console.log(`${data}`);
14
+ });
15
+ proc.on('close', (code) => {
16
+ console.log(`compilation exited with code ${code}`);
17
+ if (code !== 0) {
18
+ process.exit(code);
19
+ }
20
+ else {
21
+ process.exit(EXIT_CODES.NORMAL_EXIT);
22
+ }
23
+ resolve();
24
+ });
25
+ }
26
+ catch (e) {
27
+ reject(e);
28
+ }
29
+ });
30
+ }
31
+ //# sourceMappingURL=compile.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"compile.js","sourceRoot":"","sources":["../../../../src/bin/compile.ts"],"names":[],"mappings":";AAEA,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAE3C,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AAEpD,MAAM,CAAC,KAAK,UAAU,SAAS,CAAC,IAAe;IAC7C,OAAO,IAAI,OAAO,CAAO,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;QAC3C,IAAI,CAAC;YACH,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;YAC/B,MAAM,IAAI,GAAG,KAAK,CAAC,IAAI,EAAE,CAAC,cAAc,CAAC,CAAC,CAAC;YAE3C,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC,MAAM,EAAE,CAAC,IAAI,EAAE,EAAE;gBAC9B,OAAO,CAAC,GAAG,CAAC,GAAG,IAAI,EAAE,CAAC,CAAC;YACzB,CAAC,CAAC,CAAC;YAEH,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC,MAAM,EAAE,CAAC,IAAI,EAAE,EAAE;gBAC9B,OAAO,CAAC,GAAG,CAAC,GAAG,IAAI,EAAE,CAAC,CAAC;YACzB,CAAC,CAAC,CAAC;YAEH,IAAI,CAAC,EAAE,CAAC,OAAO,EAAE,CAAC,IAAI,EAAE,EAAE;gBACxB,OAAO,CAAC,GAAG,CAAC,gCAAgC,IAAI,EAAE,CAAC,CAAC;gBAEpD,IAAI,IAAI,KAAK,CAAC,EAAE,CAAC;oBACf,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;gBACrB,CAAC;qBAAM,CAAC;oBACN,OAAO,CAAC,IAAI,CAAC,UAAU,CAAC,WAAW,CAAC,CAAC;gBACvC,CAAC;gBACD,OAAO,EAAE,CAAC;YACZ,CAAC,CAAC,CAAC;QACL,CAAC;QAAC,OAAO,CAAC,EAAE,CAAC;YACX,MAAM,CAAC,CAAC,CAAC,CAAC;QACZ,CAAC;IACH,CAAC,CAAC,CAAC;AACL,CAAC"}
@@ -0,0 +1,17 @@
1
+ import { Logger, ParserMode, RouterJSONDoc, SchemaProperties } from "@miqro/core";
2
+ export declare function getMDDoc(args: {
3
+ ignore?: string[];
4
+ showFilePath?: boolean;
5
+ jsonDoc: RouterJSONDoc;
6
+ }, logger?: Logger): Promise<string>;
7
+ export declare function parserToString(parser: {
8
+ status?: number | number[];
9
+ headers?: string | SchemaProperties | SchemaProperties[];
10
+ headersMode?: ParserMode;
11
+ query?: string | SchemaProperties | boolean | SchemaProperties[];
12
+ queryMode?: ParserMode;
13
+ params?: string | SchemaProperties | boolean | SchemaProperties[];
14
+ paramsMode?: ParserMode;
15
+ body?: string | SchemaProperties | boolean | SchemaProperties[];
16
+ bodyMode?: ParserMode;
17
+ }): string;
@@ -0,0 +1,187 @@
1
+ /*interface SchemaProperties {
2
+ [key: string]: Schema | string;
3
+ }
4
+
5
+ type ParserMode = "add_extra" | "no_extra" | "remove_extra"*/
6
+ export async function getMDDoc(args, logger) {
7
+ const pathList = Object.keys(args.jsonDoc).sort();
8
+ let outMD = "";
9
+ const tableIndexItems = [];
10
+ for (const path of pathList) {
11
+ const pathData = args.jsonDoc[path];
12
+ const methods = Object.keys(pathData);
13
+ for (const method of methods) {
14
+ if (method) {
15
+ const apiDataList = pathData[method];
16
+ for (const apiData of apiDataList) {
17
+ tableIndexItems.push({
18
+ apiData
19
+ });
20
+ outMD += `## ${apiData.identifier /*.replaceAll("_", "-")*/}\n\n`;
21
+ outMD += `${args.showFilePath && apiData.___filePath ? apiData.___filePath + "\n\n" : ""}`;
22
+ if (apiData.name) {
23
+ outMD += `${apiData.name}\n\n`;
24
+ }
25
+ if (apiData.description) {
26
+ outMD += `${apiData.description}\n\n`;
27
+ }
28
+ outMD += `[${method}] ${path}\n\n`;
29
+ outMD += `[${path}](${path}) \n\n`;
30
+ if (apiData.policy) {
31
+ outMD += `### policy\n\n`;
32
+ outMD += policyToString(apiData.policy);
33
+ }
34
+ if (apiData.request) {
35
+ const requestOutMD = parserToString(apiData.request);
36
+ outMD += requestOutMD !== "" ? `### request\n\n${requestOutMD}` : "";
37
+ }
38
+ if (apiData.response && typeof apiData.response !== "boolean") {
39
+ const responseOutMD = parserToString(apiData.response);
40
+ outMD += responseOutMD !== "" ? `### response\n\n${responseOutMD}` : "";
41
+ }
42
+ }
43
+ }
44
+ }
45
+ }
46
+ const indexTable = getIndexTable(tableIndexItems);
47
+ return `${indexTable}\n\n${outMD}`;
48
+ }
49
+ function getIndexTable(data) {
50
+ return `${data.map(api => `[${api.apiData.identifier /*.replaceAll("_", "-")*/}](#${api.apiData.identifier /*.replaceAll("_", "-")*/.toLocaleLowerCase()})${api.apiData.name || api.apiData.description ? `\n\n\t${api.apiData.name ? api.apiData.name + " " : ""}${api.apiData.description ? api.apiData.description : ""}` : ""}`).join("\n\n")}`;
51
+ }
52
+ function policyToString(policy) {
53
+ let outMD = "| groups | policy |\n";
54
+ outMD += "|--------|--------|\n";
55
+ outMD += `| ${(policy.groups instanceof Array ? policy.groups : [policy.groups]).join(",")} | ${policy.groupPolicy} |\n\n`;
56
+ return outMD;
57
+ }
58
+ export function parserToString(parser) {
59
+ let outMD = "";
60
+ if (parser.status) {
61
+ outMD += `#### status\n\n${parser.status instanceof Array ? parser.status.join(",") : parser.status}\n\n`;
62
+ }
63
+ if (parser.params && typeof parser.params !== "boolean") {
64
+ outMD += `#### path params\n\n`;
65
+ outMD += parserPartToString(parser.params, parser.paramsMode);
66
+ }
67
+ if (parser.headers) {
68
+ outMD += `#### headers\n\n`;
69
+ outMD += parserPartToString(parser.headers, parser.headersMode);
70
+ }
71
+ if (parser.query && parser.query !== true) {
72
+ outMD += `#### query\n\n`;
73
+ outMD += parserPartToString(parser.query, parser.queryMode);
74
+ }
75
+ if (parser.body && parser.body !== true) {
76
+ outMD += `#### body\n\n`;
77
+ outMD += parserPartToString(parser.body, parser.bodyMode);
78
+ }
79
+ return outMD;
80
+ }
81
+ function parserPartToString(arg, mode) {
82
+ if (arg === false) {
83
+ return "not allowed";
84
+ }
85
+ let outMD = "";
86
+ let maxTabulation = 1;
87
+ const parsers = arg instanceof Array ? arg : typeof arg === "string" ? [arg] : [arg];
88
+ for (const parser of parsers) {
89
+ const ret = internalParserToString(parser);
90
+ if (ret.maxTabulation > maxTabulation) {
91
+ maxTabulation = ret.maxTabulation;
92
+ }
93
+ outMD += `| | | | ${getTabulation(ret.maxTabulation * 2)}\n`;
94
+ outMD += `|--------|-------|-------|${getTabulation(ret.maxTabulation * 2, true)}\n`;
95
+ outMD += `${ret.out}\n\n`;
96
+ }
97
+ return outMD;
98
+ }
99
+ function internalParserToString(parser, tabulation = 1) {
100
+ let outMD = "";
101
+ let maxTabulation = tabulation;
102
+ if (typeof parser === "string") {
103
+ outMD += `${getTabulation(tabulation)}${parser}|\n`;
104
+ }
105
+ else {
106
+ const attrNames = Object.keys(parser);
107
+ for (const name of attrNames) {
108
+ const p = parser[name];
109
+ const description = typeof p === "string" ? "" : p.description ? p.description : "";
110
+ if (typeof p === "string") {
111
+ outMD += `${getTabulation(tabulation)}${name} | ${p}|\n`;
112
+ }
113
+ else if (p.type.toLocaleLowerCase() === "object" || p.type.toLocaleLowerCase() === "object?") {
114
+ const rString = p.required === false || p.type.toLocaleLowerCase() === "object?" ? "?" : "";
115
+ outMD += `${getTabulation(tabulation)}${name} | object${rString}| ${description}|\n`;
116
+ const ret = parserBaseObjectTypeToString(p, tabulation + 1);
117
+ if (maxTabulation < ret.maxTabulation) {
118
+ maxTabulation = ret.maxTabulation;
119
+ }
120
+ outMD += `${ret.out}`;
121
+ }
122
+ else if (p.type.toLocaleLowerCase() === "dict" || p.type.toLocaleLowerCase() === "dict?") {
123
+ const rString = p.required === false || p.type.toLocaleLowerCase() === "dict?" ? "?" : "";
124
+ outMD += `${getTabulation(tabulation)}${name} | Dict\\<${p.dictType}\>${rString}| ${description}|\n`;
125
+ if (p.dictType === "object") {
126
+ const ret = parserBaseObjectTypeToString(p, tabulation + 1);
127
+ if (maxTabulation < ret.maxTabulation) {
128
+ maxTabulation = ret.maxTabulation;
129
+ }
130
+ outMD += `${ret.out}`;
131
+ }
132
+ }
133
+ else if (p.type.toLocaleLowerCase() === "array" || p.type.toLocaleLowerCase() === "array?") {
134
+ const rString = p.required === false || p.type.toLocaleLowerCase() === "array?" ? "?" : "";
135
+ outMD += `${getTabulation(tabulation)}${name} | Array\\<${p.arrayType}\>${rString}| ${description}|\n`;
136
+ if (p.arrayType.toLocaleLowerCase() === "object") {
137
+ const ret = parserBaseObjectTypeToString(p, tabulation + 1);
138
+ if (maxTabulation < ret.maxTabulation) {
139
+ maxTabulation = ret.maxTabulation;
140
+ }
141
+ outMD += `${ret.out}`;
142
+ }
143
+ }
144
+ else if (p.type.toLocaleLowerCase() === "regex") {
145
+ outMD += `${getTabulation(tabulation)}${name} | ${p.regex}| ${description}|\n`;
146
+ }
147
+ else if (p.type.toLocaleLowerCase() === "regex?") {
148
+ outMD += `${getTabulation(tabulation)}${name} | ${p.regex}?| ${description}|\n`;
149
+ }
150
+ else if (p.type.toLocaleLowerCase() === "enum") {
151
+ outMD += `${getTabulation(tabulation)}${name} | ${p.type}| ${description}|\n`;
152
+ outMD += `${getTabulation(tabulation + 1)}| ${p.enumValues?.join(",")}|\n`;
153
+ if (maxTabulation < tabulation + 1) {
154
+ maxTabulation = tabulation + 1;
155
+ }
156
+ }
157
+ else if (p.type.toLocaleLowerCase() === "enum?") {
158
+ outMD += `${getTabulation(tabulation)}${name} | ${p.type}?| ${description}|\n`;
159
+ outMD += `${getTabulation(tabulation + 1)}| ${p.enumValues?.join(",")}|\n`;
160
+ if (maxTabulation < tabulation + 1) {
161
+ maxTabulation = tabulation + 1;
162
+ }
163
+ }
164
+ else {
165
+ const rString = p.required === false ? "?" : "";
166
+ outMD += `${getTabulation(tabulation)}${name} | ${p.type}${rString}| ${description}|\n`;
167
+ }
168
+ }
169
+ }
170
+ return {
171
+ out: outMD,
172
+ maxTabulation
173
+ };
174
+ }
175
+ function parserBaseObjectTypeToString(arg, tabulation) {
176
+ const options = arg.properties ? arg.properties : {};
177
+ //const outMD = `${getTabulation(tabulation)}name | type |\n${getTabulation(tabulation)}--------|--------|\n`;
178
+ return internalParserToString(options, tabulation + 1);
179
+ }
180
+ function getTabulation(n, header = false) {
181
+ let out = "";
182
+ for (let i = 0; i < n; i++) {
183
+ out += header ? "-|" : "| ";
184
+ }
185
+ return out;
186
+ }
187
+ //# sourceMappingURL=doc-md.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"doc-md.js","sourceRoot":"","sources":["../../../../src/bin/doc-md.ts"],"names":[],"mappings":"AAGA;;;;6DAI6D;AAE7D,MAAM,CAAC,KAAK,UAAU,QAAQ,CAAC,IAA2E,EAAE,MAAe;IAEzH,MAAM,QAAQ,GAAG,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,CAAC;IAElD,IAAI,KAAK,GAAG,EAAE,CAAC;IAEf,MAAM,eAAe,GAAG,EAAE,CAAC;IAE3B,KAAK,MAAM,IAAI,IAAI,QAAQ,EAAE,CAAC;QAC5B,MAAM,QAAQ,GAAG,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;QACpC,MAAM,OAAO,GAAG,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;QACtC,KAAK,MAAM,MAAM,IAAI,OAAO,EAAE,CAAC;YAC7B,IAAI,MAAM,EAAE,CAAC;gBACX,MAAM,WAAW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G,CAAC,KAAK,CAAC;gBAC3E,IAAI,aAAa,GAAG,UAAU,GAAG,CAAC,EAAE,CAAC;oBACnC,aAAa,GAAG,UAAU,GAAG,CAAC,CAAC;gBACjC,CAAC;YACH,CAAC;iBAAM,CAAC;gBACN,MAAM,OAAO,GAAG,CAAC,CAAC,QAAQ,KAAK,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC;gBAChD,KAAK,IAAI,GAAG,aAAa,CAAC,UAAU,CAAC,GAAG,IAAI,MAAM,CAAC,CAAC,IAAI,GAAG,OAAO,KAAK,WAAW,KAAK,CAAC;YAC1F,CAAC;QACH,CAAC;IACH,CAAC;IACD,OAAO;QACL,GAAG,EAAE,KAAK;QACV,aAAa;KACd,CAAC;AACJ,CAAC;AAED,SAAS,4BAA4B,CAAC,GAAW,EAAE,UAAkB;IACnE,MAAM,OAAO,GAAqB,GAAG,CAAC,UAAU,CAAC,CAAC,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC,CAAC,EAAE,CAAC;IACvE,8GAA8G;IAC9G,OAAO,sBAAsB,CAAC,OAAO,EAAE,UAAU,GAAG,CAAC,CAAC,CAAC;AACzD,CAAC;AAED,SAAS,aAAa,CAAC,CAAS,EAAE,MAAM,GAAG,KAAK;IAC9C,IAAI,GAAG,GAAG,EAAE,CAAC;IACb,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC;QAC3B,GAAG,IAAI,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC;IAC9B,CAAC;IACD,OAAO,GAAG,CAAC;AACb,CAAC"}
@@ -0,0 +1,4 @@
1
+ import { Logger } from "@miqro/core";
2
+ import { Arguments } from "../common/arguments.js";
3
+ import { InflatedResult } from "../services/app.js";
4
+ export declare function generateDocs(args: Arguments, logger: Logger, result: InflatedResult): Promise<void>;
@@ -0,0 +1,47 @@
1
+ import { writeFileSync } from "node:fs";
2
+ import { getMDDoc } from "./doc-md.js";
3
+ import { EXIT_CODES } from "../common/constants.js";
4
+ export async function generateDocs(args, logger, result) {
5
+ /*
6
+ ** TODO FIX THIS MESS
7
+ */
8
+ const router = result.router;
9
+ const fileMap = result.fileMap;
10
+ const fileMapAPIRouteList = Object.keys(fileMap).map(f => fileMap[f]).filter(fMap => fMap.previewMethod === "api").map(fMap => fMap.routes);
11
+ const jsonDoc = router.getJSONDoc();
12
+ Object.keys(jsonDoc).forEach(path => {
13
+ const methods = Object.keys(jsonDoc[path]);
14
+ methods.forEach(method => {
15
+ const data = jsonDoc[path][method];
16
+ //console.log("[%s] [%s]", path, method);
17
+ if (fileMapAPIRouteList.filter(f => {
18
+ for (const r of f) {
19
+ if (r.method === String(method).toUpperCase() && r.path === path) {
20
+ return true;
21
+ }
22
+ }
23
+ return false;
24
+ }).length === 0) {
25
+ //console.log("DELETE [%s] [%s]", path, method);
26
+ delete jsonDoc[path][method];
27
+ }
28
+ else {
29
+ //console.log("KEEP [%s] [%s]", path, method);
30
+ }
31
+ });
32
+ });
33
+ switch (args.generateDocType) {
34
+ case "JSON":
35
+ logger.info("writing [%s]", args.generateDocOut);
36
+ writeFileSync(args.generateDocOut, JSON.stringify(jsonDoc, undefined, 4));
37
+ break;
38
+ case "MD":
39
+ logger.info("writing [%s]", args.generateDocOut);
40
+ writeFileSync(args.generateDocOut, await getMDDoc({ showFilePath: true, jsonDoc }));
41
+ break;
42
+ default:
43
+ logger.error("--generate-doc-type invalid!");
44
+ process.exit(EXIT_CODES.BAD_ARGUMENTS);
45
+ }
46
+ }
47
+ //# sourceMappingURL=generate-doc.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"generate-doc.js","sourceRoot":"","sources":["../../../../src/bin/generate-doc.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AACxC,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACvC,OAAO,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gDAAgD;gBAChD,OAAO,OAAO,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,CAAC;YAC/B,CAAC;iBAAM,CAAC;gBACN,8CAA8C;YAChD,CAAC;QAEH,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;IAEH,QAAQ,IAAI,CAAC,eAAe,EAAE,CAAC;QAC7B,KAAK,MAAM;YACT,MAAM,CAAC,IAAI,CAAC,cAAc,EAAE,IAAI,CAAC,cAAc,CAAC,CAAC;YACjD,aAAa,CAAC,IAAI,CAAC,cAAc,EAAE,IAAI,CAAC,SAAS,CAAC,OAAO,EAAE,SAAS,EAAE,CAAC,CAAC,CAAC,CAAC;YAC1E,MAAM;QACR,KAAK,IAAI;YACP,MAAM,CAAC,IAAI,CAAC,cAAc,EAAE,IAAI,CAAC,cAAc,CAAC,CAAC;YACjD,aAAa,CAAC,IAAI,CAAC,cAAc,EAAE,MAAM,QAAQ,CAAC,EAAE,YAAY,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC,CAAC,CAAC;YACpF,MAAM;QACR;YACE,MAAM,CAAC,KAAK,CAAC,8BAA8B,CAAC,CAAC;YAC7C,OAAO,CAAC,IAAI,CAAC,UAAU,CAAC,aAAa,CAAC,CAAC;IAC3C,CAAC;AACH,CAAC"}
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env node
2
+ import { Miqro } from "../services/app.js";
3
+ export declare function testMain(app: Miqro): Promise<void>;
@@ -0,0 +1,68 @@
1
+ #!/usr/bin/env node
2
+ import { request as reqlRequest } from "@miqro/request";
3
+ import { resetGlobals, runTests } from "@miqro/test/dist/runner/common.js";
4
+ import { getServicePath, TEST_SOCKET } from "../common/paths.js";
5
+ import { createNodeRuntime } from "@miqro/jsx-node";
6
+ import { EXIT_CODES } from "../common/constants.js";
7
+ import { setupTests } from "../inflate/setup-test.js";
8
+ export async function testMain(app) {
9
+ const startMS = Date.now();
10
+ //resetTests();
11
+ resetGlobals();
12
+ //const testLogger = getLogger("test");
13
+ globalThis.test = {
14
+ PORT: TEST_SOCKET,
15
+ request: (request) => reqlRequest({
16
+ ...request,
17
+ socketPath: TEST_SOCKET
18
+ }),
19
+ logger: app.logger,
20
+ sleep: async (ms) => new Promise(resolve => setTimeout(resolve, ms)),
21
+ jsx: {
22
+ createRuntime: createNodeRuntime,
23
+ test: (cb, args) => {
24
+ return async () => {
25
+ const runtime = createNodeRuntime(args.runtimeOptions);
26
+ const root = runtime.createElement("root");
27
+ const container = runtime.createContainer(root, args.containerOptions);
28
+ await cb(container, root, runtime);
29
+ container.disconnect();
30
+ };
31
+ }
32
+ }
33
+ };
34
+ for (const service of app.options.services) {
35
+ const servicePath = getServicePath(service);
36
+ await setupTests(app.logger, servicePath);
37
+ }
38
+ console.log("");
39
+ app.logger.log("===starting tests===");
40
+ console.log("");
41
+ const ret = await runTests(undefined, app.logger);
42
+ console.log("");
43
+ app.logger.log("===tests ended===");
44
+ if (ret.failed.length > 0) {
45
+ console.log("");
46
+ app.logger.error("===failed tests===");
47
+ console.log("");
48
+ }
49
+ const took = Date.now() - startMS;
50
+ ret.failed.forEach(e => {
51
+ app.logger.error("\x1b[31m%s\x1b[0m", e.fullName);
52
+ app.logger.error(e.error);
53
+ });
54
+ console.log("");
55
+ app.logger.log(ret.passed + " tests passed");
56
+ if (ret.failed.length > 0) {
57
+ app.logger.error(ret.failed.length + " failed");
58
+ }
59
+ else {
60
+ app.logger.log(ret.failed.length + " failed");
61
+ }
62
+ app.logger.log("took " + took + "ms");
63
+ if (ret.failed.length > 0) {
64
+ process.exit(EXIT_CODES.TEST_FAILED);
65
+ }
66
+ await app.dbManager.closeAll();
67
+ }
68
+ //# sourceMappingURL=test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"test.js","sourceRoot":"","sources":["../../../../src/bin/test.ts"],"names":[],"mappings":";AAEA,OAAO,EAAkB,OAAO,IAAI,WAAW,EAAE,MAAM,gBAAgB,CAAC;AACxE,OAAO,EAAE,YAAY,EAAE,QAAQ,EAAE,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AM,GAAG,eAAe,CAAC,CAAC;IAC7C,IAAI,GAAG,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QAC1B,GAAG,CAAC,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,MAAM,CAAC,MAAM,GAAG,SAAS,CAAC,CAAC;IAClD,CAAC;SAAM,CAAC;QACN,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,GAAG,CAAC,MAAM,CAAC,MAAM,GAAG,SAAS,CAAC,CAAC;IAChD,CAAC;IAED,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,OAAO,GAAG,IAAI,GAAG,IAAI,CAAC,CAAC;IAEtC,IAAI,GAAG,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QAC1B,OAAO,CAAC,IAAI,CAAC,UAAU,CAAC,WAAW,CAAC,CAAC;IACvC,CAAC;IACD,MAAM,GAAG,CAAC,SAAS,CAAC,QAAQ,EAAE,CAAC;AACjC,CAAC"}
@@ -0,0 +1,3 @@
1
+ import { MinimalLogger } from "@miqro/core";
2
+ import { Arguments } from "../common/arguments.js";
3
+ export declare function installTypings(args: Arguments, logger: MinimalLogger): Promise<void>;
@@ -0,0 +1,21 @@
1
+ import { initTypes } from "../common/assets.js";
2
+ import { existsSync, writeFileSync } from "node:fs";
3
+ import { TEMPLATES } from "../../editor/common/templates.js";
4
+ import { EXIT_CODES } from "../common/constants.js";
5
+ export async function installTypings(args, logger) {
6
+ if (args.installTypes) {
7
+ logger.debug("writing types");
8
+ // install typing for typescript only if argument --install-types is set
9
+ await initTypes(logger);
10
+ }
11
+ if (args.installTSConfig && !existsSync("tsconfig.json")) {
12
+ logger.info("writing tsconfig.json");
13
+ writeFileSync("tsconfig.json", TEMPLATES["TSCONFIGJSON"].template("", ""));
14
+ }
15
+ else if (args.installTSConfig) {
16
+ logger.error("tsconfig.json already exists!");
17
+ process.exit(EXIT_CODES.ABNORMAL);
18
+ }
19
+ process.exit(EXIT_CODES.NORMAL_EXIT);
20
+ }
21
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../src/bin/types.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAChD,OAAO,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AACpD,OAAO,EAAE,SAAS,EAAE,MAAM,kCAAkC,CAAC;AAC7D,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AAEpD,MAAM,CAAC,KAAK,UAAU,cAAc,CAAC,IAAe,EAAE,MAAqB;IACzE,IAAI,IAAI,CAAC,YAAY,EAAE,CAAC;QACtB,MAAM,CAAC,KAAK,CAAC,eAAe,CAAC,CAAC;QAC9B,wEAAwE;QACxE,MAAM,SAAS,CAAC,MAAM,CAAC,CAAC;IAC1B,CAAC;IACD,IAAI,IAAI,CAAC,eAAe,IAAI,CAAC,UAAU,CAAC,eAAe,CAAC,EAAE,CAAC;QACzD,MAAM,CAAC,IAAI,CAAC,uBAAuB,CAAC,CAAC;QACrC,aAAa,CAAC,eAAe,EAAE,SAAS,CAAC,cAAc,CAAC,CAAC,QAAQ,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC,CAAC;IAC7E,CAAC;SAAM,IAAI,IAAI,CAAC,eAAe,EAAE,CAAC;QAChC,MAAM,CAAC,KAAK,CAAC,+BAA+B,CAAC,CAAC;QAC9C,OAAO,CAAC,IAAI,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC;IACpC,CAAC;IACD,OAAO,CAAC,IAAI,CAAC,UAAU,CAAC,WAAW,CAAC,CAAC;AACvC,CAAC"}
File without changes
File without changes
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "miqro",
3
- "version": "6.0.3",
3
+ "version": "6.0.4",
4
4
  "description": "",
5
5
  "type": "module",
6
6
  "main": "build/esm/src/lib.js",
@@ -0,0 +1,35 @@
1
+ #!/usr/bin/env node
2
+
3
+ import { spawn } from "node:child_process";
4
+ import { Arguments } from "../common/arguments.js";
5
+ import { EXIT_CODES } from "../common/constants.js";
6
+
7
+ export async function compileSH(args: Arguments) {
8
+ return new Promise<void>((resolve, reject) => {
9
+ try {
10
+ process.chdir(args.inflateDir);
11
+ const proc = spawn(`sh`, ["./compile.sh"]);
12
+
13
+ proc.stdout.on('data', (data) => {
14
+ console.log(`${data}`);
15
+ });
16
+
17
+ proc.stderr.on('data', (data) => {
18
+ console.log(`${data}`);
19
+ });
20
+
21
+ proc.on('close', (code) => {
22
+ console.log(`compilation exited with code ${code}`);
23
+
24
+ if (code !== 0) {
25
+ process.exit(code);
26
+ } else {
27
+ process.exit(EXIT_CODES.NORMAL_EXIT);
28
+ }
29
+ resolve();
30
+ });
31
+ } catch (e) {
32
+ reject(e);
33
+ }
34
+ });
35
+ }
@@ -0,0 +1,210 @@
1
+ import { GroupPolicy, Logger, ParserMode, RouteJSONDoc, RouterJSONDoc, SchemaProperties } from "@miqro/core";
2
+ import { Schema } from "@miqro/parser";
3
+
4
+ /*interface SchemaProperties {
5
+ [key: string]: Schema | string;
6
+ }
7
+
8
+ type ParserMode = "add_extra" | "no_extra" | "remove_extra"*/
9
+
10
+ export async function getMDDoc(args: { ignore?: string[], showFilePath?: boolean; jsonDoc: RouterJSONDoc }, logger?: Logger) {
11
+
12
+ const pathList = Object.keys(args.jsonDoc).sort();
13
+
14
+ let outMD = "";
15
+
16
+ const tableIndexItems = [];
17
+
18
+ for (const path of pathList) {
19
+ const pathData = args.jsonDoc[path];
20
+ const methods = Object.keys(pathData);
21
+ for (const method of methods) {
22
+ if (method) {
23
+ const apiDataList: RouteJSONDoc[] = pathData[method];
24
+ for (const apiData of apiDataList) {
25
+ tableIndexItems.push({
26
+ apiData
27
+ });
28
+ outMD += `## ${apiData.identifier/*.replaceAll("_", "-")*/}\n\n`;
29
+ outMD += `${args.showFilePath && (apiData as any).___filePath ? (apiData as any).___filePath + "\n\n" : ""}`;
30
+
31
+ if (apiData.name) {
32
+ outMD += `${apiData.name}\n\n`;
33
+ }
34
+ if (apiData.description) {
35
+ outMD += `${apiData.description}\n\n`;
36
+ }
37
+ outMD += `[${method}] ${path}\n\n`;
38
+
39
+ outMD += `[${path}](${path}) \n\n`;
40
+
41
+ if (apiData.policy) {
42
+ outMD += `### policy\n\n`;
43
+ outMD += policyToString(apiData.policy);
44
+ }
45
+ if (apiData.request) {
46
+ const requestOutMD = parserToString(apiData.request);
47
+ outMD += requestOutMD !== "" ? `### request\n\n${requestOutMD}` : "";
48
+ }
49
+ if (apiData.response && typeof apiData.response !== "boolean") {
50
+ const responseOutMD = parserToString(apiData.response);
51
+ outMD += responseOutMD !== "" ? `### response\n\n${responseOutMD}` : "";
52
+ }
53
+ }
54
+ }
55
+ }
56
+ }
57
+
58
+ const indexTable = getIndexTable(tableIndexItems);
59
+
60
+ return `${indexTable}\n\n${outMD}`;
61
+ }
62
+
63
+ function getIndexTable(data: {
64
+ apiData: RouteJSONDoc;
65
+ }[]): string {
66
+ return `${data.map(api => `[${api.apiData.identifier/*.replaceAll("_", "-")*/}](#${api.apiData.identifier/*.replaceAll("_", "-")*/.toLocaleLowerCase()})${api.apiData.name || api.apiData.description ? `\n\n\t${api.apiData.name ? api.apiData.name + " " : ""}${api.apiData.description ? api.apiData.description : ""}` : ""}`).join("\n\n")}`;
67
+ }
68
+
69
+ function policyToString(policy: GroupPolicy): string {
70
+ let outMD = "| groups | policy |\n";
71
+ outMD += "|--------|--------|\n";
72
+ outMD += `| ${(policy.groups instanceof Array ? policy.groups : [policy.groups]).join(",")} | ${policy.groupPolicy} |\n\n`;
73
+ return outMD;
74
+ }
75
+
76
+ export function parserToString(parser: {
77
+ status?: number | number[],
78
+ headers?: string | SchemaProperties | SchemaProperties[];
79
+ headersMode?: ParserMode;
80
+ query?: string | SchemaProperties | boolean | SchemaProperties[];
81
+ queryMode?: ParserMode;
82
+ params?: string | SchemaProperties | boolean | SchemaProperties[];
83
+ paramsMode?: ParserMode;
84
+ body?: string | SchemaProperties | boolean | SchemaProperties[];
85
+ bodyMode?: ParserMode;
86
+ }): string {
87
+ let outMD = "";
88
+ if (parser.status) {
89
+ outMD += `#### status\n\n${parser.status instanceof Array ? parser.status.join(",") : parser.status}\n\n`;
90
+ }
91
+ if (parser.params && typeof parser.params !== "boolean") {
92
+ outMD += `#### path params\n\n`;
93
+ outMD += parserPartToString(parser.params, parser.paramsMode);
94
+ }
95
+ if (parser.headers) {
96
+ outMD += `#### headers\n\n`;
97
+ outMD += parserPartToString(parser.headers, parser.headersMode);
98
+ }
99
+ if (parser.query && parser.query !== true) {
100
+ outMD += `#### query\n\n`;
101
+ outMD += parserPartToString(parser.query, parser.queryMode);
102
+ }
103
+ if (parser.body && parser.body !== true) {
104
+ outMD += `#### body\n\n`;
105
+ outMD += parserPartToString(parser.body, parser.bodyMode);
106
+ }
107
+ return outMD;
108
+ }
109
+
110
+ function parserPartToString(arg: string | SchemaProperties | false | SchemaProperties[], mode?: ParserMode): string {
111
+ if (arg === false) {
112
+ return "not allowed";
113
+ }
114
+ let outMD = "";
115
+ let maxTabulation = 1;
116
+ const parsers: Array<SchemaProperties | string> | string = arg instanceof Array ? arg : typeof arg === "string" ? [arg] : [arg];
117
+ for (const parser of parsers) {
118
+ const ret = internalParserToString(parser);
119
+ if (ret.maxTabulation > maxTabulation) {
120
+ maxTabulation = ret.maxTabulation;
121
+ }
122
+ outMD += `| | | | ${getTabulation(ret.maxTabulation * 2)}\n`;
123
+ outMD += `|--------|-------|-------|${getTabulation(ret.maxTabulation * 2, true)}\n`;
124
+ outMD += `${ret.out}\n\n`;
125
+ }
126
+ return outMD
127
+ }
128
+
129
+ function internalParserToString(parser: string | SchemaProperties, tabulation = 1): { out: string, maxTabulation: number } {
130
+ let outMD = "";
131
+ let maxTabulation = tabulation;
132
+ if (typeof parser === "string") {
133
+ outMD += `${getTabulation(tabulation)}${parser}|\n`;
134
+ } else {
135
+ const attrNames = Object.keys(parser);
136
+ for (const name of attrNames) {
137
+ const p = parser[name];
138
+ const description = typeof p === "string" ? "" : p.description ? p.description : "";
139
+
140
+ if (typeof p === "string") {
141
+ outMD += `${getTabulation(tabulation)}${name} | ${p}|\n`;
142
+ } else if (p.type.toLocaleLowerCase() === "object" || p.type.toLocaleLowerCase() === "object?") {
143
+ const rString = p.required === false || p.type.toLocaleLowerCase() === "object?" ? "?" : "";
144
+ outMD += `${getTabulation(tabulation)}${name} | object${rString}| ${description}|\n`;
145
+ const ret = parserBaseObjectTypeToString(p, tabulation + 1);
146
+ if (maxTabulation < ret.maxTabulation) {
147
+ maxTabulation = ret.maxTabulation;
148
+ }
149
+ outMD += `${ret.out}`;
150
+ } else if (p.type.toLocaleLowerCase() === "dict" || p.type.toLocaleLowerCase() === "dict?") {
151
+ const rString = p.required === false || p.type.toLocaleLowerCase() === "dict?" ? "?" : "";
152
+ outMD += `${getTabulation(tabulation)}${name} | Dict\\<${p.dictType}\>${rString}| ${description}|\n`;
153
+ if (p.dictType === "object") {
154
+ const ret = parserBaseObjectTypeToString(p, tabulation + 1);
155
+ if (maxTabulation < ret.maxTabulation) {
156
+ maxTabulation = ret.maxTabulation;
157
+ }
158
+ outMD += `${ret.out}`;
159
+ }
160
+ } else if (p.type.toLocaleLowerCase() === "array" || p.type.toLocaleLowerCase() === "array?") {
161
+ const rString = p.required === false || p.type.toLocaleLowerCase() === "array?" ? "?" : "";
162
+ outMD += `${getTabulation(tabulation)}${name} | Array\\<${p.arrayType}\>${rString}| ${description}|\n`;
163
+ if (p.arrayType.toLocaleLowerCase() === "object") {
164
+ const ret = parserBaseObjectTypeToString(p, tabulation + 1);
165
+ if (maxTabulation < ret.maxTabulation) {
166
+ maxTabulation = ret.maxTabulation;
167
+ }
168
+ outMD += `${ret.out}`;
169
+ }
170
+ } else if (p.type.toLocaleLowerCase() === "regex") {
171
+ outMD += `${getTabulation(tabulation)}${name} | ${p.regex}| ${description}|\n`;
172
+ } else if (p.type.toLocaleLowerCase() === "regex?") {
173
+ outMD += `${getTabulation(tabulation)}${name} | ${p.regex}?| ${description}|\n`;
174
+ } else if (p.type.toLocaleLowerCase() === "enum") {
175
+ outMD += `${getTabulation(tabulation)}${name} | ${p.type}| ${description}|\n`;
176
+ outMD += `${getTabulation(tabulation + 1)}| ${p.enumValues?.join(",")}|\n`;
177
+ if (maxTabulation < tabulation + 1) {
178
+ maxTabulation = tabulation + 1;
179
+ }
180
+ } else if (p.type.toLocaleLowerCase() === "enum?") {
181
+ outMD += `${getTabulation(tabulation)}${name} | ${p.type}?| ${description}|\n`;
182
+ outMD += `${getTabulation(tabulation + 1)}| ${p.enumValues?.join(",")}|\n`;
183
+ if (maxTabulation < tabulation + 1) {
184
+ maxTabulation = tabulation + 1;
185
+ }
186
+ } else {
187
+ const rString = p.required === false ? "?" : "";
188
+ outMD += `${getTabulation(tabulation)}${name} | ${p.type}${rString}| ${description}|\n`;
189
+ }
190
+ }
191
+ }
192
+ return {
193
+ out: outMD,
194
+ maxTabulation
195
+ };
196
+ }
197
+
198
+ function parserBaseObjectTypeToString(arg: Schema, tabulation: number): { out: string; maxTabulation: number } {
199
+ const options: SchemaProperties = arg.properties ? arg.properties : {};
200
+ //const outMD = `${getTabulation(tabulation)}name | type |\n${getTabulation(tabulation)}--------|--------|\n`;
201
+ return internalParserToString(options, tabulation + 1);
202
+ }
203
+
204
+ function getTabulation(n: number, header = false) {
205
+ let out = "";
206
+ for (let i = 0; i < n; i++) {
207
+ out += header ? "-|" : "| ";
208
+ }
209
+ return out;
210
+ }
@@ -0,0 +1,55 @@
1
+ import { Logger } from "@miqro/core";
2
+ import { Arguments } from "../common/arguments.js";
3
+ import { writeFileSync } from "node:fs";
4
+ import { getMDDoc } from "./doc-md.js";
5
+ import { EXIT_CODES } from "../common/constants.js";
6
+ import { InflatedResult } from "../services/app.js";
7
+
8
+ export async function generateDocs(args: Arguments, logger: Logger, result: InflatedResult) {
9
+ /*
10
+ ** TODO FIX THIS MESS
11
+ */
12
+
13
+ const router = result.router;
14
+ const fileMap = result.fileMap;
15
+
16
+ const fileMapAPIRouteList = Object.keys(fileMap).map(f => fileMap[f]).filter(fMap => fMap.previewMethod === "api").map(fMap => fMap.routes);
17
+
18
+ const jsonDoc = router.getJSONDoc();
19
+ Object.keys(jsonDoc).forEach(path => {
20
+ const methods = Object.keys(jsonDoc[path]);
21
+ methods.forEach(method => {
22
+ const data = jsonDoc[path][method];
23
+ //console.log("[%s] [%s]", path, method);
24
+
25
+ if (fileMapAPIRouteList.filter(f => {
26
+ for (const r of f) {
27
+ if (r.method === String(method).toUpperCase() && r.path === path) {
28
+ return true;
29
+ }
30
+ }
31
+ return false;
32
+ }).length === 0) {
33
+ //console.log("DELETE [%s] [%s]", path, method);
34
+ delete jsonDoc[path][method];
35
+ } else {
36
+ //console.log("KEEP [%s] [%s]", path, method);
37
+ }
38
+
39
+ });
40
+ });
41
+
42
+ switch (args.generateDocType) {
43
+ case "JSON":
44
+ logger.info("writing [%s]", args.generateDocOut);
45
+ writeFileSync(args.generateDocOut, JSON.stringify(jsonDoc, undefined, 4));
46
+ break;
47
+ case "MD":
48
+ logger.info("writing [%s]", args.generateDocOut);
49
+ writeFileSync(args.generateDocOut, await getMDDoc({ showFilePath: true, jsonDoc }));
50
+ break;
51
+ default:
52
+ logger.error("--generate-doc-type invalid!");
53
+ process.exit(EXIT_CODES.BAD_ARGUMENTS);
54
+ }
55
+ }
@@ -0,0 +1,92 @@
1
+ #!/usr/bin/env node
2
+
3
+ import { RequestOptions, request as reqlRequest } from "@miqro/request";
4
+ import { resetGlobals, runTests } from "@miqro/test/dist/runner/common.js";
5
+ import { getServicePath, TEST_SOCKET } from "../common/paths.js";
6
+ import { createNodeRuntime } from "@miqro/jsx-node";
7
+ import { RuntimeOptions, RuntimeShadowRootInit, RuntimeURL } from "@miqro/jsx";
8
+ import { EXIT_CODES } from "../common/constants.js";
9
+ import { Miqro } from "../services/app.js";
10
+ import { setupTests } from "../inflate/setup-test.js";
11
+
12
+ export async function testMain(app: Miqro) {
13
+ const startMS = Date.now();
14
+ //resetTests();
15
+ resetGlobals();
16
+ //const testLogger = getLogger("test");
17
+ globalThis.test = {
18
+ PORT: TEST_SOCKET,
19
+ request: (request: RequestOptions) => reqlRequest({
20
+ ...request,
21
+ socketPath: TEST_SOCKET
22
+ }),
23
+ logger: app.logger,
24
+ sleep: async (ms: number) => new Promise(resolve => setTimeout(resolve, ms)),
25
+ jsx: {
26
+ createRuntime: createNodeRuntime,
27
+ test: (cb, args: {
28
+ runtimeOptions?: {
29
+ basePath?: string | null;
30
+ url?: RuntimeURL;
31
+ logger?: {
32
+ log: Function;
33
+ error: Function;
34
+ };
35
+ },
36
+ containerOptions?: {
37
+ runtimeOptions?: RuntimeOptions;
38
+ shadowInit?: boolean | RuntimeShadowRootInit;
39
+ };
40
+ }) => {
41
+ return async () => {
42
+ const runtime = createNodeRuntime(args.runtimeOptions);
43
+ const root = runtime.createElement("root");
44
+ const container = runtime.createContainer(root, args.containerOptions);
45
+ await cb(container, root, runtime);
46
+ container.disconnect();
47
+ }
48
+ }
49
+ }
50
+ }
51
+
52
+ for (const service of app.options.services) {
53
+ const servicePath = getServicePath(service);
54
+ await setupTests(app.logger, servicePath);
55
+ }
56
+
57
+ console.log("");
58
+ app.logger.log("===starting tests===");
59
+ console.log("");
60
+
61
+ const ret = await runTests(undefined, app.logger);
62
+
63
+ console.log("");
64
+ app.logger.log("===tests ended===");
65
+ if (ret.failed.length > 0) {
66
+ console.log("");
67
+ app.logger.error("===failed tests===");
68
+ console.log("");
69
+ }
70
+
71
+ const took = Date.now() - startMS;
72
+ ret.failed.forEach(e => {
73
+ app.logger.error("\x1b[31m%s\x1b[0m", e.fullName);
74
+ app.logger.error(e.error);
75
+ });
76
+
77
+
78
+ console.log("");
79
+ app.logger.log(ret.passed + " tests passed");
80
+ if (ret.failed.length > 0) {
81
+ app.logger.error(ret.failed.length + " failed");
82
+ } else {
83
+ app.logger.log(ret.failed.length + " failed");
84
+ }
85
+
86
+ app.logger.log("took " + took + "ms");
87
+
88
+ if (ret.failed.length > 0) {
89
+ process.exit(EXIT_CODES.TEST_FAILED);
90
+ }
91
+ await app.dbManager.closeAll();
92
+ }
@@ -0,0 +1,22 @@
1
+ import { MinimalLogger } from "@miqro/core";
2
+ import { Arguments } from "../common/arguments.js";
3
+ import { initTypes } from "../common/assets.js";
4
+ import { existsSync, writeFileSync } from "node:fs";
5
+ import { TEMPLATES } from "../../editor/common/templates.js";
6
+ import { EXIT_CODES } from "../common/constants.js";
7
+
8
+ export async function installTypings(args: Arguments, logger: MinimalLogger) {
9
+ if (args.installTypes) {
10
+ logger.debug("writing types");
11
+ // install typing for typescript only if argument --install-types is set
12
+ await initTypes(logger);
13
+ }
14
+ if (args.installTSConfig && !existsSync("tsconfig.json")) {
15
+ logger.info("writing tsconfig.json");
16
+ writeFileSync("tsconfig.json", TEMPLATES["TSCONFIGJSON"].template("", ""));
17
+ } else if (args.installTSConfig) {
18
+ logger.error("tsconfig.json already exists!");
19
+ process.exit(EXIT_CODES.ABNORMAL);
20
+ }
21
+ process.exit(EXIT_CODES.NORMAL_EXIT);
22
+ }