firespring_dev_commands 3.0.2.pre.alpha.0 → 3.1.1.pre.alpha.1

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: eafd206b2464356f3683dc781936eb3cc5ca1296ed130b360bc6d7ecb218f1c5
4
- data.tar.gz: 416a0585f3974ad8435422efb986154f2027e6665fa670ae142cbf9c9ba8af25
3
+ metadata.gz: 3f94e32731400739d8075ea5058a32cc18bed77f483e285a66ac0ac12f6be22b
4
+ data.tar.gz: b5d4ef361a9c41810241ce54dae2dc5f5c9a18ee7f57ec79048a9ac41e8ad4b8
5
5
  SHA512:
6
- metadata.gz: a4f6dc58f90b3dfdf2d0ba614f830024548dce70788afdeb5bf9dba0b5c3cd1b3bd01cb28b8955c02e4ac033a4246a3f3455e023c813553da758e0bd83516bf1
7
- data.tar.gz: 97e72febb58871e687893ec32f68d5fd7942987e572bd70b27d064c76f65fc7c0d1417591bfd68c5634b36e01c8662c8404cb18e821b3a2a483c589e8c9808ed
6
+ metadata.gz: ce8a4c18e3e24c4481ef1e2c5a35b5be2c0302c83f6bf63479ac10f6140b1878a6a4eef95146897ae1733b995c5ee8cdb78210477aad41d4a0c75601c306c5a8
7
+ data.tar.gz: 324df36527d37f220dc6be19ce93aed760e5f9d7b954db251a2516a99656b0a6bdab467ea949204040adb99cae3f0b1d1e6786e0fd415164a9afd3c278a670bf
@@ -0,0 +1,42 @@
1
+ module Dev
2
+ class EndOfLife
3
+ # Class which checks for eol packges referenced by the node package manager
4
+ class Node
5
+ attr_reader :node, :lockfile
6
+
7
+ def initialize(node = Dev::Node.new)
8
+ @node = node
9
+ @lockfile = File.join(node.local_path, "#{node.package_file.reverse.split('.')[-1].reverse}-lock.json")
10
+ end
11
+
12
+ # Default to NPM products
13
+ def default_products
14
+ npm_products
15
+ end
16
+
17
+ # 1.) Parse the npm lock file
18
+ # 2.) Do some package name and version manipulation
19
+ # 3.) Return the product if it looks like something that the EOL library tracks
20
+ def npm_products
21
+ eol = Dev::EndOfLife.new
22
+ major_version_only_products = %w(ckeditor vue jquery)
23
+
24
+ [].tap do |ary|
25
+ packages = JSON.parse(File.read(lockfile))&.fetch('packages', [])
26
+ packages.each do |key, info|
27
+ name = key.split('node_modules/').last
28
+ product = name
29
+
30
+ # Make sure what we found is supported by the EOL library
31
+ next unless eol.product?(product)
32
+
33
+ version = info['version'].reverse.split('.')[-2..].join('.').reverse.tr('v', '')
34
+ version = version.split('.').first if major_version_only_products.include?(product)
35
+ version.chop! if version.end_with?('.00')
36
+ ary << Dev::EndOfLife::ProductVersion.new(product, version, name)
37
+ end
38
+ end
39
+ end
40
+ end
41
+ end
42
+ end
@@ -0,0 +1,50 @@
1
+ module Dev
2
+ class EndOfLife
3
+ # Class which checks for eol packges referenced by the php package manager
4
+ class Php
5
+ attr_reader :php, :lockfile
6
+
7
+ def initialize(php = Dev::Php.new)
8
+ @php = php
9
+ @lockfile = File.join(php.local_path, "#{php.package_file.reverse.split('.')[-1].reverse}.lock")
10
+ end
11
+
12
+ # Default to Composer products
13
+ def default_products
14
+ composer_products
15
+ end
16
+
17
+ # 1.) Parse the composer lock file
18
+ # 2.) Do some package name and version manipulation
19
+ # 3.) Return the product if it looks like something that the EOL library tracks
20
+ def composer_products
21
+ eol = Dev::EndOfLife.new
22
+ major_version_only_products = ['laravel']
23
+ laravel_products = ['laravel/framework']
24
+ symfony_products = ['symfony/http-client', 'symfony/mailer', 'symfony/mailchimp-mailer']
25
+
26
+ [].tap do |ary|
27
+ packages = JSON.parse(File.read(lockfile))&.fetch('packages', [])
28
+ packages&.each do |package|
29
+ name = package['name']
30
+ product = if laravel_products.include?(name)
31
+ 'laravel'
32
+ elsif symfony_products.include?(name)
33
+ 'symfony'
34
+ else
35
+ name
36
+ end
37
+
38
+ # Make sure what we found is supported by the EOL library
39
+ next unless eol.product?(product)
40
+
41
+ version = package['version'].reverse.split('.')[-2..].join('.').reverse.tr('v', '')
42
+ version = version.split('.').first if major_version_only_products.include?(product)
43
+ version.chop! if version.end_with?('.00')
44
+ ary << Dev::EndOfLife::ProductVersion.new(product, version, name)
45
+ end
46
+ end
47
+ end
48
+ end
49
+ end
50
+ end
@@ -0,0 +1,42 @@
1
+ module Dev
2
+ class EndOfLife
3
+ # Class which checks for eol packges referenced by the ruby package manager
4
+ class Ruby
5
+ attr_reader :ruby, :lockfile
6
+
7
+ def initialize(ruby = Dev::Ruby.new)
8
+ @ruby = ruby
9
+ @lockfile = File.join(ruby.local_path, "#{ruby.package_file.reverse.split('.')[-1].reverse}.lock")
10
+ end
11
+
12
+ # Default to Rubygems products
13
+ def default_products
14
+ rubygems_products
15
+ end
16
+
17
+ # 1.) Parse the rubygems lock file
18
+ # 2.) Do some package name and version manipulation
19
+ # 3.) Return the product if it looks like something that the EOL library tracks
20
+ def rubygems_products
21
+ eol = Dev::EndOfLife.new
22
+ major_version_only_products = []
23
+
24
+ [].tap do |ary|
25
+ packages = Bundler::LockfileParser.new(Bundler.read_file(lockfile)).specs
26
+ packages.each do |package|
27
+ name = package.name
28
+ product = name
29
+
30
+ # Make sure what we found is supported by the EOL library
31
+ next unless eol.product?(product)
32
+
33
+ version = package.version.to_s.reverse.split('.')[-2..].join('.').reverse.tr('v', '')
34
+ version = version.split('.').first if major_version_only_products.include?(product)
35
+ version.chop! if version.end_with?('.00')
36
+ ary << Dev::EndOfLife::ProductVersion.new(product, version, name)
37
+ end
38
+ end
39
+ end
40
+ end
41
+ end
42
+ end
@@ -46,8 +46,18 @@ 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
+
49
54
  # Prints all of the product version statuses
