trmnl_preview 0.8.6 → 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 +11 -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/user_data_assembler.rb +13 -5
- 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,17 @@
|
|
|
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
|
+
|
|
9
|
+
## 0.8.7
|
|
10
|
+
|
|
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)
|
|
12
|
+
- Fixed the transform receiving the `trmnl.system` namespace, which the hosted service withholds. Transforms now see only `trmnl.user`, `trmnl.device`, and `trmnl.plugin_settings`, matching production.
|
|
13
|
+
- Added `trmnl.user.id` to the user namespace so its shape matches the hosted service.
|
|
14
|
+
|
|
4
15
|
## 0.8.6
|
|
5
16
|
|
|
6
17
|
- Fix missing form fields `db/data/form_fields.yml`.
|
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')
|
|
@@ -17,14 +17,14 @@ 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
|
|
21
|
-
# re-applied after the transform so it
|
|
22
|
-
# transform doesn't pass it through.
|
|
20
|
+
# then piped through the transform. The assembled trmnl namespace
|
|
21
|
+
# (overrides included) is re-applied after the transform so it
|
|
22
|
+
# survives even when the transform doesn't pass it through.
|
|
23
23
|
def call(device: {})
|
|
24
24
|
namespace = base_trmnl_data(device:)
|
|
25
25
|
merged = assemble(namespace)
|
|
26
|
-
result = transform_pipeline.call(merged)
|
|
27
|
-
result['trmnl'] =
|
|
26
|
+
result = transform_pipeline.call(transform_input(merged))
|
|
27
|
+
result['trmnl'] = merged['trmnl']
|
|
28
28
|
result
|
|
29
29
|
end
|
|
30
30
|
|
|
@@ -43,6 +43,13 @@ module TRMNLP
|
|
|
43
43
|
data
|
|
44
44
|
end
|
|
45
45
|
|
|
46
|
+
# The hosted service exposes only user/device/plugin_settings to the
|
|
47
|
+
# transform; the system namespace is added afterward. Mirror that slice
|
|
48
|
+
# so transforms behave the same locally as in production.
|
|
49
|
+
def transform_input(merged)
|
|
50
|
+
merged.merge('trmnl' => merged['trmnl'].slice('user', 'device', 'plugin_settings'))
|
|
51
|
+
end
|
|
52
|
+
|
|
46
53
|
def merge_source_data!(data)
|
|
47
54
|
if config.plugin.static?
|
|
48
55
|
data.merge!(config.plugin.static_data)
|
|
@@ -68,6 +75,7 @@ module TRMNLP
|
|
|
68
75
|
tz = ActiveSupport::TimeZone.find_tzinfo(config.project.time_zone)
|
|
69
76
|
iana = tz.name
|
|
70
77
|
{
|
|
78
|
+
'id' => 1,
|
|
71
79
|
'name' => 'name', 'first_name' => 'first_name', 'last_name' => 'last_name',
|
|
72
80
|
'locale' => 'en', 'time_zone' => ActiveSupport::TimeZone::MAPPING.invert[iana] || iana,
|
|
73
81
|
'time_zone_iana' => iana, 'utc_offset' => tz.utc_offset
|
data/lib/trmnlp/version.rb
CHANGED