kavoru 0.9.6 → 0.9.7
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/package.json +1 -1
- package/src/features.ts +27 -0
package/package.json
CHANGED
package/src/features.ts
CHANGED
|
@@ -316,6 +316,31 @@ async function writeText(
|
|
|
316
316
|
await Bun.write(path.join(projectDir, relativePath), content);
|
|
317
317
|
}
|
|
318
318
|
|
|
319
|
+
export async function regenerateRouteRegistry(projectDir: string): Promise<void> {
|
|
320
|
+
const modulesDir = path.join(projectDir, "src/modules");
|
|
321
|
+
const glob = new Bun.Glob("*/routes.ts");
|
|
322
|
+
const files = [...glob.scanSync(modulesDir)]
|
|
323
|
+
.map((file) => file.replaceAll("\\", "/"))
|
|
324
|
+
.sort();
|
|
325
|
+
|
|
326
|
+
const imports = files
|
|
327
|
+
.map((file, index) => {
|
|
328
|
+
const modulePath = `./${file.replace(/\.ts$/, "")}`;
|
|
329
|
+
return `import * as route${index} from "${modulePath}";`;
|
|
330
|
+
})
|
|
331
|
+
.join("\n");
|
|
332
|
+
|
|
333
|
+
const registry = files.map((_, index) => `route${index}`).join(", ");
|
|
334
|
+
|
|
335
|
+
const content = `// Auto-generated by scripts/generate-route-registry.ts — do not edit
|
|
336
|
+
${imports}
|
|
337
|
+
|
|
338
|
+
export const routeModules = [${registry}];
|
|
339
|
+
`;
|
|
340
|
+
|
|
341
|
+
await writeText(projectDir, "src/modules/routes.registry.ts", content);
|
|
342
|
+
}
|
|
343
|
+
|
|
319
344
|
function removeImportLines(content: string, modules: string[]) {
|
|
320
345
|
let next = content;
|
|
321
346
|
for (const modulePath of modules) {
|
|
@@ -1010,6 +1035,8 @@ export async function applyFeatures(
|
|
|
1010
1035
|
await removePaths(projectDir, FEATURE_PATHS[featureId]);
|
|
1011
1036
|
}
|
|
1012
1037
|
|
|
1038
|
+
await regenerateRouteRegistry(projectDir);
|
|
1039
|
+
|
|
1013
1040
|
await patchModulesIndex(projectDir, selection);
|
|
1014
1041
|
await patchEntryIndex(projectDir, selection);
|
|
1015
1042
|
await patchServerIndex(projectDir, selection);
|