Skip to content

Commit

Permalink
Switch from old reader ref to latest @the-via/reader. Repaired defini…
Browse files Browse the repository at this point in the history
…tions that failed validation.
  • Loading branch information
ValdisThomann committed Jan 29, 2023
1 parent c9ca247 commit 6694ce4
Show file tree
Hide file tree
Showing 170 changed files with 7,759 additions and 7,325 deletions.
17 changes: 17 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
"prettier": "^2.2.1"
},
"dependencies": {
"@the-via/reader": "^1.5.5",
"@types/glob": "^7.1.1",
"@types/rimraf": "^2.0.3",
"fs-extra": "^9.1.0",
Expand Down
10 changes: 4 additions & 6 deletions scripts/build-isolated-definitions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import {
VIADefinitionV2,
VIADefinitionV3,
DefinitionVersion,
} from 'via-reader';
import {ValidateFunction} from 'via-reader/dist/validated-types/via-definition-v3.validator';
} from '@the-via/reader';
import {ValidateFunction} from '@the-via/reader/dist/validated-types/via-definition-v3.validator';
import {getDefinitionsPath, getOutputPath, getRelativePath} from './get-path';
import {hashJSON} from './hash-json';
/**
Expand Down Expand Up @@ -61,10 +61,8 @@ export const buildIsolatedDefinitions = async <
.map((key) => {
const vendorID = (parseInt(key) >> 16).toString(16).padStart(4, '0');
const productID = (parseInt(key) & 0xffff).toString(16).padStart(4, '0');
return (
`Duplicate ID vendorId=0x${vendorID} productId=0x${productID} in:
${IDsToPaths[key].join(',\n')}`
);
return `Duplicate ID vendorId=0x${vendorID} productId=0x${productID} in:
${IDsToPaths[key].join(',\n')}`;
});

if (conflictingVIADefinitions.length) {
Expand Down
2 changes: 1 addition & 1 deletion scripts/build-names.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import stringify from 'json-stringify-pretty-compact';
import * as glob from 'glob';
import * as fs from 'fs';
import {keyboardDefinitionV3ToVIADefinitionV3} from 'via-reader';
import {keyboardDefinitionV3ToVIADefinitionV3} from '@the-via/reader';
import process from 'process';
import {getDefinitionsPath, getOutputPath} from './get-path';

Expand Down
2 changes: 1 addition & 1 deletion scripts/build-v2.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import stringify from 'json-stringify-pretty-compact';
import * as glob from 'glob';
import * as fs from 'fs';
import {getTheme, keyboardDefinitionV2ToVIADefinitionV2} from 'via-reader';
import {getTheme, keyboardDefinitionV2ToVIADefinitionV2} from '@the-via/reader';
import process from 'process';
import path from 'path';
import {getDefinitionsPath, getOutputPath} from './get-path';
Expand Down
2 changes: 1 addition & 1 deletion scripts/build-v3.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
keyboardDefinitionV3ToVIADefinitionV3,
isVIADefinitionV2,
isVIADefinitionV3,
} from 'via-reader';
} from '@the-via/reader';
import stringify from 'json-stringify-pretty-compact';
import {buildIsolatedDefinitions} from './build-isolated-definitions';
import {getCommonMenusPath, getOutputPath} from './get-path';
Expand Down
19 changes: 10 additions & 9 deletions scripts/v2-to-v3.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {
LightingTypeDefinition,
LightingTypeDefinitionV2,
VIAMenu,
} from 'via-reader';
} from '@the-via/reader';
import fs from 'fs-extra';
import stringify from 'json-stringify-pretty-compact';

Expand All @@ -25,7 +25,7 @@ const OMITTED_V2_KEYS = [

type SUPPORTED_V2_KEYS = Omit<
KeyboardDefinitionV2,
typeof OMITTED_V2_KEYS[number]
(typeof OMITTED_V2_KEYS)[number]
>;

const isLightingTypeDefinition = (
Expand Down Expand Up @@ -106,7 +106,7 @@ const resolveKeycodes = (
enum coreMenus {
QMKRGBLight = 'qmk_rgblight',
QMKBacklight = 'qmk_backlight',
QMKBacklightRGBLight = 'qmk_backlight_rgblight'
QMKBacklightRGBLight = 'qmk_backlight_rgblight',
}

const WilbaPlsHalp = '!!!WILBA!!!';
Expand Down Expand Up @@ -150,10 +150,11 @@ const resolveMenus = (
};

const cleanObject = (obj: any) => {
return Object.keys(obj).reduce((acc,key) =>
(obj[key].length ? {...acc, [key]:obj[key]} : acc)
, {})
}
return Object.keys(obj).reduce(
(acc, key) => (obj[key].length ? {...acc, [key]: obj[key]} : acc),
{}
);
};

async function convertV2ToV3() {
const definitionFiles = await glob('src/**/*.json');
Expand Down Expand Up @@ -188,13 +189,13 @@ async function convertV2ToV3() {
name,
vendorId,
productId,
...cleanObject({keycodes,menus}),
...cleanObject({keycodes, menus}),
...supportedJson,
};

