firespring_dev_commands 1.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.
Files changed (59) hide show
  1. checksums.yaml +7 -0
  2. data/LICENSE +21 -0
  3. data/README.md +83 -0
  4. data/lib/firespring_dev_commands/audit/report/item.rb +33 -0
  5. data/lib/firespring_dev_commands/audit/report/levels.rb +36 -0
  6. data/lib/firespring_dev_commands/audit/report.rb +49 -0
  7. data/lib/firespring_dev_commands/aws/account/info.rb +15 -0
  8. data/lib/firespring_dev_commands/aws/account.rb +164 -0
  9. data/lib/firespring_dev_commands/aws/cloudformation/parameters.rb +26 -0
  10. data/lib/firespring_dev_commands/aws/cloudformation.rb +188 -0
  11. data/lib/firespring_dev_commands/aws/codepipeline.rb +96 -0
  12. data/lib/firespring_dev_commands/aws/credentials.rb +136 -0
  13. data/lib/firespring_dev_commands/aws/login.rb +131 -0
  14. data/lib/firespring_dev_commands/aws/parameter.rb +32 -0
  15. data/lib/firespring_dev_commands/aws/profile.rb +55 -0
  16. data/lib/firespring_dev_commands/aws/s3.rb +42 -0
  17. data/lib/firespring_dev_commands/aws.rb +10 -0
  18. data/lib/firespring_dev_commands/boolean.rb +7 -0
  19. data/lib/firespring_dev_commands/common.rb +112 -0
  20. data/lib/firespring_dev_commands/daterange.rb +171 -0
  21. data/lib/firespring_dev_commands/docker/compose.rb +271 -0
  22. data/lib/firespring_dev_commands/docker/status.rb +38 -0
  23. data/lib/firespring_dev_commands/docker.rb +276 -0
  24. data/lib/firespring_dev_commands/dotenv.rb +6 -0
  25. data/lib/firespring_dev_commands/env.rb +38 -0
  26. data/lib/firespring_dev_commands/eol/product_version.rb +86 -0
  27. data/lib/firespring_dev_commands/eol.rb +58 -0
  28. data/lib/firespring_dev_commands/git/info.rb +13 -0
  29. data/lib/firespring_dev_commands/git.rb +420 -0
  30. data/lib/firespring_dev_commands/jira/issue.rb +33 -0
  31. data/lib/firespring_dev_commands/jira/project.rb +13 -0
  32. data/lib/firespring_dev_commands/jira/user/type.rb +20 -0
  33. data/lib/firespring_dev_commands/jira/user.rb +31 -0
  34. data/lib/firespring_dev_commands/jira.rb +78 -0
  35. data/lib/firespring_dev_commands/logger.rb +8 -0
  36. data/lib/firespring_dev_commands/node/audit.rb +39 -0
  37. data/lib/firespring_dev_commands/node.rb +107 -0
  38. data/lib/firespring_dev_commands/php/audit.rb +71 -0
  39. data/lib/firespring_dev_commands/php.rb +109 -0
  40. data/lib/firespring_dev_commands/rake.rb +24 -0
  41. data/lib/firespring_dev_commands/ruby/audit.rb +30 -0
  42. data/lib/firespring_dev_commands/ruby.rb +113 -0
  43. data/lib/firespring_dev_commands/second.rb +22 -0
  44. data/lib/firespring_dev_commands/tar/pax_header.rb +49 -0
  45. data/lib/firespring_dev_commands/tar/type_flag.rb +49 -0
  46. data/lib/firespring_dev_commands/tar.rb +149 -0
  47. data/lib/firespring_dev_commands/templates/aws.rb +84 -0
  48. data/lib/firespring_dev_commands/templates/base_interface.rb +54 -0
  49. data/lib/firespring_dev_commands/templates/ci.rb +138 -0
  50. data/lib/firespring_dev_commands/templates/docker/application.rb +177 -0
  51. data/lib/firespring_dev_commands/templates/docker/default.rb +200 -0
  52. data/lib/firespring_dev_commands/templates/docker/node/application.rb +145 -0
  53. data/lib/firespring_dev_commands/templates/docker/php/application.rb +190 -0
  54. data/lib/firespring_dev_commands/templates/docker/ruby/application.rb +146 -0
  55. data/lib/firespring_dev_commands/templates/eol.rb +23 -0
  56. data/lib/firespring_dev_commands/templates/git.rb +147 -0
  57. data/lib/firespring_dev_commands/version.rb +11 -0
  58. data/lib/firespring_dev_commands.rb +21 -0
  59. metadata +436 -0
