silgi 0.29.38 → 0.29.40

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,7 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
  import { defineCommand, runMain } from 'citty';
3
3
 
4
- const version = "0.29.38";
4
+ const version = "0.29.40";
5
5
  const packageJson = {
6
6
  version: version};
7
7
 
@@ -6,7 +6,7 @@ import { mkdirSync, existsSync, writeFileSync, promises, readFileSync } from 'no
6
6
  import { readdir, readFile } from 'node:fs/promises';
7
7
  import { genAugmentation, genObjectFromRawEntries, genImport, genTypeImport, genObjectFromRaw, genObjectFromValues } from 'knitwork';
8
8
  import { u as useSilgiCLI } from '../_chunks/silgiApp.mjs';
9
- import { resolvePath, parseNodeModulePath, lookupNodeModuleSubpath, resolveModuleExportNames, findTypeExports, findExports } from 'mlly';
9
+ import { resolvePath, parseNodeModulePath, lookupNodeModuleSubpath, findTypeExports, findExports } from 'mlly';
10
10
  import { resolveAlias } from 'pathe/utils';
11
11
  import { runtimeDir } from 'silgi/runtime/meta';
12
12
  import { toExports, scanExports, createUnimport } from 'unimport';
@@ -34,7 +34,7 @@ import { snakeCase } from 'scule';
34
34
  async function generateApiFul(silgi) {
35
35
  const config = silgi.options.apiFul;
36
36
  if (!hasSilgiModule("openapi")) {
37
- consola.info("Silgi OpenAPI module not found, if you want to use it, please install it @silgi/openapi");
37
+ silgi.logger.info("Silgi OpenAPI module not found, if you want to use it, please install it @silgi/openapi");
38
38
  return;
39
39
  }
40
40
  if (!config.services || hasSilgiModule("openapi")) {
@@ -1051,14 +1051,7 @@ async function h3Framework(silgi, skip = false) {
1051
1051
  }
1052
1052
  });
1053
1053
  if (silgi.options.imports !== false) {
1054
- const h3Exports = await resolveModuleExportNames("h3", {
1055
- url: import.meta.url
1056
- });
1057
1054
  silgi.options.imports.presets ??= [];
1058
- silgi.options.imports.presets.push({
1059
- from: "h3",
1060
- imports: h3Exports.filter((n) => !/^[A-Z]/.test(n) && n !== "use")
1061
- });
1062
1055
  }
1063
1056
  }
1064
1057
 
