@@ -572,7 +572,7 @@ public function getDefaultDependencies($type = null)
572572 return $ this ->helper ->encode ($ defaultDependencies );
573573 }
574574
575- protected function updateModuleJson ($ data , $ viaGenerateRelease = false )
575+ protected function updateModuleJson ($ data , $ viaGenerateRelease = false , $ viewPublic = false )
576576 {
577577 $ jsonFile = $ this ->getModuleJsonFileLocation ($ data );
578578
@@ -590,6 +590,8 @@ protected function updateModuleJson($data, $viaGenerateRelease = false)
590590 if (count ($ jsonContent ['dependencies ' ]['views ' ]) === 0 ) {
591591 $ data ['base_view_module_id ' ] = 0 ;
592592 }
593+
594+ $ repo = $ jsonContent ['repo ' ];
593595 } else {
594596 $ data = $ this ->jsonData ($ data , true );
595597
@@ -639,10 +641,12 @@ protected function updateModuleJson($data, $viaGenerateRelease = false)
639641 try {
640642 $ this ->localContent ->write ($ jsonFile , $ jsonContent );
641643
642- if ($ data [ ' module_type ' ] === ' views ' && $ data [ ' base_view_module_id ' ] == 0 ) {
644+ if ($ viewPublic ) {
643645 $ jsonFile = $ this ->getNewFilesLocation ($ data , true );
644646
645- $ jsonContent = str_replace ($ data ['repo ' ], $ data ['repo ' ] . '-public ' , $ jsonContent );
647+ if (!str_contains ($ data ['repo ' ], '-public ' )) {
648+ $ jsonContent = str_replace ($ data ['repo ' ], $ data ['repo ' ] . '-public ' , $ jsonContent );
649+ }
646650
647651 $ this ->localContent ->write ($ jsonFile . 'view.json ' , $ jsonContent );
648652 }
@@ -840,7 +844,7 @@ protected function generateNewFiles($data)
840844 return true ;
841845 }
842846
843- protected function getNewFilesLocation ($ data , $ public = false )
847+ protected function getNewFilesLocation ($ data , $ viewPublic = false )
844848 {
845849 if ($ data ['module_type ' ] === 'components ' ) {
846850 $ moduleLocation = 'apps/ ' . ucfirst ($ data ['app_type ' ]) . '/Components/ ' ;
@@ -864,7 +868,7 @@ protected function getNewFilesLocation($data, $public = false)
864868 } else if ($ data ['module_type ' ] === 'views ' ) {
865869 $ moduleLocation = 'apps/ ' . ucfirst ($ data ['app_type ' ]) . '/Views/ ' ;
866870
867- if ($ public ) {
871+ if ($ viewPublic ) {
868872 $ moduleLocation = 'public/ ' . $ data ['app_type ' ] . '/ ' . strtolower ($ data ['name ' ]) . '/ ' ;
869873
870874 return $ moduleLocation ;
@@ -1879,23 +1883,25 @@ public function generateRelease($data)
18791883 if ($ data ['module_type ' ] === 'bundles ' ) {
18801884 $ this ->commitBundleJson ($ module );
18811885 } else {
1882- $ jsonContent = $ this ->updateModuleJson ($ module , true );
1883-
1884- if (!$ jsonContent ) {
1885- return false ;
1886- }
1887-
18881886 $ reposArr = [$ module ['repo ' ]];
18891887
18901888 $ fileLocation = explode ('/Install/ ' , $ this ->getModuleJsonFileLocation ($ module ));
18911889
1892- if ($ data ['module_type ' ] === 'views ' ) {
1893- $ fileLocation = explode ('/Default/ ' , $ this ->getModuleJsonFileLocation ($ module ));
1894-
1890+ if ($ data ['module_type ' ] === 'views ' && isset ($ data ['base_view_module_id ' ]) && $ data ['base_view_module_id ' ] == 0 ) {
18951891 array_push ($ reposArr , $ module ['repo ' ] . '-public ' );
18961892 }
18971893
18981894 foreach ($ reposArr as $ repo ) {
1895+ if (str_contains ($ repo , '-public ' )) {
1896+ $ jsonContent = $ this ->updateModuleJson ($ module , true , true );
1897+ } else {
1898+ $ jsonContent = $ this ->updateModuleJson ($ module , true );
1899+ }
1900+
1901+ if (!$ jsonContent ) {
1902+ return false ;
1903+ }
1904+
18991905 //Check for json file on remote
19001906 if (strtolower ($ this ->apiClientConfig ['provider ' ]) === 'gitea ' ) {
19011907 \System \Base \Providers \BasepackagesServiceProvider \Packages \ApiClientServices \Apis \Repos \Gitea \ObjectSerializer::setUrlEncoding (false );
@@ -1914,7 +1920,7 @@ public function generateRelease($data)
19141920 [
19151921 $ this ->apiClientConfig ['org_user ' ],
19161922 strtolower ($ this ->helper ->last (explode ('/ ' , $ repo ))),
1917- $ data ['module_type ' ] === 'views ' ? $ fileLocation [ 1 ] : 'Install/ ' . $ fileLocation [1 ],
1923+ $ data ['module_type ' ] === 'views ' ? ' view.json ' : 'Install/ ' . $ fileLocation [1 ],
19181924 $ module ['branch ' ]
19191925 ]
19201926 )->getResponse (true );
@@ -1926,7 +1932,9 @@ public function generateRelease($data)
19261932
19271933 $ base64EncodedJsonContent = base64_encode ($ jsonContent );
19281934
1929- if (str_replace (["\n" , "\r" ], '' , $ file ['content ' ]) !== $ base64EncodedJsonContent ) {
1935+ if (str_replace (["\n" , "\r" ], '' , $ file ['content ' ]) !== $ base64EncodedJsonContent ||
1936+ $ module ['version ' ] === '0.0.0 '
1937+ ) {
19301938 if (strtolower ($ this ->apiClientConfig ['provider ' ]) === 'gitea ' ) {
19311939 $ collection = 'RepositoryApi ' ;
19321940 $ method = 'repoUpdateFile ' ;
@@ -1939,7 +1947,7 @@ public function generateRelease($data)
19391947 [
19401948 $ this ->apiClientConfig ['org_user ' ],
19411949 strtolower ($ this ->helper ->last (explode ('/ ' , $ repo ))),
1942- $ data ['module_type ' ] === 'views ' ? $ fileLocation [ 1 ] : 'Install/ ' . $ fileLocation [1 ],
1950+ $ data ['module_type ' ] === 'views ' ? ' view.json ' : 'Install/ ' . $ fileLocation [1 ],
19431951 [
19441952 'message ' => $ module ['commit_message ' ],
19451953 'content ' => $ base64EncodedJsonContent ,
@@ -1963,7 +1971,7 @@ public function generateRelease($data)
19631971 //Now we generate release after updating the json file.
19641972 $ reposArr = [$ module ['repo ' ]];
19651973
1966- if ($ data ['module_type ' ] === 'views ' ) {
1974+ if ($ data ['module_type ' ] === 'views ' && isset ( $ data [ ' base_view_module_id ' ]) && $ data [ ' base_view_module_id ' ] == 0 ) {
19671975 array_push ($ reposArr , $ module ['repo ' ] . '-public ' );
19681976 }
19691977
@@ -2349,7 +2357,7 @@ protected function checkPullRequests($data)
23492357
23502358 $ reposArr = [$ data ['repo ' ]];
23512359
2352- if ($ data ['module_type ' ] === 'views ' ) {
2360+ if ($ data ['module_type ' ] === 'views ' && isset ( $ data [ ' base_view_module_id ' ]) && $ data [ ' base_view_module_id ' ] == 0 ) {
23532361 array_push ($ reposArr , $ data ['repo ' ] . '-public ' );
23542362 }
23552363
0 commit comments