Skip to content

Commit

Permalink
deps: Fixes on commits about adding scripts to deps.json
Browse files Browse the repository at this point in the history
Signed-off-by: Andre Riesco <[email protected]>
  • Loading branch information
andreriesco committed Mar 18, 2024
1 parent 318aa53 commit 176cfe9
Show file tree
Hide file tree
Showing 17 changed files with 77 additions and 109 deletions.
2 changes: 1 addition & 1 deletion aspnetBlazor/.conf/deps.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@
"sshpass"
],
"installDepsScripts": [
".conf/install-deps-scripts/install-dotnet-sdk-8.sh"
".conf/installDepsScripts/install-dotnet-sdk-8.sh"
]
}
4 changes: 2 additions & 2 deletions dotnetAvalonia/.conf/deps.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"libgtk-3-dev"
],
"installDepsScripts": [
".conf/install-deps-scripts/install-dotnet-sdk-7.sh",
".conf/install-deps-scripts/install-dotnet-sdk-8.sh"
".conf/installDepsScripts/install-dotnet-sdk-7.sh",
".conf/installDepsScripts/install-dotnet-sdk-8.sh"
]
}
4 changes: 2 additions & 2 deletions dotnetAvaloniaFrameBuffer/.conf/deps.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"sshpass"
],
"installDepsScripts": [
".conf/install-deps-scripts/install-dotnet-sdk-7.sh",
".conf/install-deps-scripts/install-dotnet-sdk-8.sh"
".conf/installDepsScripts/install-dotnet-sdk-7.sh",
".conf/installDepsScripts/install-dotnet-sdk-8.sh"
]
}
2 changes: 1 addition & 1 deletion dotnetConsole/.conf/deps.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@
"sshpass"
],
"installDepsScripts": [
".conf/install-deps-scripts/install-dotnet-sdk-8.sh"
".conf/installDepsScripts/install-dotnet-sdk-8.sh"
]
}
41 changes: 0 additions & 41 deletions dotnetConsole/.conf/install-deps-scripts/install-dotnet-sdk-8.sh

This file was deleted.

2 changes: 1 addition & 1 deletion dotnetSlint/.conf/deps.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@
"sshpass"
],
"installDepsScripts": [
".conf/install-deps-scripts/install-dotnet-sdk-8.sh"
".conf/installDepsScripts/install-dotnet-sdk-8.sh"
]
}
2 changes: 1 addition & 1 deletion dotnetUno/.conf/deps.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@
"libgtk-3-dev"
],
"installDepsScripts": [
".conf/install-deps-scripts/install-dotnet-sdk-6.sh"
".conf/installDepsScripts/install-dotnet-sdk-6.sh"
]
}
2 changes: 1 addition & 1 deletion dotnetUno5/.conf/deps.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@
"libgtk-3-dev"
],
"installDepsScripts": [
".conf/install-deps-scripts/install-dotnet-sdk-8.sh"
".conf/installDepsScripts/install-dotnet-sdk-8.sh"
]
}
2 changes: 1 addition & 1 deletion dotnetUno5FrameBuffer/.conf/deps.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@
"libgtk-3-dev"
],
"installDepsScripts": [
".conf/install-deps-scripts/install-dotnet-sdk-8.sh"
".conf/installDepsScripts/install-dotnet-sdk-8.sh"
]
}
2 changes: 1 addition & 1 deletion dotnetUnoFrameBuffer/.conf/deps.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@
"sshpass"
],
"installDepsScripts": [
".conf/install-deps-scripts/install-dotnet-sdk-6.sh"
".conf/installDepsScripts/install-dotnet-sdk-6.sh"
]
}
2 changes: 1 addition & 1 deletion monoCsharpForms/.conf/deps.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@
"nuget"
],
"installDepsScripts": [
".conf/install-deps-scripts/install-mono-devel.sh"
".conf/installDepsScripts/install-mono-devel.sh"
]
}
91 changes: 50 additions & 41 deletions scripts/checkDeps.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -70,32 +70,48 @@ foreach ($script in $_deps.installDepsScripts) {

if ($scriptInstalled -eq $false) {
$_scriptsToInstall.Add($script)
Write-Host -ForegroundColor DarkRed "😵 $script dependency installation script not executed before for this project on this machine"
Write-Host -ForegroundColor DarkRed "😵 $script dependency installation script not executed before for this project"
} else {
Write-Host -ForegroundColor DarkGreen "👍 $script dependency installation script executed before for this project on this machine"
Write-Host -ForegroundColor DarkGreen "👍 $script dependency installation script executed before for this project"
}
}

