silgi 0.29.40 → 0.30.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/index.mjs +2 -2
- package/dist/cli/silgi.mjs +41 -41
- package/package.json +1 -1
- /package/dist/cli/{dev.mjs → watch.mjs} +0 -0
package/dist/cli/index.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { defineCommand, runMain } from 'citty';
|
|
3
3
|
|
|
4
|
-
const version = "0.
|
|
4
|
+
const version = "0.30.1";
|
|
5
5
|
const packageJson = {
|
|
6
6
|
version: version};
|
|
7
7
|
|
|
@@ -22,7 +22,7 @@ const main = defineCommand({
|
|
|
22
22
|
init: () => import('./init.mjs').then((m) => m.default),
|
|
23
23
|
run: () => import('./prepare.mjs').then(function (n) { return n.r; }).then((m) => m.default),
|
|
24
24
|
install: () => import('./install.mjs').then((m) => m.default),
|
|
25
|
-
|
|
25
|
+
watch: () => import('./watch.mjs').then((m) => m.default)
|
|
26
26
|
},
|
|
27
27
|
run() {
|
|
28
28
|
}
|
package/dist/cli/silgi.mjs
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { generateDTS } from 'apiful/openapi';
|
|
2
2
|
import consola$1, { consola } from 'consola';
|
|
3
3
|
import { join, resolve, dirname, relative, isAbsolute, basename, extname } from 'pathe';
|
|
4
|
-
import { hasSilgiModule, addTemplate, normalizeTemplate, useLogger, genEnsureSafeVar, baseHeaderBannerComment, addImports, hash, toArray,
|
|
4
|
+
import { hasSilgiModule, addTemplate, normalizeTemplate, useLogger, writeFile, genEnsureSafeVar, baseHeaderBannerComment, addImports, hash, toArray, relativeWithDot, isDirectory, isPresents, addCoreFile, resolveAlias as resolveAlias$1, directoryToURL, hasError, removeExtension, 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
|
-
import {
|
|
7
|
+
import { genObjectFromRawEntries, genObjectFromRaw, genObjectFromValues, genAugmentation, genImport, genTypeImport } from 'knitwork';
|
|
8
8
|
import { u as useSilgiCLI } from '../_chunks/silgiApp.mjs';
|
|
9
9
|
import { resolvePath, parseNodeModulePath, lookupNodeModuleSubpath, findTypeExports, findExports } from 'mlly';
|
|
10
10
|
import { resolveAlias } from 'pathe/utils';
|
|
@@ -193,6 +193,44 @@ async function compileTemplate(template, ctx) {
|
|
|
193
193
|
async function prepare(_silgi) {
|
|
194
194
|
}
|
|
195
195
|
|
|
196
|
+
async function exportRules(silgi) {
|
|
197
|
+
try {
|
|
198
|
+
if (!silgi?.routeRules?.exportRules) {
|
|
199
|
+
throw new Error("Invalid silgi configuration: routeRules or exportRules is undefined");
|
|
200
|
+
}
|
|
201
|
+
const exportedRules = silgi.routeRules.exportRules();
|
|
202
|
+
if (!exportedRules || typeof exportedRules !== "object") {
|
|
203
|
+
throw new Error("No valid route rules to export");
|
|
204
|
+
}
|
|
205
|
+
const content = `/* eslint-disable */
|
|
206
|
+
// @ts-nocheck
|
|
207
|
+
// This file is auto-generated at build time by Silgi
|
|
208
|
+
// Contains route rules with preserved functions
|
|
209
|
+
// DO NOT MODIFY THIS FILE DIRECTLY
|
|
210
|
+
|
|
211
|
+
export const routeRules = ${genObjectFromRawEntries(
|
|
212
|
+
Object.entries(exportedRules).map(([key, value]) => {
|
|
213
|
+
if (typeof value === "function") {
|
|
214
|
+
return [key, genObjectFromRaw(value)];
|
|
215
|
+
}
|
|
216
|
+
return [key, genObjectFromValues(value)];
|
|
217
|
+
})
|
|
218
|
+
)}
|
|
219
|
+
`;
|
|
220
|
+
const serverDir = silgi.options.silgi.serverDir;
|
|
221
|
+
if (!serverDir) {
|
|
222
|
+
throw new Error("Server directory not defined in configuration");
|
|
223
|
+
}
|
|
224
|
+
const file = join(serverDir, "rules.ts");
|
|
225
|
+
if (!silgi.errors.length) {
|
|
226
|
+
await writeFile(file, content);
|
|
227
|
+
}
|
|
228
|
+
} catch (error) {
|
|
229
|
+
console.error("\u274C Failed to prepare build:", error instanceof Error ? error.message : String(error));
|
|
230
|
+
throw error;
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
|
|
196
234
|
function debugMode(name) {
|
|
197
235
|
const silgi = useSilgiCLI();
|
|
198
236
|
if (silgi.options.debug === true || typeof silgi.options.debug === "object" && silgi.options.debug[name]) {
|
|
@@ -813,50 +851,12 @@ async function writeTypesAndFiles(silgi) {
|
|
|
813
851
|
}
|
|
814
852
|
}
|
|
815
853
|
|
|
816
|
-
async function prepareBuild(silgi) {
|
|
817
|
-
try {
|
|
818
|
-
if (!silgi?.routeRules?.exportRules) {
|
|
819
|
-
throw new Error("Invalid silgi configuration: routeRules or exportRules is undefined");
|
|
820
|
-
}
|
|
821
|
-
const exportedRules = silgi.routeRules.exportRules();
|
|
822
|
-
if (!exportedRules || typeof exportedRules !== "object") {
|
|
823
|
-
throw new Error("No valid route rules to export");
|
|
824
|
-
}
|
|
825
|
-
const content = `/* eslint-disable */
|
|
826
|
-
// @ts-nocheck
|
|
827
|
-
// This file is auto-generated at build time by Silgi
|
|
828
|
-
// Contains route rules with preserved functions
|
|
829
|
-
// DO NOT MODIFY THIS FILE DIRECTLY
|
|
830
|
-
|
|
831
|
-
export const routeRules = ${genObjectFromRawEntries(
|
|
832
|
-
Object.entries(exportedRules).map(([key, value]) => {
|
|
833
|
-
if (typeof value === "function") {
|
|
834
|
-
return [key, genObjectFromRaw(value)];
|
|
835
|
-
}
|
|
836
|
-
return [key, genObjectFromValues(value)];
|
|
837
|
-
})
|
|
838
|
-
)}
|
|
839
|
-
`;
|
|
840
|
-
const serverDir = silgi.options.silgi.serverDir;
|
|
841
|
-
if (!serverDir) {
|
|
842
|
-
throw new Error("Server directory not defined in configuration");
|
|
843
|
-
}
|
|
844
|
-
const file = join(serverDir, "rules.ts");
|
|
845
|
-
if (!silgi.errors.length) {
|
|
846
|
-
await writeFile(file, content);
|
|
847
|
-
}
|
|
848
|
-
} catch (error) {
|
|
849
|
-
console.error("\u274C Failed to prepare build:", error instanceof Error ? error.message : String(error));
|
|
850
|
-
throw error;
|
|
851
|
-
}
|
|
852
|
-
}
|
|
853
|
-
|
|
854
854
|
async function build(silgi) {
|
|
855
855
|
await prepare();
|
|
856
856
|
await generateApiFul(silgi);
|
|
857
857
|
await prepareCommands(silgi);
|
|
858
858
|
await writeCoreFile(silgi);
|
|
859
|
-
await
|
|
859
|
+
await exportRules(silgi);
|
|
860
860
|
await writeTypesAndFiles(silgi);
|
|
861
861
|
await generateApp(silgi);
|
|
862
862
|
}
|
package/package.json
CHANGED
|
File without changes
|