silgi 0.9.6 → 0.9.7
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/cli/prepare.mjs +14 -1
- package/dist/kit/index.d.mts +8 -1
- package/dist/kit/index.d.ts +8 -1
- package/dist/kit/index.mjs +53 -1
- package/dist/meta/index.d.mts +1 -1
- package/dist/meta/index.d.ts +1 -1
- package/dist/types/index.d.mts +3 -0
- package/dist/types/index.d.ts +3 -0
- package/package.json +2 -1
- package/dist/runtime/nitro/index.d.ts +0 -1
- package/dist/runtime/nitro/index.mjs +0 -1
- package/dist/runtime/nitro/useRuntimeConfig.d.ts +0 -1
- package/dist/runtime/nitro/useRuntimeConfig.mjs +0 -7
package/dist/_chunks/index.mjs
CHANGED
package/dist/cli/prepare.mjs
CHANGED
|
@@ -859,7 +859,20 @@ async function nitroFramework(silgi, skip = false) {
|
|
|
859
859
|
packageImport: "silgi/runtime/internal/nitro",
|
|
860
860
|
path: join(runtimeDir, "internal/nitro")
|
|
861
861
|
});
|
|
862
|
-
silgi.hook("prepare:
|
|
862
|
+
silgi.hook("prepare:createDTSFramework", (data) => {
|
|
863
|
+
data.importItems["silgi/types"] = {
|
|
864
|
+
import: [
|
|
865
|
+
{ name: "NitroRuntimeConfig", type: true }
|
|
866
|
+
],
|
|
867
|
+
from: "nitropack/types"
|
|
868
|
+
};
|
|
869
|
+
data.customContent?.push(
|
|
870
|
+
"",
|
|
871
|
+
'declare module "silgi/types" {',
|
|
872
|
+
" interface SilgiRuntimeOptions extends NitroRuntimeConfig {}",
|
|
873
|
+
"}",
|
|
874
|
+
""
|
|
875
|
+
);
|
|
863
876
|
});
|
|
864
877
|
if (silgi.options.imports !== false) {
|
|
865
878
|
silgi.options.imports.presets ??= [];
|
package/dist/kit/index.d.mts
CHANGED
|
@@ -71,6 +71,13 @@ interface Resolver {
|
|
|
71
71
|
declare function createResolver(base: string | URL): Resolver;
|
|
72
72
|
declare function resolveSilgiModule(base: string, paths: string[]): Promise<string[]>;
|
|
73
73
|
|
|
74
|
+
/**
|
|
75
|
+
* Access 'resolved' Nuxt runtime configuration, with values updated from environment.
|
|
76
|
+
*
|
|
77
|
+
* This mirrors the runtime behavior of Nitro.
|
|
78
|
+
*/
|
|
79
|
+
declare function useSilgiRuntimeConfig(): Record<string, any>;
|
|
80
|
+
|
|
74
81
|
/**
|
|
75
82
|
* Renders given template during build into the virtual file system (and optionally to disk in the project `buildDir`)
|
|
76
83
|
*/
|
|
@@ -100,4 +107,4 @@ declare const MODE_RE: RegExp;
|
|
|
100
107
|
declare function hasSilgiModule(moduleKey: string, silgi?: SilgiCLI): boolean;
|
|
101
108
|
declare function hasInstalledModule(moduleKey: string, silgi?: SilgiCLI): boolean;
|
|
102
109
|
|
|
103
|
-
export { MODE_RE, addTemplate, createResolver, defineSilgiModule, defineSilgiPreset, filterInPlace, hasInstalledModule, hasSilgiModule, isDirectory, isH3, isNitro, isNuxt, normalizeTemplate, prettyPath, relativeWithDot, resolveAlias, resolvePath, resolveSilgiModule, resolveSilgiPath, toArray, tryResolveModule, useLogger, writeFile };
|
|
110
|
+
export { MODE_RE, addTemplate, createResolver, defineSilgiModule, defineSilgiPreset, filterInPlace, hasInstalledModule, hasSilgiModule, isDirectory, isH3, isNitro, isNuxt, normalizeTemplate, prettyPath, relativeWithDot, resolveAlias, resolvePath, resolveSilgiModule, resolveSilgiPath, toArray, tryResolveModule, useLogger, useSilgiRuntimeConfig, writeFile };
|
package/dist/kit/index.d.ts
CHANGED
|
@@ -71,6 +71,13 @@ interface Resolver {
|
|
|
71
71
|
declare function createResolver(base: string | URL): Resolver;
|
|
72
72
|
declare function resolveSilgiModule(base: string, paths: string[]): Promise<string[]>;
|
|
73
73
|
|
|
74
|
+
/**
|
|
75
|
+
* Access 'resolved' Nuxt runtime configuration, with values updated from environment.
|
|
76
|
+
*
|
|
77
|
+
* This mirrors the runtime behavior of Nitro.
|
|
78
|
+
*/
|
|
79
|
+
declare function useSilgiRuntimeConfig(): Record<string, any>;
|
|
80
|
+
|
|
74
81
|
/**
|
|
75
82
|
* Renders given template during build into the virtual file system (and optionally to disk in the project `buildDir`)
|
|
76
83
|
*/
|
|
@@ -100,4 +107,4 @@ declare const MODE_RE: RegExp;
|
|
|
100
107
|
declare function hasSilgiModule(moduleKey: string, silgi?: SilgiCLI): boolean;
|
|
101
108
|
declare function hasInstalledModule(moduleKey: string, silgi?: SilgiCLI): boolean;
|
|
102
109
|
|
|
103
|
-
export { MODE_RE, addTemplate, createResolver, defineSilgiModule, defineSilgiPreset, filterInPlace, hasInstalledModule, hasSilgiModule, isDirectory, isH3, isNitro, isNuxt, normalizeTemplate, prettyPath, relativeWithDot, resolveAlias, resolvePath, resolveSilgiModule, resolveSilgiPath, toArray, tryResolveModule, useLogger, writeFile };
|
|
110
|
+
export { MODE_RE, addTemplate, createResolver, defineSilgiModule, defineSilgiPreset, filterInPlace, hasInstalledModule, hasSilgiModule, isDirectory, isH3, isNitro, isNuxt, normalizeTemplate, prettyPath, relativeWithDot, resolveAlias, resolvePath, resolveSilgiModule, resolveSilgiPath, toArray, tryResolveModule, useLogger, useSilgiRuntimeConfig, writeFile };
|
package/dist/kit/index.mjs
CHANGED
|
@@ -10,6 +10,10 @@ import { c as checkSilgiCompatibility } from '../cli/compatibility.mjs';
|
|
|
10
10
|
import { existsSync, promises } from 'node:fs';
|
|
11
11
|
import { fileURLToPath } from 'node:url';
|
|
12
12
|
import { resolveAlias as resolveAlias$1 } from 'pathe/utils';
|
|
13
|
+
import process$1 from 'node:process';
|
|
14
|
+
import destr from 'destr';
|
|
15
|
+
import { klona } from 'klona';
|
|
16
|
+
import { snakeCase } from 'scule';
|
|
13
17
|
import { hash } from 'ohash';
|
|
14
18
|
import 'semver/functions/satisfies.js';
|
|
15
19
|
import 'silgi/meta';
|
|
@@ -239,6 +243,54 @@ async function resolveSilgiModule(base, paths) {
|
|
|
239
243
|
return resolved;
|
|
240
244
|
}
|
|
241
245
|
|
|
246
|
+
function useSilgiRuntimeConfig() {
|
|
247
|
+
const silgi = useSilgi();
|
|
248
|
+
return applyEnv(klona(silgi.options.runtimeConfig), {
|
|
249
|
+
prefix: "NITRO_",
|
|
250
|
+
altPrefix: "NUXT_",
|
|
251
|
+
silgiPrefix: "SILGI_",
|
|
252
|
+
// TODO: add more prefixes ecosystem-wide
|
|
253
|
+
envExpansion: silgi.options.experimental?.envExpansion ?? !!process$1.env.NITRO_ENV_EXPANSION
|
|
254
|
+
});
|
|
255
|
+
}
|
|
256
|
+
function getEnv(key, opts, env = process$1.env) {
|
|
257
|
+
const envKey = snakeCase(key).toUpperCase();
|
|
258
|
+
return destr(
|
|
259
|
+
env[opts.prefix + envKey] ?? env[opts.altPrefix + envKey] ?? env[opts.silgiPrefix + envKey]
|
|
260
|
+
);
|
|
261
|
+
}
|
|
262
|
+
function _isObject(input) {
|
|
263
|
+
return typeof input === "object" && !Array.isArray(input);
|
|
264
|
+
}
|
|
265
|
+
function applyEnv(obj, opts, parentKey = "") {
|
|
266
|
+
for (const key in obj) {
|
|
267
|
+
const subKey = parentKey ? `${parentKey}_${key}` : key;
|
|
268
|
+
const envValue = getEnv(subKey, opts);
|
|
269
|
+
if (_isObject(obj[key])) {
|
|
270
|
+
if (_isObject(envValue)) {
|
|
271
|
+
obj[key] = { ...obj[key], ...envValue };
|
|
272
|
+
applyEnv(obj[key], opts, subKey);
|
|
273
|
+
} else if (envValue === void 0) {
|
|
274
|
+
applyEnv(obj[key], opts, subKey);
|
|
275
|
+
} else {
|
|
276
|
+
obj[key] = envValue ?? obj[key];
|
|
277
|
+
}
|
|
278
|
+
} else {
|
|
279
|
+
obj[key] = envValue ?? obj[key];
|
|
280
|
+
}
|
|
281
|
+
if (opts.envExpansion && typeof obj[key] === "string") {
|
|
282
|
+
obj[key] = _expandFromEnv(obj[key]);
|
|
283
|
+
}
|
|
284
|
+
}
|
|
285
|
+
return obj;
|
|
286
|
+
}
|
|
287
|
+
const envExpandRx = /\{\{([^{}]*)\}\}/g;
|
|
288
|
+
function _expandFromEnv(value, env = process$1.env) {
|
|
289
|
+
return value.replace(envExpandRx, (match, key) => {
|
|
290
|
+
return env[key] || match;
|
|
291
|
+
});
|
|
292
|
+
}
|
|
293
|
+
|
|
242
294
|
const RELATIVE_RE = /^([^.])/;
|
|
243
295
|
function relativeWithDot(from, to) {
|
|
244
296
|
return relative(from, to).replace(RELATIVE_RE, "./$1") || ".";
|
|
@@ -305,4 +357,4 @@ function normalizeTemplate(template, buildDir) {
|
|
|
305
357
|
return template;
|
|
306
358
|
}
|
|
307
359
|
|
|
308
|
-
export { MODE_RE, addTemplate, createResolver, defineSilgiModule, defineSilgiPreset, filterInPlace, hasInstalledModule, hasSilgiModule, isDirectory$1 as isDirectory, isH3, isNitro, isNuxt, normalizeTemplate, prettyPath, relativeWithDot, resolveAlias, resolvePath, resolveSilgiModule, resolveSilgiPath, toArray, tryResolveModule, useLogger, writeFile };
|
|
360
|
+
export { MODE_RE, addTemplate, createResolver, defineSilgiModule, defineSilgiPreset, filterInPlace, hasInstalledModule, hasSilgiModule, isDirectory$1 as isDirectory, isH3, isNitro, isNuxt, normalizeTemplate, prettyPath, relativeWithDot, resolveAlias, resolvePath, resolveSilgiModule, resolveSilgiPath, toArray, tryResolveModule, useLogger, useSilgiRuntimeConfig, writeFile };
|
package/dist/meta/index.d.mts
CHANGED
package/dist/meta/index.d.ts
CHANGED
package/dist/types/index.d.mts
CHANGED
|
@@ -944,6 +944,9 @@ type CaptureError = (error: Error, context: CapturedErrorContext) => void;
|
|
|
944
944
|
interface SilgiOptions {
|
|
945
945
|
consolaOptions?: Partial<ConsolaOptions>;
|
|
946
946
|
present: PresetNameInput;
|
|
947
|
+
runtimeConfig: SilgiRuntimeOptions & {
|
|
948
|
+
[key: string]: any;
|
|
949
|
+
};
|
|
947
950
|
/**
|
|
948
951
|
* Set to `true` to enable debug mode.
|
|
949
952
|
*
|
package/dist/types/index.d.ts
CHANGED
|
@@ -944,6 +944,9 @@ type CaptureError = (error: Error, context: CapturedErrorContext) => void;
|
|
|
944
944
|
interface SilgiOptions {
|
|
945
945
|
consolaOptions?: Partial<ConsolaOptions>;
|
|
946
946
|
present: PresetNameInput;
|
|
947
|
+
runtimeConfig: SilgiRuntimeOptions & {
|
|
948
|
+
[key: string]: any;
|
|
949
|
+
};
|
|
947
950
|
/**
|
|
948
951
|
* Set to `true` to enable debug mode.
|
|
949
952
|
*
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "silgi",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.9.
|
|
4
|
+
"version": "0.9.7",
|
|
5
5
|
"private": false,
|
|
6
6
|
"sideEffects": false,
|
|
7
7
|
"exports": {
|
|
@@ -120,6 +120,7 @@
|
|
|
120
120
|
"compatx": "^0.1.8",
|
|
121
121
|
"consola": "^3.4.0",
|
|
122
122
|
"defu": "^6.1.4",
|
|
123
|
+
"destr": "^2.0.3",
|
|
123
124
|
"dev-jiti": "^2.4.2",
|
|
124
125
|
"dot-prop": "^9.0.0",
|
|
125
126
|
"dotenv": "^16.4.7",
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { useSilgiNitroRuntimeConfig } from './useRuntimeConfig';
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { useSilgiNitroRuntimeConfig } from "./useRuntimeConfig.mjs";
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare function useSilgiNitroRuntimeConfig(): any;
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { useRuntimeConfig } from "nitropack/runtime/internal/config";
|
|
2
|
-
export function useSilgiNitroRuntimeConfig() {
|
|
3
|
-
if (globalThis.$silgiStatus === "prepare" || globalThis.$silgiStatus === "install" || globalThis.$silgiStatus === "run") {
|
|
4
|
-
return;
|
|
5
|
-
}
|
|
6
|
-
return useRuntimeConfig();
|
|
7
|
-
}
|