@ -84,20 +84,9 @@ if (Test-CommandExists Get-Acl) {
@@ -84,20 +84,9 @@ if (Test-CommandExists Get-Acl) {
}
}
$repo_path = "https://github.com/zmkfirmware/zmk-config-split -template.git"
$repo_path = "https://github.com/zmkfirmware/unified- zmk-config-template.git"
$title = "ZMK Config Setup:"
$prompt = "Pick an MCU board"
$options = {{#boards}}"{{{name}}}", {{/boards}} "" | Where-Object { $_ -ne "" }
$boards = {{#boards}}"{{id}}", {{/boards}} "" | Where-Object { $_ -ne "" }
Write-Host "$title"
Write-Host ""
Write-Host "MCU Board Selection:"
$choice = Get-Choice-From-Options -Options $options -Prompt $prompt
$board = $($boards[$choice])
Write-Host ""
Write-Host "Keyboard Shield Selection:"
$prompt = "Pick a keyboard"
@ -105,17 +94,41 @@ $prompt = "Pick a keyboard"
@@ -105,17 +94,41 @@ $prompt = "Pick a keyboard"
# TODO: Add support for "Other" and linking to docs on adding custom shields in user config repos.
$options = {{#keyboards}}"{{name}}", {{/keyboards}} "" | Where-Object { $_ -ne "" }
$names = {{#keyboards}}"{{id}}", {{/keyboards}} "" | Where-Object { $_ -ne "" }
$types = {{#keyboards}}"{{type}}", {{/keyboards}} "" | Where-Object { $_ -ne "" }
$basedirs = {{#keyboards}}"{{base_dir}}", {{/keyboards}} "" | Where-Object { $_ -ne "" }
$splits = {{#keyboards}}"{{#split}}y{{/split}}{{^split}}n{{/split}}", {{/keyboards}} "" | Where-Object { $_ -ne "" }
$arches = {{#keyboards}}"{{arch}}", {{/keyboards}} "REMOVEME" | Where-Object { $_ -ne "REMOVEME" }
$basedirs = {{#keyboards}}"{{base_dir}}", {{/keyboards}} "" | Where-Object { $_ -ne "" }
$sibling_sets = {{#keyboards}}{{#siblings.0}}( {{#siblings}}"{{.}}",{{/siblings}} "" | Where-Object { $_ -ne "" } ){{/siblings.0}}{{^siblings.0}}( "{{id}}" ){{/siblings.0}}, {{/keyboards}} "REMOVEME" | Where-Object { $_ -ne "REMOVEME" }
$choice = Get-Choice-From-Options -Options $options -Prompt $prompt
$shield_title = $($options[$choice])
$shield = $($names[$choice])
$split = $($splits[$choice])
$keyboard_title = $($options[$choice])
$keyboard = $($names[$choice])
$basedir = $($basedirs[$choice])
$keyboard_split = $($splits[$choice])
$keyboard_arch = $($arches[$choice])
$keyboard_siblings = $($sibling_sets[$choice])
$keyboard_type = $($types[$choice])
if ($split -eq "n") {
$repo_path = "https://github.com/zmkfirmware/zmk-config-template.git"
if ($keyboard_type -eq "shield") {
$prompt = "Pick an MCU board"
$options = {{#boards}}"{{{name}}}", {{/boards}} "" | Where-Object { $_ -ne "" }
$boards = {{#boards}}"{{id}}", {{/boards}} "" | Where-Object { $_ -ne "" }
Write-Host "$title"
Write-Host ""
Write-Host "MCU Board Selection:"
$choice = Get-Choice-From-Options -Options $options -Prompt $prompt
$shields = $keyboard_siblings
$board = $($boards[$choice])
$boards = ( $board )
} else {
$boards = ( $keyboard_siblings )
$shields = @( )
}
$copy_keymap = Read-Host "Copy in the stock keymap for customisation? [Yn]"
if ($copy_keymap -eq "" -or $copy_keymap -eq "Y" -or $copy_keymap -eq "y") {
@ -144,8 +157,12 @@ else {
@@ -144,8 +157,12 @@ else {
Write-Host ""
Write-Host "Preparing a user config for:"
Write-Host "* MCU Board: ${board}"
Write-Host "* Shield: ${shield}"
if ($keyboard_type -eq "shield") {
Write-Host "* MCU Board: ${boards}"
Write-Host "* Shield(s): ${shields}"
} else {
Write-Host "* Board(s): ${boards}"
}
if ($copy_keymap -eq "yes") {
Write-Host "* Copy Keymap?: Yes"
@ -171,24 +188,43 @@ Set-Location "$repo_name"
@@ -171,24 +188,43 @@ Set-Location "$repo_name"
Push-Location config
Invoke-RestMethod -Uri "https://raw.githubusercontent.com/zmkfirmware/zmk/main/app/boards/shields/${shield}/${shield}.conf" -OutFile "${shield}.conf"
$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"
} 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"
}
Write-Host "Downloading config file (${config_url})"
Try {
Invoke-RestMethod -Uri "${config_url}" -OutFile "${config_file}"
} Catch {
Set-Content -Path $config_file "# Place configuration items here"
}
if ($copy_keymap -eq "yes") {
Invoke-RestMethod -Uri "https://raw.githubusercontent.com/zmkfirmware/zmk/main/app/boards/shields/${shield}/${shield}.keymap" -OutFile "${shield}.keymap"
Write-Host "Downloading keymap file (${keymap_url})"
Invoke-RestMethod -Uri "${keymap_url}" -OutFile "${keymap_file}"
}
Pop-Location
$build_file = (Get-Content .github/workflows/build.yml).replace("BOARD_NAME", $board)
$build_file = $build_file.replace("SHIELD_NAME", $shield)
$build_file = $build_file.replace("KEYBOARD_TITLE", $shield_title)
if ($board -eq "proton_c") {
$build_file = $build_file.replace("uf2", "hex")
Add-Content -Path "build.yaml" -Value "include:"
foreach ($b in ${boards}) {
if ($keyboard_type -eq "shield") {
foreach ($s in ${shields}) {
Add-Content -Path "build.yaml" -Value " - board: $b"
Add-Content -Path "build.yaml" -Value " shield: $s"
}
} else {
Add-Content -Path "build.yaml" -Value " - board: $b"
}
}
Set-Content -Path .github/workflows/build.yml -Value $build_file
Remove-Item -Recurse -Force .git
git init .
git add .