50
55
  def status
56
+ if product_versions.empty?
57
+ puts ' no tracked products'
58
+ return
59
+ end
60
+
51
61
  product_versions.sort_by(&:name).each(&:print_status)
52
62
  end
53
63
 
@@ -1,6 +1,5 @@
1
1
  require 'fileutils'
2
2
  require 'git'
3
- require 'octokit'
4
3
 
5
4
  module Dev
6
5
  # Class for performing git functions
@@ -97,7 +96,8 @@ module Dev
97
96
  def branch_name(dir: default_project_dir)
98
97
  return unless File.exist?(dir)
99
98
 
100
- ::Git.open(dir).current_branch
99
+ g = ::Git.open(dir)
100
+ g.current_branch || "HEAD detached at #{g.object('HEAD').sha[0..7]}"
101
101
  end
102
102
 
103
103
  # Returns true if the remote branch exists, false otherwise
@@ -425,22 +425,6 @@ 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
-
444
428
  # Builds an ssh repo URL using the org and repo name given
445
429
  def ssh_repo_url(name, org)
446
430
  "git@github.com:#{org}/#{name}.git"
@@ -18,6 +18,22 @@ module Dev
18
18
  end
19
19
  end
20
20
 
21
+ # Create the rake task which shows the current AWS account information
22
+ def create_show_account_info_task!
23
+ # Have to set a local variable to be accessible inside of the instance_eval block
24
+ exclude = @exclude
25
+
26
+ DEV_COMMANDS_TOP_LEVEL.instance_eval do
27
+ return if exclude.include?(:show_account_info)
28
+
29
+ task show_account_info: %w(init ensure_aws_credentials) do
30
+ account_id = Dev::Aws::Credentials.new.logged_in_account
31
+ account_name = Dev::Aws::Account.new.name_by_account(account_id)
32
+ LOG.info "\n Current AWS Account is #{account_name} (#{account_id})\n".light_yellow
33
+ end
34
+ end
35
+ end
36
+
21
37
  # Create the rake task for the aws profile method
22
38
  def create_profile_task!
23
39
  # Have to set a local variable to be accessible inside of the instance_eval block
@@ -99,7 +115,6 @@ module Dev
99
115
 
100
116
  DEV_COMMANDS_TOP_LEVEL.instance_eval do
101
117
  return if exclude.include?(:eol)
102
- return if ENV.fetch('CHECK_AWS', nil).to_s.strip == 'false'
103
118
 
104
119
  task eol: [:'eol:aws'] do
105
120
  # This is just a placeholder to execute the dependencies
@@ -108,12 +123,16 @@ module Dev
108
123
  namespace :eol do
