wisco 0.4.1 → 0.4.3
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/exec.rb +24 -8
- data/lib/wisco/commands/status.rb +104 -0
- data/lib/wisco/version.rb +1 -1
- data/lib/wisco.rb +14 -1
- 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: d67bb33e37dba45fc8fe77679c3ce959d27b8c4e047359798bcd0abfa8d1b7f4
|
|
4
|
+
data.tar.gz: 704d8a2c8935dbae8857be939638a0b9240a21bec61813adda314d5be34d5798
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 18103132c8fdd1af2dd18da30ae44fbd47097b92f4ee1b1adc9f1f515753ce357ca20b18f0a521e35e54237c10255fd7b0597d31d044664b5a27d26d663a2b2d
|
|
7
|
+
data.tar.gz: d6a7db532c55b4eb858ca69c3bedde378948a1ad8c9d1dd2f1590afdea203c8fe788bbb8f3fd514d205746beba63d4689be14ca658406d519ef0976dd4e812d3
|
data/lib/wisco/commands/exec.rb
CHANGED
|
@@ -16,7 +16,7 @@ module Wisco
|
|
|
16
16
|
def run(path_arg, target_dir, input: nil, pagination: true, verbose: false, debug: false,
|
|
17
17
|
extended: true, closure: nil, config_fields: nil, continue: nil,
|
|
18
18
|
extended_input_schema: nil, extended_output_schema: nil,
|
|
19
|
-
summary: true, summary_lines: 20)
|
|
19
|
+
summary: true, summary_lines: 20, auto_refresh: true)
|
|
20
20
|
target_dir = File.expand_path(target_dir)
|
|
21
21
|
config_path = Wisco.config_path(target_dir)
|
|
22
22
|
|
|
@@ -40,7 +40,8 @@ module Wisco
|
|
|
40
40
|
|
|
41
41
|
# ── connection test short-circuit ──────────────────────────────────
|
|
42
42
|
if path_arg == 'test'
|
|
43
|
-
run_test(target_dir, connector_full_path, connection, verbose: verbose, debug: debug
|
|
43
|
+
run_test(target_dir, connector_full_path, connection, verbose: verbose, debug: debug,
|
|
44
|
+
auto_refresh: auto_refresh)
|
|
44
45
|
return
|
|
45
46
|
end
|
|
46
47
|
|
|
@@ -68,7 +69,8 @@ module Wisco
|
|
|
68
69
|
closure: closure, config_fields: config_fields, continue: continue,
|
|
69
70
|
extended_input_schema: extended_input_schema,
|
|
70
71
|
extended_output_schema: extended_output_schema, debug: debug,
|
|
71
|
-
summary: summary, summary_lines: summary_lines, batch: batch
|
|
72
|
+
summary: summary, summary_lines: summary_lines, batch: batch,
|
|
73
|
+
auto_refresh: auto_refresh)
|
|
72
74
|
else
|
|
73
75
|
Wisco::TerminalOutput.emit_warning(" Warning: No ready input files found in #{fixture_dir_output}")
|
|
74
76
|
input_template = File.join(fixtures_dir, 'execute_input.json')
|
|
@@ -87,14 +89,16 @@ module Wisco
|
|
|
87
89
|
extended: extended, closure: closure, config_fields: config_fields,
|
|
88
90
|
continue: continue, extended_input_schema: extended_input_schema,
|
|
89
91
|
extended_output_schema: extended_output_schema, debug: debug,
|
|
90
|
-
summary: summary, summary_lines: summary_lines, batch: batch
|
|
92
|
+
summary: summary, summary_lines: summary_lines, batch: batch,
|
|
93
|
+
auto_refresh: auto_refresh)
|
|
91
94
|
else
|
|
92
95
|
execute_one(section, key, input_file, fixtures_dir,
|
|
93
96
|
connector_full_path, connection, pagination: pagination, verbose: verbose,
|
|
94
97
|
extended: extended, closure: closure, config_fields: config_fields,
|
|
95
98
|
continue: continue, extended_input_schema: extended_input_schema,
|
|
96
99
|
extended_output_schema: extended_output_schema, debug: debug,
|
|
97
|
-
summary: summary, summary_lines: summary_lines, batch: batch
|
|
100
|
+
summary: summary, summary_lines: summary_lines, batch: batch,
|
|
101
|
+
auto_refresh: auto_refresh)
|
|
98
102
|
end
|
|
99
103
|
end
|
|
100
104
|
end
|
|
@@ -153,7 +157,8 @@ module Wisco
|
|
|
153
157
|
File.dirname(value) == '.' ? File.join(fixtures_dir, value) : value
|
|
154
158
|
end
|
|
155
159
|
|
|
156
|
-
def run_test(target_dir, connector_full_path, connection, verbose: false, debug: false
|
|
160
|
+
def run_test(target_dir, connector_full_path, connection, verbose: false, debug: false,
|
|
161
|
+
auto_refresh: true)
|
|
157
162
|
puts "Testing connection"
|
|
158
163
|
fixtures_dir = File.join(target_dir, 'fixtures', 'connection', 'test')
|
|
159
164
|
FileUtils.mkdir_p(fixtures_dir)
|
|
@@ -174,6 +179,7 @@ module Wisco
|
|
|
174
179
|
|
|
175
180
|
begin
|
|
176
181
|
cmd = Workato::CLI::ExecCommand.new(path: 'test', options: options)
|
|
182
|
+
apply_auto_refresh(cmd) if auto_refresh
|
|
177
183
|
cmd.call
|
|
178
184
|
rescue StandardError => e
|
|
179
185
|
File.write(error_file, "#{e.class}: #{e.message}\n\n#{e.backtrace.join("\n")}\n")
|
|
@@ -194,7 +200,7 @@ module Wisco
|
|
|
194
200
|
pagination: true, verbose: false, debug: false,
|
|
195
201
|
extended: true, closure: nil, config_fields: nil, continue: nil,
|
|
196
202
|
extended_input_schema: nil, extended_output_schema: nil,
|
|
197
|
-
summary: true, summary_lines: 20, batch: false)
|
|
203
|
+
summary: true, summary_lines: 20, batch: false, auto_refresh: true)
|
|
198
204
|
stem = input_file ? File.basename(input_file, '.*') : 'execute'
|
|
199
205
|
output_file = File.join(fixtures_dir, "output_#{stem}.json")
|
|
200
206
|
error_file = File.join(fixtures_dir, "error_#{stem}.txt")
|
|
@@ -265,6 +271,7 @@ module Wisco
|
|
|
265
271
|
|
|
266
272
|
begin
|
|
267
273
|
cmd = Workato::CLI::ExecCommand.new(path: exec_path, options: options)
|
|
274
|
+
apply_auto_refresh(cmd) if auto_refresh
|
|
268
275
|
cmd.call
|
|
269
276
|
rescue StandardError => e
|
|
270
277
|
FileUtils.rm_f(output_file)
|
|
@@ -295,7 +302,7 @@ module Wisco
|
|
|
295
302
|
pagination: true, verbose: false, debug: false,
|
|
296
303
|
extended: true, closure: nil, config_fields: nil, continue: nil,
|
|
297
304
|
extended_input_schema: nil, extended_output_schema: nil,
|
|
298
|
-
summary: true, summary_lines: 20, batch: false)
|
|
305
|
+
summary: true, summary_lines: 20, batch: false, auto_refresh: true)
|
|
299
306
|
subdir = File.join(fixtures_dir, File.basename(script_path, '.rb'))
|
|
300
307
|
FileUtils.mkdir_p(subdir)
|
|
301
308
|
input_file = File.join(subdir, 'input.json')
|
|
@@ -379,6 +386,7 @@ module Wisco
|
|
|
379
386
|
# Step 3: invoke ExecCommand against the generated input
|
|
380
387
|
begin
|
|
381
388
|
cmd = Workato::CLI::ExecCommand.new(path: exec_path, options: options)
|
|
389
|
+
apply_auto_refresh(cmd) if auto_refresh
|
|
382
390
|
cmd.call
|
|
383
391
|
rescue StandardError => e
|
|
384
392
|
FileUtils.rm_f(input_file)
|
|
@@ -471,6 +479,14 @@ module Wisco
|
|
|
471
479
|
str.length > max ? "#{str[0, max - 1]}…" : str
|
|
472
480
|
end
|
|
473
481
|
|
|
482
|
+
# Overrides ask() on the ExecCommand singleton so the SDK's token-refresh
|
|
483
|
+
# prompt ("Updated settings file with new connection attributes? (Yes or No)")
|
|
484
|
+
# is answered "y" automatically. The refresh lambda captures self (the
|
|
485
|
+
# ExecCommand instance), so the singleton method wins over Thor::Shell::Basic.
|
|
486
|
+
def apply_auto_refresh(cmd)
|
|
487
|
+
cmd.define_singleton_method(:ask) { |*| 'y' }
|
|
488
|
+
end
|
|
489
|
+
|
|
474
490
|
# ── SDK array-args normalisation ───────────────────────────────────────
|
|
475
491
|
# The Workato SDK's InvokePath#invoke_method applies Array.wrap(args.last).flatten(1)
|
|
476
492
|
# when the last parameter is *args, which incorrectly unwraps array-valued positional
|
|
@@ -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
|
|
@@ -102,6 +103,7 @@ module Wisco
|
|
|
102
103
|
option :debug, type: :boolean, default: false, desc: 'Print ExecCommand call details'
|
|
103
104
|
option :summary, type: :boolean, default: true, desc: 'Show output summary after execution (use --no-summary to disable)'
|
|
104
105
|
option :'summary-lines', type: :numeric, default: 20, desc: 'Max output lines to display in full before switching to summary-only'
|
|
106
|
+
option :'auto-refresh', type: :boolean, default: true, desc: 'Automatically confirm token refresh prompts (use --no-auto-refresh to disable)'
|
|
105
107
|
def exec(path_arg, target_dir = nil)
|
|
106
108
|
Wisco::Commands::Exec.run(
|
|
107
109
|
path_arg,
|
|
@@ -117,7 +119,8 @@ module Wisco
|
|
|
117
119
|
extended_output_schema: options[:extended_output_schema],
|
|
118
120
|
debug: options[:debug],
|
|
119
121
|
summary: options[:summary],
|
|
120
|
-
summary_lines: options[:'summary-lines']
|
|
122
|
+
summary_lines: options[:'summary-lines'],
|
|
123
|
+
auto_refresh: options[:'auto-refresh']
|
|
121
124
|
)
|
|
122
125
|
end
|
|
123
126
|
|
|
@@ -190,6 +193,16 @@ module Wisco
|
|
|
190
193
|
)
|
|
191
194
|
end
|
|
192
195
|
|
|
196
|
+
desc 'status [PATH]', 'Report wisco project status as JSON (for tooling)'
|
|
197
|
+
long_desc <<~DESC
|
|
198
|
+
Outputs a JSON payload describing the wisco state of the current directory.
|
|
199
|
+
Intended for use by the Wisco VS Code extension.
|
|
200
|
+
Always exits 0; check the "initialized" field to determine project state.
|
|
201
|
+
DESC
|
|
202
|
+
def status(path = nil)
|
|
203
|
+
Wisco::Commands::Status.run(path || Dir.pwd)
|
|
204
|
+
end
|
|
205
|
+
|
|
193
206
|
desc 'profile SUBCOMMAND ...ARGS', 'Manage connection profiles (~/.wisco/profiles.yaml)'
|
|
194
207
|
long_desc <<~DESC
|
|
195
208
|
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.3
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- mbillington
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2026-
|
|
11
|
+
date: 2026-07-26 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
|