wisco 0.2.7 → 0.3.0
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 +48 -4
- data/lib/wisco/version.rb +1 -1
- data/lib/wisco.rb +2 -0
- 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: e7d2ff5de3204724be5413d65d04854a3abbf36b9d04d0fe2331512ba74f6e68
|
|
4
|
+
data.tar.gz: 81791bed785af9f096dae7de781a3620a14a96f4a28dc3514d24b4bdabc80e1c
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: b4e9a41746dc88a8ef8d08595dd56c01bae20fcbabaefd6bd08758ab4d2fa8611745a3cce8c8a929a4a433fa76458a821ecf074f96720e30b824d98a9005c51c
|
|
7
|
+
data.tar.gz: d5f6560ffec23678d08131a232808f957b4aec436bd17ff87822fd45fcf6fb1bd06d9a438ba76a1904cf6eb6babb7344c1ca7d206f3c042843144f7c917e355b
|
data/lib/wisco/commands/exec.rb
CHANGED
|
@@ -10,7 +10,7 @@ module Wisco
|
|
|
10
10
|
module Exec
|
|
11
11
|
module_function
|
|
12
12
|
|
|
13
|
-
def run(path_arg, target_dir, input: nil, pagination: true, debug: false)
|
|
13
|
+
def run(path_arg, target_dir, input: nil, pagination: true, verbose: true, debug: false)
|
|
14
14
|
target_dir = File.expand_path(target_dir)
|
|
15
15
|
config_path = Wisco.config_path(target_dir)
|
|
16
16
|
|
|
@@ -32,6 +32,12 @@ module Wisco
|
|
|
32
32
|
connector_full_path = File.join(connector_path, connector_file)
|
|
33
33
|
connection = config['connection']
|
|
34
34
|
|
|
35
|
+
# ── connection test short-circuit ──────────────────────────────────
|
|
36
|
+
if path_arg == 'test'
|
|
37
|
+
run_test(target_dir, connector_full_path, connection, verbose: verbose, debug: debug)
|
|
38
|
+
return
|
|
39
|
+
end
|
|
40
|
+
|
|
35
41
|
connector = Wisco::Connector.load_connector_from_config(target_dir)
|
|
36
42
|
pairs = Wisco::PathUtils.parse_path(path_arg, connector)
|
|
37
43
|
|
|
@@ -52,7 +58,7 @@ module Wisco
|
|
|
52
58
|
if %w[pick_lists methods].include?(section)
|
|
53
59
|
# No-param pick list or method — execute once with no input file
|
|
54
60
|
execute_one(section, key, nil, fixtures_dir, connector_full_path, connection,
|
|
55
|
-
pagination: pagination, debug: debug)
|
|
61
|
+
pagination: pagination, verbose: verbose, debug: debug)
|
|
56
62
|
else
|
|
57
63
|
warn "\tWarning: No ready input files found in #{fixture_dir_output}"
|
|
58
64
|
end
|
|
@@ -61,7 +67,7 @@ module Wisco
|
|
|
61
67
|
|
|
62
68
|
input_files.each do |input_file|
|
|
63
69
|
execute_one(section, key, input_file, fixtures_dir,
|
|
64
|
-
connector_full_path, connection, pagination: pagination, debug: debug)
|
|
70
|
+
connector_full_path, connection, pagination: pagination, verbose: verbose, debug: debug)
|
|
65
71
|
end
|
|
66
72
|
end
|
|
67
73
|
end
|
|
@@ -93,8 +99,45 @@ module Wisco
|
|
|
93
99
|
first_line == Wisco::Commands::Fixtures::SENTINEL
|
|
94
100
|
end
|
|
95
101
|
|
|
102
|
+
def run_test(target_dir, connector_full_path, connection, verbose: true, debug: false)
|
|
103
|
+
puts "Testing connection"
|
|
104
|
+
fixtures_dir = File.join(target_dir, 'fixtures', 'connection', 'test')
|
|
105
|
+
FileUtils.mkdir_p(fixtures_dir)
|
|
106
|
+
|
|
107
|
+
output_file = File.join(fixtures_dir, 'output_test.json')
|
|
108
|
+
error_file = File.join(fixtures_dir, 'error_test.txt')
|
|
109
|
+
|
|
110
|
+
options = { connector: connector_full_path, output: output_file }
|
|
111
|
+
options[:connection] = connection if connection
|
|
112
|
+
options[:verbose] = verbose
|
|
113
|
+
|
|
114
|
+
if debug
|
|
115
|
+
warn "[exec] path: test"
|
|
116
|
+
warn "[exec] connector: #{connector_full_path}"
|
|
117
|
+
warn "[exec] connection: #{connection.inspect}"
|
|
118
|
+
warn "[exec] output: #{output_file}"
|
|
119
|
+
end
|
|
120
|
+
|
|
121
|
+
begin
|
|
122
|
+
cmd = Workato::CLI::ExecCommand.new(path: 'test', options: options)
|
|
123
|
+
cmd.call
|
|
124
|
+
rescue StandardError => e
|
|
125
|
+
File.write(error_file, "#{e.class}: #{e.message}\n\n#{e.backtrace.join("\n")}\n")
|
|
126
|
+
warn "Error testing connection: #{e.message}"
|
|
127
|
+
warn " Details written to: #{error_file}"
|
|
128
|
+
return
|
|
129
|
+
end
|
|
130
|
+
|
|
131
|
+
FileUtils.rm_f(error_file)
|
|
132
|
+
return unless File.exist?(output_file)
|
|
133
|
+
|
|
134
|
+
pretty = JSON.pretty_generate(JSON.parse(File.read(output_file)))
|
|
135
|
+
File.write(output_file, pretty + "\n")
|
|
136
|
+
puts " Written: #{output_file}"
|
|
137
|
+
end
|
|
138
|
+
|
|
96
139
|
def execute_one(section, key, input_file, fixtures_dir, connector_full_path, connection,
|
|
97
|
-
pagination: true, debug: false)
|
|
140
|
+
pagination: true, verbose: true, debug: false)
|
|
98
141
|
stem = input_file ? File.basename(input_file, '.*') : 'execute'
|
|
99
142
|
output_file = File.join(fixtures_dir, "output_#{stem}.json")
|
|
100
143
|
error_file = File.join(fixtures_dir, "error_#{stem}.txt")
|
|
@@ -110,6 +153,7 @@ module Wisco
|
|
|
110
153
|
|
|
111
154
|
options = { connector: connector_full_path, output: output_file }
|
|
112
155
|
options[:connection] = connection if connection
|
|
156
|
+
options[:verbose] = verbose
|
|
113
157
|
if use_args
|
|
114
158
|
options[:args] = input_file if input_file
|
|
115
159
|
else
|
data/lib/wisco/version.rb
CHANGED
data/lib/wisco.rb
CHANGED
|
@@ -86,6 +86,7 @@ module Wisco
|
|
|
86
86
|
option :input, type: :string, desc: 'Specific input file'
|
|
87
87
|
option :pagination, type: :boolean, default: true,
|
|
88
88
|
desc: 'Triggers only: true = .poll (with pagination), false = .poll_page (without)'
|
|
89
|
+
option :verbose, type: :boolean, default: true, desc: 'Enable detailed SDK logging'
|
|
89
90
|
option :debug, type: :boolean, default: false, desc: 'Print ExecCommand call details'
|
|
90
91
|
def exec(path_arg, target_dir = nil)
|
|
91
92
|
Wisco::Commands::Exec.run(
|
|
@@ -93,6 +94,7 @@ module Wisco
|
|
|
93
94
|
target_dir || Dir.pwd,
|
|
94
95
|
input: options[:input],
|
|
95
96
|
pagination: options[:pagination],
|
|
97
|
+
verbose: options[:verbose],
|
|
96
98
|
debug: options[:debug]
|
|
97
99
|
)
|
|
98
100
|
end
|