109
124
  desc 'Compares the current date to the EOL date for supported aws resources'
110
125
  task aws: %w(init ensure_aws_credentials) do
126
+ next if ENV.fetch('CHECK_AWS', nil).to_s.strip == 'false'
127
+
128
+ aws_products = Dev::EndOfLife::Aws.new.default_products
129
+ next if aws_products.empty?
130
+
131
+ puts
111
132
  account_id = Dev::Aws::Profile.new.current
112
133
  account_name = Dev::Aws::Account.new.name_by_account(account_id)
113
- LOG.info " Current AWS Account is #{account_name} (#{account_id})".light_yellow
114
- puts
115
- Dev::EndOfLife.new(product_versions: Dev::EndOfLife::Aws.new.default_products).status
116
- puts
134
+ puts "AWS product versions (in account #{account_name} / #{account_id})".light_yellow
135
+ Dev::EndOfLife.new(product_versions: aws_products).status
117
136
  end
118
137
  end
119
138
  end
@@ -20,15 +20,17 @@ module Dev
20
20
  # Have to set a local variable to be accessible inside of the instance_eval block
21
21
  exclude = @exclude
22
22
  cloudformations = @cloudformations
23
- return if exclude.include?(:status)
23
+ return if exclude.include?(:create)
24
24
 
25
25
  DEV_COMMANDS_TOP_LEVEL.instance_eval do
26
26
  namespace :ci do
27
27
  desc 'Create the ci cloudformation stack in aws'
28
- task create: %w(init ensure_aws_credentials) do
29
- LOG.info
28
+ task create: %w(init ensure_aws_credentials show_account_info) do
30
29
  next if cloudformations.empty?
31
30
 
31
+ names = cloudformations.map(&:name).join(', ')
32
+ Dev::Common.new.exit_unless_confirmed(" This will create the #{names} pipelins. Continue?")
33
+
32
34
  # Start create on all stacks without waiting so they are created in parallel
33
35
  cloudformations.each do |cloudformation|
34
36
  next if cloudformation.exist?
@@ -53,15 +55,17 @@ module Dev
53
55
  # Have to set a local variable to be accessible inside of the instance_eval block
54
56
  exclude = @exclude
55
57
  cloudformations = @cloudformations
56
- return if exclude.include?(:status)
58
+ return if exclude.include?(:update)
57
59
 
58
60
  DEV_COMMANDS_TOP_LEVEL.instance_eval do
59
61
  namespace :ci do
60
62
  desc 'Update the ci cloudformation stack in aws'
61
- task update: %w(init ensure_aws_credentials) do
62
- LOG.info
63
+ task update: %w(init ensure_aws_credentials show_account_info) do
63
64
  next if cloudformations.empty?
64
65
 
66
+ names = cloudformations.map(&:name).join(', ')
67
+ Dev::Common.new.exit_unless_confirmed(" This will update the #{names} pipelins. Continue?")
68
+
65
69
  # Start update on all stacks without waiting so they are updated in parallel
66
70
  cloudformations.each do |cloudformation|
67
71
  next unless cloudformation.exist?
@@ -86,15 +90,17 @@ module Dev
86
90
  # Have to set a local variable to be accessible inside of the instance_eval block
87
91
  exclude = @exclude
88
92
  cloudformations = @cloudformations
89
- return if exclude.include?(:status)
93
+ return if exclude.include?(:delete)
90
94
 
91
95
  DEV_COMMANDS_TOP_LEVEL.instance_eval do
92
96
  namespace :ci do
93
97
  desc 'Delete the ci cloudformation stack in aws'
94
- task delete: %w(init ensure_aws_credentials) do
95
- LOG.info
98
+ task delete: %w(init ensure_aws_credentials show_account_info) do
96
99
  next if cloudformations.empty?
97
100
 
101
+ names = cloudformations.map(&:name).join(', ')
102
+ Dev::Common.new.exit_unless_confirmed(" This will delete the #{names} pipelins. Continue?")
103
+
98
104
  # Start delete on all stacks without waiting so they are deleted in parallel
99
105
  cloudformations.each do |cloudformation|
100
106
  next unless cloudformation.exist?
@@ -124,8 +130,7 @@ module Dev
124
130
  DEV_COMMANDS_TOP_LEVEL.instance_eval do
125
131
  namespace :ci do
126
132
  desc 'Show the current status of the pipelines associated with your branch'
127
- task status: %w(init ensure_aws_credentials) do
128
- LOG.info
133
+ task status: %w(init ensure_aws_credentials show_account_info) do
129
134
  next if cloudformations.empty?
130
135
 
131
136
  pattern = /#{cloudformations.map(&:name).join('|')}/
@@ -214,6 +214,33 @@ module Dev
214
214
  end
215
215
  end
