silgi 0.29.14 → 0.29.16
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/install.mjs +25 -26
- package/dist/cli/silgi.mjs +63 -115
- package/dist/kit/index.d.mts +12 -2
- package/dist/kit/index.mjs +57 -2
- package/dist/types/index.d.mts +19 -17
- package/package.json +1 -1
package/dist/cli/index.mjs
CHANGED
package/dist/cli/install.mjs
CHANGED
|
@@ -1,16 +1,15 @@
|
|
|
1
1
|
import { execSync } from 'node:child_process';
|
|
2
|
-
import { readFileSync } from 'node:fs';
|
|
3
2
|
import { defineCommand, runCommand } from 'citty';
|
|
4
3
|
import { consola } from 'consola';
|
|
5
|
-
import { resolve } from 'pathe';
|
|
6
4
|
import { version } from 'silgi/meta';
|
|
7
5
|
import { addNPMPackage, addTemplate } from 'silgi/kit';
|
|
8
6
|
import { u as useSilgiCLI } from '../_chunks/silgiApp.mjs';
|
|
9
7
|
import { c as commonArgs, p as prepare } from './prepare.mjs';
|
|
10
|
-
import { l as loadOptions } from './types.mjs';
|
|
11
8
|
import 'unctx';
|
|
9
|
+
import 'pathe';
|
|
12
10
|
import './silgi.mjs';
|
|
13
11
|
import 'apiful/openapi';
|
|
12
|
+
import 'node:fs';
|
|
14
13
|
import 'node:fs/promises';
|
|
15
14
|
import 'knitwork';
|
|
16
15
|
import 'mlly';
|
|
@@ -18,17 +17,25 @@ import 'pathe/utils';
|
|
|
18
17
|
import 'silgi/runtime/meta';
|
|
19
18
|
import 'unimport';
|
|
20
19
|
import 'untyped';
|
|
20
|
+
import './types.mjs';
|
|
21
|
+
import 'c12';
|
|
22
|
+
import 'compatx';
|
|
23
|
+
import 'klona/full';
|
|
24
|
+
import 'std-env';
|
|
25
|
+
import 'consola/utils';
|
|
26
|
+
import 'escape-string-regexp';
|
|
27
|
+
import 'pkg-types';
|
|
28
|
+
import 'ufo';
|
|
29
|
+
import 'defu';
|
|
21
30
|
import 'hookable';
|
|
22
31
|
import 'silgi';
|
|
23
32
|
import '../_chunks/routeRules.mjs';
|
|
24
|
-
import 'ufo';
|
|
25
33
|
import '@clack/prompts';
|
|
26
34
|
import 'dotenv';
|
|
27
35
|
import 'dev-jiti';
|
|
28
36
|
import './compatibility.mjs';
|
|
29
37
|
import 'semver/functions/satisfies.js';
|
|
30
38
|
import 'node:url';
|
|
31
|
-
import 'defu';
|
|
32
39
|
import 'exsolve';
|
|
33
40
|
import 'globby';
|
|
34
41
|
import 'ignore';
|
|
@@ -37,13 +44,6 @@ import 'klona';
|
|
|
37
44
|
import 'silgi/runtime';
|
|
38
45
|
import 'unstorage';
|
|
39
46
|
import 'scule';
|
|
40
|
-
import 'c12';
|
|
41
|
-
import 'compatx';
|
|
42
|
-
import 'klona/full';
|
|
43
|
-
import 'std-env';
|
|
44
|
-
import 'consola/utils';
|
|
45
|
-
import 'escape-string-regexp';
|
|
46
|
-
import 'pkg-types';
|
|
47
47
|
|
|
48
48
|
async function installPackages(silgi = useSilgiCLI()) {
|
|
49
49
|
await addNPMPackage([
|
|
@@ -75,12 +75,15 @@ async function installPackages(silgi = useSilgiCLI()) {
|
|
|
75
75
|
};
|
|
76
76
|
packages.dependencies = {};
|
|
77
77
|
}
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
78
|
+
if (silgi.options.debug === true || silgi.options.debug.install) {
|
|
79
|
+
addTemplate({
|
|
80
|
+
filename: "install.json",
|
|
81
|
+
where: ".silgi",
|
|
82
|
+
write: true,
|
|
83
|
+
getContents: () => JSON.stringify(packages, null, 2)
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
return packages;
|
|
84
87
|
}
|
|
85
88
|
|
|
86
89
|
const install = defineCommand({
|
|
@@ -101,14 +104,10 @@ const install = defineCommand({
|
|
|
101
104
|
rawArgs: ["--commandType", "install"]
|
|
102
105
|
}).catch(() => {
|
|
103
106
|
});
|
|
104
|
-
await installPackages();
|
|
105
|
-
const silgiConfig = await loadOptions({});
|
|
107
|
+
const packages = await installPackages();
|
|
106
108
|
const commandArgs = process.argv.slice(process.argv.indexOf("install") + 1);
|
|
107
109
|
const extraArgs = commandArgs.length ? ` ${commandArgs.join(" ")}` : "";
|
|
108
|
-
|
|
109
|
-
const cli = readFileSync(getCli, "utf-8");
|
|
110
|
-
const cliJson = JSON.parse(cli);
|
|
111
|
-
if (Object.keys(cliJson).length === 0) {
|
|
110
|
+
if (Object.keys(packages).length === 0) {
|
|
112
111
|
consola.info("Empty command list, maybe forgot pnpm silgi prepare?");
|
|
113
112
|
return;
|
|
114
113
|
}
|
|
@@ -116,8 +115,8 @@ const install = defineCommand({
|
|
|
116
115
|
const cleanVersion = version.replace(/^[>=]+\s*/, "^");
|
|
117
116
|
return `${name}@${cleanVersion}`;
|
|
118
117
|
};
|
|
119
|
-
const deps = Object.entries(
|
|
120
|
-
const devDeps = Object.entries(
|
|
118
|
+
const deps = Object.entries(packages.dependencies || {}).map(([name, version]) => cleanPackageName(name, version)).join(" ");
|
|
119
|
+
const devDeps = Object.entries(packages.devDependencies || {}).map(([name, version]) => cleanPackageName(name, version)).join(" ");
|
|
121
120
|
if (deps) {
|
|
122
121
|
consola.info("Installing dependencies...");
|
|
123
122
|
execSync(`ni ${deps}${extraArgs}`, { stdio: "inherit" });
|
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, baseHeaderBannerComment, 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';
|
|
@@ -230,66 +230,12 @@ async function prepareConfigs(silgi) {
|
|
|
230
230
|
]
|
|
231
231
|
)
|
|
232
232
|
)}`);
|
|
233
|
+
importData.unshift(...baseHeaderBannerComment);
|
|
233
234
|
return importData;
|
|
234
235
|
}
|
|
235
236
|
|
|
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
237
|
async function prepareCoreFile(silgi) {
|
|
292
|
-
const { genImports, genTypeImports, addImportItem, addImportItemType } =
|
|
238
|
+
const { genImports, genTypeImports, addImportItem, addImportItemType } = addImports({
|
|
293
239
|
imports: [
|
|
294
240
|
{
|
|
295
241
|
specifier: "silgi/runtime",
|
|
@@ -433,6 +379,7 @@ async function prepareCoreFile(silgi) {
|
|
|
433
379
|
];
|
|
434
380
|
await silgi.callHook("after:core.ts", importData);
|
|
435
381
|
importData.unshift(...importsContent);
|
|
382
|
+
importData.unshift(...baseHeaderBannerComment);
|
|
436
383
|
return importData;
|
|
437
384
|
}
|
|
438
385
|
|
|
@@ -2004,36 +1951,39 @@ ${injectedResult.code}`;
|
|
|
2004
1951
|
}
|
|
2005
1952
|
|
|
2006
1953
|
async function prepareServerFiles(silgi) {
|
|
2007
|
-
const
|
|
2008
|
-
|
|
2009
|
-
|
|
2010
|
-
|
|
2011
|
-
|
|
2012
|
-
|
|
2013
|
-
|
|
2014
|
-
|
|
2015
|
-
|
|
2016
|
-
|
|
2017
|
-
|
|
2018
|
-
|
|
2019
|
-
|
|
2020
|
-
|
|
2021
|
-
|
|
2022
|
-
|
|
2023
|
-
|
|
2024
|
-
|
|
2025
|
-
|
|
2026
|
-
|
|
2027
|
-
|
|
2028
|
-
|
|
2029
|
-
|
|
2030
|
-
|
|
2031
|
-
|
|
2032
|
-
|
|
2033
|
-
|
|
2034
|
-
|
|
2035
|
-
|
|
2036
|
-
|
|
1954
|
+
const { genImports, genTypeImports, addImportItem, addImportItemType } = addImports({
|
|
1955
|
+
imports: [
|
|
1956
|
+
{
|
|
1957
|
+
specifier: "silgi",
|
|
1958
|
+
imports: [
|
|
1959
|
+
{
|
|
1960
|
+
name: "createSilgi"
|
|
1961
|
+
}
|
|
1962
|
+
]
|
|
1963
|
+
},
|
|
1964
|
+
{
|
|
1965
|
+
specifier: "./configs",
|
|
1966
|
+
imports: [
|
|
1967
|
+
{
|
|
1968
|
+
name: "cliConfigs"
|
|
1969
|
+
}
|
|
1970
|
+
]
|
|
1971
|
+
}
|
|
1972
|
+
],
|
|
1973
|
+
typeImports: [
|
|
1974
|
+
{
|
|
1975
|
+
specifier: "silgi/types",
|
|
1976
|
+
imports: [
|
|
1977
|
+
{
|
|
1978
|
+
name: "SilgiRuntimeOptions"
|
|
1979
|
+
},
|
|
1980
|
+
{
|
|
1981
|
+
name: "FrameworkContext"
|
|
1982
|
+
}
|
|
1983
|
+
]
|
|
1984
|
+
}
|
|
1985
|
+
]
|
|
1986
|
+
});
|
|
2037
1987
|
const scanned = {
|
|
2038
1988
|
uris: {},
|
|
2039
1989
|
services: [],
|
|
@@ -2044,8 +1994,8 @@ async function prepareServerFiles(silgi) {
|
|
|
2044
1994
|
],
|
|
2045
1995
|
schemas: [],
|
|
2046
1996
|
modulesURIs: {},
|
|
2047
|
-
|
|
2048
|
-
|
|
1997
|
+
addImportItem,
|
|
1998
|
+
addImportItemType
|
|
2049
1999
|
};
|
|
2050
2000
|
if (silgi.uris) {
|
|
2051
2001
|
defu(scanned.uris, silgi.uris);
|
|
@@ -2054,30 +2004,37 @@ async function prepareServerFiles(silgi) {
|
|
|
2054
2004
|
defu(scanned.modulesURIs, silgi.modulesURIs);
|
|
2055
2005
|
}
|
|
2056
2006
|
await silgi.callHook("prepare:scan.ts", scanned);
|
|
2057
|
-
if (importItems["#silgi/vfs"].import.length === 0) {
|
|
2058
|
-
delete importItems["#silgi/vfs"];
|
|
2059
|
-
}
|
|
2060
2007
|
if (scanned.services.length > 0) {
|
|
2061
|
-
|
|
2008
|
+
addImportItem({
|
|
2009
|
+
specifier: "silgi",
|
|
2010
|
+
imports: {
|
|
2011
|
+
name: "mergeServices"
|
|
2012
|
+
}
|
|
2013
|
+
});
|
|
2062
2014
|
}
|
|
2063
2015
|
if (scanned.shareds.length > 0) {
|
|
2064
|
-
|
|
2016
|
+
addImportItem({
|
|
2017
|
+
specifier: "silgi",
|
|
2018
|
+
imports: {
|
|
2019
|
+
name: "mergeShared"
|
|
2020
|
+
}
|
|
2021
|
+
});
|
|
2065
2022
|
}
|
|
2066
2023
|
if (scanned.schemas.length > 0) {
|
|
2067
|
-
|
|
2068
|
-
|
|
2069
|
-
|
|
2070
|
-
|
|
2024
|
+
addImportItem({
|
|
2025
|
+
specifier: "silgi",
|
|
2026
|
+
imports: {
|
|
2027
|
+
name: "mergeSchemas"
|
|
2028
|
+
}
|
|
2029
|
+
});
|
|
2071
2030
|
}
|
|
2072
2031
|
const importsContent = [
|
|
2073
|
-
...
|
|
2074
|
-
|
|
2075
|
-
|
|
2076
|
-
|
|
2077
|
-
return
|
|
2032
|
+
...genImports.map(({ specifier, imports, options }) => {
|
|
2033
|
+
return genImport(specifier, imports, options);
|
|
2034
|
+
}),
|
|
2035
|
+
...genTypeImports.map(({ specifier, imports }) => {
|
|
2036
|
+
return genTypeImport(specifier, Array.isArray(imports) ? imports : [imports]);
|
|
2078
2037
|
}),
|
|
2079
|
-
"",
|
|
2080
|
-
...scanned.customImports,
|
|
2081
2038
|
""
|
|
2082
2039
|
];
|
|
2083
2040
|
const importData = [
|
|
@@ -2106,18 +2063,9 @@ async function prepareServerFiles(silgi) {
|
|
|
2106
2063
|
];
|
|
2107
2064
|
await silgi.callHook("after:prepare:scan.ts", importData);
|
|
2108
2065
|
importData.unshift(...importsContent);
|
|
2066
|
+
importData.unshift(...baseHeaderBannerComment);
|
|
2109
2067
|
return importData;
|
|
2110
2068
|
}
|
|
2111
|
-
function deduplicateImportsByKey(imports) {
|
|
2112
|
-
const seenKeys = /* @__PURE__ */ new Map();
|
|
2113
|
-
return imports.filter((item) => {
|
|
2114
|
-
if (seenKeys.has(item.key)) {
|
|
2115
|
-
return false;
|
|
2116
|
-
}
|
|
2117
|
-
seenKeys.set(item.key, true);
|
|
2118
|
-
return true;
|
|
2119
|
-
});
|
|
2120
|
-
}
|
|
2121
2069
|
|
|
2122
2070
|
async function writeScanFiles(silgi) {
|
|
2123
2071
|
const data = await prepareServerFiles(silgi);
|
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 };
|
package/dist/types/index.d.mts
CHANGED
|
@@ -203,14 +203,29 @@ interface SilgiCLIHooks extends SilgiHooks {
|
|
|
203
203
|
declarations: string[];
|
|
204
204
|
tsConfig: TSConfig;
|
|
205
205
|
}) => HookResult;
|
|
206
|
-
'before:core.ts': (data:
|
|
206
|
+
'before:core.ts': (data: {
|
|
207
|
+
silgiConfigs: Record<string, any>[];
|
|
208
|
+
addImportItem: (data: GenImport | GenImport[]) => void;
|
|
209
|
+
addImportItemType: (data: GenImport | GenImport[]) => void;
|
|
210
|
+
addBuildFunction: (data: {
|
|
211
|
+
name: string;
|
|
212
|
+
params?: string[];
|
|
213
|
+
where: 'before' | 'after';
|
|
214
|
+
}[] | {
|
|
215
|
+
name: string;
|
|
216
|
+
params?: string[];
|
|
217
|
+
where: 'before' | 'after';
|
|
218
|
+
}) => void;
|
|
219
|
+
}) => HookResult;
|
|
207
220
|
'after:core.ts': (content: string[]) => HookResult;
|
|
208
|
-
'prepare:scan.ts': (data:
|
|
221
|
+
'prepare:scan.ts': (data: {
|
|
209
222
|
uris: Record<string, string>;
|
|
210
223
|
services: string[];
|
|
211
224
|
shareds: string[];
|
|
212
225
|
schemas: string[];
|
|
213
226
|
modulesURIs: Record<string, string>;
|
|
227
|
+
addImportItem: (data: GenImport | GenImport[]) => void;
|
|
228
|
+
addImportItemType: (data: GenImport | GenImport[]) => void;
|
|
214
229
|
}) => HookResult;
|
|
215
230
|
'after:prepare:scan.ts': (content: string[]) => HookResult;
|
|
216
231
|
'prepare:schema.ts': (options: {
|
|
@@ -293,20 +308,6 @@ interface SilgiHooks {
|
|
|
293
308
|
interface GenerateAppOptions {
|
|
294
309
|
filter?: (template: ResolvedSilgiTemplate<any>) => boolean;
|
|
295
310
|
}
|
|
296
|
-
interface PrepareCore {
|
|
297
|
-
silgiConfigs: Record<string, any>[];
|
|
298
|
-
addImportItem: (data: GenImport | GenImport[]) => void;
|
|
299
|
-
addImportItemType: (data: GenImport | GenImport[]) => void;
|
|
300
|
-
addBuildFunction: (data: {
|
|
301
|
-
name: string;
|
|
302
|
-
params?: string[];
|
|
303
|
-
where: 'before' | 'after';
|
|
304
|
-
}[] | {
|
|
305
|
-
name: string;
|
|
306
|
-
params?: string[];
|
|
307
|
-
where: 'before' | 'after';
|
|
308
|
-
}) => void;
|
|
309
|
-
}
|
|
310
311
|
|
|
311
312
|
/**
|
|
312
313
|
* Bu nitrojs, h3 event or request context.
|
|
@@ -621,6 +622,7 @@ interface SilgiCLIOptions extends PresetOptions {
|
|
|
621
622
|
isPreparingModules: boolean;
|
|
622
623
|
debug: true | {
|
|
623
624
|
command?: boolean;
|
|
625
|
+
install?: boolean;
|
|
624
626
|
};
|
|
625
627
|
preset: PresetName;
|
|
626
628
|
static: boolean;
|
|
@@ -1194,4 +1196,4 @@ interface ServiceParseModule {
|
|
|
1194
1196
|
(params: ServiceParse): Awaited<void> | void;
|
|
1195
1197
|
}
|
|
1196
1198
|
|
|
1197
|
-
export type { AllPaths, AppConfig, Awaitable, BaseNamespaceType, BaseSchemaType, BaseSilgiMethodType, BuildSilgi, CaptureError, CapturedErrorContext, CommandType, Commands, CreateScope, DeepPartial, DeepRequired, DefaultHooks, DefaultNamespaces, DefaultRouteConfig, DefaultRouteRules, DotenvOptions, EnvOptions, EventHandlerResponse, ExtendContext, ExtendShared, ExtractInputFromURI, ExtractOutputFromURI, ExtractPathParams, ExtractPathParamsFromURI, ExtractQueryParamsFromURI, ExtractSourceFromURI, FrameworkContext, GenImport, GenerateAppOptions, GraphQLJSON, HookResult, HttpMethod, ImportItem, LoadConfigOptions, MergedSilgiSchema, MethodHandlerType, ModuleDefinition, ModuleHookContext, ModuleMeta, ModuleOptionsCustom, ModuleSetupInstallResult, ModuleSetupReturn, Namespaces, NitroBuildInfo,
|
|
1199
|
+
export type { AllPaths, AppConfig, Awaitable, BaseNamespaceType, BaseSchemaType, BaseSilgiMethodType, BuildSilgi, CaptureError, CapturedErrorContext, CommandType, Commands, CreateScope, DeepPartial, DeepRequired, DefaultHooks, DefaultNamespaces, DefaultRouteConfig, DefaultRouteRules, DotenvOptions, EnvOptions, EventHandlerResponse, ExtendContext, ExtendShared, ExtractInputFromURI, ExtractOutputFromURI, ExtractPathParams, ExtractPathParamsFromURI, ExtractQueryParamsFromURI, ExtractSourceFromURI, FrameworkContext, GenImport, GenerateAppOptions, GraphQLJSON, HookResult, HttpMethod, ImportItem, LoadConfigOptions, MergedSilgiSchema, MethodHandlerType, ModuleDefinition, ModuleHookContext, ModuleMeta, ModuleOptionsCustom, ModuleSetupInstallResult, ModuleSetupReturn, Namespaces, NitroBuildInfo, RequiredServiceType, ResolvedMethodHandlerType, ResolvedModuleMeta, ResolvedModuleOptions, ResolvedServiceType, ResolvedSilgiTemplate, RouteRules, RouterParams, ScanFile, ServiceParse, ServiceParseModule, ServiceType, Silgi, SilgiAppPlugin, SilgiCLI, SilgiCLIConfig, SilgiCLIDynamicConfig, SilgiCLIHooks, SilgiCLIOptions, SilgiCommands, SilgiCompatibility, SilgiCompatibilityIssue, SilgiCompatibilityIssues, SilgiConfig, SilgiEvents, SilgiFetchClient, SilgiFetchOptions, SilgiFrameworkInfo, SilgiFunction, SilgiHooks, SilgiModule, SilgiModuleInput, SilgiModuleOptions, SilgiNamespaces, SilgiOperation, SilgiOptions, SilgiPreset, SilgiPresetMeta, SilgiRouteRules, SilgiRouterTypes, SilgiRuntimeActions, SilgiRuntimeConfig, SilgiRuntimeContext, SilgiRuntimeHooks, SilgiRuntimeMethods, SilgiRuntimeOptions, SilgiRuntimeRouteRules, SilgiRuntimeRouteRulesConfig, SilgiRuntimeShareds, SilgiRuntimeSharedsExtend, SilgiSchema, SilgiServiceInterface, SilgiStorageBase, SilgiTemplate, SilgiURIs, StorageConfig, StorageKeyGenerator, StorageKeyParams, StorageMounts, TSReference, TrimAfterFourSlashes, URIsTypes };
|