fix deploy issue
Browse filesFiles changed (2)
537 unmodified lines538539540541542543544545537 unmodified linesprint(f"[Deploy] history provided: {history is not None} (length: {len(history) if history else 0})")print(f"[Deploy] username: {username}")print(f"[Deploy] is_update: {is_update}")print(f"[Deploy] ============================================")if is_update:# Use existing reporepo_id = existing_repo_id537 unmodified lines538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591537 unmodified linesprint(f"[Deploy] history provided: {history is not None} (length: {len(history) if history else 0})")print(f"[Deploy] username: {username}")print(f"[Deploy] is_update: {is_update}")print(f"[Deploy] language: {language}")print(f"[Deploy] ============================================")# For Gradio space updates (import/redesign), only update .py filesif is_update and language == "gradio":print(f"[Deploy] Gradio space update - will only update .py files")# Parse the code to get all filesfiles = parse_multi_file_python_output(code)# Fallback if no files parsedif not files:print(f"[Deploy] No file markers found, using entire code as app.py")cleaned_code = remove_code_block(code)files['app.py'] = cleaned_code# Filter to only .py filespy_files = {fname: content for fname, content in files.items() if fname.endswith('.py')}if not py_files:return False, "Error: No Python files found in generated code", Noneprint(f"[Deploy] Updating {len(py_files)} Python file(s): {list(py_files.keys())}")# Update each Python file individuallyupdated_files = []for file_path, content in py_files.items():print(f"[Deploy] Updating {file_path} ({len(content)} chars)")success, msg = update_space_file(repo_id=existing_repo_id,file_path=file_path,content=content,token=token,commit_message=commit_message or f"Update {file_path} from anycoder")if success:updated_files.append(file_path)else:print(f"[Deploy] Warning: Failed to update {file_path}: {msg}")if updated_files:space_url = f"https://huggingface.co/spaces/{existing_repo_id}"files_list = ", ".join(updated_files)return True, f"✅ Updated {len(updated_files)} file(s): {files_list}! View at: {space_url}", space_urlelse:return False, "Failed to update any Python files", Noneif is_update:# Use existing reporepo_id = existing_repo_id
370 unmodified lines3713723733743753765 unmodified lines38238338438538638738822 unmodified lines4114124134144154167 unmodified lines424425426427428429370 unmodified linesconsole.log('[Redesign] Duplicated space ID:', duplicatedRepoId);setTimeout(() => {const redesignPrompt = `I have existing code in the editor from a duplicated space. Please redesign it to make it look better with minimal components needed, mobile friendly, and modern design.Current code:5 unmodified lines- Minimal, clean components- Mobile-first responsive design- Modern UI/UX best practices- Better visual hierarchy and spacing`;if (onStart) {// Pass duplicated space ID so auto-deploy updates it22 unmodified linesonImport(result.code, result.language || 'html', redesignUrl);setTimeout(() => {const redesignPrompt = `I have existing code in the editor that I imported from ${redesignUrl}. Please redesign it to make it look better with minimal components needed, mobile friendly, and modern design.Current code:7 unmodified lines- Modern UI/UX best practices- Better visual hierarchy and spacingNote: After generating the redesign, I will create a Pull Request on the original space.`;if (onStart) {370 unmodified lines3713723733743753763775 unmodified lines38338438538638738838939039122 unmodified lines4144154164174184194207 unmodified lines428429430431432433434435370 unmodified linesconsole.log('[Redesign] Duplicated space ID:', duplicatedRepoId);setTimeout(() => {const isGradio = (result.language || 'html') === 'gradio';const redesignPrompt = `I have existing code in the editor from a duplicated space. Please redesign it to make it look better with minimal components needed, mobile friendly, and modern design.Current code:5 unmodified lines- Minimal, clean components- Mobile-first responsive design- Modern UI/UX best practices- Better visual hierarchy and spacing${isGradio ? '\n\nIMPORTANT: Only output Python (.py) files. Do NOT include requirements.txt or any other non-Python files. The existing dependencies and configuration files will be preserved.' : ''}`;if (onStart) {// Pass duplicated space ID so auto-deploy updates it22 unmodified linesonImport(result.code, result.language || 'html', redesignUrl);setTimeout(() => {const isGradio = (result.language || 'html') === 'gradio';const redesignPrompt = `I have existing code in the editor that I imported from ${redesignUrl}. Please redesign it to make it look better with minimal components needed, mobile friendly, and modern design.Current code:7 unmodified lines- Modern UI/UX best practices- Better visual hierarchy and spacing${isGradio ? '\n\nIMPORTANT: Only output Python (.py) files. Do NOT include requirements.txt or any other non-Python files. The existing dependencies and configuration files will be preserved.' : ''}Note: After generating the redesign, I will create a Pull Request on the original space.`;if (onStart) {
backend_deploy.py+46
frontend/src/components/LandingPage.tsx+7-1