trmnl_preview 0.5.5 → 0.5.6

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: 16a333009aab09891c12d6fe7bf3b8662912cd6e376f31c1a4997de5a6c93314
4
- data.tar.gz: cf57e05fa4ba41059e55fb7281d7644ee07772459b63503ebe4a4023fae14085
3
+ metadata.gz: abf6757d447adc5c12e7eed3baa049bc80757bc536f0da60af8ccb624d4216d4
4
+ data.tar.gz: a533ae492f2ea9b71a55130977a88988ec3767c1393b2ebbbf618364a5a0f53b
5
5
  SHA512:
6
- metadata.gz: 43048f869b37533061b92b7e06b2623b8d47e35098942f535301655727efc726f09c004330f277fb1ee7d0a73f3b5785283846b1404e0d8a6b92cec4f94b9105
7
- data.tar.gz: 3a8672a65e06a537fef9c51e759657076bcda0a320cc4f2ee8a211c27bad31bcab09993ab592c520c3103805e2077a5f907c67c2423184688fd612d0c307e276
6
+ metadata.gz: a88985299e6c183a0ee61fa609f117dffad48b42e1abdd4c2ea8303051725f44fc411870d9b5999d0ce7b1f78e6923d10974cf79ea79787ed61212eed36c3aa4
7
+ data.tar.gz: bbdd8ac78d326b086eb56c8a66cf2aaf96096e1beb879ee951cda37b6f699cf14fc5d796fac34d4711b20c8d750075f38c1110d2829d0ebe1ed0d5fafa44c9c3
data/CHANGELOG.md CHANGED
@@ -1,5 +1,13 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.5.6
4
+
5
+ - Fixed bug that left blank plugins on server after upload failed
6
+ - Fixed bug creating upload.zip after previous upload had failed
7
+ - Added support to read API key fromk `TRMNL_API_KEY` environment variable (@andi4000)
8
+ - Fixed `init` command in Docker container (@jbarreiros)
9
+ - Automatically remove ephemeral Docker container after exit (@andi4000)
10
+
3
11
  ## 0.5.5
4
12
 
5
13
  - Added dark mode (@stephenyeargin)
data/README.md CHANGED
@@ -31,11 +31,11 @@ This is the structure of a plugin project:
31
31
  You can start building a plugin locally, then `push` it to the TRMNL server for display on your device.
32
32
 
33
33
  ```sh
34
- trmnlp init my_plugin # generate
35
- cd my_plugin
36
- trmnlp serve # develop locally
37
- trmnlp login # authenticate
38
- trmnlp push # upload
34
+ trmnlp init [my_plugin] # generate
35
+ cd [my_plugin]
36
+ trmnlp serve # develop locally
37
+ trmnlp login # authenticate
38
+ trmnlp push # upload
39
39
  ```
40
40
 
41
41
  ## Modifying an Existing Plugin
@@ -43,13 +43,19 @@ trmnlp push # upload
43
43
  If you have built a plugin with the web-based editor, you can `clone` it, work on it locally, and `push` changes back to the server.
44
44
 
45
45
  ```sh
46
- trmnlp login # authenticate
47
- trmnlp clone my_plugin [id] # first download
48
- cd my_plugin
49
- trmnlp serve # develop locally
50
- trmnlp push # upload
46
+ trmnlp login # authenticate
47
+ trmnlp clone [my_plugin] [id] # first download
48
+ cd [my_plugin]
49
+ trmnlp serve # develop locally
50
+ trmnlp push # upload
51
51
  ```
52
52
 
53
+ ## Authentication
54
+
55
+ The `trmnlp login` command saves your API key to `~/.config/trmnlp/config.yml`.
56
+
57
+ If an environment variable is more convenient (for example in a CI/CD pipeline), you can set `$TRMNL_API_KEY` instead.
58
+
53
59
  ## Running trmnlp
54
60
 
55
61
  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.
@@ -53,6 +53,16 @@ module TRMNLP
53
53
  end
54
54
  end
55
55
 
