fix(setup): Make keymap/conf fall back to using dirname

This commit is contained in:
Cem Aksoylar 2022-12-16 14:43:47 -08:00 committed by Pete Johanson
parent ebb4cb76d3
commit b8fb218a01
2 changed files with 36 additions and 23 deletions

View file

@ -209,27 +209,36 @@ Set-Location "$repo_name"
Push-Location config
$config_file = "${keyboard}.conf"
$keymap_file = "${keyboard}.keymap"
if ($keyboard_type -eq "shield") {
$config_url = "https://raw.githubusercontent.com/zmkfirmware/zmk/main/app/boards/shields/${basedir}/${keyboard}.conf"
$keymap_url = "https://raw.githubusercontent.com/zmkfirmware/zmk/main/app/boards/shields/${basedir}/${keyboard}.keymap"
$url_base = "https://raw.githubusercontent.com/zmkfirmware/zmk/main/app/boards/shields/${basedir}"
} else {
$config_url = "https://raw.githubusercontent.com/zmkfirmware/zmk/main/app/boards/${keyboard_arch}/${basedir}/${keyboard}.conf"
$keymap_url = "https://raw.githubusercontent.com/zmkfirmware/zmk/main/app/boards/${keyboard_arch}/${basedir}/${keyboard}.keymap"
$url_base = "https://raw.githubusercontent.com/zmkfirmware/zmk/main/app/boards/${keyboard_arch}/${basedir}"
}
Write-Host "Downloading config file (${config_url})"
Write-Host "Downloading config file (${url_base}/${keyboard}.conf)"
Try {
Invoke-RestMethod -Uri "${config_url}" -OutFile "${config_file}"
Invoke-RestMethod -Uri "${config_url}" -OutFile "${keyboard}.conf"
} Catch {
Set-Content -Path $config_file "# Place configuration items here"
Try {
Write-Host "Could not find it, falling back to ${url_base}/${basedir}.conf"
Invoke-RestMethod -Uri "${url_base}/${basedir}.conf" -OutFile "${basedir}.conf"
} Catch {
Set-Content -Path "${keyboard}.conf" "# Put configuration options here"
}
}
if ($copy_keymap -eq "yes") {
Write-Host "Downloading keymap file (${keymap_url})"
Invoke-RestMethod -Uri "${keymap_url}" -OutFile "${keymap_file}"
Write-Host "Downloading keymap file (${url_base}/${keyboard}.keymap)"
Try {
Invoke-RestMethod -Uri "${url_base}/${keyboard}.keymap" -OutFile "${keyboard}.keymap"
} Catch {
Write-Host "Could not find it, falling back to ${url_base}/${basedir}.keymap"
Try {
Invoke-RestMethod -Uri "${url_base}/${basedir}.keymap" -OutFile "${basedir}.keymap"
} Catch {
Write-Host "Warning: Could not find a keymap file to download!"
}
}
}
Pop-Location
@ -264,7 +273,7 @@ if ($github_repo -ne "") {
Write-Host " git remote rm origin"
Write-Host " git remote add origin FIXED_URL"
Write-Host " git push --set-upstream origin $(git symbolic-ref --short HEAD)"
Write-Host "Once pushed, your firmware should be availalbe from GitHub Actions at: $actions"
Write-Host "Once pushed, your firmware should be available from GitHub Actions at: $actions"
exit 1
}

View file

@ -205,19 +205,23 @@ cd ${repo_name}
pushd config
if [ "$keyboard_shield" == "y" ]; then
config_file="https://raw.githubusercontent.com/zmkfirmware/zmk/main/app/boards/shields/${keyboard_basedir}/${shield}.conf"
keymap_file="https://raw.githubusercontent.com/zmkfirmware/zmk/main/app/boards/shields/${keyboard_basedir}/${shield}.keymap"
url_base="https://raw.githubusercontent.com/zmkfirmware/zmk/main/app/boards/shields/${keyboard_basedir}"
else
config_file="https://raw.githubusercontent.com/zmkfirmware/zmk/main/app/boards/${keyboard_arch}/${keyboard_basedir}/${board}.conf"
keymap_file="https://raw.githubusercontent.com/zmkfirmware/zmk/main/app/boards/${keyboard_arch}/${keyboard_basedir}/${board}.keymap"
url_base="https://raw.githubusercontent.com/zmkfirmware/zmk/main/app/boards/${keyboard_arch}/${keyboard_basedir}"
fi
echo "Downloading config file (${url_base}/${keyboard}.conf)"
if ! $download_command "${url_base}/${keyboard}.conf"; then
echo "Could not find it, falling back to ${url_base}/${keyboard_basedir}.conf"
$download_command "${url_base}/${keyboard_basedir}.conf" || echo "# Put configuration options here" > "${keyboard}.conf"
fi
echo "Downloading config file (${config_file})"
$download_command "${config_file}" || echo "# Put configuration options here" > "${keyboard}.conf"
if [ "$copy_keymap" == "yes" ]; then
echo "Downloading keymap file (${keymap_file})"
$download_command "${keymap_file}"
echo "Downloading keymap file (${url_base}/${keyboard}.keymap)"
if ! $download_command "${url_base}/${keyboard}.keymap"; then
echo "Could not find it, falling back to ${url_base}/${keyboard_basedir}.keymap"
$download_command "${url_base}/${keyboard_basedir}.keymap" || echo "Warning: Could not find a keymap file to download!"
fi
fi
popd
@ -254,7 +258,7 @@ if [ -n "$github_repo" ]; then
echo " git remote rm origin"
echo " git remote add origin FIXED_URL"
echo " git push --set-upstream origin $(git symbolic-ref --short HEAD)"
echo "Once pushed, your firmware should be availalbe from GitHub Actions at: ${github_repo%.git}/actions"
echo "Once pushed, your firmware should be available from GitHub Actions at: ${github_repo%.git}/actions"
exit 1
fi