silgi 0.29.15 → 0.29.17
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 +70 -66
- package/dist/kit/index.d.mts +1 -1
- package/dist/kit/index.mjs +2 -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, addImports, hash, toArray, writeFile, relativeWithDot, isDirectory, addCoreFile, resolveAlias as resolveAlias$1, directoryToURL, hasError, parseServices, resolveSilgiPath } from 'silgi/kit';
|
|
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,6 +230,7 @@ async function prepareConfigs(silgi) {
|
|
|
230
230
|
]
|
|
231
231
|
)
|
|
232
232
|
)}`);
|
|
233
|
+
importData.unshift(...baseHeaderBannerComment);
|
|
233
234
|
return importData;
|
|
234
235
|
}
|
|
235
236
|
|
|
@@ -378,6 +379,7 @@ async function prepareCoreFile(silgi) {
|
|
|
378
379
|
];
|
|
379
380
|
await silgi.callHook("after:core.ts", importData);
|
|
380
381
|
importData.unshift(...importsContent);
|
|
382
|
+
importData.unshift(...baseHeaderBannerComment);
|
|
381
383
|
return importData;
|
|
382
384
|
}
|
|
383
385
|
|
|
@@ -1804,13 +1806,14 @@ async function scanExportFile(silgi) {
|
|
|
1804
1806
|
if (type === "schema") {
|
|
1805
1807
|
options.schemas.push(_name);
|
|
1806
1808
|
}
|
|
1807
|
-
options.
|
|
1808
|
-
|
|
1809
|
-
|
|
1810
|
-
|
|
1811
|
-
|
|
1812
|
-
|
|
1813
|
-
|
|
1809
|
+
options.addImportItem({
|
|
1810
|
+
specifier: relativeWithDot(silgi.options.silgi.serverDir, path),
|
|
1811
|
+
imports: [
|
|
1812
|
+
{
|
|
1813
|
+
name: exportName,
|
|
1814
|
+
as: _name
|
|
1815
|
+
}
|
|
1816
|
+
]
|
|
1814
1817
|
});
|
|
1815
1818
|
}
|
|
1816
1819
|
});
|
|
@@ -1949,36 +1952,39 @@ ${injectedResult.code}`;
|
|
|
1949
1952
|
}
|
|
1950
1953
|
|
|
1951
1954
|
async function prepareServerFiles(silgi) {
|
|
1952
|
-
const
|
|
1953
|
-
|
|
1954
|
-
|
|
1955
|
-
|
|
1956
|
-
|
|
1957
|
-
|
|
1958
|
-
|
|
1959
|
-
|
|
1960
|
-
|
|
1961
|
-
|
|
1962
|
-
|
|
1963
|
-
|
|
1964
|
-
|
|
1965
|
-
|
|
1966
|
-
|
|
1967
|
-
|
|
1968
|
-
|
|
1969
|
-
|
|
1970
|
-
|
|
1971
|
-
|
|
1972
|
-
|
|
1973
|
-
|
|
1974
|
-
|
|
1975
|
-
|
|
1976
|
-
|
|
1977
|
-
|
|
1978
|
-
|
|
1979
|
-
|
|
1980
|
-
|
|
1981
|
-
|
|
1955
|
+
const { genImports, genTypeImports, addImportItem, addImportItemType } = addImports({
|
|
1956
|
+
imports: [
|
|
1957
|
+
{
|
|
1958
|
+
specifier: "silgi",
|
|
1959
|
+
imports: [
|
|
1960
|
+
{
|
|
1961
|
+
name: "createSilgi"
|
|
1962
|
+
}
|
|
1963
|
+
]
|
|
1964
|
+
},
|
|
1965
|
+
{
|
|
1966
|
+
specifier: "./configs",
|
|
1967
|
+
imports: [
|
|
1968
|
+
{
|
|
1969
|
+
name: "cliConfigs"
|
|
1970
|
+
}
|
|
1971
|
+
]
|
|
1972
|
+
}
|
|
1973
|
+
],
|
|
1974
|
+
typeImports: [
|
|
1975
|
+
{
|
|
1976
|
+
specifier: "silgi/types",
|
|
1977
|
+
imports: [
|
|
1978
|
+
{
|
|
1979
|
+
name: "SilgiRuntimeOptions"
|
|
1980
|
+
},
|
|
1981
|
+
{
|
|
1982
|
+
name: "FrameworkContext"
|
|
1983
|
+
}
|
|
1984
|
+
]
|
|
1985
|
+
}
|
|
1986
|
+
]
|
|
1987
|
+
});
|
|
1982
1988
|
const scanned = {
|
|
1983
1989
|
uris: {},
|
|
1984
1990
|
services: [],
|
|
@@ -1989,8 +1995,8 @@ async function prepareServerFiles(silgi) {
|
|
|
1989
1995
|
],
|
|
1990
1996
|
schemas: [],
|
|
1991
1997
|
modulesURIs: {},
|
|
1992
|
-
|
|
1993
|
-
|
|
1998
|
+
addImportItem,
|
|
1999
|
+
addImportItemType
|
|
1994
2000
|
};
|
|
1995
2001
|
if (silgi.uris) {
|
|
1996
2002
|
defu(scanned.uris, silgi.uris);
|
|
@@ -1999,30 +2005,37 @@ async function prepareServerFiles(silgi) {
|
|
|
1999
2005
|
defu(scanned.modulesURIs, silgi.modulesURIs);
|
|
2000
2006
|
}
|
|
2001
2007
|
await silgi.callHook("prepare:scan.ts", scanned);
|
|
2002
|
-
if (importItems["#silgi/vfs"].import.length === 0) {
|
|
2003
|
-
delete importItems["#silgi/vfs"];
|
|
2004
|
-
}
|
|
2005
2008
|
if (scanned.services.length > 0) {
|
|
2006
|
-
|
|
2009
|
+
addImportItem({
|
|
2010
|
+
specifier: "silgi",
|
|
2011
|
+
imports: {
|
|
2012
|
+
name: "mergeServices"
|
|
2013
|
+
}
|
|
2014
|
+
});
|
|
2007
2015
|
}
|
|
2008
2016
|
if (scanned.shareds.length > 0) {
|
|
2009
|
-
|
|
2017
|
+
addImportItem({
|
|
2018
|
+
specifier: "silgi",
|
|
2019
|
+
imports: {
|
|
2020
|
+
name: "mergeShared"
|
|
2021
|
+
}
|
|
2022
|
+
});
|
|
2010
2023
|
}
|
|
2011
2024
|
if (scanned.schemas.length > 0) {
|
|
2012
|
-
|
|
2013
|
-
|
|
2014
|
-
|
|
2015
|
-
|
|
2025
|
+
addImportItem({
|
|
2026
|
+
specifier: "silgi",
|
|
2027
|
+
imports: {
|
|
2028
|
+
name: "mergeSchemas"
|
|
2029
|
+
}
|
|
2030
|
+
});
|
|
2016
2031
|
}
|
|
2017
2032
|
const importsContent = [
|
|
2018
|
-
...
|
|
2019
|
-
|
|
2020
|
-
|
|
2021
|
-
|
|
2022
|
-
return
|
|
2033
|
+
...genImports.map(({ specifier, imports, options }) => {
|
|
2034
|
+
return genImport(specifier, imports, options);
|
|
2035
|
+
}),
|
|
2036
|
+
...genTypeImports.map(({ specifier, imports }) => {
|
|
2037
|
+
return genTypeImport(specifier, Array.isArray(imports) ? imports : [imports]);
|
|
2023
2038
|
}),
|
|
2024
|
-
"",
|
|
2025
|
-
...scanned.customImports,
|
|
2026
2039
|
""
|
|
2027
2040
|
];
|
|
2028
2041
|
const importData = [
|
|
@@ -2051,18 +2064,9 @@ async function prepareServerFiles(silgi) {
|
|
|
2051
2064
|
];
|
|
2052
2065
|
await silgi.callHook("after:prepare:scan.ts", importData);
|
|
2053
2066
|
importData.unshift(...importsContent);
|
|
2067
|
+
importData.unshift(...baseHeaderBannerComment);
|
|
2054
2068
|
return importData;
|
|
2055
2069
|
}
|
|
2056
|
-
function deduplicateImportsByKey(imports) {
|
|
2057
|
-
const seenKeys = /* @__PURE__ */ new Map();
|
|
2058
|
-
return imports.filter((item) => {
|
|
2059
|
-
if (seenKeys.has(item.key)) {
|
|
2060
|
-
return false;
|
|
2061
|
-
}
|
|
2062
|
-
seenKeys.set(item.key, true);
|
|
2063
|
-
return true;
|
|
2064
|
-
});
|
|
2065
|
-
}
|
|
2066
2070
|
|
|
2067
2071
|
async function writeScanFiles(silgi) {
|
|
2068
2072
|
const data = await prepareServerFiles(silgi);
|
package/dist/kit/index.d.mts
CHANGED
package/dist/kit/index.mjs
CHANGED
|
@@ -81,10 +81,10 @@ async function addCoreFile(data) {
|
|
|
81
81
|
|
|
82
82
|
function addImports(data) {
|
|
83
83
|
const genImports = [
|
|
84
|
-
...data
|
|
84
|
+
...data?.imports ?? []
|
|
85
85
|
];
|
|
86
86
|
const genTypeImports = [
|
|
87
|
-
...data
|
|
87
|
+
...data?.typeImports ?? []
|
|
88
88
|
];
|
|
89
89
|
function addImportItem(data2) {
|
|
90
90
|
for (const item of toArray$1(data2)) {
|
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 };
|