silgi 0.43.11 → 0.43.13

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.
@@ -93,6 +93,7 @@ async function watchDev() {
93
93
  });
94
94
  }
95
95
  async function close() {
96
+ if (watcher) await watcher.close();
96
97
  await silgiCLIIClose();
97
98
  }
98
99
  return {
@@ -5,28 +5,9 @@ import consola from "consola";
5
5
  import { useSilgiCLI } from "silgi";
6
6
  import { version } from "silgi/meta";
7
7
  import { runCommand } from "citty";
8
- import { spawn } from "node:child_process";
9
- import { platform } from "node:os";
10
- import { promisify } from "node:util";
11
- import treeKill from "tree-kill";
8
+ import { execa } from "execa";
12
9
 
13
10
  //#region src/cli/commands/run.ts
14
- const treeKillAsync = promisify(treeKill);
15
- function waitForProcess(proc) {
16
- return new Promise((resolve, reject) => {
17
- proc.on("exit", (code) => resolve(code ?? 0));
18
- proc.on("error", (err) => reject(err));
19
- });
20
- }
21
- async function killProcessTree(pid, signal = "SIGTERM") {
22
- try {
23
- await treeKillAsync(pid, signal);
24
- return true;
25
- } catch (error) {
26
- consola.warn(`Failed to kill process tree for PID ${pid}:`, error);
27
- return false;
28
- }
29
- }
30
11
  function setupSignalHandlers(onSignal) {
31
12
  const signals = [
32
13
  "SIGINT",
@@ -59,8 +40,8 @@ const command = {
59
40
  ] });
60
41
  const silgi = useSilgiCLI();
61
42
  const startCommand = args.command || rawArgs[0];
62
- let childPid = null;
63
43
  let hasExited = false;
44
+ let childProcess = null;
64
45
  const cleanupAndExit = async (code = 0) => {
65
46
  if (hasExited) return;
66
47
  hasExited = true;
@@ -71,24 +52,27 @@ const command = {
71
52
  const removeSignalHandlers = setupSignalHandlers(async (signal) => {
72
53
  consola.info(`Received ${signal}, terminating process...`);
73
54
  if (watcher?.close) await watcher.close().catch(() => {});
74
- if (childPid) await killProcessTree(childPid, signal);
55
+ if (childProcess) childProcess.kill(signal);
75
56
  await cleanupAndExit(0);
76
57
  });
77
58
  consola.info(`Starting command: nr ${startCommand}`);
78
- const isWindows = platform() === "win32";
79
- const proc = spawn("nr", [startCommand], {
59
+ childProcess = execa("nr", [startCommand], {
80
60
  stdio: "inherit",
81
61
  shell: true,
82
- cwd: process.cwd(),
83
- ...!isWindows && { detached: true }
62
+ cwd: process.cwd()
63
+ });
64
+ childProcess.on("exit", (code) => {
65
+ if (code !== 0) consola.error(`Process exited with code ${code}`);
66
+ else consola.success("Process exited successfully.");
67
+ removeSignalHandlers();
68
+ cleanupAndExit(code ?? 0);
69
+ });
70
+ childProcess.on("error", (err) => {
71
+ consola.error("Child process error:", err);
72
+ removeSignalHandlers();
73
+ cleanupAndExit(1);
84
74
  });
85
- childPid = proc.pid ?? null;
86
- if (!childPid) throw new Error("Failed to start child process: no PID assigned");
87
- const exitCode = await waitForProcess(proc);
88
- if (exitCode !== 0) consola.error(`Process exited with code ${exitCode}`);
89
- else consola.success("Process exited successfully.");
90
- removeSignalHandlers();
91
- await cleanupAndExit(exitCode);
75
+ await childProcess;
92
76
  } catch (error) {
93
77
  consola.error(`Failed to start the development server: ${error instanceof Error ? error.message : error}`);
94
78
  if (silgi.options.debug) consola.withTag("silgi").error("Error while running the command", error);
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.11";
4
+ var version = "0.43.13";
5
5
  var private$1 = false;
6
6
  var packageManager = "pnpm@10.12.2";
7
7
  var sideEffects = false;
@@ -90,6 +90,7 @@ var dependencies = {
90
90
  "dot-prop": "catalog:",
91
91
  "dotenv": "catalog:",
92
92
  "escape-string-regexp": "catalog:",
93
+ "execa": "^9.6.0",
93
94
  "exsolve": "^1.0.7",
94
95
  "graphql": "^16.11.0",
95
96
  "hookable": "catalog:",
@@ -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 h33 from "h3";
4
+ import * as h32 from "h3";
5
5
  import { PresetName } from "silgi/presets";
6
- import * as nitropack_types1 from "nitropack/types";
6
+ import * as nitropack_types0 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_types1.NitroApp : T extends "nuxt" ? nitropack_types1.NitroApp : T extends "h3" ? h33.Router : never;
27
+ type Framework<T extends PresetName> = T extends "nitro" ? nitropack_types0.NitroApp : T extends "nuxt" ? nitropack_types0.NitroApp : T extends "h3" ? h32.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.11",
4
+ "version": "0.43.13",
5
5
  "private": false,
6
6
  "sideEffects": false,
7
7
  "exports": {
@@ -99,6 +99,7 @@
99
99
  "dot-prop": "^9.0.0",
100
100
  "dotenv": "^16.5.0",
101
101
  "escape-string-regexp": "^5.0.0",
102
+ "execa": "^9.6.0",
102
103
  "exsolve": "^1.0.7",
103
104
  "graphql": "^16.11.0",
104
105
  "hookable": "^5.5.3",