wisco 0.2.7 → 0.3.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 684776c3daf8185ae8be30ecc9afbeacdb216190f4f7c9d080ff3d8acc7bf5cb
4
- data.tar.gz: b577efaddd5424680968a77acefaad54217cca76665a936c18f5083d8d4b8289
3
+ metadata.gz: 72efcafcb9b1fdca5d4e8da95e9856e4a2c3920a8783323ff0ee533fafec1795
4
+ data.tar.gz: 7b357fbf5264403871bcc3523d31258fdc3df60fb07ca20c5d77ed41e0049395
5
5
  SHA512:
6
- metadata.gz: 2c13a0b3baad7d55e1c21b02d6be5d9a023e0f119265f57cc604b628711ac9639825505259e362c3f5be3035eec0f3be0523841de48dff6b4184a30a8f3185f7
7
- data.tar.gz: a6ff5b3f26ea143eceb6068e76c28fce4622ffd8393fd63b45fc78404e2c28d0be755f6cdddd22cd0f53237892b712e7c7bee406dc23136e01259135fd96ea5a
6
+ metadata.gz: 5d31c9feb76d2241c72d20756942048e27e0bbd16309acbe50d004f3222da33e9c7fd24df47821fdb901154282003d3931548ab0d9dbb1914f5deb27a7b192cd
7
+ data.tar.gz: 9d5e3f0b012e088720afea813f1dfe29241b57ba6da228554f1e6234b3eb8292e10b4dce3a56bd43960fba58e649cac4ef0d49763e600a3bce9184131847368c
@@ -0,0 +1,3 @@
1
+ .wisco/*
2
+ /master.key
3
+ working/*
@@ -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
@@ -1,3 +1,4 @@
1
+ require 'erb'
1
2
  require 'fileutils'
2
3
  require_relative '../config'
3
4
  require_relative '../connector'
@@ -5,6 +6,15 @@ require_relative '../connector'
5
6
  module Wisco
6
7
  module Commands
7
8
  module Init
9
+ HOSTNAMES = [
10
+ { region: 'US Data Center', hostname: 'www.workato.com' },
11
+ { region: 'EU Data Center', hostname: 'app.eu.workato.com' },
12
+ { region: 'JP Data Center', hostname: 'app.jp.workato.com' },
13
+ { region: 'SG Data Center', hostname: 'app.sg.workato.com' },
14
+ { region: 'AU Data Center', hostname: 'app.au.workato.com' },
15
+ { region: 'IL Data Center', hostname: 'app.il.workato.com' },
16
+ ].freeze
17
+
8
18
  module_function
9
19
 
10
20
  def run(target_dir)
@@ -36,10 +46,41 @@ module Wisco
36
46
  config['connector']['path'] = target_dir
37
47
  config['connector']['file'] = connector_file
38
48
 
49
+ prompt_hostname(config)
50
+
39
51
  Wisco::Config.save_config(config_path, config)
40
52
  puts "Config written to #{config_path}"
41
53
 
42
54
  update_gitignore(target_dir)
55
+ deploy_github_workflow(target_dir, connector_file, config)
56
+ end
57
+
58
+ def prompt_hostname(config)
59
+ api_cfg = config['workato_developer_api'] ||= {}
60
+ current = api_cfg['hostname']
61
+
62
+ if current && !current.strip.empty?
63
+ puts "Current Workato hostname: #{current}"
64
+ print 'Keep this? (y/n): '
65
+ return if $stdin.gets.strip.downcase == 'y'
66
+ end
67
+
68
+ puts 'Select your Workato instance:'
69
+ HOSTNAMES.each_with_index do |entry, i|
70
+ puts " #{i + 1}. #{entry[:hostname]} (#{entry[:region]})"
71
+ end
72
+
73
+ loop do
74
+ print "Enter number (1-#{HOSTNAMES.size}): "
75
+ input = $stdin.gets.strip
76
+ index = input.to_i
77
+ if index >= 1 && index <= HOSTNAMES.size
78
+ api_cfg['hostname'] = HOSTNAMES[index - 1][:hostname]
79
+ puts "Hostname set to: #{api_cfg['hostname']}"
80
+ return
81
+ end
82
+ warn "Invalid selection. Please enter a number between 1 and #{HOSTNAMES.size}."
83
+ end
43
84
  end
44
85
 
45
86
  def update_gitignore(target_dir)
@@ -55,9 +96,34 @@ module Wisco
55
96
  puts "Added '#{entry}' to .gitignore"
56
97
  end
57
98
  else
58
- puts "Note: No .gitignore found — consider adding '#{entry}' manually."
99
+ asset_path = File.join(__dir__, '..', 'assets', '.gitignore')
100
+ FileUtils.cp(asset_path, gitignore_path)
101
+ puts "Created .gitignore from template"
59
102
  end
60
103
  end
104
+
105
+ def deploy_github_workflow(target_dir, connector_file, config)
106
+ output_path = File.join(target_dir, '.github', 'workflows', 'deploy.yml')
107
+
108
+ if File.exist?(output_path)
109
+ print '.github/workflows/deploy.yml already exists. Overwrite? (y/n): '
110
+ unless $stdin.gets.strip.downcase == 'y'
111
+ puts 'Skipped: .github/workflows/deploy.yml'
112
+ return
113
+ end
114
+ end
115
+
116
+ hostname = config.dig('workato_developer_api', 'hostname')
117
+ workato_base_url = "https://#{hostname}"
118
+ connector_name = connector_file
119
+
120
+ template_path = File.join(__dir__, '..', 'assets', '.github', 'workflows', 'deploy.yml.erb')
121
+ rendered = ERB.new(File.read(template_path)).result(binding)
122
+
123
+ FileUtils.mkdir_p(File.dirname(output_path))
124
+ File.write(output_path, rendered)
125
+ puts 'Created .github/workflows/deploy.yml'
126
+ end
61
127
  end
62
128
  end
63
129
  end
data/lib/wisco/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Wisco
2
- VERSION = '0.2.7'
2
+ VERSION = '0.3.1'
3
3
  end
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
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.2.7
4
+ version: 0.3.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-17 00:00:00.000000000 Z
11
+ date: 2026-05-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -64,6 +64,7 @@ extra_rdoc_files: []
64
64
  files:
65
65
  - bin/wisco
66
66
  - lib/wisco.rb
67
+ - lib/wisco/assets/.gitignore
67
68
  - lib/wisco/commands/exec.rb
68
69
  - lib/wisco/commands/fixtures.rb
69
70
  - lib/wisco/commands/init.rb