@antelopejs/dms-frontend 0.3.8 → 0.3.9
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 +82 -23
- package/dist/cancellation.d.ts +8 -0
- package/dist/cancellation.js +23 -0
- package/dist/child-output.d.ts +45 -0
- package/dist/child-output.js +183 -0
- package/dist/commands/build-action.d.ts +21 -0
- package/dist/commands/build-action.js +144 -0
- package/dist/commands/build.js +54 -62
- package/dist/commands/clean-action.d.ts +8 -0
- package/dist/commands/clean-action.js +97 -0
- package/dist/commands/clean.js +52 -39
- package/dist/commands/dev-action.d.ts +8 -0
- package/dist/commands/dev-action.js +120 -0
- package/dist/commands/dev.js +55 -115
- package/dist/commands/prepare-action.d.ts +8 -0
- package/dist/commands/prepare-action.js +73 -0
- package/dist/commands/prepare.js +55 -54
- package/dist/commands/start-action.d.ts +5 -0
- package/dist/commands/start-action.js +77 -0
- package/dist/commands/start.js +48 -48
- package/dist/commands/verify-source-action.d.ts +10 -0
- package/dist/commands/verify-source-action.js +104 -0
- package/dist/commands/verify-source.d.ts +0 -1
- package/dist/commands/verify-source.js +53 -31
- package/dist/commands/workspace-task.d.ts +2 -0
- package/dist/commands/workspace-task.js +26 -0
- package/dist/commands/workspaces-action.d.ts +25 -0
- package/dist/commands/workspaces-action.js +71 -0
- package/dist/commands/workspaces.d.ts +2 -0
- package/dist/commands/workspaces.js +60 -0
- package/dist/common.d.ts +1 -0
- package/dist/common.js +1 -0
- package/dist/config.d.ts +13 -4
- package/dist/config.js +115 -18
- package/dist/derived-outputs.d.ts +6 -1
- package/dist/derived-outputs.js +12 -3
- package/dist/discovery.d.ts +2 -1
- package/dist/discovery.js +28 -11
- package/dist/env-file.js +5 -2
- package/dist/help.d.ts +5 -0
- package/dist/help.js +70 -0
- package/dist/index.js +98 -38
- package/dist/layer-watch.d.ts +2 -1
- package/dist/layer-watch.js +129 -26
- package/dist/layers.d.ts +2 -2
- package/dist/layers.js +71 -23
- package/dist/manifest-secrets.d.ts +3 -2
- package/dist/manifest-secrets.js +25 -21
- package/dist/manifest.d.ts +22 -5
- package/dist/manifest.js +184 -28
- package/dist/materialize.js +2 -1
- package/dist/output.d.ts +41 -0
- package/dist/output.js +197 -0
- package/dist/ports.d.ts +2 -0
- package/dist/ports.js +23 -13
- package/dist/renderer-range.d.ts +3 -1
- package/dist/renderer-range.js +49 -17
- package/dist/server-process.d.ts +39 -0
- package/dist/server-process.js +221 -0
- package/dist/typecheck-output.d.ts +13 -0
- package/dist/typecheck-output.js +87 -0
- package/dist/update-check.d.ts +14 -2
- package/dist/update-check.js +95 -29
- package/dist/verify-source-result.d.ts +11 -0
- package/dist/verify-source-result.js +17 -0
- package/dist/verify-source-runner.js +266 -131
- package/dist/vite-output.d.ts +14 -0
- package/dist/vite-output.js +99 -0
- package/dist/workspace-setup.d.ts +17 -3
- package/dist/workspace-setup.js +119 -35
- package/dist/workspace.d.ts +8 -2
- package/dist/workspace.js +47 -12
- package/package.json +4 -12
- package/templates/vue/package.json +4 -0
- package/templates/vue/server/cli-report.mjs +91 -0
- package/templates/vue/server.mjs +18 -15
- package/templates/vue/vite.config.ts +8 -1
- package/templates/vue/vite.email.config.ts +5 -1
- package/dist/utils/cli-ui.d.ts +0 -27
- package/dist/utils/cli-ui.js +0 -178
package/dist/ports.js
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.PORT_FALLBACK_RANGE = void 0;
|
|
3
|
+
exports.MAX_TCP_PORT = exports.PORT_FALLBACK_RANGE = void 0;
|
|
4
4
|
exports.reserveFreePort = reserveFreePort;
|
|
5
|
+
exports.reservePort = reservePort;
|
|
5
6
|
const node_net_1 = require("node:net");
|
|
7
|
+
const cli_1 = require("@antelopejs/core/cli");
|
|
6
8
|
exports.PORT_FALLBACK_RANGE = 20;
|
|
7
|
-
|
|
9
|
+
exports.MAX_TCP_PORT = 65535;
|
|
8
10
|
function tryListen(port) {
|
|
9
11
|
return new Promise((resolve) => {
|
|
10
12
|
const server = (0, node_net_1.createServer)((socket) => socket.destroy());
|
|
@@ -14,17 +16,25 @@ function tryListen(port) {
|
|
|
14
16
|
});
|
|
15
17
|
}
|
|
16
18
|
async function reserveFreePort(preferred, range = exports.PORT_FALLBACK_RANGE) {
|
|
17
|
-
const end = Math.min(preferred + range, MAX_TCP_PORT);
|
|
19
|
+
const end = Math.min(preferred + range, exports.MAX_TCP_PORT);
|
|
18
20
|
for (let port = preferred; port <= end; port++) {
|
|
19
|
-
const
|
|
20
|
-
if (
|
|
21
|
-
return
|
|
22
|
-
port: server.address().port,
|
|
23
|
-
release: () => new Promise((resolve) => {
|
|
24
|
-
server.close(() => resolve());
|
|
25
|
-
}),
|
|
26
|
-
};
|
|
27
|
-
}
|
|
21
|
+
const reserved = await reservePort(port);
|
|
22
|
+
if (reserved)
|
|
23
|
+
return reserved;
|
|
28
24
|
}
|
|
29
|
-
throw new
|
|
25
|
+
throw new cli_1.CliError({
|
|
26
|
+
title: `No free port found between ${preferred} and ${end}`,
|
|
27
|
+
fixes: ["Free one of these ports, or pass another one: -p <port>"],
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
async function reservePort(port) {
|
|
31
|
+
const server = await tryListen(port);
|
|
32
|
+
if (!server)
|
|
33
|
+
return undefined;
|
|
34
|
+
return {
|
|
35
|
+
port: server.address().port,
|
|
36
|
+
release: () => new Promise((resolve) => {
|
|
37
|
+
server.close(() => resolve());
|
|
38
|
+
}),
|
|
39
|
+
};
|
|
30
40
|
}
|
package/dist/renderer-range.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { type MessageOptions } from "@antelopejs/core/cli";
|
|
1
2
|
import { ResolvedLayer } from "./workspace";
|
|
2
3
|
export interface RendererRelease {
|
|
3
4
|
name: string;
|
|
@@ -5,6 +6,7 @@ export interface RendererRelease {
|
|
|
5
6
|
}
|
|
6
7
|
export interface RendererRangeCheckOptions {
|
|
7
8
|
renderer?: RendererRelease;
|
|
8
|
-
warn?: (
|
|
9
|
+
warn?: (text: string, options: MessageOptions) => void;
|
|
10
|
+
workspaceDir?: string;
|
|
9
11
|
}
|
|
10
12
|
export declare function assertLayersSupportRenderer(layers: ResolvedLayer[], options?: RendererRangeCheckOptions): void;
|
package/dist/renderer-range.js
CHANGED
|
@@ -4,18 +4,39 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.assertLayersSupportRenderer = assertLayersSupportRenderer;
|
|
7
|
+
const node_fs_1 = require("node:fs");
|
|
8
|
+
const node_path_1 = require("node:path");
|
|
9
|
+
const cli_1 = require("@antelopejs/core/cli");
|
|
7
10
|
const semver_1 = __importDefault(require("semver"));
|
|
8
11
|
const layers_1 = require("./layers");
|
|
12
|
+
const output_1 = require("./output");
|
|
9
13
|
const OWN_RELEASE = require("../package.json");
|
|
10
14
|
const noticedModules = new Set();
|
|
15
|
+
const NOTICED_MODULES_FILE = ".renderer-range-noticed";
|
|
16
|
+
function readNoticedModules(workspaceDir) {
|
|
17
|
+
const file = workspaceDir && (0, node_path_1.join)(workspaceDir, NOTICED_MODULES_FILE);
|
|
18
|
+
if (!file || !(0, node_fs_1.existsSync)(file))
|
|
19
|
+
return new Set();
|
|
20
|
+
return new Set((0, node_fs_1.readFileSync)(file, "utf8").split("\n").filter(Boolean));
|
|
21
|
+
}
|
|
22
|
+
function saveNoticedModules(workspaceDir, modules) {
|
|
23
|
+
if (!workspaceDir)
|
|
24
|
+
return;
|
|
25
|
+
(0, node_fs_1.writeFileSync)((0, node_path_1.join)(workspaceDir, NOTICED_MODULES_FILE), [...modules].map((module) => `${module}\n`).join(""));
|
|
26
|
+
}
|
|
11
27
|
function moduleLabel(layer) {
|
|
12
28
|
if (!layer.packageName)
|
|
13
29
|
return layer.path;
|
|
14
30
|
return `${layer.packageName} (${layer.path})`;
|
|
15
31
|
}
|
|
32
|
+
function shownModule(layer) {
|
|
33
|
+
const where = (0, output_1.showPath)(layer.sourcePath ?? layer.path);
|
|
34
|
+
return layer.packageName ? `${layer.packageName} (${where})` : where;
|
|
35
|
+
}
|
|
16
36
|
function declaredRange(layer, rendererName) {
|
|
17
37
|
return {
|
|
18
38
|
module: moduleLabel(layer),
|
|
39
|
+
shown: shownModule(layer),
|
|
19
40
|
range: (0, layers_1.readLayerPackage)(layer.path)?.engines?.[rendererName],
|
|
20
41
|
};
|
|
21
42
|
}
|
|
@@ -23,38 +44,49 @@ function releaseLine(version) {
|
|
|
23
44
|
return semver_1.default.coerce(version)?.version ?? version;
|
|
24
45
|
}
|
|
25
46
|
function describeProblem(declaration, version) {
|
|
26
|
-
const {
|
|
47
|
+
const { shown, range } = declaration;
|
|
27
48
|
if (typeof range !== "string" || semver_1.default.validRange(range) === null)
|
|
28
|
-
return `${
|
|
49
|
+
return `${shown} declares an unreadable range: ${JSON.stringify(range)}`;
|
|
29
50
|
if (semver_1.default.satisfies(releaseLine(version), range))
|
|
30
51
|
return undefined;
|
|
31
|
-
return `${
|
|
52
|
+
return `${shown} supports ${range}`;
|
|
32
53
|
}
|
|
33
|
-
function noticeUndeclared(declarations, renderer, warn) {
|
|
34
|
-
const
|
|
54
|
+
function noticeUndeclared(declarations, renderer, warn, workspaceDir) {
|
|
55
|
+
const remembered = readNoticedModules(workspaceDir);
|
|
56
|
+
const undeclared = declarations
|
|
35
57
|
.filter(({ range }) => range === undefined)
|
|
36
|
-
.
|
|
37
|
-
|
|
38
|
-
if (modules.length === 0)
|
|
58
|
+
.filter(({ module }) => !noticedModules.has(module) && !remembered.has(module));
|
|
59
|
+
if (undeclared.length === 0)
|
|
39
60
|
return;
|
|
40
|
-
for (const module of
|
|
61
|
+
for (const { module } of undeclared) {
|
|
41
62
|
noticedModules.add(module);
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
63
|
+
remembered.add(module);
|
|
64
|
+
}
|
|
65
|
+
saveNoticedModules(workspaceDir, remembered);
|
|
66
|
+
const hint = (0, cli_1.getProcessUi)().symbols.levels.hint;
|
|
67
|
+
warn(`No supported ${renderer.name} range declared, so not checked against ${renderer.version}`, {
|
|
68
|
+
details: [
|
|
69
|
+
...undeclared.map(({ shown }) => shown),
|
|
70
|
+
`${hint} Declare one in its package.json, under engines["${renderer.name}"]`,
|
|
71
|
+
],
|
|
72
|
+
});
|
|
45
73
|
}
|
|
46
74
|
function assertLayersSupportRenderer(layers, options = {}) {
|
|
47
75
|
const renderer = options.renderer ?? OWN_RELEASE;
|
|
48
76
|
const declarations = layers.map((layer) => declaredRange(layer, renderer.name));
|
|
49
|
-
noticeUndeclared(declarations, renderer, options.warn ??
|
|
77
|
+
noticeUndeclared(declarations, renderer, options.warn ??
|
|
78
|
+
((text, messageOptions) => (0, cli_1.getProcessUi)().message("warn", text, messageOptions)), options.workspaceDir);
|
|
50
79
|
const problems = declarations
|
|
51
80
|
.filter(({ range }) => range !== undefined)
|
|
52
81
|
.map((declaration) => describeProblem(declaration, renderer.version))
|
|
53
82
|
.filter((problem) => problem !== undefined);
|
|
54
83
|
if (problems.length === 0)
|
|
55
84
|
return;
|
|
56
|
-
throw new
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
85
|
+
throw new cli_1.CliError({
|
|
86
|
+
title: `These frontend modules do not run on ${renderer.name} ${renderer.version}`,
|
|
87
|
+
details: problems,
|
|
88
|
+
fixes: [
|
|
89
|
+
`Install a ${renderer.name} release in their ranges, or upgrade the modules`,
|
|
90
|
+
],
|
|
91
|
+
});
|
|
60
92
|
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { networkInterfaces } from "node:os";
|
|
2
|
+
import { type CliProblem } from "@antelopejs/core/cli";
|
|
3
|
+
import type { PathMapper } from "./child-output";
|
|
4
|
+
import type { ReadyLine } from "./output";
|
|
5
|
+
export interface ServerAddress {
|
|
6
|
+
address: string;
|
|
7
|
+
port: number;
|
|
8
|
+
}
|
|
9
|
+
interface ListenError {
|
|
10
|
+
code?: string;
|
|
11
|
+
message: string;
|
|
12
|
+
host: string;
|
|
13
|
+
port: number;
|
|
14
|
+
}
|
|
15
|
+
interface StartErrorLocation {
|
|
16
|
+
file: string;
|
|
17
|
+
line?: number;
|
|
18
|
+
column?: number;
|
|
19
|
+
lineText?: string;
|
|
20
|
+
}
|
|
21
|
+
export interface StartError {
|
|
22
|
+
message: string;
|
|
23
|
+
code?: string;
|
|
24
|
+
location?: StartErrorLocation;
|
|
25
|
+
}
|
|
26
|
+
export interface RunServerOptions {
|
|
27
|
+
name: string;
|
|
28
|
+
script: string;
|
|
29
|
+
cwd: string;
|
|
30
|
+
env: NodeJS.ProcessEnv;
|
|
31
|
+
mapPath?: PathMapper;
|
|
32
|
+
onReady: (address: ServerAddress) => void;
|
|
33
|
+
}
|
|
34
|
+
export declare function describeStartError(error: StartError, mapPath?: PathMapper): CliProblem;
|
|
35
|
+
export declare function describeListenError(error: ListenError): CliProblem;
|
|
36
|
+
export declare function isGuestBridge(name: string, netDir?: string): boolean;
|
|
37
|
+
export declare function readyLines(address: ServerAddress, settings: ReadyLine[], interfaces?: ReturnType<typeof networkInterfaces>, isGuestInterface?: (name: string) => boolean): ReadyLine[];
|
|
38
|
+
export declare function runServer(options: RunServerOptions): Promise<number>;
|
|
39
|
+
export {};
|
|
@@ -0,0 +1,221 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.describeStartError = describeStartError;
|
|
4
|
+
exports.describeListenError = describeListenError;
|
|
5
|
+
exports.isGuestBridge = isGuestBridge;
|
|
6
|
+
exports.readyLines = readyLines;
|
|
7
|
+
exports.runServer = runServer;
|
|
8
|
+
const node_fs_1 = require("node:fs");
|
|
9
|
+
const node_os_1 = require("node:os");
|
|
10
|
+
const node_path_1 = require("node:path");
|
|
11
|
+
const cli_1 = require("@antelopejs/core/cli");
|
|
12
|
+
const cancellation_1 = require("./cancellation");
|
|
13
|
+
const workspace_setup_1 = require("./workspace-setup");
|
|
14
|
+
const READY_MESSAGE = "dms:ready";
|
|
15
|
+
const LISTEN_ERROR_MESSAGE = "dms:listen-error";
|
|
16
|
+
const START_ERROR_MESSAGE = "dms:start-error";
|
|
17
|
+
const DEV_COMMAND = "ajs dms dev";
|
|
18
|
+
const MODULE_NOT_FOUND_CODES = ["ERR_MODULE_NOT_FOUND", "MODULE_NOT_FOUND"];
|
|
19
|
+
const WILDCARD_ADDRESSES = new Set(["0.0.0.0", "::"]);
|
|
20
|
+
const LOCAL_HOST = "localhost";
|
|
21
|
+
const VIRTUAL_INTERFACE_NAME = /^(docker\d|br-|veth|virbr|cni|flannel|cali|cilium|weave|vxlan|kube-|podman|lxcbr|lxdbr|vboxnet|vmnet)/;
|
|
22
|
+
const LINK_LOCAL_IPV4 = /^169\.254\./;
|
|
23
|
+
const MAX_NETWORK_URLS = 3;
|
|
24
|
+
const LINUX_NET_DIR = "/sys/class/net";
|
|
25
|
+
function isRecord(value) {
|
|
26
|
+
return typeof value === "object" && value !== null;
|
|
27
|
+
}
|
|
28
|
+
function readReady(message) {
|
|
29
|
+
if (!isRecord(message) || message.type !== READY_MESSAGE)
|
|
30
|
+
return undefined;
|
|
31
|
+
const { address, port } = message;
|
|
32
|
+
if (typeof address !== "string" || typeof port !== "number")
|
|
33
|
+
return undefined;
|
|
34
|
+
return { address, port };
|
|
35
|
+
}
|
|
36
|
+
function readListenError(message) {
|
|
37
|
+
if (!isRecord(message) || message.type !== LISTEN_ERROR_MESSAGE)
|
|
38
|
+
return undefined;
|
|
39
|
+
return {
|
|
40
|
+
code: typeof message.code === "string" ? message.code : undefined,
|
|
41
|
+
message: String(message.message),
|
|
42
|
+
host: String(message.host),
|
|
43
|
+
port: Number(message.port),
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
function readStartError(message) {
|
|
47
|
+
if (!isRecord(message) || message.type !== START_ERROR_MESSAGE)
|
|
48
|
+
return undefined;
|
|
49
|
+
const { location } = message;
|
|
50
|
+
const isLocated = isRecord(location) && typeof location.file === "string";
|
|
51
|
+
return {
|
|
52
|
+
message: String(message.message),
|
|
53
|
+
code: typeof message.code === "string" ? message.code : undefined,
|
|
54
|
+
location: isLocated
|
|
55
|
+
? {
|
|
56
|
+
file: String(location.file),
|
|
57
|
+
line: typeof location.line === "number" ? location.line : undefined,
|
|
58
|
+
column: typeof location.column === "number" ? location.column : undefined,
|
|
59
|
+
lineText: typeof location.lineText === "string"
|
|
60
|
+
? location.lineText
|
|
61
|
+
: undefined,
|
|
62
|
+
}
|
|
63
|
+
: undefined,
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
function codeFrame(location) {
|
|
67
|
+
const { line, column, lineText } = location;
|
|
68
|
+
if (line === undefined || lineText === undefined)
|
|
69
|
+
return [];
|
|
70
|
+
const gutter = String(line);
|
|
71
|
+
const caret = `${" ".repeat(column ?? 0)}^`;
|
|
72
|
+
return [`${gutter} | ${lineText}`, `${" ".repeat(gutter.length)} | ${caret}`];
|
|
73
|
+
}
|
|
74
|
+
function describeStartError(error, mapPath = (path) => path) {
|
|
75
|
+
const { code, location } = error;
|
|
76
|
+
const message = mapPath(error.message);
|
|
77
|
+
if (code && MODULE_NOT_FOUND_CODES.includes(code)) {
|
|
78
|
+
return {
|
|
79
|
+
title: "Vite could not start in the dev server",
|
|
80
|
+
reason: message,
|
|
81
|
+
fixes: [`Reinstall the workspace dependencies: ${DEV_COMMAND} --force`],
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
if (!location) {
|
|
85
|
+
return {
|
|
86
|
+
title: "Vite could not start in the dev server",
|
|
87
|
+
reason: message,
|
|
88
|
+
fixes: [
|
|
89
|
+
`Look for the cause in Vite's output above, then run ${DEV_COMMAND} again`,
|
|
90
|
+
],
|
|
91
|
+
};
|
|
92
|
+
}
|
|
93
|
+
const position = location.line === undefined
|
|
94
|
+
? ""
|
|
95
|
+
: `:${location.line}:${location.column ?? 0}`;
|
|
96
|
+
return {
|
|
97
|
+
title: `Vite could not start: error in ${mapPath(location.file)}${position}`,
|
|
98
|
+
reason: message,
|
|
99
|
+
fixes: [`Fix the file and run ${DEV_COMMAND} again`],
|
|
100
|
+
details: codeFrame(location),
|
|
101
|
+
};
|
|
102
|
+
}
|
|
103
|
+
function describeListenError(error) {
|
|
104
|
+
const { code, host, port } = error;
|
|
105
|
+
if (code === "EADDRINUSE") {
|
|
106
|
+
return {
|
|
107
|
+
title: `Port ${port} is already in use`,
|
|
108
|
+
reason: `Another process is listening on ${host}:${port}.`,
|
|
109
|
+
fixes: ["Stop it, or pass another port: -p <port>"],
|
|
110
|
+
};
|
|
111
|
+
}
|
|
112
|
+
if (code === "EADDRNOTAVAIL") {
|
|
113
|
+
return {
|
|
114
|
+
title: `The server cannot listen on ${host}:${port}`,
|
|
115
|
+
reason: `${host} is not an address of this machine.`,
|
|
116
|
+
fixes: ["Set HOST to one of its addresses, or unset it"],
|
|
117
|
+
};
|
|
118
|
+
}
|
|
119
|
+
if (code === "EACCES") {
|
|
120
|
+
return {
|
|
121
|
+
title: `The server cannot listen on ${host}:${port}`,
|
|
122
|
+
reason: "Permission denied: ports below 1024 need elevated privileges.",
|
|
123
|
+
fixes: ["Pass a port above 1023: -p <port>"],
|
|
124
|
+
};
|
|
125
|
+
}
|
|
126
|
+
return {
|
|
127
|
+
title: `The server cannot listen on ${host}:${port}`,
|
|
128
|
+
reason: error.message,
|
|
129
|
+
};
|
|
130
|
+
}
|
|
131
|
+
function urlHost(address) {
|
|
132
|
+
if (WILDCARD_ADDRESSES.has(address))
|
|
133
|
+
return LOCAL_HOST;
|
|
134
|
+
return address.includes(":") ? `[${address}]` : address;
|
|
135
|
+
}
|
|
136
|
+
function localUrl({ address, port }) {
|
|
137
|
+
return `http://${urlHost(address)}:${port}/`;
|
|
138
|
+
}
|
|
139
|
+
function isGuestBridge(name, netDir = LINUX_NET_DIR) {
|
|
140
|
+
if (!(0, node_fs_1.existsSync)((0, node_path_1.join)(netDir, name, "bridge")))
|
|
141
|
+
return false;
|
|
142
|
+
const ports = (0, node_fs_1.readdirSync)((0, node_path_1.join)(netDir, name, "brif"));
|
|
143
|
+
return !ports.some((port) => (0, node_fs_1.existsSync)((0, node_path_1.join)(netDir, port, "device")));
|
|
144
|
+
}
|
|
145
|
+
function isLinuxGuestBridge(name) {
|
|
146
|
+
try {
|
|
147
|
+
return process.platform === "linux" && isGuestBridge(name);
|
|
148
|
+
}
|
|
149
|
+
catch {
|
|
150
|
+
return false;
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
function networkUrls({ address, port }, interfaces = (0, node_os_1.networkInterfaces)(), isGuestInterface = isLinuxGuestBridge) {
|
|
154
|
+
if (!WILDCARD_ADDRESSES.has(address))
|
|
155
|
+
return [];
|
|
156
|
+
return Object.entries(interfaces)
|
|
157
|
+
.filter(([name]) => !VIRTUAL_INTERFACE_NAME.test(name))
|
|
158
|
+
.filter(([name]) => !isGuestInterface(name))
|
|
159
|
+
.flatMap(([, entries]) => entries ?? [])
|
|
160
|
+
.filter((entry) => entry.family === "IPv4" && !entry.internal)
|
|
161
|
+
.filter((entry) => !LINK_LOCAL_IPV4.test(entry.address))
|
|
162
|
+
.map((entry) => `http://${entry.address}:${port}/`);
|
|
163
|
+
}
|
|
164
|
+
function readyLines(address, settings, interfaces, isGuestInterface) {
|
|
165
|
+
const network = networkUrls(address, interfaces, isGuestInterface);
|
|
166
|
+
const hidden = network.length - MAX_NETWORK_URLS;
|
|
167
|
+
return [
|
|
168
|
+
{ label: "Local", value: localUrl(address), isLink: true },
|
|
169
|
+
...network.slice(0, MAX_NETWORK_URLS).map((value) => ({
|
|
170
|
+
label: "Network",
|
|
171
|
+
value,
|
|
172
|
+
isLink: true,
|
|
173
|
+
})),
|
|
174
|
+
...(hidden > 0
|
|
175
|
+
? [
|
|
176
|
+
{
|
|
177
|
+
label: "Network",
|
|
178
|
+
value: (0, cli_1.pluralize)(hidden, "more address", "more addresses"),
|
|
179
|
+
},
|
|
180
|
+
]
|
|
181
|
+
: []),
|
|
182
|
+
...settings,
|
|
183
|
+
];
|
|
184
|
+
}
|
|
185
|
+
async function runServer(options) {
|
|
186
|
+
const { name, script, cwd, env, mapPath, onReady } = options;
|
|
187
|
+
let readyAt;
|
|
188
|
+
let listenError;
|
|
189
|
+
let startError;
|
|
190
|
+
try {
|
|
191
|
+
const code = await (0, workspace_setup_1.runCommand)(process.execPath, [script], {
|
|
192
|
+
cwd,
|
|
193
|
+
env,
|
|
194
|
+
shell: false,
|
|
195
|
+
stdio: ["inherit", "inherit", "inherit", "ipc"],
|
|
196
|
+
}, (child) => {
|
|
197
|
+
child.on("message", (message) => {
|
|
198
|
+
const ready = readReady(message);
|
|
199
|
+
if (ready && readyAt === undefined) {
|
|
200
|
+
readyAt = Date.now();
|
|
201
|
+
onReady(ready);
|
|
202
|
+
}
|
|
203
|
+
listenError ??= readListenError(message);
|
|
204
|
+
startError ??= readStartError(message);
|
|
205
|
+
});
|
|
206
|
+
});
|
|
207
|
+
if (listenError)
|
|
208
|
+
throw new cli_1.CliError(describeListenError(listenError));
|
|
209
|
+
if (startError)
|
|
210
|
+
throw new cli_1.CliError(describeStartError(startError, mapPath));
|
|
211
|
+
return code;
|
|
212
|
+
}
|
|
213
|
+
catch (error) {
|
|
214
|
+
if (!(error instanceof cancellation_1.CancelledError))
|
|
215
|
+
throw error;
|
|
216
|
+
const ran = readyAt === undefined
|
|
217
|
+
? undefined
|
|
218
|
+
: `ran ${(0, cli_1.formatDuration)(Date.now() - readyAt)}`;
|
|
219
|
+
throw new cancellation_1.CancelledError(error.signal, `Stopped the ${name}`, ran);
|
|
220
|
+
}
|
|
221
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { type CliProblem } from "@antelopejs/core/cli";
|
|
2
|
+
export interface TypeCheckError {
|
|
3
|
+
location: string;
|
|
4
|
+
code: string;
|
|
5
|
+
message: string[];
|
|
6
|
+
frame: string[];
|
|
7
|
+
}
|
|
8
|
+
export interface TypeCheckReport {
|
|
9
|
+
errors: TypeCheckError[];
|
|
10
|
+
count: number;
|
|
11
|
+
}
|
|
12
|
+
export declare function parseTypeCheckOutput(lines: string[]): TypeCheckReport;
|
|
13
|
+
export declare function describeTypeCheckErrors(report: TypeCheckReport, rerun: string): CliProblem | undefined;
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.parseTypeCheckOutput = parseTypeCheckOutput;
|
|
4
|
+
exports.describeTypeCheckErrors = describeTypeCheckErrors;
|
|
5
|
+
const cli_1 = require("@antelopejs/core/cli");
|
|
6
|
+
const child_output_1 = require("./child-output");
|
|
7
|
+
const ERROR_LINE = /^(.+?):(\d+):(\d+) - error (TS\d+): (.*)$/;
|
|
8
|
+
const SUMMARY_LINE = /^Found (\d+) errors?\b/;
|
|
9
|
+
const CONTINUATION_LINE = /^\s+\S/;
|
|
10
|
+
const SHOWN_ERRORS = 5;
|
|
11
|
+
const DETAIL_INDENT = " ";
|
|
12
|
+
function readError(header, body) {
|
|
13
|
+
const [, file, line, column, code, message] = header;
|
|
14
|
+
const firstBlank = body.findIndex((entry) => entry.trim() === "");
|
|
15
|
+
const chainEnd = firstBlank < 0 ? body.length : firstBlank;
|
|
16
|
+
const chain = body
|
|
17
|
+
.slice(0, chainEnd)
|
|
18
|
+
.filter((entry) => CONTINUATION_LINE.test(entry));
|
|
19
|
+
return {
|
|
20
|
+
location: `${file}:${line}:${column}`,
|
|
21
|
+
code,
|
|
22
|
+
message: [message, ...chain.map((entry) => entry.trim())],
|
|
23
|
+
frame: body
|
|
24
|
+
.slice(chainEnd)
|
|
25
|
+
.filter((entry) => entry.trim() !== "")
|
|
26
|
+
.map((entry) => entry.trimEnd()),
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
function parseTypeCheckOutput(lines) {
|
|
30
|
+
const errors = [];
|
|
31
|
+
let header;
|
|
32
|
+
let body = [];
|
|
33
|
+
let count;
|
|
34
|
+
const close = () => {
|
|
35
|
+
if (header)
|
|
36
|
+
errors.push(readError(header, body));
|
|
37
|
+
header = undefined;
|
|
38
|
+
body = [];
|
|
39
|
+
};
|
|
40
|
+
for (const line of lines) {
|
|
41
|
+
const error = ERROR_LINE.exec(line);
|
|
42
|
+
const summary = SUMMARY_LINE.exec(line);
|
|
43
|
+
if (error || summary)
|
|
44
|
+
close();
|
|
45
|
+
if (error)
|
|
46
|
+
header = error;
|
|
47
|
+
else if (summary)
|
|
48
|
+
count = Number(summary[1]);
|
|
49
|
+
else if (header)
|
|
50
|
+
body.push(line);
|
|
51
|
+
}
|
|
52
|
+
close();
|
|
53
|
+
return { errors, count: Math.max(count ?? 0, errors.length) };
|
|
54
|
+
}
|
|
55
|
+
function describeTypeCheckErrors(report, rerun) {
|
|
56
|
+
const { errors, count } = report;
|
|
57
|
+
const [first] = errors;
|
|
58
|
+
if (!first)
|
|
59
|
+
return undefined;
|
|
60
|
+
if (count === 1) {
|
|
61
|
+
const [reason, ...chain] = first.message;
|
|
62
|
+
return {
|
|
63
|
+
title: `${first.location} ${first.code}`,
|
|
64
|
+
reason,
|
|
65
|
+
fixes: [`Fix the error and run ${rerun} again`],
|
|
66
|
+
details: [...chain, ...first.frame],
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
const shown = errors.slice(0, SHOWN_ERRORS);
|
|
70
|
+
const hidden = count - shown.length;
|
|
71
|
+
return {
|
|
72
|
+
title: (0, cli_1.pluralize)(count, "type error"),
|
|
73
|
+
fixes: [`Fix the errors and run ${rerun} again`],
|
|
74
|
+
details: [
|
|
75
|
+
...shown.flatMap((error) => [
|
|
76
|
+
`${error.location} ${error.code}`,
|
|
77
|
+
...[...error.message, ...error.frame].map((line) => `${DETAIL_INDENT}${line}`),
|
|
78
|
+
]),
|
|
79
|
+
...(hidden > 0
|
|
80
|
+
? [
|
|
81
|
+
`${(0, cli_1.getProcessUi)().symbols.ellipsis} and ${(0, cli_1.pluralize)(hidden, "more error")}`,
|
|
82
|
+
child_output_1.VERBOSE_OUTPUT_HINT,
|
|
83
|
+
]
|
|
84
|
+
: []),
|
|
85
|
+
],
|
|
86
|
+
};
|
|
87
|
+
}
|
package/dist/update-check.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { type Ui } from "@antelopejs/core/cli";
|
|
1
2
|
export declare const UPDATE_CHECK_PACKAGE = "@antelopejs/dms-frontend";
|
|
2
3
|
export declare const UPDATE_CHECK_INTERVAL_MS: number;
|
|
3
4
|
export declare const UPDATE_CHECK_RETRY_INTERVAL_MS: number;
|
|
@@ -7,13 +8,24 @@ export interface UpdateCheckOptions {
|
|
|
7
8
|
currentVersion: string;
|
|
8
9
|
argv?: readonly string[];
|
|
9
10
|
env?: NodeJS.ProcessEnv;
|
|
11
|
+
isTerminal?: boolean;
|
|
10
12
|
now?: () => number;
|
|
11
13
|
cacheFile?: string;
|
|
12
14
|
fetchLatestVersion?: (packageName: string) => Promise<string | undefined>;
|
|
13
|
-
|
|
15
|
+
ui?: Ui;
|
|
16
|
+
write?: (line: string) => void;
|
|
17
|
+
}
|
|
18
|
+
export interface UpdateNoticeOptions {
|
|
19
|
+
isFollowed?: boolean;
|
|
20
|
+
}
|
|
21
|
+
export interface UpdateCheck {
|
|
22
|
+
readonly completion: Promise<void>;
|
|
23
|
+
report(options?: UpdateNoticeOptions): Promise<void>;
|
|
14
24
|
}
|
|
15
25
|
export declare function stripUpdateCheckFlag(argv: readonly string[]): string[];
|
|
16
26
|
export declare function isUpdateCheckEnabled(argv: readonly string[], env: NodeJS.ProcessEnv): boolean;
|
|
17
27
|
export declare function updateCheckCacheFile(): string;
|
|
18
28
|
export declare function fetchLatestVersionFromRegistry(packageName: string, registryUrl?: string, timeoutMs?: number): Promise<string | undefined>;
|
|
19
|
-
export declare function
|
|
29
|
+
export declare function startUpdateCheck(options: UpdateCheckOptions): UpdateCheck | undefined;
|
|
30
|
+
export declare function startProcessUpdateCheck(options: UpdateCheckOptions): void;
|
|
31
|
+
export declare function reportAvailableUpdate(options?: UpdateNoticeOptions): Promise<void>;
|