silgi 0.29.13 → 0.29.15
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 +23 -76
- package/dist/kit/index.d.mts +12 -2
- package/dist/kit/index.mjs +57 -2
- 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,
|
|
4
|
+
import { hasSilgiModule, addTemplate, normalizeTemplate, useLogger, genEnsureSafeVar, addImports, hash, toArray, writeFile, relativeWithDot, isDirectory, addCoreFile, resolveAlias as resolveAlias$1, directoryToURL, hasError, parseServices, 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, genImport, genTypeImport, genObjectFromRaw, genObjectFromValues } from 'knitwork';
|
|
@@ -233,63 +233,8 @@ async function prepareConfigs(silgi) {
|
|
|
233
233
|
return importData;
|
|
234
234
|
}
|
|
235
235
|
|
|
236
|
-
function scanImports(data) {
|
|
237
|
-
const genImports = [
|
|
238
|
-
...data.imports ?? []
|
|
239
|
-
];
|
|
240
|
-
const genTypeImports = [
|
|
241
|
-
...data.typeImports ?? []
|
|
242
|
-
];
|
|
243
|
-
function addImportItem(data2) {
|
|
244
|
-
for (const item of toArray(data2)) {
|
|
245
|
-
const isSpecifier = genImports.some((i) => i.specifier === item.specifier);
|
|
246
|
-
if (isSpecifier) {
|
|
247
|
-
const index = genImports.findIndex((i) => i.specifier === item.specifier);
|
|
248
|
-
if (Array.isArray(genImports[index].imports)) {
|
|
249
|
-
genImports[index].imports ??= [];
|
|
250
|
-
genImports[index].imports.push(...toArray(item.imports));
|
|
251
|
-
} else {
|
|
252
|
-
genImports[index].imports = item.imports;
|
|
253
|
-
}
|
|
254
|
-
} else {
|
|
255
|
-
genImports.push({
|
|
256
|
-
specifier: item.specifier,
|
|
257
|
-
imports: item.imports,
|
|
258
|
-
options: item.options
|
|
259
|
-
});
|
|
260
|
-
}
|
|
261
|
-
}
|
|
262
|
-
}
|
|
263
|
-
function addImportItemType(data2) {
|
|
264
|
-
for (const item of toArray(data2)) {
|
|
265
|
-
const isSpecifier = genTypeImports.some((i) => i.specifier === item.specifier);
|
|
266
|
-
if (isSpecifier) {
|
|
267
|
-
const index = genTypeImports.findIndex((i) => i.specifier === item.specifier);
|
|
268
|
-
if (Array.isArray(genTypeImports[index].imports)) {
|
|
269
|
-
genTypeImports[index].imports ??= [];
|
|
270
|
-
genTypeImports[index].imports.push(...toArray(item.imports));
|
|
271
|
-
} else {
|
|
272
|
-
genTypeImports[index].imports = item.imports;
|
|
273
|
-
}
|
|
274
|
-
} else {
|
|
275
|
-
genTypeImports.push({
|
|
276
|
-
specifier: item.specifier,
|
|
277
|
-
imports: item.imports,
|
|
278
|
-
options: item.options
|
|
279
|
-
});
|
|
280
|
-
}
|
|
281
|
-
}
|
|
282
|
-
}
|
|
283
|
-
return {
|
|
284
|
-
genImports,
|
|
285
|
-
genTypeImports,
|
|
286
|
-
addImportItem,
|
|
287
|
-
addImportItemType
|
|
288
|
-
};
|
|
289
|
-
}
|
|
290
|
-
|
|
291
236
|
async function prepareCoreFile(silgi) {
|
|
292
|
-
const { genImports, genTypeImports, addImportItem, addImportItemType } =
|
|
237
|
+
const { genImports, genTypeImports, addImportItem, addImportItemType } = addImports({
|
|
293
238
|
imports: [
|
|
294
239
|
{
|
|
295
240
|
specifier: "silgi/runtime",
|
|
@@ -1063,26 +1008,28 @@ async function h3Framework(silgi, skip = false) {
|
|
|
1063
1008
|
""
|
|
1064
1009
|
);
|
|
1065
1010
|
});
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
errors
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
context.event.waitUntil
|
|
1011
|
+
addCoreFile({
|
|
1012
|
+
before: ({ silgiConfigs }) => {
|
|
1013
|
+
silgiConfigs.push({
|
|
1014
|
+
captureError: `(silgi, error, context = {}) => {
|
|
1015
|
+
const promise = silgi.hooks
|
|
1016
|
+
.callHookParallel('error', silgi, error, context)
|
|
1017
|
+
.catch((error_) => {
|
|
1018
|
+
console.error('Error while capturing another error', error_)
|
|
1019
|
+
})
|
|
1020
|
+
|
|
1021
|
+
if (context.event && isEvent(context.event)) {
|
|
1022
|
+
const errors = context.event.context.nitro?.errors
|
|
1023
|
+
if (errors) {
|
|
1024
|
+
errors.push({ error, context })
|
|
1025
|
+
}
|
|
1026
|
+
if (context.event.waitUntil) {
|
|
1027
|
+
context.event.waitUntil(promise)
|
|
1028
|
+
}
|
|
1082
1029
|
}
|
|
1083
|
-
}
|
|
1084
|
-
}
|
|
1085
|
-
}
|
|
1030
|
+
}`
|
|
1031
|
+
});
|
|
1032
|
+
}
|
|
1086
1033
|
});
|
|
1087
1034
|
if (silgi.options.imports !== false) {
|
|
1088
1035
|
const h3Exports = await resolveModuleExportNames("h3", {
|
package/dist/kit/index.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Commands, SilgiCLIHooks, SilgiCLI, ModuleOptionsCustom, ModuleDefinition, SilgiModule, ServiceParseModule, SilgiPreset, SilgiPresetMeta, SilgiTemplate, ResolvedSilgiTemplate, SilgiEvents } from 'silgi/types';
|
|
1
|
+
import { Commands, SilgiCLIHooks, GenImport, SilgiCLI, ModuleOptionsCustom, ModuleDefinition, SilgiModule, ServiceParseModule, SilgiPreset, SilgiPresetMeta, SilgiTemplate, ResolvedSilgiTemplate, SilgiEvents } from 'silgi/types';
|
|
2
2
|
import { Buffer } from 'node:buffer';
|
|
3
3
|
import { ConsolaOptions, ConsolaInstance } from 'consola';
|
|
4
4
|
import * as rfc6902 from 'rfc6902';
|
|
@@ -12,6 +12,16 @@ declare function addCoreFile(data: {
|
|
|
12
12
|
after?: SilgiCLIHooks['after:core.ts'];
|
|
13
13
|
}): Promise<void>;
|
|
14
14
|
|
|
15
|
+
declare function addImports(data: {
|
|
16
|
+
imports?: GenImport[];
|
|
17
|
+
typeImports?: GenImport[];
|
|
18
|
+
}): {
|
|
19
|
+
genImports: GenImport[];
|
|
20
|
+
genTypeImports: GenImport[];
|
|
21
|
+
addImportItem: (data: GenImport | GenImport[]) => void;
|
|
22
|
+
addImportItemType: (data: GenImport | GenImport[]) => void;
|
|
23
|
+
};
|
|
24
|
+
|
|
15
25
|
declare function addNPMPackage(data: {
|
|
16
26
|
name: string;
|
|
17
27
|
version?: string;
|
|
@@ -303,5 +313,5 @@ declare const baseHeaderBannerComment: string[];
|
|
|
303
313
|
declare function processFilePath(src: string): string;
|
|
304
314
|
declare function isPresents(names: PresetName[]): boolean;
|
|
305
315
|
|
|
306
|
-
export { MODE_RE, MigrationStatus, addCommands, addCoreFile, 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 };
|
|
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 };
|
|
307
317
|
export type { FunctionConfig, JsonPatch, MigrationData, MigrationInfo, MigrationOptions, MigrationResult };
|
package/dist/kit/index.mjs
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
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
3
|
import { useSilgiCLI, tryUseSilgiCLI, useSilgi } from 'silgi';
|
|
4
|
+
import { toArray as toArray$1, hash as hash$2 } from 'silgi/kit';
|
|
4
5
|
import { execSync } from 'node:child_process';
|
|
5
6
|
import { pathToFileURL, fileURLToPath } from 'node:url';
|
|
6
7
|
import { resolvePath as resolvePath$1 } from 'mlly';
|
|
@@ -17,7 +18,6 @@ import { defu } from 'defu';
|
|
|
17
18
|
import { c as checkSilgiCompatibility } from '../cli/compatibility.mjs';
|
|
18
19
|
import { withLeadingSlash } from 'ufo';
|
|
19
20
|
import { resolveAlias as resolveAlias$1 } from 'pathe/utils';
|
|
20
|
-
import { hash as hash$2 } from 'silgi/kit';
|
|
21
21
|
import 'unctx';
|
|
22
22
|
import 'semver/functions/satisfies.js';
|
|
23
23
|
import 'silgi/meta';
|
|
@@ -79,6 +79,61 @@ async function addCoreFile(data) {
|
|
|
79
79
|
silgi.hook("after:core.ts", data.after);
|
|
80
80
|
}
|
|
81
81
|
|
|
82
|
+
function addImports(data) {
|
|
83
|
+
const genImports = [
|
|
84
|
+
...data.imports ?? []
|
|
85
|
+
];
|
|
86
|
+
const genTypeImports = [
|
|
87
|
+
...data.typeImports ?? []
|
|
88
|
+
];
|
|
89
|
+
function addImportItem(data2) {
|
|
90
|
+
for (const item of toArray$1(data2)) {
|
|
91
|
+
const isSpecifier = genImports.some((i) => i.specifier === item.specifier);
|
|
92
|
+
if (isSpecifier) {
|
|
93
|
+
const index = genImports.findIndex((i) => i.specifier === item.specifier);
|
|
94
|
+
if (Array.isArray(genImports[index].imports)) {
|
|
95
|
+
genImports[index].imports ??= [];
|
|
96
|
+
genImports[index].imports.push(...toArray$1(item.imports));
|
|
97
|
+
} else {
|
|
98
|
+
genImports[index].imports = item.imports;
|
|
99
|
+
}
|
|
100
|
+
} else {
|
|
101
|
+
genImports.push({
|
|
102
|
+
specifier: item.specifier,
|
|
103
|
+
imports: item.imports,
|
|
104
|
+
options: item.options
|
|
105
|
+
});
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
function addImportItemType(data2) {
|
|
110
|
+
for (const item of toArray$1(data2)) {
|
|
111
|
+
const isSpecifier = genTypeImports.some((i) => i.specifier === item.specifier);
|
|
112
|
+
if (isSpecifier) {
|
|
113
|
+
const index = genTypeImports.findIndex((i) => i.specifier === item.specifier);
|
|
114
|
+
if (Array.isArray(genTypeImports[index].imports)) {
|
|
115
|
+
genTypeImports[index].imports ??= [];
|
|
116
|
+
genTypeImports[index].imports.push(...toArray$1(item.imports));
|
|
117
|
+
} else {
|
|
118
|
+
genTypeImports[index].imports = item.imports;
|
|
119
|
+
}
|
|
120
|
+
} else {
|
|
121
|
+
genTypeImports.push({
|
|
122
|
+
specifier: item.specifier,
|
|
123
|
+
imports: item.imports,
|
|
124
|
+
options: item.options
|
|
125
|
+
});
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
return {
|
|
130
|
+
genImports,
|
|
131
|
+
genTypeImports,
|
|
132
|
+
addImportItem,
|
|
133
|
+
addImportItemType
|
|
134
|
+
};
|
|
135
|
+
}
|
|
136
|
+
|
|
82
137
|
const delay = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
|
|
83
138
|
async function addNPMPackage(data) {
|
|
84
139
|
const silgi = useSilgiCLI$1();
|
|
@@ -973,4 +1028,4 @@ function isValidIp(ip) {
|
|
|
973
1028
|
return false;
|
|
974
1029
|
}
|
|
975
1030
|
|
|
976
|
-
export { MODE_RE, MigrationStatus, addCommands, addCoreFile, 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 };
|
|
1031
|
+
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 };
|