silgi 0.43.13 → 0.43.15
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 +19 -28
- package/dist/package.mjs +1 -1
- package/dist/types/kits.d.mts +3 -3
- 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,45 +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
55
|
stdio: "inherit",
|
|
61
|
-
shell: true,
|
|
62
56
|
cwd: process.cwd()
|
|
63
57
|
});
|
|
64
58
|
childProcess.on("exit", (code) => {
|
|
65
59
|
if (code !== 0) consola.error(`Process exited with code ${code}`);
|
|
66
60
|
else consola.success("Process exited successfully.");
|
|
67
|
-
removeSignalHandlers();
|
|
68
61
|
cleanupAndExit(code ?? 0);
|
|
69
62
|
});
|
|
70
63
|
childProcess.on("error", (err) => {
|
|
71
64
|
consola.error("Child process error:", err);
|
|
72
|
-
removeSignalHandlers();
|
|
73
65
|
cleanupAndExit(1);
|
|
74
66
|
});
|
|
75
67
|
await childProcess;
|
|
76
68
|
} catch (error) {
|
|
77
|
-
consola.error(
|
|
78
|
-
|
|
79
|
-
await cleanupAndExit(1);
|
|
69
|
+
consola.error("Error:", error);
|
|
70
|
+
cleanupAndExit(1);
|
|
80
71
|
}
|
|
81
72
|
}
|
|
82
73
|
};
|
package/dist/package.mjs
CHANGED
package/dist/types/kits.d.mts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { SilgiCLI } from "./silgiCLI.mjs";
|
|
2
2
|
import { BuildSilgi } from "./silgi.mjs";
|
|
3
3
|
import { ESMCodeGenOptions, ESMImport } from "knitwork";
|
|
4
|
-
import * as
|
|
4
|
+
import * as h33 from "h3";
|
|
5
5
|
import { PresetName } from "silgi/presets";
|
|
6
|
-
import * as
|
|
6
|
+
import * as nitropack_types1 from "nitropack/types";
|
|
7
7
|
|
|
8
8
|
//#region src/types/kits.d.ts
|
|
9
9
|
interface SilgiCommands {}
|
|
@@ -24,7 +24,7 @@ interface GenImport {
|
|
|
24
24
|
imports: ESMImport | ESMImport[];
|
|
25
25
|
options?: ESMCodeGenOptions;
|
|
26
26
|
}
|
|
27
|
-
type Framework<T extends PresetName> = T extends "nitro" ?
|
|
27
|
+
type Framework<T extends PresetName> = T extends "nitro" ? nitropack_types1.NitroApp : T extends "nuxt" ? nitropack_types1.NitroApp : T extends "h3" ? h33.Router : never;
|
|
28
28
|
interface DefineFrameworkOptions<T extends PresetName> extends Omit<BuildSilgi, "framework"> {
|
|
29
29
|
framework: Framework<T>;
|
|
30
30
|
}
|