56
+ def delete_plugin_setting(id)
57
+ response = conn.delete("plugin_settings/#{id}")
58
+
59
+ if response.status == 204
60
+ true
61
+ else
62
+ raise Error, "failed to delete plugin setting: #{response.status} #{response.body}"
63
+ end
64
+ end
65
+
56
66
  private
57
67
 
58
68
  attr_reader :config
@@ -6,7 +6,9 @@ module TRMNLP
6
6
  def call
7
7
  if config.app.logged_in?
8
8
  anonymous_key = config.app.api_key[0..10] + '*' * (config.app.api_key.length - 11)
9
- output "Currently authenticated as: #{anonymous_key}"
9
+ output "Currently authenticated as: #{anonymous_key}"
10
+ confirm = prompt("You are already authenticated. Do you want to re-authenticate? (y/N): ")
11
+ return unless confirm.strip.downcase == 'y'
10
12
  end
11
13
 
12
14
  output "Please visit #{config.app.account_uri} to grab your API key, then paste it here."
@@ -11,6 +11,7 @@ module TRMNLP
11
11
  authenticate!
12
12
 
13
13
  is_new = false
14
+ zip_path = 'upload.zip'
14
15
 
15
16
  api = APIClient.new(config)
16
17
 
@@ -27,10 +28,7 @@ module TRMNLP
27
28
  raise Error, 'aborting' unless answer == 'y' || answer == 'yes'
28
29
  end
29
30
 
30
- size = 0
31
-
32
- zip_path = 'upload.zip'
33
- f = Zip::File.open(zip_path, Zip::File::CREATE) do |zip_file|
31
+ Zip::File.open(zip_path, Zip::File::CREATE) do |zip_file|
34
32
  paths.src_files.each do |file|
35
33
  zip_file.add(File.basename(file), file)
36
34
  end
@@ -40,7 +38,6 @@ module TRMNLP
40
38
  paths.plugin_config.write(response.dig('data', 'settings_yaml'))
41
39
 
42
40
  size = File.size(zip_path)
43
- File.delete(zip_path)
44
41
 
45
42
  output <<~HEREDOC
46
43
  Uploaded plugin (#{size} bytes)
@@ -55,6 +52,15 @@ module TRMNLP
55
52
  #{config.app.playlists_uri}
56
53
  HEREDOC
57
54
  end
55
+ rescue
56
+ if is_new && plugin_settings_id
57
+ output 'Error during creation, cleaning up...'
58
+ api.delete_plugin_setting(plugin_settings_id)
59
+ end
60
+
61
+ raise
62
+ ensure
63
+ File.delete(zip_path) if File.exist?(zip_path)
58
64
  end
59
65
  end
60
66
  end
@@ -17,7 +17,11 @@ module TRMNLP
17
17
  def logged_in? = api_key && !api_key.empty?
18
18
  def logged_out? = !logged_in?
19
19
 
20
- def api_key = @config['api_key']
20
+ def api_key
21
+ env_api_key = ENV['TRMNL_API_KEY']
22
+ return env_api_key if env_api_key && !env_api_key.empty?
23
+ @config['api_key']
24
+ end
21
25
 
22
26
  def api_key=(key)
23
27
  @config['api_key'] = key
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module TRMNLP
4
- VERSION = "0.5.5".freeze
4
+ VERSION = "0.5.6".freeze
5
5
  end
@@ -13,6 +13,7 @@ fi
13
13
  if command -v docker &> /dev/null
14
14
  then
15
15
  docker run \
16
+ --rm \
16
17
  --publish 4567:4567 \
17
18
  --volume "$(pwd):/plugin" \
18
19
  trmnl/trmnlp "$@"
@@ -27,4 +28,4 @@ Or install Docker:
27
28
 
28
29
  https://docs.docker.com/get-docker/"
29
30
 
30
- exit 1
31
+ exit 1
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: trmnl_preview
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.5
4
+ version: 0.5.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Rockwell Schrock
8
8
  bindir: bin
9
9
  cert_chain: []
10
- date: 2025-06-27 00:00:00.000000000 Z
10
+ date: 2025-07-10 00:00:00.000000000 Z
11
11
  dependencies:
12
12
  - !ruby/object:Gem::Dependency
13
13
  name: sinatra