silgi 0.26.0 → 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/package.json +1 -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);
|