firespring_dev_commands 2.1.36.pre.alpha.3 → 2.1.37.pre.alpha.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8b16a12fa92abd7ddb0eba2538a4e2435b40ec20547f2bbe3f82a8f33527feb8
4
- data.tar.gz: b958406a536676933f1dc8441cf5fa0672213c45f6ae6fcae9de71bdd0b44f15
3
+ metadata.gz: 36294ff00a51f5c76ff68456bdbb03cceda36c630d4acaa67187b8f9f7f762f7
4
+ data.tar.gz: a0702083c579aa28d9e75501333c988a6a915f7e47ef5bcce58f3c8122010c6c
5
5
  SHA512:
6
- metadata.gz: 1ab1a0dc3cf178481a223d6a8a6535f91f1026827a6d744aaac5e9e01acdaf08c4c4f85e334394d945fefc836bb92f312023a16918b89f745b70384e3546d8e2
7
- data.tar.gz: c6b89c0c3b1244ac6f9d67bd1473520d094b833825ed544b6da67f5070f19b5f1ecf2295a3ff08bda3a120d3d44ffa758c06e02e276171fc7e3cb9ea2fe551f8
6
+ metadata.gz: e3b7b824b702d719674040152c893e97ebc177e8dff3d6be94385fe3b1e2befea7b60811163cda850b595ddc9e58458923afcf4938d3c8a2e22b63eeac9d1ab9
7
+ data.tar.gz: d4ed9ede7d5e7c106b91acd99fa5b01cca187ce24c030434f28835c122df2dd30b759c684d3fbb9170710ee7c825e027b07f2c4c4455481c8d0c0ebcc0ebdba2
@@ -46,18 +46,8 @@ module Dev
46
46
  @products
47
47
  end
48
48
 
49
- # Returns true if the given product is supported either in the endoflife api products or a manual product
50
- def product?(product)
51
- products.include?(product) || self.class.config.manual_dates.any? { |key, _| key.to_s.start_with?("#{product}_") }
52
- end
53
-
54
49
  # Prints all of the product version statuses
55
50
  def status
56
- if product_versions.empty?
57
- puts ' no tracked products'
58
- return
59
- end
60
-
61
51
  product_versions.sort_by(&:name).each(&:print_status)
62
52
  end
63
53
 
@@ -1,5 +1,6 @@
1
1
  require 'fileutils'
2
2
  require 'git'
3
+ require 'octokit'
3
4
 
4
5
  module Dev
5
6
  # Class for performing git functions
@@ -96,8 +97,7 @@ module Dev
96
97
  def branch_name(dir: default_project_dir)
97
98
  return unless File.exist?(dir)
98
99
 
99
- g = ::Git.open(dir)
100
- g.current_branch || "HEAD detached at #{g.object('HEAD').sha[0..7]}"
100
+ ::Git.open(dir).current_branch
101
101
  end
102
102
 
103
103
  # Returns true if the remote branch exists, false otherwise
@@ -425,6 +425,22 @@ module Dev
425
425
  g.fetch('origin', prune: true)
426
426
  end
427
427
 
428
+ def commit_status(repository:, branch:, status:, organization: 'firespring', options: {})
429
+ token = ENV['GITHUB_TOKEN'].to_s.strip
430
+ raise 'GITHUB_TOKEN is required' unless token
431
+
432
+ # Set up the GitHub client
433
+ client = Octokit::Client.new(access_token: token)
434
+
435
+ # Fetch the latest commit SHA for the given branch
436
+ repo = "#{organization}/#{repository}"
437
+ ref = "heads/#{branch}"
438
+ sha = client.ref(repo, ref).object.sha
439
+
440
+ # Create the commit status
441
+ client.create_status(repo, sha, status, options)
442
+ end
443
+
428
444
  # Builds an ssh repo URL using the org and repo name given
429
445
  def ssh_repo_url(name, org)
430
446
  "git@github.com:#{org}/#{name}.git"
@@ -101,6 +101,7 @@ module Dev
101
101
 
102
102
  DEV_COMMANDS_TOP_LEVEL.instance_eval do
103
103
  return if exclude.include?(:eol)
104
+ return if ENV.fetch('CHECK_AWS', nil).to_s.strip == 'false'
104
105
 
105
106
  task eol: [:'eol:aws'] do
