vtk 0.2.2 → 0.3.0

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: 83a1b06084a090c2a973975063ae3584e5be741cd8231907aec5445e5ef9fdeb
4
- data.tar.gz: ea5f7ebfd58fa183fe765d99a5e8efd81511ac0950b645f2008d7f0fd4c05cba
3
+ metadata.gz: dbb2159bd782736d6f9647826b073ab189e0e7d40d69dcb1664c16f62a688f09
4
+ data.tar.gz: 36386f949cd2c08013e97d3689ebc6f2c86c95ce0ca9fd7344223c35cb3ff261
5
5
  SHA512:
6
- metadata.gz: f669995c82560deaa6651800c8025ee6a9bde95706a0671a1aea066ebcfc4b857673ba71c783b39de57e16c2685f3d29e8b63f98d3d798e8351a9aa7938981bc
7
- data.tar.gz: 510020062d3c3f804f05eaf4135ace5443fb77da4043700ac7373db0e933ff5c57f356c2e396d294106709794615094e771a71127c791514739c1804222b5c80
6
+ metadata.gz: b375532131584051a1ad0c3036f68bab2304e8bdeb47cbfe7e3806fba24a5838be3e2229663cc836ae429eb17ebc2dc86a771589d83934226ea011dd80a8edc5
7
+ data.tar.gz: e28c0bbfa60f7ef3b15948e355171a8e9f2b8cb17fca8f4094217b75423b337e1e693d7226b42a80cc2b1165da08f7ac3951a284c26c68fc5178da2fef5504d9
data/.rubocop.yml CHANGED
@@ -6,4 +6,5 @@ Layout/LineLength:
6
6
 
7
7
  Metrics/BlockLength:
8
8
  Exclude:
9
- - 'spec/integration/module_spec.rb'
9
+ - 'spec/**/*.rb'
10
+ - '*.gemspec'
data/CHANGELOG.md CHANGED
@@ -1,13 +1,61 @@
1
1
  # Changelog
2
2
 
3
- ## [Unreleased](https://github.com/department-of-veterans-affairs/vtk/tree/HEAD)
3
+ ## [v0.2.6](https://github.com/department-of-veterans-affairs/vtk/tree/v0.2.6) (2021-02-03)
4
4
 
