mirror of
https://github.com/keymanapp/keyman.git
synced 2026-08-05 00:15:32 +00:00
chore(developer): verify kmp.json output from kmc-package
This commit is contained in:
parent
2189e54560
commit
cdac2dd01b
7 changed files with 22 additions and 3 deletions
|
|
@ -38,6 +38,7 @@ function compile_schemas() {
|
|||
"$KEYMAN_ROOT/common/schemas/keyman-touch-layout/keyman-touch-layout.spec.json"
|
||||
"$KEYMAN_ROOT/common/schemas/keyman-touch-layout/keyman-touch-layout.clean.spec.json"
|
||||
"$KEYMAN_ROOT/common/schemas/keyboard_info/keyboard_info.schema.json"
|
||||
"$KEYMAN_ROOT/common/schemas/kmp/kmp.schema.json"
|
||||
)
|
||||
|
||||
rm -rf "$THIS_SCRIPT_PATH/obj/schemas"
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@ import displayMap from './schemas/displaymap.schema.validator.mjs';
|
|||
import touchLayoutClean from './schemas/keyman-touch-layout.clean.spec.validator.mjs';
|
||||
import touchLayout from './schemas/keyman-touch-layout.spec.validator.mjs';
|
||||
import keyboard_info from './schemas/keyboard_info.schema.validator.mjs';
|
||||
import kmp from './schemas/kmp.schema.validator.mjs';
|
||||
|
||||
// How to use: https://ajv.js.org/standalone.html#using-the-validation-function-s
|
||||
// See also existing uses (search for `SchemaValidators`) for examples.
|
||||
|
|
@ -20,6 +21,7 @@ const SchemaValidators = {
|
|||
touchLayoutClean,
|
||||
touchLayout,
|
||||
keyboard_info,
|
||||
kmp,
|
||||
};
|
||||
|
||||
export default SchemaValidators;
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@ import displayMap from './schemas/displaymap.schema.js';
|
|||
import touchLayoutClean from './schemas/keyman-touch-layout.clean.spec.js';
|
||||
import touchLayout from './schemas/keyman-touch-layout.spec.js';
|
||||
import keyboard_info from './schemas/keyboard_info.schema.js';
|
||||
import kmp from './schemas/kmp.schema.js';
|
||||
|
||||
const Schemas = {
|
||||
kpj,
|
||||
|
|
@ -19,6 +20,7 @@ const Schemas = {
|
|||
touchLayoutClean,
|
||||
touchLayout,
|
||||
keyboard_info,
|
||||
kmp,
|
||||
};
|
||||
|
||||
export default Schemas;
|
||||
|
|
|
|||
|
|
@ -15,6 +15,7 @@ await esbuild.build({
|
|||
'obj/schemas/keyman-touch-layout.clean.spec.validator.cjs',
|
||||
'obj/schemas/keyman-touch-layout.spec.validator.cjs',
|
||||
'obj/schemas/keyboard_info.schema.validator.cjs',
|
||||
'obj/schemas/kmp.schema.validator.cjs',
|
||||
],
|
||||
bundle: true,
|
||||
format: 'esm',
|
||||
|
|
|
|||
|
|
@ -122,6 +122,7 @@ make-kmc-install-zip: copy-schemas
|
|||
sentry.dll sentry.x64.dll \
|
||||
kmdecomp.exe \
|
||||
keyboard_info.schema.json \
|
||||
kmp.schema.json \
|
||||
keyman-touch-layout.spec.json keyman-touch-layout.clean.spec.json \
|
||||
xml\layoutbuilder\*.keyman-touch-layout \
|
||||
projects\* \
|
||||
|
|
@ -136,4 +137,5 @@ copy-schemas:
|
|||
copy $(KEYMAN_ROOT)\common\schemas\keyman-touch-layout\keyman-touch-layout.spec.json $(DEVELOPER_ROOT)\bin
|
||||
copy $(KEYMAN_ROOT)\common\schemas\keyman-touch-layout\keyman-touch-layout.clean.spec.json $(DEVELOPER_ROOT)\bin
|
||||
copy $(KEYMAN_ROOT)\common\schemas\displaymap\displaymap.schema.json $(DEVELOPER_ROOT)\bin
|
||||
copy $(KEYMAN_ROOT)\common\schemas\kmp\kmp.schema.json $(DEVELOPER_ROOT)\bin
|
||||
|
||||
|
|
|
|||
|
|
@ -171,6 +171,10 @@
|
|||
<File Name="keyboard_info.schema.json" Source="..\..\..\common\schemas\keyboard_info\" KeyPath="yes" />
|
||||
</Component>
|
||||
|
||||
<Component>
|
||||
<File Name="kmp.schema.json" Source="..\..\..\common\schemas\kmp\" KeyPath="yes" />
|
||||
</Component>
|
||||
|
||||
<!-- Data Files -->
|
||||
|
||||
<Component>
|
||||
|
|
|
|||
|
|
@ -2,9 +2,8 @@ import * as xml2js from 'xml2js';
|
|||
import JSZip from 'jszip';
|
||||
import KEYMAN_VERSION from "@keymanapp/keyman-version";
|
||||
|
||||
import { CompilerCallbacks, KeymanFileTypes, KvkFile } from '@keymanapp/common-types';
|
||||
import { KmpJsonFile, KpsFile, SchemaValidators, CompilerCallbacks, KeymanFileTypes, KvkFile } from '@keymanapp/common-types';
|
||||
import { CompilerMessages } from './messages.js';
|
||||
import { KmpJsonFile, KpsFile } from '@keymanapp/common-types';
|
||||
import { PackageMetadataCollector } from './package-metadata-collector.js';
|
||||
import { KmpInfWriter } from './kmp-inf-writer.js';
|
||||
import { transcodeToCP1252 } from './cp1252.js';
|
||||
|
|
@ -31,7 +30,15 @@ export class KmpCompiler {
|
|||
if(!kps) {
|
||||
return null;
|
||||
}
|
||||
return this.transformKpsFileToKmpObject(kpsFilename, kps);
|
||||
const kmp = this.transformKpsFileToKmpObject(kpsFilename, kps);
|
||||
|
||||
// Verify that the generated kmp.json validates with the kmp.json schema
|
||||
if(!SchemaValidators.default.kmp(kmp)) {
|
||||
// This is an internal error, so throwing an exception is appropriate
|
||||
throw new Error((<any>SchemaValidators.default.kmp).errors);
|
||||
}
|
||||
|
||||
return kmp;
|
||||
}
|
||||
|
||||
public loadKpsFile(kpsFilename: string): KpsFile.KpsFile {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue