silgi 0.43.14 → 0.43.16
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/dist/cli/commands/run.mjs +20 -31
- package/dist/cli/scan/prepareSchema.mjs +0 -12
- package/dist/package.mjs +1 -1
- package/package.json +1 -1
|
@@ -2,21 +2,11 @@ import { watchDev } from "../build/dev.mjs";
|
|
|
2
2
|
import { commonArgs } from "../utils/common.mjs";
|
|
3
3
|
import prepare_default from "./prepare.mjs";
|
|
4
4
|
import consola from "consola";
|
|
5
|
-
import { useSilgiCLI } from "silgi";
|
|
6
5
|
import { version } from "silgi/meta";
|
|
7
6
|
import { runCommand } from "citty";
|
|
8
7
|
import { execa } from "execa";
|
|
9
8
|
|
|
10
9
|
//#region src/cli/commands/run.ts
|
|
11
|
-
function setupSignalHandlers(onSignal) {
|
|
12
|
-
const signals = [
|
|
13
|
-
"SIGINT",
|
|
14
|
-
"SIGTERM",
|
|
15
|
-
"SIGHUP"
|
|
16
|
-
];
|
|
17
|
-
signals.forEach((signal) => process.on(signal, () => onSignal(signal)));
|
|
18
|
-
return () => signals.forEach((signal) => process.off(signal, () => onSignal(signal)));
|
|
19
|
-
}
|
|
20
10
|
const command = {
|
|
21
11
|
meta: {
|
|
22
12
|
name: "dev",
|
|
@@ -38,47 +28,46 @@ const command = {
|
|
|
38
28
|
"--dev",
|
|
39
29
|
"true"
|
|
40
30
|
] });
|
|
41
|
-
const silgi = useSilgiCLI();
|
|
42
31
|
const startCommand = args.command || rawArgs[0];
|
|
43
|
-
let hasExited = false;
|
|
44
32
|
let childProcess = null;
|
|
33
|
+
let watcher = null;
|
|
34
|
+
let exiting = false;
|
|
45
35
|
const cleanupAndExit = async (code = 0) => {
|
|
46
|
-
if (
|
|
47
|
-
|
|
36
|
+
if (exiting) return;
|
|
37
|
+
exiting = true;
|
|
38
|
+
try {
|
|
39
|
+
if (watcher?.close) await watcher.close().catch(() => {});
|
|
40
|
+
if (childProcess) childProcess.kill("SIGTERM");
|
|
41
|
+
} catch {}
|
|
48
42
|
process.exit(code);
|
|
49
43
|
};
|
|
44
|
+
const handleSignal = (signal) => {
|
|
45
|
+
consola.info(`Received ${signal}, terminating...`);
|
|
46
|
+
cleanupAndExit(0);
|
|
47
|
+
};
|
|
48
|
+
process.on("SIGINT", handleSignal);
|
|
49
|
+
process.on("SIGTERM", handleSignal);
|
|
50
|
+
process.on("SIGHUP", handleSignal);
|
|
50
51
|
try {
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
consola.info(`Received ${signal}, terminating process...`);
|
|
54
|
-
if (watcher?.close) await watcher.close().catch(() => {});
|
|
55
|
-
if (childProcess) childProcess.kill(signal);
|
|
56
|
-
await cleanupAndExit(0);
|
|
57
|
-
});
|
|
58
|
-
consola.info(`Starting command: nr ${startCommand}`);
|
|
52
|
+
watcher = await watchDev();
|
|
53
|
+
consola.info(`Starting: nr ${startCommand}`);
|
|
59
54
|
childProcess = execa("nr", [startCommand], {
|
|
60
|
-
stdio: "
|
|
61
|
-
shell: true,
|
|
55
|
+
stdio: "inherit",
|
|
62
56
|
cwd: process.cwd()
|
|
63
57
|
});
|
|
64
|
-
if (childProcess.stdout) childProcess.stdout.pipe(process.stdout);
|
|
65
|
-
if (childProcess.stderr) childProcess.stderr.pipe(process.stderr);
|
|
66
58
|
childProcess.on("exit", (code) => {
|
|
67
59
|
if (code !== 0) consola.error(`Process exited with code ${code}`);
|
|
68
60
|
else consola.success("Process exited successfully.");
|
|
69
|
-
removeSignalHandlers();
|
|
70
61
|
cleanupAndExit(code ?? 0);
|
|
71
62
|
});
|
|
72
63
|
childProcess.on("error", (err) => {
|
|
73
64
|
consola.error("Child process error:", err);
|
|
74
|
-
removeSignalHandlers();
|
|
75
65
|
cleanupAndExit(1);
|
|
76
66
|
});
|
|
77
67
|
await childProcess;
|
|
78
68
|
} catch (error) {
|
|
79
|
-
consola.error(
|
|
80
|
-
|
|
81
|
-
await cleanupAndExit(1);
|
|
69
|
+
consola.error("Error:", error);
|
|
70
|
+
cleanupAndExit(1);
|
|
82
71
|
}
|
|
83
72
|
}
|
|
84
73
|
};
|
|
@@ -81,18 +81,6 @@ async function prepareSchema(silgi) {
|
|
|
81
81
|
indentation: 0
|
|
82
82
|
}) : "",
|
|
83
83
|
"",
|
|
84
|
-
generateTypes(await resolveSchema({ ...Object.fromEntries(Object.entries(silgi.options.runtimeConfig).filter(([key]) => ![
|
|
85
|
-
"app",
|
|
86
|
-
"nitro",
|
|
87
|
-
"nuxt"
|
|
88
|
-
].includes(key))) }), {
|
|
89
|
-
interfaceName: "SilgiRuntimeConfigExtends",
|
|
90
|
-
addExport: false,
|
|
91
|
-
addDefaults: false,
|
|
92
|
-
allowExtraKeys: false,
|
|
93
|
-
indentation: 0
|
|
94
|
-
}),
|
|
95
|
-
"",
|
|
96
84
|
generateTypes(await resolveSchema({ ...silgi.services ? Object.values(silgi.services).reduce((acc, service) => {
|
|
97
85
|
const { route } = getServicePath(service.path);
|
|
98
86
|
if (route) acc[route] = "";
|
package/dist/package.mjs
CHANGED