wisco 0.4.0 → 0.4.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 +4 -4
- data/lib/wisco/commands/list.rb +37 -36
- data/lib/wisco/commands/status.rb +104 -0
- data/lib/wisco/version.rb +1 -1
- data/lib/wisco.rb +11 -0
- metadata +3 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 4893611d0b98c82232776fa4705b9f92f83d76f4df549a641e2951068d7a5ee3
|
|
4
|
+
data.tar.gz: af96365443af8fc4b407ad7de5fae4c279e630665d405f6d8945c7f3a992fb2d
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 1edd85873a8c84fda1bd7829e47a7da67a917b50279204956ea29309f31174fb90825b06e298489d69dc88f11f2d9f68ec1abdb45ed96fb29200ef7e54304fab
|
|
7
|
+
data.tar.gz: 9876280ad0dbd7cb2cfeea241155f2538df6b65f37ecdd8ab4d4b6406de9c841bce52c4b23b2043b27cf047aef3919bc94da185139789013c246f0a9ecdbb2f5
|
data/lib/wisco/commands/list.rb
CHANGED
|
@@ -114,50 +114,51 @@ module Wisco
|
|
|
114
114
|
end
|
|
115
115
|
|
|
116
116
|
def build_connector_hash(connector)
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
'connection' => build_connection(connector[:connection]),
|
|
120
|
-
'actions' => build_section(connector[:actions]),
|
|
121
|
-
'triggers' => build_section(connector[:triggers]),
|
|
122
|
-
'methods' => (connector[:methods] || {}).keys.map(&:to_s).sort,
|
|
123
|
-
'pick_lists' => (connector[:pick_lists] || {}).keys.map(&:to_s).sort
|
|
124
|
-
}
|
|
125
|
-
end
|
|
126
|
-
|
|
127
|
-
def build_connection(conn)
|
|
128
|
-
return { 'fields' => [] } unless conn.is_a?(Hash)
|
|
129
|
-
|
|
130
|
-
fields = conn[:fields] || []
|
|
131
|
-
{ 'fields' => fields.map { |f| safe_serialize(f) }.compact }
|
|
132
|
-
end
|
|
117
|
+
# Full connector serialization with context-aware lambda handling
|
|
118
|
+
data = serialize_value(connector, context: :root)
|
|
133
119
|
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
section.keys.sort_by(&:to_s).each_with_object({}) do |key, h|
|
|
138
|
-
item = section[key]
|
|
139
|
-
h[key.to_s] = {
|
|
140
|
-
'title' => title_for(key, item),
|
|
141
|
-
'subtitle' => subtitle_for(item).to_s
|
|
142
|
-
}
|
|
120
|
+
# Post-process object_definitions: convert Hash to sorted array of keys
|
|
121
|
+
if data.is_a?(Hash) && data['object_definitions'].is_a?(Hash)
|
|
122
|
+
data['object_definitions'] = data['object_definitions'].keys.map(&:to_s).sort
|
|
143
123
|
end
|
|
124
|
+
|
|
125
|
+
data
|
|
144
126
|
end
|
|
145
127
|
|
|
146
|
-
|
|
147
|
-
# Proc/lambda values are dropped (returned as nil so callers can compact).
|
|
148
|
-
def safe_serialize(value)
|
|
128
|
+
def serialize_value(value, context: nil)
|
|
149
129
|
case value
|
|
130
|
+
when Proc
|
|
131
|
+
case context
|
|
132
|
+
when :methods, :pick_lists
|
|
133
|
+
# Extract parameter info; format type as string
|
|
134
|
+
{
|
|
135
|
+
'parameters' => value.parameters.map { |type, name| [type.to_s, name.to_s] }
|
|
136
|
+
}
|
|
137
|
+
else
|
|
138
|
+
# All other lambdas become "__is_lambda__" string
|
|
139
|
+
'__is_lambda__'
|
|
140
|
+
end
|
|
150
141
|
when Hash
|
|
142
|
+
# Recursively serialize each key-value pair, tracking context
|
|
151
143
|
value.each_with_object({}) do |(k, v), h|
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
serialized = safe_serialize(v)
|
|
155
|
-
h[k.to_s] = serialized
|
|
144
|
+
next_context = determine_context(k, context)
|
|
145
|
+
h[k.to_s] = serialize_value(v, context: next_context)
|
|
156
146
|
end
|
|
157
|
-
when Array
|
|
158
|
-
|
|
159
|
-
when Symbol
|
|
160
|
-
|
|
147
|
+
when Array
|
|
148
|
+
value.map { |v| serialize_value(v, context: context) }
|
|
149
|
+
when Symbol
|
|
150
|
+
value.to_s
|
|
151
|
+
else
|
|
152
|
+
value
|
|
153
|
+
end
|
|
154
|
+
end
|
|
155
|
+
|
|
156
|
+
def determine_context(key, parent_context)
|
|
157
|
+
# When traversing into :methods or :pick_lists hashes, set context for param extraction
|
|
158
|
+
case key
|
|
159
|
+
when :methods then :methods
|
|
160
|
+
when :pick_lists then :pick_lists
|
|
161
|
+
else parent_context
|
|
161
162
|
end
|
|
162
163
|
end
|
|
163
164
|
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
require 'json'
|
|
2
|
+
require_relative '../config'
|
|
3
|
+
require_relative '../connector'
|
|
4
|
+
require_relative '../profile'
|
|
5
|
+
require_relative '../version'
|
|
6
|
+
|
|
7
|
+
module Wisco
|
|
8
|
+
module Commands
|
|
9
|
+
module Status
|
|
10
|
+
module_function
|
|
11
|
+
|
|
12
|
+
def run(target_dir)
|
|
13
|
+
target_dir = File.expand_path(target_dir)
|
|
14
|
+
config_path = Wisco.config_path(target_dir)
|
|
15
|
+
|
|
16
|
+
unless File.exist?(config_path)
|
|
17
|
+
puts JSON.pretty_generate(uninitialised_payload)
|
|
18
|
+
return
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
config = Wisco::Config.load_config(config_path)
|
|
22
|
+
connector_path = config.dig('connector', 'path')
|
|
23
|
+
connector_file = config.dig('connector', 'file')
|
|
24
|
+
|
|
25
|
+
if connector_path.nil? || connector_file.nil?
|
|
26
|
+
puts JSON.pretty_generate(uninitialised_payload)
|
|
27
|
+
return
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
profile_name = config.dig('workato_developer_api', 'profile').to_s
|
|
31
|
+
profile_name = nil if profile_name.empty?
|
|
32
|
+
hostname = resolve_hostname(profile_name, config)
|
|
33
|
+
|
|
34
|
+
full_connector_path = File.join(connector_path, connector_file)
|
|
35
|
+
connector_info = load_connector_info(full_connector_path, target_dir)
|
|
36
|
+
credentials = check_credentials(connector_path)
|
|
37
|
+
|
|
38
|
+
payload = {
|
|
39
|
+
'wisco_version' => Wisco::VERSION,
|
|
40
|
+
'initialized' => true,
|
|
41
|
+
'config_path' => config_path,
|
|
42
|
+
'profile' => { 'name' => profile_name },
|
|
43
|
+
'hostname' => hostname,
|
|
44
|
+
'connection' => config['connection'],
|
|
45
|
+
'connector' => {
|
|
46
|
+
'path' => full_connector_path,
|
|
47
|
+
'valid' => connector_info[:valid],
|
|
48
|
+
'title' => connector_info[:title],
|
|
49
|
+
'error' => connector_info[:error]
|
|
50
|
+
},
|
|
51
|
+
'credentials' => credentials
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
puts JSON.pretty_generate(payload)
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
def uninitialised_payload
|
|
58
|
+
{
|
|
59
|
+
'wisco_version' => Wisco::VERSION,
|
|
60
|
+
'initialized' => false,
|
|
61
|
+
'config_path' => nil,
|
|
62
|
+
'profile' => nil,
|
|
63
|
+
'hostname' => nil,
|
|
64
|
+
'connection' => nil,
|
|
65
|
+
'connector' => nil,
|
|
66
|
+
'credentials' => nil
|
|
67
|
+
}
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
def resolve_hostname(profile_name, config)
|
|
71
|
+
if profile_name
|
|
72
|
+
profile = Wisco::Profiles.get(profile_name)
|
|
73
|
+
profile&.dig('hostname')
|
|
74
|
+
else
|
|
75
|
+
config.dig('workato_developer_api', 'hostname')
|
|
76
|
+
end
|
|
77
|
+
end
|
|
78
|
+
|
|
79
|
+
def load_connector_info(full_path, target_dir)
|
|
80
|
+
unless File.exist?(full_path)
|
|
81
|
+
return { valid: false, title: nil, error: "Connector file not found: #{full_path}" }
|
|
82
|
+
end
|
|
83
|
+
|
|
84
|
+
begin
|
|
85
|
+
connector = Wisco::Connector.load_connector_from_config(target_dir)
|
|
86
|
+
{ valid: true, title: connector[:title]&.to_s, error: nil }
|
|
87
|
+
rescue StandardError => e
|
|
88
|
+
{ valid: false, title: nil, error: e.message.strip }
|
|
89
|
+
end
|
|
90
|
+
end
|
|
91
|
+
|
|
92
|
+
def check_credentials(connector_path)
|
|
93
|
+
plaintext = File.exist?(File.join(connector_path, 'settings.yaml'))
|
|
94
|
+
encrypted = File.exist?(File.join(connector_path, 'settings.yaml.enc'))
|
|
95
|
+
present = plaintext || encrypted
|
|
96
|
+
|
|
97
|
+
{
|
|
98
|
+
'present' => present,
|
|
99
|
+
'encrypted' => present && !plaintext
|
|
100
|
+
}
|
|
101
|
+
end
|
|
102
|
+
end
|
|
103
|
+
end
|
|
104
|
+
end
|
data/lib/wisco/version.rb
CHANGED
data/lib/wisco.rb
CHANGED
|
@@ -25,6 +25,7 @@ require_relative 'wisco/commands/pull'
|
|
|
25
25
|
require_relative 'wisco/commands/push'
|
|
26
26
|
require_relative 'wisco/commands/schema'
|
|
27
27
|
require_relative 'wisco/commands/profile'
|
|
28
|
+
require_relative 'wisco/commands/status'
|
|
28
29
|
|
|
29
30
|
module Wisco
|
|
30
31
|
class CLI < Thor
|
|
@@ -190,6 +191,16 @@ module Wisco
|
|
|
190
191
|
)
|
|
191
192
|
end
|
|
192
193
|
|
|
194
|
+
desc 'status [PATH]', 'Report wisco project status as JSON (for tooling)'
|
|
195
|
+
long_desc <<~DESC
|
|
196
|
+
Outputs a JSON payload describing the wisco state of the current directory.
|
|
197
|
+
Intended for use by the Wisco VS Code extension.
|
|
198
|
+
Always exits 0; check the "initialized" field to determine project state.
|
|
199
|
+
DESC
|
|
200
|
+
def status(path = nil)
|
|
201
|
+
Wisco::Commands::Status.run(path || Dir.pwd)
|
|
202
|
+
end
|
|
203
|
+
|
|
193
204
|
desc 'profile SUBCOMMAND ...ARGS', 'Manage connection profiles (~/.wisco/profiles.yaml)'
|
|
194
205
|
long_desc <<~DESC
|
|
195
206
|
Subcommands:
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: wisco
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.4.
|
|
4
|
+
version: 0.4.2
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- mbillington
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2026-06-
|
|
11
|
+
date: 2026-06-15 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: activesupport
|
|
@@ -75,6 +75,7 @@ files:
|
|
|
75
75
|
- lib/wisco/commands/pull.rb
|
|
76
76
|
- lib/wisco/commands/push.rb
|
|
77
77
|
- lib/wisco/commands/schema.rb
|
|
78
|
+
- lib/wisco/commands/status.rb
|
|
78
79
|
- lib/wisco/config.rb
|
|
79
80
|
- lib/wisco/connector.rb
|
|
80
81
|
- lib/wisco/exec_script.rb
|