216
216
  end
217
+
218
+ # Create the rake task for the node eol method
219
+ def create_eol_task!
220
+ # Have to set a local variable to be accessible inside of the instance_eval block
221
+ exclude = @exclude
222
+ node = @node
223
+
224
+ DEV_COMMANDS_TOP_LEVEL.instance_eval do
225
+ return if exclude.include?(:eol)
226
+
227
+ task eol: [:'eol:node'] do
228
+ # This is just a placeholder to execute the dependencies
229
+ end
230
+
231
+ namespace :eol do
232
+ desc 'Compares the current date to the EOL date for supported packages in the node package file'
233
+ task node: %w(init) do
234
+ eol = Dev::EndOfLife::Node.new(node)
235
+ node_products = eol.default_products
236
+
237
+ puts
238
+ puts "Node product versions (in #{eol.lockfile})".light_yellow
239
+ Dev::EndOfLife.new(product_versions: node_products).status
240
+ end
241
+ end
242
+ end
243
+ end
217
244
  end
218
245
  end
219
246
  end
@@ -260,6 +260,33 @@ module Dev
260
260
  end
261
261
  end
262
262
  end
263
+
264
+ # Create the rake task for the php eol method
265
+ def create_eol_task!
266
+ # Have to set a local variable to be accessible inside of the instance_eval block
267
+ exclude = @exclude
268
+ php = @php
269
+
270
+ DEV_COMMANDS_TOP_LEVEL.instance_eval do
271
+ return if exclude.include?(:eol)
272
+
273
+ task eol: [:'eol:php'] do
274
+ # Thie is just a placeholder to execute the dependencies
275
+ end
276
+
277
+ namespace :eol do
278
+ desc 'Compares the current date to the EOL date for supported packages in the php package file'
279
+ task php: %w(init) do
280
+ eol = Dev::EndOfLife::Php.new(php)
281
+ php_products = eol.default_products
282
+
283
+ puts
284
+ puts "Php product versions (in #{eol.lockfile})".light_yellow
285
+ Dev::EndOfLife.new(product_versions: php_products).status
286
+ end
287
+ end
288
+ end
289
+ end
263
290
  end
264
291
  end
265
292
  end
@@ -215,6 +215,33 @@ module Dev
215
215
  end
216
216
  end
217
217
  end
218
+
219
+ # Create the rake task for the ruby eol method
220
+ def create_eol_task!
221
+ # Have to set a local variable to be accessible inside of the instance_eval block
222
+ exclude = @exclude
223
+ ruby = @ruby
224
+
225
+ DEV_COMMANDS_TOP_LEVEL.instance_eval do
226
+ return if exclude.include?(:eol)
227
+
228
+ task eol: [:'eol:ruby'] do
229
+ # This is just a placeholder to execute the dependencies
230
+ end
231
+
232
+ namespace :eol do
233
+ desc 'Compares the current date to the EOL date for supported packages in the ruby package file'
234
+ task ruby: %w(init) do
235
+ eol = Dev::EndOfLife::Ruby.new(ruby)
236
+ ruby_products = eol.default_products
237
+
238
+ puts
239
+ puts "Ruby product versions (in #{eol.lockfile})".light_yellow
240
+ Dev::EndOfLife.new(product_versions: ruby_products).status
241
+ end
242
+ end
243
+ end
244
+ end
218
245
  end
219
246
  end
220
247
  end
@@ -15,7 +15,13 @@ 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
- Dev::EndOfLife.new.status
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
19
25
  end
20
26
  end
21
27
  end
@@ -159,49 +159,6 @@ 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
205
162
  end
206
163
  end
207
164
  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 = '3.0.2.pre.alpha.0'.freeze
9
+ VERSION = '3.1.1.pre.alpha.1'.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: 3.0.2.pre.alpha.0
4
+ version: 3.1.1.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: 2024-06-03 00:00:00.000000000 Z
11
+ date: 2024-06-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -262,20 +262,6 @@ 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'
279
265
  - !ruby/object:Gem::Dependency
280
266
  name: ox
281
267
  requirement: !ruby/object:Gem::Requirement
@@ -376,7 +362,10 @@ files:
376
362
  - lib/firespring_dev_commands/env.rb
377
363
  - lib/firespring_dev_commands/eol.rb
378
364
  - lib/firespring_dev_commands/eol/aws.rb
365
+ - lib/firespring_dev_commands/eol/node.rb
366
+ - lib/firespring_dev_commands/eol/php.rb
379
367
  - lib/firespring_dev_commands/eol/product_version.rb
368
+ - lib/firespring_dev_commands/eol/ruby.rb
380
369
  - lib/firespring_dev_commands/git.rb
381
370
  - lib/firespring_dev_commands/git/info.rb
382
371
  - lib/firespring_dev_commands/jira.rb