silgi 0.25.20 → 0.26.1
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/dev.mjs +1 -0
- package/dist/cli/index.mjs +1 -1
- package/dist/cli/init.mjs +1 -0
- package/dist/cli/install.mjs +1 -0
- package/dist/cli/prepare.mjs +38 -1
- package/dist/types/index.d.mts +2 -0
- package/package.json +2 -1
package/dist/cli/dev.mjs
CHANGED
package/dist/cli/index.mjs
CHANGED
package/dist/cli/init.mjs
CHANGED
package/dist/cli/install.mjs
CHANGED
package/dist/cli/prepare.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { defineCommand, runCommand } from 'citty';
|
|
2
|
-
import { resolve } from 'pathe';
|
|
2
|
+
import { resolve, join } from 'pathe';
|
|
3
3
|
import { version } from 'silgi/meta';
|
|
4
4
|
import { d as prepareEnv, c as createSilgiCLI, a as prepare$2, b as writeTypesAndFiles, w as writeCoreFile, p as prepareBuild } from './writeTypesAndFiles.mjs';
|
|
5
5
|
import { execSync } from 'node:child_process';
|
|
@@ -10,6 +10,8 @@ import { createJiti } from 'dev-jiti';
|
|
|
10
10
|
import color from 'picocolors';
|
|
11
11
|
import { useSilgiCLI } from 'silgi';
|
|
12
12
|
import { a as silgiCLIIClose } from '../_chunks/silgiApp.mjs';
|
|
13
|
+
import { generateDTS } from 'apiful/openapi';
|
|
14
|
+
import { hasSilgiModule, addTemplate } from 'silgi/kit';
|
|
13
15
|
import { l as loadOptions } from './types.mjs';
|
|
14
16
|
|
|
15
17
|
const commonArgs = {
|
|
@@ -187,6 +189,40 @@ const run$1 = {
|
|
|
187
189
|
default: run
|
|
188
190
|
};
|
|
189
191
|
|
|
192
|
+
async function generateApiFul(silgi) {
|
|
193
|
+
const config = silgi.options.apiFul;
|
|
194
|
+
if (!config || hasSilgiModule("openapi")) {
|
|
195
|
+
config.services = config?.services ?? {};
|
|
196
|
+
config.services = {
|
|
197
|
+
silgi: {
|
|
198
|
+
schema: join(silgi.options.build.dir, "openapi.json")
|
|
199
|
+
}
|
|
200
|
+
};
|
|
201
|
+
}
|
|
202
|
+
const resolvedOpenAPIServices = Object.fromEntries(
|
|
203
|
+
Object.entries(config?.services ?? {}).filter(([, service]) => Boolean(service.schema))
|
|
204
|
+
);
|
|
205
|
+
if (Object.keys(resolvedOpenAPIServices).length === 0) {
|
|
206
|
+
consola.info("No OpenAPI schemas found, skipping generation");
|
|
207
|
+
return;
|
|
208
|
+
}
|
|
209
|
+
for (const service of Object.values(resolvedOpenAPIServices)) {
|
|
210
|
+
if (typeof service.schema === "string" && !service.schema.startsWith("http")) {
|
|
211
|
+
service.schema = resolve(silgi.options.rootDir, service.schema);
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
const types = await generateDTS(resolvedOpenAPIServices);
|
|
215
|
+
silgi.hook("prepare:types", (opts) => {
|
|
216
|
+
opts.references.push({ path: "./apiful.d.ts" });
|
|
217
|
+
});
|
|
218
|
+
addTemplate({
|
|
219
|
+
filename: "types/apiful.d.ts",
|
|
220
|
+
where: ".silgi",
|
|
221
|
+
write: true,
|
|
222
|
+
getContents: () => types
|
|
223
|
+
});
|
|
224
|
+
}
|
|
225
|
+
|
|
190
226
|
const prepare = defineCommand({
|
|
191
227
|
meta: {
|
|
192
228
|
name: "prepare",
|
|
@@ -227,6 +263,7 @@ const prepare = defineCommand({
|
|
|
227
263
|
activeEnvironment: args.env
|
|
228
264
|
});
|
|
229
265
|
await prepare$2();
|
|
266
|
+
await generateApiFul(silgi);
|
|
230
267
|
await writeTypesAndFiles(silgi);
|
|
231
268
|
await writeCoreFile(silgi);
|
|
232
269
|
await prepareBuild(silgi);
|
package/dist/types/index.d.mts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { ApifulConfig } from 'apiful/config';
|
|
1
2
|
import { C12InputConfig, ResolvedConfig, ConfigWatcher, WatchConfigOptions } from 'c12';
|
|
2
3
|
import { ChokidarOptions } from 'chokidar';
|
|
3
4
|
import { DateString, CompatibilityDateSpec, CompatibilityDates } from 'compatx';
|
|
@@ -801,6 +802,7 @@ interface SilgiCLIOptions extends PresetOptions {
|
|
|
801
802
|
description?: string;
|
|
802
803
|
}>>;
|
|
803
804
|
installPackages: Record<'dependencies' | 'devDependencies', Record<string, string>>;
|
|
805
|
+
apiFul: ApifulConfig;
|
|
804
806
|
}
|
|
805
807
|
/**
|
|
806
808
|
* Silgi input config (silgi.config)
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "silgi",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.26.1",
|
|
5
5
|
"private": false,
|
|
6
6
|
"sideEffects": false,
|
|
7
7
|
"exports": {
|
|
@@ -71,6 +71,7 @@
|
|
|
71
71
|
"@fastify/deepmerge": "^3.1.0",
|
|
72
72
|
"@oxc-parser/wasm": "^0.60.0",
|
|
73
73
|
"@standard-schema/spec": "^1.0.0",
|
|
74
|
+
"apiful": "^2.0.2",
|
|
74
75
|
"c12": "^3.0.3",
|
|
75
76
|
"chokidar": "^4.0.3",
|
|
76
77
|
"citty": "^0.1.6",
|