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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 0f80ac8d03e9b67e4ea6c7f18e8cd7745a76c910e9801f910662cc46b5661eb0
4
- data.tar.gz: 1022cfae134c303ba7d00201d2d6ca7acb7c23c927371585b9e63a00fa28bfa2
3
+ metadata.gz: 236a5502b02ab161fffc5330fc712c329810f877038c71baadc86b376e607157
4
+ data.tar.gz: 41400bbbe0b54639311ae928280277ee1717f58f1de74bd71ab92f213bbe92db
5
5
  SHA512:
6
- metadata.gz: 6667ad132d9b601073db2010c524f8322e6a7fd2b5425d248cf3a53398166d1f579171e8c1142da146247f7fcb96192c50c7fa0e8d9158797bc98d7bc9755eb2
7
- data.tar.gz: 189d830c8ee5b2ed2ccd2006ef1fda9c6dadd258488a74d4925ac4476762c581fd4df3961fb94f771ff0943f3ba57cd62d0294cff6e5e1c5f79558c763d534a1
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, 2, or 4 — overriding the markup |
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, 2, or 4 (with --png)'
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
- def css_url = "#{@asset_host}/css/#{path_segment}/plugins.css"
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/#{path_segment}/plugins.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.view_markup.values
28
- .flat_map { |html| html.scan(/<img[^>]+src\s*=\s*["']([^"']+)["']/i).flatten }
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, not window.onLoad()'
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
@@ -72,7 +72,7 @@ module TRMNLP
72
72
  end
73
73
  end
74
74
 
75
- # bindings must match the `GET /render/{view}.html` route in app.rb
75
+ # ivars must match the @-references in web/views/render_html.erb
76
76
  class TemplateBinding
77
77
  def initialize(renderer, view, params)
78
78
  @view = view
@@ -59,9 +59,7 @@ module TRMNLP
59
59
  TransformClient::Result.new(
60
60
  stdout: parsed['stdout'] || '',
61
61
  stderr: parsed['stderr'] || '',
62
- # Fall back to stdout for daemons that haven't been upgraded to
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
- # verbatim except for the configurable sink.
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 re-applied
21
- # after the transform so device, user, and plugin_settings survive
22
- # even when the transform doesn't pass them through.
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)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module TRMNLP
4
- VERSION = '0.8.1'
4
+ VERSION = '0.8.2'
5
5
  end
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.8.1
4
+ version: 0.8.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Rockwell Schrock