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

Migrate some DEFAULT_FOLDER to keyboard_aliases.hjson #24835

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from

Conversation

zvecr
Copy link
Member

@zvecr zvecr commented Jan 20, 2025

Description

Migrated keyboard rules.mk which only contain DEFAULT_FOLDER and alias does not yet exist.

Script used
#!/bin/bash

head -n -2 data/mappings/keyboard_aliases.hjson > /tmp/keyboard_aliases.hjson
echo "    }," >> /tmp/keyboard_aliases.hjson
echo "    // DEFAULT_FOLDER removed during 2025 Q1 cycle" >> /tmp/keyboard_aliases.hjson

for rule in $(find keyboards/ -name rules.mk | sort | grep -v keymaps); do
    if [[ $(cat $rule | grep . | grep -Ev "^#.*" | grep -v DEFAULT_FOLDER | wc -l) == 0 ]]; then
        default_folder=$(cat $rule | grep . | grep -Ev "^#.*" | sed 's^DEFAULT_FOLDER[= ]*^^')
        kb_folder=$(echo $rule | sed 's?^keyboards/??' | sed 's^/rules.mk^^')
        # echo "ONLY DF - $rule - $kb_folder - $default_folder"

        if [[ ! -d keyboards/$default_folder ]]; then
            echo "DF no exists"
            continue
        fi
        
        if grep -q '\s"'$kb_folder'"' data/mappings/keyboard_aliases.hjson; then
            echo "dupe:$kb_folder"
            continue
        fi

        # append
        echo -e '    "'$kb_folder'": {\n        "target": "'$default_folder'"\n    },' >> /tmp/keyboard_aliases.hjson
        # remove
        rm -f $rule
    fi
done

# remove last ,
truncate -s-2 /tmp/keyboard_aliases.hjson

echo -e "\n}" >> /tmp/keyboard_aliases.hjson

mv /tmp/keyboard_aliases.hjson data/mappings/keyboard_aliases.hjson

Refactoring remaining use of DEFAULT_FOLDER will follow shortly after what can be automated.

Types of Changes

  • Core
  • Bugfix
  • New feature
  • Enhancement/optimization
  • Keyboard (addition or update)
  • Keymap/layout (addition or update)
  • Documentation

Issues Fixed or Closed by This PR

Checklist

  • My code follows the code style of this project: C, Python
  • I have read the PR Checklist document and have made the appropriate changes.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have read the CONTRIBUTING document.
  • I have added tests to cover my changes.
  • I have tested the changes and verified that they work and don't break anything (as well as I can manage).

@github-actions github-actions bot added keyboard dd Data Driven Changes labels Jan 20, 2025
@zvecr zvecr force-pushed the deprecate_default_folder2 branch from 48cf26c to dbcef19 Compare January 20, 2025 02:36
@zvecr zvecr force-pushed the deprecate_default_folder2 branch from dbcef19 to 522d5b5 Compare January 20, 2025 02:47
@zvecr zvecr marked this pull request as ready for review January 20, 2025 03:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
dd Data Driven Changes keyboard
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant