silgi 0.28.7 → 0.28.9

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.28.7";
4
+ const version = "0.28.9";
5
5
  const packageJson = {
6
6
  version: version};
7
7
 
@@ -1,7 +1,7 @@
1
1
  import { generateDTS } from 'apiful/openapi';
2
2
  import consola$1, { consola } from 'consola';
3
3
  import { join, resolve, dirname, isAbsolute, relative, basename, extname } from 'pathe';
4
- import { hasSilgiModule, addTemplate, normalizeTemplate, useLogger, genEnsureSafeVar, hash, relativeWithDot, writeFile, isDirectory, resolveAlias as resolveAlias$1, directoryToURL, hasError, parseServices, resolveSilgiPath } from 'silgi/kit';
4
+ import { hasSilgiModule, addTemplate, normalizeTemplate, useLogger, genEnsureSafeVar, hash, relativeWithDot, writeFile, isDirectory, resolveAlias as resolveAlias$1, directoryToURL, hasError, parseServices, addNPMPackage, resolveSilgiPath } from 'silgi/kit';
5
5
  import { mkdirSync, existsSync, writeFileSync, promises, readFileSync } from 'node:fs';
6
6
  import { readdir, readFile } from 'node:fs/promises';
7
7
  import { genObjectFromRawEntries, genObjectFromRaw, genObjectFromValues } from 'knitwork';
@@ -28,7 +28,6 @@ import { parseSync } from '@oxc-parser/wasm';
28
28
  import { klona } from 'klona';
29
29
  import { useSilgiRuntimeConfig, initRuntimeConfig } from 'silgi/runtime';
30
30
  import { createStorage, builtinDrivers } from 'unstorage';
31
- import { peerDependencies } from 'silgi/meta';
32
31
  import { snakeCase } from 'scule';
33
32
 
