Merge unrelated histories
This commit is contained in:
68
init.sh
Normal file
68
init.sh
Normal file
@@ -0,0 +1,68 @@
|
||||
#!/bin/sh
|
||||
|
||||
# Bestimme das aktuelle Verzeichnis
|
||||
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
||||
|
||||
# Entferne vorhandenes Git-Repository, falls vorhanden
|
||||
rm -rf .git
|
||||
|
||||
# Erstelle eine neue React-App mit dem PWA-Template und TypeScript
|
||||
npx create-react-app frontend --template cra-template-pwa-typescript
|
||||
|
||||
# Installiere zusätzliche Abhängigkeiten im Frontend-Verzeichnis
|
||||
npm install --prefix frontend
|
||||
|
||||
# Erstelle das Backend-Verzeichnis und dessen src-Ordner
|
||||
mkdir -p backend/src
|
||||
|
||||
# Initialisiere ein neues npm-Projekt im Backend-Verzeichnis
|
||||
npm init -y --prefix backend
|
||||
|
||||
# Installiere die notwendigen Backend-Abhängigkeiten inklusive TypeScript und Typendefinitionen
|
||||
npm i --prefix backend express dotenv @types/express @types/dotenv typescript ts-node
|
||||
|
||||
# Erstelle eine TypeScript-Konfigurationsdatei für das Backend
|
||||
echo '{
|
||||
"compilerOptions": {
|
||||
"target": "esnext",
|
||||
"module": "commonjs",
|
||||
"strict": true,
|
||||
"esModuleInterop": true,
|
||||
"skipLibCheck": true,
|
||||
"forceConsistentCasingInFileNames": true,
|
||||
"outDir": "./dist",
|
||||
"rootDir": "./src"
|
||||
},
|
||||
"include": ["src/**/*"],
|
||||
"exclude": ["node_modules", "dist"]
|
||||
}' > backend/tsconfig.json
|
||||
|
||||
# Füge ein Start-Skript zum Backend package.json hinzu
|
||||
echo '{
|
||||
"scripts": {
|
||||
"start": "ts-node src/index.ts",
|
||||
"build": "tsc",
|
||||
"dev": "nodemon src/index.ts"
|
||||
}
|
||||
}' > backend/package.json
|
||||
|
||||
# Erstelle die index.ts Datei im Backend/src-Verzeichnis
|
||||
cat <<EOT > backend/src/index.ts
|
||||
// Standard-Einstiegspunkt für die App
|
||||
import express from 'express';
|
||||
import dotenv from 'dotenv';
|
||||
|
||||
dotenv.config();
|
||||
|
||||
const app = express();
|
||||
const NODE_ENV = process.env.NODE_ENV || 'dev';
|
||||
const Port = NODE_ENV === "production" ? parseInt(process.env.PORT || '') || 507 : 2210;
|
||||
|
||||
app.listen(Port, () => {
|
||||
console.log(\`Server läuft auf Port \${Port}\`);
|
||||
});
|
||||
EOT
|
||||
|
||||
# Hinweis: Dieses Skript erstellt eine neue index.ts Datei im Backend/src-Ordner und fügt
|
||||
# die notwendigen Skripte und Abhängigkeiten hinzu. Stelle sicher, dass deine Umgebungsvariablen
|
||||
# und jeglicher anderer benötigter Code korrekt in die index.ts Datei integriert sind.
|
||||
Reference in New Issue
Block a user