5
- [Full Changelog](https://github.com/department-of-veterans-affairs/vtk/compare/oclif...HEAD)
5
+ [Full Changelog](https://github.com/department-of-veterans-affairs/vtk/compare/v0.2.5...v0.2.6)
6
6
 
7
7
  **Merged pull requests:**
8
8
 
9
+ - Update changelog docs and raketask [\#13](https://github.com/department-of-veterans-affairs/vtk/pull/13) ([LindseySaari](https://github.com/LindseySaari))
10
+ - add gem to auto generate changelog [\#12](https://github.com/department-of-veterans-affairs/vtk/pull/12) ([LindseySaari](https://github.com/LindseySaari))
11
+
12
+ ## [v0.2.5](https://github.com/department-of-veterans-affairs/vtk/tree/v0.2.5) (2021-02-03)
13
+
14
+ [Full Changelog](https://github.com/department-of-veterans-affairs/vtk/compare/v0.2.4...v0.2.5)
15
+
16
+ ## [v0.2.4](https://github.com/department-of-veterans-affairs/vtk/tree/v0.2.4) (2021-01-26)
17
+
18
+ [Full Changelog](https://github.com/department-of-veterans-affairs/vtk/compare/v0.2.3...v0.2.4)
19
+
20
+ **Merged pull requests:**
21
+
22
+ - added Docker instructions to the README [\#10](https://github.com/department-of-veterans-affairs/vtk/pull/10) ([thilton-oddball](https://github.com/thilton-oddball))
23
+ - use system command [\#7](https://github.com/department-of-veterans-affairs/vtk/pull/7) ([LindseySaari](https://github.com/LindseySaari))
9
24
  - Add additional module subcommands [\#6](https://github.com/department-of-veterans-affairs/vtk/pull/6) ([LindseySaari](https://github.com/LindseySaari))
10
25
  - Check for Rails dependency [\#5](https://github.com/department-of-veterans-affairs/vtk/pull/5) ([LindseySaari](https://github.com/LindseySaari))
26
+
27
+ ## [v0.2.3](https://github.com/department-of-veterans-affairs/vtk/tree/v0.2.3) (2021-01-05)
28
+
29
+ [Full Changelog](https://github.com/department-of-veterans-affairs/vtk/compare/v0.2.2...v0.2.3)
30
+
31
+ **Merged pull requests:**
32
+
11
33
  - one more crack at fixing the README [\#4](https://github.com/department-of-veterans-affairs/vtk/pull/4) ([thilton-oddball](https://github.com/thilton-oddball))
34
+
35
+ ## [v0.2.2](https://github.com/department-of-veterans-affairs/vtk/tree/v0.2.2) (2021-01-05)
36
+
37
+ [Full Changelog](https://github.com/department-of-veterans-affairs/vtk/compare/v0.1.0...v0.2.2)
38
+
39
+ **Merged pull requests:**
40
+
12
41
  - fixing markdown in README … [\#3](https://github.com/department-of-veterans-affairs/vtk/pull/3) ([thilton-oddball](https://github.com/thilton-oddball))
42
+
43
+ ## [v0.1.0](https://github.com/department-of-veterans-affairs/vtk/tree/v0.1.0) (2021-01-04)
44
+
45
+ [Full Changelog](https://github.com/department-of-veterans-affairs/vtk/compare/oclif...v0.1.0)
46
+
47
+ **Merged pull requests:**
48
+
13
49
  - Start afresh with tty [\#2](https://github.com/department-of-veterans-affairs/vtk/pull/2) ([LindseySaari](https://github.com/LindseySaari))
50
+
51
+ ## [oclif](https://github.com/department-of-veterans-affairs/vtk/tree/oclif) (2020-08-10)
52
+
53
+ [Full Changelog](https://github.com/department-of-veterans-affairs/vtk/compare/79143038509757799edb2bb9be2f925b7d985221...oclif)
54
+
55
+ **Merged pull requests:**
56
+
57
+ - Open Jenkins [\#1](https://github.com/department-of-veterans-affairs/vtk/pull/1) ([cvalarida](https://github.com/cvalarida))
58
+
59
+
60
+
61
+ \* *This Changelog was automatically generated by [github_changelog_generator](https://github.com/github-changelog-generator/github-changelog-generator)*
data/README.md CHANGED
@@ -26,6 +26,23 @@ To add additional functionality to your module, the commands listed below are av
26
26
  $ vtk module service <module name>
27
27
 
28
28
  This above command runs a custom rails generator. For more information see the [module generator documentation](https://github.com/department-of-veterans-affairs/vets-api/blob/master/lib/generators/module/USAGE)
29
+
30
+ ### SOCKS
31
+
32
+ Handles connecting to VA network via SOCKS.
33
+
34
+ ```
35
+ $ vtk socks on
36
+ ----> Connecting...
37
+ ----> Connected to SOCKS.
38
+ ```
39
+
40
+ To disconnect, run:
41
+
42
+ ```
43
+ $ vtk socks off
44
+ ----> Disconnected from SOCKS.
45
+ ```
29
46
 
30
47
  ### Help
31
48
 
@@ -33,3 +50,27 @@ For helpful information about commands and subcommands run the following:
33
50
 
34
51
  $ vtk -h
35
52
  $ vtk module -h
53
+
54
+ ### Docker
55
+
56
+ If using the vtk gem in Docker, you may first need to run the following commands to avoid any errors:
57
+
58
+ $ make docker-clean
59
+ $ make build
60
+ $ make bash
61
+
62
+ ### Contributing
63
+ 1. Clone the repo
64
+ 2. Create your feature branch (git checkout -b my-new-feature)
65
+ 3. Run the tests (bundle exec rake)
66
+ 4. Commit your changes
67
+ 5. Push to the branch (git push origin my-new-feature)
68
+ 6. Create new Pull Request
69
+
70
+ ### Releasing
71
+ 1. Merge in your approved pull requests
72
+ 2. Update the version to be whatever it should (in lib/vtk/version.rb) be and commit
73
+ - The version bump could also be part of your PR
74
+ 3. ``` bundle exec rake release ```
75
+ - This will tag the release and publish to RubyGems
76
+ 4. Update the changelog — (```github_changelog_generator -u department-of-veterans-affairs -p vtk```)
data/Rakefile CHANGED
@@ -10,3 +10,11 @@ require 'rubocop/rake_task'
10
10
  RuboCop::RakeTask.new
11
11
 
12
12
  task default: %i[spec rubocop]
13
+
14
+ desc 'Tags version, pushes to remote, and pushes gem'
15
+ task :release do
16
+ sh 'git', 'tag', "v#{Vtk::VERSION}"
17
+ sh "git push origin v#{Vtk::VERSION}"
18
+ sh 'rake build'
19
+ sh "ls pkg/vtk-#{Vtk::VERSION}.gem | xargs -n 1 gem push"
20
+ end
data/lib/vtk/cli.rb CHANGED
@@ -18,6 +18,9 @@ module Vtk
18
18
  end
19
19
  map %w[--version -v] => :version
20
20
 
21
+ require_relative 'commands/socks'
22
+ register Vtk::Commands::Socks, 'socks', 'socks [SUBCOMMAND]', 'Handles connecting to VA network via SOCKS'
23
+
21
24
  require_relative 'commands/module'
22
25
  register Vtk::Commands::Module, 'module', 'module [SUBCOMMAND]', 'Command description...'
23
26
  end
@@ -23,7 +23,7 @@ module Vtk
23
23
  private
24
24
 
25
25
  def create_controller(name)
26
- `rails g module_component #{name} controller`
26
+ system("rails g module_component #{name} controller")
27
27
  end
28
28
  end
29
29
  end
@@ -23,7 +23,7 @@ module Vtk
23
23
  private
24
24
 
25
25
  def create_model(name)
26
- `rails g module_component #{name} model`
26
+ system("rails g module_component #{name} model")
27
27
  end
28
28
  end
29
29
  end
@@ -23,7 +23,7 @@ module Vtk
23
23
  private
24
24
 
25
25
  def create_serializer(name)
26
- `rails g module_component #{name} serializer`
26
+ system("rails g module_component #{name} serializer")
27
27
  end
28
28
  end
29
29
  end
@@ -23,7 +23,7 @@ module Vtk
23
23
  private
24
24
 
25
25
  def create_service(name)
26
- `rails g module_component #{name} service`
26
+ system("rails g module_component #{name} service")
27
27
  end
28
28
  end
29
29
  end
@@ -0,0 +1,40 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'thor'
4
+
5
+ module Vtk
6
+ module Commands
7
+ # Handles connecting to VA network via SOCKS
8
+ class Socks < Thor
9
+ namespace :socks
10
+
11
+ desc 'off', 'Disconnects from VA SOCKS'
12
+ method_option :help, aliases: '-h', type: :boolean,
13
+ desc: 'Display usage information'
14
+ method_option :port, aliases: '-p', type: :string,
15
+ desc: 'Port that SOCKS server is running on'
16
+ def off(*)
17
+ if options[:help]
18
+ invoke :help, ['off']
19
+ else
20
+ require_relative 'socks/off'
21
+ Vtk::Commands::Socks::Off.new(options).execute
22
+ end
23
+ end
24
+
25
+ desc 'on', 'Connects to VA SOCKS'
26
+ method_option :help, aliases: '-h', type: :boolean,
27
+ desc: 'Display usage information'
28
+ method_option :port, aliases: '-p', type: :string,
29
+ desc: 'Port to run SOCKS server on'
30
+ def on(*)
31
+ if options[:help]
32
+ invoke :help, ['on']
33
+ else
34
+ require_relative 'socks/on'
35
+ Vtk::Commands::Socks::On.new(options).execute
36
+ end
37
+ end
38
+ end
39
+ end
40
+ end
@@ -0,0 +1,40 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative '../../command'
4
+
5
+ module Vtk
6
+ module Commands
7
+ class Socks
8
+ # Turns off SOCKS connection to VA network
9
+ class Off < Vtk::Command
10
+ attr_reader :options
11
+
12
+ def initialize(options)
13
+ @options = options
14
+
15
+ super()
16
+ end
17
+
18
+ def execute(_input: $stdin, output: $stdout)
19
+ pids_killed = running_pids.map { |pid| kill_pid pid }
20
+
21
+ if pids_killed.any? && pids_killed.all?
22
+ output.puts '----> Disconnected from SOCKS.'
23
+ else
24
+ output.puts '----> No SOCKS connection found.'
25
+ end
26
+ end
27
+
28
+ private
29
+
30
+ def running_pids
31
+ `lsof -Pi :#{options['port'] || 2001} -sTCP:LISTEN -t`.chomp.split "\n"
32
+ end
33
+
34
+ def kill_pid(pid)
35
+ system "kill -9 #{pid}"
36
+ end
37
+ end
38
+ end
39
+ end
40
+ end
@@ -0,0 +1,61 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative '../../command'
4
+
5
+ module Vtk
6
+ module Commands
7
+ class Socks
8
+ # Turns on SOCKS connection to VA network
9
+ class On < Vtk::Command
10
+ attr_reader :input, :output, :port
11
+
12
+ def initialize(options)
13
+ @options = options
14
+ @port = options['port'] || '2001'
15
+
16
+ super()
17
+ end
18
+
19
+ def execute(_input: $stdin, output: $stdout)
20
+ @input = input
21
+ @output = output
22
+
23
+ return output.puts '----> Already connected to SOCKS.' if connected?
24
+
25
+ connect_to_socks
26
+ ensure_connection
27
+ end
28
+
29
+ private
30
+
31
+ def connected?
32
+ system "curl --max-time 2 -sL --proxy socks5h://127.0.0.1:#{port} sentry.vfs.va.gov 2> /dev/null | " \
33
+ 'grep -q sentry-logo'
34
+ end
35
+
36
+ def connect_to_socks
37
+ exit if system "lsof -Pi :#{port} -sTCP:LISTEN -t > /dev/null"
38
+
39
+ Process.spawn "nohup ssh -vvv -o ServerAliveInterval=60 -o ConnectTimeout=5 socks -D #{port} -N" \
40
+ '> /tmp/socks.log 2>&1 &'
41
+ end
42
+
43
+ def ensure_connection
44
+ output.print '----> Connecting'
45
+ 10.times do
46
+ sleep 1
47
+ output.print '.'
48
+ next unless connected?
49
+
50
+ return output.puts "\r----> Connected to SOCKS."
51
+ end
52
+
53
+ output.puts "\r----> ERROR: Could not connect to SOCKS."
54
+ output.puts "----> Verbose Output from SSH log:\n\n"
55
+
56
+ output.puts File.read '/tmp/socks.log'
57
+ end
58
+ end
59
+ end
60
+ end
61
+ end
data/lib/vtk/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Vtk
4
- VERSION = '0.2.2'
4
+ VERSION = '0.3.0'
5
5
  end
data/vtk.gemspec CHANGED
@@ -16,7 +16,7 @@ Gem::Specification.new do |spec|
16
16
 
17
17
  spec.metadata['homepage_uri'] = spec.homepage
18
18
  spec.metadata['source_code_uri'] = spec.homepage
19
- spec.metadata['changelog_uri'] = 'https://github.com/department-of-veterans-affairs/vsp-toolkit/blob/master/CHANGELOG.md'
19
+ spec.metadata['changelog_uri'] = 'https://github.com/department-of-veterans-affairs/vtk/blob/master/CHANGELOG.md'
20
20
 
21
21
  # Specify which files should be added to the gem when it is released.
22
22
  # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
@@ -29,6 +29,8 @@ Gem::Specification.new do |spec|
29
29
 
30
30
  spec.add_dependency 'thor', '> 0.20.3'
31
31
 
32
+ spec.add_development_dependency 'github_changelog_generator', '~> 1.15.0'
33
+ spec.add_development_dependency 'pry', '~> 0.13.0'
32
34
  spec.add_development_dependency 'rake', '~> 13.0.0'
33
35
  spec.add_development_dependency 'rspec', '~> 3.10.0'
34
36
  spec.add_development_dependency 'rubocop', '~> 1.6.0'
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vtk
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.2
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Eric Boehs
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: exe
12
12
  cert_chain: []
13
- date: 2021-01-22 00:00:00.000000000 Z
13
+ date: 2021-02-16 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: thor
@@ -26,6 +26,34 @@ dependencies:
26
26
  - - ">"
27
27
  - !ruby/object:Gem::Version
28
28
  version: 0.20.3
29
+ - !ruby/object:Gem::Dependency
30
+ name: github_changelog_generator
31
+ requirement: !ruby/object:Gem::Requirement
32
+ requirements:
33
+ - - "~>"
34
+ - !ruby/object:Gem::Version
35
+ version: 1.15.0
36
+ type: :development
37
+ prerelease: false
38
+ version_requirements: !ruby/object:Gem::Requirement
39
+ requirements:
40
+ - - "~>"
41
+ - !ruby/object:Gem::Version
42
+ version: 1.15.0
43
+ - !ruby/object:Gem::Dependency
44
+ name: pry
45
+ requirement: !ruby/object:Gem::Requirement
46
+ requirements:
47
+ - - "~>"
48
+ - !ruby/object:Gem::Version
49
+ version: 0.13.0
50
+ type: :development
51
+ prerelease: false
52
+ version_requirements: !ruby/object:Gem::Requirement
53
+ requirements:
54
+ - - "~>"
55
+ - !ruby/object:Gem::Version
56
+ version: 0.13.0
29
57
  - !ruby/object:Gem::Dependency
30
58
  name: rake
31
59
  requirement: !ruby/object:Gem::Requirement
@@ -131,6 +159,9 @@ files:
131
159
  - lib/vtk/commands/module/model.rb
132
160
  - lib/vtk/commands/module/serializer.rb
133
161
  - lib/vtk/commands/module/service.rb
162
+ - lib/vtk/commands/socks.rb
163
+ - lib/vtk/commands/socks/off.rb
164
+ - lib/vtk/commands/socks/on.rb
134
165
  - lib/vtk/templates/.gitkeep
135
166
  - lib/vtk/templates/module/add/.gitkeep
136
167
  - lib/vtk/version.rb
@@ -141,7 +172,7 @@ licenses:
141
172
  metadata:
142
173
  homepage_uri: https://github.com/department-of-veterans-affairs/vsp-toolkit
143
174
  source_code_uri: https://github.com/department-of-veterans-affairs/vsp-toolkit
144
- changelog_uri: https://github.com/department-of-veterans-affairs/vsp-toolkit/blob/master/CHANGELOG.md
175
+ changelog_uri: https://github.com/department-of-veterans-affairs/vtk/blob/master/CHANGELOG.md
145
176
  post_install_message:
146
177
  rdoc_options: []
147
178
  require_paths:
@@ -157,7 +188,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
157
188
  - !ruby/object:Gem::Version
158
189
  version: '0'
159
190
  requirements: []
160
- rubygems_version: 3.0.8
191
+ rubygems_version: 3.2.1
161
192
  signing_key:
162
193
  specification_version: 4
163
194
  summary: A CLI for the VSP platform