Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GitAuto: [FEATURE] Installation script for this template (PowerShell and Bash) #45

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 34 additions & 0 deletions install.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
Param(
[string]$ProjectName,
[string]$Namespace,
[string]$SonarCloudUrl,
[string]$HealthChecksId
)

Write-Host "Setting up project: $ProjectName"

Check warning on line 8 in install.ps1

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

install.ps1#L8

File 'install.ps1' uses Write-Host. Avoid using Write-Host because it might not work in all hosts, does not work when there is no host, and (prior to PS 5.0) cannot be suppressed, captured, or redirected. Instead, use Write-Output, Write-Verbose, or Write-Information.

# Update .wakatime and README.md
(Get-Content .wakatime-project) -replace 'TemplateProject', $ProjectName | Set-Content .wakatime-project
(Get-Content README.md) -replace 'TemplateProject', $ProjectName | Set-Content README.md

# Update composer.json
(Get-Content composer.json) -replace 'TemplateNamespace', $Namespace | Set-Content composer.json

# Update Healthchecks.io badge
Write-Host "Please create a HealthChecks.io account if needed."

Check warning on line 18 in install.ps1

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

install.ps1#L18

File 'install.ps1' uses Write-Host. Avoid using Write-Host because it might not work in all hosts, does not work when there is no host, and (prior to PS 5.0) cannot be suppressed, captured, or redirected. Instead, use Write-Output, Write-Verbose, or Write-Information.
(Get-Content README.md) -replace 'HealthChecksId', $HealthChecksId | Set-Content README.md

# Update SonarCloud URL
(Get-Content README.md) -replace 'SonarCloudUrl', $SonarCloudUrl | Set-Content README.md

# Run composer install
Write-Host "Running composer install..."

Check warning on line 25 in install.ps1

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

install.ps1#L25

File 'install.ps1' uses Write-Host. Avoid using Write-Host because it might not work in all hosts, does not work when there is no host, and (prior to PS 5.0) cannot be suppressed, captured, or redirected. Instead, use Write-Output, Write-Verbose, or Write-Information.
composer install

Write-Host "Project setup complete."

Check warning on line 28 in install.ps1

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

install.ps1#L28

File 'install.ps1' uses Write-Host. Avoid using Write-Host because it might not work in all hosts, does not work when there is no host, and (prior to PS 5.0) cannot be suppressed, captured, or redirected. Instead, use Write-Output, Write-Verbose, or Write-Information.

# Additional PHP setup tasks
Write-Host "Performing additional PHP setup tasks..."

Check warning on line 31 in install.ps1

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

install.ps1#L31

File 'install.ps1' uses Write-Host. Avoid using Write-Host because it might not work in all hosts, does not work when there is no host, and (prior to PS 5.0) cannot be suppressed, captured, or redirected. Instead, use Write-Output, Write-Verbose, or Write-Information.
# Add any additional setup commands here

Write-Host "Setup finished successfully."

Check warning on line 34 in install.ps1

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

install.ps1#L34

File 'install.ps1' uses Write-Host. Avoid using Write-Host because it might not work in all hosts, does not work when there is no host, and (prior to PS 5.0) cannot be suppressed, captured, or redirected. Instead, use Write-Output, Write-Verbose, or Write-Information.
41 changes: 41 additions & 0 deletions install.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
#!/bin/bash

echo "Enter the project name:"
read -r project_name

echo "Enter the default namespace:"
read -r namespace

echo "Enter the SonarCloud URL:"
read -r sonarcloud_url

echo "Enter the HealthChecks.io ID:"
read -r healthchecks_id

echo "Setting up project: $project_name"

# Update .wakatime and README.md
sed -i "s/TemplateProject/$project_name/g" .wakatime-project
sed -i "s/TemplateProject/$project_name/g" README.md

# Update composer.json
sed -i "s/TemplateNamespace/$namespace/g" composer.json

# Update Healthchecks.io badge
echo "Please create a HealthChecks.io account if needed."
sed -i "s/HealthChecksId/$healthchecks_id/g" README.md

# Update SonarCloud URL
sed -i "s|SonarCloudUrl|$sonarcloud_url|g" README.md

# Run composer install
echo "Running composer install..."
composer install

echo "Project setup complete."

# Additional PHP setup tasks
echo "Performing additional PHP setup tasks..."
# Add any additional setup commands here

echo "Setup finished successfully."