wisco 0.4.1 → 0.4.2

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: 6d835a3d768c20b2555e1b17ecd61bf1d3363db39b74aa6e2a3cd56c507ec136
4
- data.tar.gz: 903542f44f76502b94f247337b4c77f6bb34d06c6d84f1f94ef0efab05a97917
3
+ metadata.gz: 4893611d0b98c82232776fa4705b9f92f83d76f4df549a641e2951068d7a5ee3
4
+ data.tar.gz: af96365443af8fc4b407ad7de5fae4c279e630665d405f6d8945c7f3a992fb2d
5
5
  SHA512:
6
- metadata.gz: 5cec2439df4a49df18a314a40535acd2d460e1116b80a87e550a356ad02b4a834d94c2c5a921ed342f4994411c5897bd7814d635a7ae0483c17957bc2d55ae31
7
- data.tar.gz: 19ad6f559d813656907576b53d341f2222bce65e234f0ac42bd6285d8f59f8c55e8f0595a598ca02ec0e2608c8be5c4afe5af278027f3f75af94a62174cc540d
6
+ metadata.gz: 1edd85873a8c84fda1bd7829e47a7da67a917b50279204956ea29309f31174fb90825b06e298489d69dc88f11f2d9f68ec1abdb45ed96fb29200ef7e54304fab
7
+ data.tar.gz: 9876280ad0dbd7cb2cfeea241155f2538df6b65f37ecdd8ab4d4b6406de9c841bce52c4b23b2043b27cf047aef3919bc94da185139789013c246f0a9ecdbb2f5
@@ -0,0 +1,104 @@
1
+ require 'json'
2
+ require_relative '../config'
3
+ require_relative '../connector'
4
+ require_relative '../profile'
5
+ require_relative '../version'
6
+
7
+ module Wisco
8
+ module Commands
9
+ module Status
10
+ module_function
11
+
12
+ def run(target_dir)
13
+ target_dir = File.expand_path(target_dir)
14
+ config_path = Wisco.config_path(target_dir)
15
+
16
+ unless File.exist?(config_path)
17
+ puts JSON.pretty_generate(uninitialised_payload)
18
+ return
19
+ end
20
+
21
+ config = Wisco::Config.load_config(config_path)
22
+ connector_path = config.dig('connector', 'path')
23
+ connector_file = config.dig('connector', 'file')
24
+
25
+ if connector_path.nil? || connector_file.nil?
26
+ puts JSON.pretty_generate(uninitialised_payload)
27
+ return
28
+ end
29
+
30
+ profile_name = config.dig('workato_developer_api', 'profile').to_s
31
+ profile_name = nil if profile_name.empty?
32
+ hostname = resolve_hostname(profile_name, config)
33
+
34
+ full_connector_path = File.join(connector_path, connector_file)
35
+ connector_info = load_connector_info(full_connector_path, target_dir)
36
+ credentials = check_credentials(connector_path)
37
+
38
+ payload = {
39
+ 'wisco_version' => Wisco::VERSION,
40
+ 'initialized' => true,
41
+ 'config_path' => config_path,
42
+ 'profile' => { 'name' => profile_name },
43
+ 'hostname' => hostname,
44
+ 'connection' => config['connection'],
45
+ 'connector' => {
46
+ 'path' => full_connector_path,
47
+ 'valid' => connector_info[:valid],
48
+ 'title' => connector_info[:title],
49
+ 'error' => connector_info[:error]
50
+ },
51
+ 'credentials' => credentials
52
+ }
53
+
54
+ puts JSON.pretty_generate(payload)
55
+ end
56
+
57
+ def uninitialised_payload
58
+ {
59
+ 'wisco_version' => Wisco::VERSION,
60
+ 'initialized' => false,
61
+ 'config_path' => nil,
62
+ 'profile' => nil,
63
+ 'hostname' => nil,
64
+ 'connection' => nil,
65
+ 'connector' => nil,
66
+ 'credentials' => nil
67
+ }
68
+ end
69
+
70
+ def resolve_hostname(profile_name, config)
71
+ if profile_name
72
+ profile = Wisco::Profiles.get(profile_name)
73
+ profile&.dig('hostname')
74
+ else
75
+ config.dig('workato_developer_api', 'hostname')
76
+ end
77
+ end
78
+
79
+ def load_connector_info(full_path, target_dir)
80
+ unless File.exist?(full_path)
81
+ return { valid: false, title: nil, error: "Connector file not found: #{full_path}" }
82
+ end
83
+
84
+ begin
85
+ connector = Wisco::Connector.load_connector_from_config(target_dir)
86
+ { valid: true, title: connector[:title]&.to_s, error: nil }
87
+ rescue StandardError => e
88
+ { valid: false, title: nil, error: e.message.strip }
89
+ end
90
+ end
91
+
92
+ def check_credentials(connector_path)
93
+ plaintext = File.exist?(File.join(connector_path, 'settings.yaml'))
94
+ encrypted = File.exist?(File.join(connector_path, 'settings.yaml.enc'))
95
+ present = plaintext || encrypted
96
+
97
+ {
98
+ 'present' => present,
99
+ 'encrypted' => present && !plaintext
100
+ }
101
+ end
102
+ end
103
+ end
104
+ end
data/lib/wisco/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Wisco
2
- VERSION = '0.4.1'
2
+ VERSION = '0.4.2'
3
3
  end
data/lib/wisco.rb CHANGED
@@ -25,6 +25,7 @@ require_relative 'wisco/commands/pull'
25
25
  require_relative 'wisco/commands/push'
26
26
  require_relative 'wisco/commands/schema'
27
27
  require_relative 'wisco/commands/profile'
28
+ require_relative 'wisco/commands/status'
28
29
 
29
30
  module Wisco
30
31
  class CLI < Thor
@@ -190,6 +191,16 @@ module Wisco
190
191
  )
191
192
  end
192
193
 
194
+ desc 'status [PATH]', 'Report wisco project status as JSON (for tooling)'
195
+ long_desc <<~DESC
196
+ Outputs a JSON payload describing the wisco state of the current directory.
197
+ Intended for use by the Wisco VS Code extension.
198
+ Always exits 0; check the "initialized" field to determine project state.
199
+ DESC
200
+ def status(path = nil)
201
+ Wisco::Commands::Status.run(path || Dir.pwd)
202
+ end
203
+
193
204
  desc 'profile SUBCOMMAND ...ARGS', 'Manage connection profiles (~/.wisco/profiles.yaml)'
194
205
  long_desc <<~DESC
195
206
  Subcommands:
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: wisco
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.1
4
+ version: 0.4.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - mbillington
@@ -75,6 +75,7 @@ files:
75
75
  - lib/wisco/commands/pull.rb
76
76
  - lib/wisco/commands/push.rb
77
77
  - lib/wisco/commands/schema.rb
78
+ - lib/wisco/commands/status.rb
78
79
  - lib/wisco/config.rb
79
80
  - lib/wisco/connector.rb
80
81
  - lib/wisco/exec_script.rb