106
107
  # This is just a placeholder to execute the dependencies
@@ -109,16 +110,12 @@ module Dev
109
110
  namespace :eol do
110
111
  desc 'Compares the current date to the EOL date for supported aws resources'
111
112
  task aws: %w(init ensure_aws_credentials) do
112
- next if ENV.fetch('CHECK_AWS', nil).to_s.strip == 'false'
113
-
114
- aws_products = Dev::EndOfLife::Aws.new.default_products
115
- next if aws_products.empty?
116
-
117
- puts
118
113
  account_id = Dev::Aws::Profile.new.current
119
114
  account_name = Dev::Aws::Account.new.name_by_account(account_id)
120
- puts "AWS product versions (in account #{account_name} / #{account_id})".light_yellow
121
- Dev::EndOfLife.new(product_versions: aws_products).status
115
+ LOG.info " Current AWS Account is #{account_name} (#{account_id})".light_yellow
116
+ puts
117
+ Dev::EndOfLife.new(product_versions: Dev::EndOfLife::Aws.new.default_products).status
118
+ puts
122
119
  end
123
120
  end
124
121
  end
@@ -163,33 +163,6 @@ module Dev
163
163
  end
164
164
  end
165
165
  end
166
-
167
- # Create the rake task for the node eol method
168
- def create_eol_task!
169
- # Have to set a local variable to be accessible inside of the instance_eval block
170
- exclude = @exclude
171
- node = @node
172
-
173
- DEV_COMMANDS_TOP_LEVEL.instance_eval do
174
- return if exclude.include?(:eol)
175
-
176
- task eol: [:'eol:node'] do
177
- # This is just a placeholder to execute the dependencies
178
- end
179
-
180
- namespace :eol do
181
- desc 'Compares the current date to the EOL date for supported packages in the node package file'
182
- task node: %w(init) do
183
- eol = Dev::EndOfLife::Node.new(node)
184
- node_products = eol.default_products
185
-
186
- puts
187
- puts "Node product versions (in #{eol.lockfile})".light_yellow
188
- Dev::EndOfLife.new(product_versions: node_products).status
189
- end
190
- end
191
- end
192
- end
193
166
  end
194
167
  end
195
168
  end
@@ -210,33 +210,6 @@ module Dev
210
210
  end
211
211
  end
212
212
  end
213
-
214
- # Create the rake task for the php eol method
215
- def create_eol_task!
216
- # Have to set a local variable to be accessible inside of the instance_eval block
217
- exclude = @exclude
218
- php = @php
219
-
220
- DEV_COMMANDS_TOP_LEVEL.instance_eval do
221
- return if exclude.include?(:eol)
222
-
223
- task eol: [:'eol:php'] do
224
- # Thie is just a placeholder to execute the dependencies
225
- end
226
-
227
- namespace :eol do
228
- desc 'Compares the current date to the EOL date for supported packages in the php package file'
229
- task php: %w(init) do
230
- eol = Dev::EndOfLife::Php.new(php)
231
- php_products = eol.default_products
232
-
233
- puts
234
- puts "Php product versions (in #{eol.lockfile})".light_yellow
235
- Dev::EndOfLife.new(product_versions: php_products).status
236
- end
237
- end
238
- end
239
- end
240
213
  end
241
214
  end
242
215
  end
@@ -163,33 +163,6 @@ module Dev
163
163
  end
164
164
  end
165
165
  end
166
-
167
- # Create the rake task for the ruby eol method
168
- def create_eol_task!
169
- # Have to set a local variable to be accessible inside of the instance_eval block
170
- exclude = @exclude
171
- ruby = @ruby
172
-
173
- DEV_COMMANDS_TOP_LEVEL.instance_eval do
174
- return if exclude.include?(:eol)
175
-
176
- task eol: [:'eol:ruby'] do
177
- # This is just a placeholder to execute the dependencies
178
- end
179
-
180
- namespace :eol do
181
- desc 'Compares the current date to the EOL date for supported packages in the ruby package file'
182
- task ruby: %w(init) do
183
- eol = Dev::EndOfLife::Ruby.new(ruby)
184
- ruby_products = eol.default_products
185
-
186
- puts
187
- puts "Ruby product versions (in #{eol.lockfile})".light_yellow
188
- Dev::EndOfLife.new(product_versions: ruby_products).status
189
- end
190
- end
191
- end
192
- end
193
166
  end
