wisco 0.3.7 → 0.3.9

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 942295e665d5ecea09078c736425531bb9846bfe29db26223bf52034ff4221b0
4
- data.tar.gz: c56480bf18d42ac7797dd2b46f9d50146788f1590e673f4056bbe0ce55580347
3
+ metadata.gz: b4b85a40b2a730027328f11d2ad3689c278450ed80f84f4a6348d8e4ed0f011a
4
+ data.tar.gz: 3b2798e4939b06bd8c7171bd1cecfb962f0f570d110b13e00324d91a4b8c7241
5
5
  SHA512:
6
- metadata.gz: 797b1ac153469a31d1edd1781510bac1ac7c05a7f7b2545de34a48d40540a79fcbffd189c851b85d830f9ca63424a5f9006f1a85915bdd9bd6da01f9fe2da392
7
- data.tar.gz: 7133a41ae9da79285993f77ccd32e65ff49c3b3c0d203140c1f3c128bdfa8657c8cd882d435ab180b1bd51811103e3c51f16f8c49ee67150388e11a5062e1448
6
+ metadata.gz: 4a933e918f07db02c27d52169ddcb846d956a1d9ed528a8ac42fcc65c79c72c39648e0ff1da8c0053832f486b0fcce99eaf3e5d349175f507a85d7e9c56592dd
7
+ data.tar.gz: 1d76c173b1a1ef13a95e24e4e6c879e14aa82a6d26ea910bb4fb4caf56bdd81d3f088df2390e7aa1d55ebb92c2de6a4463972be24d8421118707fd45f3c94382
@@ -1,19 +1,22 @@
1
1
  require 'fileutils'
2
+ require 'tempfile'
2
3
  require 'workato/connector/sdk'
3
4
  require 'workato/cli/exec_command'
4
5
  require_relative '../config'
5
6
  require_relative '../connector'
6
7
  require_relative '../path_utils'
7
8
  require_relative '../exec_script'
9
+ require_relative 'fixtures'
8
10
 
9
11
  module Wisco
10
12
  module Commands
11
13
  module Exec
12
14
  module_function
13
15
 
14
- def run(path_arg, target_dir, input: nil, pagination: true, verbose: true, debug: false,
16
+ def run(path_arg, target_dir, input: nil, pagination: true, verbose: false, debug: false,
15
17
  extended: true, closure: nil, config_fields: nil, continue: nil,
16
- extended_input_schema: nil, extended_output_schema: nil)
18
+ extended_input_schema: nil, extended_output_schema: nil,
19
+ summary: true, summary_lines: 20)
17
20
  target_dir = File.expand_path(target_dir)
18
21
  config_path = Wisco.config_path(target_dir)
19
22
 
@@ -50,12 +53,12 @@ module Wisco
50
53
  fixture_dir_output = fixtures_dir.sub(connector_path, '.')
51
54
 
52
55
  unless File.directory?(fixtures_dir)
53
- Wisco::TerminalOutput.emit_error("Error: fixtures directory not found: #{fixture_dir_output}")
54
- Wisco::TerminalOutput.emit_error(" Run '#{Wisco::CLI_NAME} fixtures #{section}.#{key}' first.")
55
- next
56
+ puts " Auto-setup: running fixtures for #{section}.#{key}"
57
+ Wisco::Commands::Fixtures.run("#{section}.#{key}", target_dir, debug: debug)
56
58
  end
57
59
 
58
60
  input_files = resolve_input_files(input, fixtures_dir, debug: debug)
61
+ batch = pairs.length > 1 || input_files.length > 1
59
62
 
60
63
  if input_files.empty?
61
64
  if %w[pick_lists methods].include?(section)
@@ -64,9 +67,14 @@ module Wisco
64
67
  pagination: pagination, verbose: verbose, extended: extended,
65
68
  closure: closure, config_fields: config_fields, continue: continue,
66
69
  extended_input_schema: extended_input_schema,
67
- extended_output_schema: extended_output_schema, debug: debug)
70
+ extended_output_schema: extended_output_schema, debug: debug,
71
+ summary: summary, summary_lines: summary_lines, batch: batch)
68
72
  else
69
73
  Wisco::TerminalOutput.emit_warning(" Warning: No ready input files found in #{fixture_dir_output}")
74
+ input_template = File.join(fixtures_dir, 'execute_input.json')
75
+ if File.exist?(input_template)
76
+ Wisco::TerminalOutput.emit_info(" Fill in #{File.join(fixture_dir_output, 'execute_input.json')} and re-run.")
77
+ end
70
78
  end
