Skip to content

Commit e57dc29

Browse files
committed
ensure index.tsx must have
1 parent 75f59df commit e57dc29

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

backend/src/build-system/handlers/file-manager/file-struct/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -514,6 +514,7 @@ export class FileStructureAndArchitectureHandler
514514
};
515515
}
516516

517+
// add shadcn and check if missing must have path like "src/index.tsx"
517518
let added_structure = '';
518519
try {
519520
added_structure = mergePaths(fileStructureJsonContent);

backend/src/build-system/utils/strings.ts

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,13 +58,22 @@ export const SHADCN_COMPONENT_PATHS: string[] = [
5858
* and write the result to a new JSON file.
5959
*/
6060
export function mergePaths(input: string) {
61+
const INDEX_PATH = 'src/index.tsx';
6162
try {
6263
// Parse the input string into a JSON object
6364
const parsedData = JSON.parse(input) as { Paths: string[] };
6465

65-
// Merge the existing paths with the SHADCN components
66+
// Create a Set to avoid duplicates
67+
const pathSet = new Set([...parsedData.Paths, ...SHADCN_COMPONENT_PATHS]);
68+
69+
// Check if src/index.tsx exists, if not, add it
70+
if (!pathSet.has(INDEX_PATH)) {
71+
pathSet.add(INDEX_PATH);
72+
}
73+
74+
// Convert Set back to array
6675
const updatedPaths = {
67-
Paths: [...parsedData.Paths, ...SHADCN_COMPONENT_PATHS],
76+
Paths: Array.from(pathSet),
6877
};
6978

7079
// Convert back to JSON string with formatting

0 commit comments

Comments
 (0)