try {
//if ( ! v3Definition.menus?.includes(WilbaPlsHalp) ) {
fs.outputFile(`v3/${definition.path}`, stringify(v3Definition));
fs.outputFile(`v3/${definition.path}`, stringify(v3Definition));
//}
} catch (e) {
console.error(e);
Expand Down
109 changes: 95 additions & 14 deletions src/0xC7/61key/61key.json
Original file line number Diff line number Diff line change
@@ -1,16 +1,97 @@
{
"name": "61Key by 0xC7",
"vendorId": "0xE117",
"productId": "0x6161",
"lighting": "none",
"matrix": {"rows": 5, "cols": 14},
"layouts": {
"keymap": [
["0,0","0,1","0,2","0,3","0,4","0,5","0,6","0,7","0,8","0,9","0,10","0,11","0,12",{"w":2},"0,13"],
[{"w":1.5},"1,0","1,1","1,2","1,3","1,4","1,5","1,6","1,7","1,8","1,9","1,10","1,11","1,12",{"w":1.5},"1,13"],
[{"w":1.75},"2,0","2,1","2,2","2,3","2,4","2,5","2,6","2,7","2,8","2,9","2,10","2,11",{"w":2.25},"2,13"],
[{"w":2.25},"3,0","3,1","3,2","3,3","3,4","3,5","3,6","3,7","3,8","3,9","3,10",{"w":2.75},"3,13"],
[{"w":1.25},"4,0",{"w":1.25},"4,1",{"w":1.25},"4,2",{"a":7,"w":6.25},"4,5",{"a":4,"w":1.25},"4,8",{"w":1.25},"4,9",{"w":1.25},"4,11",{"w":1.25},"4,13"]
]
}
"name": "61Key by 0xC7",
"vendorId": "0xE117",
"productId": "0x6161",
"lighting": "none",
"matrix": {"rows": 5, "cols": 14},
"layouts": {
"keymap": [
[
"0,0",
"0,1",
"0,2",
"0,3",
"0,4",
"0,5",
"0,6",
"0,7",
"0,8",
"0,9",
"0,10",
"0,11",
"0,12",
{"w": 2},
"0,13"
],
[
{"w": 1.5},
"1,0",
"1,1",
"1,2",
"1,3",
"1,4",
"1,5",
"1,6",
"1,7",
"1,8",
"1,9",
"1,10",
"1,11",
"1,12",
{"w": 1.5},
"1,13"
],
[
{"w": 1.75},
"2,0",
"2,1",
"2,2",
"2,3",
"2,4",
"2,5",
"2,6",
"2,7",
"2,8",
"2,9",
"2,10",
"2,11",
{"w": 2.25},
"2,13"
],
[
{"w": 2.25},
"3,0",
"3,1",
"3,2",
"3,3",
"3,4",
"3,5",
"3,6",
"3,7",
"3,8",
"3,9",
"3,10",
{"w": 2.75},
"3,13"
],
[
{"w": 1.25},
"4,0",
{"w": 1.25},
"4,1",
{"w": 1.25},
"4,2",
{"w": 6.25},
"4,5",
{"w": 1.25},
"4,8",
{"w": 1.25},
"4,9",
{"w": 1.25},
"4,11",
{"w": 1.25},
"4,13"
]
]
}
}
Loading

0 comments on commit 6694ce4

Please sign in to comment.