@@ -932,6 +932,110 @@ export default defineConfig({
932932 }
933933 expect ( fsSpy . glob ) . toHaveBeenCalledTimes ( 6 ) ;
934934 } ) ;
935+
936+ it ( "Should detect and update React projects with projects/* structure but no explicit workspaces" , async ( ) => {
937+ const mockFileArray : MockFile [ ] = [
938+ {
939+ path : "package.json" ,
940+ content :
941+ `{
942+ "name": "grid-demos-react",
943+ "dependencies": {
944+ "igniteui-react-grids": "^18.5.1",
945+ "some-package": "^0.0.0"
946+ }
947+ }
948+ ` ,
949+ expected :
950+ `{
951+ "name": "grid-demos-react",
952+ "dependencies": {
953+ "@infragistics/igniteui-react-grids": "^18.5.1",
954+ "some-package": "^0.0.0"
955+ }
956+ }
957+ `
958+ } ,
959+ {
960+ path : "projects/erp-hierarchical-grid/src/app.tsx" ,
961+ content :
962+ `import { IgrGridModule, IgrGrid } from 'igniteui-react-grids';
963+ import 'igniteui-react-grids/grids/themes/light/bootstrap.css';
964+
965+ export default function App() {
966+ return <IgrGrid />;
967+ }` ,
968+ expected :
969+ `import { IgrGridModule, IgrGrid } from '@infragistics/igniteui-react-grids';
970+ import '@infragistics/igniteui-react-grids/grids/themes/light/bootstrap.css';
971+
972+ export default function App() {
973+ return <IgrGrid />;
974+ }`
975+ } ,
976+ {
977+ path : "projects/finance-grid/src/components/GridComponent.tsx" ,
978+ content :
979+ `import { IgrColumn } from 'igniteui-react-grids';
980+
981+ export const GridComponent = () => {
982+ return <IgrColumn />;
983+ }` ,
984+ expected :
985+ `import { IgrColumn } from '@infragistics/igniteui-react-grids';
986+
987+ export const GridComponent = () => {
988+ return <IgrColumn />;
989+ }`
990+ } ] ;
991+
992+ ( fsSpy . fileExists as jasmine . Spy ) . and . returnValue ( true ) ;
993+ // Mock directoryExists to return true for projects directories and src
994+ ( fsSpy . directoryExists as jasmine . Spy ) . and . callFake ( ( dirPath : string ) => {
995+ return dirPath === "projects" || dirPath . endsWith ( "/projects" ) || dirPath . includes ( "projects/" ) || dirPath === "src" || dirPath . endsWith ( "/src" ) ;
996+ } ) ;
997+
998+ // Mock glob to simulate finding projects directories and files
999+ ( fsSpy . glob as jasmine . Spy ) . and . callFake ( ( dirPath : string , pattern : string ) => {
1000+ if ( pattern === "package.json" ) {
1001+ return [ "package.json" ] ;
1002+ } else if ( pattern === "projects/*" ) {
1003+ return [ "projects/erp-hierarchical-grid" , "projects/finance-grid" ] ;
1004+ } else if ( pattern === "**/*.tsx" ) {
1005+ if ( dirPath . includes ( "erp-hierarchical-grid" ) ) {
1006+ return [ "projects/erp-hierarchical-grid/src/app.tsx" ] ;
1007+ } else if ( dirPath . includes ( "finance-grid" ) ) {
1008+ return [ "projects/finance-grid/src/components/GridComponent.tsx" ] ;
1009+ } else if ( dirPath . endsWith ( "/src" ) ) {
1010+ return [ ] ; // src directory has no tsx files
1011+ }
1012+ return [ ] ;
1013+ } else if ( pattern === "**/*.css" ) {
1014+ return [ ] ;
1015+ } else if ( pattern === "**/package.json" ) {
1016+ return [ ] ;
1017+ } else if ( pattern === "vite.config.ts" ) {
1018+ return [ ] ;
1019+ }
1020+ return [ ] ;
1021+ } ) ;
1022+
1023+ ( fsSpy . readFile as jasmine . Spy ) . and . callFake ( ( filePath : string ) => {
1024+ if ( filePath . indexOf ( "package.json" ) > - 1 ) {
1025+ return mockFileArray . find ( entry => entry . path === "package.json" ) . content ;
1026+ }
1027+ const fileEntry = mockFileArray . find ( entry => entry . path === filePath ) ;
1028+ return fileEntry ? fileEntry . content : "" ;
1029+ } ) ;
1030+ spyOn ( PackageManager , "ensureRegistryUser" ) . and . returnValue ( true ) ;
1031+ spyOn ( Util , "log" ) ;
1032+ expect ( await updateWorkspace ( "" ) ) . toEqual ( true ) ;
1033+ for ( const fileEntry of mockFileArray ) {
1034+ expect ( ( fsSpy . writeFile as jasmine . Spy ) ) . toHaveBeenCalledWith ( fileEntry . path , fileEntry . expected ) ;
1035+ }
1036+ // Expect calls for: package.json, projects/*, src tsx files, src css files, src package.json, vite.config.ts, erp-hierarchical-grid tsx files, erp-hierarchical-grid css files, erp-hierarchical-grid package.json, finance-grid tsx files, finance-grid css files, finance-grid package.json
1037+ expect ( fsSpy . glob ) . toHaveBeenCalledTimes ( 13 ) ;
1038+ } ) ;
9351039 } ) ;
9361040
9371041 describe ( "Webcomponents" , ( ) => {
0 commit comments