trmnl_preview 0.8.1 → 0.8.2
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 +4 -4
- data/CHANGELOG.md +5 -0
- data/README.md +63 -1
- data/lib/trmnlp/cli.rb +1 -1
- data/lib/trmnlp/framework_version.rb +6 -8
- data/lib/trmnlp/lint/checks/image_links_reachable.rb +2 -2
- data/lib/trmnlp/lint/checks/waits_for_dom_load.rb +2 -1
- data/lib/trmnlp/renderer.rb +1 -1
- data/lib/trmnlp/transform_backend/http.rb +1 -3
- data/lib/trmnlp/transform_backend/wrapper.rb +4 -2
- data/lib/trmnlp/user_data_assembler.rb +3 -3
- data/lib/trmnlp/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 236a5502b02ab161fffc5330fc712c329810f877038c71baadc86b376e607157
|
|
4
|
+
data.tar.gz: 41400bbbe0b54639311ae928280277ee1717f58f1de74bd71ab92f213bbe92db
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 604a7f74231c2e738dbf61995469a64e488cc1d69fa9eb84076fb9badfb2d83fd8c490fa261154471852e7c7effb6071e458d40e748bc70de7ea27455d5a8485
|
|
7
|
+
data.tar.gz: c4396159f68882180618578725f2e386e703a9d992a195a5ce2de463d8dab407d9b0a30655495963e0b1af35ee2ab0813fae75ed77633d616312fa64246ef753
|
data/CHANGELOG.md
CHANGED
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
|
|
2
2
|
# Changelog
|
|
3
3
|
|
|
4
|
+
## 0.8.2
|
|
5
|
+
|
|
6
|
+
- Fixed `framework_version: latest` rendering against the auto-upgrading `/latest/` asset path instead of the current concrete release, matching the hosted service (#99)
|
|
7
|
+
- Cleanup and minor improvements
|
|
8
|
+
|
|
4
9
|
## 0.8.1
|
|
5
10
|
|
|
6
11
|
### Added
|
data/README.md
CHANGED
|
@@ -111,7 +111,7 @@ trmnlp build --png --color-depth 2
|
|
|
111
111
|
| `--png` | Render a PNG per view alongside the HTML |
|
|
112
112
|
| `--width` | PNG width in pixels (default 800) |
|
|
113
113
|
| `--height` | PNG height in pixels (default 480) |
|
|
114
|
-
| `--color-depth` | PNG bit depth — 1
|
|
114
|
+
| `--color-depth` | PNG bit depth — 1-8 — overriding the markup |
|
|
115
115
|
|
|
116
116
|
`--width`, `--height`, and `--color-depth` apply only with `--png`. PNG rendering needs Firefox and ImageMagick installed; plain `trmnlp build` needs neither.
|
|
117
117
|
|
|
@@ -121,6 +121,53 @@ The `trmnlp login` command saves your API key to `~/.config/trmnlp/config.yml`.
|
|
|
121
121
|
|
|
122
122
|
If an environment variable is more convenient (for example in a CI/CD pipeline), you can set `$TRMNL_API_KEY` instead.
|
|
123
123
|
|
|
124
|
+
## Continuous Integration
|
|
125
|
+
|
|
126
|
+
`trmnlp` runs in GitHub Actions without `trmnlp login` — set the `TRMNL_API_KEY`
|
|
127
|
+
environment variable and it's used in place of the saved config. Add it as a
|
|
128
|
+
repository secret, then drop this into `.github/workflows/trmnl.yml`:
|
|
129
|
+
|
|
130
|
+
```yaml
|
|
131
|
+
name: TRMNL
|
|
132
|
+
on:
|
|
133
|
+
pull_request:
|
|
134
|
+
push:
|
|
135
|
+
branches: [main]
|
|
136
|
+
|
|
137
|
+
jobs:
|
|
138
|
+
lint:
|
|
139
|
+
runs-on: ubuntu-latest
|
|
140
|
+
steps:
|
|
141
|
+
- uses: actions/checkout@v6
|
|
142
|
+
- uses: ruby/setup-ruby@v1
|
|
143
|
+
with:
|
|
144
|
+
ruby-version: "4.0"
|
|
145
|
+
- run: gem install trmnl_preview
|
|
146
|
+
- run: trmnlp lint
|
|
147
|
+
|
|
148
|
+
push:
|
|
149
|
+
needs: lint
|
|
150
|
+
if: github.ref == 'refs/heads/main'
|
|
151
|
+
runs-on: ubuntu-latest
|
|
152
|
+
steps:
|
|
153
|
+
- uses: actions/checkout@v6
|
|
154
|
+
- uses: ruby/setup-ruby@v1
|
|
155
|
+
with:
|
|
156
|
+
ruby-version: "4.0"
|
|
157
|
+
- run: gem install trmnl_preview
|
|
158
|
+
- run: trmnlp push --force
|
|
159
|
+
env:
|
|
160
|
+
TRMNL_API_KEY: ${{ secrets.TRMNL_API_KEY }}
|
|
161
|
+
```
|
|
162
|
+
|
|
163
|
+
The `lint` job gates every pull request — `trmnlp lint` exits non-zero on
|
|
164
|
+
issues, so a failing check blocks the merge. The `push` job uploads to TRMNL
|
|
165
|
+
only on `main`.
|
|
166
|
+
|
|
167
|
+
> **Make sure `src/settings.yml` has an `id`.** `trmnlp push` updates the
|
|
168
|
+
> plugin with that id; without one it creates a *new* plugin on every run.
|
|
169
|
+
> Projects made with `trmnlp clone` or `trmnlp pull` already have it.
|
|
170
|
+
|
|
124
171
|
## Running trmnlp
|
|
125
172
|
|
|
126
173
|
The `bin/trmnlp` script is provided as a convenience. It will use the local Ruby gem if available, falling back to the `trmnl/trmnlp` Docker image.
|
|
@@ -336,6 +383,21 @@ bin/rake
|
|
|
336
383
|
|
|
337
384
|
Specs run under SimpleCov; a coverage report is written to `coverage/`.
|
|
338
385
|
|
|
386
|
+
## Releasing
|
|
387
|
+
|
|
388
|
+
Releases are automated. The [`Release` workflow](.github/workflows/release.yaml)
|
|
389
|
+
fires whenever `lib/trmnlp/version.rb` changes on `main`, then tags the commit,
|
|
390
|
+
publishes the gem to RubyGems, and pushes the multi-arch Docker image. Each step
|
|
391
|
+
is idempotent, so the workflow is safe to re-run after a partial failure.
|
|
392
|
+
|
|
393
|
+
To cut a release:
|
|
394
|
+
|
|
395
|
+
1. Bump the version in `lib/trmnlp/version.rb`.
|
|
396
|
+
2. Run `bundle install` so `Gemfile.lock` picks up the new version.
|
|
397
|
+
3. Commit and merge to `main` — the workflow does the rest.
|
|
398
|
+
|
|
399
|
+
By convention, add a matching `CHANGELOG.md` entry in the same change.
|
|
400
|
+
|
|
339
401
|
## Contributing
|
|
340
402
|
|
|
341
403
|
Bug reports and pull requests are welcome on GitHub at https://github.com/usetrmnl/trmnlp.
|
data/lib/trmnlp/cli.rb
CHANGED
|
@@ -22,7 +22,7 @@ module TRMNLP
|
|
|
22
22
|
method_option :png, type: :boolean, default: false, desc: 'Also render a PNG per view'
|
|
23
23
|
method_option :width, type: :numeric, desc: 'PNG width in pixels (with --png)'
|
|
24
24
|
method_option :height, type: :numeric, desc: 'PNG height in pixels (with --png)'
|
|
25
|
-
method_option :color_depth, type: :numeric, desc: 'PNG bit depth: 1
|
|
25
|
+
method_option :color_depth, type: :numeric, desc: 'PNG bit depth: 1-8 (with --png)'
|
|
26
26
|
def build
|
|
27
27
|
Commands::Build.run(options)
|
|
28
28
|
end
|
|
@@ -44,9 +44,13 @@ module TRMNLP
|
|
|
44
44
|
|
|
45
45
|
def pinned? = @pinned
|
|
46
46
|
|
|
47
|
-
|
|
47
|
+
# Both a pinned and an unpinned ("latest") version resolve to a
|
|
48
|
+
# concrete release here — #number is never the literal "latest" — so a
|
|
49
|
+
# local preview renders the same bundle as the hosted service instead
|
|
50
|
+
# of drifting onto a new release the moment one ships.
|
|
51
|
+
def css_url = "#{@asset_host}/css/#{number}/plugins.css"
|
|
48
52
|
|
|
49
|
-
def js_url = "#{@asset_host}/js/#{
|
|
53
|
+
def js_url = "#{@asset_host}/js/#{number}/plugins.js"
|
|
50
54
|
|
|
51
55
|
def ==(other) = other.is_a?(self.class) && number == other.number
|
|
52
56
|
|
|
@@ -59,11 +63,5 @@ module TRMNLP
|
|
|
59
63
|
def as_json(*) = number
|
|
60
64
|
|
|
61
65
|
def to_s = number
|
|
62
|
-
|
|
63
|
-
private
|
|
64
|
-
|
|
65
|
-
# When pinned, requests assets at /css/<version>/plugins.css to lock
|
|
66
|
-
# behavior; otherwise hit /css/latest/ for live updates.
|
|
67
|
-
def path_segment = pinned? ? @number : 'latest'
|
|
68
66
|
end
|
|
69
67
|
end
|
|
@@ -24,8 +24,8 @@ module TRMNLP
|
|
|
24
24
|
def pass? = static_image_urls.all? { |url| reachable?(url) }
|
|
25
25
|
|
|
26
26
|
def static_image_urls
|
|
27
|
-
source.
|
|
28
|
-
.
|
|
27
|
+
source.all_markup
|
|
28
|
+
.scan(/<img[^>]+src\s*=\s*["']([^"']+)["']/i).flatten
|
|
29
29
|
.map(&:strip)
|
|
30
30
|
.reject { |src| src.empty? || src.include?('{{') || src.start_with?('data:') }
|
|
31
31
|
end
|
|
@@ -6,7 +6,8 @@ module TRMNLP
|
|
|
6
6
|
module Lint
|
|
7
7
|
module Checks
|
|
8
8
|
class WaitsForDomLoad < Check
|
|
9
|
-
MESSAGE = 'JavaScript should listen for the DOMContentLoaded event,
|
|
9
|
+
MESSAGE = 'JavaScript should listen for the DOMContentLoaded event, ' \
|
|
10
|
+
'not window.onload or window.addEventListener("load")'
|
|
10
11
|
LEARN_MORE = 'https://help.trmnl.com/en/articles/9510536-private-plugins#h_db7030f8b8'
|
|
11
12
|
FORBIDDEN = ['window.onload', 'window.addeventlistener("load")',
|
|
12
13
|
"window.addeventlistener('load')"].freeze
|
data/lib/trmnlp/renderer.rb
CHANGED
|
@@ -59,9 +59,7 @@ module TRMNLP
|
|
|
59
59
|
TransformClient::Result.new(
|
|
60
60
|
stdout: parsed['stdout'] || '',
|
|
61
61
|
stderr: parsed['stderr'] || '',
|
|
62
|
-
|
|
63
|
-
# the separate `output` channel yet.
|
|
64
|
-
output: (parsed['output'].to_s.empty? ? parsed['stdout'] : parsed['output']).to_s,
|
|
62
|
+
output: parsed['output'].to_s,
|
|
65
63
|
exit_code: parsed['exit_code'] || 0,
|
|
66
64
|
duration_ms: parsed['duration_ms'] || 0,
|
|
67
65
|
error: parsed['error']
|
|
@@ -9,8 +9,10 @@ module TRMNLP
|
|
|
9
9
|
# snippet supplied by the caller. Subprocess writes to a tempfile
|
|
10
10
|
# path, Http writes to FD 3 for the production daemon to capture.
|
|
11
11
|
#
|
|
12
|
-
# Mirrors the hosted serverless runtime's code-wrapping behavior
|
|
13
|
-
#
|
|
12
|
+
# Mirrors the hosted serverless runtime's code-wrapping behavior,
|
|
13
|
+
# parameterized on the per-backend output sink. PHP additionally
|
|
14
|
+
# carries a leading `<?php` tag the file-based Subprocess path
|
|
15
|
+
# needs; the daemon tolerates it, so parity holds.
|
|
14
16
|
#
|
|
15
17
|
# NOTE: `output_sink` is spliced verbatim into the generated script as
|
|
16
18
|
# executable code. It MUST be trmnlp-generated (see Subprocess#sink_for
|
|
@@ -17,9 +17,9 @@ module TRMNLP
|
|
|
17
17
|
|
|
18
18
|
# Assembles the merged data hash. The trmnl namespace is built first,
|
|
19
19
|
# layered with static_data / cached polled data / user_data_overrides,
|
|
20
|
-
# then piped through the transform. The trmnl namespace is
|
|
21
|
-
# after the transform so
|
|
22
|
-
#
|
|
20
|
+
# then piped through the transform. The whole trmnl namespace is
|
|
21
|
+
# re-applied after the transform so it survives even when the
|
|
22
|
+
# transform doesn't pass it through.
|
|
23
23
|
def call(device: {})
|
|
24
24
|
namespace = base_trmnl_data(device:)
|
|
25
25
|
merged = assemble(namespace)
|
data/lib/trmnlp/version.rb
CHANGED