194
167
  end
195
168
  end
@@ -15,13 +15,7 @@ module Dev
15
15
  desc 'Compares the current date to the EOL date for all configured projects' \
16
16
  "\n\toptionally specify CHECK_AWS=<true/false> to toggle whether AWS resources are checked for EOL (defaults to true)"
17
17
  task eol: %w(init) do
18
- manual_products = Dev::EndOfLife.new.product_versions
19
- next if manual_products.empty?
20
-
21
- puts
22
- puts 'Manual product versions'
23
- Dev::EndOfLife.new(product_versions: manual_products).status
24
- puts
18
+ Dev::EndOfLife.new.status
25
19
  end
26
20
  end
27
21
  end
@@ -159,6 +159,49 @@ module Dev
159
159
  end
160
160
  end
161
161
  end
162
+
163
+ # Create the rake task for the git commit status task.
164
+ def create_commit_status_task!
165
+ # Have to set a local variable to be accessible inside of the instance_eval block
166
+ exclude = @exclude
167
+
168
+ DEV_COMMANDS_TOP_LEVEL.instance_eval do
169
+ namespace :git do
170
+ return if exclude.include?(:commit_status)
171
+
172
+ # TODO: Clean, comments and description
173
+ desc 'Add status to commit' \
174
+ "\n\tuse TODO"
175
+
176
+ task :create_commit_status do
177
+ # Key Values
178
+ repository = ENV['REPOSITORY'].to_s.strip
179
+ branch = ENV['BRANCH'].to_s.strip
180
+ status = ENV['STATUS'].to_s.strip
181
+
182
+ raise 'Repository name is required' unless repository
183
+ raise 'Branch name is required' unless branch
184
+ raise 'Status is required' unless status
185
+
186
+ # Validate status
187
+ valid_statuses = %w(error failure pending success)
188
+ raise "Invalid status: #{status}. Valid statuses are: #{valid_statuses.join(', ')}" unless valid_statuses.include?(status)
189
+
190
+ # Optional Values
191
+ context = ENV['CONTEXT'].to_s.strip
192
+ description = ENV['DESCRIPTION'].to_s.strip
193
+ target_url = ENV['TARGET_URL'].to_s.strip
194
+
195
+ options = {}
196
+ options[:context] = context unless context.empty?
197
+ options[:description] = description unless description.empty?
198
+ options[:target_url] = target_url unless target_url.empty?
199
+
200
+ Dev::Git.new.commit_status(repository:, branch:, status:, options:)
201
+ end
202
+ end
203
+ end
204
+ end
162
205
  end
163
206
  end
164
207
  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.36.pre.alpha.3'.freeze
9
+ VERSION = '2.1.37.pre.alpha.0'.freeze
10
10
  end
11
11
  end
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.36.pre.alpha.3
4
+ version: 2.1.37.pre.alpha.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Firespring
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-05-23 00:00:00.000000000 Z
11
+ date: 2024-06-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -262,6 +262,20 @@ dependencies:
262
262
  - - "~>"
263
263
  - !ruby/object:Gem::Version
264
264
  version: 2.3.0
265
+ - !ruby/object:Gem::Dependency
266
+ name: octokit
267
+ requirement: !ruby/object:Gem::Requirement
268
+ requirements:
269
+ - - "~>"
270
+ - !ruby/object:Gem::Version
271
+ version: '8.1'
272
+ type: :runtime
273
+ prerelease: false
274
+ version_requirements: !ruby/object:Gem::Requirement
275
+ requirements:
276
+ - - "~>"
277
+ - !ruby/object:Gem::Version
278
+ version: '8.1'
265
279
  - !ruby/object:Gem::Dependency
266
280
  name: ox
267
281
  requirement: !ruby/object:Gem::Requirement
@@ -361,10 +375,7 @@ files:
361
375
  - lib/firespring_dev_commands/env.rb
362
376
  - lib/firespring_dev_commands/eol.rb
363
377
  - lib/firespring_dev_commands/eol/aws.rb
364
- - lib/firespring_dev_commands/eol/node.rb
365
- - lib/firespring_dev_commands/eol/php.rb
366
378
  - lib/firespring_dev_commands/eol/product_version.rb
367
- - lib/firespring_dev_commands/eol/ruby.rb
368
379
  - lib/firespring_dev_commands/git.rb
