trmnl_preview 0.21.0 → 0.22.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d1b736ce74a0385dda5b989fe604d0256d0b1522b1955855aa0eac945ec3dd0b
4
- data.tar.gz: f4b4321d72bd9129a025f07d21707f0584e965a5bfe072db3ecc95c2fbf04921
3
+ metadata.gz: '089ae072f5b1117682e0aeec9337910929f304d36ff8f19e33cc2ca08c76ccdc'
4
+ data.tar.gz: e3fc15289b21f4b039fb236096ea8c6bddf8323ce468ea92057f3864868adffd
5
5
  SHA512:
6
- metadata.gz: 3997799add0b42fd60ffd8f6c7d9d3c99696152fe32316e8925cfe1a24eed73f410a7efc86a432a46697d1fbd7fa0fa44c7d8c63727c48c0ff48778035e993f5
7
- data.tar.gz: 12cf46d3ae00fda1f1e82eb80c5ed2bbe2598208ad84de9ecdc878afcb96b51f27e4ed62630195cdb1a0fc60a8d5b6cbc1d6be2f1ef4833aefdc0c370cd1634d
6
+ metadata.gz: 9cb4cf95b5c00363682503b4383c236f8d63becc470146c37248da0b7c6073ef5b490f8cc7cbb774fc3053fa0061c5097151f08cd9a84f19dbd9531e43762131
7
+ data.tar.gz: a5411570286789b52c8d0c44e27626b7a4a181f4c8fd8737ecb4b2ad147103da60a977a0b83d320c5cab68bd10b06e3dcd84fd5ee50d137ef8a6b518968259fc
data/CHANGELOG.md CHANGED
@@ -1,6 +1,10 @@
1
1
 
2
2
  # Changelog
3
3
 
4
+ ## 0.22.0
5
+
6
+ - The `bin/trmnlp` script that `trmnlp init` writes takes the steps that run the Docker image from the image, once a day, so a fix to them reaches every plugin with the image. Before, each plugin kept its own copy, which changed only when `trmnlp init` ran again. A plugin made before this release gets the new script from `trmnlp init <its folder>`, answering `y` for `bin/trmnlp` only, once.
7
+
4
8
  ## 0.21.0
5
9
 
6
10
  - The `bin/trmnlp` script that `trmnlp init` writes pulls a newer `trmnl/trmnlp` image once a day, so a Docker user stays on the latest release. Before, it ran whatever image was pulled first. The README shows how to install the script as `trmnlp` with Docker alone.
data/README.md CHANGED
@@ -253,9 +253,10 @@ docker run --rm --entrypoint cat trmnl/trmnlp /app/templates/init/bin/trmnlp > ~
253
253
  chmod +x ~/.local/bin/trmnlp
