Class: Dev::Template::Docker::Node::Application
- Inherits:
-
ApplicationInterface
- Object
- BaseInterface
- ApplicationInterface
- Dev::Template::Docker::Node::Application
- Defined in:
- lib/firespring_dev_commands/templates/docker/node/application.rb
Overview
Class for default rake tasks associated with a node project
Instance Attribute Summary collapse
-
#node ⇒ Object
readonly
Returns the value of attribute node.
-
#start_container_dependencies_on_test ⇒ Object
readonly
Returns the value of attribute start_container_dependencies_on_test.
Attributes inherited from ApplicationInterface
Attributes inherited from BaseInterface
Instance Method Summary collapse
-
#create_audit_task! ⇒ Object
Create the rake tasks which runs the security audits of application packages.
-
#create_eol_task! ⇒ Object
Create the rake task for the node eol method.
-
#create_install_task! ⇒ Object
Create the rake task which runs the install command for the application packages.
-
#create_lint_task! ⇒ Object
Create the rake task which runs linting for the application name rubocop:disable Metrics/MethodLength.
-
#create_test_task! ⇒ Object
Create the rake task which runs all tests for the application name.
-
#initialize(application, container_path: nil, local_path: nil, start_container_dependencies_on_test: true, exclude: []) ⇒ Application
constructor
Create the templated rake tasks for the node application.
Methods inherited from BaseInterface
Constructor Details
#initialize(application, container_path: nil, local_path: nil, start_container_dependencies_on_test: true, exclude: []) ⇒ Application
Create the templated rake tasks for the node application
19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/firespring_dev_commands/templates/docker/node/application.rb', line 19 def initialize( application, container_path: nil, local_path: nil, start_container_dependencies_on_test: true, exclude: [] ) @node = Dev::Node.new(container_path:, local_path:) @start_container_dependencies_on_test = start_container_dependencies_on_test super(application, exclude:) end |
Instance Attribute Details
#node ⇒ Object (readonly)
Returns the value of attribute node.
10 11 12 |
# File 'lib/firespring_dev_commands/templates/docker/node/application.rb', line 10 def node @node end |
#start_container_dependencies_on_test ⇒ Object (readonly)
Returns the value of attribute start_container_dependencies_on_test.
10 11 12 |
# File 'lib/firespring_dev_commands/templates/docker/node/application.rb', line 10 def start_container_dependencies_on_test @start_container_dependencies_on_test end |
Instance Method Details
#create_audit_task! ⇒ Object
Create the rake tasks which runs the security audits of application packages
129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 |
# File 'lib/firespring_dev_commands/templates/docker/node/application.rb', line 129 def create_audit_task! # Have to set a local variable to be accessible inside of the instance_eval block application = @name node = @node exclude = @exclude return if exclude.include?(:audit) DEV_COMMANDS_TOP_LEVEL.instance_eval do namespace application do desc 'Run all security audits' task audit: %w(node:audit) do # This is just a placeholder to execute the dependencies end namespace :node do desc 'Run NPM Audit on the target application' \ "\n\tuse MIN_SEVERITY=(info low moderate high critical) to fetch only severity type selected and above (default=high)." \ "\n\tuse IGNORELIST=(comma delimited list of ids) removes the entry from the list." task audit: %w(init_docker up_no_deps) do opts = [] opts << '-T' if Dev::Common.new.running_codebuild? # Retrieve results of the scan. data = Dev::Docker::Compose.new(services: application, options: opts, capture: true).exec(*node.audit_command) Dev::Node::Audit.new(data).to_report.check end namespace :audit do desc 'Run NPM Audit fix command' task fix: %w(init_docker up_no_deps) do Dev::Docker::Compose.new(services: application).exec(*node.audit_fix_command) end end end end end end |
#create_eol_task! ⇒ Object
Create the rake task for the node eol method
168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 |
# File 'lib/firespring_dev_commands/templates/docker/node/application.rb', line 168 def create_eol_task! # Have to set a local variable to be accessible inside of the instance_eval block exclude = @exclude node = @node DEV_COMMANDS_TOP_LEVEL.instance_eval do return if exclude.include?(:eol) task eol: [:'eol:node'] do # This is just a placeholder to execute the dependencies end namespace :eol do desc 'Compares the current date to the EOL date for supported packages in the node package file' task node: %w(init) do eol = Dev::EndOfLife::Node.new(node) node_products = eol.default_products puts puts "Node product versions (in #{eol.lockfile})".light_yellow Dev::EndOfLife.new(product_versions: node_products).status end end end end |
#create_install_task! ⇒ Object
Create the rake task which runs the install command for the application packages
109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 |
# File 'lib/firespring_dev_commands/templates/docker/node/application.rb', line 109 def create_install_task! # Have to set a local variable to be accessible inside of the instance_eval block application = @name node = @node exclude = @exclude return if exclude.include?(:install) DEV_COMMANDS_TOP_LEVEL.instance_eval do namespace application do namespace :node do desc 'Install all npm packages' task install: %w(init_docker up_no_deps) do Dev::Docker::Compose.new(services: application).exec(*node.install_command) end end end end end |
#create_lint_task! ⇒ Object
Create the rake task which runs linting for the application name rubocop:disable Metrics/MethodLength
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 |
# File 'lib/firespring_dev_commands/templates/docker/node/application.rb', line 33 def create_lint_task! application = @name node = @node exclude = @exclude return if exclude.include?(:lint) DEV_COMMANDS_TOP_LEVEL.instance_eval do namespace application do desc 'Run all linting software' task lint: %w(node:lint) do # This is just a placeholder to execute the dependencies end namespace :lint do desc 'Run all linting software and apply all available fixes' task fix: %w(node:lint:fix) do # This is just a placeholder to execute the dependencies end end namespace :node do desc "Run the node linting software against the #{application}'s codebase" task lint: %w(init_docker up_no_deps) do LOG.debug('Check for node linting errors') = [] << '-T' if Dev::Common.new.running_codebuild? Dev::Docker::Compose.new(services: application, options:).exec(*node.lint_command) end namespace :lint do desc "Run the linting software against the #{application}'s codebase and apply all available fixes" task fix: %w(init_docker up_no_deps) do LOG.debug('Check and fix linting errors') = [] << '-T' if Dev::Common.new.running_codebuild? Dev::Docker::Compose.new(services: application, options:).exec(*node.lint_fix_command) end end end end end end |
#create_test_task! ⇒ Object
Create the rake task which runs all tests for the application name
80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 |
# File 'lib/firespring_dev_commands/templates/docker/node/application.rb', line 80 def create_test_task! application = @name node = @node exclude = @exclude up_cmd = @start_container_dependencies_on_test ? :up : :up_no_deps return if exclude.include?(:test) DEV_COMMANDS_TOP_LEVEL.instance_eval do namespace application do desc 'Run all tests' task test: %w(node:test) do # This is just a placeholder to execute the dependencies end namespace :node do desc "Run all node tests against the #{application}'s codebase" task test: %W(init_docker #{up_cmd}) do LOG.debug("Running all node tests in the #{application} codebase") = [] << '-T' if Dev::Common.new.running_codebuild? Dev::Docker::Compose.new(services: application, options:).exec(*node.test_command) end end end end end |