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

Add macro config per user, refactor & add tests #3

Merged
merged 20 commits into from
Apr 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# EditorConfig is awesome: https://EditorConfig.org

# top-most EditorConfig file
root = true

# Unix-style newlines with a newline ending every file
[*]
end_of_line = lf
insert_final_newline = true

# Matches multiple files with brace expansion notation
# Set default charset
[*.{js,ts}]
charset = utf-8
# 4 space indentation
indent_style = space
indent_size = 4

# Matches the exact file: package.json - and yaml files
[{package.json,*.yml}]
indent_style = space
indent_size = 2
3 changes: 2 additions & 1 deletion .env.dist
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
USER_NAME="githubUserName"
LAYOUT_ID="default"
LAYOUT_FOLDER="moonlander_moonlander-default-layout_source"
LAYOUT_DIR="./layout_src"
LAYOUT_SRC="./layout_src"
15 changes: 15 additions & 0 deletions .eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
module.exports = {
extends: [
'eslint:recommended',
'plugin:@typescript-eslint/recommended',
'plugin:@typescript-eslint/recommended-requiring-type-checking',
],
parser: '@typescript-eslint/parser',
plugins: ['@typescript-eslint'],
parserOptions: {
project: true,
tsconfigRootDir: __dirname,
},
root: true,
ignorePatterns: [".eslintrc.cjs", "babel.config.cjs"]
};
26 changes: 26 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: Node Test/Lint CI

on:
push:
workflow_dispatch:

jobs:
test:
runs-on: ubuntu-latest
name: Run your tests
env:
LAYOUT_ID: ${{ vars.LAYOUT_ID }}
LAYOUT_FOLDER: ${{ vars.LAYOUT_FOLDER }}
CI: true
steps:
- uses: actions/checkout@v3
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: 16.x
- name: Install
run: npm install
- name: Lint
run: npm run lint
- name: Test
run: npm run test
7 changes: 4 additions & 3 deletions .github/workflows/process.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,13 @@ jobs:
env:
LAYOUT_ID: ${{ vars.LAYOUT_ID }}
LAYOUT_FOLDER: ${{ vars.LAYOUT_FOLDER }}
USER_NAME: ${{ github.event.repository.owner.name }}
steps:
- uses: actions/checkout@v1
- uses: actions/checkout@v3
- name: Use Node.js
uses: actions/setup-node@v1
uses: actions/setup-node@v3
with:
node-version: 14.x
node-version: 16.x
- name: Install
run: npm install
- name: Get ORYX layout
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
node_modules
coverage
test
layout_src
.env
7 changes: 7 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"semi": true,
"trailingComma": "all",
"singleQuote": false,
"printWidth": 80,
"useTabs": false
}
20 changes: 8 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Ergodox Macro Hax
# Oryx Macro Hax

This is a quick and dirty script to nicely get around the annoying (though reasonable) limitation of Ergodox / Moonlander keyboards in the Oryx configurator where macros can only be five key sequences for security reasons.

Expand Down Expand Up @@ -39,12 +39,12 @@ It is also recommended to `git branch <your layout name>` and gitignore allowlis
## 2. Create a mapping in this script


Grab macros.ts or example and change it to what you need
Copy `macros/example.ts` and change it to what you need, use your lowercased username for the filename.

Here's an example of creating an extended (more than five character) macro:

```
const macro = newMacro()
"funct": newMacro()
.typeAlphanumeric("function") // Supports a-z and 0-9
.sendRawCmd("SS_DELAY(100)") // Raw commands in the C file
.tapKey("X_SPACE") // Tap a raw key code
Expand All @@ -68,19 +68,15 @@ The name of the macro tells the system what to replace. always start with 'dance
.typeAlphanumeric("cp ../moonlander_hacked.bin /mnt/c/tools/"),

```
### Tests `npm test (--watch | --coverage)`

You can also create a `user_name.process_record_user.spec.ts` (integration test) or unit tests if you like TDD and test coverage, please also add a unit test if you add a feature to the MacroBuilder!

## 3. Run the post-processor `npm start`

## 3. Run the post-processor
Run to modify your `keymap.c` and extend your macros. By default layoutFolderName is 'moonlander_default-layout_source'

Run to modify your config and extend your macros. By default layoutFolderName is 'moonlander_default-layout_source'

```
cd ~/qmk_firmware/ergodox-macro-hax
npm run hax -- <layoutFolderName>
```

Run `npm run copy` to copy the processed keymap to the parent keymaps folder (../keyboards/moonlander/keymaps/hacked).
Optionally, run `npm run copy` to copy the processed keymap to the parent keymaps folder (../keyboards/moonlander/keymaps/hacked).

## 4. Build Modified Source and Flash it!

Expand Down
6 changes: 6 additions & 0 deletions babel.config.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
module.exports = {
presets: [
['@babel/preset-env', {targets: {node: 'current'}}],
'@babel/preset-typescript',
],
};
Loading