wisco 0.1.8 → 0.2.1
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 +20 -7
- data/lib/wisco/commands/fixtures.rb +61 -19
- data/lib/wisco/path_utils.rb +10 -11
- data/lib/wisco/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: bd806fc6e7654c8df8d7fb20d08bd64f33cde8cff24770362a1752d2af96a23b
|
|
4
|
+
data.tar.gz: 9b834ed0d9f1d6242be4b61bdefd15b46184b4d815d892c258e69ba341a5591d
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 453649dd03027111cbc4fc0f0add8256c9369cfb971e941286df3021338d1bcaf1df6f09970d91c7e66604ac182be7933b31198a5cd3ff155160c2a6cff70671
|
|
7
|
+
data.tar.gz: d6fe40803f89746010bc2cbb450abff2fa6713db9c120c6b3e1d5fab29120724fda5b090a35d9c04c7d43274202fb6253dde0c2d3f116de58f3a0d6e7022e96f
|
data/lib/wisco/commands/exec.rb
CHANGED
|
@@ -49,7 +49,12 @@ module Wisco
|
|
|
49
49
|
input_files = resolve_input_files(input, fixtures_dir)
|
|
50
50
|
|
|
51
51
|
if input_files.empty?
|
|
52
|
-
|
|
52
|
+
if section == 'pick_lists'
|
|
53
|
+
# Static/dynamic pick list — no args needed; execute once with no input file
|
|
54
|
+
execute_one(section, key, nil, fixtures_dir, connector_full_path, connection, debug: debug)
|
|
55
|
+
else
|
|
56
|
+
warn "\tWarning: No ready input files found in #{fixture_dir_output}"
|
|
57
|
+
end
|
|
53
58
|
next
|
|
54
59
|
end
|
|
55
60
|
|
|
@@ -88,27 +93,35 @@ module Wisco
|
|
|
88
93
|
end
|
|
89
94
|
|
|
90
95
|
def execute_one(section, key, input_file, fixtures_dir, connector_full_path, connection, debug: false)
|
|
91
|
-
stem = File.basename(input_file, '.*')
|
|
96
|
+
stem = input_file ? File.basename(input_file, '.*') : 'execute'
|
|
92
97
|
output_file = File.join(fixtures_dir, "output_#{stem}.json")
|
|
93
98
|
error_file = File.join(fixtures_dir, "error_#{stem}.txt")
|
|
94
99
|
|
|
95
|
-
|
|
100
|
+
pick_list = (section == 'pick_lists')
|
|
101
|
+
exec_path = pick_list ? "#{section}.#{key}" : "#{section}.#{key}.execute"
|
|
102
|
+
|
|
103
|
+
options = { connector: connector_full_path, output: output_file }
|
|
96
104
|
options[:connection] = connection if connection
|
|
105
|
+
if pick_list
|
|
106
|
+
options[:args] = input_file if input_file
|
|
107
|
+
else
|
|
108
|
+
options[:input] = input_file
|
|
109
|
+
end
|
|
97
110
|
|
|
98
111
|
if debug
|
|
99
|
-
warn "[exec] path: #{
|
|
112
|
+
warn "[exec] path: #{exec_path}"
|
|
100
113
|
warn "[exec] connector: #{connector_full_path}"
|
|
101
114
|
warn "[exec] connection: #{connection.inspect}"
|
|
102
|
-
warn "[exec] input: #{input_file}"
|
|
115
|
+
warn "[exec] #{pick_list ? 'args' : 'input'}: #{input_file.inspect}"
|
|
103
116
|
warn "[exec] output: #{output_file}"
|
|
104
117
|
end
|
|
105
118
|
|
|
106
119
|
begin
|
|
107
|
-
cmd = Workato::CLI::ExecCommand.new(path:
|
|
120
|
+
cmd = Workato::CLI::ExecCommand.new(path: exec_path, options: options)
|
|
108
121
|
cmd.call
|
|
109
122
|
rescue StandardError => e
|
|
110
123
|
File.write(error_file, "#{e.class}: #{e.message}\n\n#{e.backtrace.join("\n")}\n")
|
|
111
|
-
warn "Error executing #{section}.#{key} with #{File.basename(input_file)}: #{e.message}"
|
|
124
|
+
warn "Error executing #{section}.#{key} with #{input_file ? File.basename(input_file) : 'no input'}: #{e.message}"
|
|
112
125
|
warn " Details written to: #{error_file}"
|
|
113
126
|
return
|
|
114
127
|
end
|
|
@@ -42,25 +42,29 @@ module Wisco
|
|
|
42
42
|
fixtures_dir = File.join(target_dir, 'fixtures', section, key)
|
|
43
43
|
FileUtils.mkdir_p(fixtures_dir)
|
|
44
44
|
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
45
|
+
if section == 'pick_lists'
|
|
46
|
+
process_pick_list(key, connector, fixtures_dir, overwrite: overwrite)
|
|
47
|
+
else
|
|
48
|
+
input_fields_file = File.join(fixtures_dir, 'input_fields.json')
|
|
49
|
+
call_exec(
|
|
50
|
+
path: "#{section}.#{key}.input_fields",
|
|
51
|
+
connector: connector_full_path,
|
|
52
|
+
connection: connection,
|
|
53
|
+
output: input_fields_file,
|
|
54
|
+
debug: debug
|
|
55
|
+
)
|
|
56
|
+
|
|
57
|
+
generate_execute_input(input_fields_file, fixtures_dir, overwrite: overwrite, debug: debug)
|
|
58
|
+
|
|
59
|
+
output_fields_file = File.join(fixtures_dir, 'output_fields.json')
|
|
60
|
+
call_exec(
|
|
61
|
+
path: "#{section}.#{key}.output_fields",
|
|
62
|
+
connector: connector_full_path,
|
|
63
|
+
connection: connection,
|
|
64
|
+
output: output_fields_file,
|
|
65
|
+
debug: debug
|
|
66
|
+
)
|
|
67
|
+
end
|
|
64
68
|
end
|
|
65
69
|
end
|
|
66
70
|
|
|
@@ -120,6 +124,44 @@ module Wisco
|
|
|
120
124
|
end
|
|
121
125
|
end
|
|
122
126
|
|
|
127
|
+
def process_pick_list(key, connector, fixtures_dir, overwrite: false)
|
|
128
|
+
pick_list_fn = connector[:pick_lists]&.[](key.to_sym)
|
|
129
|
+
|
|
130
|
+
unless pick_list_fn.respond_to?(:parameters)
|
|
131
|
+
warn " Warning: pick_list '#{key}' is not callable — skipping."
|
|
132
|
+
return
|
|
133
|
+
end
|
|
134
|
+
|
|
135
|
+
# Drop the first parameter (connection); remaining params become input fields
|
|
136
|
+
input_params = pick_list_fn.parameters.drop(1)
|
|
137
|
+
|
|
138
|
+
if input_params.empty?
|
|
139
|
+
puts " No input required: #{fixtures_dir}"
|
|
140
|
+
return
|
|
141
|
+
end
|
|
142
|
+
|
|
143
|
+
output_file = File.join(fixtures_dir, 'execute_input.json')
|
|
144
|
+
|
|
145
|
+
if File.exist?(output_file)
|
|
146
|
+
first_line = begin
|
|
147
|
+
File.open(output_file, &:readline).chomp
|
|
148
|
+
rescue StandardError
|
|
149
|
+
''
|
|
150
|
+
end
|
|
151
|
+
unless first_line == SENTINEL || overwrite
|
|
152
|
+
puts " Skipped (user-edited): #{output_file}"
|
|
153
|
+
return
|
|
154
|
+
end
|
|
155
|
+
end
|
|
156
|
+
|
|
157
|
+
template = input_params.each_with_object({}) do |(_, name), hash|
|
|
158
|
+
hash[name.to_s] = '<string_value_required>'
|
|
159
|
+
end
|
|
160
|
+
content = "#{SENTINEL}\n#{JSON.pretty_generate(template)}\n"
|
|
161
|
+
File.write(output_file, content)
|
|
162
|
+
puts " Written: #{output_file}"
|
|
163
|
+
end
|
|
164
|
+
|
|
123
165
|
def call_exec(path:, connector:, connection:, output:, debug: false)
|
|
124
166
|
options = { connector: connector, output: output }
|
|
125
167
|
options[:connection] = connection if connection
|
data/lib/wisco/path_utils.rb
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
module Wisco
|
|
2
2
|
module PathUtils
|
|
3
|
-
VALID_SECTIONS = %w[actions triggers].freeze
|
|
3
|
+
VALID_SECTIONS = %w[actions triggers pick_lists].freeze
|
|
4
4
|
|
|
5
5
|
module_function
|
|
6
6
|
|
|
@@ -36,19 +36,18 @@ module Wisco
|
|
|
36
36
|
items.keys.map { |k| [section, k.to_s] }
|
|
37
37
|
|
|
38
38
|
else
|
|
39
|
-
key
|
|
40
|
-
|
|
41
|
-
in_triggers = connector[:triggers]&.key?(key.to_sym) || false
|
|
39
|
+
key = path_arg
|
|
40
|
+
found_in = VALID_SECTIONS.select { |s| connector[s.to_sym]&.key?(key.to_sym) }
|
|
42
41
|
|
|
43
|
-
case
|
|
44
|
-
when
|
|
45
|
-
|
|
46
|
-
when
|
|
47
|
-
warn "Error: '#{key}'
|
|
48
|
-
warn " Qualify with section, e.g. 'actions.#{key}'."
|
|
42
|
+
case found_in.size
|
|
43
|
+
when 1
|
|
44
|
+
[[found_in.first, key]]
|
|
45
|
+
when 0
|
|
46
|
+
warn "Error: '#{key}' not found in #{VALID_SECTIONS.join(', ')}."
|
|
49
47
|
exit 1
|
|
50
48
|
else
|
|
51
|
-
warn "Error: '#{key}'
|
|
49
|
+
warn "Error: '#{key}' exists in multiple sections: #{found_in.join(', ')}."
|
|
50
|
+
warn " Qualify with section, e.g. '#{found_in.first}.#{key}'."
|
|
52
51
|
exit 1
|
|
53
52
|
end
|
|
54
53
|
end
|
data/lib/wisco/version.rb
CHANGED
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.1
|
|
4
|
+
version: 0.2.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- mbillington
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2026-05-
|
|
11
|
+
date: 2026-05-17 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: activesupport
|