jets 5.0.2 → 5.0.4

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: 56b1cd2d4dadd8582bfaf2eeda623bed469ae4effd0cd3aff9f2c80741721b23
4
- data.tar.gz: 4abf083f6a7d090ed0bf0adf1c16b24ea6f8ec98714c0335ba165f92b5115766
3
+ metadata.gz: a5dfbf6918bc02ab0aa922e66411129fb177f79acbefd26f481b9d0b9e6fe046
4
+ data.tar.gz: 81bde117ec85d14328dc523c20e757123c8e73ea7de508e0ab00f368cce7a38d
5
5
  SHA512:
6
- metadata.gz: aae65dfb73f92802e3a8e44b7e4171a97345ba7912143ad03d644e1ded48822541fba035d4d1c6707c0e2aed2d31c595be637c8cdc9c9eb19be13627b2576afb
7
- data.tar.gz: 3a71ac74963d2d81cb75f57bcb2a32df1a34a890f2d60f522d4a53640f8bee3ff2c6fc7ddcca73990c232724436597ecf0f2b0cc6bab2513c3d4c15c5ea99d5d
6
+ metadata.gz: e7794943a90301a37af8dc14338e0504a53b0d3ff37ae6a15541c48130194e06078de0d66ef4be6b119db37284ae679c87095e7c252ef4860938aba31ff72af4
7
+ data.tar.gz: 0b768fa41186630d876fd9690003c8c3ff3f70b46ace56a3f325d931dc4ae80dd2a777d2bfe3af0c8f6b73b377a83ab4c0bb3bd2158d3baddd6afcdd7a8cacb5
data/CHANGELOG.md CHANGED
@@ -3,6 +3,17 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  This project *loosely tries* to adhere to [Semantic Versioning](http://semver.org/).
5
5
 
6
+ ## [5.0.4] - 2023-12-17
7
+ - [#695](https://github.com/rubyonjets/jets/pull/695) dont run reconfigure webpacker unless using
8
+ - [#696](https://github.com/rubyonjets/jets/pull/696) improve deploy failure message by showing nested stack failure message
9
+ - update delete error messaging to stack
10
+
11
+ ## [5.0.3] - 2023-12-15
12
+ - [#691](https://github.com/rubyonjets/jets/pull/691) jets deploy fix for empty project
13
+ - [#692](https://github.com/rubyonjets/jets/pull/692) fix jets deploy for empty project
14
+ - [#693](https://github.com/rubyonjets/jets/pull/693) do not include sprockets-jets in new app generator for api mode
15
+ - [#694](https://github.com/rubyonjets/jets/pull/694) fix jets deploy for empty project
16
+
6
17
  ## [5.0.2] - 2023-12-11
7
18
  - [#688](https://github.com/rubyonjets/jets/pull/688) improve releases:info output
8
19
 
data/jets.gemspec CHANGED
@@ -48,7 +48,7 @@ Gem::Specification.new do |spec|
48
48
  spec.add_dependency "aws-sdk-ssm"
49
49
  spec.add_dependency "cfn_camelizer", ">= 0.4.9"
50
50
  spec.add_dependency "cfn_response"
51
- spec.add_dependency "cfn-status"
51
+ spec.add_dependency "cfn-status", ">= 0.5.0"
52
52
  spec.add_dependency "cli-format", ">= 0.4.0"
53
53
  spec.add_dependency "dotenv"
54
54
  spec.add_dependency "dsl_evaluator", ">= 0.3.0" # for DslEvaluator.print_code
@@ -232,7 +232,7 @@ module Jets::Builders
232
232
  # Checking this way because when using jets standalone for Afterburner mode we don't want to run into
233
233
  # bundler gem collisions. TODO: figure out the a better way to handle the collisions.
234
234
  lines = IO.readlines("#{Jets.root}/Gemfile")
235
- lines.detect { |l| l =~ /#{name}/ && l !~ /\s.*#/ }
235
+ lines.detect { |l| l =~ /gem ['"]#{name}/ && l !~ /^\s*?#/ }
236
236
  end
237
237
 
238
238
  # Cleans out non-cached files like code-*.zip in Jets.build_root
@@ -279,6 +279,7 @@ module Jets::Builders
279
279
  # when they deploy a jets project in development mode
280
280
  def reconfigure_development_webpacker
281
281
  return unless Jets.env.development?
282
+ return unless gemfile_include?("jetpacker")
282
283
  headline "Reconfiguring webpacker development settings for AWS Lambda."
283
284
 
284
285
  webpacker_yml = "#{"#{stage_area}/code"}/config/webpacker.yml"
@@ -305,7 +306,7 @@ module Jets::Builders
305
306
  puts "Skip packaging ruby".color(:yellow) # useful for developing handlers
306
307
  return
307
308
  end
308
- return if Jets.poly_only?
309
+ return unless Jets.gem_layer?
309
310
 
310
311
  check_agree
311
312
  ruby_packager.install
@@ -322,7 +323,7 @@ module Jets::Builders
322
323
  end
323
324
 
324
325
  def build_lambda_layer
325
- return if Jets.poly_only?
326
+ return unless Jets.gem_layer?
326
327
  lambda_layer = LambdaLayer.new
327
328
  lambda_layer.build
328
329
  end
@@ -45,6 +45,14 @@ module Jets::Builders
45
45
  generate_handler(vars)
46
46
  end
47
47
  end
48
+
49
+ if app_files.empty? && Jets.gem_layer?
50
+ # When there are no app files, still need to generate a shim for JetsController
51
+ lib = File.expand_path('../../..', __dir__)
52
+ path = "#{lib}/engines/internal/app/controllers/jets/public_controller.rb"
53
+ vars = Jets::Builders::ShimVars::App.new(path)
54
+ generate_handler(vars)
55
+ end
48
56
  end
49
57
 
50
58
  def generate_handler(vars)
@@ -44,7 +44,7 @@ class Jets::Cfn::Builder
44
44
  add_resource(resource)
45
45
  add_outputs(resource.outputs)
46
46
 
47
- return if Jets.poly_only?
47
+ return unless Jets.gem_layer?
48
48
  resource = Jets::Cfn::Resource::Lambda::GemLayer.new
49
49
  add_resource(resource)
50
50
  add_outputs(resource.outputs)
@@ -86,8 +86,8 @@ module Jets::Cfn
86
86
  builder_class = "Jets::Cfn::Builder::#{app_class}".constantize
87
87
 
88
88
  app_class = Jets::Klass.from_path(path)
89
- if Jets.poly_only? && app_class == Jets::PreheatJob
90
- return # No prewarm when there's only poly functions
89
+ if !Jets.gem_layer? && app_class == Jets::PreheatJob
90
+ return # No prewarm when there's only poly functions and no gem layer
91
91
  end
92
92
 
93
93
  # Builder class fully qualified name:
@@ -5,7 +5,7 @@ module Jets::Cfn::Params
5
5
  IamRole: "!GetAtt IamRole.Arn",
6
6
  S3Bucket: "!Ref S3Bucket",
7
7
  }
8
- parameters[:GemLayer] = "!Ref GemLayer" unless Jets.poly_only?
8
+ parameters[:GemLayer] = "!Ref GemLayer" if Jets.gem_layer?
9
9
  parameters
10
10
  end
11
11
 
data/lib/jets/cfn/ship.rb CHANGED
@@ -31,16 +31,11 @@ module Jets::Cfn
31
31
  end
32
32
  end
33
33
 
34
- success = wait_for_stack
34
+ # waits for /(_COMPLETE|_FAILED)$/ status
35
+ cfn_status = Jets::Cfn::Status.new
36
+ success = cfn_status.wait
35
37
  unless success
36
- puts <<~EOL
37
- The Jets application failed to deploy. Jets creates a few CloudFormation stacks to deploy your application.
38
- The logs above show the CloudFormation parent stack events and points to the stack with the error.
39
- Please go to the CloudFormation console and look for the specific stack with the error.
40
- The specific child stack usually shows more detailed information and can be used to resolve the issue.
41
- Example of checking the CloudFormation console: https://rubyonjets.com/docs/debugging/cloudformation/
42
- EOL
43
- exit 1
38
+ cfn_status.failure_message!
44
39
  end
45
40
 
46
41
  save_apigw_state
@@ -100,11 +95,6 @@ module Jets::Cfn
100
95
  @template ||= Template.new(Jets::Names.parent_template_path, @options)
101
96
  end
102
97
 
103
- # check for /(_COMPLETE|_FAILED)$/ status
104
- def wait_for_stack
105
- Jets::Cfn::Status.new(@options).wait
106
- end
107
-
108
98
  def save_apigw_state
109
99
  Jets::Router::State.save_apigw_state
110
100
  end
@@ -116,7 +106,7 @@ module Jets::Cfn
116
106
  end
117
107
  return unless @options[:stack_type] == :full # s3 bucket is available
118
108
  return unless Jets.config.prewarm.enable
119
- return if Jets.poly_only?
109
+ return unless Jets.gem_layer?
120
110
 
121
111
  puts "Prewarming application."
122
112
  Jets::PreheatJob.prewarm!
@@ -2,9 +2,52 @@ require 'cfn_status'
2
2
 
3
3
  module Jets::Cfn
4
4
  class Status < CfnStatus
5
- def initialize(options={})
6
- @stack_name = Jets::Names.parent_stack_name
7
- super(@stack_name, options)
5
+ extend Memoist
6
+
7
+ def initialize(stack_name = Jets::Names.parent_stack_name, options={})
8
+ super(stack_name, options)
9
+ end
10
+
11
+ def failure_message!
12
+ puts <<~EOL
13
+ The Jets application failed to deploy. Jets creates a few CloudFormation stacks
14
+ to deploy your application. The logs above show the CloudFormation parent stack
15
+ events. You can go to the CloudFormation console and look for the nested stack
16
+ with the error. The specific nested stack usually shows more detailed information
17
+ and can be used to resolve the issue.
18
+ Example of checking the CloudFormation console:
19
+
20
+ https://rubyonjets.com/docs/debugging/cloudformation/
21
+
22
+ EOL
23
+
24
+ show_nested_stack_error
25
+
26
+ exit 1
27
+ end
28
+
29
+ def show_nested_stack_error
30
+ event = find_failed_event
31
+ return unless event
32
+ puts "-" * 80
33
+ puts "Here's the nested stack error details: #{event.resource_status_reason}"
34
+ self.class.new(event.physical_resource_id, start_index_before_delete: true).run
35
+
36
+ region = Jets.aws.region
37
+ puts <<~EOL
38
+ Here's also the AWS Console link to the failed nested stack:
39
+
40
+ https://#{region}.console.aws.amazon.com/cloudformation/home?region=#{region}#/stacks/events?filteringText=&filteringStatus=active&viewNested=true&stackId=#{event.physical_resource_id}
41
+
42
+ EOL
43
+ end
44
+
45
+ def find_failed_event
46
+ cfn_status = self.class.new # fresh instance to get the refreshed events
47
+ cfn_status.refresh_events
48
+ i = cfn_status.start_index
49
+ events = cfn_status.events[0..i].reverse # events are in reverse chronological order
50
+ events.find { |e| e.resource_status =~ /FAILED/ } # first failed event
8
51
  end
9
52
  end
10
53
  end
@@ -138,6 +138,9 @@ module Jets::Cfn
138
138
  # If only max_age is provided, then we'll generate a cache_control header.
139
139
  # Using max_age is the shorter and simply way of setting the cache_control header.
140
140
  def cache_control
141
+ # default when sprockets-jets not installed
142
+ return "public, max-age=3600" unless Jets.config.respond_to?(:assets)
143
+
141
144
  cache_control = Jets.config.assets.cache_control
142
145
  unless cache_control
143
146
  max_age = Jets.config.assets.max_age # defaults to 3600 in jets/application.rb
@@ -44,7 +44,7 @@ module Jets::Command
44
44
  end
45
45
 
46
46
  def wait_for_stack
47
- status = Jets::Cfn::Status.new(@options)
47
+ status = Jets::Cfn::Status.new
48
48
  start_time = Time.now
49
49
  status.wait
50
50
  took = Time.now - start_time
@@ -60,7 +60,7 @@ module Jets::Command
60
60
  def confirm_project_exists
61
61
  stack = find_stack(parent_stack_name)
62
62
  return if stack
63
- puts "ERROR: Project #{parent_stack_name} does not exist".color(:red)
63
+ puts "ERROR: Stack #{parent_stack_name} does not exist".color(:red)
64
64
  exit 1
65
65
  end
66
66
 
@@ -44,8 +44,8 @@ module Jets::Command
44
44
  def delete_minimal_stack
45
45
  puts "Existing stack is in ROLLBACK_COMPLETE state from a previous failed minimal deploy. Deleting stack and continuing."
46
46
  cfn.delete_stack(stack_name: stack_name)
47
- status.wait
48
- status.reset
47
+ cfn_status.wait
48
+ cfn_status.reset
49
49
  end
50
50
 
51
51
  def check_dev_mode
@@ -69,8 +69,8 @@ module Jets::Command
69
69
  Jets::Cfn::Ship.new(options).run
70
70
  end
71
71
 
72
- def status
73
- @status ||= Jets::Cfn::Status.new(stack_name)
72
+ def cfn_status
73
+ @cfn_status ||= Jets::Cfn::Status.new(stack_name)
74
74
  end
75
75
 
76
76
  def stack_name
@@ -1,9 +1,16 @@
1
1
  module Jets::Command
2
2
  class StatusCommand < Base
3
+ include Jets::AwsServices
4
+
3
5
  desc "status", "Shows the current status of the Jets app"
4
6
  long_desc Help.text(:status)
5
7
  def perform
6
- Jets::Cfn::Status.new(options).run
8
+ Jets.boot
9
+ cfn_status = Jets::Cfn::Status.new
10
+ success = cfn_status.run
11
+ unless success
12
+ cfn_status.failure_message!
13
+ end
7
14
  end
8
15
  end
9
16
  end
data/lib/jets/core.rb CHANGED
@@ -207,6 +207,10 @@ module Jets::Core
207
207
  Jets.config.cfn.build.controllers == "one_lambda_for_all_controllers"
208
208
  end
209
209
 
210
+ def gem_layer?
211
+ !Jets.poly_only? || Jets.one_lambda_for_all_controllers?
212
+ end
213
+
210
214
  # Do not memoize here. The JetsBucket.name does it's own special memoization.
211
215
  def s3_bucket
212
216
  Jets::Cfn::Resource::S3::JetsBucket.name
@@ -2,9 +2,12 @@ source "https://rubygems.org"
2
2
 
3
3
  gem "jets", "~> <%= Jets::VERSION %>"
4
4
 
5
+ <%- if options[:mode] == 'html'-%>
6
+ gem "sprockets-jets"
7
+ <% end -%>
8
+
5
9
  <%- if options[:mode] != 'job' && !options[:database].nil? -%>
6
10
  <%= database_gemfile_entry %>
7
- gem "sprockets-jets"
8
11
  <%- end -%>
9
12
  <%- if options[:mode] == 'html' -%>
10
13
  gem "importmap-jets"
@@ -21,7 +21,7 @@ class Jets::Stack
21
21
  return unless elements
22
22
 
23
23
  if section == :parameters
24
- elements[:GemLayer] = {Type: "String"} unless Jets.poly_only?
24
+ elements[:GemLayer] = {Type: "String"} if Jets.gem_layer?
25
25
  end
26
26
  @template[section] = elements
27
27
  end
data/lib/jets/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Jets
2
- VERSION = "5.0.2"
2
+ VERSION = "5.0.4"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jets
3
3
  version: !ruby/object:Gem::Version
4
- version: 5.0.2
4
+ version: 5.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tung Nguyen
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-12-11 00:00:00.000000000 Z
11
+ date: 2023-12-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: actionmailer
@@ -296,14 +296,14 @@ dependencies:
296
296
  requirements:
297
297
  - - ">="
298
298
  - !ruby/object:Gem::Version
299
- version: '0'
299
+ version: 0.5.0
300
300
  type: :runtime
301
301
  prerelease: false
302
302
  version_requirements: !ruby/object:Gem::Requirement
303
303
  requirements:
304
304
  - - ">="
305
305
  - !ruby/object:Gem::Version
306
- version: '0'
306
+ version: 0.5.0
307
307
  - !ruby/object:Gem::Dependency
308
308
  name: cli-format
309
309
  requirement: !ruby/object:Gem::Requirement