miqro 7.0.1 → 7.0.3
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/editor/auth.d.ts +6 -0
- package/build/esm/editor/auth.js +41 -0
- package/build/esm/editor/common/admin-interface.d.ts +36 -0
- package/build/esm/editor/common/admin-interface.js +44 -0
- package/build/esm/editor/common/constants.d.ts +4 -0
- package/build/esm/editor/common/constants.js +20 -0
- package/build/esm/editor/common/constants.server.d.ts +2 -0
- package/build/esm/editor/common/constants.server.js +4 -0
- package/build/esm/editor/common/editor-index.d.ts +2 -0
- package/build/esm/editor/common/editor-index.js +14 -0
- package/build/esm/editor/common/html-encode.d.ts +1 -0
- package/build/esm/editor/common/html-encode.js +14 -0
- package/build/esm/editor/common/log-socket.d.ts +15 -0
- package/build/esm/editor/common/log-socket.js +71 -0
- package/build/esm/editor/common/templates.d.ts +11 -0
- package/build/esm/editor/common/templates.js +477 -0
- package/build/esm/editor/components/api-preview.d.ts +11 -0
- package/build/esm/editor/components/api-preview.js +92 -0
- package/build/esm/editor/components/editor.d.ts +16 -0
- package/build/esm/editor/components/editor.js +367 -0
- package/build/esm/editor/components/file-browser.d.ts +37 -0
- package/build/esm/editor/components/file-browser.js +127 -0
- package/build/esm/editor/components/file-editor-toolbar.d.ts +22 -0
- package/build/esm/editor/components/file-editor-toolbar.js +95 -0
- package/build/esm/editor/components/file-editor.d.ts +32 -0
- package/build/esm/editor/components/file-editor.js +61 -0
- package/build/esm/editor/components/filter-query.d.ts +1 -0
- package/build/esm/editor/components/filter-query.js +23 -0
- package/build/esm/editor/components/highlight-text-area.d.ts +11 -0
- package/build/esm/editor/components/highlight-text-area.js +127 -0
- package/build/esm/editor/components/log-viewer.d.ts +6 -0
- package/build/esm/editor/components/log-viewer.js +71 -0
- package/build/esm/editor/components/new-file.d.ts +10 -0
- package/build/esm/editor/components/new-file.js +119 -0
- package/build/esm/editor/components/scroll-query.d.ts +7 -0
- package/build/esm/editor/components/scroll-query.js +22 -0
- package/build/esm/editor/components/start-page.d.ts +13 -0
- package/build/esm/editor/components/start-page.js +32 -0
- package/build/esm/editor/http/admin/editor/api/fs/delete.api.d.ts +3 -0
- package/build/esm/editor/http/admin/editor/api/fs/delete.api.js +30 -0
- package/build/esm/editor/http/admin/editor/api/fs/read.api.d.ts +5 -0
- package/build/esm/editor/http/admin/editor/api/fs/read.api.js +50 -0
- package/build/esm/editor/http/admin/editor/api/fs/rename.api.d.ts +4 -0
- package/build/esm/editor/http/admin/editor/api/fs/rename.api.js +40 -0
- package/build/esm/editor/http/admin/editor/api/fs/scan.api.d.ts +26 -0
- package/build/esm/editor/http/admin/editor/api/fs/scan.api.js +150 -0
- package/build/esm/editor/http/admin/editor/api/fs/write.api.d.ts +3 -0
- package/build/esm/editor/http/admin/editor/api/fs/write.api.js +39 -0
- package/build/esm/editor/http/admin/editor/api/server/reload.api.d.ts +10 -0
- package/build/esm/editor/http/admin/editor/api/server/reload.api.js +46 -0
- package/build/esm/editor/http/admin/editor/api/server/restart.api.d.ts +10 -0
- package/build/esm/editor/http/admin/editor/api/server/restart.api.js +46 -0
- package/build/esm/editor/http/admin/editor/editor.d.ts +1 -0
- package/build/esm/editor/http/admin/editor/editor.js +8 -0
- package/build/esm/editor/http/admin/editor/index.api.d.ts +3 -0
- package/build/esm/editor/http/admin/editor/index.api.js +22 -0
- package/build/esm/editor/server.d.ts +3 -0
- package/build/esm/editor/server.js +49 -0
- package/build/esm/editor/ws.d.ts +3 -0
- package/build/esm/editor/ws.js +11 -0
- package/build/esm/src/inflate/inflate-sea.js +8 -1
- package/build/esm/src/services/app.js +7 -2
- package/build/lib.cjs +14 -3
- package/editor/auth.ts +51 -0
- package/editor/common/admin-interface.ts +84 -0
- package/editor/common/constants.server.ts +5 -0
- package/editor/common/constants.ts +21 -0
- package/editor/common/editor-index.tsx +17 -0
- package/editor/common/html-encode.ts +14 -0
- package/editor/common/log-socket.tsx +87 -0
- package/editor/common/templates.ts +481 -0
- package/editor/components/api-preview.tsx +118 -0
- package/editor/components/editor.tsx +496 -0
- package/editor/components/file-browser.tsx +311 -0
- package/editor/components/file-editor-toolbar.tsx +194 -0
- package/editor/components/file-editor.tsx +125 -0
- package/editor/components/filter-query.tsx +26 -0
- package/editor/components/highlight-text-area.tsx +148 -0
- package/editor/components/log-viewer.tsx +113 -0
- package/editor/components/new-file.tsx +172 -0
- package/editor/components/scroll-query.tsx +25 -0
- package/editor/components/start-page.tsx +52 -0
- package/editor/http/admin/editor/api/fs/delete.api.tsx +32 -0
- package/editor/http/admin/editor/api/fs/read.api.tsx +55 -0
- package/editor/http/admin/editor/api/fs/rename.api.tsx +41 -0
- package/editor/http/admin/editor/api/fs/scan.api.tsx +181 -0
- package/editor/http/admin/editor/api/fs/write.api.tsx +41 -0
- package/editor/http/admin/editor/api/server/reload.api.ts +53 -0
- package/editor/http/admin/editor/api/server/restart.api.tsx +52 -0
- package/editor/http/admin/editor/editor.tsx +10 -0
- package/editor/http/admin/editor/index.api.tsx +42 -0
- package/editor/server.ts +57 -0
- package/editor/ws.ts +15 -0
- package/package.json +2 -2
- package/src/bin/compile.ts +35 -0
- package/src/bin/doc-md.ts +210 -0
- package/src/bin/generate-doc.ts +64 -0
- package/src/bin/test.ts +92 -0
- package/src/bin/types.ts +34 -0
- package/src/cluster.ts +27 -0
- package/src/common/arguments.ts +762 -0
- package/src/common/assets.ts +148 -0
- package/src/common/checksum.ts +58 -0
- package/src/common/constants.ts +18 -0
- package/src/common/content-type.ts +84 -0
- package/src/common/esbuild.ts +102 -0
- package/src/common/exit.ts +91 -0
- package/src/common/fs.ts +82 -0
- package/src/common/help.ts +60 -0
- package/src/common/jsx.ts +562 -0
- package/src/common/jwt.ts +85 -0
- package/src/common/paths.ts +107 -0
- package/src/common/watch.ts +88 -0
- package/src/inflate/inflate-sea.ts +244 -0
- package/src/inflate/inflate.ts +101 -0
- package/src/inflate/md.ts +25 -0
- package/src/inflate/setup-auth.ts +41 -0
- package/src/inflate/setup-cors.ts +41 -0
- package/src/inflate/setup-db.ts +117 -0
- package/src/inflate/setup-error.ts +44 -0
- package/src/inflate/setup-http.ts +704 -0
- package/src/inflate/setup-log.ts +45 -0
- package/src/inflate/setup-middleware.ts +47 -0
- package/src/inflate/setup-server-config.ts +48 -0
- package/src/inflate/setup-test.ts +23 -0
- package/src/inflate/setup-ws.ts +50 -0
- package/src/inflate/setup.doc.ts +92 -0
- package/src/inflate/utils/sea-utils.ts +14 -0
- package/src/lib.ts +34 -0
- package/src/main.ts +101 -0
- package/src/services/app.ts +703 -0
- package/src/services/editor.tsx +101 -0
- package/src/services/globals.ts.ignore +186 -0
- package/src/services/hot-reload.ts +51 -0
- package/src/services/migrations.ts +68 -0
- package/src/services/utils/admin-interface.ts +37 -0
- package/src/services/utils/cache.ts +88 -0
- package/src/services/utils/cluster-cache.ts +230 -0
- package/src/services/utils/cluster-ws.ts +202 -0
- package/src/services/utils/db-manager.ts +92 -0
- package/src/services/utils/get-route.ts +70 -0
- package/src/services/utils/jwt.ts +25 -0
- package/src/services/utils/log-transport.ts +81 -0
- package/src/services/utils/log.ts +92 -0
- package/src/services/utils/middleware.ts +10 -0
- package/src/services/utils/server-interface.ts +122 -0
- package/src/services/utils/websocketmanager.ts +157 -0
- package/src/types.ts +307 -0
|
@@ -0,0 +1,762 @@
|
|
|
1
|
+
import { checkEnvVariable } from "@miqro/core";
|
|
2
|
+
import { cp, existsSync, readFileSync, statSync } from "node:fs";
|
|
3
|
+
import { basename, dirname, join, relative, resolve } from "node:path";
|
|
4
|
+
import { cwd, env, platform, arch } from "node:process";
|
|
5
|
+
|
|
6
|
+
import { EXIT_CODES } from "./constants.js";
|
|
7
|
+
import { tmpdir } from "node:os";
|
|
8
|
+
import { randomUUID } from "node:crypto";
|
|
9
|
+
import { BIN_NAME, help, usage } from "./help.js";
|
|
10
|
+
import { getMiqroJSONPath, TEST_SOCKET } from "./paths.js";
|
|
11
|
+
import { isSea } from "node:sea";
|
|
12
|
+
import cluster from "node:cluster";
|
|
13
|
+
import { __package_dirname, getVersion } from "./assets.js";
|
|
14
|
+
import { Parser, Schema } from "@miqro/parser";
|
|
15
|
+
import { ServerOptions } from "node:https";
|
|
16
|
+
|
|
17
|
+
const parser = new Parser();
|
|
18
|
+
|
|
19
|
+
interface MiqroJSON {
|
|
20
|
+
services?: string[];
|
|
21
|
+
port?: string | number;
|
|
22
|
+
inflateDir?: string;
|
|
23
|
+
name?: string;
|
|
24
|
+
browser?: string | boolean;
|
|
25
|
+
logFile?: string | boolean;
|
|
26
|
+
editor?: boolean;
|
|
27
|
+
https?: boolean;
|
|
28
|
+
serverOptions?: ServerOptions;
|
|
29
|
+
httpsRedirect?: number;
|
|
30
|
+
inflateParallel?: number;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
const MiqroJSONSchema: Schema<MiqroJSON> = {
|
|
34
|
+
type: "object",
|
|
35
|
+
properties: {
|
|
36
|
+
name: "string?",
|
|
37
|
+
services: "string[]?",
|
|
38
|
+
port: "number?|string?",
|
|
39
|
+
inflateDir: "string?",
|
|
40
|
+
browser: "boolean?|string?",
|
|
41
|
+
logFile: "boolean?|string?",
|
|
42
|
+
editor: "boolean?",
|
|
43
|
+
https: "boolean?",
|
|
44
|
+
serverOptions: "any?",
|
|
45
|
+
httpsRedirect: "number?",
|
|
46
|
+
inflateParallel: "number?"
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
export function importMiqroJSON(inFile: string) {
|
|
51
|
+
const mod = JSON.parse(readFileSync(inFile).toString());
|
|
52
|
+
const module = parser.parse(mod, MiqroJSONSchema, basename(inFile));
|
|
53
|
+
if (module !== undefined) {
|
|
54
|
+
return module as MiqroJSON;
|
|
55
|
+
} else {
|
|
56
|
+
throw new Error(`error loading [${inFile}] undefined`);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
export function getPORT() {
|
|
61
|
+
return checkEnvVariable("PORT", "8080");
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
export interface Arguments {
|
|
65
|
+
name?: string;
|
|
66
|
+
browser?: string | boolean;
|
|
67
|
+
logFile?: string | boolean;
|
|
68
|
+
// installTypes: boolean;
|
|
69
|
+
installMiqroJSON: boolean;
|
|
70
|
+
installTSConfig: boolean;
|
|
71
|
+
install: boolean;
|
|
72
|
+
test: boolean;
|
|
73
|
+
port: string;
|
|
74
|
+
inflate: boolean;
|
|
75
|
+
generateDoc: boolean;
|
|
76
|
+
generateDocOut: string;
|
|
77
|
+
miqroJSONPath: string | false;
|
|
78
|
+
disableMiqroJSON: boolean;
|
|
79
|
+
generateDocAll: boolean;
|
|
80
|
+
generateDocType: "JSON" | "MD";
|
|
81
|
+
migrateUp: boolean;
|
|
82
|
+
migrateDown: boolean;
|
|
83
|
+
compile: boolean;
|
|
84
|
+
inflateSEA: boolean;
|
|
85
|
+
inflateDir: string;
|
|
86
|
+
services: string[];
|
|
87
|
+
editor: boolean;
|
|
88
|
+
hotreload: boolean;
|
|
89
|
+
watch: boolean;
|
|
90
|
+
https: boolean;
|
|
91
|
+
serverOptions: ServerOptions;
|
|
92
|
+
httpsRedirect?: number;
|
|
93
|
+
inflateParallel?: number;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* parse process.argv arguments
|
|
98
|
+
*/
|
|
99
|
+
export function parseArguments(): Arguments {
|
|
100
|
+
//env["LOG_FILE"] = env["LOG_FILE"] ? env["LOG_FILE"] : "./server.log";
|
|
101
|
+
|
|
102
|
+
|
|
103
|
+
const args = cluster.isPrimary ? process.argv.slice(2, process.argv.length) : process.argv.slice(3, process.argv.length);
|
|
104
|
+
const flags: {
|
|
105
|
+
inflateParallel: number | null;
|
|
106
|
+
httpsRedirect: number | null;
|
|
107
|
+
https: boolean | null;
|
|
108
|
+
serverOptions: ServerOptions;
|
|
109
|
+
logFile: string | boolean | null;
|
|
110
|
+
browser: string | boolean | null;
|
|
111
|
+
name: string | null;
|
|
112
|
+
// installTypes: boolean | null;
|
|
113
|
+
installMiqroJSON: boolean | null;
|
|
114
|
+
installTSConfig: boolean | null;
|
|
115
|
+
install: boolean | null;
|
|
116
|
+
inflate: boolean | null;
|
|
117
|
+
port: string | null;
|
|
118
|
+
generateDoc: boolean | null;
|
|
119
|
+
generateDocAll: boolean | null;
|
|
120
|
+
miqroJSONPath: string | null;
|
|
121
|
+
disableMiqroJSON: boolean | null;
|
|
122
|
+
generateDocOut?: string | null;
|
|
123
|
+
generateDocType?: string | null;
|
|
124
|
+
test: boolean;
|
|
125
|
+
migrateUp: boolean | null;
|
|
126
|
+
migrateDown: boolean | null;
|
|
127
|
+
compile: boolean | null;
|
|
128
|
+
inflateSEA: boolean | null;
|
|
129
|
+
editor: boolean | null;
|
|
130
|
+
inflateDir?: string | null;
|
|
131
|
+
hotreload?: boolean | null;
|
|
132
|
+
watch?: boolean | null;
|
|
133
|
+
} = {
|
|
134
|
+
inflateParallel: null,
|
|
135
|
+
httpsRedirect: null,
|
|
136
|
+
https: null,
|
|
137
|
+
serverOptions: {},
|
|
138
|
+
name: null,
|
|
139
|
+
browser: null,
|
|
140
|
+
logFile: null,
|
|
141
|
+
hotreload: null,
|
|
142
|
+
watch: null,
|
|
143
|
+
miqroJSONPath: null,
|
|
144
|
+
installMiqroJSON: null,
|
|
145
|
+
install: null,
|
|
146
|
+
disableMiqroJSON: null,
|
|
147
|
+
// installTypes: null,
|
|
148
|
+
port: null,
|
|
149
|
+
installTSConfig: null,
|
|
150
|
+
migrateUp: null,
|
|
151
|
+
migrateDown: null,
|
|
152
|
+
inflateSEA: null,
|
|
153
|
+
compile: null,
|
|
154
|
+
test: null,
|
|
155
|
+
inflate: null,
|
|
156
|
+
generateDoc: null,
|
|
157
|
+
generateDocAll: null,
|
|
158
|
+
generateDocOut: null,
|
|
159
|
+
generateDocType: null,
|
|
160
|
+
editor: null,
|
|
161
|
+
inflateDir: null
|
|
162
|
+
};
|
|
163
|
+
const services: string[] = [];
|
|
164
|
+
|
|
165
|
+
for (let i = 0; i < args.length; i++) {
|
|
166
|
+
const argument = args[i];
|
|
167
|
+
switch (argument) {
|
|
168
|
+
case "-v":
|
|
169
|
+
case "--version":
|
|
170
|
+
const { VERSION, NODE_VERSION, ESBUILD_VERSION } = getVersion();
|
|
171
|
+
if (isSea()) {
|
|
172
|
+
console.log("version [%s]", VERSION);
|
|
173
|
+
console.log("Node.js version [%s]", NODE_VERSION);
|
|
174
|
+
console.log("esbuild version [%s]", ESBUILD_VERSION);
|
|
175
|
+
console.log("platform [%s-%s]", platform, arch);
|
|
176
|
+
} else {
|
|
177
|
+
const packageJSON = JSON.parse(readFileSync(resolve(__package_dirname, "package.json")).toString());
|
|
178
|
+
const VERSION = packageJSON.version;
|
|
179
|
+
console.log("version [%s]", VERSION);
|
|
180
|
+
}
|
|
181
|
+
process.exit(EXIT_CODES.NORMAL_EXIT);
|
|
182
|
+
case "-h":
|
|
183
|
+
case "--help":
|
|
184
|
+
console.log(usage);
|
|
185
|
+
console.log(help);
|
|
186
|
+
process.exit(EXIT_CODES.NORMAL_EXIT);
|
|
187
|
+
case "--disable-miqrojson":
|
|
188
|
+
if (flags.disableMiqroJSON !== null || flags.miqroJSONPath !== null) {
|
|
189
|
+
console.error("bad arguments.");
|
|
190
|
+
console.error(usage);
|
|
191
|
+
process.exit(EXIT_CODES.BAD_ARGUMENTS);
|
|
192
|
+
}
|
|
193
|
+
flags.disableMiqroJSON = true;
|
|
194
|
+
continue;
|
|
195
|
+
case "--config":
|
|
196
|
+
if (flags.miqroJSONPath !== null || flags.disableMiqroJSON !== null) {
|
|
197
|
+
console.error("bad arguments.");
|
|
198
|
+
console.error(usage);
|
|
199
|
+
process.exit(EXIT_CODES.BAD_ARGUMENTS);
|
|
200
|
+
}
|
|
201
|
+
if (typeof args[i + 1] !== "string") {
|
|
202
|
+
console.error("bad arguments. --config must be a string.");
|
|
203
|
+
console.error(usage);
|
|
204
|
+
process.exit(EXIT_CODES.BAD_ARGUMENTS);
|
|
205
|
+
} else {
|
|
206
|
+
const cPath = String(args[i + 1]) as any;
|
|
207
|
+
flags.miqroJSONPath = cPath;
|
|
208
|
+
}
|
|
209
|
+
i++;
|
|
210
|
+
continue;
|
|
211
|
+
case "--install-tsconfig":
|
|
212
|
+
if (flags.inflate !== null || flags.installTSConfig !== null) {
|
|
213
|
+
console.error("bad arguments.");
|
|
214
|
+
console.error(usage);
|
|
215
|
+
process.exit(EXIT_CODES.BAD_ARGUMENTS);
|
|
216
|
+
}
|
|
217
|
+
flags.installTSConfig = true;
|
|
218
|
+
continue;
|
|
219
|
+
case "--install":
|
|
220
|
+
if (flags.inflate !== null || flags.installTSConfig !== null) {
|
|
221
|
+
console.error("bad arguments.");
|
|
222
|
+
console.error(usage);
|
|
223
|
+
process.exit(EXIT_CODES.BAD_ARGUMENTS);
|
|
224
|
+
}
|
|
225
|
+
flags.install = true;
|
|
226
|
+
continue;
|
|
227
|
+
case "--watch":
|
|
228
|
+
if (flags.watch !== null) {
|
|
229
|
+
console.error("bad arguments.");
|
|
230
|
+
console.error(usage);
|
|
231
|
+
process.exit(EXIT_CODES.BAD_ARGUMENTS);
|
|
232
|
+
}
|
|
233
|
+
flags.watch = true;
|
|
234
|
+
continue;
|
|
235
|
+
case "--hot-reload":
|
|
236
|
+
if (flags.hotreload !== null) {
|
|
237
|
+
console.error("bad arguments.");
|
|
238
|
+
console.error(usage);
|
|
239
|
+
process.exit(EXIT_CODES.BAD_ARGUMENTS);
|
|
240
|
+
}
|
|
241
|
+
flags.hotreload = true;
|
|
242
|
+
continue;
|
|
243
|
+
case "--https":
|
|
244
|
+
if (flags.https !== null) {
|
|
245
|
+
console.error("bad arguments.");
|
|
246
|
+
console.error(usage);
|
|
247
|
+
process.exit(EXIT_CODES.BAD_ARGUMENTS);
|
|
248
|
+
}
|
|
249
|
+
flags.https = true;
|
|
250
|
+
continue;
|
|
251
|
+
case "--https-redirect":
|
|
252
|
+
if (flags.httpsRedirect !== null) {
|
|
253
|
+
console.error("bad arguments.");
|
|
254
|
+
console.error(usage);
|
|
255
|
+
process.exit(EXIT_CODES.BAD_ARGUMENTS);
|
|
256
|
+
}
|
|
257
|
+
const httpsRedirectPort = parseInt(String(args[i + 1]) as any, 10);
|
|
258
|
+
if (isNaN(httpsRedirectPort)) {
|
|
259
|
+
console.error("bad arguments. --https-redirect must be a number.");
|
|
260
|
+
console.error(usage);
|
|
261
|
+
process.exit(EXIT_CODES.BAD_ARGUMENTS);
|
|
262
|
+
}
|
|
263
|
+
flags.httpsRedirect = httpsRedirectPort;
|
|
264
|
+
i++;
|
|
265
|
+
continue;
|
|
266
|
+
case "--https-cert":
|
|
267
|
+
if (flags.serverOptions.cert) {
|
|
268
|
+
console.error("bad arguments.");
|
|
269
|
+
console.error(usage);
|
|
270
|
+
process.exit(EXIT_CODES.BAD_ARGUMENTS);
|
|
271
|
+
}
|
|
272
|
+
const httpsCertPath = args[i + 1] as any;
|
|
273
|
+
if (typeof httpsCertPath !== "string") {
|
|
274
|
+
console.error("bad arguments. --https-cert must be a string.");
|
|
275
|
+
console.error(usage);
|
|
276
|
+
process.exit(EXIT_CODES.BAD_ARGUMENTS);
|
|
277
|
+
}
|
|
278
|
+
flags.serverOptions.cert = readFileSync(httpsCertPath);
|
|
279
|
+
i++;
|
|
280
|
+
continue;
|
|
281
|
+
case "--https-key":
|
|
282
|
+
if (flags.serverOptions.key) {
|
|
283
|
+
console.error("bad arguments.");
|
|
284
|
+
console.error(usage);
|
|
285
|
+
process.exit(EXIT_CODES.BAD_ARGUMENTS);
|
|
286
|
+
}
|
|
287
|
+
const httpsKeyPath = args[i + 1] as any;
|
|
288
|
+
if (typeof httpsKeyPath !== "string") {
|
|
289
|
+
console.error("bad arguments. --https-key must be a string.");
|
|
290
|
+
console.error(usage);
|
|
291
|
+
process.exit(EXIT_CODES.BAD_ARGUMENTS);
|
|
292
|
+
}
|
|
293
|
+
flags.serverOptions.key = readFileSync(httpsKeyPath);
|
|
294
|
+
i++;
|
|
295
|
+
continue;
|
|
296
|
+
case "--port":
|
|
297
|
+
if (flags.port !== null) {
|
|
298
|
+
console.error("bad arguments.");
|
|
299
|
+
console.error(usage);
|
|
300
|
+
process.exit(EXIT_CODES.BAD_ARGUMENTS);
|
|
301
|
+
}
|
|
302
|
+
if (typeof args[i + 1] !== "string") {
|
|
303
|
+
console.error("bad arguments. --port must be a string.");
|
|
304
|
+
console.error(usage);
|
|
305
|
+
process.exit(EXIT_CODES.BAD_ARGUMENTS);
|
|
306
|
+
} else {
|
|
307
|
+
const cPort = String(args[i + 1]) as any;
|
|
308
|
+
flags.port = cPort;
|
|
309
|
+
}
|
|
310
|
+
i++;
|
|
311
|
+
continue;
|
|
312
|
+
case "--name":
|
|
313
|
+
if (flags.name !== null) {
|
|
314
|
+
console.error("bad arguments.");
|
|
315
|
+
console.error(usage);
|
|
316
|
+
process.exit(EXIT_CODES.BAD_ARGUMENTS);
|
|
317
|
+
}
|
|
318
|
+
if (typeof args[i + 1] !== "string") {
|
|
319
|
+
console.error("bad arguments. --port must be a string.");
|
|
320
|
+
console.error(usage);
|
|
321
|
+
process.exit(EXIT_CODES.BAD_ARGUMENTS);
|
|
322
|
+
} else {
|
|
323
|
+
const cName = String(args[i + 1]).toUpperCase() as any;
|
|
324
|
+
flags.name = cName;
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
i++;
|
|
328
|
+
continue;
|
|
329
|
+
case "--log-file":
|
|
330
|
+
if (flags.logFile !== null) {
|
|
331
|
+
console.error("bad arguments.");
|
|
332
|
+
console.error(usage);
|
|
333
|
+
process.exit(EXIT_CODES.BAD_ARGUMENTS);
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
if (typeof args[i + 1] !== "string") {
|
|
337
|
+
console.error("bad arguments. --port must be a string.");
|
|
338
|
+
console.error(usage);
|
|
339
|
+
process.exit(EXIT_CODES.BAD_ARGUMENTS);
|
|
340
|
+
} else {
|
|
341
|
+
const cLofFile = String(args[i + 1]) as any;
|
|
342
|
+
flags.logFile = cLofFile;
|
|
343
|
+
}
|
|
344
|
+
i++;
|
|
345
|
+
continue;
|
|
346
|
+
case "--browser":
|
|
347
|
+
if (flags.browser !== null) {
|
|
348
|
+
console.error("bad arguments.");
|
|
349
|
+
console.error(usage);
|
|
350
|
+
process.exit(EXIT_CODES.BAD_ARGUMENTS);
|
|
351
|
+
}
|
|
352
|
+
|
|
353
|
+
if (typeof args[i + 1] !== "string") {
|
|
354
|
+
console.error("bad arguments. --port must be a string.");
|
|
355
|
+
console.error(usage);
|
|
356
|
+
process.exit(EXIT_CODES.BAD_ARGUMENTS);
|
|
357
|
+
} else {
|
|
358
|
+
const cBrowser = String(args[i + 1]) as any;
|
|
359
|
+
flags.browser = cBrowser;
|
|
360
|
+
}
|
|
361
|
+
i++;
|
|
362
|
+
continue;
|
|
363
|
+
case "--generate-doc":
|
|
364
|
+
if (flags.generateDoc !== null) {
|
|
365
|
+
console.error("bad arguments.");
|
|
366
|
+
console.error(usage);
|
|
367
|
+
process.exit(EXIT_CODES.BAD_ARGUMENTS);
|
|
368
|
+
}
|
|
369
|
+
flags.generateDoc = true;
|
|
370
|
+
continue;
|
|
371
|
+
case "--generate-doc-all":
|
|
372
|
+
if (flags.generateDocAll !== null) {
|
|
373
|
+
console.error("bad arguments.");
|
|
374
|
+
console.error(usage);
|
|
375
|
+
process.exit(EXIT_CODES.BAD_ARGUMENTS);
|
|
376
|
+
}
|
|
377
|
+
flags.generateDocAll = true;
|
|
378
|
+
continue;
|
|
379
|
+
case "--generate-doc-out":
|
|
380
|
+
if (flags.generateDocOut !== null) {
|
|
381
|
+
console.error("bad arguments. --generate-doc-out already set.");
|
|
382
|
+
console.error(usage);
|
|
383
|
+
process.exit(EXIT_CODES.BAD_ARGUMENTS);
|
|
384
|
+
}
|
|
385
|
+
flags.generateDocOut = args[i + 1];
|
|
386
|
+
if (typeof flags.generateDocOut !== "string") {
|
|
387
|
+
console.error("bad arguments. --generate-doc-out missing value.");
|
|
388
|
+
console.error(usage);
|
|
389
|
+
process.exit(EXIT_CODES.BAD_ARGUMENTS);
|
|
390
|
+
}
|
|
391
|
+
i++;
|
|
392
|
+
continue;
|
|
393
|
+
case "--generate-doc-type":
|
|
394
|
+
if (flags.generateDocType !== null) {
|
|
395
|
+
console.error("bad arguments. --generate-doc-type already set.");
|
|
396
|
+
console.error(usage);
|
|
397
|
+
process.exit(EXIT_CODES.BAD_ARGUMENTS);
|
|
398
|
+
}
|
|
399
|
+
const gDt = String(args[i + 1]).toUpperCase() as any;
|
|
400
|
+
if (typeof gDt !== "string" || (gDt !== "JSON" && gDt !== "MD")) {
|
|
401
|
+
console.error("bad arguments. --generate-doc-type can be json or md.");
|
|
402
|
+
console.error(usage);
|
|
403
|
+
process.exit(EXIT_CODES.BAD_ARGUMENTS);
|
|
404
|
+
}
|
|
405
|
+
flags.generateDocType = gDt;
|
|
406
|
+
i++;
|
|
407
|
+
continue;
|
|
408
|
+
case "--compile":
|
|
409
|
+
if (flags.compile !== null) {
|
|
410
|
+
if (flags.inflateDir === null) {
|
|
411
|
+
flags.inflateDir = resolve(tmpdir(), `${BIN_NAME}-compile`, randomUUID());
|
|
412
|
+
}
|
|
413
|
+
console.error("bad arguments. --compile already set");
|
|
414
|
+
console.error(usage);
|
|
415
|
+
process.exit(EXIT_CODES.BAD_ARGUMENTS);
|
|
416
|
+
}
|
|
417
|
+
flags.compile = true;
|
|
418
|
+
flags.inflateSEA = true;
|
|
419
|
+
flags.inflate = true;
|
|
420
|
+
continue;
|
|
421
|
+
/*case "--install-types":
|
|
422
|
+
if (flags.inflate !== null || flags.installTypes !== null) {
|
|
423
|
+
console.error("bad arguments.");
|
|
424
|
+
console.error(usage);
|
|
425
|
+
process.exit(EXIT_CODES.BAD_ARGUMENTS);
|
|
426
|
+
}
|
|
427
|
+
flags.installTypes = true;
|
|
428
|
+
continue;*/
|
|
429
|
+
case "--editor":
|
|
430
|
+
if (flags.editor !== null) {
|
|
431
|
+
console.error("bad arguments.");
|
|
432
|
+
console.error(usage);
|
|
433
|
+
process.exit(EXIT_CODES.BAD_ARGUMENTS);
|
|
434
|
+
}
|
|
435
|
+
flags.editor = true;
|
|
436
|
+
continue;
|
|
437
|
+
case "--install-miqrojson":
|
|
438
|
+
if (flags.installMiqroJSON !== null) {
|
|
439
|
+
console.error("bad arguments. --install-miqrojson already set.");
|
|
440
|
+
console.error(usage);
|
|
441
|
+
process.exit(EXIT_CODES.BAD_ARGUMENTS);
|
|
442
|
+
}
|
|
443
|
+
flags.installMiqroJSON = true;
|
|
444
|
+
continue;
|
|
445
|
+
case "--inflate-sea":
|
|
446
|
+
if (flags.inflateSEA !== null) {
|
|
447
|
+
console.error("bad arguments. --inflate-sea already set.");
|
|
448
|
+
console.error(usage);
|
|
449
|
+
process.exit(EXIT_CODES.BAD_ARGUMENTS);
|
|
450
|
+
}
|
|
451
|
+
flags.inflateSEA = true;
|
|
452
|
+
continue;
|
|
453
|
+
case "--migrate-up":
|
|
454
|
+
if (flags.migrateUp !== null) {
|
|
455
|
+
console.error("bad arguments.");
|
|
456
|
+
console.error(usage);
|
|
457
|
+
process.exit(EXIT_CODES.BAD_ARGUMENTS);
|
|
458
|
+
}
|
|
459
|
+
flags.migrateUp = true;
|
|
460
|
+
continue;
|
|
461
|
+
case "--migrate-down":
|
|
462
|
+
if (flags.migrateDown !== null) {
|
|
463
|
+
console.error("bad arguments.");
|
|
464
|
+
console.error(usage);
|
|
465
|
+
process.exit(EXIT_CODES.BAD_ARGUMENTS);
|
|
466
|
+
}
|
|
467
|
+
flags.migrateDown = true;
|
|
468
|
+
continue;
|
|
469
|
+
case "--inflate":
|
|
470
|
+
if (flags.inflate !== null) {
|
|
471
|
+
console.error("bad arguments.");
|
|
472
|
+
console.error(usage);
|
|
473
|
+
process.exit(EXIT_CODES.BAD_ARGUMENTS);
|
|
474
|
+
}
|
|
475
|
+
flags.inflate = true;
|
|
476
|
+
continue;
|
|
477
|
+
case "--test":
|
|
478
|
+
if (flags.test !== null) {
|
|
479
|
+
console.error("bad arguments.");
|
|
480
|
+
console.error(usage);
|
|
481
|
+
process.exit(EXIT_CODES.BAD_ARGUMENTS);
|
|
482
|
+
}
|
|
483
|
+
env["BROWSER"] = env["BROWSER"] ? env["BROWSER"] : "none";
|
|
484
|
+
env["PORT"] = TEST_SOCKET;
|
|
485
|
+
flags.test = true;
|
|
486
|
+
continue;
|
|
487
|
+
case "--service":
|
|
488
|
+
if (args[i + 1] === undefined) {
|
|
489
|
+
console.error("bad arguments. service directory not provided.");
|
|
490
|
+
console.error(usage);
|
|
491
|
+
process.exit(EXIT_CODES.BAD_ARGUMENTS);
|
|
492
|
+
}
|
|
493
|
+
services.push(args[i + 1]);
|
|
494
|
+
i++;
|
|
495
|
+
continue;
|
|
496
|
+
case "--inflate-parallel":
|
|
497
|
+
if (args[i + 1] === undefined) {
|
|
498
|
+
console.error("bad arguments. service directory not provided.");
|
|
499
|
+
console.error(usage);
|
|
500
|
+
process.exit(EXIT_CODES.BAD_ARGUMENTS);
|
|
501
|
+
}
|
|
502
|
+
if (typeof args[i + 1] !== "string") {
|
|
503
|
+
console.error("bad arguments. --inflate-parallel must be a number.");
|
|
504
|
+
console.error(usage);
|
|
505
|
+
process.exit(EXIT_CODES.BAD_ARGUMENTS);
|
|
506
|
+
} else {
|
|
507
|
+
const cParallel = parseInt(String(args[i + 1]), 10);
|
|
508
|
+
if (isNaN(cParallel)) {
|
|
509
|
+
console.error("bad arguments. --inflate-parallel must be a number.");
|
|
510
|
+
console.error(usage);
|
|
511
|
+
process.exit(EXIT_CODES.BAD_ARGUMENTS);
|
|
512
|
+
}
|
|
513
|
+
flags.inflateParallel = cParallel;
|
|
514
|
+
}
|
|
515
|
+
i++;
|
|
516
|
+
continue;
|
|
517
|
+
case "--inflate-dir":
|
|
518
|
+
if (flags.inflateDir !== null && flags.compile === null) {
|
|
519
|
+
console.error("bad arguments. --inflate-dir already set.");
|
|
520
|
+
console.error(usage);
|
|
521
|
+
process.exit(EXIT_CODES.BAD_ARGUMENTS);
|
|
522
|
+
}
|
|
523
|
+
flags.inflateDir = args[i + 1];
|
|
524
|
+
if (typeof flags.inflateDir !== "string") {
|
|
525
|
+
console.error("bad arguments. inflate directory not provided.");
|
|
526
|
+
console.error(usage);
|
|
527
|
+
process.exit(EXIT_CODES.BAD_ARGUMENTS);
|
|
528
|
+
}
|
|
529
|
+
i++;
|
|
530
|
+
continue;
|
|
531
|
+
default:
|
|
532
|
+
//console.error("IGNORING bad arguments. [%s]", argument);
|
|
533
|
+
//continue;
|
|
534
|
+
console.error("bad argument. [%s]", argument);
|
|
535
|
+
console.error(usage);
|
|
536
|
+
console.log(help);
|
|
537
|
+
process.exit(EXIT_CODES.BAD_ARGUMENTS);
|
|
538
|
+
/*flags.inflate = flags.inflate ? flags.inflate : false;
|
|
539
|
+
flags.editor = flags.editor ? flags.editor : false;
|
|
540
|
+
flags.inflateDir = flags.inflateDir ? flags.inflateDir : undefined;
|
|
541
|
+
services.push(argument);
|
|
542
|
+
continue;*/
|
|
543
|
+
}
|
|
544
|
+
}
|
|
545
|
+
|
|
546
|
+
flags.inflate = flags.inflate ? flags.inflate : false;
|
|
547
|
+
|
|
548
|
+
flags.test = flags.test ? flags.test : false;
|
|
549
|
+
flags.inflateDir = flags.inflateDir ? flags.inflateDir : undefined;
|
|
550
|
+
|
|
551
|
+
const miqroJSONPath = !flags.disableMiqroJSON ? flags.miqroJSONPath ? resolve(flags.miqroJSONPath) : getMiqroJSONPath() : false;
|
|
552
|
+
const miqroRC = miqroJSONPath ? importMiqroJSON(miqroJSONPath) : {};
|
|
553
|
+
|
|
554
|
+
//console.dir(miqroRC.serverOptions);
|
|
555
|
+
|
|
556
|
+
// try to load .miqrorc
|
|
557
|
+
if (!flags.disableMiqroJSON && miqroJSONPath) {
|
|
558
|
+
if (services.length === 0) {
|
|
559
|
+
if (miqroRC.services) {
|
|
560
|
+
for (const service of miqroRC.services) {
|
|
561
|
+
services.push(join(relative(cwd(), dirname(miqroJSONPath)), service));
|
|
562
|
+
}
|
|
563
|
+
}
|
|
564
|
+
}
|
|
565
|
+
if (flags.https === null) {
|
|
566
|
+
if (miqroRC.https) {
|
|
567
|
+
flags.https = miqroRC.https;
|
|
568
|
+
}
|
|
569
|
+
}
|
|
570
|
+
if (flags.httpsRedirect === null) {
|
|
571
|
+
if (miqroRC.httpsRedirect && flags.https) {
|
|
572
|
+
/*console.log("reading key from " + String(miqroRC.serverOptions?.key));
|
|
573
|
+
flags.serverOptions.key = readFileSync(String(miqroRC.serverOptions?.key));*/
|
|
574
|
+
flags.httpsRedirect = miqroRC.httpsRedirect;
|
|
575
|
+
}
|
|
576
|
+
}
|
|
577
|
+
if (!flags.serverOptions.key) {
|
|
578
|
+
if (miqroRC.serverOptions?.key) {
|
|
579
|
+
/*console.log("reading key from " + String(miqroRC.serverOptions?.key));
|
|
580
|
+
flags.serverOptions.key = readFileSync(String(miqroRC.serverOptions?.key));*/
|
|
581
|
+
flags.serverOptions.key = miqroRC.serverOptions?.key;
|
|
582
|
+
}
|
|
583
|
+
}
|
|
584
|
+
|
|
585
|
+
if (!flags.serverOptions.cert) {
|
|
586
|
+
if (miqroRC.serverOptions?.cert) {
|
|
587
|
+
/*console.log("reading cert from " + String(miqroRC.serverOptions?.cert));
|
|
588
|
+
flags.serverOptions.cert = readFileSync(String(miqroRC.serverOptions?.cert));*/
|
|
589
|
+
flags.serverOptions.cert = miqroRC.serverOptions?.cert;
|
|
590
|
+
}
|
|
591
|
+
}
|
|
592
|
+
if (flags.port === null) {
|
|
593
|
+
if (miqroRC.port) {
|
|
594
|
+
flags.port = String(miqroRC.port);
|
|
595
|
+
}
|
|
596
|
+
}
|
|
597
|
+
if (!flags.inflateDir && flags.inflate) {
|
|
598
|
+
if (miqroRC.inflateDir) {
|
|
599
|
+
flags.inflateDir = miqroRC.inflateDir;
|
|
600
|
+
}
|
|
601
|
+
}
|
|
602
|
+
if (flags.name === null) {
|
|
603
|
+
if (miqroRC.name) {
|
|
604
|
+
flags.name = miqroRC.name;
|
|
605
|
+
}
|
|
606
|
+
}
|
|
607
|
+
if (flags.logFile === null) {
|
|
608
|
+
if (miqroRC.logFile !== undefined) {
|
|
609
|
+
flags.logFile = miqroRC.logFile;
|
|
610
|
+
}
|
|
611
|
+
}
|
|
612
|
+
if (flags.browser === null) {
|
|
613
|
+
if (miqroRC.browser !== undefined) {
|
|
614
|
+
flags.browser = miqroRC.browser;
|
|
615
|
+
}
|
|
616
|
+
}
|
|
617
|
+
if (flags.editor === null) {
|
|
618
|
+
if (miqroRC.editor !== undefined) {
|
|
619
|
+
flags.editor = miqroRC.editor;
|
|
620
|
+
}
|
|
621
|
+
}
|
|
622
|
+
|
|
623
|
+
if (flags.inflateParallel === null) {
|
|
624
|
+
if (miqroRC.inflateParallel !== undefined) {
|
|
625
|
+
flags.inflateParallel = miqroRC.inflateParallel;
|
|
626
|
+
}
|
|
627
|
+
}
|
|
628
|
+
}
|
|
629
|
+
|
|
630
|
+
flags.editor = flags.editor ? flags.editor : false;
|
|
631
|
+
|
|
632
|
+
if (services.length === 0 && (!flags.installTSConfig/* && !flags.installTypes*/ && !flags.installMiqroJSON)) {
|
|
633
|
+
flags.inflateDir = flags.inflateDir ? flags.inflateDir : undefined;
|
|
634
|
+
console.error(`bad arguments. missing --service argument`);
|
|
635
|
+
console.error(usage);
|
|
636
|
+
process.exit(EXIT_CODES.BAD_ARGUMENTS);
|
|
637
|
+
}
|
|
638
|
+
|
|
639
|
+
const notDirServices = services.filter(service => existsSync(resolve(process.cwd(), service)) && !statSync(resolve(process.cwd(), service)).isDirectory());
|
|
640
|
+
|
|
641
|
+
if (notDirServices.length > 0) {
|
|
642
|
+
console.error(`bad arguments. [${notDirServices.join(",")}] are not directories.`);
|
|
643
|
+
console.error(usage);
|
|
644
|
+
process.exit(EXIT_CODES.BAD_ARGUMENTS);
|
|
645
|
+
}
|
|
646
|
+
|
|
647
|
+
if (flags.inflateDir && existsSync(resolve(cwd(), flags.inflateDir)) && !statSync(resolve(cwd(), flags.inflateDir)).isDirectory()) {
|
|
648
|
+
console.error("bad arguments. inflate directory not a directory.");
|
|
649
|
+
console.error(usage);
|
|
650
|
+
process.exit(EXIT_CODES.BAD_ARGUMENTS);
|
|
651
|
+
}
|
|
652
|
+
|
|
653
|
+
if (!flags.inflate && flags.inflateDir) {
|
|
654
|
+
console.error("bad arguments. to use --inflate-dir you must use --inflate.");
|
|
655
|
+
console.error(usage);
|
|
656
|
+
process.exit(EXIT_CODES.BAD_ARGUMENTS);
|
|
657
|
+
}
|
|
658
|
+
|
|
659
|
+
if (flags.inflate === null || flags.inflateDir === null) {
|
|
660
|
+
console.error("for ts");
|
|
661
|
+
process.exit(EXIT_CODES.BAD_ARGUMENTS);
|
|
662
|
+
}
|
|
663
|
+
|
|
664
|
+
if (flags.install && flags.inflate) {
|
|
665
|
+
console.error("bad arguments. cannot use --install with --inflate");
|
|
666
|
+
process.exit(EXIT_CODES.BAD_ARGUMENTS);
|
|
667
|
+
}
|
|
668
|
+
|
|
669
|
+
if (flags.inflate && flags.editor) {
|
|
670
|
+
console.error("bad arguments. cannot use --inflate with --editor");
|
|
671
|
+
process.exit(EXIT_CODES.BAD_ARGUMENTS);
|
|
672
|
+
}
|
|
673
|
+
|
|
674
|
+
if (flags.inflate && (/*flags.installTypes || */flags.installTSConfig || flags.installMiqroJSON || flags.install)) {
|
|
675
|
+
console.error("bad arguments. cannot use --inflate with --install, --install-tsconfig or --install-miqrojson");
|
|
676
|
+
process.exit(EXIT_CODES.BAD_ARGUMENTS);
|
|
677
|
+
}
|
|
678
|
+
|
|
679
|
+
if (flags.inflateSEA && !flags.inflate) {
|
|
680
|
+
console.error("bad arguments. cannot use --inflate-sea without --inflate");
|
|
681
|
+
process.exit(EXIT_CODES.BAD_ARGUMENTS);
|
|
682
|
+
}
|
|
683
|
+
|
|
684
|
+
if (flags.editor && (/*flags.installTypes || */flags.installTSConfig || flags.installMiqroJSON)) {
|
|
685
|
+
console.error("bad arguments. cannot use --editor with--install-types, --install-tsconfig or --install-miqrojson");
|
|
686
|
+
process.exit(EXIT_CODES.BAD_ARGUMENTS);
|
|
687
|
+
}
|
|
688
|
+
|
|
689
|
+
if (flags.test && (flags.watch || flags.hotreload || flags.editor || flags.compile || flags.inflate)) {
|
|
690
|
+
console.error("bad arguments. cannot use --editor with --test");
|
|
691
|
+
process.exit(EXIT_CODES.BAD_ARGUMENTS);
|
|
692
|
+
}
|
|
693
|
+
|
|
694
|
+
if (flags.migrateUp && (flags.watch || flags.hotreload || flags.editor || flags.compile || flags.test || flags.migrateDown || flags.inflate)) {
|
|
695
|
+
console.error("bad arguments. cannot use with --migrate-up");
|
|
696
|
+
process.exit(EXIT_CODES.BAD_ARGUMENTS);
|
|
697
|
+
}
|
|
698
|
+
|
|
699
|
+
if (flags.migrateDown && (flags.watch || flags.hotreload || flags.editor || flags.compile || flags.test || flags.migrateUp || flags.inflate)) {
|
|
700
|
+
console.error("bad arguments. cannot use with --migrate-down");
|
|
701
|
+
process.exit(EXIT_CODES.BAD_ARGUMENTS);
|
|
702
|
+
}
|
|
703
|
+
|
|
704
|
+
if (flags.generateDoc && (flags.watch || flags.hotreload || flags.editor || flags.compile || flags.test || flags.migrateUp || flags.inflate || flags.migrateDown)) {
|
|
705
|
+
console.error("bad arguments. cannot use with --generate-doc");
|
|
706
|
+
process.exit(EXIT_CODES.BAD_ARGUMENTS);
|
|
707
|
+
}
|
|
708
|
+
|
|
709
|
+
if ((flags.generateDocAll || flags.generateDocOut || flags.generateDocType) && !flags.generateDoc) {
|
|
710
|
+
console.error("bad arguments. cannot use without --generate-doc");
|
|
711
|
+
process.exit(EXIT_CODES.BAD_ARGUMENTS);
|
|
712
|
+
}
|
|
713
|
+
|
|
714
|
+
const generateDocType = flags.generateDocType ? flags.generateDocType as any : "MD";
|
|
715
|
+
|
|
716
|
+
if (flags.https && (!flags.serverOptions.key)) {
|
|
717
|
+
console.error("bad arguments. cannot use --https without --https-key. or set values in miqro.json file.");
|
|
718
|
+
process.exit(EXIT_CODES.BAD_ARGUMENTS);
|
|
719
|
+
}
|
|
720
|
+
|
|
721
|
+
if (flags.https && (!flags.serverOptions.cert)) {
|
|
722
|
+
console.error("bad arguments. cannot use --https without --https-cert. or set values in miqro.json file.");
|
|
723
|
+
process.exit(EXIT_CODES.BAD_ARGUMENTS);
|
|
724
|
+
}
|
|
725
|
+
|
|
726
|
+
if (flags.httpsRedirect && !flags.https) {
|
|
727
|
+
console.error("bad arguments. cannot use --https-redirect without --https. or set values in miqro.json file.");
|
|
728
|
+
process.exit(EXIT_CODES.BAD_ARGUMENTS);
|
|
729
|
+
}
|
|
730
|
+
|
|
731
|
+
return {
|
|
732
|
+
inflateParallel: flags.inflateParallel ? flags.inflateParallel : undefined,
|
|
733
|
+
name: flags.name ? flags.name : undefined,
|
|
734
|
+
browser: flags.browser !== null ? flags.browser : undefined,
|
|
735
|
+
logFile: flags.logFile !== null ? flags.logFile : undefined,
|
|
736
|
+
generateDocAll: flags.generateDocAll ? true : false,
|
|
737
|
+
hotreload: flags.hotreload ? true : false,
|
|
738
|
+
watch: flags.watch ? true : false,
|
|
739
|
+
disableMiqroJSON: flags.disableMiqroJSON !== null ? flags.disableMiqroJSON : false,
|
|
740
|
+
miqroJSONPath: miqroJSONPath ? miqroJSONPath : false,
|
|
741
|
+
// installTypes: flags.installTypes ? true : false,
|
|
742
|
+
installMiqroJSON: flags.installMiqroJSON ? true : false,
|
|
743
|
+
installTSConfig: flags.installTSConfig ? true : false,
|
|
744
|
+
install: flags.install,
|
|
745
|
+
inflate: flags.inflate,
|
|
746
|
+
port: flags.port ? flags.port : getPORT(),
|
|
747
|
+
migrateUp: flags.migrateUp ? true : false,
|
|
748
|
+
migrateDown: flags.migrateDown ? true : false,
|
|
749
|
+
test: flags.test ? true : false,
|
|
750
|
+
compile: flags.compile,
|
|
751
|
+
inflateSEA: flags.inflateSEA ? true : false,
|
|
752
|
+
inflateDir: flags.inflateDir ? resolve(process.cwd(), flags.inflateDir) : resolve(process.cwd(), "inflated"),
|
|
753
|
+
generateDoc: flags.generateDoc = flags.generateDoc ? flags.generateDoc : false,
|
|
754
|
+
generateDocOut: flags.generateDocOut ? resolve(process.cwd(), flags.generateDocOut) : generateDocType === "MD" ? resolve(process.cwd(), "API.md") : resolve(process.cwd(), "API.json"),
|
|
755
|
+
generateDocType,
|
|
756
|
+
services,
|
|
757
|
+
editor: flags.editor ? true : false,
|
|
758
|
+
https: flags.https ? true : false,
|
|
759
|
+
httpsRedirect: flags.httpsRedirect ? flags.httpsRedirect : undefined,
|
|
760
|
+
serverOptions: flags.serverOptions
|
|
761
|
+
}
|
|
762
|
+
}
|