silgi 0.43.16 → 0.43.18
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/build.d.mts +2 -2
- package/dist/cli/build/dev.d.mts +4 -3
- package/dist/cli/build/dev.mjs +30 -44
- package/dist/cli/build/prepare.d.mts +1 -1
- package/dist/cli/commands/init.mjs +1 -1
- package/dist/cli/commands/run.mjs +11 -62
- package/dist/cli/commands/watch.mjs +88 -6
- package/dist/cli/config/index.d.mts +2 -2
- package/dist/cli/config/loader.d.mts +1 -1
- package/dist/cli/config/resolvers/compatibility.mjs +1 -1
- package/dist/cli/config/types.d.mts +1 -1
- package/dist/cli/core/apiful.mjs +1 -1
- package/dist/cli/core/app.mjs +1 -1
- package/dist/cli/index.mjs +1 -1
- package/dist/cli/module/install.mjs +1 -1
- package/dist/cli/module/scan.mjs +6 -6
- package/dist/cli/scan/prepareCommands.mjs +1 -1
- package/dist/cli/scan/scanExportFile.mjs +3 -3
- package/dist/cli/scan/writeTypesAndFiles.mjs +1 -1
- package/dist/cli/utils/compatibility.mjs +1 -1
- package/dist/core/context.d.mts +1 -1
- package/dist/core/createSilgi.d.mts +1 -1
- package/dist/core/error.d.mts +1 -1
- package/dist/core/event.d.mts +1 -1
- package/dist/core/index.d.mts +19 -19
- package/dist/core/response.d.mts +2 -2
- package/dist/core/silgi.d.mts +1 -1
- package/dist/core/silgiApp.d.mts +1 -1
- package/dist/core/storage.d.mts +1 -1
- package/dist/core/unctx.d.mts +1 -1
- package/dist/core/utils/event-stream.d.mts +2 -2
- package/dist/core/utils/event.d.mts +1 -1
- package/dist/core/utils/internal/event-stream.d.mts +1 -1
- package/dist/core/utils/merge.d.mts +1 -1
- package/dist/core/utils/middleware.d.mts +1 -1
- package/dist/core/utils/resolver.d.mts +1 -1
- package/dist/core/utils/runtime.d.mts +1 -1
- package/dist/core/utils/schema.d.mts +1 -1
- package/dist/core/utils/service.d.mts +1 -1
- package/dist/core/utils/shared.d.mts +1 -1
- package/dist/core/utils/storage.d.mts +1 -1
- package/dist/index.d.mts +19 -19
- package/dist/kit/add/add-commands.d.mts +1 -1
- package/dist/kit/add/add-core-file.d.mts +1 -1
- package/dist/kit/add/add-imports.d.mts +1 -1
- package/dist/kit/add/add-npm.d.mts +1 -1
- package/dist/kit/define.d.mts +1 -1
- package/dist/kit/errors.d.mts +1 -1
- package/dist/kit/esm.d.mts +1 -1
- package/dist/kit/fs.d.mts +1 -1
- package/dist/kit/function-utils.d.mts +1 -1
- package/dist/kit/function-utils.mjs +1 -1
- package/dist/kit/gen.d.mts +1 -1
- package/dist/kit/hash.d.mts +1 -1
- package/dist/kit/index.d.mts +21 -21
- package/dist/kit/index.mjs +1 -1
- package/dist/kit/isFramework.d.mts +1 -1
- package/dist/kit/logger.d.mts +1 -1
- package/dist/kit/migration.d.mts +1 -1
- package/dist/kit/migration.mjs +1 -1
- package/dist/kit/module.d.mts +1 -1
- package/dist/kit/path.d.mts +1 -1
- package/dist/kit/preset.d.mts +1 -1
- package/dist/kit/resolve.d.mts +1 -1
- package/dist/kit/resolve.mjs +1 -1
- package/dist/kit/template.d.mts +1 -1
- package/dist/kit/useRequest.d.mts +1 -1
- package/dist/kit/utils.d.mts +1 -1
- package/dist/package.mjs +10 -8
- package/dist/types/kits.d.mts +3 -3
- package/package.json +20 -18
package/dist/build.d.mts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { watchDev } from "./cli/build/dev.mjs";
|
|
2
|
-
import { prepareBuild } from "./cli/build/prepare.mjs";
|
|
1
|
+
import { watchDev$1 as watchDev } from "./cli/build/dev.mjs";
|
|
2
|
+
import { prepareBuild$1 as prepareBuild } from "./cli/build/prepare.mjs";
|
|
3
3
|
export { prepareBuild, watchDev };
|
package/dist/cli/build/dev.d.mts
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { FSWatcher } from "chokidar";
|
|
2
2
|
|
|
3
3
|
//#region src/cli/build/dev.d.ts
|
|
4
|
-
|
|
4
|
+
interface WatchDevResult {
|
|
5
5
|
watcher: FSWatcher | undefined;
|
|
6
6
|
close: () => Promise<void>;
|
|
7
|
-
}
|
|
7
|
+
}
|
|
8
|
+
declare function watchDev(): Promise<WatchDevResult>;
|
|
8
9
|
//#endregion
|
|
9
|
-
export { watchDev };
|
|
10
|
+
export { watchDev as watchDev$1 };
|
package/dist/cli/build/dev.mjs
CHANGED
|
@@ -8,46 +8,27 @@ import { basename } from "pathe";
|
|
|
8
8
|
import { debounce } from "perfect-debounce";
|
|
9
9
|
|
|
10
10
|
//#region src/cli/build/dev.ts
|
|
11
|
+
const WATCH_IGNORE_FILES = [
|
|
12
|
+
"scan",
|
|
13
|
+
"meta",
|
|
14
|
+
"core",
|
|
15
|
+
"configs"
|
|
16
|
+
];
|
|
17
|
+
const WATCH_IGNORE_EXTENSIONS = [
|
|
18
|
+
"ts",
|
|
19
|
+
"js",
|
|
20
|
+
"mjs",
|
|
21
|
+
"cjs",
|
|
22
|
+
"d.ts",
|
|
23
|
+
"d.mts",
|
|
24
|
+
"d.cts",
|
|
25
|
+
"d.js"
|
|
26
|
+
];
|
|
11
27
|
const IGNORED_WATCH_PATTERNS = [
|
|
12
28
|
"**/.silgi/**",
|
|
13
29
|
"**/.output/**",
|
|
14
30
|
"**/types/**",
|
|
15
|
-
|
|
16
|
-
"**/scan.js",
|
|
17
|
-
"**/scan.mjs",
|
|
18
|
-
"**/scan.cjs",
|
|
19
|
-
"**/scan.d.ts",
|
|
20
|
-
"**/scan.d.mts",
|
|
21
|
-
"**/scan.d.cts",
|
|
22
|
-
"**/scan.d.js",
|
|
23
|
-
"**/scan.d.ts",
|
|
24
|
-
"**/meta.ts",
|
|
25
|
-
"**/meta.js",
|
|
26
|
-
"**/meta.mjs",
|
|
27
|
-
"**/meta.cjs",
|
|
28
|
-
"**/meta.d.ts",
|
|
29
|
-
"**/meta.d.mts",
|
|
30
|
-
"**/meta.d.cts",
|
|
31
|
-
"**/meta.d.js",
|
|
32
|
-
"**/meta.d.ts",
|
|
33
|
-
"**/core.ts",
|
|
34
|
-
"**/core.js",
|
|
35
|
-
"**/core.mjs",
|
|
36
|
-
"**/core.cjs",
|
|
37
|
-
"**/core.d.ts",
|
|
38
|
-
"**/core.d.mts",
|
|
39
|
-
"**/core.d.cts",
|
|
40
|
-
"**/core.d.js",
|
|
41
|
-
"**/core.d.ts",
|
|
42
|
-
"**/configs.ts",
|
|
43
|
-
"**/configs.js",
|
|
44
|
-
"**/configs.mjs",
|
|
45
|
-
"**/configs.cjs",
|
|
46
|
-
"**/configs.d.ts",
|
|
47
|
-
"**/configs.d.mts",
|
|
48
|
-
"**/configs.d.cts",
|
|
49
|
-
"**/configs.d.js",
|
|
50
|
-
"**/configs.d.ts"
|
|
31
|
+
...WATCH_IGNORE_FILES.flatMap((file) => WATCH_IGNORE_EXTENSIONS.map((ext) => `**/${file}.${ext}`))
|
|
51
32
|
];
|
|
52
33
|
function isIgnoredByPattern(path) {
|
|
53
34
|
return IGNORED_WATCH_PATTERNS.some((pattern) => micromatch.isMatch(path, pattern));
|
|
@@ -55,14 +36,24 @@ function isIgnoredByPattern(path) {
|
|
|
55
36
|
async function watchDev() {
|
|
56
37
|
const silgi = useSilgiCLI();
|
|
57
38
|
let watcher;
|
|
39
|
+
const changedFiles = new Set();
|
|
58
40
|
async function load() {
|
|
41
|
+
const startTime = performance.now();
|
|
42
|
+
if (changedFiles.size > 0) {
|
|
43
|
+
const fileList = Array.from(changedFiles).map((f) => basename(f)).join(", ");
|
|
44
|
+
consola.info(`Rebuilding: ${fileList}`);
|
|
45
|
+
changedFiles.clear();
|
|
46
|
+
}
|
|
59
47
|
await prepareBuild({
|
|
60
48
|
commandType: "prepare",
|
|
61
49
|
activeEnvironment: silgi.options.activeEnvironment || ".env",
|
|
62
50
|
dev: true
|
|
63
51
|
});
|
|
52
|
+
const endTime = performance.now();
|
|
53
|
+
const elapsedTime = Math.round(endTime - startTime);
|
|
54
|
+
silgi.logger.success(`Build completed in ${elapsedTime}ms`);
|
|
64
55
|
}
|
|
65
|
-
const reload = debounce(load);
|
|
56
|
+
const reload = debounce(load, 300);
|
|
66
57
|
const watchReloadEvents = new Set([
|
|
67
58
|
"add",
|
|
68
59
|
"addDir",
|
|
@@ -72,22 +63,17 @@ async function watchDev() {
|
|
|
72
63
|
]);
|
|
73
64
|
if (silgi.options.devServer.watch.length > 0) {
|
|
74
65
|
silgi.options.devServer.watch = [...new Set(silgi.options.devServer.watch)].filter((p) => !isIgnoredByPattern(p));
|
|
75
|
-
consola.info(
|
|
66
|
+
consola.info(`[silgi] Watching ${silgi.options.devServer.watch.length} paths for changes`);
|
|
76
67
|
watcher = watch(silgi.options.devServer.watch, silgi.options.watchOptions);
|
|
77
68
|
watcher.on("all", async (event, path, stats) => {
|
|
78
69
|
if (!watchReloadEvents.has(event)) return;
|
|
79
|
-
|
|
80
|
-
silgi.errors = [];
|
|
70
|
+
changedFiles.add(path);
|
|
81
71
|
try {
|
|
82
72
|
await reloadScan(path, stats);
|
|
83
73
|
await reload();
|
|
84
74
|
} catch (error) {
|
|
85
75
|
consola.withTag("silgi").error(error);
|
|
86
76
|
}
|
|
87
|
-
silgi.errors = [];
|
|
88
|
-
const endTime = performance.now();
|
|
89
|
-
const elapsedTime = Math.round(endTime - startTime);
|
|
90
|
-
silgi.logger.success(`${basename(path)} - ${elapsedTime}ms`);
|
|
91
77
|
}).on("error", (error) => {
|
|
92
78
|
consola.withTag("silgi").error(error);
|
|
93
79
|
});
|
|
@@ -45,7 +45,7 @@ const command = defineCommand({
|
|
|
45
45
|
"",
|
|
46
46
|
"export default defineSilgiConfig({",
|
|
47
47
|
` preset: '${framework}',`,
|
|
48
|
-
` compatibilityDate: '${
|
|
48
|
+
` compatibilityDate: '${new Date().toISOString().split("T")[0]}',`,
|
|
49
49
|
"",
|
|
50
50
|
"})",
|
|
51
51
|
""
|
|
@@ -1,74 +1,23 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { commonArgs } from "../utils/common.mjs";
|
|
3
|
-
import prepare_default from "./prepare.mjs";
|
|
1
|
+
import watch_default from "./watch.mjs";
|
|
4
2
|
import consola from "consola";
|
|
5
3
|
import { version } from "silgi/meta";
|
|
6
4
|
import { runCommand } from "citty";
|
|
7
|
-
import { execa } from "execa";
|
|
8
5
|
|
|
9
6
|
//#region src/cli/commands/run.ts
|
|
10
7
|
const command = {
|
|
11
8
|
meta: {
|
|
12
|
-
name: "
|
|
13
|
-
description: "
|
|
9
|
+
name: "run",
|
|
10
|
+
description: "[DEPRECATED] Use \"silgi watch <command>\" instead",
|
|
14
11
|
version
|
|
15
12
|
},
|
|
16
|
-
args: {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
async run({ args, rawArgs }) {
|
|
25
|
-
await runCommand(prepare_default, { rawArgs: [
|
|
26
|
-
"--commandType",
|
|
27
|
-
"dev",
|
|
28
|
-
"--dev",
|
|
29
|
-
"true"
|
|
30
|
-
] });
|
|
31
|
-
const startCommand = args.command || rawArgs[0];
|
|
32
|
-
let childProcess = null;
|
|
33
|
-
let watcher = null;
|
|
34
|
-
let exiting = false;
|
|
35
|
-
const cleanupAndExit = async (code = 0) => {
|
|
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 {}
|
|
42
|
-
process.exit(code);
|
|
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);
|
|
51
|
-
try {
|
|
52
|
-
watcher = await watchDev();
|
|
53
|
-
consola.info(`Starting: nr ${startCommand}`);
|
|
54
|
-
childProcess = execa("nr", [startCommand], {
|
|
55
|
-
stdio: "inherit",
|
|
56
|
-
cwd: process.cwd()
|
|
57
|
-
});
|
|
58
|
-
childProcess.on("exit", (code) => {
|
|
59
|
-
if (code !== 0) consola.error(`Process exited with code ${code}`);
|
|
60
|
-
else consola.success("Process exited successfully.");
|
|
61
|
-
cleanupAndExit(code ?? 0);
|
|
62
|
-
});
|
|
63
|
-
childProcess.on("error", (err) => {
|
|
64
|
-
consola.error("Child process error:", err);
|
|
65
|
-
cleanupAndExit(1);
|
|
66
|
-
});
|
|
67
|
-
await childProcess;
|
|
68
|
-
} catch (error) {
|
|
69
|
-
consola.error("Error:", error);
|
|
70
|
-
cleanupAndExit(1);
|
|
71
|
-
}
|
|
13
|
+
args: { command: {
|
|
14
|
+
type: "string",
|
|
15
|
+
description: "your application start command",
|
|
16
|
+
required: false
|
|
17
|
+
} },
|
|
18
|
+
async run({ rawArgs }) {
|
|
19
|
+
consola.warn("The \"run\" command is deprecated. Please use \"silgi watch <command>\" instead.");
|
|
20
|
+
return runCommand(watch_default, { rawArgs });
|
|
72
21
|
}
|
|
73
22
|
};
|
|
74
23
|
var run_default = command;
|
|
@@ -4,6 +4,9 @@ import prepare_default from "./prepare.mjs";
|
|
|
4
4
|
import consola from "consola";
|
|
5
5
|
import { version } from "silgi/meta";
|
|
6
6
|
import { defineCommand, runCommand } from "citty";
|
|
7
|
+
import { execa } from "execa";
|
|
8
|
+
import psTree from "ps-tree";
|
|
9
|
+
import treeKill from "tree-kill";
|
|
7
10
|
|
|
8
11
|
//#region src/cli/commands/watch.ts
|
|
9
12
|
const command = defineCommand({
|
|
@@ -21,9 +24,14 @@ const command = defineCommand({
|
|
|
21
24
|
stub: {
|
|
22
25
|
type: "boolean",
|
|
23
26
|
description: "Run in silgi development mode"
|
|
27
|
+
},
|
|
28
|
+
command: {
|
|
29
|
+
type: "string",
|
|
30
|
+
description: "Optional command to run alongside watch (e.g., \"npm run dev\")",
|
|
31
|
+
required: false
|
|
24
32
|
}
|
|
25
33
|
},
|
|
26
|
-
async run() {
|
|
34
|
+
async run({ args, rawArgs }) {
|
|
27
35
|
await runCommand(prepare_default, { rawArgs: [
|
|
28
36
|
"--commandType",
|
|
29
37
|
"dev",
|
|
@@ -31,15 +39,89 @@ const command = defineCommand({
|
|
|
31
39
|
"true"
|
|
32
40
|
] });
|
|
33
41
|
const watch = await watchDev();
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
42
|
+
const userCommand = args.command || rawArgs[0];
|
|
43
|
+
let childProcess = null;
|
|
44
|
+
if (userCommand) {
|
|
45
|
+
consola.withTag("silgi").info(`Starting: ${userCommand}`);
|
|
46
|
+
const [cmd, ...cmdArgs] = userCommand.split(" ");
|
|
47
|
+
if (!cmd) {
|
|
48
|
+
consola.error("Invalid command provided");
|
|
49
|
+
process.exit(1);
|
|
50
|
+
}
|
|
51
|
+
childProcess = execa(cmd, cmdArgs, {
|
|
52
|
+
stdio: "inherit",
|
|
53
|
+
cwd: process.cwd(),
|
|
54
|
+
cleanup: true,
|
|
55
|
+
detached: false
|
|
56
|
+
});
|
|
57
|
+
childProcess.on("exit", (code) => {
|
|
58
|
+
if (code !== 0) consola.error(`Process exited with code ${code}`);
|
|
59
|
+
process.exit(code ?? 0);
|
|
60
|
+
});
|
|
61
|
+
childProcess.on("error", (err) => {
|
|
62
|
+
consola.error("Child process error:", err);
|
|
63
|
+
process.exit(1);
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
let isShuttingDown = false;
|
|
67
|
+
const shutdown = async (signal) => {
|
|
68
|
+
if (isShuttingDown) return;
|
|
69
|
+
isShuttingDown = true;
|
|
70
|
+
consola.withTag("silgi").info(`Received ${signal}, shutting down...`);
|
|
71
|
+
try {
|
|
72
|
+
if (childProcess && childProcess.pid) {
|
|
73
|
+
const children = await new Promise((resolve) => {
|
|
74
|
+
psTree(childProcess.pid, (err, children$1) => {
|
|
75
|
+
if (err) resolve([]);
|
|
76
|
+
else resolve(children$1);
|
|
77
|
+
});
|
|
78
|
+
});
|
|
79
|
+
if (children.length > 0) {
|
|
80
|
+
consola.info("Terminating process tree:");
|
|
81
|
+
children.forEach((child) => {
|
|
82
|
+
consola.info(` - ${child.COMMAND} (PID: ${child.PID})`);
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
const processCount = children.length + 1;
|
|
86
|
+
consola.info(`Terminating ${processCount} processes...`);
|
|
87
|
+
await new Promise((resolve) => {
|
|
88
|
+
treeKill(childProcess.pid, "SIGTERM", (err) => {
|
|
89
|
+
if (err) consola.withTag("silgi").error("Error killing process tree:", err);
|
|
90
|
+
resolve();
|
|
91
|
+
});
|
|
92
|
+
});
|
|
93
|
+
await new Promise((resolve) => setTimeout(resolve, 2e3));
|
|
94
|
+
if (childProcess.pid) try {
|
|
95
|
+
treeKill(childProcess.pid, "SIGKILL");
|
|
96
|
+
} catch {}
|
|
97
|
+
}
|
|
98
|
+
if (watch?.close) await watch.close();
|
|
99
|
+
consola.success("All processes terminated successfully");
|
|
100
|
+
} catch (error) {
|
|
101
|
+
consola.withTag("silgi").error("Error during shutdown:", error);
|
|
102
|
+
}
|
|
38
103
|
process.exit(0);
|
|
104
|
+
};
|
|
105
|
+
process.on("SIGINT", () => shutdown("SIGINT"));
|
|
106
|
+
process.on("SIGTERM", () => shutdown("SIGTERM"));
|
|
107
|
+
process.on("SIGHUP", () => shutdown("SIGHUP"));
|
|
108
|
+
process.on("SIGQUIT", () => shutdown("SIGQUIT"));
|
|
109
|
+
process.on("exit", () => {
|
|
110
|
+
if (childProcess && childProcess.pid) try {
|
|
111
|
+
treeKill(childProcess.pid, "SIGKILL");
|
|
112
|
+
} catch {}
|
|
113
|
+
});
|
|
114
|
+
process.on("uncaughtException", (error) => {
|
|
115
|
+
consola.withTag("silgi").error("Uncaught exception:", error);
|
|
116
|
+
shutdown("uncaughtException");
|
|
117
|
+
});
|
|
118
|
+
process.on("unhandledRejection", (reason, promise) => {
|
|
119
|
+
consola.withTag("silgi").error("Unhandled rejection at:", promise, "reason:", reason);
|
|
120
|
+
shutdown("unhandledRejection");
|
|
39
121
|
});
|
|
40
122
|
consola.withTag("silgi").success("Prepare completed");
|
|
41
123
|
consola.withTag("silgi").info("Process is still running. Press Ctrl+C to exit.");
|
|
42
|
-
|
|
124
|
+
if (!childProcess) await new Promise(() => {});
|
|
43
125
|
}
|
|
44
126
|
});
|
|
45
127
|
var watch_default = command;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { loadOptions } from "./loader.mjs";
|
|
2
|
-
import { silgiGenerateType } from "./types.mjs";
|
|
1
|
+
import { loadOptions$1 as loadOptions } from "./loader.mjs";
|
|
2
|
+
import { silgiGenerateType$1 as silgiGenerateType } from "./types.mjs";
|
|
3
3
|
export { loadOptions, silgiGenerateType };
|
|
@@ -3,4 +3,4 @@ import { LoadConfigOptions, SilgiCLIConfig, SilgiCLIOptions } from "silgi/types"
|
|
|
3
3
|
//#region src/cli/config/loader.d.ts
|
|
4
4
|
declare function loadOptions(configOverrides?: SilgiCLIConfig, opts?: LoadConfigOptions): Promise<SilgiCLIOptions>;
|
|
5
5
|
//#endregion
|
|
6
|
-
export { loadOptions };
|
|
6
|
+
export { loadOptions as loadOptions$1 };
|
|
@@ -12,7 +12,7 @@ async function resolveCompatibilityOptions(options) {
|
|
|
12
12
|
let _fallbackInfoShown = false;
|
|
13
13
|
let _promptedUserToUpdate = false;
|
|
14
14
|
async function _resolveDefault(options) {
|
|
15
|
-
const _todayDate = formatDate(
|
|
15
|
+
const _todayDate = formatDate(new Date());
|
|
16
16
|
const consola$2 = consola.withTag("silgi");
|
|
17
17
|
consola$2.warn(`No valid compatibility date is specified.`);
|
|
18
18
|
const onFallback = () => {
|
package/dist/cli/core/apiful.mjs
CHANGED
|
@@ -12,7 +12,7 @@ async function generateApiFul(silgi) {
|
|
|
12
12
|
}
|
|
13
13
|
if (!config.services || hasSilgiModule("openapi")) {
|
|
14
14
|
config.services ??= {};
|
|
15
|
-
config.services = {
|
|
15
|
+
config.services.silgi = { schema: join(silgi.options.build.dir, "openapi.json") };
|
|
16
16
|
}
|
|
17
17
|
const resolvedOpenAPIServices = Object.fromEntries(Object.entries(config?.services ?? {}).filter(([, service]) => Boolean(service.schema)));
|
|
18
18
|
if (Object.keys(resolvedOpenAPIServices).length === 0) {
|
package/dist/cli/core/app.mjs
CHANGED
|
@@ -42,7 +42,7 @@ async function generateApp(app, options = {}) {
|
|
|
42
42
|
}
|
|
43
43
|
const templateContext = { app };
|
|
44
44
|
const writes = [];
|
|
45
|
-
const dirs =
|
|
45
|
+
const dirs = new Set();
|
|
46
46
|
const changedTemplates = [];
|
|
47
47
|
async function processTemplate(template) {
|
|
48
48
|
let dir;
|
package/dist/cli/index.mjs
CHANGED
package/dist/cli/module/scan.mjs
CHANGED
|
@@ -103,12 +103,12 @@ async function scanModules(silgi) {
|
|
|
103
103
|
silgi.scanModules = modules;
|
|
104
104
|
}
|
|
105
105
|
function createDependencyGraph(modules) {
|
|
106
|
-
const graph =
|
|
107
|
-
const inDegree =
|
|
106
|
+
const graph = new Map();
|
|
107
|
+
const inDegree = new Map();
|
|
108
108
|
modules.forEach((module) => {
|
|
109
109
|
const key = module.meta?.configKey;
|
|
110
110
|
if (key) {
|
|
111
|
-
graph.set(key,
|
|
111
|
+
graph.set(key, new Set());
|
|
112
112
|
inDegree.set(key, 0);
|
|
113
113
|
}
|
|
114
114
|
});
|
|
@@ -118,7 +118,7 @@ function createDependencyGraph(modules) {
|
|
|
118
118
|
const requiredDeps = module.meta?.requiredDependencies || [];
|
|
119
119
|
const beforeDeps = module.meta?.beforeDependencies || [];
|
|
120
120
|
const afterDeps = module.meta?.afterDependencies || [];
|
|
121
|
-
const processedDeps =
|
|
121
|
+
const processedDeps = new Set();
|
|
122
122
|
requiredDeps.forEach((dep) => {
|
|
123
123
|
if (!graph.has(dep)) throw new Error(`Required dependency "${dep}" for module "${key}" is missing`);
|
|
124
124
|
graph.get(dep)?.add(key);
|
|
@@ -143,8 +143,8 @@ function createDependencyGraph(modules) {
|
|
|
143
143
|
};
|
|
144
144
|
}
|
|
145
145
|
function findCyclicDependencies(graph) {
|
|
146
|
-
const visited =
|
|
147
|
-
const recursionStack =
|
|
146
|
+
const visited = new Set();
|
|
147
|
+
const recursionStack = new Set();
|
|
148
148
|
const cycles = [];
|
|
149
149
|
function dfs(node, path = []) {
|
|
150
150
|
visited.add(node);
|
|
@@ -19,7 +19,7 @@ async function prepareCommands(silgi = useSilgiCLI()) {
|
|
|
19
19
|
if (command.tags) command.tags.forEach((tag) => acc.add(tag));
|
|
20
20
|
});
|
|
21
21
|
return acc;
|
|
22
|
-
},
|
|
22
|
+
}, new Set());
|
|
23
23
|
const data = [
|
|
24
24
|
genAugmentation("silgi/types", { SilgiCommands: { ...Object.fromEntries(Array.from(allTags.values()).map((tag) => [tag, "string"])) } }),
|
|
25
25
|
"",
|
|
@@ -152,7 +152,7 @@ async function extractExportEntitiesFromFile(absoluteFilePath, functionExportNam
|
|
|
152
152
|
const exportEntities = [];
|
|
153
153
|
const fileContent = await readFile(absoluteFilePath, "utf-8");
|
|
154
154
|
const parsed = await parseAsync(absoluteFilePath, fileContent);
|
|
155
|
-
const variableDeclarations =
|
|
155
|
+
const variableDeclarations = new Map();
|
|
156
156
|
for (const node of parsed.program.body) {
|
|
157
157
|
if (node.type === "VariableDeclaration" && Array.isArray(node.declarations)) {
|
|
158
158
|
for (const decl of node.declarations) if (decl.type === "VariableDeclarator" && decl.id.type === "Identifier") variableDeclarations.set(decl.id.name, decl);
|
|
@@ -224,7 +224,7 @@ async function extractExportEntitiesFromFile(absoluteFilePath, functionExportNam
|
|
|
224
224
|
return exportEntities;
|
|
225
225
|
}
|
|
226
226
|
async function scanSilgiExports(path, packageName, silgiInstance = useSilgiCLI(), scanOptions = {}) {
|
|
227
|
-
const processedFilePaths =
|
|
227
|
+
const processedFilePaths = new Set();
|
|
228
228
|
const alreadyScannedPaths = [];
|
|
229
229
|
const serverDirectory = path || silgiInstance.options.serverDir;
|
|
230
230
|
const functionExportNames = scanOptions.functionExportNames ?? DEFAULT_FUNCTION_EXPORT_NAMES;
|
|
@@ -263,7 +263,7 @@ async function scanSilgiExports(path, packageName, silgiInstance = useSilgiCLI()
|
|
|
263
263
|
if (!silgiInstance.options.extensions?.includes(fileExtension)) continue;
|
|
264
264
|
try {
|
|
265
265
|
const exportEntities = await extractExportEntitiesFromFile(absoluteFilePath, functionExportNames, interfaceExtendsNames);
|
|
266
|
-
const seenServiceSignatures =
|
|
266
|
+
const seenServiceSignatures = new Map();
|
|
267
267
|
for (const entity of exportEntities) if ((entity.funcName === "createService" || entity.funcName === "createWebSocket") && entity.servicePath && entity.serviceMethod) {
|
|
268
268
|
const key = `${entity.serviceMethod}:${entity.servicePath}`;
|
|
269
269
|
if (seenServiceSignatures.has(key)) throw new Error(`Duplicate ${entity.funcName} detected for path "${entity.servicePath}" and method "${entity.serviceMethod}".\nFirst found in: ${seenServiceSignatures.get(key)}\nDuplicate in: ${absoluteFilePath}\nPlease ensure each service path/method combination is unique.`);
|
|
@@ -24,7 +24,7 @@ async function writeTypesAndFiles(silgi) {
|
|
|
24
24
|
await silgi.unimport.init();
|
|
25
25
|
const allImports = await silgi.unimport.getImports();
|
|
26
26
|
autoImportExports = toExports(allImports).replace(/#internal\/nitro/g, relative(typesDir, runtimeDir));
|
|
27
|
-
const resolvedImportPathMap =
|
|
27
|
+
const resolvedImportPathMap = new Map();
|
|
28
28
|
for (const i of allImports.filter((i$1) => !i$1.type)) {
|
|
29
29
|
if (resolvedImportPathMap.has(i.from)) continue;
|
|
30
30
|
let path = resolveAlias$1(i.from, silgi.options.alias);
|
package/dist/core/context.d.mts
CHANGED
package/dist/core/error.d.mts
CHANGED
|
@@ -62,4 +62,4 @@ declare function createError<DataT = unknown>(input: string | (Partial<SilgiErro
|
|
|
62
62
|
*/
|
|
63
63
|
declare function isError<DataT = unknown>(input: any): input is SilgiError<DataT>;
|
|
64
64
|
//#endregion
|
|
65
|
-
export { SilgiError, createError, isError };
|
|
65
|
+
export { SilgiError as SilgiError$1, createError as createError$1, isError as isError$1 };
|
package/dist/core/event.d.mts
CHANGED
package/dist/core/index.d.mts
CHANGED
|
@@ -1,22 +1,22 @@
|
|
|
1
|
-
import { updateRuntimeStorage, useRuntime } from "./context.mjs";
|
|
2
|
-
import { createSilgi } from "./createSilgi.mjs";
|
|
3
|
-
import { SilgiError, createError, isError } from "./error.mjs";
|
|
4
|
-
import { SilgiHttpEvent } from "./event.mjs";
|
|
5
|
-
import { handleResponse, kHandled, kNotFound } from "./response.mjs";
|
|
6
|
-
import { getWebsocket, handler, middleware, silgiFetch } from "./silgi.mjs";
|
|
7
|
-
import { silgiCLICtx, tryUseSilgiCLI, useSilgiCLI } from "./silgiApp.mjs";
|
|
8
|
-
import { storageMount } from "./storage.mjs";
|
|
9
|
-
import { silgiCtx, tryUseSilgi, useSilgi } from "./unctx.mjs";
|
|
10
|
-
import { createEventStream } from "./utils/event-stream.mjs";
|
|
11
|
-
import { getEvent, getEventContext } from "./utils/event.mjs";
|
|
12
|
-
import { deepMergeObjects } from "./utils/merge.mjs";
|
|
13
|
-
import { createMiddleware } from "./utils/middleware.mjs";
|
|
14
|
-
import { createResolver, getUrlPrefix } from "./utils/resolver.mjs";
|
|
15
|
-
import { replaceRuntimeValues } from "./utils/runtime.mjs";
|
|
16
|
-
import { createSchema } from "./utils/schema.mjs";
|
|
17
|
-
import { createService, createWebSocket, defineServiceSetup } from "./utils/service.mjs";
|
|
18
|
-
import { createShared } from "./utils/shared.mjs";
|
|
19
|
-
import { createStorage, useSilgiStorage } from "./utils/storage.mjs";
|
|
1
|
+
import { updateRuntimeStorage$1 as updateRuntimeStorage, useRuntime$1 as useRuntime } from "./context.mjs";
|
|
2
|
+
import { createSilgi$1 as createSilgi } from "./createSilgi.mjs";
|
|
3
|
+
import { SilgiError$1 as SilgiError, createError$1 as createError, isError$1 as isError } from "./error.mjs";
|
|
4
|
+
import { SilgiHttpEvent$1 as SilgiHttpEvent } from "./event.mjs";
|
|
5
|
+
import { handleResponse$1 as handleResponse, kHandled$1 as kHandled, kNotFound$1 as kNotFound } from "./response.mjs";
|
|
6
|
+
import { getWebsocket$1 as getWebsocket, handler$1 as handler, middleware$1 as middleware, silgiFetch$1 as silgiFetch } from "./silgi.mjs";
|
|
7
|
+
import { silgiCLICtx$1 as silgiCLICtx, tryUseSilgiCLI$1 as tryUseSilgiCLI, useSilgiCLI$1 as useSilgiCLI } from "./silgiApp.mjs";
|
|
8
|
+
import { storageMount$1 as storageMount } from "./storage.mjs";
|
|
9
|
+
import { silgiCtx$1 as silgiCtx, tryUseSilgi$1 as tryUseSilgi, useSilgi$1 as useSilgi } from "./unctx.mjs";
|
|
10
|
+
import { createEventStream$1 as createEventStream } from "./utils/event-stream.mjs";
|
|
11
|
+
import { getEvent$1 as getEvent, getEventContext$1 as getEventContext } from "./utils/event.mjs";
|
|
12
|
+
import { deepMergeObjects$1 as deepMergeObjects } from "./utils/merge.mjs";
|
|
13
|
+
import { createMiddleware$1 as createMiddleware } from "./utils/middleware.mjs";
|
|
14
|
+
import { createResolver$3 as createResolver, getUrlPrefix$1 as getUrlPrefix } from "./utils/resolver.mjs";
|
|
15
|
+
import { replaceRuntimeValues$1 as replaceRuntimeValues } from "./utils/runtime.mjs";
|
|
16
|
+
import { createSchema$1 as createSchema } from "./utils/schema.mjs";
|
|
17
|
+
import { createService$1 as createService, createWebSocket$1 as createWebSocket, defineServiceSetup$1 as defineServiceSetup } from "./utils/service.mjs";
|
|
18
|
+
import { createShared$1 as createShared } from "./utils/shared.mjs";
|
|
19
|
+
import { createStorage$1 as createStorage, useSilgiStorage$1 as useSilgiStorage } from "./utils/storage.mjs";
|
|
20
20
|
|
|
21
21
|
//#region src/core/index.d.ts
|
|
22
22
|
// TODO: bunlari yinede destekle.
|
package/dist/core/response.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { SilgiError } from "./error.mjs";
|
|
1
|
+
import { SilgiError$1 as SilgiError } from "./error.mjs";
|
|
2
2
|
import { SilgiEvent } from "silgi/types";
|
|
3
3
|
|
|
4
4
|
//#region src/core/response.d.ts
|
|
@@ -17,4 +17,4 @@ declare const kNotFound: symbol;
|
|
|
17
17
|
declare const kHandled: symbol;
|
|
18
18
|
declare function handleResponse(val: unknown, event: SilgiEvent, config: SilgiHandlerConfig): Response | Promise<Response>;
|
|
19
19
|
//#endregion
|
|
20
|
-
export { handleResponse, kHandled, kNotFound };
|
|
20
|
+
export { handleResponse as handleResponse$1, kHandled as kHandled$1, kNotFound as kNotFound$1 };
|
package/dist/core/silgi.d.mts
CHANGED
|
@@ -16,4 +16,4 @@ declare function middleware(event: SilgiEvent): Promise<any>;
|
|
|
16
16
|
declare function handler(event: SilgiEvent): Promise<any>;
|
|
17
17
|
declare function getWebsocket(silgi?: Silgi): WebSocketOptions;
|
|
18
18
|
//#endregion
|
|
19
|
-
export { getWebsocket, handler, middleware, silgiFetch };
|
|
19
|
+
export { getWebsocket as getWebsocket$1, handler as handler$1, middleware as middleware$1, silgiFetch as silgiFetch$1 };
|
package/dist/core/silgiApp.d.mts
CHANGED
|
@@ -6,4 +6,4 @@ declare const silgiCLICtx: UseContext<SilgiCLI>;
|
|
|
6
6
|
declare function useSilgiCLI(): SilgiCLI;
|
|
7
7
|
declare function tryUseSilgiCLI(): SilgiCLI | null;
|
|
8
8
|
//#endregion
|
|
9
|
-
export { silgiCLICtx, tryUseSilgiCLI, useSilgiCLI };
|
|
9
|
+
export { silgiCLICtx as silgiCLICtx$1, tryUseSilgiCLI as tryUseSilgiCLI$1, useSilgiCLI as useSilgiCLI$1 };
|
package/dist/core/storage.d.mts
CHANGED
|
@@ -4,4 +4,4 @@ import { Silgi, SilgiStorageBase } from "silgi/types";
|
|
|
4
4
|
//#region src/core/storage.d.ts
|
|
5
5
|
declare function storageMount<T extends Storage = Storage>(silgi?: Silgi): (base: keyof SilgiStorageBase, driver: Parameters<Storage["mount"]>[1]) => T;
|
|
6
6
|
//#endregion
|
|
7
|
-
export { storageMount };
|
|
7
|
+
export { storageMount as storageMount$1 };
|
package/dist/core/unctx.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { EventStream } from "./internal/event-stream.mjs";
|
|
1
|
+
import { EventStream$1 as EventStream } from "./internal/event-stream.mjs";
|
|
2
2
|
import { SilgiEvent } from "silgi/types";
|
|
3
3
|
|
|
4
4
|
//#region src/core/utils/event-stream.d.ts
|
|
@@ -50,4 +50,4 @@ interface EventStreamMessage {
|
|
|
50
50
|
*/
|
|
51
51
|
declare function createEventStream(event: SilgiEvent, opts?: EventStreamOptions): EventStream;
|
|
52
52
|
//#endregion
|
|
53
|
-
export { EventStreamMessage, EventStreamOptions, createEventStream };
|
|
53
|
+
export { EventStreamMessage, EventStreamOptions, createEventStream as createEventStream$1 };
|