wisco 0.3.8 → 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: a6489b0aaac5c9626f27141afebc7b4dda9b087c2cf94fee0744b9b603de4953
4
- data.tar.gz: 298e1469cd688e9d824fd091d32ea84526934637b96e92a4ea19243dfb715e49
3
+ metadata.gz: b4b85a40b2a730027328f11d2ad3689c278450ed80f84f4a6348d8e4ed0f011a
4
+ data.tar.gz: 3b2798e4939b06bd8c7171bd1cecfb962f0f570d110b13e00324d91a4b8c7241
5
5
  SHA512:
6
- metadata.gz: 4b711094e3bf5990c6a591a9a75356660c86d813a76df331f101c8cf48ecbf3d98edcf9f4ede28c4c3cff1448f19991ef89383a1fecb5c78c8a21a3b1a1ce88c
7
- data.tar.gz: 1581e25abeb992cb6eee659407561df32a47ecbe2cacacf9bb5ea55650eabe27015114c97cf6d5f5bcbba4acbf5593416c1bb5b37ca612f682b7095ba3708ccb
6
+ metadata.gz: 4a933e918f07db02c27d52169ddcb846d956a1d9ed528a8ac42fcc65c79c72c39648e0ff1da8c0053832f486b0fcce99eaf3e5d349175f507a85d7e9c56592dd
7
+ data.tar.gz: 1d76c173b1a1ef13a95e24e4e6c879e14aa82a6d26ea910bb4fb4caf56bdd81d3f088df2390e7aa1d55ebb92c2de6a4463972be24d8421118707fd45f3c94382
@@ -6,6 +6,7 @@ require_relative '../config'
6
6
  require_relative '../connector'
7
7
  require_relative '../path_utils'
8
8
  require_relative '../exec_script'
9
+ require_relative 'fixtures'
9
10
 
10
11
  module Wisco
11
12
  module Commands
@@ -14,7 +15,8 @@ module Wisco
14
15
 
15
16
  def run(path_arg, target_dir, input: nil, pagination: true, verbose: false, debug: false,
16
17
  extended: true, closure: nil, config_fields: nil, continue: nil,
17
- extended_input_schema: nil, extended_output_schema: nil)
18
+ extended_input_schema: nil, extended_output_schema: nil,
19
+ summary: true, summary_lines: 20)
18
20
  target_dir = File.expand_path(target_dir)
19
21
  config_path = Wisco.config_path(target_dir)
20
22
 
@@ -51,12 +53,12 @@ module Wisco
51
53
  fixture_dir_output = fixtures_dir.sub(connector_path, '.')
52
54
 
53
55
  unless File.directory?(fixtures_dir)
54
- Wisco::TerminalOutput.emit_error("Error: fixtures directory not found: #{fixture_dir_output}")
55
- Wisco::TerminalOutput.emit_error(" Run '#{Wisco::CLI_NAME} fixtures #{section}.#{key}' first.")
56
- next
56
+ puts " Auto-setup: running fixtures for #{section}.#{key}"
57
+ Wisco::Commands::Fixtures.run("#{section}.#{key}", target_dir, debug: debug)
57
58
  end
58
59
 
59
60
  input_files = resolve_input_files(input, fixtures_dir, debug: debug)
61
+ batch = pairs.length > 1 || input_files.length > 1
60
62
 
61
63
  if input_files.empty?
62
64
  if %w[pick_lists methods].include?(section)
@@ -65,9 +67,14 @@ module Wisco
65
67
  pagination: pagination, verbose: verbose, extended: extended,
66
68
  closure: closure, config_fields: config_fields, continue: continue,
67
69
  extended_input_schema: extended_input_schema,
68
- 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)
69
72
  else
70
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
71
78
  end
72
79
  next
73
80
  end
@@ -79,13 +86,15 @@ module Wisco
79
86
  pagination: pagination, verbose: verbose,
80
87
  extended: extended, closure: closure, config_fields: config_fields,
81
88
  continue: continue, extended_input_schema: extended_input_schema,
82
- 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)
83
91
  else
84
92
  execute_one(section, key, input_file, fixtures_dir,
85
93
  connector_full_path, connection, pagination: pagination, verbose: verbose,
86
94
  extended: extended, closure: closure, config_fields: config_fields,
87
95
  continue: continue, extended_input_schema: extended_input_schema,
88
- 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)
89
98
  end
90
99
  end
91
100
  end
@@ -184,7 +193,8 @@ module Wisco
184
193
  def execute_one(section, key, input_file, fixtures_dir, connector_full_path, connection,
185
194
  pagination: true, verbose: false, debug: false,
186
195
  extended: true, closure: nil, config_fields: nil, continue: nil,
187
- 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)
188
198
  stem = input_file ? File.basename(input_file, '.*') : 'execute'
189
199
  output_file = File.join(fixtures_dir, "output_#{stem}.json")
190
200
  error_file = File.join(fixtures_dir, "error_#{stem}.txt")
@@ -265,12 +275,14 @@ module Wisco
265
275
  end
266
276
 
267
277
  FileUtils.rm_f(error_file)
268
-
269
278
  return unless File.exist?(output_file)
270
279
 
271
- pretty = JSON.pretty_generate(JSON.parse(File.read(output_file)))
280
+ parsed = JSON.parse(File.read(output_file))
281
+ pretty = JSON.pretty_generate(parsed)
272
282
  File.write(output_file, pretty + "\n")
273
283
  puts " Written: #{output_file}"
284
+ display_output_summary(parsed, pretty, section: section, summary: summary,
285
+ summary_lines: summary_lines, batch: batch)
274
286
  end
275
287
 
276
288
  # Handles `execute_*.rb` scripts: evaluates the script to produce dynamic
@@ -282,7 +294,8 @@ module Wisco
282
294
  connector_full_path, connection, config,
283
295
  pagination: true, verbose: false, debug: false,
284
296
  extended: true, closure: nil, config_fields: nil, continue: nil,
285
- 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)
286
299
  subdir = File.join(fixtures_dir, File.basename(script_path, '.rb'))
287
300
  FileUtils.mkdir_p(subdir)
288
301
  input_file = File.join(subdir, 'input.json')
@@ -377,14 +390,88 @@ module Wisco
377
390
  end
378
391
 
379
392
  FileUtils.rm_f(error_file)
380
-
381
393
  return unless File.exist?(output_file)
382
394
 
383
- pretty = JSON.pretty_generate(JSON.parse(File.read(output_file)))
395
+ parsed = JSON.parse(File.read(output_file))
396
+ pretty = JSON.pretty_generate(parsed)
384
397
  File.write(output_file, pretty + "\n")
385
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
386
472
  end
387
473
 
474
+ # ── SDK array-args normalisation ───────────────────────────────────────
388
475
  # The Workato SDK's InvokePath#invoke_method applies Array.wrap(args.last).flatten(1)
389
476
  # when the last parameter is *args, which incorrectly unwraps array-valued positional
390
477
  # arguments one level too many. These helpers compensate by pre-wrapping Array elements
data/lib/wisco/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Wisco
2
- VERSION = '0.3.8'
2
+ VERSION = '0.3.9'
3
3
  end
data/lib/wisco.rb CHANGED
@@ -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
 
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.8
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-13 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