diff --git a/developer/server/.gitignore b/developer/server/.gitignore index 16a4cb7c17..2293999f4d 100644 --- a/developer/server/.gitignore +++ b/developer/server/.gitignore @@ -1,4 +1,5 @@ dist/ build/ node_modules/ -src/site/resource/ \ No newline at end of file +src/site/resource/ +tsconfig.tsbuildinfo \ No newline at end of file diff --git a/developer/server/build-addins.inc.sh b/developer/server/build-addins.inc.sh index 3448f25d9b..6c0e90e072 100644 --- a/developer/server/build-addins.inc.sh +++ b/developer/server/build-addins.inc.sh @@ -36,7 +36,7 @@ build_addins() { # Build node-windows-trayicon # - pushd "./node_modules/node-windows-trayicon" + pushd "../../node_modules/node-windows-trayicon" rm -rf build npx node-gyp clean configure build --arch=$ARCH --silent cp build/Release/addon.node "$TRAYICON_TARGET" @@ -46,7 +46,7 @@ build_addins() { # Build hetrodo-node-hide-console-window-napi # - pushd "./node_modules/hetrodo-node-hide-console-window-napi" + pushd "../../node_modules/hetrodo-node-hide-console-window-napi" rm -rf build npx node-gyp clean configure build --arch=$ARCH --silent cp build/Release/node-hide-console-window.node "$HIDECONSOLE_TARGET" diff --git a/developer/server/build.sh b/developer/server/build.sh index d39a2c5966..060682b6ca 100755 --- a/developer/server/build.sh +++ b/developer/server/build.sh @@ -14,6 +14,8 @@ THIS_SCRIPT="$(greadlink -f "${BASH_SOURCE[0]}" 2>/dev/null || readlink -f "${BA ## END STANDARD BUILD SCRIPT INCLUDE EX_USAGE=64 +. "$KEYMAN_ROOT/resources/build/jq.inc.sh" + pushd "$(dirname "$THIS_SCRIPT")" # Build the main script. @@ -100,7 +102,7 @@ if (( install_dependencies )) ; then rm -f "$KEYMAN_ROOT"/node_modules/ngrok/bin/ngrok.exe fi -set_npm_version || fail "Setting version failed." +# set_npm_version || fail "Setting version failed." # ---------------------------------------- # Rebuild and bundle addins @@ -162,13 +164,28 @@ fi # ---------------------------------------- if (( production )) ; then - # We'll build in the build/ folder - rm -rf build/ - mkdir build/ - cp -R dist/ package.json package-lock.json build/ - cd build/ + # We need to build in a tmp folder so that npm doesn't get confused by our + # monorepo setup, and so we can copy the relevant node_modules in, because + # we'll need them in order to build the deployable version. + + PRODBUILDTEMP=`mktemp -d` + echo "Preparing in $PRODBUILDTEMP" + # Remove @keymanapp devDependencies because they won't install outside the + # monorepo context + cat package.json | "$JQ" \ + '. | del(.devDependencies."@keymanapp/resources-gosh") | del(.devDependencies."@keymanapp/keyman-version")' \ + > "$PRODBUILDTEMP/package.json" + + pushd "$PRODBUILDTEMP" npm install --omit=dev --omit=optional # See https://github.com/bubenshchykov/ngrok/issues/254, https://github.com/bubenshchykov/ngrok/pull/255 rm -f node_modules/ngrok/bin/ngrok.exe - cd .. + popd + + # We'll build in the build/ folder + rm -rf build/ + mkdir build/ + cp -R dist/* build/ + cp -R "$PRODBUILDTEMP"/* build/ + rm -rf "$PRODBUILDTEMP" fi diff --git a/developer/server/tsconfig.json b/developer/server/tsconfig.json index 64a2939556..caeb1bf247 100644 --- a/developer/server/tsconfig.json +++ b/developer/server/tsconfig.json @@ -7,6 +7,7 @@ "moduleResolution": "node", "sourceMap": true, "outDir": "dist/", + "rootDir": "src/", "declaration": true, "alwaysStrict": true, "noImplicitThis": true, diff --git a/resources/build/jq.inc.sh b/resources/build/jq.inc.sh index f77fbcbc1f..0070d120a9 100644 --- a/resources/build/jq.inc.sh +++ b/resources/build/jq.inc.sh @@ -8,16 +8,16 @@ ## START STANDARD BUILD SCRIPT INCLUDE # adjust relative paths as necessary -THIS_SCRIPT="$(greadlink -f "${BASH_SOURCE[0]}" 2>/dev/null || readlink -f "${BASH_SOURCE[0]}")" +JQ_THIS_SCRIPT="$(greadlink -f "${BASH_SOURCE[0]}" 2>/dev/null || readlink -f "${BASH_SOURCE[0]}")" # . "$(dirname "$THIS_SCRIPT")/build-utils.sh" ## END STANDARD BUILD SCRIPT INCLUDE case "${OSTYPE}" in "cygwin") - JQ=$(dirname "$THIS_SCRIPT")/jq-win64.exe + JQ=$(dirname "$JQ_THIS_SCRIPT")/jq-win64.exe ;; "msys") - JQ=$(dirname "$THIS_SCRIPT")/jq-win64.exe + JQ=$(dirname "$JQ_THIS_SCRIPT")/jq-win64.exe ;; *) JQ=jq