trmnl_preview 0.8.7 → 0.8.8

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: d16bcd0fdfc494a9984625f39fad67bdc5603d8506e4865a91038d4b582609aa
4
- data.tar.gz: a756611a7c1b1a0e02fbeb183cb6d2f2a7bf02ecfdc37b03d3a415ad582f774a
3
+ metadata.gz: 84919e1b992ea8c0adab71308260b49c178f6c8c9af501b0d5662f80f123e262
4
+ data.tar.gz: 58c3960edf707710301e76b004172d0983a7f26e6fc8f4cd79e2376a599938fe
5
5
  SHA512:
6
- metadata.gz: da3d1e0a4df32aa1c0c1a2dc6a6e189c0910f7f1199105502fa41fabce014818320136a63ec25541fb3133cd10e27e26bb3afbc43ec940d4a0aebb5bf8997689
7
- data.tar.gz: f20e88c4acfe689d02a18daa36f696bd612682f7da1b2c5fe8b2fa85301f835870ec209b0457de5a9a61c9d053adf851911aac95576608f777b68b8fba1caff4
6
+ metadata.gz: 7c6f55953c874c74239386a4cc703e7e1641058a4b3b4ea37a12eb7403d540f8acae62a3479eeb6c12b7eedf6243ec80dc6e5d887891e3ad5e64684abc4350b1
7
+ data.tar.gz: 1de6ad69a4708c0c7922cb21ce40f811f6e2fd591641cda99dbddeac157bbb0470c541a7fa661366b83b978075bc27dece96c416aa70d3310b146ea2afacdf74
data/CHANGELOG.md CHANGED
@@ -1,6 +1,11 @@
1
1
 
2
2
  # Changelog
3
3
 
4
+ ## 0.8.8
5
+
6
+ - Added a `--server` flag to `trmnlp login` so commands like `trmnlp push` can target a self-hosted (BYOS) server. The chosen URL is saved as `base_url`, and the `user_` API key prefix is only required for trmnl.com; BYOS servers accept their own token formats. A scheme-less `--server` value (such as `localhost:3000`) no longer crashes the host check. (#113)
7
+ - `trmnlp list` now shows plugins with a nil `plugin_id`, which BYOS servers like LaraPaper return. (#113)
8
+
4
9
  ## 0.8.7
5
10
 
6
11
  - Fixed `.trmnlp.yml` `variables` overrides under the `trmnl` namespace being dropped. The assembler re-applied the pre-override namespace after the transform, clobbering user overrides like `trmnl.user.time_zone`. (#110)
data/lib/trmnlp/cli.rb CHANGED
@@ -28,6 +28,7 @@ module TRMNLP
28
28
  end
29
29
 
30
30
  desc 'login', 'Authenticate with TRMNL server'
31
+ method_option :server, type: :string, aliases: '-s', desc: 'Server URL (default: https://trmnl.com)'
31
32
  def login
32
33
  Commands::Login.run(options)
33
34
  end
@@ -16,7 +16,7 @@ module TRMNLP
16
16
  api = APIClient.new(config)
17
17
  response = api.get_plugin_settings
18
18
  plugins = (response || [])
19
- .select { |p| p['plugin_id'] == PRIVATE_PLUGIN_ID }
19
+ .select { |p| p['plugin_id'].nil? || p['plugin_id'] == PRIVATE_PLUGIN_ID }
20
20
  .sort_by { |p| (p['name'] || '').downcase }
21
21
 
22
22
  if plugins.empty?
@@ -6,36 +6,46 @@ require_relative '../api_client'
6
6
  module TRMNLP
7
7
  module Commands
8
8
  class Login < Base
9
- Options = Data.define(:dir, :quiet)
9
+ Options = Data.define(:dir, :quiet, :server)
10
10
 
11
11
  def call
12
- if config.app.logged_in?
13
- anonymous_key = config.app.api_key[0..10] + ('*' * (config.app.api_key.length - 11))
14
- reporter.info "Currently authenticated as: #{anonymous_key}"
15
- confirm = prompt('You are already authenticated. Do you want to re-authenticate? (y/N): ')
16
- return unless confirm.strip.downcase == 'y'
17
- end
12
+ config.app.base_url = options.server if options.server
13
+ return unless confirm_reauthentication?
18
14
 
19
15
  reporter.info "Please visit #{config.app.account_uri} to grab your API key, then paste it here."
20
16
 
21
17
  api_key = prompt('API Key: ')
22
18
  raise InvalidApiKey, 'API key cannot be empty' if api_key.empty?
23
- unless api_key.start_with?('user_')
19
+
20
+ # Only trmnl.com issues user_-prefixed keys; BYOS servers use their own token formats (e.g. Sanctum).
21
+ if config.app.trmnl_host? && !api_key.start_with?('user_')
24
22
  raise InvalidApiKey,
25
23
  'Invalid API key; did you copy it from the right place?'
26
24
  end
27
25
 
28
26
  config.app.api_key = api_key
27
+ save_credentials
28
+ end
29
+
30
+ private
29
31
 
32
+ def confirm_reauthentication?
33
+ return true unless config.app.logged_in?
34
+
35
+ anonymous_key = config.app.api_key[0..10] + ('*' * (config.app.api_key.length - 11))
36
+ reporter.info "Currently authenticated as: #{anonymous_key}"
37
+ confirm = prompt('You are already authenticated. Do you want to re-authenticate? (y/N): ')
38
+ confirm.strip.downcase == 'y'
39
+ end
40
+
41
+ def save_credentials
30
42
  api_client = APIClient.new(config)
31
- begin
32
- user_info = api_client.get_me
33
- reporter.info "Authenticated as #{user_info['name']} (#{user_info['email']})"
34
- config.app.save
35
- reporter.info "Saved changes to #{paths.app_config}"
36
- rescue StandardError => e
37
- raise AuthenticationFailed, "Authentication failed; changes were not saved.\n#{e.message}"
38
- end
43
+ user_info = api_client.get_me
44
+ reporter.info "Authenticated as #{user_info['name']} (#{user_info['email']})"
45
+ config.app.save
46
+ reporter.info "Saved changes to #{paths.app_config}"
47
+ rescue StandardError => e
48
+ raise AuthenticationFailed, "Authentication failed; changes were not saved.\n#{e.message}"
39
49
  end
40
50
  end
41
51
  end
@@ -30,8 +30,15 @@ module TRMNLP
30
30
  @config['api_key'] = key
31
31
  end
32
32
 
33
+ def base_url=(url)
34
+ @config['base_url'] = url
35
+ end
36
+
33
37
  def base_uri = URI.parse(@config['base_url'] || 'https://trmnl.com')
34
38
 
39
+ # Scheme-less base_urls (e.g. "localhost:3000") parse to a nil host, so guard before matching.
40
+ def trmnl_host? = !!base_uri.host&.end_with?('trmnl.com')
41
+
35
42
  def api_uri = URI.join(base_uri, '/api')
36
43
 
37
44
  def account_uri = URI.join(base_uri, '/account')
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module TRMNLP
4
- VERSION = '0.8.7'
4
+ VERSION = '0.8.8'
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.7
4
+ version: 0.8.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Rockwell Schrock