silgi 0.9.16 → 0.9.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.
@@ -1,4 +1,4 @@
1
- const version = "0.9.16";
1
+ const version = "0.9.18";
2
2
  const devDependencies = {
3
3
  "@antfu/eslint-config": "^4.3.0",
4
4
  "@nuxt/kit": "^3.15.4",
@@ -146,6 +146,8 @@ async function readCoreFile(silgi) {
146
146
  });
147
147
  try {
148
148
  if (silgi.options.commandType === "prepare") {
149
+ injectedResult.code = `global.$silgiSharedRuntimeConfig = ${JSON.stringify(silgi.options.runtimeConfig)};
150
+ ${injectedResult.code}`;
149
151
  injectedResult.code = injectedResult.code.replace(/runtimeConfig: \{\}/, `runtimeConfig: ${JSON.stringify(silgi.options.runtimeConfig)}`);
150
152
  }
151
153
  const coreFile = await jiti.evalModule(
@@ -625,12 +627,12 @@ async function silgiCoreFile(data, frameworkContext, silgi) {
625
627
  " modulesURIs,",
626
628
  ` plugins: [${plugins.join(", ")}],`,
627
629
  _data._silgiConfigs.length > 0 ? ` ${_data._silgiConfigs.map((config) => typeof config === "string" ? config : typeof config === "object" ? Object.entries(config).map(([key, value]) => `${key}: ${value}`).join(",\n ") : "").join(",\n ")},` : "",
630
+ " runtimeConfig: {},",
628
631
  " ...buildOptions,",
629
632
  " options: mergeDeep(",
630
633
  " moduleOptions || {},",
631
634
  " {",
632
635
  ` present: '${silgi.options.preset}',`,
633
- " runtimeConfig: {},",
634
636
  " ...cliOptions,",
635
637
  " },",
636
638
  " ) as any,",
@@ -503,6 +503,8 @@ async function createSilgi(config) {
503
503
  ready: () => {
504
504
  return hooks.callHook("ready", silgi);
505
505
  },
506
+ envOptions: config.envOptions ?? {},
507
+ runtimeConfig: config.runtimeConfig ?? {},
506
508
  close: () => hooks.callHook("close", silgi),
507
509
  logger: createConsola(defu(config.options?.consolaOptions ?? {}, {
508
510
  tag: "silgi"
@@ -1,6 +1,7 @@
1
1
  import { Buffer } from 'node:buffer';
2
2
  import * as consola from 'consola';
3
3
  import { ConsolaOptions } from 'consola';
4
+ import * as silgi_types from 'silgi/types';
4
5
  import { ModuleOptionsCustom, ModuleDefinition, SilgiModule, SilgiCLI, SilgiPreset, SilgiPresetMeta, EnvOptions, SilgiTemplate, ResolvedSilgiTemplate } from 'silgi/types';
5
6
 
6
7
  /**
@@ -76,7 +77,7 @@ declare function resolveSilgiModule(base: string, paths: string[]): Promise<stri
76
77
  *
77
78
  * This mirrors the runtime behavior of Nitro.
78
79
  */
79
- declare function useSilgiRuntimeConfig(): Record<string, any> | undefined;
80
+ declare function useSilgiRuntimeConfig(): silgi_types.SilgiRuntimeOptions;
80
81
  declare function applyEnv(obj: Record<string, any>, opts: EnvOptions, parentKey?: string): Record<string, any>;
81
82
 
82
83
  /**
@@ -1,6 +1,7 @@
1
1
  import { Buffer } from 'node:buffer';
2
2
  import * as consola from 'consola';
3
3
  import { ConsolaOptions } from 'consola';
4
+ import * as silgi_types from 'silgi/types';
4
5
  import { ModuleOptionsCustom, ModuleDefinition, SilgiModule, SilgiCLI, SilgiPreset, SilgiPresetMeta, EnvOptions, SilgiTemplate, ResolvedSilgiTemplate } from 'silgi/types';
5
6
 
6
7
  /**
@@ -76,7 +77,7 @@ declare function resolveSilgiModule(base: string, paths: string[]): Promise<stri
76
77
  *
77
78
  * This mirrors the runtime behavior of Nitro.
78
79
  */
79
- declare function useSilgiRuntimeConfig(): Record<string, any> | undefined;
80
+ declare function useSilgiRuntimeConfig(): silgi_types.SilgiRuntimeOptions;
80
81
  declare function applyEnv(obj: Record<string, any>, opts: EnvOptions, parentKey?: string): Record<string, any>;
81
82
 
82
83
  /**
@@ -246,14 +246,14 @@ async function resolveSilgiModule(base, paths) {
246
246
  function useSilgiRuntimeConfig() {
247
247
  const silgi = tryUseSilgi();
248
248
  if (!silgi) {
249
- return void 0;
249
+ return globalThis.$silgiSharedRuntimeConfig;
250
250
  }
251
- return applyEnv(klona(silgi.options.runtimeConfig), {
251
+ return applyEnv(klona(silgi.runtimeConfig), {
252
252
  prefix: "NITRO_",
253
253
  altPrefix: "NUXT_",
254
254
  silgiPrefix: "SILGI_",
255
255
  envExpansion: silgi.options.experimental?.envExpansion ?? !!process$1.env.NITRO_ENV_EXPANSION,
256
- ...silgi.options.envOptions
256
+ ...silgi.envOptions
257
257
  });
258
258
  }
259
259
  function getEnv(key, opts, env = process$1.env) {
@@ -1,4 +1,4 @@
1
- const version = "0.9.16";
1
+ const version = "0.9.18";
2
2
  const devDependencies = {
3
3
  "@antfu/eslint-config": "^4.3.0",
4
4
  "@nuxt/kit": "^3.15.4",
@@ -1,4 +1,4 @@
1
- const version = "0.9.16";
1
+ const version = "0.9.18";
2
2
  const devDependencies = {
3
3
  "@antfu/eslint-config": "^4.3.0",
4
4
  "@nuxt/kit": "^3.15.4",
@@ -934,6 +934,10 @@ interface Silgi {
934
934
  close: () => Promise<void>;
935
935
  logger: ConsolaInstance;
936
936
  storage: Storage;
937
+ envOptions: EnvOptions;
938
+ runtimeConfig: SilgiRuntimeOptions & {
939
+ [key: string]: any;
940
+ };
937
941
  options: SilgiOptions & SilgiRuntimeOptions;
938
942
  captureError: CaptureError;
939
943
  }
@@ -957,10 +961,6 @@ type CaptureError = (error: Error, context: CapturedErrorContext) => void;
957
961
  interface SilgiOptions {
958
962
  consolaOptions?: Partial<ConsolaOptions>;
959
963
  present: PresetNameInput;
960
- envOptions: EnvOptions;
961
- runtimeConfig: SilgiRuntimeOptions & {
962
- [key: string]: any;
963
- };
964
964
  /**
965
965
  * Set to `true` to enable debug mode.
966
966
  *
@@ -934,6 +934,10 @@ interface Silgi {
934
934
  close: () => Promise<void>;
935
935
  logger: ConsolaInstance;
936
936
  storage: Storage;
937
+ envOptions: EnvOptions;
938
+ runtimeConfig: SilgiRuntimeOptions & {
939
+ [key: string]: any;
940
+ };
937
941
  options: SilgiOptions & SilgiRuntimeOptions;
938
942
  captureError: CaptureError;
939
943
  }
@@ -957,10 +961,6 @@ type CaptureError = (error: Error, context: CapturedErrorContext) => void;
957
961
  interface SilgiOptions {
958
962
  consolaOptions?: Partial<ConsolaOptions>;
959
963
  present: PresetNameInput;
960
- envOptions: EnvOptions;
961
- runtimeConfig: SilgiRuntimeOptions & {
962
- [key: string]: any;
963
- };
964
964
  /**
965
965
  * Set to `true` to enable debug mode.
966
966
  *
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "silgi",
3
3
  "type": "module",
4
- "version": "0.9.16",
4
+ "version": "0.9.18",
5
5
  "private": false,
6
6
  "sideEffects": false,
7
7
  "exports": {