firespring_dev_commands 2.1.16.pre.alpha.2 → 2.5.0.pre.alpha.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: f810b97efdfffe33d29fc32b31c63e59e988e4c7b11e82d68a4cd6e85262a7b0
4
- data.tar.gz: 965832c284d5276501f658c5a0d7d70c6a4b4f88ef84c834011bc4b6bdb1cd6f
3
+ metadata.gz: e146e8c9d9c3422dfd7641c6a09ca8c2cdfad6ed430d73aec5808de28ed5d880
4
+ data.tar.gz: 273923aae5ccce231fc77174ed89cbe0e4f5ad59b52219b04303f983e9966e1d
5
5
  SHA512:
6
- metadata.gz: ea9ffaa8921ed4c75f1e0c3c9262167fa45faa382d0d9074c22d4aa6a4318856dc380a7f23f5ce2b09e5a20197af193e587f102ded1bc09447c81c6a87aac092
7
- data.tar.gz: ad5e684614fb9bcadba6a6a975712bf1a6ccd4d27687cb3e1288fd8efc34bea5cb1285c4da47b12f7a72f1eb283bb71f0e6bbae604ae071bb7d3d0eadbac9b69
6
+ metadata.gz: 67223e6ba12a10f798d7fee6b1cab844da41cd3dc65a449330e8c8bd0ef86180cc297889b7365b7b68f5ca8054919e9881693707ecfde02e539d0a7e22c6af51
7
+ data.tar.gz: ada0e13a3f2d8022687a2542503bad6bc847bf32fc17604116d17e06ed46ee7efa18aea35635c31a26c07f5ccdd6a3c5083235edaafd77684528bc487c17f3c7
@@ -3,12 +3,11 @@ module Dev
3
3
  class Audit
4
4
  # The class containing standardized information about an audit report
5
5
  class Report
6
- attr_accessor :items, :min_severity, :error_on_unknown, :ignorelist, :filtered_items
6
+ attr_accessor :items, :min_severity, :ignorelist, :filtered_items
7
7
 
8
8
  def initialize(
9
9
  items,
10
10
  min_severity: ENV.fetch('MIN_SEVERITY', nil),
11
- error_on_unknown: ENV.fetch('ERROR_ON_UNKNOWN', nil),
12
11
  ignorelist: ENV['IGNORELIST'].to_s.split(/\s*,\s*/)
13
12
  )
14
13
  # Items should be an array of Item objects
@@ -16,18 +15,12 @@ module Dev
16
15
  raise 'items must all be report items' unless @items.all?(Dev::Audit::Report::Item)
17
16
 
18
17
  @min_severity = min_severity || Level::HIGH
19
- @error_on_unknown = error_on_unknown
20
18
  @ignorelist = Array(ignorelist).compact
21
19
  end
22
20
 
23
21
  # Get all severities greater than or equal to the minimum severity
24
22
  def desired_severities
25
- max_severity = if error_on_unknown.to_s.strip == 'true'
26
- -1
27
- else
28
- -2
29
- end
30
- LEVELS.slice(LEVELS.find_index(min_severity)..max_severity)
23
+ LEVELS.slice(LEVELS.find_index(min_severity)..-1)
31
24
  end
32
25
 
33
26
  # Run the filters against the report items and filter out any which should be excluded
@@ -96,7 +96,7 @@ module Dev
96
96
  test
97
97
  end
98
98
 
99
- # Build the node test command
99
+ # Build the node test (with coverage) command
100
100
  def test_coverage_command
101
101
  test = base_command
102
102
  test << 'run' << 'test:coverage'
@@ -58,12 +58,9 @@ module Dev
58
58
  end
59
59
 
60
60
  # Build the command to fix any security vulnerabilities that were found
61
- # def audit_fix_command
62
- # audit_fix = base_command
63
- # audit_fix << 'audit' << 'fix'
64
- # audit_fix.concat(Dev::Common.new.tokenize(ENV['OPTS'].to_s))
65
- # audit_fix
66
- # end
61
+ def audit_fix_command
62
+ raise 'not implemented'
63
+ end
67
64
 
68
65
  # Build the php install command
69
66
  def install_command
@@ -76,7 +73,7 @@ module Dev
76
73
  # Build the php lint command
77
74
  def lint_command
78
75
  lint = base_command
79
- lint << 'lint'
76
+ lint << 'run' << 'lint'
80
77
  lint.concat(Dev::Common.new.tokenize(ENV['OPTS'].to_s))
81
78
  lint
82
79
  end