254
254
  ```
255
255
 
256
- It runs each command in the image and pulls a newer image once a day. To stay on one release,
257
- set `IMAGE` in the script to a tag such as `trmnl/trmnlp:v0.20.0`. `trmnlp init` puts the same
258
- script in each plugin as `bin/trmnlp`.
256
+ It runs each command in the image and pulls a newer image once a day. The steps that run the image
257
+ come from the image too, so the script itself does not go out of date. To stay on one release, set
258
+ `IMAGE` in the script to a tag such as `trmnl/trmnlp:v0.22.0` (v0.22.0 or later). `trmnlp init` puts
259
+ the same script in each plugin as `bin/trmnlp`.
259
260
 
260
261
  Or run the image yourself:
261
262
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module TRMNLP
4
- VERSION = '0.21.0'
4
+ VERSION = '0.22.0'
5
5
  end
@@ -4,6 +4,9 @@
4
4
  # Use this opportunity to set up environment variables, install dependencies, etc.
5
5
  #
6
6
 
7
+ # Add a tag to stay on one release, v0.22.0 or later: trmnl/trmnlp:v0.22.0
8
+ IMAGE=trmnl/trmnlp
9
+
7
10
  # Saved on the PATH as `trmnlp`, this script is what `command -v trmnlp` finds: not a gem.
8
11
  GEM="$(command -v trmnlp)"
9
12
  if [ -n "$GEM" ] && ! [ "$GEM" -ef "$0" ]
@@ -23,71 +26,25 @@ Or install Docker:
23
26
  exit 1
24
27
  fi
25
28
 
26
- # Determine XDG config directory on host OS
27
- if [ -n "$XDG_CONFIG_HOME" ]; then
28
- CONFIG_DIR="$XDG_CONFIG_HOME/trmnlp"
29
- else
30
- CONFIG_DIR="$HOME/.config/trmnlp"
31
- fi
32
-
33
- # What trmnlp caches is kept as well: a plugin's OAuth tokens, its saved data and transform state.
29
+ # The steps that run the image live in the image, so this copy in the plugin never goes out of date.
30
+ # Once a day a newer image is pulled and those steps are taken from it. With no network, the image
31
+ # already here is used.
34
32
  CACHE_DIR="${XDG_CACHE_HOME:-$HOME/.cache}/trmnl"
35
-
36
- mkdir -p "$CONFIG_DIR" "$CACHE_DIR"
37
-
38
- # Add a tag to stay on one release: trmnl/trmnlp:v0.20.0
39
- IMAGE=trmnl/trmnlp
40
-
41
- # A newer release is pulled once a day. With no network, the image already here runs.
42
- PULLED_AT="$CACHE_DIR/image_pulled"
43
- if [ -z "$(find "$PULLED_AT" -mtime -1 2> /dev/null)" ]; then
33
+ RUN_IN_DOCKER="$CACHE_DIR/run_in_docker/${IMAGE//[^a-zA-Z0-9._-]/_}"
34
+ if [ -z "$(find "$RUN_IN_DOCKER" -mtime -1 2> /dev/null)" ]; then
35
+ mkdir -p "$(dirname "$RUN_IN_DOCKER")"
44
36
  docker pull --quiet "$IMAGE" > /dev/null 2>&1
45
- touch "$PULLED_AT"
46
- fi
47
-
48
- # On Linux the container's root is the host's root, and the files trmnlp writes (snapshots, _build,
49
- # a pulled plugin) would be root's. So trmnlp runs as you, with a home of its own to write in.
50
- # Docker Desktop and rootless Docker hand the files to you already.
51
- CONTAINER_HOME=/root
52
- SECURITY="$(docker info --format '{{.SecurityOptions}}' 2> /dev/null)"
53
- if [ "$(uname)" = Linux ] && [ "$(id -u)" != 0 ] && [ -n "$SECURITY" ] && [[ "$SECURITY" != *rootless* ]]
54
- then
55
- CONTAINER_HOME=/tmp/home
56
- # .config and .cache are made for you as well: Docker would make them root's to mount the
57
- # folders below into them, and Firefox hangs when it cannot write there.
58
- ARGS=(
59
- --user "$(id -u):$(id -g)"
60
- --env HOME=/tmp/home
61
- --tmpfs "/tmp/home:exec,uid=$(id -u),gid=$(id -g)"
62
- --tmpfs "/tmp/home/.config:uid=$(id -u),gid=$(id -g)"
63
- --tmpfs "/tmp/home/.cache:exec,uid=$(id -u),gid=$(id -g)"
64
- )
37
+ if docker run --rm --entrypoint cat "$IMAGE" /app/templates/run_in_docker > "$RUN_IN_DOCKER.$$" 2> /dev/null
38
+ then
39
+ mv "$RUN_IN_DOCKER.$$" "$RUN_IN_DOCKER"
40
+ else
41
+ rm -f "$RUN_IN_DOCKER.$$"
42
+ fi
65
43
  fi
66
44
 
67
- # A terminal only when there is one: CI and scripts have none.
68
- if [ -t 0 ] && [ -t 1 ]; then
69
- ARGS+=(--tty)
70
- fi
71
-
72
- # Only serve listens, so every other command can run next to it.
73
- if [ "$1" = serve ]; then
74
- PORT=4567
75
- for ARG in "$@"; do
76
- case "$PREVIOUS" in -p | --port) PORT="$ARG" ;; esac
77
- case "$ARG" in --port=*) PORT="${ARG#--port=}" ;; esac
78
- PREVIOUS="$ARG"
79
- done
80
- ARGS+=(--publish "$PORT:$PORT")
45
+ if ! [ -s "$RUN_IN_DOCKER" ]; then
46
+ echo "Could not run $IMAGE. Check that Docker is running and that the image is v0.22.0 or later."
47
+ exit 1
81
48
  fi
82
49
 
83
- exec docker run \
84
- --rm \
85
- --init \
86
- --interactive \
87
- "${ARGS[@]}" \
88
- --env CI \
89
- --env TRMNL_API_KEY \
90
- --volume "$CONFIG_DIR:$CONTAINER_HOME/.config/trmnlp" \
91
- --volume "$CACHE_DIR:$CONTAINER_HOME/.cache/trmnl" \
92
- --volume "$(pwd):/plugin" \
93
- "$IMAGE" "$@"
50
+ IMAGE="$IMAGE" exec bash "$RUN_IN_DOCKER" "$@"
@@ -0,0 +1,66 @@
1
+ #!/usr/bin/env bash
2
+ #
3
+ # Runs a trmnlp command in the Docker image. The bin/trmnlp script that `trmnlp init` writes takes
4
+ # this file from the image once a day, so a fix here reaches every plugin with the image.
5
+ #
6
+
7
+ IMAGE="${IMAGE:-trmnl/trmnlp}"
8
+
9
+ # Determine XDG config directory on host OS
10
+ if [ -n "$XDG_CONFIG_HOME" ]; then
11
+ CONFIG_DIR="$XDG_CONFIG_HOME/trmnlp"
12
+ else
13
+ CONFIG_DIR="$HOME/.config/trmnlp"
14
+ fi
15
+
16
+ # What trmnlp caches is kept as well: a plugin's OAuth tokens, its saved data and transform state.
17
+ CACHE_DIR="${XDG_CACHE_HOME:-$HOME/.cache}/trmnl"
18
+
19
+ mkdir -p "$CONFIG_DIR" "$CACHE_DIR"
20
+
21
+ # On Linux the container's root is the host's root, and the files trmnlp writes (snapshots, _build,
22
+ # a pulled plugin) would be root's. So trmnlp runs as you, with a home of its own to write in.
23
+ # Docker Desktop and rootless Docker hand the files to you already.
24
+ CONTAINER_HOME=/root
25
+ SECURITY="$(docker info --format '{{.SecurityOptions}}' 2> /dev/null)"
26
+ if [ "$(uname)" = Linux ] && [ "$(id -u)" != 0 ] && [ -n "$SECURITY" ] && [[ "$SECURITY" != *rootless* ]]
27
+ then
28
+ CONTAINER_HOME=/tmp/home
29
+ # .config and .cache are made for you as well: Docker would make them root's to mount the
30
+ # folders below into them, and Firefox hangs when it cannot write there.
31
+ ARGS=(
32
+ --user "$(id -u):$(id -g)"
33
+ --env HOME=/tmp/home
34
+ --tmpfs "/tmp/home:exec,uid=$(id -u),gid=$(id -g)"
35
+ --tmpfs "/tmp/home/.config:uid=$(id -u),gid=$(id -g)"
36
+ --tmpfs "/tmp/home/.cache:exec,uid=$(id -u),gid=$(id -g)"
37
+ )
38
+ fi
39
+
40
+ # A terminal only when there is one: CI and scripts have none.
41
+ if [ -t 0 ] && [ -t 1 ]; then
42
+ ARGS+=(--tty)
43
+ fi
44
+
45
+ # Only serve listens, so every other command can run next to it.
46
+ if [ "$1" = serve ]; then
47
+ PORT=4567
48
+ for ARG in "$@"; do
49
+ case "$PREVIOUS" in -p | --port) PORT="$ARG" ;; esac
50
+ case "$ARG" in --port=*) PORT="${ARG#--port=}" ;; esac
51
+ PREVIOUS="$ARG"
52
+ done
53
+ ARGS+=(--publish "$PORT:$PORT")
54
+ fi
55
+
56
+ exec docker run \
57
+ --rm \
58
+ --init \
59
+ --interactive \
60
+ "${ARGS[@]}" \
61
+ --env CI \
62
+ --env TRMNL_API_KEY \
63
+ --volume "$CONFIG_DIR:$CONTAINER_HOME/.config/trmnlp" \
64
+ --volume "$CACHE_DIR:$CONTAINER_HOME/.cache/trmnl" \
65
+ --volume "$(pwd):/plugin" \
66
+ "$IMAGE" "$@"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: trmnl_preview
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.21.0
4
+ version: 0.22.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Rockwell Schrock
@@ -502,6 +502,7 @@ files:
502
502
  - templates/init/src/shared.liquid
503
503
  - templates/init/src/transform.py.example
504
504
  - templates/init/tests/plugin_spec.rb
505
+ - templates/run_in_docker
505
506
  - trmnl_preview.gemspec
506
507
  - web/public/highlight/highlight.min.js
507
508
  - web/public/highlight/styles/atom-one-dark.min.css