71
79
  next
72
80
  end
@@ -78,13 +86,15 @@ module Wisco
78
86
  pagination: pagination, verbose: verbose,
79
87
  extended: extended, closure: closure, config_fields: config_fields,
80
88
  continue: continue, extended_input_schema: extended_input_schema,
81
- extended_output_schema: extended_output_schema, debug: debug)
89
+ extended_output_schema: extended_output_schema, debug: debug,
90
+ summary: summary, summary_lines: summary_lines, batch: batch)
82
91
  else
83
92
  execute_one(section, key, input_file, fixtures_dir,
84
93
  connector_full_path, connection, pagination: pagination, verbose: verbose,
85
94
  extended: extended, closure: closure, config_fields: config_fields,
86
95
  continue: continue, extended_input_schema: extended_input_schema,
87
- extended_output_schema: extended_output_schema, debug: debug)
96
+ extended_output_schema: extended_output_schema, debug: debug,
97
+ summary: summary, summary_lines: summary_lines, batch: batch)
88
98
  end
89
99
  end
90
100
  end
@@ -143,7 +153,7 @@ module Wisco
143
153
  File.dirname(value) == '.' ? File.join(fixtures_dir, value) : value
144
154
  end
145
155
 
146
- def run_test(target_dir, connector_full_path, connection, verbose: true, debug: false)
156
+ def run_test(target_dir, connector_full_path, connection, verbose: false, debug: false)
147
157
  puts "Testing connection"
148
158
  fixtures_dir = File.join(target_dir, 'fixtures', 'connection', 'test')
149
159
  FileUtils.mkdir_p(fixtures_dir)
@@ -181,9 +191,10 @@ module Wisco
181
191
  end
182
192
 
183
193
  def execute_one(section, key, input_file, fixtures_dir, connector_full_path, connection,
184
- pagination: true, verbose: true, debug: false,
194
+ pagination: true, verbose: false, debug: false,
185
195
  extended: true, closure: nil, config_fields: nil, continue: nil,
186
- extended_input_schema: nil, extended_output_schema: nil)
196
+ extended_input_schema: nil, extended_output_schema: nil,
197
+ summary: true, summary_lines: 20, batch: false)
187
198
  stem = input_file ? File.basename(input_file, '.*') : 'execute'
188
199
  output_file = File.join(fixtures_dir, "output_#{stem}.json")
189
200
  error_file = File.join(fixtures_dir, "error_#{stem}.txt")
@@ -201,7 +212,11 @@ module Wisco
201
212
  options[:connection] = connection if connection
202
213
  options[:verbose] = verbose
203
214
  if use_args
204
- options[:args] = input_file if input_file
215
+ if input_file && section == 'methods'
216
+ options[:args] = normalize_method_args(input_file)
217
+ elsif input_file
218
+ options[:args] = input_file
219
+ end
205
220
  else
206
221
  options[:input] = input_file
207
222
  end
@@ -260,12 +275,14 @@ module Wisco
260
275
  end
261
276
 
262
277
  FileUtils.rm_f(error_file)
263
-
264
278
  return unless File.exist?(output_file)
265
279
 
266
- pretty = JSON.pretty_generate(JSON.parse(File.read(output_file)))
280
+ parsed = JSON.parse(File.read(output_file))
281
+ pretty = JSON.pretty_generate(parsed)
267
282
  File.write(output_file, pretty + "\n")
268
283
  puts " Written: #{output_file}"
284
+ display_output_summary(parsed, pretty, section: section, summary: summary,
285
+ summary_lines: summary_lines, batch: batch)
269
286
  end
270
287
 
271
288
  # Handles `execute_*.rb` scripts: evaluates the script to produce dynamic
@@ -275,9 +292,10 @@ module Wisco
275
292
  # execute_input.rb -> execute_input/.
276
293
  def execute_ruby_script(section, key, script_path, fixtures_dir, target_dir,
277
294
  connector_full_path, connection, config,
278
- pagination: true, verbose: true, debug: false,
295
+ pagination: true, verbose: false, debug: false,
279
296
  extended: true, closure: nil, config_fields: nil, continue: nil,
280
- extended_input_schema: nil, extended_output_schema: nil)
297
+ extended_input_schema: nil, extended_output_schema: nil,
298
+ summary: true, summary_lines: 20, batch: false)
281
299
  subdir = File.join(fixtures_dir, File.basename(script_path, '.rb'))
282
300
  FileUtils.mkdir_p(subdir)
283
301
  input_file = File.join(subdir, 'input.json')
