refactor: Add js-yaml dep, scrtipt gen tweaks.
* Make the synthetic "base name" property double underscore prefixed, since internal, and to avoid future conflicts w/ YAML format add'ns. * Switch to PS hash dictionaries for our metadata collections for saner data inspection/use.
This commit is contained in:
parent
e544d74948
commit
01d2102c23
6 changed files with 600 additions and 1445 deletions
1968
docs/package-lock.json
generated
1968
docs/package-lock.json
generated
File diff suppressed because it is too large
Load diff
|
@ -20,14 +20,15 @@
|
|||
"@fortawesome/fontawesome-svg-core": "^1.2.32",
|
||||
"@fortawesome/free-solid-svg-icons": "^5.15.3",
|
||||
"@fortawesome/react-fontawesome": "^0.1.14",
|
||||
"@mdx-js/react": "^1.6.22",
|
||||
"classnames": "^2.2.6",
|
||||
"js-yaml": "^4.1.0",
|
||||
"react": "^17.0.2",
|
||||
"react-async": "^10.0.1",
|
||||
"react-copy-to-clipboard": "^5.0.3",
|
||||
"react-dom": "^17.0.2",
|
||||
"react-toastify": "^7.0.4",
|
||||
"web-tree-sitter": "^0.19.4",
|
||||
"@mdx-js/react": "^1.6.22"
|
||||
"web-tree-sitter": "^0.19.4"
|
||||
},
|
||||
"browserslist": {
|
||||
"production": [
|
||||
|
@ -42,6 +43,11 @@
|
|||
]
|
||||
},
|
||||
"devDependencies": {
|
||||
"@docusaurus/module-type-aliases": "^2.0.0-beta.3",
|
||||
"@tsconfig/docusaurus": "^1.0.2",
|
||||
"@types/react": "^17.0.3",
|
||||
"@types/react-helmet": "^6.1.0",
|
||||
"@types/react-router-dom": "^5.1.7",
|
||||
"eslint": "^7.32.0",
|
||||
"eslint-config-prettier": "^8.3.0",
|
||||
"eslint-plugin-mdx": "^1.13.0",
|
||||
|
@ -53,11 +59,6 @@
|
|||
"prettier": "2.3.1",
|
||||
"string-replace-loader": "^3.0.3",
|
||||
"typescript": "^4.2.3",
|
||||
"webpack": "^5.46.0",
|
||||
"@docusaurus/module-type-aliases": "^2.0.0-beta.3",
|
||||
"@tsconfig/docusaurus": "^1.0.2",
|
||||
"@types/react": "^17.0.3",
|
||||
"@types/react-helmet": "^6.1.0",
|
||||
"@types/react-router-dom": "^5.1.7"
|
||||
"webpack": "^5.46.0"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -12,7 +12,7 @@ const glob = require("glob");
|
|||
function generateHardwareMetadataAggregate() {
|
||||
glob("../app/boards/**/*.zmk.yml", (error, files) => {
|
||||
const aggregated = files.flatMap((f) =>
|
||||
yaml.safeLoadAll(fs.readFileSync(f, "utf8"))
|
||||
yaml.loadAll(fs.readFileSync(f, "utf8"))
|
||||
);
|
||||
fs.writeFileSync(
|
||||
"src/data/hardware-metadata.json",
|
||||
|
|
|
@ -14,8 +14,8 @@ const Mustache = require("mustache");
|
|||
function generateSetupScripts() {
|
||||
return glob("../app/boards/**/*.zmk.yml", (error, files) => {
|
||||
const aggregated = files.map((f) => ({
|
||||
...yaml.safeLoadAll(fs.readFileSync(f, "utf8"))[0],
|
||||
base_dir: path.basename(path.dirname(f)),
|
||||
...yaml.load(fs.readFileSync(f, "utf8")),
|
||||
__base_dir: path.basename(path.dirname(f)),
|
||||
}));
|
||||
|
||||
const data = aggregated.reduce(
|
||||
|
|
|
@ -91,44 +91,54 @@ Write-Host ""
|
|||
Write-Host "Keyboard Shield Selection:"
|
||||
$prompt = "Pick a keyboard"
|
||||
|
||||
$keyboards = [ordered]@{
|
||||
{{#keyboards}}
|
||||
"{{id}}" = @{
|
||||
name = "{{{name}}}";
|
||||
type = "{{type}}";
|
||||
basedir = "{{__base_dir}}";
|
||||
split = "{{split}}";
|
||||
arch = "{{arch}}";
|
||||
siblings = {{#siblings.0}}@(
|
||||
{{#siblings}}
|
||||
"{{.}}"
|
||||
{{/siblings}}
|
||||
){{/siblings.0}}{{^siblings.0}}( "{{id}}" ){{/siblings.0}};
|
||||
}
|
||||
{{/keyboards}}
|
||||
}
|
||||
# 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
|
||||
$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])
|
||||
$choice = Get-Choice-From-Options -Options ($keyboards.values | % { $_['name'] }) -Prompt $prompt
|
||||
$keyboard = $($($keyboards.keys)[$choice])
|
||||
$keyboard_title = $keyboards[$keyboard].name
|
||||
$basedir = $keyboards[$keyboard].basedir
|
||||
$keyboard_split = $keyboards[$keyboard].split
|
||||
$keyboard_arch = $keyboards[$keyboard].arch
|
||||
$keyboard_siblings = $keyboards[$keyboard].siblings
|
||||
$keyboard_type = $keyboards[$keyboard].type
|
||||
|
||||
if ($keyboard_type -eq "shield") {
|
||||
$prompt = "Pick an MCU board"
|
||||
$options = {{#boards}}"{{{name}}}", {{/boards}} "" | Where-Object { $_ -ne "" }
|
||||
$boards = {{#boards}}"{{id}}", {{/boards}} "" | Where-Object { $_ -ne "" }
|
||||
$boards = [ordered]@{
|
||||
{{#boards}}
|
||||
{{id}} = "{{{name}}}";
|
||||
{{/boards}}
|
||||
}
|
||||
|
||||
Write-Host "$title"
|
||||
Write-Host ""
|
||||
Write-Host "MCU Board Selection:"
|
||||
|
||||
$choice = Get-Choice-From-Options -Options $options -Prompt $prompt
|
||||
$choice = Get-Choice-From-Options -Options $boards.values -Prompt $prompt
|
||||
$shields = $keyboard_siblings
|
||||
$board = $($boards[$choice])
|
||||
$board = $($($boards.keys)[$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") {
|
||||
|
|
|
@ -72,7 +72,7 @@ options=({{#keyboards}}"{{{name}}}" {{/keyboards}})
|
|||
keyboards_id=({{#keyboards}}"{{id}}" {{/keyboards}})
|
||||
keyboards_type=({{#keyboards}}"{{type}}" {{/keyboards}})
|
||||
keyboards_arch=({{#keyboards}}"{{arch}}" {{/keyboards}})
|
||||
keyboards_basedir=({{#keyboards}}"{{base_dir}}" {{/keyboards}})
|
||||
keyboards_basedir=({{#keyboards}}"{{__base_dir}}" {{/keyboards}})
|
||||
keyboards_split=({{#keyboards}}"{{#split}}y{{/split}}{{^split}}n{{/split}}" {{/keyboards}})
|
||||
keyboards_shield=({{#keyboards}}"{{#compatible}}y{{/compatible}}{{^compatible}}n{{/compatible}}" {{/keyboards}})
|
||||
|
||||
|
|
Loading…
Reference in a new issue