refactor: use python instead of javascript

This commit is contained in:
Bjarke Sporring
2026-01-05 12:21:48 +01:00
parent e1b8d8418a
commit f11f5a4646
14 changed files with 550 additions and 735 deletions

View File

@@ -31,22 +31,17 @@ git config user.email "user@workshop.local" | Out-Null
# Create initial project files
$app = @"
class Application {
constructor() {
this.name = 'TeamProject';
this.version = '1.0.0';
}
class Application:
def __init__(self):
self.name = 'TeamProject'
self.version = '1.0.0'
start() {
console.log('Application started');
}
}
module.exports = Application;
def start(self):
print('Application started')
"@
Set-Content -Path "app.js" -Value $app
git add app.js
Set-Content -Path "app.py" -Value $app
git add app.py
git commit -m "Initial application" | Out-Null
$readme = @"
@@ -63,17 +58,19 @@ git add README.md
git commit -m "Add README" | Out-Null
$package = @"
{
"name": "team-project",
"version": "1.0.0",
"description": "Learning Git remotes",
"main": "app.js"
}
from setuptools import setup
setup(
name='team-project',
version='1.0.0',
description='Learning Git remotes',
py_modules=['app'],
)
"@
Set-Content -Path "package.json" -Value $package
git add package.json
git commit -m "Add package.json" | Out-Null
Set-Content -Path "setup.py" -Value $package
git add setup.py
git commit -m "Add setup.py" | Out-Null
# Create the "remote" repository (bare repository)
Set-Location ..
@@ -102,18 +99,17 @@ git config user.name "Teammate" 2>>`$null | Out-Null
git config user.email "teammate@workshop.local" 2>>`$null | Out-Null
# Make changes to main branch
`$appContent = Get-Content "app.js" -Raw
`$updatedApp = `$appContent -replace "start\(\) {", @"
start() {
console.log('Starting application...');
this.initialize();
}
`$appContent = Get-Content "app.py" -Raw
`$updatedApp = `$appContent -replace "def start\(self\):", @"
def start(self):
print('Starting application...')
self.initialize()
initialize() {
def initialize(self):
"@
Set-Content -Path "app.js" -Value `$updatedApp
git add app.js 2>>`$null
Set-Content -Path "app.py" -Value `$updatedApp
git add app.py 2>>`$null
git commit -m "Add initialization method" 2>>`$null | Out-Null
git push origin main 2>>`$null | Out-Null
@@ -140,7 +136,7 @@ Write-Host "1. Navigate to the challenge directory: cd challenge" -ForegroundCol
Write-Host "2. Clone the remote: git clone remote-repo local-repo" -ForegroundColor White
Write-Host "3. Navigate to your clone: cd local-repo" -ForegroundColor White
Write-Host "4. Create a feature branch: git checkout -b add-feature" -ForegroundColor White
Write-Host "5. Add a new method to app.js (e.g., stop method)" -ForegroundColor White
Write-Host "5. Add a new method to app.py (e.g., stop method)" -ForegroundColor White
Write-Host "6. Commit your changes" -ForegroundColor White
Write-Host "7. Push your branch: git push -u origin add-feature" -ForegroundColor White
Write-Host "8. Go back to challenge directory: cd .." -ForegroundColor White

View File

@@ -80,7 +80,7 @@ $mainCommitCount = (git rev-list --count main 2>$null)
if ($featureCommitCount -le $mainCommitCount) {
Write-Host "[FAIL] add-feature branch has no new commits." -ForegroundColor Red
Write-Host "Hint: Make changes to app.js and commit them on the add-feature branch" -ForegroundColor Yellow
Write-Host "Hint: Make changes to app.py and commit them on the add-feature branch" -ForegroundColor Yellow
Set-Location ../..
exit 1
}
@@ -103,20 +103,20 @@ Write-Host "[PASS] Feature branch pushed to remote!" -ForegroundColor Green
Set-Location ../local-repo
# Check if app.js has been modified
if (-not (Test-Path "app.js")) {
Write-Host "[FAIL] app.js not found." -ForegroundColor Red
# Check if app.py has been modified
if (-not (Test-Path "app.py")) {
Write-Host "[FAIL] app.py not found." -ForegroundColor Red
Set-Location ../..
exit 1
}
$appContent = Get-Content "app.js" -Raw
$appContent = Get-Content "app.py" -Raw
# Check for user's changes (should have added something)
$featureCommits = git log --pretty=format:"%s" add-feature 2>$null
if (-not ($featureCommits -match "stop|feature|add" -or $appContent -match "stop")) {
Write-Host "[FAIL] No new feature detected in app.js." -ForegroundColor Red
Write-Host "Hint: Add a new method (like 'stop') to app.js and commit it" -ForegroundColor Yellow
Write-Host "[FAIL] No new feature detected in app.py." -ForegroundColor Red
Write-Host "Hint: Add a new method (like 'stop') to app.py and commit it" -ForegroundColor Yellow
Set-Location ../..
exit 1
}