# Check if there are any packages to be installed or scripts to be executed
if ($_packagesToInstall.Count -eq 0 -and $_scriptsToInstall.Count -eq 0) {
Write-Host -ForegroundColor DarkGreen "✅ All packages already installed and installation script executed before for this project on this machine"
if (
($_packagesToInstall.Count -eq 0) -and
($_scriptsToInstall.Count -eq 0)

# we need to ran the check deps only if it's not ran yet
New-Item -Path .conf/ -Name .depok -ItemType File 2>&1 | out-null
} else {
) {
Write-Host -ForegroundColor DarkGreen "✅ All packages already installed and installation scripts executed before for this project"

$_packagesInstalledOk = $true
$_scriptsInstalledOk = $true
# all packages installed and installation scripts executed before create dep ok if it doesn't already exist
if ( -not (Test-Path ./.conf/.depok)){
New-Item -Path .conf/ -Name .depok -ItemType File 2>&1 | out-null
}
} else {

# ask if the user want to install the packages that are not installed
# Check if there are packages to be installed and/or scripts to be executed
if ($_packagesToInstall.Count -gt 0) {
$_packagesInstalledOk = $false
} else {
$_packagesInstalledOk = $true
}

if ($_scriptsToInstall.Count -gt 0) {
$_scriptsInstalledOk = $false
} else {
$_scriptsInstalledOk = $true
}

$_packagesInstalledOk = $false

$_installConfirm = Read-Host `
"Do you want to try to install the missing debian package dependencies? <y/N>"
"Try to install the missing debian packages and execute the missing installation scripts? <y/N>"

if ($_installConfirm -eq 'y') {

# ask if the user want to install the packages that are not installed
if ($_packagesToInstall.Count -gt 0) {

if ($_installConfirm -eq 'y') {
# make sure to update the list first
sudo apt-get update

Expand All @@ -116,45 +132,38 @@ if ($_packagesToInstall.Count -eq 0 -and $_scriptsToInstall.Count -eq 0) {
$_packagesInstalledOk = $true

}
}
# ask if the user want to execute the installation scripts that have not been executed before for this project on this machine
if ($_scriptsToInstall.Count -gt 0) {
# ask if the user want to execute the installation scripts that have not been executed before for this project on this machine
if ($_scriptsToInstall.Count -gt 0) {

$_scriptsInstalledOk = $false

$_installConfirm = Read-Host `
"Do you want to try to install the missing debian package dependencies? <y/N>"

if ($_installConfirm -eq 'y') {

$_installedScrips = New-Object Collections.Generic.List[string]
$_installedScrips = New-Object Collections.Generic.List[string]

# Try to execute the installation scripts
foreach ($item in $_scriptsToInstall) {
if ($item.EndsWith('.sh')) {
chmod +x $item
}
# Try to execute the installation scripts
foreach ($item in $_scriptsToInstall) {
if ($item.EndsWith('.sh')) {
chmod +x $item
}

$_installedScrips.Add($item)
& ./$item 2>&1
$_installedScrips.Add($item)
& ./$item 2>&1

if ($? -eq $false) {
Write-Host -ForegroundColor DarkRed "❌ error trying to execute the dependency installation script $item"
exit 69
}
if ($? -eq $false) {
Write-Host -ForegroundColor DarkRed "❌ error trying to execute the dependency installation script $item"
exit 69
}
}

Write-Host -ForegroundColor DarkGreen "✅ All packages dependency installation scripts executed successfully"

$_scriptsInstalledOk = $true
Write-Host -ForegroundColor DarkGreen "✅ All dependency installation scripts executed successfully"

}
$_scriptsInstalledOk = $true
}

}
if ($_packagesInstalledOk -eq $true -and $_scriptsInstalledOk -eq $true) {

# all packages installed then dep ok
New-Item -Path .conf/ -Name .depok -ItemType File 2>&1 | out-null
# all packages installed and installation scripts executed before create dep ok if it doesn't already exist
if ( -not (Test-Path ./.conf/.depok)){
New-Item -Path .conf/ -Name .depok -ItemType File 2>&1 | out-null
}

# Add the name of the scripts to the .conf/.depok to know that it has
# already been executed for this project on this machine
Expand Down
16 changes: 8 additions & 8 deletions scripts/createFromTemplate.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -152,20 +152,20 @@ $_deps = Get-Content "$templateFolder/.conf/deps.json" | ConvertFrom-Json

# If there are installation scripts listed on the .conf/deps.json of the template
if (($_deps.installDepsScripts.Count -gt 0)) {
# Create the .conf/install-deps-scripts if it doesn't exist and there are
# installation scripts that have the path .conf/install-deps-scripts
if (-not (Test-Path -Path "$location/.conf/install-deps-scripts" )){
New-Item -ItemType Directory -Path "$location/.conf/install-deps-scripts"
# Create the .conf/installDepsScripts if it doesn't exist and there are
# installation scripts that have the path .conf/installDepsScripts
if (-not (Test-Path -Path "$location/.conf/installDepsScripts" )){
New-Item -ItemType Directory -Path "$location/.conf/installDepsScripts"
}

# If there is no script in the .conf/install-deps-scripts of the template, but there is some script defined in the
# installDepsScripts with the .conf/install-deps-scripts path, then it comes from the scripts/install-deps-scripts
# If there is no script in the .conf/installDepsScripts of the template, but there is some script defined in the
# installDepsScripts with the .conf/installDepsScripts path, then it comes from the scripts/installDepsScripts
# folder of the vscode-torizon-templates repo. This is useful when there are scripts that are common for many
# templates, like the install-dotnet-sdk-8.sh one for example.
foreach ($script in $_deps.installDepsScripts) {
if ((-not (Test-Path -Path "$location/$script" )) -and
$script -match ".conf/install-deps-scripts") {
# Copy the script from the scripts/install-deps-scripts folder to the .conf/install-deps-scripts folder of the template
$script -match ".conf/installDepsScripts") {
# Copy the script from the scripts/installDepsScripts folder to the .conf/installDepsScripts folder of the template
$scriptSource = $script.Replace(".conf","scripts")
Copy-Item "$templateFolder/../$scriptSource" "$location/$script"
}
Expand Down
14 changes: 7 additions & 7 deletions scripts/projectUpdater.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -243,19 +243,19 @@ $_deps = Get-Content ./deps.json | ConvertFrom-Json

# If there are installation scripts listed on the .conf/deps.json of the template
if (($_deps.installDepsScripts.Count -gt 0)) {
# Create the install-deps-scripts dir on the .conf/tmp dir
if (-not (Test-Path -Path ./install-deps-scripts )){
New-Item -ItemType Directory -Path ./install-deps-scripts
# Create the installDepsScripts dir on the .conf/tmp dir
if (-not (Test-Path -Path ./installDepsScripts )){
New-Item -ItemType Directory -Path ./installDepsScripts
}
# If there is no script in the .conf/install-deps-scripts of the template, but there is some script defined in the
# installDepsScripts with the .conf/install-deps-scripts path, then it comes from the scripts/install-deps-scripts
# If there is no script in the .conf/installDepsScripts of the template, but there is some script defined in the
# installDepsScripts with the .conf/installDepsScripts path, then it comes from the scripts/installDepsScripts
# folder of the vscode-torizon-templates repo. This is useful when there are scripts that are common for many
# templates, like the install-dotnet-sdk-8.sh one for example.
foreach ($script in $_deps.installDepsScripts) {

if ((-not (Test-Path -Path $Env:HOME/.apollox/$templateName/$script )) -and
$script -match ".conf/install-deps-scripts") {
# Copy the script from the scripts/install-deps-scripts folder to the .conf/install-deps-scripts folder of the template
$script -match ".conf/installDepsScripts") {
# Copy the script from the scripts/installDepsScripts folder to the .conf/installDepsScripts folder of the template
$scriptSource = $script.Replace(".conf","scripts")
$scriptDest = $script.Replace(".conf/","")
Copy-Item $Env:HOME/.apollox/$scriptSource ./$scriptDest
Expand Down

0 comments on commit 176cfe9

Please sign in to comment.