@@ -84,7 +81,7 @@ module Dev
84
81
  # Build the php lint fix command
85
82
  def lint_fix_command
86
83
  lint_fix = base_command
87
- lint_fix << 'lint-fix'
84
+ lint_fix << 'run' << 'lint-fix'
88
85
  lint_fix.concat(Dev::Common.new.tokenize(ENV['OPTS'].to_s))
89
86
  lint_fix
90
87
  end
@@ -92,18 +89,14 @@ module Dev
92
89
  # Build the php test command
93
90
  def test_command
94
91
  test = []
95
- test << './vendor/bin/phpunit'
92
+ lint_fix << 'run' << 'test'
96
93
  test.concat(Dev::Common.new.tokenize(ENV['OPTS'].to_s))
97
94
  test
98
95
  end
99
96
 
100
- # Build the php fast test command
101
- def test_fast_command(processes = 4)
102
- test = []
103
- test << './vendor/bin/paratest'
104
- test.concat(Dev::Common.new.tokenize(ENV['OPTS'].to_s))
105
- test << "-p#{processes}" << '--runner=WrapperRunner'
106
- test
97
+ # Build the php test (with coverage) command
98
+ def test_coverage_command
99
+ raise 'not implemented'
107
100
  end
108
101
  end
109
102
  end
@@ -15,7 +15,7 @@ module Dev
15
15
  # The text of the url variable key
16
16
  TP_URL = 'TP_URL'.freeze
17
17
 
18
- # Config object for setting top level target process config options
18
+ # Config object for setting top level jira config options
19
19
  Config = Struct.new(:username, :password, :url, :http_debug) do
20
20
  def initialize
21
21
  Dotenv.load(CONFIG_FILE) if File.exist?(CONFIG_FILE)
@@ -1,4 +1,5 @@
1
1
  require_relative '../../base_interface'
2
+ require 'securerandom'
2
3
 
3
4
  module Dev
4
5
  module Template
@@ -7,11 +8,15 @@ module Dev
7
8
  module Php
8
9
  # Class for default rake tasks associated with a php project
9
10
  class Application < Dev::Template::ApplicationInterface
10
- attr_reader :php
11
+ attr_reader :php, :siloed_tests
11
12
 
12
13
  # Allow for custom container path for the application
13
- def initialize(application, container_path: nil, local_path: nil, exclude: [])
14
+ def initialize(application, container_path: nil, local_path: nil, siloed_tests: nil, exclude: [])
14
15
  @php = Dev::Php.new(container_path:, local_path:)
16
+ # TODO: Better name
17
+ # TODO: Should this apply to all or just tests?
18
+ @siloed_tests = siloed_tests
19
+
15
20
  super(application, exclude:)
16
21
  end
17
22
 
@@ -102,6 +107,7 @@ module Dev
102
107
  def create_test_task!
103
108
  application = @name
104
109
  php = @php
110
+ siloed_tests = @siloed_tests
105
111
  exclude = @exclude
106
112
  return if exclude.include?(:test)
107
113
 
@@ -117,9 +123,13 @@ module Dev
117
123
  task test: %w(init_docker up) do
118
124
  LOG.debug("Running all php tests in the #{application} codebase")
119
125
 
126
+ project_name = nil
127
+ project_name = SecureRandom.hex if siloed_tests
128
+
120
129
  options = []
121
130
  options << '-T' if Dev::Common.new.running_codebuild?
122
- Dev::Docker::Compose.new(services: application, options:).exec(*php.test_command)
131
+ Dev::Docker::Compose.new(project_name:, services: application, options:).exec(*php.test_command)
132
+ # TODO: Add clean if we are siloed
123
133
  end
124
134
  end
125
135
  end
@@ -6,6 +6,6 @@ module Dev
6
6
  # Use 'v.v.v.pre.alpha.v' for pre-release vesions
7
7
  # Use 'v.v.v.beta.v for beta versions
8
8
  # Use semantic versioning for any releases (https://semver.org/)
9
- VERSION = '2.1.16.pre.alpha.2'.freeze
9
+ VERSION = '2.5.0.pre.alpha.1'.freeze
10
10
  end
11
11
  end
@@ -11,7 +11,7 @@ DEV_COMMANDS_TOP_LEVEL = self
11
11
 
12
12
  # Load all gems referenced in the Gemfile
13
13
  require 'bundler'
14
- Bundler.require(:default)
14
+ Bundler.require
15
15
 
16
16
  # Add libdir to the default ruby path
