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.
@@ -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 (hasExited) return;
47
- hasExited = true;
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
- const watcher = await watchDev();
52
- const removeSignalHandlers = setupSignalHandlers(async (signal) => {
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(`Failed to start the development server: ${error instanceof Error ? error.message : error}`);
78
- if (silgi.options.debug) consola.withTag("silgi").error("Error while running the command", error);
79
- await cleanupAndExit(1);
69
+ consola.error("Error:", error);
70
+ cleanupAndExit(1);
80
71
  }
81
72
  }
82
73
  };
package/dist/package.mjs CHANGED
@@ -1,7 +1,7 @@
1
1
  //#region package.json
2
2
  var name = "silgi";
3
3
  var type = "module";
4
- var version = "0.43.13";
4
+ var version = "0.43.15";
5
5
  var private$1 = false;
6
6
  var packageManager = "pnpm@10.12.2";
7
7
  var sideEffects = false;
@@ -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 h32 from "h3";
4
+ import * as h33 from "h3";
5
5
  import { PresetName } from "silgi/presets";
6
- import * as nitropack_types0 from "nitropack/types";
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" ? nitropack_types0.NitroApp : T extends "nuxt" ? nitropack_types0.NitroApp : T extends "h3" ? h32.Router : never;
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
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "silgi",
3
3
  "type": "module",
4
- "version": "0.43.13",
4
+ "version": "0.43.15",
5
5
  "private": false,
6
6
  "sideEffects": false,
7
7
  "exports": {