@@ -320,7 +338,7 @@ module Wisco
320
338
  options[:connection] = connection if connection
321
339
  options[:verbose] = verbose
322
340
  if use_args
323
- options[:args] = input_file
341
+ options[:args] = section == 'methods' ? normalize_ruby_method_args(input_file) : input_file
324
342
  else
325
343
  options[:input] = input_file
326
344
  end
@@ -372,12 +390,116 @@ module Wisco
372
390
  end
373
391
 
374
392
  FileUtils.rm_f(error_file)
375
-
376
393
  return unless File.exist?(output_file)
377
394
 
378
- pretty = JSON.pretty_generate(JSON.parse(File.read(output_file)))
395
+ parsed = JSON.parse(File.read(output_file))
396
+ pretty = JSON.pretty_generate(parsed)
379
397
  File.write(output_file, pretty + "\n")
380
398
  puts " Written: #{output_file}"
399
+ display_output_summary(parsed, pretty, section: section, summary: summary,
400
+ summary_lines: summary_lines, batch: batch)
401
+ end
402
+
403
+ # ── Output summary ─────────────────────────────────────────────────────
404
+
405
+ def display_output_summary(parsed, pretty, section:, summary:, summary_lines:, batch:)
406
+ return unless summary
407
+
408
+ if section == 'pick_lists'
409
+ if batch
410
+ count = parsed.is_a?(Array) ? parsed.length : '?'
411
+ puts " Items: #{count}"
412
+ else
413
+ display_pick_list_table(parsed)
414
+ end
415
+ return
416
+ end
417
+
418
+ puts pretty if !batch && pretty.lines.length <= (summary_lines || 20)
419
+ puts " #{format_summary(parsed)}"
420
+ end
421
+
422
+ def display_pick_list_table(data)
423
+ unless data.is_a?(Array) && !data.empty?
424
+ puts ' (empty)'
425
+ return
426
+ end
427
+
428
+ rows = data.select { |item| item.is_a?(Array) && item.length >= 2 }
429
+
430
+ if rows.empty?
431
+ puts " Items: #{data.length} (unexpected format)"
432
+ return
433
+ end
434
+
435
+ max_col = 60
436
+ labels = rows.map { |item| truncate_str(item[0].to_s, max_col) }
437
+ values = rows.map { |item| truncate_str(item[1].to_s, max_col) }
438
+
439
+ col1_w = [labels.map(&:length).max, 'Label'.length].max
440
+ col2_w = [values.map(&:length).max, 'Value'.length].max
441
+ num_w = rows.length.to_s.length
442
+
443
+ puts " Items: #{rows.length}"
444
+ puts " | #{'#'.ljust(num_w)} | #{'Label'.ljust(col1_w)} | #{'Value'.ljust(col2_w)} |"
445
+ puts " |#{'-' * (num_w + 2)}|#{'-' * (col1_w + 2)}|#{'-' * (col2_w + 2)}|"
446
+ rows.each_with_index do |_, i|
447
+ puts " | #{(i + 1).to_s.ljust(num_w)} | #{labels[i].ljust(col1_w)} | #{values[i].ljust(col2_w)} |"
448
+ end
449
+ end
450
+
451
+ def format_summary(parsed)
452
+ case parsed
453
+ when Array
454
+ return 'Array: 0 items' if parsed.empty?
455
+ first_str = parsed.first.inspect
456
+ first_str = "#{first_str[0, 97]}…" if first_str.length > 100
457
+ "Array: #{parsed.length} #{parsed.length == 1 ? 'item' : 'items'} — first: #{first_str}"
458
+ when Hash
459
+ return 'Hash: 0 keys' if parsed.empty?
460
+ keys = parsed.keys.first(20)
461
+ suffix = parsed.keys.length > 20 ? " (+#{parsed.keys.length - 20} more)" : ''
462
+ "Hash: #{parsed.keys.length} keys — #{keys.join(', ')}#{suffix}"
463
+ when NilClass
464
+ '(nil)'
465
+ else
466
+ "Value: #{parsed.inspect}"
467
+ end
468
+ end
469
+
470
+ def truncate_str(str, max)
471
+ str.length > max ? "#{str[0, max - 1]}…" : str
472
+ end
473
+
474
+ # ── SDK array-args normalisation ───────────────────────────────────────
475
+ # The Workato SDK's InvokePath#invoke_method applies Array.wrap(args.last).flatten(1)
476
+ # when the last parameter is *args, which incorrectly unwraps array-valued positional
477
+ # arguments one level too many. These helpers compensate by pre-wrapping Array elements
478
+ # so that flatten(1) cancels out and the method receives the correct value.
479
+
480
+ # For JSON execute_input files (positional-args array format):
481
+ # [[{h1},{h2}]] → [[[{h1},{h2}]]] so SDK flatten(1) restores [[{h1},{h2}]] → method([{h1},{h2}])
482
+ def normalize_method_args(input_file)
483
+ parsed = JSON.parse(File.read(input_file))
484
+ return input_file unless parsed.is_a?(Array) && parsed.any? { |a| a.is_a?(Array) }
485
+
486
+ fixed = parsed.map { |a| a.is_a?(Array) ? [a] : a }
487
+ tmp = Tempfile.new(['wisco_args_', '.json'])
488
+ tmp.write(JSON.generate(fixed))
489
+ tmp.close
490
+ tmp.path
491
+ end
492
+
493
+ # For Ruby-script-generated input files (direct argument value):
494
+ # [{h1},{h2}] → [[{h1},{h2}]] so SDK flatten(1) restores [{h1},{h2}] → method([{h1},{h2}])
495
+ def normalize_ruby_method_args(input_file)
496
+ parsed = JSON.parse(File.read(input_file))
497
+ return input_file unless parsed.is_a?(Array)
498
+
499
+ tmp = Tempfile.new(['wisco_args_', '.json'])
500
+ tmp.write(JSON.generate([parsed]))
501
+ tmp.close
502
+ tmp.path
381
503
  end
