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 +4 -4
- data/CHANGELOG.md +5 -0
- data/lib/trmnlp/cli.rb +1 -0
- data/lib/trmnlp/commands/list.rb +1 -1
- data/lib/trmnlp/commands/login.rb +26 -16
- data/lib/trmnlp/config/app.rb +7 -0
- 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: 84919e1b992ea8c0adab71308260b49c178f6c8c9af501b0d5662f80f123e262
|
|
4
|
+
data.tar.gz: 58c3960edf707710301e76b004172d0983a7f26e6fc8f4cd79e2376a599938fe
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
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
data/lib/trmnlp/commands/list.rb
CHANGED
|
@@ -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
|
-
|
|
13
|
-
|
|
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
|
-
|
|
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
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
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
|
data/lib/trmnlp/config/app.rb
CHANGED
|
@@ -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')
|
data/lib/trmnlp/version.rb
CHANGED