silgi 0.28.8 → 0.28.10
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/cli/index.mjs +1 -1
- package/dist/cli/silgi.mjs +16 -5
- package/dist/cli/types.mjs +7 -15
- package/dist/kit/index.d.mts +8 -1
- package/dist/kit/index.mjs +32 -9
- package/dist/types/index.d.mts +1 -1
- package/package.json +1 -1
package/dist/cli/index.mjs
CHANGED
package/dist/cli/silgi.mjs
CHANGED
|
@@ -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
|
-
|
|
2214
|
+
console.log(packages);
|
|
2204
2215
|
if (silgi.options.preset === "npm-package") {
|
|
2205
2216
|
packages.devDependencies = {
|
|
2206
2217
|
...packages.devDependencies,
|
package/dist/cli/types.mjs
CHANGED
|
@@ -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
|
-
|
|
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";
|
package/dist/kit/index.d.mts
CHANGED
|
@@ -4,6 +4,13 @@ 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
|
+
when?: boolean;
|
|
12
|
+
}[]): Promise<void>;
|
|
13
|
+
|
|
7
14
|
declare function hasError(type: SilgiCLI['errors'][0]['type'], silgi?: SilgiCLI): boolean;
|
|
8
15
|
|
|
9
16
|
declare function directoryToURL(dir: string): URL;
|
|
@@ -283,5 +290,5 @@ declare function hasInstalledModule(moduleKey: string, silgi?: SilgiCLI): boolea
|
|
|
283
290
|
declare const baseHeaderBannerComment: string[];
|
|
284
291
|
declare function processFilePath(src: string): string;
|
|
285
292
|
|
|
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 };
|
|
293
|
+
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
294
|
export type { FunctionConfig, JsonPatch, MigrationData, MigrationInfo, MigrationOptions, MigrationResult };
|
package/dist/kit/index.mjs
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
import {
|
|
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,30 @@ 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
|
+
if (item.when === false) {
|
|
29
|
+
continue;
|
|
30
|
+
}
|
|
31
|
+
const getPackageVersion = execSync(
|
|
32
|
+
`pnpm info ${item.name} version`,
|
|
33
|
+
{ encoding: "utf-8" }
|
|
34
|
+
);
|
|
35
|
+
let version = item.version || getPackageVersion.trim();
|
|
36
|
+
version = `^${version}`;
|
|
37
|
+
if (item.isDev) {
|
|
38
|
+
silgi.options.installPackages.devDependencies[item.name] = version;
|
|
39
|
+
} else {
|
|
40
|
+
silgi.options.installPackages.dependencies[item.name] = version;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
22
45
|
function hasError(type, silgi) {
|
|
23
46
|
silgi = silgi ?? tryUseSilgiCLI() ?? void 0;
|
|
24
47
|
if (silgi && silgi.errors.some((error) => error.type === type)) {
|
|
@@ -66,7 +89,7 @@ function _compilePathTemplate(contents) {
|
|
|
66
89
|
}
|
|
67
90
|
|
|
68
91
|
async function writeFile(file, contents, log = false) {
|
|
69
|
-
const silgi = useSilgiCLI();
|
|
92
|
+
const silgi = useSilgiCLI$1();
|
|
70
93
|
if (silgi.errors.length) {
|
|
71
94
|
return;
|
|
72
95
|
}
|
|
@@ -569,7 +592,7 @@ function _defineSilgiModule(definition) {
|
|
|
569
592
|
}
|
|
570
593
|
const module = defu(definition, { meta: {} });
|
|
571
594
|
module.meta.configKey ||= module.meta.name;
|
|
572
|
-
async function getOptions(inlineOptions, silgi = useSilgiCLI()) {
|
|
595
|
+
async function getOptions(inlineOptions, silgi = useSilgiCLI$1()) {
|
|
573
596
|
const nuxtConfigOptionsKey = module.meta.configKey || module.meta.name;
|
|
574
597
|
const nuxtConfigOptions = nuxtConfigOptionsKey && nuxtConfigOptionsKey in silgi.options ? silgi.options[nuxtConfigOptionsKey] : {};
|
|
575
598
|
const optionsDefaults = typeof module.defaults === "function" ? await module.defaults(silgi) : module.defaults ?? {};
|
|
@@ -769,10 +792,10 @@ function filterInPlace(array, predicate) {
|
|
|
769
792
|
return array;
|
|
770
793
|
}
|
|
771
794
|
const MODE_RE = /\.(server|client)(\.\w+)*$/;
|
|
772
|
-
function hasSilgiModule(moduleKey, silgi = useSilgiCLI()) {
|
|
795
|
+
function hasSilgiModule(moduleKey, silgi = useSilgiCLI$1()) {
|
|
773
796
|
return silgi.scanModules.some(({ meta }) => meta.configKey === moduleKey) || Object.keys(silgi.scanModules).includes(moduleKey);
|
|
774
797
|
}
|
|
775
|
-
function hasInstalledModule(moduleKey, silgi = useSilgiCLI()) {
|
|
798
|
+
function hasInstalledModule(moduleKey, silgi = useSilgiCLI$1()) {
|
|
776
799
|
const find = silgi.scanModules.find(({ meta }) => meta.configKey === moduleKey);
|
|
777
800
|
return find?.installed ?? false;
|
|
778
801
|
}
|
|
@@ -784,7 +807,7 @@ const baseHeaderBannerComment = [
|
|
|
784
807
|
"/* tslint:disable */"
|
|
785
808
|
];
|
|
786
809
|
function processFilePath(src) {
|
|
787
|
-
const silgi = useSilgiCLI();
|
|
810
|
+
const silgi = useSilgiCLI$1();
|
|
788
811
|
if (silgi.options.typescript.removeFileExtension) {
|
|
789
812
|
src = src.replace(/\.ts$/, "");
|
|
790
813
|
return src;
|
|
@@ -793,7 +816,7 @@ function processFilePath(src) {
|
|
|
793
816
|
}
|
|
794
817
|
|
|
795
818
|
function addTemplate(_template) {
|
|
796
|
-
const silgi = useSilgiCLI();
|
|
819
|
+
const silgi = useSilgiCLI$1();
|
|
797
820
|
const template = normalizeTemplate(_template);
|
|
798
821
|
filterInPlace(silgi.options.build.templates, (p) => normalizeTemplate(p).dst !== template.dst);
|
|
799
822
|
silgi.options.build.templates.push(template);
|
|
@@ -827,7 +850,7 @@ function normalizeTemplate(template, buildDir) {
|
|
|
827
850
|
template.write = true;
|
|
828
851
|
}
|
|
829
852
|
if (!template.dst) {
|
|
830
|
-
const silgi = useSilgiCLI();
|
|
853
|
+
const silgi = useSilgiCLI$1();
|
|
831
854
|
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
855
|
template.dst = resolve(buildDir ?? dir, template.filename);
|
|
833
856
|
}
|
|
@@ -922,4 +945,4 @@ function isValidIp(ip) {
|
|
|
922
945
|
return false;
|
|
923
946
|
}
|
|
924
947
|
|
|
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 };
|
|
948
|
+
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 };
|
package/dist/types/index.d.mts
CHANGED
|
@@ -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
|
|