silgi 0.20.36 → 0.20.38
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/_chunks/index.mjs +1 -1
- package/dist/_chunks/{routeRules.mjs → silgiApp.mjs} +24 -1
- package/dist/cli/dev.mjs +28 -32
- package/dist/cli/install.mjs +2 -1
- package/dist/cli/prepare.mjs +6 -35
- package/dist/core/index.mjs +4 -15
- package/dist/meta/index.d.mts +1 -1
- package/dist/meta/index.d.ts +1 -1
- package/package.json +1 -1
package/dist/_chunks/index.mjs
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import { withoutTrailingSlash, withLeadingSlash } from 'ufo';
|
|
2
|
+
import consola from 'consola';
|
|
3
|
+
import { createContext } from 'unctx';
|
|
2
4
|
|
|
3
5
|
function patternToRegex(pattern) {
|
|
4
6
|
let regexStr = pattern.replace(/[.+?^${}()|[\]\\]/g, "\\$&");
|
|
@@ -285,4 +287,25 @@ function createRouteRules() {
|
|
|
285
287
|
};
|
|
286
288
|
}
|
|
287
289
|
|
|
288
|
-
|
|
290
|
+
const silgiCLICtx = createContext();
|
|
291
|
+
function useSilgiCLI() {
|
|
292
|
+
const instance = silgiCLICtx.tryUse();
|
|
293
|
+
if (!instance) {
|
|
294
|
+
throw new Error("Silgi instance is unavailable!");
|
|
295
|
+
}
|
|
296
|
+
return instance;
|
|
297
|
+
}
|
|
298
|
+
async function silgiCLIIClose() {
|
|
299
|
+
const silgi = silgiCLICtx.tryUse();
|
|
300
|
+
if (!silgi) {
|
|
301
|
+
return;
|
|
302
|
+
}
|
|
303
|
+
await silgi.close();
|
|
304
|
+
await silgi.callHook("close", silgi);
|
|
305
|
+
consola.withTag("silgi").success("Process terminated");
|
|
306
|
+
}
|
|
307
|
+
function tryUseSilgiCLI() {
|
|
308
|
+
return silgiCLICtx.tryUse();
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
export { silgiCLICtx as a, createRouteRules as c, silgiCLIIClose as s, tryUseSilgiCLI as t, useSilgiCLI as u };
|
package/dist/cli/dev.mjs
CHANGED
|
@@ -1,12 +1,14 @@
|
|
|
1
|
+
import { basename } from 'node:path';
|
|
1
2
|
import { watch } from 'chokidar';
|
|
2
3
|
import { defineCommand, runCommand } from 'citty';
|
|
3
4
|
import consola from 'consola';
|
|
4
5
|
import { useSilgiCLI } from 'silgi/core';
|
|
5
6
|
import { version } from 'silgi/meta';
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import
|
|
9
|
-
import '
|
|
7
|
+
import { s as silgiCLIIClose } from '../_chunks/silgiApp.mjs';
|
|
8
|
+
import { c as commonArgs, p as prepare } from './prepare.mjs';
|
|
9
|
+
import 'ufo';
|
|
10
|
+
import 'unctx';
|
|
11
|
+
import 'pathe';
|
|
10
12
|
import 'silgi/kit';
|
|
11
13
|
import 'node:fs';
|
|
12
14
|
import 'node:fs/promises';
|
|
@@ -14,12 +16,12 @@ import 'hookable';
|
|
|
14
16
|
import 'silgi/runtime/meta';
|
|
15
17
|
import 'silgi/types';
|
|
16
18
|
import 'unimport';
|
|
17
|
-
import '../_chunks/routeRules.mjs';
|
|
18
|
-
import 'ufo';
|
|
19
19
|
import '@clack/prompts';
|
|
20
20
|
import 'dotenv';
|
|
21
21
|
import 'mlly';
|
|
22
22
|
import 'dev-jiti';
|
|
23
|
+
import './compatibility.mjs';
|
|
24
|
+
import 'semver/functions/satisfies.js';
|
|
23
25
|
import 'node:url';
|
|
24
26
|
import 'defu';
|
|
25
27
|
import 'exsolve';
|
|
@@ -41,19 +43,9 @@ import 'pathe/utils';
|
|
|
41
43
|
import 'node:child_process';
|
|
42
44
|
import 'picocolors';
|
|
43
45
|
|
|
44
|
-
async function reloadScan(
|
|
45
|
-
const
|
|
46
|
-
silgi.errors = [];
|
|
46
|
+
async function reloadScan(path, _stats) {
|
|
47
|
+
const silgi = useSilgiCLI();
|
|
47
48
|
await silgi.callHook("reload:scan", path, _stats);
|
|
48
|
-
await scanFiles(silgi, silgi.options.devServer.watch);
|
|
49
|
-
if (!hasError("Parser", silgi)) {
|
|
50
|
-
await writeScanFiles(silgi);
|
|
51
|
-
}
|
|
52
|
-
await generateApp(silgi);
|
|
53
|
-
silgi.errors = [];
|
|
54
|
-
const endTime = performance.now();
|
|
55
|
-
const elapsedTime = Math.round(endTime - startTime);
|
|
56
|
-
silgi.logger.success(`${basename(path)} - ${elapsedTime}ms`);
|
|
57
49
|
}
|
|
58
50
|
|
|
59
51
|
const dev = defineCommand({
|
|
@@ -73,7 +65,7 @@ const dev = defineCommand({
|
|
|
73
65
|
description: "Run in silgi development mode"
|
|
74
66
|
}
|
|
75
67
|
},
|
|
76
|
-
async run(
|
|
68
|
+
async run() {
|
|
77
69
|
await runCommand(prepare, {
|
|
78
70
|
rawArgs: ["--commands", "run"]
|
|
79
71
|
});
|
|
@@ -81,30 +73,34 @@ const dev = defineCommand({
|
|
|
81
73
|
let watcher;
|
|
82
74
|
if (silgi.options.devServer.watch.length > 0) {
|
|
83
75
|
watcher = watch(silgi.options.devServer.watch, silgi.options.watchOptions);
|
|
84
|
-
watcher.on("add", async (
|
|
76
|
+
watcher.on("add", async (path, stats) => {
|
|
77
|
+
const startTime = performance.now();
|
|
78
|
+
await reloadScan(path, stats);
|
|
85
79
|
await runCommand(prepare, {
|
|
86
80
|
rawArgs: ["--commands", "run"]
|
|
87
81
|
});
|
|
88
|
-
|
|
89
|
-
|
|
82
|
+
silgi.errors = [];
|
|
83
|
+
const endTime = performance.now();
|
|
84
|
+
const elapsedTime = Math.round(endTime - startTime);
|
|
85
|
+
silgi.logger.success(`${basename(path)} - ${elapsedTime}ms`);
|
|
86
|
+
}).on("change", async (path, stats) => {
|
|
87
|
+
const startTime = performance.now();
|
|
88
|
+
await reloadScan(path, stats);
|
|
90
89
|
await runCommand(prepare, {
|
|
91
90
|
rawArgs: ["--commands", "run"]
|
|
92
91
|
});
|
|
93
|
-
|
|
92
|
+
silgi.errors = [];
|
|
93
|
+
const endTime = performance.now();
|
|
94
|
+
const elapsedTime = Math.round(endTime - startTime);
|
|
95
|
+
silgi.logger.success(`${basename(path)} - ${elapsedTime}ms`);
|
|
94
96
|
});
|
|
95
97
|
}
|
|
96
|
-
|
|
97
|
-
|
|
98
|
+
process.on("SIGINT", async () => {
|
|
99
|
+
consola.withTag("silgi").info("Shutting down...");
|
|
98
100
|
if (watcher) {
|
|
99
101
|
watcher.close();
|
|
100
102
|
}
|
|
101
|
-
await
|
|
102
|
-
consola.withTag("silgi").success("Process terminated");
|
|
103
|
-
};
|
|
104
|
-
process.on("SIGINT", async () => {
|
|
105
|
-
consola.withTag("silgi").info("Shutting down...");
|
|
106
|
-
await close();
|
|
107
|
-
await silgi.callHook("close", silgi);
|
|
103
|
+
await silgiCLIIClose();
|
|
108
104
|
process.exit(0);
|
|
109
105
|
});
|
|
110
106
|
consola.withTag("silgi").success("Prepare completed");
|
package/dist/cli/install.mjs
CHANGED
|
@@ -13,8 +13,9 @@ import 'silgi/core';
|
|
|
13
13
|
import 'silgi/runtime/meta';
|
|
14
14
|
import 'silgi/types';
|
|
15
15
|
import 'unimport';
|
|
16
|
-
import '../_chunks/
|
|
16
|
+
import '../_chunks/silgiApp.mjs';
|
|
17
17
|
import 'ufo';
|
|
18
|
+
import 'unctx';
|
|
18
19
|
import '@clack/prompts';
|
|
19
20
|
import 'dotenv';
|
|
20
21
|
import 'mlly';
|
package/dist/cli/prepare.mjs
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
import { defineCommand, runCommand } from 'citty';
|
|
2
|
-
import consola$1, { consola } from 'consola';
|
|
3
2
|
import { join, resolve, relative, dirname, basename, extname, isAbsolute } from 'pathe';
|
|
4
3
|
import { peerDependencies, version } from 'silgi/meta';
|
|
5
4
|
import { writeFile, relativeWithDot, hash, resolveAlias, directoryToURL, addTemplate, parseServices, normalizeTemplate, useLogger, initRuntimeConfig, hasError as hasError$1, resolveSilgiPath, isDirectory } from 'silgi/kit';
|
|
6
5
|
import { existsSync, promises, readFileSync, writeFileSync, mkdirSync } from 'node:fs';
|
|
7
6
|
import { readdir, readFile } from 'node:fs/promises';
|
|
7
|
+
import consola$1, { consola } from 'consola';
|
|
8
8
|
import { createHooks, createDebugger } from 'hookable';
|
|
9
9
|
import { useSilgiCLI, silgiCLICtx } from 'silgi/core';
|
|
10
10
|
import { runtimeDir } from 'silgi/runtime/meta';
|
|
11
11
|
import { autoImportTypes } from 'silgi/types';
|
|
12
12
|
import { scanExports, createUnimport, toExports } from 'unimport';
|
|
13
|
-
import { c as createRouteRules } from '../_chunks/
|
|
13
|
+
import { c as createRouteRules, s as silgiCLIIClose } from '../_chunks/silgiApp.mjs';
|
|
14
14
|
import * as p from '@clack/prompts';
|
|
15
15
|
import * as dotenv from 'dotenv';
|
|
16
16
|
import { resolveModuleExportNames, findTypeExports, findExports, resolvePath, parseNodeModulePath, lookupNodeModuleSubpath } from 'mlly';
|
|
@@ -1290,11 +1290,10 @@ class SchemaParser {
|
|
|
1290
1290
|
}
|
|
1291
1291
|
|
|
1292
1292
|
async function scanFiles$1(silgi, watchFiles) {
|
|
1293
|
-
const isWatch = watchFiles && watchFiles.length > 0;
|
|
1294
1293
|
const filePaths = /* @__PURE__ */ new Set();
|
|
1295
1294
|
const scannedPaths = [];
|
|
1296
1295
|
const dir = silgi.options.serverDir;
|
|
1297
|
-
const files =
|
|
1296
|
+
const files = (await globby(dir, { cwd: silgi.options.rootDir, ignore: silgi.options.ignore })).sort();
|
|
1298
1297
|
if (files.length) {
|
|
1299
1298
|
const siblings = await readdir(dirname(dir)).catch(() => []);
|
|
1300
1299
|
const directory = basename(dir);
|
|
@@ -2475,16 +2474,7 @@ const run = defineCommand({
|
|
|
2475
2474
|
consola.error("Silgi not found");
|
|
2476
2475
|
return;
|
|
2477
2476
|
}
|
|
2478
|
-
const silgi =
|
|
2479
|
-
if (silgi) {
|
|
2480
|
-
if (silgiCLICtx.tryUse()) {
|
|
2481
|
-
silgiCLICtx.unset();
|
|
2482
|
-
silgiCLICtx.set(silgi);
|
|
2483
|
-
} else {
|
|
2484
|
-
silgiCLICtx.set(silgi);
|
|
2485
|
-
silgi.hook("close", () => silgiCLICtx.unset());
|
|
2486
|
-
}
|
|
2487
|
-
}
|
|
2477
|
+
const silgi = useSilgiCLI();
|
|
2488
2478
|
const tags = args.tag?.split(",").map((t) => t.trim());
|
|
2489
2479
|
p.intro(color.bold(`Silgi CLI ${color.green(`v${version}`)}`));
|
|
2490
2480
|
const silgiConfig = await loadOptions({});
|
|
@@ -2599,18 +2589,6 @@ const run = defineCommand({
|
|
|
2599
2589
|
});
|
|
2600
2590
|
let cleanHandler = cmd.handler.handler.replace(/\n/g, "");
|
|
2601
2591
|
cleanHandler = `import { silgiCLICtx } from 'silgi/core'
|
|
2602
|
-
|
|
2603
|
-
// Access from global scope
|
|
2604
|
-
const silgiObj = globalThis.__silgi_temp_obj;
|
|
2605
|
-
if (silgiCLICtx.tryUse()) {
|
|
2606
|
-
silgiCLICtx.unset()
|
|
2607
|
-
silgiCLICtx.set(silgiObj)
|
|
2608
|
-
}
|
|
2609
|
-
else {
|
|
2610
|
-
silgiCLICtx.set(silgiObj)
|
|
2611
|
-
// Use the silgiObj directly
|
|
2612
|
-
silgiObj.hook && silgiObj.hook('close', () => silgiCLICtx.unset())
|
|
2613
|
-
}
|
|
2614
2592
|
${cleanHandler}
|
|
2615
2593
|
`;
|
|
2616
2594
|
await jiti.evalModule(cleanHandler, {
|
|
@@ -2621,6 +2599,7 @@ const run = defineCommand({
|
|
|
2621
2599
|
});
|
|
2622
2600
|
}
|
|
2623
2601
|
}
|
|
2602
|
+
await silgiCLIIClose();
|
|
2624
2603
|
}
|
|
2625
2604
|
});
|
|
2626
2605
|
|
|
@@ -2669,14 +2648,6 @@ const prepare = defineCommand({
|
|
|
2669
2648
|
await writeCoreFile(silgi);
|
|
2670
2649
|
await prepareBuild(silgi);
|
|
2671
2650
|
if (!args.commands) {
|
|
2672
|
-
const close = async () => {
|
|
2673
|
-
await silgi.close();
|
|
2674
|
-
await silgi.callHook("close", silgi);
|
|
2675
|
-
consola$1.withTag("silgi").success("Process terminated");
|
|
2676
|
-
};
|
|
2677
|
-
await silgi.callHook("close", silgi);
|
|
2678
|
-
consola$1.withTag("silgi").success("Prepare completed");
|
|
2679
|
-
await close();
|
|
2680
2651
|
await runCommand(run, {
|
|
2681
2652
|
rawArgs: ["--tag", "init", "--active", "false"]
|
|
2682
2653
|
});
|
|
@@ -2692,4 +2663,4 @@ const prepare$1 = {
|
|
|
2692
2663
|
default: prepare
|
|
2693
2664
|
};
|
|
2694
2665
|
|
|
2695
|
-
export { prepare$1 as a, commonArgs as c,
|
|
2666
|
+
export { prepare$1 as a, commonArgs as c, prepare as p, run$1 as r };
|
package/dist/core/index.mjs
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { createConsola } from 'consola';
|
|
2
2
|
import defu, { defu as defu$1 } from 'defu';
|
|
3
3
|
import { createHooks } from 'hookable';
|
|
4
|
-
import { c as createRouteRules } from '../_chunks/
|
|
5
|
-
|
|
4
|
+
import { c as createRouteRules } from '../_chunks/silgiApp.mjs';
|
|
5
|
+
export { a as silgiCLICtx, t as tryUseSilgiCLI, u as useSilgiCLI } from '../_chunks/silgiApp.mjs';
|
|
6
|
+
import { getContext } from 'unctx';
|
|
6
7
|
import { Buffer } from 'node:buffer';
|
|
7
8
|
import { klona } from 'klona';
|
|
8
9
|
import { createStorage as createStorage$1, builtinDrivers, prefixStorage } from 'unstorage';
|
|
@@ -716,18 +717,6 @@ function createShared(shared) {
|
|
|
716
717
|
return shared;
|
|
717
718
|
}
|
|
718
719
|
|
|
719
|
-
const silgiCLICtx = createContext();
|
|
720
|
-
function useSilgiCLI() {
|
|
721
|
-
const instance = silgiCLICtx.tryUse();
|
|
722
|
-
if (!instance) {
|
|
723
|
-
throw new Error("Silgi instance is unavailable!");
|
|
724
|
-
}
|
|
725
|
-
return instance;
|
|
726
|
-
}
|
|
727
|
-
function tryUseSilgiCLI() {
|
|
728
|
-
return silgiCLICtx.tryUse();
|
|
729
|
-
}
|
|
730
|
-
|
|
731
720
|
function storageMount(silgi) {
|
|
732
721
|
const _silgi = silgi || useSilgi();
|
|
733
722
|
return (base, driver) => {
|
|
@@ -740,4 +729,4 @@ function storageMount(silgi) {
|
|
|
740
729
|
};
|
|
741
730
|
}
|
|
742
731
|
|
|
743
|
-
export { ErrorCategory, ErrorFactory, ErrorSeverity, HttpStatus, SilgiError, createSchema, createService, createShared, createSilgi, createStorage, getEvent, getEventContext, isBaseError, mergeSchemas, mergeServices, mergeShared, parseURI, silgi,
|
|
732
|
+
export { ErrorCategory, ErrorFactory, ErrorSeverity, HttpStatus, SilgiError, createSchema, createService, createShared, createSilgi, createStorage, getEvent, getEventContext, isBaseError, mergeSchemas, mergeServices, mergeShared, parseURI, silgi, silgiCtx, storageMount, tryUseSilgi, useSilgi, useSilgiStorage };
|
package/dist/meta/index.d.mts
CHANGED
package/dist/meta/index.d.ts
CHANGED