Skip to content

Commit

Permalink
Merge pull request #12090 from keymanapp/refactor/developer/12077-rem…
Browse files Browse the repository at this point in the history
…ove-git-npm-deps

refactor(developer): use npm or local source for server addons instead of github references
  • Loading branch information
mcdurdin authored Aug 14, 2024
2 parents 50468f0 + c1d3fea commit cf6ee68
Show file tree
Hide file tree
Showing 20 changed files with 3,787 additions and 557 deletions.
2 changes: 2 additions & 0 deletions developer/src/common/web/utils/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
],
"dependencies": {
"@sentry/node": "^7.57.0",
"@keymanapp/common-types": "*",
"eventemitter3": "^5.0.0",
"restructure": "^3.0.1",
"semver": "^7.5.2",
"sax": ">=0.6.0",
Expand Down
9 changes: 5 additions & 4 deletions developer/src/server/build-addins.inc.sh
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,10 @@ do_build_addins() {
# Build node-windows-trayicon
#

pushd "$KEYMAN_ROOT/node_modules/node-windows-trayicon"
pushd "$KEYMAN_ROOT/developer/src/server/src/win32/trayicon/addon-src"
rm -rf build
npx node-gyp clean configure build --arch=$ARCH --silent
npm ci
"$KEYMAN_ROOT/node_modules/.bin/node-gyp" clean configure build --arch=$ARCH --silent
cp build/Release/addon.node "$TRAYICON_SRC_TARGET"
cp build/Release/addon.node "$TRAYICON_BIN_TARGET"
popd
Expand All @@ -52,9 +53,9 @@ do_build_addins() {
# Build hetrodo-node-hide-console-window-napi
#

pushd "$KEYMAN_ROOT/node_modules/hetrodo-node-hide-console-window-napi"
pushd "$KEYMAN_ROOT/node_modules/node-hide-console-window"
rm -rf build
npx node-gyp clean configure build --arch=$ARCH --silent
"$KEYMAN_ROOT/node_modules/.bin/node-gyp" clean configure build --arch=$ARCH --silent
cp build/Release/node-hide-console-window.node "$HIDECONSOLE_SRC_TARGET"
cp build/Release/node-hide-console-window.node "$HIDECONSOLE_BIN_TARGET"
popd
Expand Down
18 changes: 14 additions & 4 deletions developer/src/server/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -87,9 +87,16 @@ function build_server() {

# Post build
mkdir -p "$THIS_SCRIPT_PATH/build/src/site/"
mkdir -p "$THIS_SCRIPT_PATH/build/src/win32/"
cp -r "$THIS_SCRIPT_PATH/src/site/"** "$THIS_SCRIPT_PATH/build/src/site/"
cp -r "$THIS_SCRIPT_PATH/src/win32/"** "$THIS_SCRIPT_PATH/build/src/win32/"

mkdir -p "$THIS_SCRIPT_PATH/build/src/win32/"
mkdir -p "$THIS_SCRIPT_PATH/build/src/win32/console"
mkdir -p "$THIS_SCRIPT_PATH/build/src/win32/trayicon"
cp "$THIS_SCRIPT_PATH/src/win32/README.md" "$THIS_SCRIPT_PATH/build/src/win32/"
cp "$THIS_SCRIPT_PATH/src/win32/console/node-hide-console-window.node" "$THIS_SCRIPT_PATH/build/src/win32/console/"
cp "$THIS_SCRIPT_PATH/src/win32/console/node-hide-console-window.x64.node" "$THIS_SCRIPT_PATH/build/src/win32/console/"
cp "$THIS_SCRIPT_PATH/src/win32/trayicon/addon.node" "$THIS_SCRIPT_PATH/build/src/win32/trayicon/"
cp "$THIS_SCRIPT_PATH/src/win32/trayicon/addon.x64.node" "$THIS_SCRIPT_PATH/build/src/win32/trayicon/"

replaceVersionStrings "$THIS_SCRIPT_PATH/build/src/site/lib/sentry/init.js.in" "$THIS_SCRIPT_PATH/build/src/site/lib/sentry/init.js"
rm "$THIS_SCRIPT_PATH/build/src/site/lib/sentry/init.js.in"
Expand All @@ -114,10 +121,13 @@ function installer_server() {
rm -f node_modules/ngrok/bin/ngrok.exe
popd

# @keymanapp/keyman-version is required in build/ now but we need to copy it in manually
# Dependencies are required in build/ but we need to copy them in manually
mkdir -p "$PRODBUILDTEMP/node_modules/@keymanapp/"
cp -R "$KEYMAN_ROOT/node_modules/@keymanapp/keyman-version/" "$PRODBUILDTEMP/node_modules/@keymanapp/"
cp -R "$KEYMAN_ROOT/node_modules/@keymanapp/developer-utils/" "$PRODBUILDTEMP/node_modules/@keymanapp/"
cp -R "$KEYMAN_ROOT/node_modules/@keymanapp/common-types/" "$PRODBUILDTEMP/node_modules/@keymanapp/"
cp -R "$KEYMAN_ROOT/node_modules/@keymanapp/ldml-keyboard-constants/" "$PRODBUILDTEMP/node_modules/@keymanapp/"
cp -R "$KEYMAN_ROOT/node_modules/eventemitter3/" "$PRODBUILDTEMP/node_modules/"

# We'll build in the $KEYMAN_ROOT/developer/bin/server/ folder
rm -rf "$KEYMAN_ROOT/developer/bin/server/"
Expand All @@ -144,8 +154,8 @@ function publish_server() {

builder_run_action clean:server clean_server
builder_run_action configure:server configure_server
builder_run_action build:server build_server
builder_run_action build:addins build_addins
builder_run_action build:server build_server
builder_run_action test:server test_server
# builder_run_action test:addins # no op
builder_run_action installer:server installer_server # TODO: rename to install-prep
Expand Down
12 changes: 8 additions & 4 deletions developer/src/server/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,14 @@
"multer": "^1.4.5-lts.1",
"ngrok": "^5.0.0-beta.2",
"open": "^8.4.0",
"ws": "^8.17.1"
},
"restructure": "^3.0.1",
"sax": ">=0.6.0",
"semver": "^7.5.2",
"ws": "^8.17.1",
"xmlbuilder": "~11.0.0"
},
"optionalDependencies": {
"hetrodo-node-hide-console-window-napi": "keymanapp/hetrodo-node-hide-console-window-napi#keyman-15.0",
"node-windows-trayicon": "keymanapp/node-windows-trayicon#keyman-16.0"
"node-hide-console-window": "^2.2.0"
},
"devDependencies": {
"@keymanapp/keyman-version": "*",
Expand All @@ -32,6 +35,7 @@
"@types/ws": "^8.2.2",
"copyfiles": "^2.4.1",
"mocha": "^10.0.0",
"node-gyp": "^10.2.0",
"tsc-watch": "^4.5.0",
"typescript": "^5.4.5"
}
Expand Down
5 changes: 5 additions & 0 deletions developer/src/server/src/win32/trayicon/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,8 @@ bundled libraries target for specific versions of node.
* Tree: https://github.com/mceSystems/node-windows-trayicon/tree/cbd7543ac186ca15ee8d7141aac43f26ceae1655
* License: MIT
* Built from: /developer/src/server/win32/node-windows-trayicon

---

The source for trayicon is currently in addon-src, as the original package is
unmaintained.
62 changes: 62 additions & 0 deletions developer/src/server/src/win32/trayicon/addon-src/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*

# Runtime data
pids
*.pid
*.seed
*.pid.lock

# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov

# Coverage directory used by tools like istanbul
coverage

# nyc test coverage
.nyc_output

# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
.grunt

# Bower dependency directory (https://bower.io/)
bower_components

# node-waf configuration
.lock-wscript

# Compiled binary addons (http://nodejs.org/api/addons.html)
build/Release

# Dependency directories
node_modules/
jspm_packages/

# Typescript v1 declaration files
typings/

# Optional npm cache directory
.npm

# Optional eslint cache
.eslintcache

# Optional REPL history
.node_repl_history

# Output of 'npm pack'
*.tgz

# Yarn Integrity file
.yarn-integrity

# dotenv environment variables file
.env

.vscode
build/
test/icon.ico
21 changes: 21 additions & 0 deletions developer/src/server/src/win32/trayicon/addon-src/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2018 mceSystems

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
57 changes: 57 additions & 0 deletions developer/src/server/src/win32/trayicon/addon-src/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
# windows-trayicon
Native addon to add a windows tray icon with menu, built on windows-native libraries (no .NET dependency)

# Installation
```
npm install --save windows-trayicon
```

# Usage
```
const WindowsTrayicon = require("windows-trayicon");
const path = require("path");
const fs = require("fs");
const myTrayApp = new WindowsTrayicon({
title: "Trayicon Test",
icon: path.resolve(__dirname, "icon.ico"),
menu: [
{
id: "item-1-id",
caption: "First Item"
},
{
id: "item-2-id",
caption: "Second Item"
},
{
id: "item-3-id-exit",
caption: "Exit"
}
]
});
myTrayApp.item((id) => {
console.log(`Menu id selected=${id}`);
switch (id) {
case "item-1-id": {
console.log("First item selected...");
break;
}
case "item-2-id": {
myTrayApp.balloon("Hello There!", "This is my message to you").then(() => {
console.log("Balloon clicked");
})
break;
}
case "item-3-id-exit": {
myTrayApp.exit();
process.exit(0)
break;
}
}
});
process.stdin.resume()
```
Loading

0 comments on commit cf6ee68

Please sign in to comment.