@@ -2288,7 +2281,7 @@ async function createSilgiCLI(config = {}, opts = {}) {
2288
2281
  hooks,
2289
2282
  errors: [],
2290
2283
  _requiredModules: {},
2291
- logger: consola.withTag("silgi"),
2284
+ logger: opts.consola || consola.withTag("silgi"),
2292
2285
  close: () => silgi.hooks.callHook("close", silgi),
2293
2286
  storage: void 0,
2294
2287
  scanModules: [],
@@ -40,19 +40,20 @@ declare function addNPMPackage(data: {
40
40
  * @param preset The framework preset to use
41
41
  * @example
42
42
  * ```ts
43
- * const h3Handler = defineFramework('h3').build((options) => {
43
+ * const h3Handler = defineFramework('h3').build(async (options) => {
44
44
  * // Type-safe access to h3 router
45
45
  * const router = options.framework
46
- * // Implementation here
46
+ * // Implementation here with async/await support
47
+ * await someAsyncOperation()
47
48
  * })
48
49
  * ```
49
50
  */
50
51
  declare function defineFramework<T extends PresetName>(preset: T): {
51
52
  /**
52
53
  * Build the framework handler
53
- * @param callback The callback function that will receive typed options
54
+ * @param callback The callback function that will receive typed options (can be async)
54
55
  */
55
- build(callback: (options: DefineFrameworkOptions<T>) => void): (options: DefineFrameworkOptions<T>) => void;
56
+ build(callback: (options: DefineFrameworkOptions<T>) => void | Promise<void>): (options: DefineFrameworkOptions<T>) => Promise<void>;
56
57
  };
57
58
 
58
59
  declare function hasError(type: SilgiCLI['errors'][0]['type'], silgi?: SilgiCLI): boolean;
@@ -193,11 +193,11 @@ function defineFramework(preset) {
193
193
  return {
194
194
  /**
195
195
  * Build the framework handler
196
- * @param callback The callback function that will receive typed options
196
+ * @param callback The callback function that will receive typed options (can be async)
197
197
  */
198
198
  build(callback) {
199
- return function handler(options) {
200
- callback(options);
199
+ return async function handler(options) {
200
+ await callback(options);
201
201
  };
202
202
  }
203
203
  };
@@ -16,6 +16,18 @@ const h3 = defineSilgiPreset(
16
16
  isDev: true
17
17
  });
18
18
  }
19
+ },
20
+ imports: {
21
+ dirs: [
22
+ // '{{ serverDir }}/**',
23
+ "!{{ serverDir }}/runtime/**",
24
+ "!{{ serverDir }}/api/**",
25
+ "!{{ serverDir }}/routes/**",
26
+ "!{{ serverDir }}/modules/**",
27
+ "!{{ serverDir }}/assets/**",
28
+ "!{{ serverDir }}/public/**",
29
+ "!{{ silgi.serverDir }}/**"
30
+ ]
19
31
  }
20
32
  },
21
33
  {
@@ -14,7 +14,7 @@ const nitro = defineSilgiPreset(
14
14
  },
15
15
  imports: {
16
16
  dirs: [
17
- "{{ serverDir }}/**",
17
+ // '{{ serverDir }}/**',
18
18
  "!{{ serverDir }}/runtime/**",
19
19
  "!{{ serverDir }}/api/**",
20
20
  "!{{ serverDir }}/routes/**",
@@ -15,7 +15,7 @@ const npmPackage = defineSilgiPreset(
15
15
  },
16
16
  imports: {
17
17
  dirs: [
18
- "{{ serverDir }}/**",
18
+ // '{{ serverDir }}/**',
19
19
  "!{{ serverDir }}/runtime/**",
20
20
  "!{{ silgi.serverDir }}/**",
21
21
  "!{{ serverDir }}/module.ts",
@@ -15,7 +15,7 @@ const nuxt = defineSilgiPreset(
15
15
  },
16
16
  imports: {
17
17
  dirs: [
18
- "{{ serverDir }}/**",
18
+ // '{{ serverDir }}/**',
19
19
  "!{{ serverDir }}/runtime/**",
20
20
  "!{{ serverDir }}/api/**",
21
21
  "!{{ serverDir }}/routes/**",
@@ -820,7 +820,7 @@ interface SilgiCLIOptions extends PresetOptions {
820
820
  /**
821
821
  * Silgi input config (silgi.config)
822
822
  */
823
- interface SilgiCLIConfig extends DeepPartial<Omit<SilgiCLIOptions, 'preset' | 'compatibilityDate' | '_config' | '_c12'>>, C12InputConfig<SilgiCLIConfig>, Partial<SilgiModuleOptions> {
823
+ interface SilgiCLIConfig extends DeepPartial<Omit<SilgiCLIOptions, 'preset' | 'compatibilityDate' | '_config' | '_c12' | 'consola'>>, C12InputConfig<SilgiCLIConfig>, Partial<SilgiModuleOptions> {
824
824
  preset?: PresetNameInput;
825
825
  extends?: string | string[] | SilgiPreset;
826
826
  compatibilityDate?: CompatibilityDateSpec;
@@ -832,6 +832,7 @@ interface LoadConfigOptions {
832
832
  watch?: boolean;
833
833
  c12?: WatchConfigOptions;
834
834
  compatibilityDate?: CompatibilityDateSpec;
835
+ consola?: ConsolaInstance;
835
836
  }
836
837
 
837
838
  type TrimAfterFourSlashes<T extends string> = T extends `/${infer S1}/${infer S2}/${infer S3}/${infer S4}/${infer _}` ? `/${S1}/${S2}/${S3}/${S4}` : T;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "silgi",
3
3
  "type": "module",
4
- "version": "0.29.38",
4
+ "version": "0.29.40",
5
5
  "private": false,
6
6
  "sideEffects": false,
7
7
  "exports": {