silgi 0.26.5 → 0.26.6
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 +39 -2
- 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,17 +1,53 @@
|
|
|
1
1
|
import { defineCommand, runCommand } from 'citty';
|
|
2
|
-
import { resolve } from 'pathe';
|
|
2
|
+
import { join, resolve } 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, g as generateApp } from './writeTypesAndFiles.mjs';
|
|
5
|
+
import { generateDTS } from 'apiful/openapi';
|
|
6
|
+
import { consola } from 'consola';
|
|
7
|
+
import { hasSilgiModule, addTemplate } from 'silgi/kit';
|
|
5
8
|
import { execSync } from 'node:child_process';
|
|
6
9
|
import { readFileSync } from 'node:fs';
|
|
7
10
|
import * as p from '@clack/prompts';
|
|
8
|
-
import { consola } from 'consola';
|
|
9
11
|
import { createJiti } from 'dev-jiti';
|
|
10
12
|
import color from 'picocolors';
|
|
11
13
|
import { useSilgiCLI } from 'silgi';
|
|
12
14
|
import { a as silgiCLIIClose } from '../_chunks/silgiApp.mjs';
|
|
13
15
|
import { l as loadOptions } from './types.mjs';
|
|
14
16
|
|
|
17
|
+
async function generateApiFul(silgi) {
|
|
18
|
+
const config = silgi.options.apiFul;
|
|
19
|
+
if (!config.services || hasSilgiModule("openapi")) {
|
|
20
|
+
config.services ??= {};
|
|
21
|
+
config.services = {
|
|
22
|
+
silgi: {
|
|
23
|
+
schema: join(silgi.options.build.dir, "openapi.json")
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
const resolvedOpenAPIServices = Object.fromEntries(
|
|
28
|
+
Object.entries(config?.services ?? {}).filter(([, service]) => Boolean(service.schema))
|
|
29
|
+
);
|
|
30
|
+
if (Object.keys(resolvedOpenAPIServices).length === 0) {
|
|
31
|
+
consola.info("No OpenAPI schemas found, skipping generation");
|
|
32
|
+
return;
|
|
33
|
+
}
|
|
34
|
+
for (const service of Object.values(resolvedOpenAPIServices)) {
|
|
35
|
+
if (typeof service.schema === "string" && !service.schema.startsWith("http")) {
|
|
36
|
+
service.schema = resolve(silgi.options.rootDir, service.schema);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
const types = await generateDTS(resolvedOpenAPIServices);
|
|
40
|
+
silgi.hook("prepare:types", (opts) => {
|
|
41
|
+
opts.references.push({ path: "./apiful.d.ts" });
|
|
42
|
+
});
|
|
43
|
+
addTemplate({
|
|
44
|
+
filename: "types/apiful.d.ts",
|
|
45
|
+
where: ".silgi",
|
|
46
|
+
write: true,
|
|
47
|
+
getContents: () => types
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
|
|
15
51
|
const commonArgs = {
|
|
16
52
|
dir: {
|
|
17
53
|
type: "string",
|
|
@@ -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);
|