silgi 0.30.5 → 0.30.6
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.mjs +7 -77
- package/dist/cli/dev.mjs +83 -0
- package/dist/cli/index.mjs +1 -1
- package/dist/cli/watch.mjs +10 -53
- package/package.json +2 -2
- package/dist/cli/devServer.mjs +0 -8
package/dist/build.mjs
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
import { c as createSilgiCLI, b as build } from './cli/build.mjs';
|
|
1
|
+
export { p as prepareBuild, w as watchDev } from './cli/dev.mjs';
|
|
2
|
+
import 'chokidar';
|
|
3
|
+
import 'consola';
|
|
4
|
+
import 'pathe';
|
|
5
|
+
import 'perfect-debounce';
|
|
6
|
+
import './_chunks/silgiApp.mjs';
|
|
8
7
|
import 'unctx';
|
|
9
8
|
import 'silgi';
|
|
9
|
+
import './cli/build.mjs';
|
|
10
10
|
import 'hookable';
|
|
11
11
|
import 'silgi/kit';
|
|
12
12
|
import 'silgi/runtime/meta';
|
|
@@ -44,73 +44,3 @@ import 'pkg-types';
|
|
|
44
44
|
import 'apiful/openapi';
|
|
45
45
|
import 'pathe/utils';
|
|
46
46
|
import 'untyped';
|
|
47
|
-
|
|
48
|
-
async function prepareBuild(config) {
|
|
49
|
-
const silgi = await createSilgiCLI({
|
|
50
|
-
commandType: config?.commandType || "prepare",
|
|
51
|
-
...config
|
|
52
|
-
});
|
|
53
|
-
await build(silgi);
|
|
54
|
-
return silgi;
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
async function watchDev() {
|
|
58
|
-
let watcher;
|
|
59
|
-
async function load() {
|
|
60
|
-
await prepareBuild({
|
|
61
|
-
commandType: "prepare",
|
|
62
|
-
activeEnvironment: ".env"
|
|
63
|
-
});
|
|
64
|
-
}
|
|
65
|
-
const reload = debounce(load);
|
|
66
|
-
const silgi = useSilgiCLI();
|
|
67
|
-
silgi.options.watchOptions.ignored ??= [];
|
|
68
|
-
silgi.options.watchOptions.ignoreInitial = true;
|
|
69
|
-
if (Array.isArray(silgi.options.watchOptions.ignored)) {
|
|
70
|
-
silgi.options.watchOptions.ignored.push(
|
|
71
|
-
`!${join(silgi.options.silgi.serverDir, "config")}`
|
|
72
|
-
);
|
|
73
|
-
}
|
|
74
|
-
silgi.options.devServer.watch.push(
|
|
75
|
-
join(silgi.options.serverDir, "services"),
|
|
76
|
-
join(silgi.options.serverDir, "schemas"),
|
|
77
|
-
join(silgi.options.serverDir, "shared"),
|
|
78
|
-
join(silgi.options.serverDir, "utils"),
|
|
79
|
-
join(silgi.options.serverDir, "types"),
|
|
80
|
-
join(silgi.options.silgi.serverDir, "config"),
|
|
81
|
-
join(silgi.options.rootDir, "silgi.config.ts")
|
|
82
|
-
);
|
|
83
|
-
const watchReloadEvents = /* @__PURE__ */ new Set(["add", "addDir", "unlink", "unlinkDir", "change"]);
|
|
84
|
-
if (silgi.options.devServer.watch.length > 0) {
|
|
85
|
-
silgi.options.devServer.watch = [...new Set(silgi.options.devServer.watch)];
|
|
86
|
-
watcher = watch(silgi.options.devServer.watch, silgi.options.watchOptions);
|
|
87
|
-
watcher.on("all", async (event, path, stats) => {
|
|
88
|
-
if (!watchReloadEvents.has(event)) {
|
|
89
|
-
return;
|
|
90
|
-
}
|
|
91
|
-
const startTime = performance.now();
|
|
92
|
-
silgi.errors = [];
|
|
93
|
-
try {
|
|
94
|
-
await reloadScan(path, stats);
|
|
95
|
-
await reload();
|
|
96
|
-
} catch (error) {
|
|
97
|
-
consola.withTag("silgi").error(error);
|
|
98
|
-
}
|
|
99
|
-
silgi.errors = [];
|
|
100
|
-
const endTime = performance.now();
|
|
101
|
-
const elapsedTime = Math.round(endTime - startTime);
|
|
102
|
-
silgi.logger.success(`${basename(path)} - ${elapsedTime}ms`);
|
|
103
|
-
}).on("error", (error) => {
|
|
104
|
-
consola.withTag("silgi").error(error);
|
|
105
|
-
});
|
|
106
|
-
}
|
|
107
|
-
async function close() {
|
|
108
|
-
await silgiCLIIClose();
|
|
109
|
-
}
|
|
110
|
-
return {
|
|
111
|
-
watcher,
|
|
112
|
-
close
|
|
113
|
-
};
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
export { prepareBuild, watchDev };
|
package/dist/cli/dev.mjs
ADDED
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import { watch } from 'chokidar';
|
|
2
|
+
import consola from 'consola';
|
|
3
|
+
import { join, basename } from 'pathe';
|
|
4
|
+
import { debounce } from 'perfect-debounce';
|
|
5
|
+
import { u as useSilgiCLI$1, a as silgiCLIIClose } from '../_chunks/silgiApp.mjs';
|
|
6
|
+
import { useSilgiCLI } from 'silgi';
|
|
7
|
+
import { c as createSilgiCLI, b as build } from './build.mjs';
|
|
8
|
+
|
|
9
|
+
async function reloadScan(path, _stats) {
|
|
10
|
+
const silgi = useSilgiCLI();
|
|
11
|
+
await silgi.callHook("reload:scan", path, _stats);
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
async function prepareBuild(config) {
|
|
15
|
+
const silgi = await createSilgiCLI({
|
|
16
|
+
commandType: config?.commandType || "prepare",
|
|
17
|
+
...config
|
|
18
|
+
});
|
|
19
|
+
await build(silgi);
|
|
20
|
+
return silgi;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
async function watchDev() {
|
|
24
|
+
let watcher;
|
|
25
|
+
async function load() {
|
|
26
|
+
await prepareBuild({
|
|
27
|
+
commandType: "prepare",
|
|
28
|
+
activeEnvironment: ".env"
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
const reload = debounce(load);
|
|
32
|
+
const silgi = useSilgiCLI$1();
|
|
33
|
+
silgi.options.watchOptions.ignored ??= [];
|
|
34
|
+
silgi.options.watchOptions.ignoreInitial = true;
|
|
35
|
+
if (Array.isArray(silgi.options.watchOptions.ignored)) {
|
|
36
|
+
silgi.options.watchOptions.ignored.push(
|
|
37
|
+
`!${join(silgi.options.silgi.serverDir, "config")}`
|
|
38
|
+
);
|
|
39
|
+
}
|
|
40
|
+
silgi.options.devServer.watch.push(
|
|
41
|
+
join(silgi.options.serverDir, "services"),
|
|
42
|
+
join(silgi.options.serverDir, "schemas"),
|
|
43
|
+
join(silgi.options.serverDir, "shared"),
|
|
44
|
+
join(silgi.options.serverDir, "utils"),
|
|
45
|
+
join(silgi.options.serverDir, "types"),
|
|
46
|
+
join(silgi.options.silgi.serverDir, "config"),
|
|
47
|
+
join(silgi.options.silgi.serverDir, "modules"),
|
|
48
|
+
join(silgi.options.rootDir, "silgi.config.ts")
|
|
49
|
+
);
|
|
50
|
+
const watchReloadEvents = /* @__PURE__ */ new Set(["add", "addDir", "unlink", "unlinkDir", "change"]);
|
|
51
|
+
if (silgi.options.devServer.watch.length > 0) {
|
|
52
|
+
silgi.options.devServer.watch = [...new Set(silgi.options.devServer.watch)];
|
|
53
|
+
watcher = watch(silgi.options.devServer.watch, silgi.options.watchOptions);
|
|
54
|
+
watcher.on("all", async (event, path, stats) => {
|
|
55
|
+
if (!watchReloadEvents.has(event)) {
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
58
|
+
const startTime = performance.now();
|
|
59
|
+
silgi.errors = [];
|
|
60
|
+
try {
|
|
61
|
+
await reloadScan(path, stats);
|
|
62
|
+
await reload();
|
|
63
|
+
} catch (error) {
|
|
64
|
+
consola.withTag("silgi").error(error);
|
|
65
|
+
}
|
|
66
|
+
silgi.errors = [];
|
|
67
|
+
const endTime = performance.now();
|
|
68
|
+
const elapsedTime = Math.round(endTime - startTime);
|
|
69
|
+
silgi.logger.success(`${basename(path)} - ${elapsedTime}ms`);
|
|
70
|
+
}).on("error", (error) => {
|
|
71
|
+
consola.withTag("silgi").error(error);
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
async function close() {
|
|
75
|
+
await silgiCLIIClose();
|
|
76
|
+
}
|
|
77
|
+
return {
|
|
78
|
+
watcher,
|
|
79
|
+
close
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
export { prepareBuild as p, watchDev as w };
|
package/dist/cli/index.mjs
CHANGED
package/dist/cli/watch.mjs
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import { basename } from 'node:path';
|
|
2
|
-
import { watch } from 'chokidar';
|
|
3
1
|
import { defineCommand, runCommand } from 'citty';
|
|
4
2
|
import consola from 'consola';
|
|
5
|
-
import { join } from 'pathe';
|
|
6
|
-
import { useSilgiCLI } from 'silgi';
|
|
7
3
|
import { version } from 'silgi/meta';
|
|
8
|
-
import {
|
|
9
|
-
import { r as reloadScan } from './devServer.mjs';
|
|
4
|
+
import { w as watchDev } from './dev.mjs';
|
|
10
5
|
import { b as commonArgs, a as command$1 } from './prepare.mjs';
|
|
6
|
+
import 'chokidar';
|
|
7
|
+
import 'pathe';
|
|
8
|
+
import 'perfect-debounce';
|
|
9
|
+
import '../_chunks/silgiApp.mjs';
|
|
11
10
|
import 'unctx';
|
|
11
|
+
import 'silgi';
|
|
12
12
|
import './build.mjs';
|
|
13
13
|
import 'hookable';
|
|
14
14
|
import 'silgi/kit';
|
|
@@ -69,56 +69,13 @@ const command = defineCommand({
|
|
|
69
69
|
await runCommand(command$1, {
|
|
70
70
|
rawArgs: ["--commandType", "dev", "--dev", "true"]
|
|
71
71
|
});
|
|
72
|
-
const
|
|
73
|
-
silgi.options.watchOptions.ignored ??= [];
|
|
74
|
-
silgi.options.watchOptions.ignoreInitial = true;
|
|
75
|
-
if (Array.isArray(silgi.options.watchOptions.ignored)) {
|
|
76
|
-
silgi.options.watchOptions.ignored.push(
|
|
77
|
-
`!${join(silgi.options.silgi.serverDir, "config")}`
|
|
78
|
-
);
|
|
79
|
-
}
|
|
80
|
-
silgi.options.devServer.watch.push(
|
|
81
|
-
join(silgi.options.serverDir, "services"),
|
|
82
|
-
join(silgi.options.serverDir, "schemas"),
|
|
83
|
-
join(silgi.options.serverDir, "shared"),
|
|
84
|
-
join(silgi.options.serverDir, "utils"),
|
|
85
|
-
join(silgi.options.serverDir, "types"),
|
|
86
|
-
join(silgi.options.silgi.serverDir, "config"),
|
|
87
|
-
join(silgi.options.rootDir, "silgi.config.ts")
|
|
88
|
-
);
|
|
89
|
-
const watchReloadEvents = /* @__PURE__ */ new Set(["add", "addDir", "unlink", "unlinkDir", "change"]);
|
|
90
|
-
let watcher;
|
|
91
|
-
if (silgi.options.devServer.watch.length > 0) {
|
|
92
|
-
silgi.options.devServer.watch = [...new Set(silgi.options.devServer.watch)];
|
|
93
|
-
watcher = watch(silgi.options.devServer.watch, silgi.options.watchOptions);
|
|
94
|
-
watcher.on("all", async (event, path, stats) => {
|
|
95
|
-
if (!watchReloadEvents.has(event)) {
|
|
96
|
-
return;
|
|
97
|
-
}
|
|
98
|
-
const startTime = performance.now();
|
|
99
|
-
silgi.errors = [];
|
|
100
|
-
try {
|
|
101
|
-
await reloadScan(path, stats);
|
|
102
|
-
await runCommand(command$1, {
|
|
103
|
-
rawArgs: ["--commands", "run", "--dev", "true"]
|
|
104
|
-
});
|
|
105
|
-
} catch (error) {
|
|
106
|
-
consola.withTag("silgi").error(error);
|
|
107
|
-
}
|
|
108
|
-
silgi.errors = [];
|
|
109
|
-
const endTime = performance.now();
|
|
110
|
-
const elapsedTime = Math.round(endTime - startTime);
|
|
111
|
-
silgi.logger.success(`${basename(path)} - ${elapsedTime}ms`);
|
|
112
|
-
}).on("error", (error) => {
|
|
113
|
-
consola.withTag("silgi").error(error);
|
|
114
|
-
});
|
|
115
|
-
}
|
|
72
|
+
const watch = await watchDev();
|
|
116
73
|
process.on("SIGINT", async () => {
|
|
117
74
|
consola.withTag("silgi").info("Shutting down...");
|
|
118
|
-
if (
|
|
119
|
-
|
|
75
|
+
if (watch) {
|
|
76
|
+
watch.close();
|
|
120
77
|
}
|
|
121
|
-
await
|
|
78
|
+
await watch.close();
|
|
122
79
|
process.exit(0);
|
|
123
80
|
});
|
|
124
81
|
consola.withTag("silgi").success("Prepare completed");
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "silgi",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.30.
|
|
4
|
+
"version": "0.30.6",
|
|
5
5
|
"private": false,
|
|
6
6
|
"sideEffects": false,
|
|
7
7
|
"exports": {
|
|
@@ -124,7 +124,7 @@
|
|
|
124
124
|
"@antfu/eslint-config": "^4.12.0",
|
|
125
125
|
"@nuxt/kit": "^3.16.2",
|
|
126
126
|
"@nuxt/schema": "^3.16.2",
|
|
127
|
-
"@silgi/ecosystem": "^0.6.
|
|
127
|
+
"@silgi/ecosystem": "^0.6.2",
|
|
128
128
|
"@types/node": "^22.15.2",
|
|
129
129
|
"@types/semver": "^7.7.0",
|
|
130
130
|
"@vitest/coverage-v8": "3.0.5",
|