34
33
  async function generateApiFul(silgi) {
@@ -2190,17 +2189,29 @@ async function createStorageCLI(silgi) {
2190
2189
  }
2191
2190
 
2192
2191
  async function installPackages(silgi) {
2192
+ await addNPMPackage([
2193
+ {
2194
+ name: "@fastify/deepmerge",
2195
+ isDev: false
2196
+ },
2197
+ {
2198
+ name: "@silgi/ecosystem",
2199
+ isDev: false
2200
+ },
2201
+ {
2202
+ name: "unadapter",
2203
+ isDev: false
2204
+ }
2205
+ ]);
2193
2206
  const packages = {
2194
2207
  dependencies: {
2195
- "@fastify/deepmerge": peerDependencies["@fastify/deepmerge"],
2196
- "@silgi/ecosystem": peerDependencies["@silgi/ecosystem"],
2197
2208
  ...silgi.options.installPackages?.dependencies
2198
2209
  },
2199
2210
  devDependencies: {
2200
2211
  ...silgi.options.installPackages?.devDependencies
2201
2212
  }
2202
2213
  };
2203
- await silgi.callHook("prepare:installPackages", packages);
2214
+ console.log(packages);
2204
2215
  if (silgi.options.preset === "npm-package") {
2205
2216
  packages.devDependencies = {
2206
2217
  ...packages.devDependencies,
@@ -86,8 +86,6 @@ const SilgiCLIDefaults = {
86
86
  presets: [],
87
87
  virtualImports: ["#silgiImports"]
88
88
  },
89
- // virtual: {},
90
- // compressPublicAssets: false,
91
89
  ignore: [],
92
90
  // Dev
93
91
  dev: false,
@@ -114,17 +112,6 @@ const SilgiCLIDefaults = {
114
112
  "**/tmp/**"
115
113
  ]
116
114
  },
117
- // devProxy: {},
118
- // Logging
119
- // logging: {
120
- // compressedSizes: true,
121
- // buildSuccess: true,
122
- // },
123
- // Routing
124
- // baseURL: process.env.NITRO_APP_BASE_URL || '/',
125
- // handlers: [],
126
- // devHandlers: [],
127
- // errorHandler: undefined,
128
115
  // Advanced
129
116
  typescript: {
130
117
  strict: false,
@@ -138,7 +125,7 @@ const SilgiCLIDefaults = {
138
125
  },
139
126
  conditions: [],
140
127
  nodeModulesDirs: [],
141
- // hooks: {},
128
+ hooks: {},
142
129
  commands: {},
143
130
  // Framework
144
131
  framework: {
@@ -148,7 +135,12 @@ const SilgiCLIDefaults = {
148
135
  extensions: [".js", ".jsx", ".mjs", ".ts", ".tsx", ".vue"],
149
136
  ignoreOptions: void 0,
150
137
  // 3. party
151
- apiFul: {}
138
+ apiFul: {},
139
+ // Kit
140
+ installPackages: {
141
+ dependencies: {},
142
+ devDependencies: {}
143
+ }
152
144
  };
153
145
 
154
146
  const fallbackCompatibilityDate = "2025-02-04";
@@ -349,7 +341,9 @@ async function resolvePathOptions(options) {
349
341
  }
350
342
  options.alias ||= {};
351
343
  options.alias[packageJson.name] = join(options.rootDir, "src/module");
352
- options.alias[`${packageJson.name}/runtime/`] = join(options.rootDir, "src/runtime");
344
+ options.alias[`${packageJson.name}/runtime`] = join(options.rootDir, "src/runtime");
345
+ options.alias[`${packageJson.name}/data`] = join(options.rootDir, "src/data");
346
+ options.alias[`${packageJson.name}/data/*`] = join(options.rootDir, "src/data/*");
353
347
  options.alias[`${packageJson.name}/runtime/*`] = join(options.rootDir, "src/runtime/*");
354
348
  options.alias[`${packageJson.name}/types`] = join(options.rootDir, "src/types");
355
349
  }
@@ -357,9 +351,7 @@ async function resolvePathOptions(options) {
357
351
  options.alias = {
358
352
  ...options.alias,
359
353
  "silgi/runtime": join(runtimeDir),
360
- "#internal/silgi": join(runtimeDir),
361
- "silgi/runtime/*": join(runtimeDir, "*"),
362
- "#internal/silgi/*": join(runtimeDir, "*")
354
+ "silgi/runtime/*": join(runtimeDir, "*")
363
355
  };
364
356
  }
365
357
  options.alias = {
@@ -4,6 +4,12 @@ import { ConsolaOptions, ConsolaInstance } from 'consola';
4
4
  import * as rfc6902 from 'rfc6902';
5
5
  import { IncomingMessage, ServerResponse } from 'node:http';
6
6
 
7
+ declare function addNPMPackage(data: {
8
+ name: string;
9
+ version?: string;
10
+ isDev?: boolean;
11
+ }[]): Promise<void>;
12
+
7
13
  declare function hasError(type: SilgiCLI['errors'][0]['type'], silgi?: SilgiCLI): boolean;
8
14
 
9
15
  declare function directoryToURL(dir: string): URL;
@@ -283,5 +289,5 @@ declare function hasInstalledModule(moduleKey: string, silgi?: SilgiCLI): boolea
283
289
  declare const baseHeaderBannerComment: string[];
284
290
  declare function processFilePath(src: string): string;
285
291
 
286
- export { MODE_RE, MigrationStatus, addTemplate, baseHeaderBannerComment, createFunction, createFunctionConfigs, createResolver, defineSilgiModule, defineSilgiPreset, directoryToURL, filterInPlace, formatFunctions, genEnsureSafeVar, generateMigration, getAllEntries, getIpAddress, getMigration, hasError, hasInstalledModule, hasSilgiModule, hash, ipAddress, isDirectory, isH3, isNitro, isNuxt, listMigrations, migrationDown, migrationUp, normalizeTemplate, parseServices, prettyPath, processFilePath, relativeWithDot, resolveAlias, resolvePath, resolveSilgiModule, resolveSilgiPath, serviceParseModule, toArray, tryResolveModule, useLogger, useRequest, useResponse, writeFile };
292
+ export { MODE_RE, MigrationStatus, 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, listMigrations, migrationDown, migrationUp, normalizeTemplate, parseServices, prettyPath, processFilePath, relativeWithDot, resolveAlias, resolvePath, resolveSilgiModule, resolveSilgiPath, serviceParseModule, toArray, tryResolveModule, useLogger, useRequest, useResponse, writeFile };
287
293
  export type { FunctionConfig, JsonPatch, MigrationData, MigrationInfo, MigrationOptions, MigrationResult };
@@ -1,4 +1,6 @@
1
- import { tryUseSilgiCLI, useSilgiCLI, useSilgi } from 'silgi';
1
+ import { execSync } from 'node:child_process';
2
+ import { u as useSilgiCLI } from '../_chunks/silgiApp.mjs';
3
+ import { tryUseSilgiCLI, useSilgiCLI as useSilgiCLI$1, useSilgi } from 'silgi';
2
4
  import { pathToFileURL, fileURLToPath } from 'node:url';
3
5
  import { resolvePath as resolvePath$1 } from 'mlly';
4
6
  import fsp, { mkdir, readFile, writeFile as writeFile$1 } from 'node:fs/promises';
@@ -16,9 +18,27 @@ import { c as checkSilgiCompatibility } from '../cli/compatibility.mjs';
16
18
  import { withLeadingSlash } from 'ufo';
17
19
  import { resolveAlias as resolveAlias$1 } from 'pathe/utils';
18
20
  import { hash as hash$2 } from 'silgi/kit';
21
+ import 'unctx';
19
22
  import 'semver/functions/satisfies.js';
20
23
  import 'silgi/meta';
21
24
 
25
+ async function addNPMPackage(data) {
26
+ const silgi = useSilgiCLI();
27
+ for (const item of data) {
28
+ const getPackageVersion = execSync(
29
+ `pnpm info ${item.name} version`,
30
+ { encoding: "utf-8" }
31
+ );
32
+ let version = item.version || getPackageVersion.trim();
33
+ version = `^${version}`;
34
+ if (item.isDev) {
35
+ silgi.options.installPackages.devDependencies[item.name] = version;
36
+ } else {
37
+ silgi.options.installPackages.dependencies[item.name] = version;
38
+ }
39
+ }
40
+ }
41
+
22
42
  function hasError(type, silgi) {
23
43
  silgi = silgi ?? tryUseSilgiCLI() ?? void 0;
24
44
  if (silgi && silgi.errors.some((error) => error.type === type)) {
@@ -66,7 +86,7 @@ function _compilePathTemplate(contents) {
66
86
  }
67
87
 
68
88
  async function writeFile(file, contents, log = false) {
69
- const silgi = useSilgiCLI();
89
+ const silgi = useSilgiCLI$1();
70
90
  if (silgi.errors.length) {
71
91
  return;
72
92
  }
@@ -569,7 +589,7 @@ function _defineSilgiModule(definition) {
569
589
  }
570
590
  const module = defu(definition, { meta: {} });
571
591
  module.meta.configKey ||= module.meta.name;
572
- async function getOptions(inlineOptions, silgi = useSilgiCLI()) {
592
+ async function getOptions(inlineOptions, silgi = useSilgiCLI$1()) {
573
593
  const nuxtConfigOptionsKey = module.meta.configKey || module.meta.name;
574
594
  const nuxtConfigOptions = nuxtConfigOptionsKey && nuxtConfigOptionsKey in silgi.options ? silgi.options[nuxtConfigOptionsKey] : {};
575
595
  const optionsDefaults = typeof module.defaults === "function" ? await module.defaults(silgi) : module.defaults ?? {};
@@ -769,10 +789,10 @@ function filterInPlace(array, predicate) {
769
789
  return array;
770
790
  }
771
791
  const MODE_RE = /\.(server|client)(\.\w+)*$/;
772
- function hasSilgiModule(moduleKey, silgi = useSilgiCLI()) {
792
+ function hasSilgiModule(moduleKey, silgi = useSilgiCLI$1()) {
773
793
  return silgi.scanModules.some(({ meta }) => meta.configKey === moduleKey) || Object.keys(silgi.scanModules).includes(moduleKey);
774
794
  }
775
- function hasInstalledModule(moduleKey, silgi = useSilgiCLI()) {
795
+ function hasInstalledModule(moduleKey, silgi = useSilgiCLI$1()) {
776
796
  const find = silgi.scanModules.find(({ meta }) => meta.configKey === moduleKey);
777
797
  return find?.installed ?? false;
778
798
  }
@@ -784,7 +804,7 @@ const baseHeaderBannerComment = [
784
804
  "/* tslint:disable */"
785
805
  ];
786
806
  function processFilePath(src) {
787
- const silgi = useSilgiCLI();
807
+ const silgi = useSilgiCLI$1();
788
808
  if (silgi.options.typescript.removeFileExtension) {
789
809
  src = src.replace(/\.ts$/, "");
790
810
  return src;
@@ -793,7 +813,7 @@ function processFilePath(src) {
793
813
  }
794
814
 
795
815
  function addTemplate(_template) {
796
- const silgi = useSilgiCLI();
816
+ const silgi = useSilgiCLI$1();
797
817
  const template = normalizeTemplate(_template);
798
818
  filterInPlace(silgi.options.build.templates, (p) => normalizeTemplate(p).dst !== template.dst);
799
819
  silgi.options.build.templates.push(template);
@@ -827,7 +847,7 @@ function normalizeTemplate(template, buildDir) {
827
847
  template.write = true;
828
848
  }
829
849
  if (!template.dst) {
830
- const silgi = useSilgiCLI();
850
+ const silgi = useSilgiCLI$1();
831
851
  const dir = template.where === ".silgi" ? silgi.options.build.dir : template.where === "server" ? silgi.options.silgi.serverDir : template.where === "client" ? silgi.options.silgi.clientDir : silgi.options.silgi.serverDir;
832
852
  template.dst = resolve(buildDir ?? dir, template.filename);
833
853
  }
@@ -922,4 +942,4 @@ function isValidIp(ip) {
922
942
  return false;
923
943
  }
924
944
 
925
- export { MODE_RE, MigrationStatus, 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, listMigrations, migrationDown, migrationUp, normalizeTemplate, parseServices, prettyPath, processFilePath, relativeWithDot, resolveAlias, resolvePath, resolveSilgiModule, resolveSilgiPath, serviceParseModule, toArray, tryResolveModule, useLogger, useRequest, useResponse, writeFile };
945
+ export { MODE_RE, MigrationStatus, 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, listMigrations, migrationDown, migrationUp, normalizeTemplate, parseServices, prettyPath, processFilePath, relativeWithDot, resolveAlias, resolvePath, resolveSilgiModule, resolveSilgiPath, serviceParseModule, toArray, tryResolveModule, useLogger, useRequest, useResponse, writeFile };
@@ -273,7 +273,6 @@ interface SilgiCLIHooks extends SilgiHooks {
273
273
  'app:templatesGenerated': (app: SilgiCLI, templates: ResolvedSilgiTemplate[], options?: GenerateAppOptions) => HookResult;
274
274
  'scanFiles:done': (app: SilgiCLI) => HookResult;
275
275
  'prepare:commands': (commands: SilgiCLI['commands']) => HookResult;
276
- 'prepare:installPackages': (packages: Record<'dependencies' | 'devDependencies', Record<string, string>>) => HookResult;
277
276
  }
278
277
  type TSReference = {
279
278
  types: string;
@@ -1116,6 +1115,7 @@ interface SilgiOptions {
1116
1115
  [key: string]: any;
1117
1116
  };
1118
1117
  captureError: CaptureError;
1118
+ adapters: Record<string, Adapter<Record<string, any>, TablesSchema, InferModelTypes<TablesSchema>>>;
1119
1119
  [key: string]: any;
1120
1120
  }
1121
1121
 
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "silgi",
3
3
  "type": "module",
4
- "version": "0.28.7",
4
+ "version": "0.28.9",
5
5
  "private": false,
6
6
  "sideEffects": false,
7
7
  "exports": {