diff --git a/.gitignore b/.gitignore index 9a57f32..946fcf7 100644 --- a/.gitignore +++ b/.gitignore @@ -2,4 +2,5 @@ dist/ build/ node_modules/ package-lock.json -.lock-waf* \ No newline at end of file +.lock-waf* +pebble-wrapper.sh \ No newline at end of file diff --git a/README.md b/README.md new file mode 100644 index 0000000..005e41e --- /dev/null +++ b/README.md @@ -0,0 +1,14 @@ +# Pebble Typescript + +A somewhat foolproof way to write Pebble apps with PebbleKit JS using TypeScript. + +## Usage + +1. Clone this repository +2. Open `pebble.py`, and edit `PEBBLE_TOOL_LOCATION` to point to your Pebble Tool location. This can be a wrapper script, or point directly to the `pebble` executable. +3. Run `npm install` +4. Write your TypeScript code in `src/pkts/` +5. Run `npm run build` +6. Your compiled Pebble app will be in `build/pebble-ts.pbw` + +To clean, simply run `npm run clean`. This will delete the webpack caches and run `pebble clean` as to not leave any pebble build artifacts behind. diff --git a/pebble-wrapper.sh b/pebble-wrapper.sh deleted file mode 100755 index 3a84ef3..0000000 --- a/pebble-wrapper.sh +++ /dev/null @@ -1,34 +0,0 @@ -#!/bin/bash - -# Set up args for podman or docker depending on the container runtime installed -# CONTAINER_RUNTIME="podman" -# EXTRA_RUN_ARGS="--userns=keep-id" - -CONTAINER_RUNTIME="docker" -EXTRA_RUN_ARGS="" - -IMAGE='docker.io/kennedn/pebble-wrapper:latest' - - -# If clean-containers passed, set a flag that will run a `"${CONTAINER_RUNTIME}" rm` once image_ids is obtained -CLEAN= -[ "$1" == "clean-containers" ] && CLEAN=1 - -# Obtain list of running containers with the pebble base image -image_ids=$("${CONTAINER_RUNTIME}" ps --filter "ancestor=${IMAGE}" --format '{{.ID}}') - -image_id= -# If list is not empty, check if any have the current directory mounted -if [ -n "${image_ids}" ]; then - image_id=$("${CONTAINER_RUNTIME}" inspect ${image_ids} | jq -r --arg pwd "$(pwd)" '[.[] | select (.Mounts[].Destination == "/pebble" and .Mounts[].Source == $pwd)][0].Id | select (. != null)') - [ -n "${CLEAN}" ] && "${CONTAINER_RUNTIME}" kill ${image_ids} -fi - -[ -n "${CLEAN}" ] && exit 0 - -# If no running containers have the current directory mounted, create one -if [ -z "${image_id}" ]; then - image_id=$("${CONTAINER_RUNTIME}" run ${EXTRA_RUN_ARGS} -d -e DISPLAY=$DISPLAY -v /tmp/.X11-unix/:/tmp/.x11-unix -v ~/.Xauthority:/home/pebble/.Xauthority --net=host --entrypoint="sleep" -v .:/pebble ${IMAGE} infinity) -fi -# Pass all args to the pebble tool in the container that has the current directory mounted -"${CONTAINER_RUNTIME}" exec -it -w="/pebble" ${image_id} pebble $@