382
504
  end
383
505
  end
data/lib/wisco/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Wisco
2
- VERSION = '0.3.7'
2
+ VERSION = '0.3.9'
3
3
  end
data/lib/wisco.rb CHANGED
@@ -90,7 +90,7 @@ module Wisco
90
90
  option :input, type: :string, desc: 'Specific input file'
91
91
  option :pagination, type: :boolean, default: true,
92
92
  desc: 'Triggers only: true = .poll (with pagination), false = .poll_page (without)'
93
- option :verbose, type: :boolean, default: true, desc: 'Enable detailed SDK logging'
93
+ option :verbose, type: :boolean, default: false, desc: 'Enable detailed SDK logging'
94
94
  option :extended, type: :boolean, default: true,
95
95
  desc: 'Auto-pass input_fields/output_fields as extended schema (actions/triggers)'
96
96
  option :closure, type: :string, desc: 'Closure JSON file (triggers: simulate subsequent polls)'
@@ -98,7 +98,9 @@ module Wisco
98
98
  option :continue, type: :string, desc: 'Continue JSON file (multistep actions)'
99
99
  option :'extended-input-schema', type: :string, desc: 'Extended input schema JSON (overrides --extended auto-detection)'
100
100
  option :'extended-output-schema', type: :string, desc: 'Extended output schema JSON (overrides --extended auto-detection)'
101
- option :debug, type: :boolean, default: false, desc: 'Print ExecCommand call details'
101
+ option :debug, type: :boolean, default: false, desc: 'Print ExecCommand call details'
102
+ option :summary, type: :boolean, default: true, desc: 'Show output summary after execution (use --no-summary to disable)'
103
+ option :'summary-lines', type: :numeric, default: 20, desc: 'Max output lines to display in full before switching to summary-only'
102
104
  def exec(path_arg, target_dir = nil)
103
105
  Wisco::Commands::Exec.run(
104
106
  path_arg,
@@ -112,7 +114,9 @@ module Wisco
112
114
  continue: options[:continue],
113
115
  extended_input_schema: options[:extended_input_schema],
114
116
  extended_output_schema: options[:extended_output_schema],
115
- debug: options[:debug]
117
+ debug: options[:debug],
118
+ summary: options[:summary],
119
+ summary_lines: options[:'summary-lines']
116
120
  )
117
121
  end
118
122
 
@@ -149,7 +153,7 @@ module Wisco
149
153
  option :title, type: :string, desc: 'Connector title (default: from config or connector code)'
150
154
  option :notes, type: :string, desc: 'Version notes (prompted if not provided)'
151
155
  option :folder, type: :numeric, desc: 'Workato folder ID to push connector into'
152
- option :verbose, type: :boolean, default: true, desc: 'Enable detailed SDK logging'
156
+ option :verbose, type: :boolean, default: false, desc: 'Enable detailed SDK logging'
153
157
  option :debug, type: :boolean, default: false, desc: 'Show push call details'
154
158
  def push(target_dir = nil)
155
159
  Wisco::Commands::Push.run(
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.3.7
4
+ version: 0.3.9
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-07 00:00:00.000000000 Z
11
+ date: 2026-06-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport