miqro 7.3.6 → 8.0.2
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 +3 -7
- package/build/esm/{src/bin → bin}/types.js +1 -2
- package/build/esm/{src/common → common}/arguments.d.ts +0 -2
- package/build/esm/{src/common → common}/arguments.js +5 -38
- package/build/esm/{src/common → common}/assets.js +1 -1
- package/build/esm/{src/common → common}/constants.d.ts +11 -0
- package/build/esm/{editor/common/templates.js → common/constants.js} +14 -0
- package/build/esm/{src/common → common}/esbuild.js +0 -1
- package/build/esm/common/help.d.ts +3 -0
- package/build/esm/{src/common → common}/help.js +0 -1
- package/build/esm/{src/inflate → inflate}/inflate-sea.js +3 -0
- package/build/esm/inflate/md.d.ts +1 -0
- package/build/esm/inflate/md.js +4 -0
- package/build/esm/{src/inflate → inflate}/setup-http.js +2 -3
- package/build/esm/{src/main.js → main.js} +0 -1
- package/build/esm/{src/services → services}/app.d.ts +0 -1
- package/build/esm/{src/services → services}/app.js +1 -53
- package/build/esm/{src/services → services}/utils/server-interface.js +18 -3
- package/build/esm/{src/services → services}/utils/websocketmanager.d.ts +0 -1
- package/build/esm/{src/services → services}/utils/websocketmanager.js +10 -20
- package/build/esm/{src/types.d.ts → types.d.ts} +2 -1
- package/build/lib.cjs +8391 -11627
- package/package.json +11 -23
- package/build/editor.bundle.js +0 -12329
- package/build/esm/editor/auth.d.ts +0 -6
- package/build/esm/editor/auth.js +0 -44
- package/build/esm/editor/common/constants.d.ts +0 -4
- package/build/esm/editor/common/constants.js +0 -20
- package/build/esm/editor/common/constants.server.d.ts +0 -2
- package/build/esm/editor/common/constants.server.js +0 -4
- package/build/esm/editor/common/editor-index.d.ts +0 -2
- package/build/esm/editor/common/editor-index.js +0 -14
- package/build/esm/editor/common/html-encode.d.ts +0 -1
- package/build/esm/editor/common/html-encode.js +0 -14
- package/build/esm/editor/common/log-socket.d.ts +0 -15
- package/build/esm/editor/common/log-socket.js +0 -71
- package/build/esm/editor/common/templates.d.ts +0 -11
- package/build/esm/editor/components/api-preview.d.ts +0 -11
- package/build/esm/editor/components/api-preview.js +0 -92
- package/build/esm/editor/components/editor.d.ts +0 -16
- package/build/esm/editor/components/editor.js +0 -367
- package/build/esm/editor/components/file-browser.d.ts +0 -37
- package/build/esm/editor/components/file-browser.js +0 -127
- package/build/esm/editor/components/file-editor-toolbar.d.ts +0 -22
- package/build/esm/editor/components/file-editor-toolbar.js +0 -95
- package/build/esm/editor/components/file-editor.d.ts +0 -32
- package/build/esm/editor/components/file-editor.js +0 -61
- package/build/esm/editor/components/filter-query.d.ts +0 -1
- package/build/esm/editor/components/filter-query.js +0 -23
- package/build/esm/editor/components/highlight-text-area.d.ts +0 -11
- package/build/esm/editor/components/highlight-text-area.js +0 -127
- package/build/esm/editor/components/log-viewer.d.ts +0 -6
- package/build/esm/editor/components/log-viewer.js +0 -71
- package/build/esm/editor/components/new-file.d.ts +0 -10
- package/build/esm/editor/components/new-file.js +0 -119
- package/build/esm/editor/components/scroll-query.d.ts +0 -7
- package/build/esm/editor/components/scroll-query.js +0 -22
- package/build/esm/editor/components/start-page.d.ts +0 -13
- package/build/esm/editor/components/start-page.js +0 -32
- package/build/esm/editor/http/admin/editor/api/fs/delete.api.d.ts +0 -4
- package/build/esm/editor/http/admin/editor/api/fs/delete.api.js +0 -30
- package/build/esm/editor/http/admin/editor/api/fs/read.api.d.ts +0 -7
- package/build/esm/editor/http/admin/editor/api/fs/read.api.js +0 -50
- package/build/esm/editor/http/admin/editor/api/fs/rename.api.d.ts +0 -7
- package/build/esm/editor/http/admin/editor/api/fs/rename.api.js +0 -40
- package/build/esm/editor/http/admin/editor/api/fs/scan.api.d.ts +0 -26
- package/build/esm/editor/http/admin/editor/api/fs/scan.api.js +0 -150
- package/build/esm/editor/http/admin/editor/api/fs/write.api.d.ts +0 -3
- package/build/esm/editor/http/admin/editor/api/fs/write.api.js +0 -39
- package/build/esm/editor/http/admin/editor/api/server/reload.api.d.ts +0 -10
- package/build/esm/editor/http/admin/editor/api/server/reload.api.js +0 -46
- package/build/esm/editor/http/admin/editor/api/server/restart.api.d.ts +0 -10
- package/build/esm/editor/http/admin/editor/api/server/restart.api.js +0 -46
- package/build/esm/editor/http/admin/editor/editor.d.ts +0 -1
- package/build/esm/editor/http/admin/editor/editor.js +0 -8
- package/build/esm/editor/http/admin/editor/index.api.d.ts +0 -3
- package/build/esm/editor/http/admin/editor/index.api.js +0 -23
- package/build/esm/editor/server.d.ts +0 -3
- package/build/esm/editor/server.js +0 -49
- package/build/esm/editor/ws.d.ts +0 -3
- package/build/esm/editor/ws.js +0 -12
- package/build/esm/src/common/constants.js +0 -14
- package/build/esm/src/common/help.d.ts +0 -3
- package/build/esm/src/inflate/md.d.ts +0 -3
- package/build/esm/src/inflate/md.js +0 -22
- package/build/esm/src/services/editor.d.ts +0 -3
- package/build/esm/src/services/editor.js +0 -66
- package/build/esm/src/services/utils/admin-interface.d.ts +0 -3
- package/build/esm/src/services/utils/admin-interface.js +0 -33
- package/build/style.css +0 -620
- package/editor/auth.ts +0 -53
- package/editor/common/constants.server.ts +0 -5
- package/editor/common/constants.ts +0 -21
- package/editor/common/editor-index.tsx +0 -17
- package/editor/common/html-encode.ts +0 -14
- package/editor/common/log-socket.tsx +0 -87
- package/editor/common/templates.ts +0 -481
- package/editor/components/api-preview.tsx +0 -118
- package/editor/components/editor.tsx +0 -496
- package/editor/components/file-browser.tsx +0 -311
- package/editor/components/file-editor-toolbar.tsx +0 -194
- package/editor/components/file-editor.tsx +0 -125
- package/editor/components/filter-query.tsx +0 -26
- package/editor/components/highlight-text-area.tsx +0 -148
- package/editor/components/log-viewer.tsx +0 -113
- package/editor/components/new-file.tsx +0 -172
- package/editor/components/scroll-query.tsx +0 -25
- package/editor/components/start-page.tsx +0 -52
- package/editor/http/admin/editor/api/fs/delete.api.tsx +0 -32
- package/editor/http/admin/editor/api/fs/read.api.tsx +0 -55
- package/editor/http/admin/editor/api/fs/rename.api.tsx +0 -41
- package/editor/http/admin/editor/api/fs/scan.api.tsx +0 -181
- package/editor/http/admin/editor/api/fs/write.api.tsx +0 -41
- package/editor/http/admin/editor/api/server/reload.api.ts +0 -53
- package/editor/http/admin/editor/api/server/restart.api.tsx +0 -52
- package/editor/http/admin/editor/editor.tsx +0 -10
- package/editor/http/admin/editor/index.api.tsx +0 -43
- package/editor/server.ts +0 -57
- package/editor/ws.ts +0 -17
- /package/build/esm/{src/bin → bin}/compile.d.ts +0 -0
- /package/build/esm/{src/bin → bin}/compile.js +0 -0
- /package/build/esm/{src/bin → bin}/doc-md.d.ts +0 -0
- /package/build/esm/{src/bin → bin}/doc-md.js +0 -0
- /package/build/esm/{src/bin → bin}/generate-doc.d.ts +0 -0
- /package/build/esm/{src/bin → bin}/generate-doc.js +0 -0
- /package/build/esm/{src/bin → bin}/test.d.ts +0 -0
- /package/build/esm/{src/bin → bin}/test.js +0 -0
- /package/build/esm/{src/bin → bin}/types.d.ts +0 -0
- /package/build/esm/{src/cluster.d.ts → cluster.d.ts} +0 -0
- /package/build/esm/{src/cluster.js → cluster.js} +0 -0
- /package/build/esm/{src/common → common}/admin-interface.d.ts +0 -0
- /package/build/esm/{src/common → common}/admin-interface.js +0 -0
- /package/build/esm/{src/common → common}/assets.d.ts +0 -0
- /package/build/esm/{src/common → common}/checksum.d.ts +0 -0
- /package/build/esm/{src/common → common}/checksum.js +0 -0
- /package/build/esm/{src/common → common}/content-type.d.ts +0 -0
- /package/build/esm/{src/common → common}/content-type.js +0 -0
- /package/build/esm/{src/common → common}/esbuild.d.ts +0 -0
- /package/build/esm/{src/common → common}/exit.d.ts +0 -0
- /package/build/esm/{src/common → common}/exit.js +0 -0
- /package/build/esm/{src/common → common}/fs.d.ts +0 -0
- /package/build/esm/{src/common → common}/fs.js +0 -0
- /package/build/esm/{src/common → common}/jsx.d.ts +0 -0
- /package/build/esm/{src/common → common}/jsx.js +0 -0
- /package/build/esm/{src/common → common}/jwt.d.ts +0 -0
- /package/build/esm/{src/common → common}/jwt.js +0 -0
- /package/build/esm/{src/common → common}/paths.d.ts +0 -0
- /package/build/esm/{src/common → common}/paths.js +0 -0
- /package/build/esm/{src/common → common}/watch.d.ts +0 -0
- /package/build/esm/{src/common → common}/watch.js +0 -0
- /package/build/esm/{src/inflate → inflate}/inflate-sea.d.ts +0 -0
- /package/build/esm/{src/inflate → inflate}/inflate.d.ts +0 -0
- /package/build/esm/{src/inflate → inflate}/inflate.js +0 -0
- /package/build/esm/{src/inflate → inflate}/setup-auth.d.ts +0 -0
- /package/build/esm/{src/inflate → inflate}/setup-auth.js +0 -0
- /package/build/esm/{src/inflate → inflate}/setup-cors.d.ts +0 -0
- /package/build/esm/{src/inflate → inflate}/setup-cors.js +0 -0
- /package/build/esm/{src/inflate → inflate}/setup-db.d.ts +0 -0
- /package/build/esm/{src/inflate → inflate}/setup-db.js +0 -0
- /package/build/esm/{src/inflate → inflate}/setup-error.d.ts +0 -0
- /package/build/esm/{src/inflate → inflate}/setup-error.js +0 -0
- /package/build/esm/{src/inflate → inflate}/setup-http.d.ts +0 -0
- /package/build/esm/{src/inflate → inflate}/setup-log.d.ts +0 -0
- /package/build/esm/{src/inflate → inflate}/setup-log.js +0 -0
- /package/build/esm/{src/inflate → inflate}/setup-middleware.d.ts +0 -0
- /package/build/esm/{src/inflate → inflate}/setup-middleware.js +0 -0
- /package/build/esm/{src/inflate → inflate}/setup-server-config.d.ts +0 -0
- /package/build/esm/{src/inflate → inflate}/setup-server-config.js +0 -0
- /package/build/esm/{src/inflate → inflate}/setup-test.d.ts +0 -0
- /package/build/esm/{src/inflate → inflate}/setup-test.js +0 -0
- /package/build/esm/{src/inflate → inflate}/setup-ws.d.ts +0 -0
- /package/build/esm/{src/inflate → inflate}/setup-ws.js +0 -0
- /package/build/esm/{src/inflate → inflate}/setup.doc.d.ts +0 -0
- /package/build/esm/{src/inflate → inflate}/setup.doc.js +0 -0
- /package/build/esm/{src/inflate → inflate}/utils/sea-utils.d.ts +0 -0
- /package/build/esm/{src/inflate → inflate}/utils/sea-utils.js +0 -0
- /package/build/esm/{src/lib.d.ts → lib.d.ts} +0 -0
- /package/build/esm/{src/lib.js → lib.js} +0 -0
- /package/build/esm/{src/main.d.ts → main.d.ts} +0 -0
- /package/build/esm/{src/services → services}/hot-reload.d.ts +0 -0
- /package/build/esm/{src/services → services}/hot-reload.js +0 -0
- /package/build/esm/{src/services → services}/migrations.d.ts +0 -0
- /package/build/esm/{src/services → services}/migrations.js +0 -0
- /package/build/esm/{src/services → services}/utils/cache.d.ts +0 -0
- /package/build/esm/{src/services → services}/utils/cache.js +0 -0
- /package/build/esm/{src/services → services}/utils/cluster-cache.d.ts +0 -0
- /package/build/esm/{src/services → services}/utils/cluster-cache.js +0 -0
- /package/build/esm/{src/services → services}/utils/cluster-ws.d.ts +0 -0
- /package/build/esm/{src/services → services}/utils/cluster-ws.js +0 -0
- /package/build/esm/{src/services → services}/utils/db-manager.d.ts +0 -0
- /package/build/esm/{src/services → services}/utils/db-manager.js +0 -0
- /package/build/esm/{src/services → services}/utils/get-route.d.ts +0 -0
- /package/build/esm/{src/services → services}/utils/get-route.js +0 -0
- /package/build/esm/{src/services → services}/utils/jwt.d.ts +0 -0
- /package/build/esm/{src/services → services}/utils/jwt.js +0 -0
- /package/build/esm/{src/services → services}/utils/log-transport.d.ts +0 -0
- /package/build/esm/{src/services → services}/utils/log-transport.js +0 -0
- /package/build/esm/{src/services → services}/utils/log.d.ts +0 -0
- /package/build/esm/{src/services → services}/utils/log.js +0 -0
- /package/build/esm/{src/services → services}/utils/middleware.d.ts +0 -0
- /package/build/esm/{src/services → services}/utils/middleware.js +0 -0
- /package/build/esm/{src/services → services}/utils/server-interface.d.ts +0 -0
- /package/build/esm/{src/types.js → types.js} +0 -0
|
@@ -1,181 +0,0 @@
|
|
|
1
|
-
import { APIRoute, JSONParser } from "@miqro/core";
|
|
2
|
-
import { existsSync, readdirSync, statSync } from "node:fs";
|
|
3
|
-
import { basename, dirname, extname, join, relative, resolve, sep } from "node:path";
|
|
4
|
-
import { BASE_PATH } from "../../../../../common/constants.server.js";
|
|
5
|
-
import { AdminRequest } from "../../../../../../src/common/admin-interface.js";
|
|
6
|
-
|
|
7
|
-
export interface ScannedFile {
|
|
8
|
-
filePath: string;
|
|
9
|
-
ext: string;
|
|
10
|
-
fileName: string;
|
|
11
|
-
name: string;
|
|
12
|
-
subExt: string;
|
|
13
|
-
subName: string;
|
|
14
|
-
language: string;
|
|
15
|
-
previewPath?: string;
|
|
16
|
-
dirs: string[];
|
|
17
|
-
apiPreview?: {
|
|
18
|
-
path: string;
|
|
19
|
-
method: string;
|
|
20
|
-
}[];
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
export default {
|
|
24
|
-
method: "GET",
|
|
25
|
-
path: "/scan",
|
|
26
|
-
description: "admin editor file scan endpoint",
|
|
27
|
-
middleware: [JSONParser()],
|
|
28
|
-
request: {
|
|
29
|
-
body: false
|
|
30
|
-
},
|
|
31
|
-
response: {
|
|
32
|
-
status: [200, 400]
|
|
33
|
-
},
|
|
34
|
-
handler: async (req: AdminRequest, res) => {
|
|
35
|
-
const admin = req.editor;
|
|
36
|
-
const services = admin ? admin.getServices() : ["."];
|
|
37
|
-
return res.json({
|
|
38
|
-
files: scanDir(req),
|
|
39
|
-
services
|
|
40
|
-
});
|
|
41
|
-
},
|
|
42
|
-
} as APIRoute;
|
|
43
|
-
|
|
44
|
-
export function scanDir(req: AdminRequest, basePath: string = BASE_PATH, ret: ScannedFile[] = []): ScannedFile[] {
|
|
45
|
-
const admin = req.editor;
|
|
46
|
-
const services = admin ? admin.getServices() : ["."];
|
|
47
|
-
services.forEach(service => {
|
|
48
|
-
scanDirInternal(req, resolve(basePath, service), ret);
|
|
49
|
-
});
|
|
50
|
-
return ret;
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
function scanDirInternal(req, path: string = BASE_PATH, ret: ScannedFile[] = []): ScannedFile[] {
|
|
54
|
-
if (!existsSync(path)) {
|
|
55
|
-
return ret;
|
|
56
|
-
}
|
|
57
|
-
const files = readdirSync(path);
|
|
58
|
-
for (const file of files) {
|
|
59
|
-
if (shouldIgnoreFile(file)) {
|
|
60
|
-
continue;
|
|
61
|
-
}
|
|
62
|
-
const filePath = resolve(path, file);
|
|
63
|
-
if (statSync(filePath).isDirectory()) {
|
|
64
|
-
scanDirInternal(req, filePath, ret);
|
|
65
|
-
continue;
|
|
66
|
-
} else {
|
|
67
|
-
const ext = extname(filePath);
|
|
68
|
-
const fileName = basename(filePath);
|
|
69
|
-
const name = fileName.substring(0, fileName.length - ext.length);
|
|
70
|
-
const subExt = extname(name);
|
|
71
|
-
const subName = name.substring(0, name.length - subExt.length);
|
|
72
|
-
|
|
73
|
-
ret.push({
|
|
74
|
-
dirs: getFileDirs(relative(BASE_PATH, filePath)),
|
|
75
|
-
language: getLanguage(filePath),
|
|
76
|
-
filePath: relative(BASE_PATH, filePath),
|
|
77
|
-
ext,
|
|
78
|
-
fileName,
|
|
79
|
-
name,
|
|
80
|
-
subExt,
|
|
81
|
-
subName,
|
|
82
|
-
previewPath: getPreview(req, filePath),
|
|
83
|
-
apiPreview: getAPIPreview(req, filePath)
|
|
84
|
-
});
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
return ret;
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
function shouldIgnoreFile(file) {
|
|
91
|
-
return file === ".git" || file === ".types" || file === ".DS_Store" || file === "node_modules";
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
function getFileDirs(filePath: string): string[] {
|
|
95
|
-
const dirs: string[] = [];
|
|
96
|
-
let dir = dirname(filePath);
|
|
97
|
-
while (dir !== sep && dir !== "" && dir !== "." && dir !== BASE_PATH) {
|
|
98
|
-
|
|
99
|
-
dirs.push(dir);
|
|
100
|
-
dir = dirname(dir);
|
|
101
|
-
|
|
102
|
-
}
|
|
103
|
-
return dirs.reverse().map(d => basename(d));
|
|
104
|
-
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
export function getLanguage(filePath: string): string {
|
|
108
|
-
const ext = extname(filePath);
|
|
109
|
-
const fileName = basename(filePath);
|
|
110
|
-
switch (ext.toLocaleLowerCase()) {
|
|
111
|
-
case ".py":
|
|
112
|
-
return "python";
|
|
113
|
-
case ".sh":
|
|
114
|
-
return "bash";
|
|
115
|
-
case ".webmanifest":
|
|
116
|
-
case ".json":
|
|
117
|
-
return "json";
|
|
118
|
-
case ".xml":
|
|
119
|
-
return "xml";
|
|
120
|
-
case ".jsx":
|
|
121
|
-
case ".js":
|
|
122
|
-
return "javascript";
|
|
123
|
-
case ".tsx":
|
|
124
|
-
case ".ts":
|
|
125
|
-
case "d.ts":
|
|
126
|
-
return "typescript";
|
|
127
|
-
case ".htm":
|
|
128
|
-
case ".html":
|
|
129
|
-
return "html";
|
|
130
|
-
case ".scss":
|
|
131
|
-
case ".css":
|
|
132
|
-
return "css";
|
|
133
|
-
case ".md":
|
|
134
|
-
return "markdown";
|
|
135
|
-
case ".c":
|
|
136
|
-
return "c";
|
|
137
|
-
case ".h":
|
|
138
|
-
case ".cpp":
|
|
139
|
-
return "cpp";
|
|
140
|
-
case ".yml":
|
|
141
|
-
case ".yaml":
|
|
142
|
-
return "yaml";
|
|
143
|
-
case ".txt":
|
|
144
|
-
case ".log":
|
|
145
|
-
return "text";
|
|
146
|
-
default:
|
|
147
|
-
switch (fileName) {
|
|
148
|
-
case "dockerfile":
|
|
149
|
-
return "dockerfile";
|
|
150
|
-
case ".gitignore":
|
|
151
|
-
return "text";
|
|
152
|
-
}
|
|
153
|
-
return "text";
|
|
154
|
-
}
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
export function getPreview(req: AdminRequest, filePath: string): undefined | string {
|
|
158
|
-
const admin = req.editor;
|
|
159
|
-
const inflateData = admin ? admin.getRouteFileMap()[filePath] : undefined;
|
|
160
|
-
if (inflateData) {
|
|
161
|
-
return inflateData.previewMethod === "html" ? inflateData.routes[0].path : undefined;
|
|
162
|
-
}
|
|
163
|
-
return undefined;
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
export function getAPIPreview(req, filePath: string): undefined | {
|
|
167
|
-
path: string;
|
|
168
|
-
method: string;
|
|
169
|
-
}[] {
|
|
170
|
-
const admin = req.editor;
|
|
171
|
-
const inflateData = admin ? admin.getRouteFileMap()[filePath] : undefined;
|
|
172
|
-
if (inflateData) {
|
|
173
|
-
return inflateData.previewMethod === "api" ? inflateData.routes.map(r => {
|
|
174
|
-
return {
|
|
175
|
-
path: r.path,
|
|
176
|
-
method: r.method ? r.method : "GET"
|
|
177
|
-
};
|
|
178
|
-
}) : undefined;
|
|
179
|
-
}
|
|
180
|
-
return undefined;
|
|
181
|
-
}
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
import { APIRoute, JSONParser } from "@miqro/core";
|
|
2
|
-
import { existsSync, mkdirSync, writeFileSync } from "node:fs";
|
|
3
|
-
import { getPath } from "./read.api.js";
|
|
4
|
-
import { dirname } from "node:path";
|
|
5
|
-
|
|
6
|
-
export default {
|
|
7
|
-
middleware: [JSONParser()],
|
|
8
|
-
method: "POST",
|
|
9
|
-
path: "/write",
|
|
10
|
-
description: "admin editor file write endpoint",
|
|
11
|
-
request: {
|
|
12
|
-
body: {
|
|
13
|
-
path: "string",
|
|
14
|
-
contents: "string",
|
|
15
|
-
override: "boolean?"
|
|
16
|
-
}
|
|
17
|
-
},
|
|
18
|
-
response: {
|
|
19
|
-
status: [200, 400],
|
|
20
|
-
body: {
|
|
21
|
-
message: "string"
|
|
22
|
-
}
|
|
23
|
-
},
|
|
24
|
-
handler: async (req, res) => {
|
|
25
|
-
const { path, contents, override } = req.body;
|
|
26
|
-
await writeFile(path, contents, override);
|
|
27
|
-
return res.json({
|
|
28
|
-
message: "OK"
|
|
29
|
-
});
|
|
30
|
-
}
|
|
31
|
-
} as APIRoute;
|
|
32
|
-
|
|
33
|
-
async function writeFile(path: string, contents: string, override?: boolean) {
|
|
34
|
-
if (existsSync(getPath(path)) && !override) {
|
|
35
|
-
throw new Error("file already exists!");
|
|
36
|
-
}
|
|
37
|
-
mkdirSync(dirname(getPath(path)), {
|
|
38
|
-
recursive: true
|
|
39
|
-
});
|
|
40
|
-
writeFileSync(getPath(path), contents);
|
|
41
|
-
}
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
import { APIRoute } from "@miqro/core";
|
|
2
|
-
import { relative } from "node:path";
|
|
3
|
-
import { BASE_PATH } from "../../../../../common/constants.server.js";
|
|
4
|
-
import { AdminRequest } from "../../../../../../src/common/admin-interface.js";
|
|
5
|
-
|
|
6
|
-
export default {
|
|
7
|
-
method: "POST",
|
|
8
|
-
path: "/reload",
|
|
9
|
-
description: "admin editor server reload endpoint. reloads the server without closing the port",
|
|
10
|
-
middleware: [],
|
|
11
|
-
request: {
|
|
12
|
-
body: false
|
|
13
|
-
},
|
|
14
|
-
response: {
|
|
15
|
-
status: [200, 400],
|
|
16
|
-
body: {
|
|
17
|
-
message: "string",
|
|
18
|
-
reloadString: "string",
|
|
19
|
-
migrations: "string[]",
|
|
20
|
-
errors: {
|
|
21
|
-
allowNull: true,
|
|
22
|
-
type: "array",
|
|
23
|
-
arrayType: "object",
|
|
24
|
-
properties: {
|
|
25
|
-
filePath: "string",
|
|
26
|
-
error: "string"
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
},
|
|
31
|
-
handler: async (req: AdminRequest, res) => {
|
|
32
|
-
const errors = await req?.editor?.reload();
|
|
33
|
-
const parsedErrors = parseInflateErrors(errors);
|
|
34
|
-
return res.json({
|
|
35
|
-
message: "OK",
|
|
36
|
-
reloadString: req.uuid,
|
|
37
|
-
migrations: req?.editor?.getMigrations().map(m => m.name),
|
|
38
|
-
errors: parsedErrors ? parsedErrors : []
|
|
39
|
-
});
|
|
40
|
-
},
|
|
41
|
-
} as APIRoute;
|
|
42
|
-
|
|
43
|
-
export function parseInflateErrors(errors: {
|
|
44
|
-
filePath: string;
|
|
45
|
-
error: Error;
|
|
46
|
-
}[] | null) {
|
|
47
|
-
return errors?.map(error => {
|
|
48
|
-
return {
|
|
49
|
-
filePath: relative(BASE_PATH, error.filePath),
|
|
50
|
-
error: error.error.message
|
|
51
|
-
}
|
|
52
|
-
});
|
|
53
|
-
}
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
import { APIRoute, JSONParser } from "@miqro/core";
|
|
2
|
-
import { relative } from "node:path";
|
|
3
|
-
import { BASE_PATH } from "../../../../../common/constants.server.js";
|
|
4
|
-
import { AdminRequest } from "../../../../../../src/common/admin-interface.js";
|
|
5
|
-
|
|
6
|
-
export default {
|
|
7
|
-
method: "POST",
|
|
8
|
-
path: "/restart",
|
|
9
|
-
description: "admin editor server restart endpoint",
|
|
10
|
-
middleware: [JSONParser()],
|
|
11
|
-
request: {
|
|
12
|
-
body: false
|
|
13
|
-
},
|
|
14
|
-
response: {
|
|
15
|
-
status: [200, 400],
|
|
16
|
-
body: {
|
|
17
|
-
message: "string",
|
|
18
|
-
reloadString: "string",
|
|
19
|
-
migrations: "string[]",
|
|
20
|
-
errors: {
|
|
21
|
-
allowNull: true,
|
|
22
|
-
type: "array",
|
|
23
|
-
arrayType: "object",
|
|
24
|
-
properties: {
|
|
25
|
-
filePath: "string",
|
|
26
|
-
error: "string"
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
},
|
|
31
|
-
handler: async (req: AdminRequest, res) => {
|
|
32
|
-
const errors = await req?.editor?.restart();
|
|
33
|
-
return res.json({
|
|
34
|
-
message: "OK",
|
|
35
|
-
reloadString: req.uuid,
|
|
36
|
-
migrations: req?.editor?.getMigrations().map(m => m.name),
|
|
37
|
-
errors: parseInflateErrors(errors)
|
|
38
|
-
});
|
|
39
|
-
},
|
|
40
|
-
} as APIRoute;
|
|
41
|
-
|
|
42
|
-
export function parseInflateErrors(errors: {
|
|
43
|
-
filePath: string;
|
|
44
|
-
error: Error;
|
|
45
|
-
}[] | null) {
|
|
46
|
-
return errors?.map(error => {
|
|
47
|
-
return {
|
|
48
|
-
filePath: relative(BASE_PATH, error.filePath),
|
|
49
|
-
error: error.error.message
|
|
50
|
-
}
|
|
51
|
-
});
|
|
52
|
-
}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { define } from "@miqro/jsx-dom";
|
|
2
|
-
|
|
3
|
-
//import "../../../../.types/browser.globals";
|
|
4
|
-
import { Editor } from "../../../components/editor.js";
|
|
5
|
-
|
|
6
|
-
window.addEventListener("load", async (event) => {
|
|
7
|
-
define("editor-component", Editor, {
|
|
8
|
-
shadowInit: false
|
|
9
|
-
});
|
|
10
|
-
});
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
import * as jsx from "@miqro/jsx";
|
|
2
|
-
import JSX from "@miqro/jsx";
|
|
3
|
-
|
|
4
|
-
import { APIRoute, Response } from "@miqro/core";
|
|
5
|
-
import { scanDir } from "./api/fs/scan.api.js";
|
|
6
|
-
import { HTMLEncode } from "../../../common/html-encode.js";
|
|
7
|
-
import { AdminRequest } from "../../../../src/common/admin-interface.js";
|
|
8
|
-
import { jsx2HTML } from "../../../../src/lib.js";
|
|
9
|
-
|
|
10
|
-
export default {
|
|
11
|
-
description: "ADMIN EDITOR GUI",
|
|
12
|
-
path: "/",
|
|
13
|
-
method: "GET",
|
|
14
|
-
handler: async (req: AdminRequest, res: Response) => {
|
|
15
|
-
const admin = req.editor;
|
|
16
|
-
const errors = admin ? admin.getInflateErrors() : [];
|
|
17
|
-
const files = scanDir(req);
|
|
18
|
-
const migrations = admin ? admin.getMigrations().map(m => m.name) : [];
|
|
19
|
-
const services = admin ? admin.getServices() : ["."];
|
|
20
|
-
|
|
21
|
-
return res.html("<!DOCTYPE html>" + jsx2HTML(<html>
|
|
22
|
-
<head>
|
|
23
|
-
<link rel="stylesheet" href="/admin/editor/style.css" />
|
|
24
|
-
</head>
|
|
25
|
-
<body>
|
|
26
|
-
|
|
27
|
-
<script type="module" src="/admin/editor/editor.js" />
|
|
28
|
-
<editor-component
|
|
29
|
-
disablelog="true"
|
|
30
|
-
disablepreview="true"
|
|
31
|
-
disablereload="true"
|
|
32
|
-
class="main-container"
|
|
33
|
-
reloadstring={`${req?.uuid}`}
|
|
34
|
-
migrations={`${HTMLEncode(JSON.stringify(migrations))}`}
|
|
35
|
-
services={`${HTMLEncode(JSON.stringify(services))}`}
|
|
36
|
-
errors={`${HTMLEncode(JSON.stringify(errors))}`}
|
|
37
|
-
files={`${HTMLEncode(JSON.stringify(files))}`}>
|
|
38
|
-
<noscript>Enable JavaScript</noscript>
|
|
39
|
-
</editor-component>
|
|
40
|
-
</body></html>)
|
|
41
|
-
);
|
|
42
|
-
}
|
|
43
|
-
} as APIRoute;
|
package/editor/server.ts
DELETED
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
import { randomUUID } from "node:crypto";
|
|
2
|
-
import { ServerConfig, ServerInterface } from "../src/types.js";
|
|
3
|
-
import { BASEEDITOR_PATH } from "./common/constants.js";
|
|
4
|
-
import { existsSync, readFileSync } from "node:fs";
|
|
5
|
-
import { relative, resolve } from "node:path";
|
|
6
|
-
import { ADMIN_EDITOR_AUTH_KEY, ADMIN_EDITOR_AUTH_QUERY } from "./auth.js";
|
|
7
|
-
import { EditorAdminInterface } from "../src/common/admin-interface.js";
|
|
8
|
-
//import { getEditorAdmin } from "./common/admin-interface.js";
|
|
9
|
-
|
|
10
|
-
const ADMIN_EDITOR_BROWSER_OPEN_KEY = "ADMIN_EDITOR_BROWSER_OPEN_KEY$$";
|
|
11
|
-
|
|
12
|
-
export default {
|
|
13
|
-
preload: (serverInterface: ServerInterface, adminInterface: EditorAdminInterface) => {
|
|
14
|
-
//console.dir(server);
|
|
15
|
-
if (serverInterface?.isPrimaryWorker()) {
|
|
16
|
-
const cache = (adminInterface ? adminInterface.getCache() : serverInterface.cache);
|
|
17
|
-
if (!cache.has(ADMIN_EDITOR_AUTH_KEY)) {
|
|
18
|
-
const adminKEYPath = resolve(".admin_key");
|
|
19
|
-
if (existsSync(adminKEYPath)) {
|
|
20
|
-
serverInterface.logger.warn("loading static ADMIN_KEY from [%s]", relative(process.cwd(), adminKEYPath));
|
|
21
|
-
cache.set(ADMIN_EDITOR_AUTH_KEY, readFileSync(adminKEYPath).toString().trim());
|
|
22
|
-
} else {
|
|
23
|
-
cache.set(ADMIN_EDITOR_AUTH_KEY, randomUUID());
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
},
|
|
28
|
-
start: (serverInterface: ServerInterface, adminInterface: EditorAdminInterface) => {
|
|
29
|
-
//console.dir(server);
|
|
30
|
-
const cache = (adminInterface ? adminInterface.getCache() : serverInterface.cache);
|
|
31
|
-
if (!cache.has(ADMIN_EDITOR_BROWSER_OPEN_KEY)) {
|
|
32
|
-
|
|
33
|
-
const KEY = cache.get(ADMIN_EDITOR_AUTH_KEY);
|
|
34
|
-
|
|
35
|
-
const adminPath = `${BASEEDITOR_PATH}?${ADMIN_EDITOR_AUTH_QUERY}=${KEY}`;
|
|
36
|
-
|
|
37
|
-
if (serverInterface?.isPrimaryWorker()) {
|
|
38
|
-
serverInterface.logger.log("\n\n\tADMIN_EDITOR\n\n\t%s\n\n", adminPath);
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
//const DEFAULT_OPEN = process.platform === "win32" ? "explorer" : process.platform === "darwin" ? "open" : "xdg-open";
|
|
42
|
-
|
|
43
|
-
//const OPEN = process.env["BROWSER"] ? process.env["BROWSER"] === "none" ? false : process.env["BROWSER"] : DEFAULT_OPEN;
|
|
44
|
-
|
|
45
|
-
if (serverInterface.isPrimaryWorker()) {
|
|
46
|
-
cache.set(ADMIN_EDITOR_BROWSER_OPEN_KEY, true);
|
|
47
|
-
try {
|
|
48
|
-
serverInterface.openBrowser(`${BASEEDITOR_PATH}?${ADMIN_EDITOR_AUTH_QUERY}=${KEY}`);
|
|
49
|
-
//serverInterface.logger.log(`${OPEN} "${adminPath}"`);
|
|
50
|
-
//execSync(`${OPEN} "${adminPath}"`);
|
|
51
|
-
} catch (e) {
|
|
52
|
-
serverInterface.logger.error(e.message);
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
} as ServerConfig;
|
package/editor/ws.ts
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { WSConfig } from "../src/types.js";
|
|
2
|
-
import { LOG_SOCKET_PATH } from "./common/constants.js";
|
|
3
|
-
import { AdminRequest } from "../src/common/admin-interface.js";
|
|
4
|
-
import { ADMIN_EDITOR_AUTH_KEY } from "./auth.js";
|
|
5
|
-
|
|
6
|
-
export default {
|
|
7
|
-
path: LOG_SOCKET_PATH,
|
|
8
|
-
validate(req: AdminRequest) {
|
|
9
|
-
const admin = req.editor;
|
|
10
|
-
const cache = (admin ? admin.getCache() : req.server.cache);
|
|
11
|
-
|
|
12
|
-
const KEY = cache.get(ADMIN_EDITOR_AUTH_KEY);
|
|
13
|
-
const cookieToken = req.cookies[ADMIN_EDITOR_AUTH_KEY];
|
|
14
|
-
|
|
15
|
-
return cookieToken && KEY && cookieToken === KEY ? true : false;
|
|
16
|
-
},
|
|
17
|
-
} as WSConfig;
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|