17
17
  libdir = File.realpath(File.dirname(__FILE__))
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: firespring_dev_commands
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.1.16.pre.alpha.2
4
+ version: 2.5.0.pre.alpha.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Firespring
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-12-04 00:00:00.000000000 Z
11
+ date: 2023-11-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -327,10 +327,6 @@ files:
327
327
  - lib/firespring_dev_commands/aws/parameter.rb
328
328
  - lib/firespring_dev_commands/aws/profile.rb
329
329
  - lib/firespring_dev_commands/aws/s3.rb
330
- - lib/firespring_dev_commands/bloom_growth.rb
331
- - lib/firespring_dev_commands/bloom_growth/rock.rb
332
- - lib/firespring_dev_commands/bloom_growth/seat.rb
333
- - lib/firespring_dev_commands/bloom_growth/user.rb
334
330
  - lib/firespring_dev_commands/boolean.rb
335
331
  - lib/firespring_dev_commands/common.rb
336
332
  - lib/firespring_dev_commands/daterange.rb
@@ -1,34 +0,0 @@
1
- module Dev
2
- class BloomGrowth
3
- # Class containing rock information
4
- class Rock
5
- attr_accessor :data, :id, :type, :name, :owner, :complete, :completion_id, :created, :due
6
- attr_reader :state
7
-
8
- def initialize(data)
9
- @data = data
10
- @id = data['Id']
11
- @type = data['Type']
12
- @name = data['Name'].to_s.strip
13
- @owner = User.new(data['Owner']) if data['Owner']
14
- @complete = data['Complete']
15
- @completion_id = data['Completion']
16
- @created = Time.parse(data['CreateTime']) if data['CreateTime']
17
- @due = Time.parse(data['DueDate']) if data['DueDate']
18
- @archived = data['Archived']
19
- end
20
-
21
- # Convert the completion_id bloom growth gives us into a text version
22
- def state
23
- case completion_id
24
- when 0
25
- 'Off Track'
26
- when 1
27
- 'On Track'
28
- when 2
29
- 'Complete'
30
- end
31
- end
32
- end
33
- end
34
- end
@@ -1,16 +0,0 @@
1
- module Dev
2
- class BloomGrowth
3
- # Class containing seat information
4
- class Seat
5
- attr_accessor :data, :id, :type, :name
6
-
7
- def initialize(data)
8
- @data = data
9
- position = data.dig('Group', 'Position')
10
- @id = position&.fetch('Id')
11
- @type = position&.fetch('Type')
12
- @name = position&.fetch('Name').to_s.strip
13
- end
14
- end
15
- end
16
- end
@@ -1,43 +0,0 @@
1
- module Dev
2
- class BloomGrowth
3
- # Class containing user information
4
- class User
5
- attr_accessor :data, :id, :type, :name, :rocks, :direct_reports, :seats
6
-
7
- def initialize(data)
8
- @data = data
9
- @id = data['Id']
10
- @type = data['Type']
11
- @name = data['Name'].to_s.strip
12
- @rocks = nil
13
- @direct_reports = nil
14
- @seats = nil
15
- end
16
-
17
- def rocks
18
- @rocks ||= [].tap do |ary|
19
- Dev::BloomGrowth.new.get("/api/v1/rocks/user/#{id}") do |data|
20
- ary << Rock.new(data)
21
- end
22
- end
23
- end
24
-
25
- def direct_reports
26
- @direct_reports ||= [].tap do |ary|
27
- Dev::BloomGrowth.new.get("/api/v1/users/#{id}/directreports") do |data|
28
- ary << User.new(data)
29
- end
30
- end
31
- end
32
-
33
- def seats
34
- @seats ||= [].tap do |ary|
35
- Dev::BloomGrowth.new.get("/api/v1/users/#{id}/seats") do |data|
36
- ary << Seat.new(data)
37
- puts ary.last.inspect
38
- end
39
- end
40
- end
41
- end
42
- end
43
- end
@@ -1,132 +0,0 @@
1
- require 'net/http'
2
-
3
- module Dev
4
- # Class for interacting with the Bloom Growth api
5
- class BloomGrowth
6
- # The config file to try to load credentials from
7
- CONFIG_FILE = "#{Dir.home}/.env.bloom".freeze
8
-
9
- # The text of the username variable key
10
- BLOOM_USERNAME = 'BLOOM_USERNAME'.freeze
11
-
12
- # The text of the password variable key
13
- BLOOM_PASSWORD = 'BLOOM_PASSWORD'.freeze
14
-
15
- # The text of the token variable key
16
- BLOOM_TOKEN = 'BLOOM_TOKEN'.freeze
17
-
18
- # The text of the url variable key
19
- BLOOM_URL = 'BLOOM_URL'.freeze
20
-
21
- # Config object for setting top level bloom growth config options
22
- Config = Struct.new(:username, :password, :url, :http_debug) do
23
- def initialize
24
- Dotenv.load(CONFIG_FILE) if File.exist?(CONFIG_FILE)
25
-
26
- self.username = ENV.fetch(BLOOM_USERNAME, nil)
27
- self.password = ENV.fetch(BLOOM_PASSWORD, nil)
28
- self.url = ENV.fetch(BLOOM_URL, 'https://app.bloomgrowth.com')
29
- self.http_debug = false
30
- end
31
- end
32
-
33
- class << self
34
- # Instantiates a new top level config object if one hasn't already been created
35
- # Yields that config object to any given block
36
- # Returns the resulting config object
37
- def config
38
- @config ||= Config.new
39
- yield(@config) if block_given?
40
- @config
41
- end
42
-
43
- # Alias the config method to configure for a slightly clearer access syntax
44
- alias_method :configure, :config
45
- end
46
-
47
- attr_accessor :username, :password, :url, :token, :client, :default_headers
48
-
49
- # Initialize a new target process client using the given inputs
50
- def initialize(username: self.class.config.username, password: self.class.config.password, url: self.class.config.url)
51
- raise 'username is required' if username.to_s.strip.empty?
52
- raise 'password is required' if password.to_s.strip.empty?
53
- raise 'url is required' if url.to_s.strip.empty?
54
-
55
- @username = username
56
- @password = password
57
- @url = url
58
- uri = URI.parse(@url)
59
- @client = Net::HTTP.new(uri.host, uri.port)
60
- @client.use_ssl = true
61
- @client.verify_mode = OpenSSL::SSL::VERIFY_PEER
62
- @client.set_debug_output(LOG) if self.class.config.http_debug
63
- @default_headers = {
64
- 'authorization' => "Bearer #{token}",
65
- 'content-type' => 'application/json',
66
- 'accept' => 'application/json'
67
- }
68
- end
69
-
70
- # Method for getting a bearer token for the bloom growth api. There are a couple of possible logic paths
71
- # - If a token has already been defined, use it
72
- # - If a token is found in the ENV, use it
73
- # - Otherwise, use the username and passowrd that has been configured to request a new token from bloom
74
- def token
75
- @token ||= ENV.fetch(BLOOM_TOKEN, nil)
76
-
77
- unless @token
78
- response = post(
79
- '/Token',
80
- {
81
- grant_type: 'password',
82
- userName: username,
83
- password:
84
- },
85
- headers: {
86
- 'content-type' => 'application/json',
87
- 'accept' => 'application/json'
88
- }
89
- )
90
- # TODO: Should we look at https://github.com/DannyBen/lightly for caching the token?
91
- @token = ENV[BLOOM_TOKEN] = response['access_token']
92
- LOG.info("Retrieved BloomGrowth token. Expires on #{Time.now + response['expires_in']}")
93
- end
94
-
95
- @token
96
- end
97
-
98
- # Return all user objects visible to the logged in user
99
- def visible_users(&)
100
- [].tap do |ary|
101
- get('/api/v1/users/mineviewable') do |user_data|
102
- ary << User.new(user_data)
103
- end
104
- ary.each(&)
105
- end
106
- end
107
-
108
- # Perform a get request to the given path using the given query
109
- # Call the given block (if present) with each piece of data
110
- # Return all pieces of data
111
- def get(path, query_string: nil, headers: default_headers, &)
112
- url = path
113
- url << "?#{URI.encode_www_form(query_string)}" unless query_string.to_s.strip.empty?
114
-
115
- response = client.request_get(url, headers)
116
- raise "Error querying #{url} [#{query_string}]: #{response.inspect}" unless response.response.is_a?(Net::HTTPSuccess)
117
-
118
- JSON.parse(response.body).each(&)
119
- nil
120
- end
121
-
122
- # Perform a post request to the given path using the gien data
123
- # Return the parsed json body
124
- def post(path, data, headers: default_headers)
125
- data = data.to_json unless data.is_a?(String)
126
- response = client.request_post(path, data, headers)
127
- raise "Error querying #{url}/#{path}: #{response.inspect}" unless response.response.is_a?(Net::HTTPSuccess)
128
-
129
- JSON.parse(response.body)
130
- end
131
- end
132
- end