silgi 0.29.29 → 0.29.31

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.29";
4
+ const version = "0.29.31";
5
5
  const packageJson = {
6
6
  version: version};
7
7
 
@@ -227,7 +227,8 @@ async function prepareCommands(silgi = useSilgiCLI()) {
227
227
  ...Object.fromEntries(Array.from(allTags.values()).map((tag) => [tag, "string"]))
228
228
  }
229
229
  }),
230
- ""
230
+ "",
231
+ "export {}"
231
232
  ];
232
233
  addTemplate({
233
234
  filename: "types/commands.d.ts",
@@ -364,10 +365,18 @@ async function prepareCoreFile(silgi) {
364
365
  addBuildFunction: (data) => {
365
366
  for (const item of toArray(data)) {
366
367
  if (item.where === "after") {
367
- after.push(item.params?.length ? ` await ${item.name}(option, ${item.params.join(",")})` : ` await ${item.name}(option)`);
368
+ if (item.custom) {
369
+ after.push(item.custom);
370
+ } else {
371
+ after.push(item.params?.length ? ` await ${item.name}(option, ${item.params.join(",")})` : ` await ${item.name}(option)`);
372
+ }
368
373
  }
369
374
  if (item.where === "before") {
370
- before.push(item.params?.length ? ` await ${item.name}(option, ${item.params.join(",")})` : ` await ${item.name}(option)`);
375
+ if (item.custom) {
376
+ before.push(item.custom);
377
+ } else {
378
+ before.push(item.params?.length ? ` await ${item.name}(option, ${item.params.join(",")})` : ` await ${item.name}(option)`);
379
+ }
371
380
  }
372
381
  }
373
382
  }
@@ -7,6 +7,7 @@ import { Buffer } from 'node:buffer';
7
7
  import { klona } from 'klona';
8
8
  import { useSilgiRuntimeConfig } from 'silgi/runtime';
9
9
  import { createStorage as createStorage$1, builtinDrivers, prefixStorage } from 'unstorage';
10
+ import { isRuntimePresents } from 'silgi/kit';
10
11
  export { s as silgiCLICtx, t as tryUseSilgiCLI, u as useSilgiCLI } from '../_chunks/silgiApp.mjs';
11
12
  import 'ufo';
12
13
 
@@ -718,16 +719,14 @@ function mergeShared(sharedOrArray) {
718
719
  }
719
720
 
720
721
  function getEvent(event) {
721
- const silgi = useSilgi();
722
- if (silgi.options.present === "h3" || silgi.options.present === "nitro" || silgi.options.present === "nuxt") {
722
+ if (isRuntimePresents(["h3", "nitro", "nuxt"])) {
723
723
  return event;
724
724
  }
725
725
  return event;
726
726
  }
727
727
  function getEventContext(event) {
728
- const silgi = useSilgi();
729
728
  const _event = getEvent(event);
730
- if (silgi.options.present === "h3" || silgi.options.present === "nitro" || silgi.options.present === "nuxt") {
729
+ if (isRuntimePresents(["h3", "nitro", "nuxt"])) {
731
730
  return _event.context;
732
731
  }
733
732
  return _event;
package/dist/index.mjs CHANGED
@@ -10,3 +10,4 @@ import 'node:buffer';
10
10
  import 'klona';
11
11
  import 'silgi/runtime';
12
12
  import 'unstorage';
13
+ import 'silgi/kit';
@@ -312,6 +312,7 @@ declare function hasInstalledModule(moduleKey: string, silgi?: SilgiCLI): boolea
312
312
  declare const baseHeaderBannerComment: string[];
313
313
  declare function processFilePath(src: string): string;
314
314
  declare function isPresents(names: PresetName[]): boolean;
315
+ declare function isRuntimePresents(names: PresetName[]): boolean;
315
316
 
316
- export { MODE_RE, MigrationStatus, addCommands, addCoreFile, addImports, addNPMPackage, addTemplate, baseHeaderBannerComment, createFunction, createFunctionConfigs, createResolver, defineSilgiModule, defineSilgiPreset, directoryToURL, filterInPlace, formatFunctions, genEnsureSafeVar, generateMigration, getAllEntries, getIpAddress, getMigration, hasError, hasInstalledModule, hasSilgiModule, hash, ipAddress, isDirectory, isH3, isNitro, isNuxt, isPresents, listMigrations, migrationDown, migrationUp, normalizeTemplate, parseServices, prettyPath, processFilePath, relativeWithDot, resolveAlias, resolvePath, resolveSilgiModule, resolveSilgiPath, serviceParseModule, toArray, tryResolveModule, useLogger, useRequest, useResponse, writeFile };
317
+ export { MODE_RE, MigrationStatus, addCommands, addCoreFile, addImports, addNPMPackage, addTemplate, baseHeaderBannerComment, createFunction, createFunctionConfigs, createResolver, defineSilgiModule, defineSilgiPreset, directoryToURL, filterInPlace, formatFunctions, genEnsureSafeVar, generateMigration, getAllEntries, getIpAddress, getMigration, hasError, hasInstalledModule, hasSilgiModule, hash, ipAddress, isDirectory, isH3, isNitro, isNuxt, isPresents, isRuntimePresents, listMigrations, migrationDown, migrationUp, normalizeTemplate, parseServices, prettyPath, processFilePath, relativeWithDot, resolveAlias, resolvePath, resolveSilgiModule, resolveSilgiPath, serviceParseModule, toArray, tryResolveModule, useLogger, useRequest, useResponse, writeFile };
317
318
  export type { FunctionConfig, JsonPatch, MigrationData, MigrationInfo, MigrationOptions, MigrationResult };
@@ -1,6 +1,6 @@
1
1
  import { u as useSilgiCLI$1 } from '../_chunks/silgiApp.mjs';
2
2
  import { relative, resolve, dirname, join, normalize, isAbsolute, parse, basename } from 'pathe';
3
- import { useSilgiCLI, tryUseSilgiCLI, useSilgi } from 'silgi';
3
+ import { useSilgiCLI, useSilgi, tryUseSilgiCLI } from 'silgi';
4
4
  import { toArray as toArray$1, hash as hash$2 } from 'silgi/kit';
5
5
  import { execSync } from 'node:child_process';
6
6
  import { pathToFileURL, fileURLToPath } from 'node:url';
@@ -64,6 +64,10 @@ function isPresents(names) {
64
64
  const silgi = useSilgiCLI();
65
65
  return names.filter((name) => silgi.options.preset.includes(name)).length > 0;
66
66
  }
67
+ function isRuntimePresents(names) {
68
+ const silgi = useSilgi();
69
+ return names.filter((name) => silgi.options.preset.includes(name)).length > 0;
70
+ }
67
71
 
68
72
  async function addCommands(data) {
69
73
  useSilgiCLI$1().hook("prepare:commands", (commads) => {
@@ -1041,4 +1045,4 @@ function isValidIp(ip) {
1041
1045
  return false;
1042
1046
  }
1043
1047
 
1044
- export { MODE_RE, MigrationStatus, addCommands, addCoreFile, addImports, addNPMPackage, addTemplate, baseHeaderBannerComment, createFunction, createFunctionConfigs, createResolver, defineSilgiModule, defineSilgiPreset, directoryToURL, filterInPlace, formatFunctions, genEnsureSafeVar, generateMigration, getAllEntries, getIpAddress, getMigration, hasError, hasInstalledModule, hasSilgiModule, hash, ipAddress, isDirectory$1 as isDirectory, isH3, isNitro, isNuxt, isPresents, listMigrations, migrationDown, migrationUp, normalizeTemplate, parseServices, prettyPath, processFilePath, relativeWithDot, resolveAlias, resolvePath, resolveSilgiModule, resolveSilgiPath, serviceParseModule, toArray, tryResolveModule, useLogger, useRequest, useResponse, writeFile };
1048
+ export { MODE_RE, MigrationStatus, addCommands, addCoreFile, addImports, addNPMPackage, addTemplate, baseHeaderBannerComment, createFunction, createFunctionConfigs, createResolver, defineSilgiModule, defineSilgiPreset, directoryToURL, filterInPlace, formatFunctions, genEnsureSafeVar, generateMigration, getAllEntries, getIpAddress, getMigration, hasError, hasInstalledModule, hasSilgiModule, hash, ipAddress, isDirectory$1 as isDirectory, isH3, isNitro, isNuxt, isPresents, isRuntimePresents, listMigrations, migrationDown, migrationUp, normalizeTemplate, parseServices, prettyPath, processFilePath, relativeWithDot, resolveAlias, resolvePath, resolveSilgiModule, resolveSilgiPath, serviceParseModule, toArray, tryResolveModule, useLogger, useRequest, useResponse, writeFile };
@@ -192,10 +192,12 @@ interface SilgiCLIHooks extends SilgiHooks {
192
192
  addBuildFunction: (data: {
193
193
  name: string;
194
194
  params?: string[];
195
+ custom?: string;
195
196
  where: 'before' | 'after';
196
197
  }[] | {
197
198
  name: string;
198
199
  params?: string[];
200
+ custom?: string;
199
201
  where: 'before' | 'after';
200
202
  }) => void;
201
203
  }) => HookResult;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "silgi",
3
3
  "type": "module",
4
- "version": "0.29.29",
4
+ "version": "0.29.31",
5
5
  "private": false,
6
6
  "sideEffects": false,
7
7
  "exports": {