silgi 0.26.13 → 0.27.1
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/cli/dev.mjs +3 -3
- package/dist/cli/index.mjs +2 -2
- package/dist/cli/init.mjs +4 -4
- package/dist/cli/install.mjs +4 -4
- package/dist/cli/prepare.mjs +14 -14
- package/dist/cli/writeTypesAndFiles.mjs +15 -10
- package/dist/core/index.d.mts +3 -3
- package/dist/core/index.mjs +4 -4
- package/dist/kit/index.d.mts +4 -5
- package/dist/presets/_all.gen.d.mts +3 -2
- package/dist/presets/_all.gen.mjs +6 -5
- package/dist/presets/_resolve.mjs +17 -4
- package/dist/presets/h3/preset.d.mts +3 -2
- package/dist/presets/h3/preset.mjs +2 -1
- package/dist/presets/index.d.mts +2 -2
- package/dist/presets/index.mjs +1 -1
- package/dist/presets/nitro/preset.d.mts +3 -2
- package/dist/presets/nitro/preset.mjs +2 -1
- package/dist/presets/npmpackage/preset.d.mts +3 -2
- package/dist/presets/npmpackage/preset.mjs +2 -1
- package/dist/presets/nuxt/preset.d.mts +3 -2
- package/dist/presets/nuxt/preset.mjs +2 -1
- package/dist/runtime/index.d.mts +3 -3
- package/dist/runtime/index.mjs +3 -3
- package/dist/runtime/internal/config.mjs +1 -1
- package/dist/runtime/internal/debug.d.mts +1 -0
- package/dist/runtime/internal/debug.mjs +1 -1
- package/dist/runtime/internal/index.d.mts +6 -6
- package/dist/runtime/internal/index.mjs +6 -6
- package/dist/types/index.d.mts +5 -1
- package/lib/meta.d.mts +3 -3
- package/package.json +2 -1
package/dist/cli/dev.mjs
CHANGED
|
@@ -6,7 +6,7 @@ import { join } from 'pathe';
|
|
|
6
6
|
import { useSilgiCLI } from 'silgi';
|
|
7
7
|
import { version } from 'silgi/meta';
|
|
8
8
|
import { a as silgiCLIIClose } from '../_chunks/silgiApp.mjs';
|
|
9
|
-
import {
|
|
9
|
+
import { a as commonArgs, c as command } from './prepare.mjs';
|
|
10
10
|
import 'unctx';
|
|
11
11
|
import './writeTypesAndFiles.mjs';
|
|
12
12
|
import 'knitwork';
|
|
@@ -71,7 +71,7 @@ const dev = defineCommand({
|
|
|
71
71
|
}
|
|
72
72
|
},
|
|
73
73
|
async run() {
|
|
74
|
-
await runCommand(
|
|
74
|
+
await runCommand(command, {
|
|
75
75
|
rawArgs: ["--commands", "run", "--dev", "true"]
|
|
76
76
|
});
|
|
77
77
|
const silgi = useSilgiCLI();
|
|
@@ -104,7 +104,7 @@ const dev = defineCommand({
|
|
|
104
104
|
silgi.errors = [];
|
|
105
105
|
try {
|
|
106
106
|
await reloadScan(path, stats);
|
|
107
|
-
await runCommand(
|
|
107
|
+
await runCommand(command, {
|
|
108
108
|
rawArgs: ["--commands", "run", "--dev", "true"]
|
|
109
109
|
});
|
|
110
110
|
} catch (error) {
|
package/dist/cli/index.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { defineCommand, runMain } from 'citty';
|
|
3
3
|
|
|
4
|
-
const version = "0.
|
|
4
|
+
const version = "0.27.1";
|
|
5
5
|
const packageJson = {
|
|
6
6
|
version: version};
|
|
7
7
|
|
|
@@ -18,7 +18,7 @@ const main = defineCommand({
|
|
|
18
18
|
}
|
|
19
19
|
},
|
|
20
20
|
subCommands: {
|
|
21
|
-
prepare: () => import('./prepare.mjs').then(function (n) { return n.
|
|
21
|
+
prepare: () => import('./prepare.mjs').then(function (n) { return n.p; }).then((m) => m.default),
|
|
22
22
|
init: () => import('./init.mjs').then((m) => m.default),
|
|
23
23
|
run: () => import('./prepare.mjs').then(function (n) { return n.r; }).then((m) => m.default),
|
|
24
24
|
install: () => import('./install.mjs').then((m) => m.default),
|
package/dist/cli/init.mjs
CHANGED
|
@@ -4,7 +4,7 @@ import * as p from '@clack/prompts';
|
|
|
4
4
|
import { defineCommand, runCommand } from 'citty';
|
|
5
5
|
import consola from 'consola';
|
|
6
6
|
import { dirname } from 'pathe';
|
|
7
|
-
import {
|
|
7
|
+
import { c as command$1 } from './prepare.mjs';
|
|
8
8
|
import 'silgi/meta';
|
|
9
9
|
import './writeTypesAndFiles.mjs';
|
|
10
10
|
import 'knitwork';
|
|
@@ -46,7 +46,7 @@ import 'picocolors';
|
|
|
46
46
|
import '../_chunks/silgiApp.mjs';
|
|
47
47
|
import 'unctx';
|
|
48
48
|
|
|
49
|
-
const
|
|
49
|
+
const command = defineCommand({
|
|
50
50
|
meta: {
|
|
51
51
|
name: "Silgi Init",
|
|
52
52
|
description: "Initialize silgi config",
|
|
@@ -101,7 +101,7 @@ const init = defineCommand({
|
|
|
101
101
|
await fsp.mkdir(dirname(file), { recursive: true });
|
|
102
102
|
writeFileSync(file, plugin.join("\n"));
|
|
103
103
|
consola.success("Silgi plugin created, see server/plugins/silgi.ts");
|
|
104
|
-
runCommand(
|
|
104
|
+
runCommand(command$1, {
|
|
105
105
|
rawArgs: ["--env", ".env"]
|
|
106
106
|
});
|
|
107
107
|
}
|
|
@@ -110,4 +110,4 @@ const init = defineCommand({
|
|
|
110
110
|
}
|
|
111
111
|
});
|
|
112
112
|
|
|
113
|
-
export {
|
|
113
|
+
export { command as default };
|
package/dist/cli/install.mjs
CHANGED
|
@@ -4,7 +4,7 @@ import { defineCommand, runCommand } from 'citty';
|
|
|
4
4
|
import { consola } from 'consola';
|
|
5
5
|
import { resolve } from 'pathe';
|
|
6
6
|
import { version } from 'silgi/meta';
|
|
7
|
-
import {
|
|
7
|
+
import { a as commonArgs, c as command$1 } from './prepare.mjs';
|
|
8
8
|
import { l as loadOptions } from './types.mjs';
|
|
9
9
|
import './writeTypesAndFiles.mjs';
|
|
10
10
|
import 'knitwork';
|
|
@@ -46,7 +46,7 @@ import 'consola/utils';
|
|
|
46
46
|
import 'escape-string-regexp';
|
|
47
47
|
import 'pkg-types';
|
|
48
48
|
|
|
49
|
-
const
|
|
49
|
+
const command = defineCommand({
|
|
50
50
|
meta: {
|
|
51
51
|
name: "install",
|
|
52
52
|
description: "Install dependencies from the install.json file.",
|
|
@@ -60,7 +60,7 @@ const install = defineCommand({
|
|
|
60
60
|
}
|
|
61
61
|
},
|
|
62
62
|
async run() {
|
|
63
|
-
await runCommand(
|
|
63
|
+
await runCommand(command$1, {
|
|
64
64
|
rawArgs: []
|
|
65
65
|
}).catch(() => {
|
|
66
66
|
});
|
|
@@ -92,4 +92,4 @@ const install = defineCommand({
|
|
|
92
92
|
}
|
|
93
93
|
});
|
|
94
94
|
|
|
95
|
-
export {
|
|
95
|
+
export { command as default };
|
package/dist/cli/prepare.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { defineCommand, runCommand } from 'citty';
|
|
2
2
|
import { resolve } from 'pathe';
|
|
3
3
|
import { version } from 'silgi/meta';
|
|
4
|
-
import { d as prepareEnv, c as createSilgiCLI, a as prepare$
|
|
4
|
+
import { d as prepareEnv, c as createSilgiCLI, a as prepare$1, g as generateApiFul, b as writeTypesAndFiles, w as writeCoreFile, p as prepareBuild, e as generateApp } from './writeTypesAndFiles.mjs';
|
|
5
5
|
import { execSync } from 'node:child_process';
|
|
6
6
|
import { readFileSync } from 'node:fs';
|
|
7
7
|
import * as p from '@clack/prompts';
|
|
@@ -24,7 +24,7 @@ const commonArgs = {
|
|
|
24
24
|
}
|
|
25
25
|
};
|
|
26
26
|
|
|
27
|
-
const
|
|
27
|
+
const command$1 = defineCommand({
|
|
28
28
|
meta: {
|
|
29
29
|
name: "run",
|
|
30
30
|
description: "Run a command from the CLI",
|
|
@@ -46,7 +46,7 @@ const run = defineCommand({
|
|
|
46
46
|
}
|
|
47
47
|
},
|
|
48
48
|
async run({ args }) {
|
|
49
|
-
const data = args.active ? await runCommand(
|
|
49
|
+
const data = args.active ? await runCommand(command, {
|
|
50
50
|
rawArgs: ["--commands", "run"]
|
|
51
51
|
}) : void 0;
|
|
52
52
|
globalThis.__nitro__ = globalThis.__nitro__ || {};
|
|
@@ -93,9 +93,9 @@ const run = defineCommand({
|
|
|
93
93
|
return;
|
|
94
94
|
}
|
|
95
95
|
const allTags = Object.values(silgi.commands).reduce((acc, commandGroup) => {
|
|
96
|
-
Object.values(commandGroup).forEach((
|
|
97
|
-
if (
|
|
98
|
-
|
|
96
|
+
Object.values(commandGroup).forEach((command2) => {
|
|
97
|
+
if (command2.tags) {
|
|
98
|
+
command2.tags.forEach((tag) => acc.add(tag));
|
|
99
99
|
}
|
|
100
100
|
});
|
|
101
101
|
return acc;
|
|
@@ -186,12 +186,12 @@ const run = defineCommand({
|
|
|
186
186
|
}
|
|
187
187
|
});
|
|
188
188
|
|
|
189
|
-
const run
|
|
189
|
+
const run = {
|
|
190
190
|
__proto__: null,
|
|
191
|
-
default:
|
|
191
|
+
default: command$1
|
|
192
192
|
};
|
|
193
193
|
|
|
194
|
-
const
|
|
194
|
+
const command = defineCommand({
|
|
195
195
|
meta: {
|
|
196
196
|
name: "prepare",
|
|
197
197
|
description: "Generate types for the project",
|
|
@@ -230,14 +230,14 @@ const prepare = defineCommand({
|
|
|
230
230
|
commandType: "prepare",
|
|
231
231
|
activeEnvironment: args.env
|
|
232
232
|
});
|
|
233
|
-
await prepare$
|
|
233
|
+
await prepare$1();
|
|
234
234
|
await generateApiFul(silgi);
|
|
235
235
|
await writeTypesAndFiles(silgi);
|
|
236
236
|
await writeCoreFile(silgi);
|
|
237
237
|
await prepareBuild(silgi);
|
|
238
238
|
await generateApp(silgi);
|
|
239
239
|
if (!args.commands) {
|
|
240
|
-
await runCommand(
|
|
240
|
+
await runCommand(command$1, {
|
|
241
241
|
rawArgs: ["--tag", "init", "--active", "false"]
|
|
242
242
|
});
|
|
243
243
|
}
|
|
@@ -247,9 +247,9 @@ const prepare = defineCommand({
|
|
|
247
247
|
}
|
|
248
248
|
});
|
|
249
249
|
|
|
250
|
-
const prepare
|
|
250
|
+
const prepare = {
|
|
251
251
|
__proto__: null,
|
|
252
|
-
default:
|
|
252
|
+
default: command
|
|
253
253
|
};
|
|
254
254
|
|
|
255
|
-
export {
|
|
255
|
+
export { commonArgs as a, command as c, prepare as p, run as r };
|
|
@@ -16,7 +16,7 @@ import { resolveModuleExportNames, findTypeExports, findExports, resolvePath, pa
|
|
|
16
16
|
import { createJiti } from 'dev-jiti';
|
|
17
17
|
import { h as hasInstalledModule } from './compatibility.mjs';
|
|
18
18
|
import { fileURLToPath } from 'node:url';
|
|
19
|
-
import
|
|
19
|
+
import { defu } from 'defu';
|
|
20
20
|
import { resolveModuleURL } from 'exsolve';
|
|
21
21
|
import { isRelative, withTrailingSlash } from 'ufo';
|
|
22
22
|
import { generateTypes, resolveSchema } from 'untyped';
|
|
@@ -360,7 +360,12 @@ async function nuxtFramework(silgi, skip = false) {
|
|
|
360
360
|
await nitroFramework(silgi, true);
|
|
361
361
|
}
|
|
362
362
|
|
|
363
|
-
const frameworkSetup = [
|
|
363
|
+
const frameworkSetup = [
|
|
364
|
+
emptyFramework,
|
|
365
|
+
h3Framework,
|
|
366
|
+
nitroFramework,
|
|
367
|
+
nuxtFramework
|
|
368
|
+
];
|
|
364
369
|
|
|
365
370
|
async function registerModuleExportScan(silgi) {
|
|
366
371
|
silgi.hook("prepare:schema.ts", async (options) => {
|
|
@@ -1179,7 +1184,7 @@ function buildUriMap(silgi, currentPath = []) {
|
|
|
1179
1184
|
}
|
|
1180
1185
|
}
|
|
1181
1186
|
traverse(silgi.schemas, currentPath);
|
|
1182
|
-
silgi.uris = defu
|
|
1187
|
+
silgi.uris = defu(silgi.uris, Object.fromEntries(uriMap));
|
|
1183
1188
|
return uriMap;
|
|
1184
1189
|
}
|
|
1185
1190
|
|
|
@@ -1216,11 +1221,11 @@ ${injectedResult.code}`;
|
|
|
1216
1221
|
return (await silgi.unimport.injectImports(data, name)).code;
|
|
1217
1222
|
}
|
|
1218
1223
|
);
|
|
1219
|
-
silgi.uris = defu
|
|
1220
|
-
silgi.schemas = defu
|
|
1221
|
-
silgi.services = defu
|
|
1222
|
-
silgi.shareds = defu
|
|
1223
|
-
silgi.modulesURIs = defu
|
|
1224
|
+
silgi.uris = defu(silgi.uris, scanFile.uris) || {};
|
|
1225
|
+
silgi.schemas = defu(scanFile.schemas, scanFile.uris) || {};
|
|
1226
|
+
silgi.services = defu(scanFile.services, scanFile.uris) || {};
|
|
1227
|
+
silgi.shareds = defu(scanFile.shareds, scanFile.shareds) || {};
|
|
1228
|
+
silgi.modulesURIs = defu(scanFile.modulesURIs, scanFile.modulesURIs) || {};
|
|
1224
1229
|
return {
|
|
1225
1230
|
context,
|
|
1226
1231
|
object: {
|
|
@@ -1297,10 +1302,10 @@ async function prepareServerFiles(silgi) {
|
|
|
1297
1302
|
importItems
|
|
1298
1303
|
};
|
|
1299
1304
|
if (silgi.uris) {
|
|
1300
|
-
defu
|
|
1305
|
+
defu(scanned.uris, silgi.uris);
|
|
1301
1306
|
}
|
|
1302
1307
|
if (silgi.modulesURIs) {
|
|
1303
|
-
defu
|
|
1308
|
+
defu(scanned.modulesURIs, silgi.modulesURIs);
|
|
1304
1309
|
}
|
|
1305
1310
|
await silgi.callHook("prepare:scan.ts", scanned);
|
|
1306
1311
|
if (importItems["#silgi/vfs"].import.length === 0) {
|
package/dist/core/index.d.mts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { SilgiConfig, Silgi, SilgiEvents, SilgiFunction, SilgiOperation, MergedSilgiSchema, ServiceType, SilgiSchema, RequiredServiceType, SilgiRuntimeSharedsExtend, SilgiRuntimeContext, DefaultNamespaces, BaseSchemaType, SilgiRuntimeShareds, StorageConfig, SilgiCLI, SilgiStorageBase } from 'silgi/types';
|
|
2
2
|
import { StandardSchemaV1 } from '@standard-schema/spec';
|
|
3
3
|
import { Storage, StorageValue } from 'unstorage';
|
|
4
|
-
import
|
|
4
|
+
import { UseContext } from 'unctx';
|
|
5
5
|
|
|
6
6
|
declare function createSilgi(config: SilgiConfig): Promise<Silgi>;
|
|
7
7
|
|
|
@@ -231,7 +231,7 @@ declare class SilgiError extends Error implements BaseError {
|
|
|
231
231
|
}
|
|
232
232
|
declare function isBaseError(error: unknown): error is BaseError;
|
|
233
233
|
|
|
234
|
-
declare const silgiCtx:
|
|
234
|
+
declare const silgiCtx: UseContext<Silgi>;
|
|
235
235
|
declare function useSilgi(): Silgi;
|
|
236
236
|
/**
|
|
237
237
|
* Get access to Nuxt instance.
|
|
@@ -247,7 +247,7 @@ declare function useSilgi(): Silgi;
|
|
|
247
247
|
*/
|
|
248
248
|
declare function tryUseSilgi(): Silgi | null;
|
|
249
249
|
|
|
250
|
-
declare const silgiCLICtx:
|
|
250
|
+
declare const silgiCLICtx: UseContext<SilgiCLI>;
|
|
251
251
|
declare function useSilgiCLI(): SilgiCLI;
|
|
252
252
|
declare function tryUseSilgiCLI(): SilgiCLI | null;
|
|
253
253
|
|
package/dist/core/index.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { createConsola } from 'consola';
|
|
2
|
-
import
|
|
2
|
+
import { defu } from 'defu';
|
|
3
3
|
import { createHooks } from 'hookable';
|
|
4
4
|
import { c as createRouteRules } from '../_chunks/routeRules.mjs';
|
|
5
5
|
import { getContext } from 'unctx';
|
|
@@ -615,13 +615,13 @@ async function execute(uriString, input, event, source, queryParams) {
|
|
|
615
615
|
success = cacheData.success;
|
|
616
616
|
cached = cacheData.cached;
|
|
617
617
|
} else {
|
|
618
|
-
let parameters = defu
|
|
618
|
+
let parameters = defu(operation.routerParams, operation.query) || {};
|
|
619
619
|
if (queryParams) {
|
|
620
|
-
parameters = defu
|
|
620
|
+
parameters = defu(queryParams, parameters);
|
|
621
621
|
}
|
|
622
622
|
silgiCtx.shared.silgi = silgi(event);
|
|
623
623
|
result = await handler?.handler(
|
|
624
|
-
defu
|
|
624
|
+
defu(input, { parameters }),
|
|
625
625
|
silgiCtx.shared,
|
|
626
626
|
event,
|
|
627
627
|
source
|
package/dist/kit/index.d.mts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { SilgiCLI, ModuleOptionsCustom, ModuleDefinition, SilgiModule, ServiceParseModule, SilgiPreset, SilgiPresetMeta, SilgiTemplate, ResolvedSilgiTemplate, SilgiEvents } from 'silgi/types';
|
|
2
2
|
import { Buffer } from 'node:buffer';
|
|
3
|
-
import
|
|
4
|
-
import { ConsolaOptions } from 'consola';
|
|
3
|
+
import { ConsolaOptions, ConsolaInstance } from 'consola';
|
|
5
4
|
import { IncomingMessage, ServerResponse } from 'node:http';
|
|
6
5
|
|
|
7
6
|
declare function hasError(type: SilgiCLI['errors'][0]['type'], silgi?: SilgiCLI): boolean;
|
|
@@ -52,7 +51,7 @@ declare function isNuxt(): boolean;
|
|
|
52
51
|
declare function isNitro(): boolean;
|
|
53
52
|
declare function isH3(): boolean;
|
|
54
53
|
|
|
55
|
-
declare function useLogger(tag?: string, options?: Partial<ConsolaOptions>):
|
|
54
|
+
declare function useLogger(tag?: string, options?: Partial<ConsolaOptions>): ConsolaInstance;
|
|
56
55
|
|
|
57
56
|
/**
|
|
58
57
|
* Define a Silgi module, automatically merging defaults with user provided options, installing
|
|
@@ -143,8 +142,8 @@ declare function normalizeTemplate<T>(template: SilgiTemplate<T> | string, build
|
|
|
143
142
|
declare function useRequest<T extends IncomingMessage>(event: SilgiEvents): T | (IncomingMessage & {
|
|
144
143
|
originalUrl?: string;
|
|
145
144
|
});
|
|
146
|
-
declare function useResponse<T extends ServerResponse>(event: SilgiEvents): ServerResponse
|
|
147
|
-
declare function getIpAddress(event: SilgiEvents): string |
|
|
145
|
+
declare function useResponse<T extends ServerResponse>(event: SilgiEvents): ServerResponse;
|
|
146
|
+
declare function getIpAddress(event: SilgiEvents): string | boolean;
|
|
148
147
|
/**
|
|
149
148
|
* Extract the client's IP address from request headers with high accuracy
|
|
150
149
|
* @param req - The incoming HTTP request
|
|
@@ -1,2 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import type { SilgiPreset } from "silgi/types";
|
|
2
|
+
declare const presets: readonly SilgiPreset[];
|
|
3
|
+
export default presets;
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
import _h3
|
|
2
|
-
import _nitro
|
|
3
|
-
import _npmpackage
|
|
4
|
-
import _nuxt
|
|
5
|
-
|
|
1
|
+
import _h3 from "./h3/preset.mjs";
|
|
2
|
+
import _nitro from "./nitro/preset.mjs";
|
|
3
|
+
import _npmpackage from "./npmpackage/preset.mjs";
|
|
4
|
+
import _nuxt from "./nuxt/preset.mjs";
|
|
5
|
+
const presets = [
|
|
6
6
|
..._h3,
|
|
7
7
|
..._nitro,
|
|
8
8
|
..._npmpackage,
|
|
9
9
|
..._nuxt
|
|
10
10
|
];
|
|
11
|
+
export default presets;
|
|
@@ -4,16 +4,21 @@ import {
|
|
|
4
4
|
} from "compatx";
|
|
5
5
|
import { kebabCase } from "scule";
|
|
6
6
|
import { provider } from "std-env";
|
|
7
|
-
import allPresets
|
|
7
|
+
import allPresets from "./_all.gen.mjs";
|
|
8
8
|
const _stdProviderMap = {
|
|
9
9
|
aws_amplify: "aws",
|
|
10
10
|
azure_static: "azure",
|
|
11
11
|
cloudflare_pages: "cloudflare"
|
|
12
12
|
};
|
|
13
|
+
function hasMetaProperty(preset) {
|
|
14
|
+
return typeof preset !== "function" && preset._meta !== void 0;
|
|
15
|
+
}
|
|
13
16
|
export async function resolvePreset(name, opts) {
|
|
14
17
|
const _name = kebabCase(name) || provider;
|
|
15
18
|
const _compatDates = opts.compatibilityDate ? resolveCompatibilityDatesFromEnv(opts.compatibilityDate) : false;
|
|
16
19
|
const matches = allPresets.filter((preset2) => {
|
|
20
|
+
if (!hasMetaProperty(preset2))
|
|
21
|
+
return false;
|
|
17
22
|
const names = [preset2._meta.name, preset2._meta.stdName, ...preset2._meta.aliases || []].filter(Boolean);
|
|
18
23
|
if (!names.includes(_name)) {
|
|
19
24
|
return false;
|
|
@@ -26,12 +31,14 @@ export async function resolvePreset(name, opts) {
|
|
|
26
31
|
}
|
|
27
32
|
return true;
|
|
28
33
|
}).sort((a, b) => {
|
|
34
|
+
if (!hasMetaProperty(a) || !hasMetaProperty(b))
|
|
35
|
+
return 0;
|
|
29
36
|
const aDate = new Date(a._meta.compatibilityDate || 0);
|
|
30
37
|
const bDate = new Date(b._meta.compatibilityDate || 0);
|
|
31
38
|
return bDate > aDate ? 1 : -1;
|
|
32
39
|
});
|
|
33
40
|
const preset = matches.find(
|
|
34
|
-
(p) => (p._meta.static || false) === (opts?.static || false)
|
|
41
|
+
(p) => hasMetaProperty(p) && (p._meta.static || false) === (opts?.static || false)
|
|
35
42
|
) || matches[0];
|
|
36
43
|
if (typeof preset === "function") {
|
|
37
44
|
return preset();
|
|
@@ -40,14 +47,20 @@ export async function resolvePreset(name, opts) {
|
|
|
40
47
|
return opts?.static ? resolvePreset("static", opts) : resolvePreset("node-server", opts);
|
|
41
48
|
}
|
|
42
49
|
if (name && !preset) {
|
|
43
|
-
const options = allPresets.filter((p) => p._meta.name === name || p._meta.stdName === name || p._meta.aliases?.includes(name)).sort((a, b) =>
|
|
50
|
+
const options = allPresets.filter((p) => hasMetaProperty(p) && (p._meta.name === name || p._meta.stdName === name || p._meta.aliases?.includes(name))).sort((a, b) => {
|
|
51
|
+
if (!hasMetaProperty(a) || !hasMetaProperty(b))
|
|
52
|
+
return 0;
|
|
53
|
+
return (a._meta.compatibilityDate || 0) > (b._meta.compatibilityDate || 0) ? 1 : -1;
|
|
54
|
+
});
|
|
44
55
|
if (options.length > 0) {
|
|
45
56
|
let msg = `Preset "${name}" cannot be resolved with current compatibilityDate: ${formatCompatibilityDate(_compatDates || "")}.
|
|
46
57
|
|
|
47
58
|
`;
|
|
48
59
|
for (const option of options) {
|
|
49
|
-
|
|
60
|
+
if (hasMetaProperty(option)) {
|
|
61
|
+
msg += `
|
|
50
62
|
- ${option._meta.name} (requires compatibilityDate >= ${option._meta.compatibilityDate})`;
|
|
63
|
+
}
|
|
51
64
|
}
|
|
52
65
|
const err = new Error(msg);
|
|
53
66
|
Error.captureStackTrace?.(err, resolvePreset);
|
|
@@ -1,2 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import type { SilgiPreset } from 'silgi/types';
|
|
2
|
+
declare const presets: readonly SilgiPreset[];
|
|
3
|
+
export default presets;
|
package/dist/presets/index.d.mts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { resolvePreset }
|
|
2
|
-
export type { PresetName, PresetNameInput, PresetOptions }
|
|
1
|
+
export { resolvePreset } from "./_resolve.mjs";
|
|
2
|
+
export type { PresetName, PresetNameInput, PresetOptions } from "./_types.gen.mjs";
|
package/dist/presets/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { resolvePreset }
|
|
1
|
+
export { resolvePreset } from "./_resolve.mjs";
|
|
@@ -1,2 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import type { SilgiPreset } from 'silgi/types';
|
|
2
|
+
declare const presets: readonly SilgiPreset[];
|
|
3
|
+
export default presets;
|
|
@@ -1,2 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import type { SilgiPreset } from 'silgi/types';
|
|
2
|
+
declare const presets: readonly SilgiPreset[];
|
|
3
|
+
export default presets;
|
|
@@ -1,2 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import type { SilgiPreset } from 'silgi/types';
|
|
2
|
+
declare const presets: readonly SilgiPreset[];
|
|
3
|
+
export default presets;
|
package/dist/runtime/index.d.mts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export { initRuntimeConfig, useSilgiRuntimeConfig }
|
|
2
|
-
export { defineSilgiPlugin }
|
|
3
|
-
export { mergeDeep }
|
|
1
|
+
export { initRuntimeConfig, useSilgiRuntimeConfig } from "./internal/config.mjs";
|
|
2
|
+
export { defineSilgiPlugin } from "./internal/plugin.mjs";
|
|
3
|
+
export { mergeDeep } from "./internal/defu.mjs";
|
package/dist/runtime/index.mjs
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export { initRuntimeConfig, useSilgiRuntimeConfig }
|
|
2
|
-
export { defineSilgiPlugin }
|
|
3
|
-
export { mergeDeep }
|
|
1
|
+
export { initRuntimeConfig, useSilgiRuntimeConfig } from "./internal/config.mjs";
|
|
2
|
+
export { defineSilgiPlugin } from "./internal/plugin.mjs";
|
|
3
|
+
export { mergeDeep } from "./internal/defu.mjs";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
export { debugPlugin, }
|
|
2
|
-
export { mergeDeep, }
|
|
3
|
-
export { addNitroApp, }
|
|
4
|
-
export { useSilgiFetch, }
|
|
5
|
-
export { createSilgiFetch, silgi$fetch, }
|
|
6
|
-
export { defineSilgiPlugin, silgiPlugin, }
|
|
1
|
+
export { debugPlugin, } from "./debug.mjs";
|
|
2
|
+
export { mergeDeep, } from "./defu.mjs";
|
|
3
|
+
export { addNitroApp, } from "./nitro.mjs";
|
|
4
|
+
export { useSilgiFetch, } from "./nuxt.mjs";
|
|
5
|
+
export { createSilgiFetch, silgi$fetch, } from "./ofetch.mjs";
|
|
6
|
+
export { defineSilgiPlugin, silgiPlugin, } from "./plugin.mjs";
|
|
@@ -1,20 +1,20 @@
|
|
|
1
1
|
export {
|
|
2
2
|
debugPlugin
|
|
3
|
-
}
|
|
3
|
+
} from "./debug.mjs";
|
|
4
4
|
export {
|
|
5
5
|
mergeDeep
|
|
6
|
-
}
|
|
6
|
+
} from "./defu.mjs";
|
|
7
7
|
export {
|
|
8
8
|
addNitroApp
|
|
9
|
-
}
|
|
9
|
+
} from "./nitro.mjs";
|
|
10
10
|
export {
|
|
11
11
|
useSilgiFetch
|
|
12
|
-
}
|
|
12
|
+
} from "./nuxt.mjs";
|
|
13
13
|
export {
|
|
14
14
|
createSilgiFetch,
|
|
15
15
|
silgi$fetch
|
|
16
|
-
}
|
|
16
|
+
} from "./ofetch.mjs";
|
|
17
17
|
export {
|
|
18
18
|
defineSilgiPlugin,
|
|
19
19
|
silgiPlugin
|
|
20
|
-
}
|
|
20
|
+
} from "./plugin.mjs";
|
package/dist/types/index.d.mts
CHANGED
|
@@ -557,7 +557,11 @@ declare global {
|
|
|
557
557
|
};
|
|
558
558
|
}
|
|
559
559
|
|
|
560
|
-
type SilgiPreset = SilgiCLIConfig
|
|
560
|
+
type SilgiPreset = (SilgiCLIConfig & {
|
|
561
|
+
_meta?: SilgiPresetMeta;
|
|
562
|
+
}) | (() => SilgiCLIConfig & {
|
|
563
|
+
_meta?: SilgiPresetMeta;
|
|
564
|
+
});
|
|
561
565
|
interface SilgiPresetMeta {
|
|
562
566
|
url: string;
|
|
563
567
|
name: string;
|
package/lib/meta.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
export const version: string
|
|
2
|
-
export const dependencies: string
|
|
3
|
-
export const devDependencies: string
|
|
4
|
-
export const peerDependencies: string
|
|
2
|
+
export const dependencies: Record<string, string>
|
|
3
|
+
export const devDependencies: Record<string, string>
|
|
4
|
+
export const peerDependencies: Record<string, string>
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "silgi",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.27.1",
|
|
5
5
|
"private": false,
|
|
6
6
|
"sideEffects": false,
|
|
7
7
|
"exports": {
|
|
@@ -132,6 +132,7 @@
|
|
|
132
132
|
"build:package": "unbuild",
|
|
133
133
|
"build": "pnpm gen-presets && pnpm install && pnpm build:package",
|
|
134
134
|
"build:prepare": "pnpm build:stub",
|
|
135
|
+
"typecheck": "tsc --noEmit",
|
|
135
136
|
"build:stub": "pnpm gen-presets && unbuild --stub",
|
|
136
137
|
"dev:k6": "k6 run ./__tests__/k6.js",
|
|
137
138
|
"test": "vitest",
|