Commit graph

110 commits

Author SHA1 Message Date
Marc Durdin
306934eb62 fix(developer): kmc-package support for keyboard metadata
Fixes #9208.
Fixes #9209.
Fixes #9203.
Fixes #9198.

The changes here overlap in kmp-compiler.ts. Addresses several issues
with the package compiler:

* refactors the reading of the metadata from keyboards to make use of it
  when refreshing the keyboard metadata in kmp.json (#9208). This is the
  bulk of the changes.
* Fixes case on some fields in the kps file format (#9209)
* Removes code which emitted strings table to kmp.json, as these were
  only ever used for package installer executables (#9203)
* Cleans up code which emitted Start Menu items to make it match spec
  (#9198)
2023-07-06 13:49:04 +07:00
Marc Durdin
3773522e06 feat(developer): kmc-package support for writing kmp.inf
Fixes #9205.
2023-07-06 13:49:03 +07:00
Marc Durdin
92c8c6497e fix(developer): improve warnings around keyboard version matching
Fixes #9145.

* `WARN_KeyboardVersionsDoNotMatch` is now only raised when
  `FollowKeyboardVersion` is set.
* `WARN_KeyboardVersionsDoNotMatchPackageVersion` has been removed,
  because it did not really make sense; if 'FollowKeyboardVersion' is
  set, it could not be raised, and otherwise, the author may wish to
  have separate keyboard + package versions anyway.
* Note that the 0x0013 compiler message allocation for
  `WARN_KeyboardVersionsDoNotMatchPackageVersion` has been left alone;
  as this was only used in pre-release, we can probably re-task it in
  the future.
2023-07-03 09:40:09 +07:00
Marc Durdin
9a1b87824a fix(developer): split keyboard and model language metadata tests
Fixes #9146.

For model packages, 304016 (ERROR_ModelMustHaveAtLeastOneLanguage)
remains as an error (this is a new error for kmc, kmcomp did not
validate model metadata). For keyboard packages, a new warning is
introduced to match the existing kmcomp behaviour, 20401B
(WARN_KeyboardShouldHaveAtLeastOneLanguage).
2023-07-03 09:31:29 +07:00
Marc Durdin
f85478ac6f fix(developer): kmc needs to support .js-only packages
Fixes #9111.

We have existing packages which have only .js in them, for touch-only
keyboards (mostly legacy but still...), so we need to support the freaky
Javascript regex search which we did in the past for extracting
metadata. While this is not necessarily going to work with hand-crafted
Javascript keyboards, it should work with all kmc- and kmcomp-generated
keyboards, so it will suffice to support these legacy packages.

In the future, we will be giving a hint when a package includes a .js
but not a .kmx, gradually upgrading this to a warning and finally an
error as we attempt to phase out .js-based keyboards in preference for
.kmx keyboards.
2023-06-30 08:45:03 +07:00
Joshua Horton
2ac8a4503b
Merge branch 'master' into feature-esmodule-web-engine 2023-06-26 09:09:43 +07:00
Marc Durdin
cbc5b13034 fix(developer): keep kmc-kmn messages within namespace
Fixes #8998.

kmc-kmn messages were broken down into sub-namespaces, but the range
overlapped the reserved namespace mask range. Fixed the message values,
added a new test to the verifyCompilerMessagesObject function to verify
that messages don't creep outside their namespace, and defined new
masks (in CompilerErrorSeverity enum... hmm) to help.

I opted to remove the leading `0` in the messages for kmc-kmn as I had
to correct a number of them anyway, but not the messages in remaining
units at this time (it's not an error, but just slightly misleading as
we only have 12 bits, not 16 to play with).

It is safe to reassign these messages as they were only assigned in 17.0
alpha.
2023-06-13 06:22:15 +07:00
Joshua A. Horton
718ca50b23 chore(web): Merge branch 'master' into chore/web/feature-esmodule-a17s14-mid-update 2023-06-06 12:37:15 +07:00
Marc Durdin
e293d7608c chore(developer): add test for missing .js file 2023-05-23 09:28:26 +07:00
Marc Durdin
3828a5c16b refactor(developer): move message tests into test-messages.ts 2023-05-23 08:31:29 +07:00
Joshua A. Horton
ca894d0991 chore(web): Merge branch 'master' into chore/web/merge-master-esmodule-a17s13-mid 2023-05-22 13:49:45 +07:00
Marc Durdin
4ad975d3a8
Merge pull request #8793 from keymanapp/chore/developer/verify-package-has-a-model-or-keyboard
chore(developer): verify that package has at least a model or keyboard
2023-05-16 17:21:41 +10:00
Marc Durdin
ced54e260a
Merge pull request #8792 from keymanapp/chore/developer/verify-included-files-in-package
chore(developer): verify file types of content files in package
2023-05-16 17:21:24 +10:00
Marc Durdin
1be22862cf
Merge pull request #8783 from keymanapp/feat/developer/verify-at-least-one-language-in-package
feat(developer): verify at least one language in package
2023-05-16 17:21:01 +10:00
Marc Durdin
888786e0f4
Merge pull request #8778 from keymanapp/feat/developer/verify-package-lang-tags
feat(developer): verify bcp47 tags are valid and minimal in kmc-package
2023-05-16 17:20:46 +10:00
Marc Durdin
b2e293892d
Update developer/src/kmc-package/test/fixtures/invalid/keyboardcontentfilenotfound.kps 2023-05-16 13:21:31 +10:00
Marc Durdin
c31118cd6d chore(developer): rename fixture 2023-05-15 20:17:22 +07:00
Marc Durdin
663e4195ff
chore: Apply suggestions from code review 2023-05-15 23:16:36 +10:00
Joshua A. Horton
1308e74833 chore(web): Merge branch 'feature-esmodule-web-engine' into fix/web/webview-android-launch 2023-05-15 08:50:28 +07:00
Marc Durdin
135d6f9c0f
chore(developer): rename misnamed error message 2023-05-14 17:23:21 +10:00
Marc Durdin
abd174557c chore(developer): verify that package has at least a model or keyboard
Adds `ERROR_PackageMustContainAPackageOrAKeyboard` and corresponding
unit tests. A couple of unit tests tweaked as their fixtures were no
longer valid!
2023-05-14 09:53:36 +07:00
Marc Durdin
3c9492dd56 chore(developer): verify file types of content files in package
This is a transfer of the functionality in the legacy package compiler;
we could go much further in verifying file types and excluding certain
files, but that's a big design session. For now, just refreshed to
include the set of Keyman for Windows and Keyman Engine for Windows
files which are most likely to be accidentally included.

Adds WARN_RedistFileShouldNotBeInPackage and WARN_DocFileDangerous and
corresponding unit tests and constant declarations.
2023-05-14 09:31:32 +07:00
Marc Durdin
8446775dd5 feat(developer): verify at least one language in package
Adds `ERROR_MustHaveAtLeastOneLanguage` and corresponding unit test.
2023-05-12 14:42:07 +07:00
Marc Durdin
e4ad95550e feat(developer): verify bcp47 tags are valid and minimal in kmc-package
Adds checks for bcp47 tag metadata for keyboards and lexical models --
both validity and minimality. Adds `ERROR_LanguageTagIsNotValid` and
`WARN_LanguageTagIsNotMinimal` messages and corresponding unit tests.

This was implemented by extending the existing duplicate id check, so
renamed that function accordingly.
2023-05-12 13:21:13 +07:00
Marc Durdin
d3e4762b52 chore(developer): Info_KeyboardFileHasNoKeyboardVersion
Downgrades `Warn_KeyboardFileHasNoKeyboardVersion` to
`Info_KeyboardFileHasNoKeyboardVersion`, because this is not an error,
or even something wrong necessarily; it's just something it's good to be
aware of. Updates unit test for kmc to cater for the extra message.
2023-05-12 09:07:46 +07:00
Marc Durdin
53c51b79e6 feat(developer): add tests for keyboard and package version matching
Adds `WARN_KeyboardVersionsDoNotMatch` and
`WARN_KeyboardVersionsDoNotMatchPackageVersion`.

Adds unit tests. Several other 'invalid' packages needed corrections
after adding this validation. Note that one unit test was deleted
because it could never be satisfied after adding this validation step.
2023-05-12 08:26:54 +07:00
Marc Durdin
3c3a363478 feat(developer): verify keyboard versions in kmc-package
Refactor the `extractKeyboardVersionFromKmx` function into a new class
and add extra version checking. This caused a bit of a cascade of test
failures due to some of the 'invalid' fixtures actually being invalid
in multiple ways, so the fixtures have been corrected to only be wrong
in a single way -- the way they are supposed to be broken. This means
additional fixture files in the 'invalid' folder.

Now updates keyboard version metadata for all keyboards in the package.

Upgrades `WARN_FollowKeyboardVersionButNoKeyboards` to
`ERROR_FollowKeyboardVersionButNoKeyboards`, as this leads to invalid
package metadata on build.

Renames `ERROR_KeyboardFileNotFound` to
`ERROR_KeyboardContentFileNotFound` to better reflect that no `<File>`
in the package is found to match a given `<Keyboard>` entry.

Adds `ERROR_KeyboardFileNotFound` when a referenced .kmx does not exist.

Adds and updates corresponding unit tests.
2023-05-12 07:19:33 +07:00
Marc Durdin
70279914a8 feat(developer): validate package name in compiler 2023-05-11 15:03:53 +07:00
Marc Durdin
b2be12c258 feat(developer): validate content file names in packages 2023-05-11 14:42:26 +07:00
Marc Durdin
88b31ba49e feat(developer): add validation of package filenames
Adds `WARN_PackageNameDoesNotFollowKeyboardConventions` and
`WARN_PackageNameDoesNotFollowLexicalModelConventions`, refactoring as
required to test filenames, and adds unit tests for same.
2023-05-11 13:23:33 +07:00
Marc Durdin
6c17f4851a feat(developer): add validation for keyboards in package
Adds validation for WARN_PackageShouldNotRepeatLanguages for keyboards
plus unit test.
2023-05-10 11:57:40 +07:00
Marc Durdin
dbc64bcbb0 feat(developer): add package validation
Adds a package-validation.ts module, plus adds a call to the validation
step in the compilers.

Rearranges the kmc-package files to match other compilers better.

Removes `default` from exports.

And finally, adds ERROR_PackageCannotContainBothModelsAndKeyboards and
WARN_PackageShouldNotRepeatLanguages messages, plus tests.
2023-05-10 11:50:54 +07:00
Marc Durdin
53ccdbe241 chore(developer): move package formats to common/web/types
Package file interfaces were stored in developer/kmc-package but belong
better now in common/web/types.
2023-05-09 15:48:50 +07:00
Joshua A. Horton
fd21d267f3 fix(developer): right, gotta update keyman-version references from master 2023-05-03 08:45:48 +07:00
Marc Durdin
5e0471f0b7 refactor(developer): use callbacks to avoid direct fs access in kmc-package
Fixes #8644.

This is a signficant cleanup and refactor of code that was accessing the
fs or path modules in Node directly. Given we want to be able to run
these modules on web as well in the future, it is important that we
avoid that.

This also redesigns the CompilerCallback interfaces to provide Node-like
interfaces for path and fs, with a minimal set of functions. The aim
here is to provide a surface that will hopefully match a future
web-based component such as path-browserify without significant
retooling of the kmc-* modules.

Enables linting for common/web/types and turns on the
eslintNoNodeImports checks for that module and kmc-package.

Note: Buffer is still in use in a few places also, so we'll need to
refactor that in a future commit.
2023-04-26 12:31:50 +07:00
Marc Durdin
f475176f8f chore(developer): update dependency refs 2023-04-25 09:47:30 +07:00
Marc Durdin
c9bca0bff2 chore(developer): test message correctness in compiler modules 2023-04-25 07:51:07 +07:00
Marc Durdin
f11ff9d208 chore(developer): fixup deps for kmc modules 2023-04-24 09:01:29 +07:00
Marc Durdin
34ae4a1397 chore(developer): additional unit tests 2023-04-23 06:48:31 +07:00
Marc Durdin
66a7a6fc4e feat(developer): support FollowKeyboardVersion in kmc-package
Fixes #7340.

Removes the unused <Version> element from <LexicalModel> element in the
.kps schema. (This needs to be copied to api.keyman.com also.)

Updates compiler to check for <FollowKeyboardVersion> and read the
version data from the .kmx in that case.

Unit tests updated. Some of the fixtures were incorrect as they had
<FollowKeyboardVersion> set for model-type packages or packages that
contained no keyboards. Fixed.
2023-04-21 14:04:06 +07:00
Marc Durdin
0ce42db399 chore: address review comments 2023-04-20 10:42:42 +07:00
Marc Durdin
2f7407b4b8 feat(developer): warn if .kps file includes a non-binary .kvk file
Relates to #8150.

Legacy .kmp compiler would transform xml-format .kvk files into a binary
.kvk file; now we want that to remain the responsibility of the keyboard
compiler, so we'll warn the few users who are still doing this.
2023-04-19 15:32:29 +07:00
Marc Durdin
88601f2409 feat(developer): add file-existence check to kmc-package 2023-04-19 12:44:52 +07:00
Marc Durdin
7644979dee chore(developer): unit test for absolute path warning 2023-04-19 12:17:29 +07:00
Marc Durdin
161fb924b9 feat(developer): add CompilerMessages support to kmc-package
Adds basic infrastructure for CompilerMessages events. Additional warnings,
errors, and hints to come.
2023-04-19 11:57:02 +07:00
Marc Durdin
787b32ba34
Revert "chore(web): merge master into feature-esmodule-web-engine (A17S9 end) 🧩" 2023-03-31 14:17:37 +11:00
Joshua A. Horton
f5e64a10a5 chore: Merge branch 'chore/common/ldml-ts-and-node-updates' into chore/feature-esmodule-master-update 2023-03-14 09:23:39 +07:00
Joshua A. Horton
2439ba4e97 fix(developer): updates kmc, web/types module resolution, adds missing type import/exports 2023-03-14 08:41:29 +07:00
Joshua A. Horton
0da7ac24be chore(common): updates TS, sets export map for keyman-version 2023-03-14 08:22:26 +07:00
Steven R. Loomis
ac461e97b8 fix(developer): ldml: merge fixes: fix scope of JSZip in the test 🙀
- JSZip() needs to be in an inner function otherwise the single zip grows and grows
- also don't read the kps version when building the kmp

For #7042
2022-12-22 14:31:49 -06:00