Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add script to copy local runtime #207

Merged
merged 9 commits into from
Jul 9, 2024
Merged
35 changes: 35 additions & 0 deletions .dev/scripts/linkRuntime.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#!/usr/bin/env bash

# Switch to connector root dir, regardless of where this script is executed
# from.
CONNECTORPATH="$(dirname "$(dirname "$(dirname "$(realpath "$0")")")")"
cd "$CONNECTORPATH"

[ -f .env ] && source "$CONNECTORPATH/.env"
if [ -z "$RUNTIME_PATH" ]; then
echo "\$RUNTIME_PATH not set but required."
exit 1
fi

if ! type "entr" >/dev/null; then
echo "'entr' not found. Please install it via your package manager."
exit 1
fi

_copyRuntime() {
sleep 2
printf "Copying runtime ..."

find "$RUNTIME_PATH/packages/" -maxdepth 1 -mindepth 1 -type d | while read runtimePkgPath; do
pkgName="$(jq -r .name "$runtimePkgPath/package.json")"
mkdir -p "$CONNECTORPATH/node_modules/$pkgName"
cp -r "$runtimePkgPath/dist" "$runtimePkgPath/src" "$CONNECTORPATH/node_modules/$pkgName"
done
echo "done!"
}

case "$1" in
"") find $RUNTIME_PATH/packages/*/dist | entr -dd -r -s "$0 _copyRuntime" ;;

*) "$@" ;;
esac
12 changes: 12 additions & 0 deletions README_dev.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,18 @@ If you're running on Windows you have to execute the `Restart` task after you sa

## How to test

### Local Runtime

To use a local runtime you need to set the envvar $RUNTIME_PATH (e.g. inside a local `.env` file in the root folder of the project). The $RUNTIME_PATH needs to contain the path to the runtime mono-repository root folder, either relative or absolute.

```bash
export RUNTIME_PATH=.../path/to/local/runtime
```

Afterwards you can run `npm run link-runtime`. This will copy the build result and sources from you local runtime in you node_modules folder.

To use the npm version of the runtime again you need to run `npm run unlink-runtime` this will restore the version in the package.json

### Remote Backbone

Set the following environment variables:
Expand Down
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
"sdk:schemas:watch": "npm run --workspace packages/sdk build:schemas:watch",
"copy-additional-files": "cpx \"src/**/*.{json,yml,ico}\" dist",
"copy-additional-files:watch": "cpx \"src/**/*.{json,yml,ico}\" dist --watch",
"link-runtime": "bash .dev/scripts/linkRuntime.sh",
"unlink-runtime": "rm -rf node_modules/@nmshd && npm install",
jkoenig134 marked this conversation as resolved.
Show resolved Hide resolved
"tsc": "tsc",
"tsc:watch": "tsc -w",
"test:ci": "npm run build && jest -i",
Expand Down