diff --git a/backend/apimanager/check_updates.py b/backend/apimanager/check_updates.py index 08d3b62..5688b15 100644 --- a/backend/apimanager/check_updates.py +++ b/backend/apimanager/check_updates.py @@ -26,15 +26,21 @@ def update_rangolio(rangolio_location): # Update server shutil.move(settings.DEPLOY_CONFIG["DEPLOY_LOCATION"]+'/server', f'{settings.DEPLOY_CONFIG["DEPLOY_LOCATION"]}/server.old') + run_npm_command('npm_run', f'{rangolio_location}/frontend/viewable-ui', ['build:server']) - git_update_viewable_ui(f'{settings.DEPLOY_CONFIG["DEPLOY_LOCATION"]}/server', 'server.old') + git_update_viewable_ui(f'{settings.DEPLOY_CONFIG["DEPLOY_LOCATION"]}/server.old', 'server', False) + shutil.move(settings.DEPLOY_CONFIG["DEPLOY_LOCATION"]+'/server.old', + f'{settings.DEPLOY_CONFIG["DEPLOY_LOCATION"]}/server') + # Update ghpages shutil.move(settings.DEPLOY_CONFIG["DEPLOY_LOCATION"]+'/ghpages', f'{settings.DEPLOY_CONFIG["DEPLOY_LOCATION"]}/ghpages.old') run_npm_command('npm_run', f'{rangolio_location}/frontend/viewable-ui', ['build:ghpages']) - git_update_viewable_ui(f'{settings.DEPLOY_CONFIG["DEPLOY_LOCATION"]}/ghpages', 'ghpages.old') + git_update_viewable_ui(f'{settings.DEPLOY_CONFIG["DEPLOY_LOCATION"]}/ghpages.old', 'ghpages', False) + shutil.move(settings.DEPLOY_CONFIG["DEPLOY_LOCATION"]+'/ghpages.old', + f'{settings.DEPLOY_CONFIG["DEPLOY_LOCATION"]}/ghpages') # Update editor-ui run_npm_command('npm_run', f'{rangolio_location}/frontend/editable-ui', ['build']) diff --git a/backend/apimanager/publish_methods_github.py b/backend/apimanager/publish_methods_github.py index 580ec14..45a19da 100644 --- a/backend/apimanager/publish_methods_github.py +++ b/backend/apimanager/publish_methods_github.py @@ -72,23 +72,28 @@ def git_check_user_details(deploy_location): return True -def git_update_viewable_ui(deploy_location, dist_folder_name): +def git_update_viewable_ui(deploy_location, dist_folder_name, copy_index_and_asset=True): + # deploy_location = server.old ; dist_folder_name = server + + # server.old -> server.old.temp shutil.move(deploy_location, f'{deploy_location}.temp') + # server -> server.old shutil.move(f'{settings.DEPLOY_CONFIG["DEPLOY_LOCATION"]}/{dist_folder_name}', f'{deploy_location}') - copy_content( - f'{deploy_location}.temp/index.html', - deploy_location, - 'file', - 'remove_and_copy' - ) - copy_content( - f'{deploy_location}.temp/assets', - f'{deploy_location}/assets', - 'folder', - 'remove_and_copy' - ) + if copy_index_and_asset: + copy_content( + f'{deploy_location}.temp/index.html', + deploy_location, + 'file', + 'remove_and_copy' + ) + copy_content( + f'{deploy_location}.temp/assets', + f'{deploy_location}/assets', + 'folder', + 'remove_and_copy' + ) copy_content( f'{deploy_location}.temp/data', f'{deploy_location}/data',