@@ -0,0 +1,200 @@
1
+ require_relative '../base_interface'
2
+
3
+ module Dev
4
+ module Template
5
+ # Module containing all default docker rake tasks
6
+ module Docker
7
+ # Class containing default rake tasks which are application agnostic (run against all containers)
8
+ class Default < Dev::Template::BaseInterface
9
+ # Create the rake task which runs a docker compose build
10
+ def create_build_task!
11
+ exclude = @exclude
12
+
13
+ DEV_COMMANDS_TOP_LEVEL.instance_eval do
14
+ return if exclude.include?(:build)
15
+
16
+ desc 'Builds all images used by services in the compose files' \
17
+ "\n\toptionally specify NO_CACHE=true to not use build cache" \
18
+ "\n\toptionally specify PULL=true to force pulling new base images"
19
+ task build: %w(init_docker) do
20
+ LOG.debug('In base build')
21
+ Dev::Docker::Compose.new.build
22
+ end
23
+ end
24
+ end
25
+
26
+ # Create the rake task which runs a docker compose up
27
+ def create_up_task!
28
+ exclude = @exclude
29
+
30
+ DEV_COMMANDS_TOP_LEVEL.instance_eval do
31
+ return if exclude.include?(:up)
32
+
33
+ desc 'Starts containers for all services listed in the compose files' \
34
+ "\n\toptionally specify DETACHED=false to not detach from the started services"
35
+ task up: %w(init_docker) do
36
+ LOG.debug('In base up')
37
+ Dev::Docker::Compose.new.up
38
+ end
39
+ end
40
+ end
41
+
42
+ # Create the rake task which runs a docker compose logs
43
+ def create_logs_task!
44
+ exclude = @exclude
45
+
46
+ DEV_COMMANDS_TOP_LEVEL.instance_eval do
47
+ return if exclude.include?(:logs)
48
+
49
+ desc 'Connects to the output stream of all running containers' \
50
+ "\n\toptionally specify NO_FOLLOW=true to print all current output and exit" \
51
+ "\n\toptionally specify TAIL=n to print the last 'n' lines of output"
52
+ task logs: %w(init_docker) do
53
+ LOG.debug('In base logs')
54
+ Dev::Docker::Compose.new.logs
55
+ end
56
+ end
57
+ end
58
+
59
+ # Create the rake task which runs a docker compose down
60
+ def create_down_task!
61
+ exclude = @exclude
62
+
63
+ DEV_COMMANDS_TOP_LEVEL.instance_eval do
64
+ return if exclude.include?(:down)
65
+
66
+ desc 'Stops and removes containers and associated resources' \
67
+ "\n\toptionally specify REMOVE_VOLUMES=true to also remove unused volumes"
68
+ task down: %w(init_docker) do
69
+ LOG.debug('In base down')
70
+ Dev::Docker::Compose.new.down
71
+ end
72
+ end
73
+ end
74
+
75
+ # Create the rake task which runs a docker compose down followed by an up
76
+ def create_reload_task!
77
+ exclude = @exclude
78
+
79
+ DEV_COMMANDS_TOP_LEVEL.instance_eval do
80
+ return if exclude.include?(:reload)
81
+
82
+ desc 'Runs a "down" followed by an "up"'
83
+ task reload: %w(down up) do
84
+ LOG.debug('In reload')
85
+ end
86
+ end
87
+ end
88
+
89
+ # Create the rake task which runs a docker compose clean
90
+ def create_clean_task!
91
+ exclude = @exclude
92
+
93
+ DEV_COMMANDS_TOP_LEVEL.instance_eval do
94
+ return if exclude.include?(:clean)
95
+
96
+ desc 'Removes all stopped containers and unused images, volumes, and networks'
97
+ task clean: %w(init_docker) do
98
+ LOG.debug 'In base clean'
99
+ Dev::Docker.new.prune
100
+ LOG.info
101
+ end
102
+ task prune: [:clean] do
103
+ # This is an alias to the clean command
104
+ end
105
+ end
106
+ end
107
+
108
+ # Create the rake task which runs a docker compose push
109
+ def create_push_task!
110
+ exclude = @exclude
111
+
112
+ DEV_COMMANDS_TOP_LEVEL.instance_eval do
113
+ return if exclude.include?(:push)
114
+
115
+ desc 'Push all local images to their defined image repository'
116
+ task push: %w(init_docker) do
117
+ LOG.debug 'In base push'
118
+ Dev::Docker::Compose.new.push
119
+ end
120
+ end
121
+ end
122
+
123
+ # Create the rake task which runs a docker compose pull
124
+ def create_pull_task!
125
+ exclude = @exclude
126
+
127
+ DEV_COMMANDS_TOP_LEVEL.instance_eval do
128
+ return if exclude.include?(:pull)
129
+
130
+ desc 'Pull all images from their defined image repository'
131
+ task pull: %w(init_docker) do
132
+ LOG.debug 'In base pull'
133
+ Dev::Docker::Compose.new.pull
134
+ end
135
+ end
136
+ end
137
+
138
+ # Create the rake task which shows all docker images on the system
139
+ def create_images_task!
140
+ exclude = @exclude
141
+
142
+ DEV_COMMANDS_TOP_LEVEL.instance_eval do
143
+ return if exclude.include?(:images)
144
+
145
+ desc 'Print a table of all images' \
146
+ "\n\t(equivalent to docker images)"
147
+ task images: %w(init_docker) do
148
+ Dev::Docker.new.print_images
149
+ end
150
+ end
151
+ end
152
+
153
+ # Create the rake task which shows all docker containers on the system
154
+ def create_ps_task!
155
+ exclude = @exclude
156
+
157
+ DEV_COMMANDS_TOP_LEVEL.instance_eval do
158
+ return if exclude.include?(:ps)
159
+
160
+ desc 'Print a table of all running containers' \
161
+ "\n\t(equivalent to docker ps)"
162
+ task ps: %w(init_docker) do
163
+ Dev::Docker.new.print_containers
164
+ end
165
+ end
166
+ end
167
+
168
+ # Create the rake task which shows all docker images on the system
169
+ def create_images_task!
170
+ exclude = @exclude
171
+
172
+ DEV_COMMANDS_TOP_LEVEL.instance_eval do
173
+ unless exclude.include?(:images)
174
+ desc 'Print a table of all images' \
175
+ "\n\t(equivalent to docker images)"
176
+ task images: [:init] do
177
+ Dev::Docker.new.print_images
178
+ end
179
+ end
180
+ end
181
+ end
182
+
183
+ # Create the rake task which shows all docker containers on the system
184
+ def create_ps_task!
185
+ exclude = @exclude
186
+
187
+ DEV_COMMANDS_TOP_LEVEL.instance_eval do
188
+ unless exclude.include?(:ps)
189
+ desc 'Print a table of all running containers' \
190
+ "\n\t(equivalent to docker ps)"
191
+ task ps: [:init] do
192
+ Dev::Docker.new.print_containers
193
+ end
194
+ end
195
+ end
196
+ end
197
+ end
198
+ end
199
+ end
200
+ end
@@ -0,0 +1,145 @@
1
+ require_relative '../../base_interface'
2
+
3
+ module Dev
4
+ module Template
5
+ module Docker
6
+ # Module for rake tasks associated with node applications
7
+ module Node
8
+ # Class for default rake tasks associated with a node project
9
+ class Application < Dev::Template::ApplicationInterface
10
+ # Allow for custom container path for the application
11
+ def initialize(application, container_path: nil, local_path: nil, exclude: [])
12
+ @node = Dev::Node.new(container_path: container_path, local_path: local_path)
13
+ super(application, exclude: exclude)
14
+ end
15
+
16
+ # Create the rake task which runs linting for the application name
17
+ def create_lint_task!
18
+ application = @name
19
+ node = @node
20
+ exclude = @exclude
21
+ return if exclude.include?(:lint)
22
+
23
+ DEV_COMMANDS_TOP_LEVEL.instance_eval do
24
+ namespace application do
25
+ desc 'Run all linting software'
26
+ task lint: %w(node:lint) do
27
+ # This is just a placeholder to execute the dependencies
28
+ end
29
+
30
+ namespace :node do
31
+ desc "Run the node linting software against the #{application}'s codebase"
32
+ task lint: %w(init_docker up_no_deps) do
33
+ LOG.debug('Check for node linting errors')
34
+
35
+ options = []
36
+ options << '-T' if Dev::Common.new.running_codebuild?
37
+ Dev::Docker::Compose.new(services: application, options: options).exec(*node.lint_command)
38
+ end
39
+
40
+ namespace :lint do
41
+ desc "Run the linting software against the #{application}'s codebase and apply all available fixes"
42
+ task fix: %w(init_docker up_no_deps) do
43
+ LOG.debug('Check and fix linting errors')
44
+
45
+ options = []
46
+ options << '-T' if Dev::Common.new.running_codebuild?
47
+ Dev::Docker::Compose.new(services: application, options: options).exec(*node.lint_fix_command)
48
+ end
49
+ end
50
+ end
51
+ end
52
+ end
53
+ end
54
+
55
+ # Create the rake task which runs all tests for the application name
56
+ def create_test_task!
57
+ application = @name
58
+ node = @node
59
+ exclude = @exclude
60
+ return if exclude.include?(:test)
61
+
62
+ DEV_COMMANDS_TOP_LEVEL.instance_eval do
63
+ namespace application do
64
+ desc 'Run all tests'
65
+ task test: %w(node:test) do
66
+ # This is just a placeholder to execute the dependencies
67
+ end
68
+
69
+ namespace :node do
70
+ desc "Run all node tests against the #{application}'s codebase"
71
+ task test: %w(init_docker up) do
72
+ LOG.debug("Running all node tests in the #{application} codebase")
73
+
74
+ options = []
75
+ options << '-T' if Dev::Common.new.running_codebuild?
76
+ Dev::Docker::Compose.new(services: application, options: options).exec(*node.test_command)
77
+ end
78
+ end
79
+ end
80
+ end
81
+ end
82
+
83
+ # Create the rake task which runs the install command for the application packages
84
+ def create_install_task!
85
+ # Have to set a local variable to be accessible inside of the instance_eval block
86
+ application = @name
87
+ node = @node
88
+ exclude = @exclude
89
+ return if exclude.include?(:install)
90
+
91
+ DEV_COMMANDS_TOP_LEVEL.instance_eval do
92
+ namespace application do
93
+ namespace :node do
94
+ desc 'Install all npm packages'
95
+ task install: %w(init_docker up_no_deps) do
96
+ Dev::Docker::Compose.new(services: application).exec(*node.install_command)
97
+ end
98
+ end
99
+ end
100
+ end
101
+ end
102
+
103
+ # Create the rake tasks which runs the security audits of application packages
104
+ def create_audit_task!
105
+ # Have to set a local variable to be accessible inside of the instance_eval block
106
+ application = @name
107
+ node = @node
108
+ exclude = @exclude
109
+ return if exclude.include?(:audit)
110
+
111
+ DEV_COMMANDS_TOP_LEVEL.instance_eval do
112
+ namespace application do
113
+ desc 'Run all security audits'
114
+ task audit: %w(node:audit) do
115
+ # This is just a placeholder to execute the dependencies
116
+ end
117
+
118
+ namespace :node do
119
+ desc 'Run NPM Audit on the target application' \
120
+ "\n\tuse MIN_SEVERITY=(info low moderate high critical) to fetch only severity type selected and above (default=high)." \
121
+ "\n\tuse IGNORELIST=(comma delimited list of ids) removes the entry from the list."
122
+ task audit: %w(init_docker up_no_deps) do
123
+ opts = []
124
+ opts << '-T' if Dev::Common.new.running_codebuild?
125
+
126
+ # Retrieve results of the scan.
127
+ data = Dev::Docker::Compose.new(services: application, options: opts, capture: true).exec(*node.audit_command)
128
+ Dev::Node::Audit.new(data).to_report.check
129
+ end
130
+
131
+ namespace :audit do
132
+ desc 'Run NPM Audit fix command'
133
+ task fix: %w(init_docker up_no_deps) do
134
+ Dev::Docker::Compose.new(services: application).exec(*node.audit_fix_command)
135
+ end
136
+ end
137
+ end
138
+ end
139
+ end
140
+ end
141
+ end
142
+ end
143
+ end
144
+ end
145
+ end
@@ -0,0 +1,190 @@
1
+ require_relative '../../base_interface'
2
+
3
+ module Dev
4
+ module Template
5
+ module Docker
6
+ # Module for rake tasks associated with php applications
7
+ module Php
8
+ # Class for default rake tasks associated with a php project
9
+ class Application < Dev::Template::ApplicationInterface
10
+ # Allow for custom container path for the application
11
+ def initialize(application, container_path: nil, local_path: nil, exclude: [])
12
+ @php = Dev::Php.new(container_path: container_path, local_path: local_path)
13
+ super(application, exclude: exclude)
14
+ end
15
+
16
+ # Create the rake task which downloads the vendor directory to your local system for the given application name
17
+ def create_vendor_download_task!
18
+ application = @name
19
+ php = @php
20
+ exclude = @exclude
21
+ return if exclude.include?(:'vendor:download')
22
+
23
+ DEV_COMMANDS_TOP_LEVEL.instance_eval do
24
+ namespace application do
25
+ namespace :php do
26
+ namespace :vendor do
27
+ desc "Copy #{application} vendor files from the container to your local system"
28
+ task download: %w(init_docker up_no_deps) do
29
+ container = Dev::Docker::Compose.new.container_by_name(application)
30
+ Dev::Docker.new.copy_from_container(container, "#{php.container_path}/vendor/", "#{php.local_path}/vendor/", required: true)
31
+ end
32
+ end
33
+ end
34
+ end
35
+ end
36
+ end
37
+
38
+ # Create the rake task which uploads the vendor directory from your local system for the given application name
39
+ def create_vendor_upload_task!
40
+ application = @name
41
+ php = @php
42
+ exclude = @exclude
43
+ return if exclude.include?(:'vendor:upload')
44
+
45
+ DEV_COMMANDS_TOP_LEVEL.instance_eval do
46
+ namespace application do
47
+ namespace :php do
48
+ namespace :vendor do
49
+ desc "Copy #{application} vendor files from your local system to the container"
50
+ task upload: %w(init_docker up_no_deps) do
51
+ container = Dev::Docker::Compose.new.container_by_name(application)
52
+ Dev::Docker.new.copy_to_container(container, "#{php.local_path}/vendor/", "#{php.container_path}/vendor/")
53
+ end
54
+ end
55
+ end
56
+ end
57
+ end
58
+ end
59
+
60
+ # Create the rake task which runs linting for the application name
61
+ def create_lint_task!
62
+ application = @name
63
+ php = @php
64
+ exclude = @exclude
65
+ return if exclude.include?(:lint)
66
+
67
+ DEV_COMMANDS_TOP_LEVEL.instance_eval do
68
+ namespace application do
69
+ desc 'Run all linting software'
70
+ task lint: %w(php:lint) do
71
+ # This is just a placeholder to execute the dependencies
72
+ end
73
+
74
+ namespace :php do
75
+ desc "Run the php linting software against the #{application}'s codebase"
76
+ task lint: %w(init_docker up_no_deps) do
77
+ LOG.debug("Check for php linting errors in the #{application} codebase")
78
+
79
+ options = []
80
+ options << '-T' if Dev::Common.new.running_codebuild?
81
+ Dev::Docker::Compose.new(services: application, options: options).exec(*php.lint_command)
82
+ end
83
+
84
+ namespace :lint do
85
+ desc "Run the php linting software against the #{application}'s codebase and apply all available fixes"
86
+ task fix: %w(init_docker up_no_deps) do
87
+ LOG.debug("Check and fix all php linting errors in the #{application} codebase")
88
+
89
+ options = []
90
+ options << '-T' if Dev::Common.new.running_codebuild?
91
+ Dev::Docker::Compose.new(services: application, options: options).exec(*php.lint_fix_command)
92
+ end
93
+ end
94
+ end
95
+ end
96
+ end
97
+ end
98
+
99
+ # Create the rake task which runs all tests for the application name
100
+ def create_test_task!
101
+ application = @name
102
+ php = @php
103
+ exclude = @exclude
104
+ return if exclude.include?(:test)
105
+
106
+ DEV_COMMANDS_TOP_LEVEL.instance_eval do
107
+ namespace application do
108
+ desc 'Run all tests'
109
+ task test: %w(php:test) do
110
+ # This is just a placeholder to execute the dependencies
111
+ end
112
+
113
+ namespace :php do
114
+ desc "Run all php tests against the #{application}'s codebase"
115
+ task test: %w(init_docker up) do
116
+ LOG.debug("Running all php tests in the #{application} codebase")
117
+
118
+ options = []
119
+ options << '-T' if Dev::Common.new.running_codebuild?
120
+ Dev::Docker::Compose.new(services: application, options: options).exec(*php.test_command)
121
+ end
122
+ end
123
+ end
124
+ end
125
+ end
126
+
127
+ # Create the rake tasks which runs the install command for the application packages
128
+ def create_install_task!
129
+ # Have to set a local variable to be accessible inside of the instance_eval block
130
+ application = @name
131
+ php = @php
132
+ exclude = @exclude
133
+ return if exclude.include?(:install)
134
+
135
+ DEV_COMMANDS_TOP_LEVEL.instance_eval do
136
+ namespace application do
137
+ namespace :php do
138
+ desc 'Install all npm packages'
139
+ task install: %w(init_docker up_no_deps) do
140
+ Dev::Docker::Compose.new(services: application).exec(*php.install_command)
141
+ end
142
+ end
143
+ end
144
+ end
145
+ end
146
+
147
+ # Create the rake tasks which runs the security audits for the application packages
148
+ def create_audit_task!
149
+ # Have to set a local variable to be accessible inside of the instance_eval block
150
+ application = @name
151
+ php = @php
152
+ exclude = @exclude
153
+ return if exclude.include?(:audit)
154
+
155
+ DEV_COMMANDS_TOP_LEVEL.instance_eval do
156
+ namespace application do
157
+ desc 'Run all security audits'
158
+ task audit: %w(php:audit) do
159
+ # This is just a placeholder to execute the dependencies
160
+ end
161
+
162
+ namespace :php do
163
+ desc 'Run Composer Audit on the target application' \
164
+ "\n\tuse MIN_SEVERITY=(info low moderate high critical) to fetch only severity type selected and above (default=high)." \
165
+ "\n\tuse IGNORELIST=(comma delimited list of cwe numbers) removes the entry from the list."
166
+ task audit: %w(init_docker up_no_deps) do
167
+ opts = []
168
+ opts << '-T' if Dev::Common.new.running_codebuild?
169
+
170
+ # Retrieve results of the scan.
171
+ data = Dev::Docker::Compose.new(services: application, options: opts, capture: true).exec(*php.audit_command)
172
+ Dev::Php::Audit.new(data).to_report.check
173
+ end
174
+
175
+ # namespace :audit do
176
+ # desc 'Fix the composer vulnerabilities that were found'
177
+ # task fix: %w(init_docker up_no_deps) do
178
+ # raise 'not implemented'
179
+ # # Dev::Docker::Compose.new(services: application).exec(*php.audit_fix_command)
180
+ # end
181
+ # end
182
+ end
183
+ end
184
+ end
185
+ end
186
+ end
187
+ end
188
+ end
189
+ end
190
+ end
@@ -0,0 +1,146 @@
1
+ require_relative '../../base_interface'
2
+
3
+ module Dev
4
+ module Template
5
+ module Docker
6
+ # Module for rake tasks associated with ruby applications
7
+ module Ruby
8
+ # Class for default rake tasks associated with a ruby project
9
+ class Application < Dev::Template::ApplicationInterface
10
+ # Allow for custom container path for the application
11
+ def initialize(application, container_path: nil, local_path: nil, exclude: [])
12
+ @ruby = Dev::Ruby.new(container_path: container_path, local_path: local_path)
13
+ super(application, exclude: exclude)
14
+ end
15
+
16
+ # Create the rake task which runs linting for the application name
17
+ def create_lint_task!
18
+ application = @name
19
+ ruby = @ruby
20
+ exclude = @exclude
21
+ return if exclude.include?(:lint)
22
+
23
+ DEV_COMMANDS_TOP_LEVEL.instance_eval do
24
+ namespace application do
25
+ desc 'Run all linting software'
26
+ task lint: %w(ruby:lint) do
27
+ # This is just a placeholder to execute the dependencies
28
+ end
29
+
30
+ namespace :ruby do
31
+ desc "Run the ruby linting software against the #{application}'s codebase"
32
+ task lint: %w(init_docker up_no_deps) do
33
+ LOG.debug("Check for ruby linting errors in the #{application} codebase")
34
+
35
+ options = []
36
+ options << '-T' if Dev::Common.new.running_codebuild?
37
+ Dev::Docker::Compose.new(services: application, options: options).exec(*ruby.lint_command)
38
+ end
39
+
40
+ namespace :lint do
41
+ desc "Run the ruby linting software against the #{application}'s codebase and apply all available fixes"
42
+ task fix: %w(init_docker up_no_deps) do
43
+ LOG.debug("Check and fix all ruby linting errors in the #{application} codebase")
44
+
45
+ options = []
46
+ options << '-T' if Dev::Common.new.running_codebuild?
47
+ Dev::Docker::Compose.new(services: application, options: options).exec(*ruby.lint_fix_command)
48
+ end
49
+ end
50
+ end
51
+ end
52
+ end
53
+ end
54
+
55
+ # Create the rake task which runs all tests for the application name
56
+ def create_test_task!
57
+ application = @name
58
+ ruby = @ruby
59
+ exclude = @exclude
60
+ return if exclude.include?(:test)
61
+
62
+ DEV_COMMANDS_TOP_LEVEL.instance_eval do
63
+ namespace application do
64
+ desc 'Run all tests'
65
+ task test: [:'ruby:test'] do
66
+ # This is just a placeholder to execute the dependencies
67
+ end
68
+
69
+ namespace :ruby do
70
+ desc "Run all ruby tests against the #{application}'s codebase"
71
+ task test: %w(init_docker up_no_deps) do
72
+ LOG.debug("Running all ruby tests in the #{application} codebase")
73
+
74
+ options = []
75
+ options << '-T' if Dev::Common.new.running_codebuild?
76
+ Dev::Docker::Compose.new(services: application, options: options).exec(*ruby.test_command)
77
+ end
78
+ end
79
+ end
80
+ end
81
+ end
82
+
83
+ # Create the rake task which runs the install command for the application packages
84
+ def create_install_task!
85
+ # Have to set a local variable to be accessible inside of the instance_eval block
86
+ application = @name
87
+ ruby = @ruby
88
+ exclude = @exclude
89
+ return if exclude.include?(:install)
90
+
91
+ DEV_COMMANDS_TOP_LEVEL.instance_eval do
92
+ namespace application do
93
+ namespace :ruby do
94
+ desc 'Install all npm packages'
95
+ task install: %w(init_docker up_no_deps) do
96
+ Dev::Docker::Compose.new(services: application).exec(*ruby.install_command)
97
+ end
98
+ end
99
+ end
100
+ end
101
+ end
102
+
103
+ # Create the rake task which runs the security audits for the application packages
104
+ def create_audit_task!
105
+ # Have to set a local variable to be accessible inside of the instance_eval block
106
+ application = @name
107
+ ruby = @ruby
108
+ exclude = @exclude
109
+ return if exclude.include?(:audit)
110
+
111
+ DEV_COMMANDS_TOP_LEVEL.instance_eval do
112
+ namespace application do
113
+ desc 'Run all security audits'
114
+ task audit: [:'ruby:audit'] do
115
+ # This is just a placeholder to execute the dependencies
116
+ end
117
+
118
+ namespace :ruby do
119
+ desc 'Run Bundle Audit on the target application' \
120
+ "\n\tuse MIN_SEVERITY=(info low moderate high critical) to fetch only severity type selected and above (default=high)." \
121
+ "\n\tuse IGNORELIST=(comma delimited list of ids) removes the entry from the list."
122
+ task audit: %w(init_docker up_no_deps) do
123
+ opts = []
124
+ opts << '-T' if Dev::Common.new.running_codebuild?
125
+
126
+ # Retrieve results of the scan.
127
+ data = Dev::Docker::Compose.new(services: application, options: opts, capture: true).exec(*ruby.audit_command)
128
+ Dev::Ruby::Audit.new(data).to_report.check
129
+ end
130
+
131
+ # namespace :audit do
132
+ # desc 'Run NPM Audit fix command'
133
+ # task fix: %w(init_docker up_no_deps) do
134
+ # raise 'not implemented'
135
+ # # Dev::Docker::Compose.new(services: application).exec(*ruby.audit_fix_command)
136
+ # end
137
+ # end
138
+ end
139
+ end
140
+ end
141
+ end
142
+ end
143
+ end
144
+ end
145
+ end
146
+ end