File tree Expand file tree Collapse file tree 2 files changed +12
-2
lines changed
handlers/file-manager/file-struct Expand file tree Collapse file tree 2 files changed +12
-2
lines changed Original file line number Diff line number Diff line change @@ -514,6 +514,7 @@ export class FileStructureAndArchitectureHandler
514
514
} ;
515
515
}
516
516
517
+ // add shadcn and check if missing must have path like "src/index.tsx"
517
518
let added_structure = '' ;
518
519
try {
519
520
added_structure = mergePaths ( fileStructureJsonContent ) ;
Original file line number Diff line number Diff line change @@ -58,13 +58,22 @@ export const SHADCN_COMPONENT_PATHS: string[] = [
58
58
* and write the result to a new JSON file.
59
59
*/
60
60
export function mergePaths ( input : string ) {
61
+ const INDEX_PATH = 'src/index.tsx' ;
61
62
try {
62
63
// Parse the input string into a JSON object
63
64
const parsedData = JSON . parse ( input ) as { Paths : string [ ] } ;
64
65
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
66
75
const updatedPaths = {
67
- Paths : [ ... parsedData . Paths , ... SHADCN_COMPONENT_PATHS ] ,
76
+ Paths : Array . from ( pathSet ) ,
68
77
} ;
69
78
70
79
// Convert back to JSON string with formatting
You can’t perform that action at this time.
0 commit comments