Spaces:
Sleeping
Sleeping
# This script is used to pull the latest frontend code during the build process | |
# It is called from the Dockerfile | |
set -e # Exit on error | |
if [ -d "frontend/podcraft" ]; then | |
echo "Frontend code already exists" | |
else | |
echo "Frontend code not found, creating dummy placeholder" | |
mkdir -p frontend/podcraft/public | |
mkdir -p frontend/podcraft/src | |
# Create a minimal package.json | |
cat > frontend/podcraft/package.json << EOF | |
{ | |
"name": "podcraft", | |
"private": true, | |
"version": "0.0.0", | |
"type": "module", | |
"scripts": { | |
"dev": "vite", | |
"build": "vite build", | |
"lint": "eslint .", | |
"preview": "vite preview" | |
}, | |
"dependencies": { | |
"react": "^18.2.0", | |
"react-dom": "^18.2.0", | |
"react-icons": "^4.10.1", | |
"react-router-dom": "^6.15.0", | |
"reactflow": "^11.8.3" | |
}, | |
"devDependencies": { | |
"@types/react": "^18.2.15", | |
"@types/react-dom": "^18.2.7", | |
"@vitejs/plugin-react": "^4.0.3", | |
"eslint": "^8.0.0", | |
"eslint-plugin-react-hooks": "^4.0.0", | |
"eslint-plugin-react-refresh": "^0.4.0", | |
"vite": "^4.0.0" | |
} | |
} | |
EOF | |
# Create a minimal index.html | |
cat > frontend/podcraft/index.html << EOF | |
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="UTF-8" /> | |
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> | |
<title>PodCraft</title> | |
</head> | |
<body> | |
<div id="root"></div> | |
<script type="module" src="/src/main.jsx"></script> | |
</body> | |
</html> | |
EOF | |
# Create a minimal vite.config.js | |
cat > frontend/podcraft/vite.config.js << EOF | |
import { defineConfig } from 'vite' | |
import react from '@vitejs/plugin-react' | |
export default defineConfig({ | |
plugins: [react()], | |
server: { | |
proxy: { | |
'/api': 'http://localhost:8000', | |
'/login': 'http://localhost:8000', | |
'/signup': 'http://localhost:8000', | |
'/token': 'http://localhost:8000', | |
'/generate-podcast': 'http://localhost:8000' | |
} | |
} | |
}) | |
EOF | |
# Create a minimal main.jsx | |
mkdir -p frontend/podcraft/src | |
cat > frontend/podcraft/src/main.jsx << EOF | |
import React from 'react' | |
import ReactDOM from 'react-dom/client' | |
import App from './App.jsx' | |
import './index.css' | |
ReactDOM.createRoot(document.getElementById('root')).render( | |
<React.StrictMode> | |
<App /> | |
</React.StrictMode>, | |
) | |
EOF | |
# Create a minimal App.jsx | |
cat > frontend/podcraft/src/App.jsx << EOF | |
import React from 'react' | |
import './App.css' | |
function App() { | |
return ( | |
<div className="App"> | |
<header className="App-header"> | |
<h1>PodCraft</h1> | |
<p>Welcome to PodCraft API. This is the backend server for the PodCraft application.</p> | |
<p>Please use the API endpoints to interact with the application.</p> | |
</header> | |
</div> | |
) | |
} | |
export default App | |
EOF | |
# Create minimal CSS files | |
cat > frontend/podcraft/src/index.css << EOF | |
body { | |
margin: 0; | |
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', | |
'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue', | |
sans-serif; | |
-webkit-font-smoothing: antialiased; | |
-moz-osx-font-smoothing: grayscale; | |
} | |
EOF | |
cat > frontend/podcraft/src/App.css << EOF | |
.App { | |
text-align: center; | |
} | |
.App-header { | |
background-color: #282c34; | |
min-height: 100vh; | |
display: flex; | |
flex-direction: column; | |
align-items: center; | |
justify-content: center; | |
font-size: calc(10px + 2vmin); | |
color: white; | |
} | |
EOF | |
echo "Created dummy frontend code" | |
fi | |
# Make the script executable | |
chmod +x $0 |