369
380
  - lib/firespring_dev_commands/git/info.rb
370
381
  - lib/firespring_dev_commands/jira.rb
@@ -1,37 +0,0 @@
1
- module Dev
2
- class EndOfLife
3
- class Node
4
- attr_reader :node, :lockfile
5
-
6
- def initialize(node = Dev::Node.new)
7
- @node = node
8
- @lockfile = File.join(node.local_path, "#{node.package_file.reverse.split('.')[-1].reverse}-lock.json")
9
- end
10
-
11
- def default_products
12
- npm_products
13
- end
14
-
15
- def npm_products
16
- eol = Dev::EndOfLife.new
17
- major_version_only_products = %w(ckeditor vue jquery)
18
-
19
- [].tap do |ary|
20
- packages = JSON.parse(File.read(lockfile))&.fetch('packages', [])
21
- packages.each do |key, info|
22
- name = key.split('node_modules/').last
23
- product = name
24
-
25
- # Make sure what we found is supported by the EOL library
26
- next unless eol.product?(product)
27
-
28
- version = info['version'].reverse.split('.')[-2..].join('.').reverse.tr('v', '')
29
- version = version.split('.').first if major_version_only_products.include?(product)
30
- version.chop! if version.end_with?('.00')
31
- ary << Dev::EndOfLife::ProductVersion.new(product, version, name)
32
- end
33
- end
34
- end
35
- end
36
- end
37
- end
@@ -1,45 +0,0 @@
1
- module Dev
2
- class EndOfLife
3
- class Php
4
- attr_reader :php, :lockfile
5
-
6
- def initialize(php = Dev::Php.new)
7
- @php = php
8
- @lockfile = File.join(php.local_path, "#{php.package_file.reverse.split('.')[-1].reverse}.lock")
9
- end
10
-
11
- def default_products
12
- composer_products
13
- end
14
-
15
- def composer_products
16
- eol = Dev::EndOfLife.new
17
- major_version_only_products = ['laravel']
18
- laravel_products = ['laravel/framework']
19
- symfony_products = ['symfony/http-client', 'symfony/mailer', 'symfony/mailchimp-mailer']
20
-
21
- [].tap do |ary|
22
- packages = JSON.parse(File.read(lockfile))&.fetch('packages', [])
23
- packages&.each do |package|
24
- name = package['name']
25
- product = if laravel_products.include?(name)
26
- 'laravel'
27
- elsif symfony_products.include?(name)
28
- 'symfony'
29
- else
30
- name
31
- end
32
-
33
- # Make sure what we found is supported by the EOL library
34
- next unless eol.product?(product)
35
-
36
- version = package['version'].reverse.split('.')[-2..].join('.').reverse.tr('v', '')
37
- version = version.split('.').first if major_version_only_products.include?(product)
38
- version.chop! if version.end_with?('.00')
39
- ary << Dev::EndOfLife::ProductVersion.new(product, version, name)
40
- end
41
- end
42
- end
43
- end
44
- end
45
- end
@@ -1,37 +0,0 @@
1
- module Dev
2
- class EndOfLife
3
- class Ruby
4
- attr_reader :ruby, :lockfile
5
-
6
- def initialize(ruby = Dev::Ruby.new)
7
- @ruby = ruby
8
- @lockfile = File.join(ruby.local_path, "#{ruby.package_file.reverse.split('.')[-1].reverse}.lock")
9
- end
10
-
11
- def default_products
12
- composer_products
13
- end
14
-
15
- def composer_products
16
- eol = Dev::EndOfLife.new
17
- major_version_only_products = []
18
-
19
- [].tap do |ary|
20
- packages = Bundler::LockfileParser.new(Bundler.read_file(lockfile)).specs
21
- packages.each do |package|
22
- name = package.name
23
- product = name
24
-
25
- # Make sure what we found is supported by the EOL library
26
- next unless eol.product?(product)
27
-
28
- version = package.version.to_s.reverse.split('.')[-2..].join('.').reverse.tr('v', '')
29
- version = version.split('.').first if major_version_only_products.include?(product)
30
- version.chop! if version.end_with?('.00')
31
- ary << Dev::EndOfLife::ProductVersion.new(product, version, name)
32
- end
33
- end
34
- end
35
- end
36
- end
37
- end