spiegel-keyman/developer/src/common/web/utils/build.sh
Marc Durdin f5066174cd fix(developer): make LDML import path consistent for all bundlings of kmc
The default import path is relative to ldml-keyboard-xml-reader.js. The
bundling of kmc with Keyman Developer reduces the directory tree depth,
so we move the import path to be a subdirectory of the immediate parent
directory, rather than two levels up, so that
`C:\Program Files\Keyman\Keyman Developer\kmc` can refer to
`C:\Program Files\Keyman\Keyman Developer\import` when kmc is bundled.

Fixes: #12279
2024-08-24 10:28:48 +08:00

63 lines
2.4 KiB
Bash
Executable file

#!/usr/bin/env bash
## START STANDARD BUILD SCRIPT INCLUDE
# adjust relative paths as necessary
THIS_SCRIPT="$(readlink -f "${BASH_SOURCE[0]}")"
. "${THIS_SCRIPT%/*}/../../../../../resources/build/builder.inc.sh"
## END STANDARD BUILD SCRIPT INCLUDE
. "$KEYMAN_ROOT/resources/shellHelperFunctions.sh"
. "$KEYMAN_ROOT/resources/build/build-utils-ci.inc.sh"
builder_describe "Build Keyman Developer web utility module" \
"@/common/web/types" \
"clean" \
"configure" \
"build" \
"api analyze API and prepare API documentation (no-op for now)" \
"test" \
publish \
"--npm-publish+ For publish, do a npm publish, not npm pack (only for CI)" \
"--dry-run,-n don't actually publish, just dry run"
builder_describe_outputs \
configure /node_modules \
build /developer/src/common/web/utils/build/src/index.js
builder_parse "$@"
#-------------------------------------------------------------------------------------------------------------------
function copy_cldr_imports() {
# Store CLDR imports
# load all versions that have a cldr_info.json
for CLDR_INFO_PATH in "$KEYMAN_ROOT/resources/standards-data/ldml-keyboards/"*/cldr_info.json
do
# TODO-LDML: developer/src/inst/download.in.mak needs these also...
CLDR_PATH=$(dirname "$CLDR_INFO_PATH")
CLDR_VER=$(basename "$CLDR_PATH")
mkdir -p "$THIS_SCRIPT_PATH/build/src/types/import/$CLDR_VER"
# TODO-LDML: When these are copied, the DOCTYPE will break due to the wrong path. We don't use the DTD so it should be OK.
cp "$CLDR_INFO_PATH" "$CLDR_PATH/import/"*.xml "$THIS_SCRIPT_PATH/build/src/types/import/$CLDR_VER/"
done
}
function do_build() {
copy_cldr_imports
tsc --build
}
builder_run_action clean rm -rf ./build/
builder_run_action configure verify_npm_setup
builder_run_action build do_build
if builder_start_action test; then
eslint .
tsc --build test
readonly C8_THRESHOLD=40
c8 --reporter=lcov --reporter=text --exclude-after-remap --lines $C8_THRESHOLD --statements $C8_THRESHOLD --branches $C8_THRESHOLD --functions $C8_THRESHOLD mocha
builder_echo warning "Coverage thresholds are currently $C8_THRESHOLD%, which is lower than ideal."
builder_echo warning "Please increase threshold in build.sh as test coverage improves."
builder_finish_action success test
fi
builder_run_action publish builder_publish_npm