jets 1.4.5 → 1.4.6

Sign up to get free protection for your applications and to get access to all the features.
Files changed (38) hide show
  1. checksums.yaml +4 -4
  2. data/.github/ISSUE_TEMPLATE.md +7 -0
  3. data/.github/ISSUE_TEMPLATE/bug_report.md +67 -0
  4. data/.github/ISSUE_TEMPLATE/documentation.md +27 -0
  5. data/.github/ISSUE_TEMPLATE/feature_request.md +64 -0
  6. data/.github/ISSUE_TEMPLATE/question.md +16 -0
  7. data/.github/PULL_REQUEST_TEMPLATE.md +40 -0
  8. data/CHANGELOG.md +13 -2
  9. data/Gemfile.lock +2 -2
  10. data/backers.md +16 -0
  11. data/lib/jets/application.rb +5 -2
  12. data/lib/jets/booter.rb +1 -1
  13. data/lib/jets/builders/code_builder.rb +10 -4
  14. data/lib/jets/builders/purger.rb +1 -1
  15. data/lib/jets/builders/ruby_packager.rb +2 -2
  16. data/lib/jets/builders/tidy.rb +21 -5
  17. data/lib/jets/cfn/builders/api_gateway_builder.rb +1 -1
  18. data/lib/jets/cfn/ship.rb +1 -1
  19. data/lib/jets/commands/help/upgrade.md +5 -0
  20. data/lib/jets/commands/main.rb +6 -0
  21. data/lib/jets/commands/new.rb +1 -0
  22. data/lib/jets/commands/templates/skeleton/.gitignore +1 -1
  23. data/lib/jets/commands/upgrade.rb +124 -6
  24. data/lib/jets/commands/upgrade/templates/bin/webpack +19 -0
  25. data/lib/jets/commands/upgrade/templates/bin/webpack-dev-server +19 -0
  26. data/lib/jets/commands/url.rb +1 -1
  27. data/lib/jets/controller/redirection.rb +1 -1
  28. data/lib/jets/mega/request.rb +1 -1
  29. data/lib/jets/router.rb +1 -1
  30. data/lib/jets/turbo/rail.rb +2 -2
  31. data/lib/jets/util.rb +16 -0
  32. data/lib/jets/version.rb +1 -1
  33. data/vendor/jets-gems/lib/jets/gems/agree.rb +6 -2
  34. data/vendor/jets-gems/lib/jets/gems/check.rb +0 -1
  35. metadata +12 -5
  36. data/lib/jets/commands/templates/skeleton/bin/ruby_server +0 -18
  37. data/lib/jets/commands/templates/skeleton/bin/ruby_server.rb +0 -2
  38. data/lib/jets/commands/upgrade/v1.rb +0 -104
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 2ee1fb12f1e6271e22fca7680fc8f47c117fc4c6a81ea43f5890790dfad0d10d
4
- data.tar.gz: f74fbb708e6fe7dc7d46840c7fc5823175bda8fa288b48d68d8f62147d69b700
3
+ metadata.gz: d2f49380cd0963ba7e18923f0415ab7809c44210093b96c0a59564600f0b73c8
4
+ data.tar.gz: c6d074dec9a4f790f5ae0a8819fe89839ced01def6d90de15831714cc717f34d
5
5
  SHA512:
6
- metadata.gz: bce25cb0b17ab514ac8afaebdca5743ef8f2251f2818b8e8bb2f64497adbb8a03fa72db233d6dba2b8e628fd4fde2c1052608a04ac81072de683eb74e644fed7
7
- data.tar.gz: 874e792ef63a0da0c64f6b1afdff355d799385134e66dbd273542c90f28b83b2748e1afe3e450e31c9226727fbdb1a79e06754bf0f713a4335481ef7e6cc68af
6
+ metadata.gz: '08e247f3811ac8853ff644188692d564e4518c2b74746701dfd4688b6ec8eab72d9fa5d103ded268dfbad3e7d66ab86e902adc1093ef28aecec8f60829003f0e'
7
+ data.tar.gz: e03b64bfa9a81b9842946650586c433ae8630a829147e55b3eba83cbba8896016b499cb477d6e5167adca032435f9215ef41667bf3cfa0dfa6c4708068e16c0c
@@ -0,0 +1,7 @@
1
+ Please fill out one of the templates on https://github.com/tongueroo/jets/issues/new/choose
2
+
3
+ If you want to ask a question please do so on the Jets Community forum: https://community.rubyonjets.com
4
+
5
+ To be sensitive to everyone's time, we will close issues asking questions without comment. Here are some additional options for questions http://rubyonjets.com/docs/support/ 👌
6
+
7
+ Thank you!
@@ -0,0 +1,67 @@
1
+ ---
2
+ name: Reproducible Bug Report
3
+ about: Is something not working as expected?
4
+ title: ''
5
+ labels: 'bug'
6
+ assignees: ''
7
+
8
+ ---
9
+
10
+ <!--
11
+ Hi! Thanks for considering to file a bug with Jets. Please take the time to
12
+ answer the basic questions. Please try to be as detailed as possible.
13
+ To be sensitive to everyone's time, if not enough details are provided, the
14
+ issue may be closed without comment. Please use your best judgment. 👌
15
+
16
+ If you are unsure this is a bug in Jets, please consider asking your question at https://community.rubyonjets.com
17
+
18
+ Thanks!
19
+ -->
20
+
21
+ ## Checklist
22
+
23
+ <!--
24
+ Make sure that you've done all of these. To mark a checkbox done, replace [ ] with [x].
25
+ -->
26
+
27
+ - [ ] Upgrade Jets: Are you using the latest version of Jets? This allows Jets to fix issues fast. There's a `jets upgrade` command that makes this a simple task. There's also an Upgrading Guide: http://rubyonjets.com/docs/upgrading/
28
+ - [ ] Reproducibility: Are you reporting a bug others will be able to reproduce and not asking a question. If you're unsure or want to ask a question, do so on https://community.rubyonjets.com
29
+ - [ ] Code sample: Have you put together a code sample to reproduce the issue and make it available? Code samples help speed up fixes dramatically. If it's an easily reproducible issue, then code samples are not needed. If you're unsure, please include a code sample.
30
+
31
+ ## My Environment
32
+
33
+ <!-- Please fill out the table below with debugging info to help: -->
34
+
35
+ | Software | Version |
36
+ | ---------------- | ------- |
37
+ | Operating System | |
38
+ | `jets` | |
39
+ | `ruby` | |
40
+
41
+ ---
42
+
43
+ ## Expected Behaviour
44
+
45
+ <!--
46
+ What is it you expected to happen? This should be a description of how the functionality you tried to use is supposed to work. Try to keep this to one-paragraph.
47
+ -->
48
+
49
+ ## Current Behavior
50
+
51
+ <!--
52
+ Describe the details of the bug. Try to keep this to one-paragraph.
53
+ -->
54
+
55
+ ## Step-by-step reproduction instructions
56
+
57
+ <!--
58
+ Be sure to include any steps you took for the problem to exist. This is likely the longest part of the report.
59
+
60
+ Please include any logs you think relevant here. If the logs are long (more than 50 lines) please make a gist of the logs and link to it. https://gist.github.com
61
+ -->
62
+
63
+ ## Code Sample
64
+
65
+ <!--
66
+ Please provide a code repository, gist, code snippet or sample files to reproduce the issue.
67
+ -->
@@ -0,0 +1,27 @@
1
+ ---
2
+ name: Documentation
3
+ about: Found a typo or something that isn't crystal clear in the docs?
4
+ title: ''
5
+ labels: docs
6
+ assignees: ''
7
+
8
+ ---
9
+
10
+ <!--
11
+ Thanks for taking the time to open a documentation issue and help us make Jets better!
12
+
13
+ Great documentation is key to great software and is very important. So thank you!
14
+
15
+ If it is just a typo or grammar fix, you don't have to fill out any of the sections below. 🚀
16
+ -->
17
+
18
+ ## Motivation
19
+
20
+ <!-- Why should the docs be updated? -->
21
+
22
+
23
+ ## Suggestion
24
+
25
+ <!-- What can be done instead? -->
26
+
27
+ <!-- Thanks again for taking the time to open an issue and help us make Jets better! -->
@@ -0,0 +1,64 @@
1
+ ---
2
+ name: New Feature Suggestion
3
+ about: Want to add a feature to Jets?
4
+ title: ''
5
+ labels: feature
6
+ assignees: ''
7
+
8
+ ---
9
+
10
+ <!--
11
+ Hi! Thanks for considering to file a feature request with Jets. Please take the time to answer the basic questions. Please try to be as detailed as possible.
12
+
13
+ Thanks!
14
+ -->
15
+
16
+ ## Summary
17
+
18
+ <!--
19
+ A one-paragraph explanation of the feature.
20
+ -->
21
+
22
+ ## Motivation
23
+
24
+ <!--
25
+ Why do you want to see this feature in Jets? What use cases does it support?
26
+
27
+ How the feature would be relevant to 80% or more of Jets users.
28
+ -->
29
+
30
+ ## Guide-level explanation
31
+
32
+ <!--
33
+ Explain the proposal as if it was already included in the project and you were teaching it to another programmer. That generally means:
34
+
35
+ - Introducing new named concepts.
36
+ - Explaining the feature largely in terms of examples.
37
+ - If applicable, provide sample error messages, deprecation warnings, or upgrade guidance.
38
+
39
+ If this is a small feature, you may omit this section.
40
+ -->
41
+
42
+ ## Reference-level explanation
43
+
44
+ <!--
45
+ This is the technical portion of the feature request. Explain the design in sufficient detail that:
46
+
47
+ - Its interaction with other features is clear.
48
+ - It is reasonably clear how the feature would be implemented.
49
+ - Corner cases are dissected by example.
50
+
51
+ If you do not know how to answer this, you can omit it. No worries!
52
+ -->
53
+
54
+ ## Drawbacks
55
+
56
+ <!--
57
+ Why should we *not* do this?
58
+ -->
59
+
60
+ ## Unresolved Questions
61
+
62
+ <!--
63
+ What related issues do you consider out of scope for this feature that could be addressed in the future independently of the solution that comes out of this feature?
64
+ -->
@@ -0,0 +1,16 @@
1
+ ---
2
+ name: Question
3
+ about: Have any questions about how Jets works?
4
+ title: ''
5
+ labels: 'question'
6
+ assignees: ''
7
+
8
+ ---
9
+
10
+ <!--
11
+ The Jets issue tracker IS NOT for usage questions! Please post your question on our dedicated forum at https://community.rubyonjets.com
12
+
13
+ Also, here are some additional options for questions http://rubyonjets.com/docs/support/ 👌
14
+
15
+ Thank you!
16
+ -->
@@ -0,0 +1,40 @@
1
+ <!--
2
+ Thanks for creating a Pull Request! Before you submit, please make sure you've done the following:
3
+
4
+ - I read the contributing document at https://rubyonjets.com/docs/contributing/
5
+ -->
6
+
7
+ <!--
8
+ Make our lives easier! Choose one of the following by uncommenting it:
9
+ -->
10
+
11
+ <!-- This is a 🐞 bug fix. -->
12
+ <!-- This is a 🙋‍♂️ feature or enhancement. -->
13
+ <!-- This is a 🧐 documentation change. -->
14
+
15
+ <!--
16
+ Before you submit this pull request, make sure to have a look at the following checklist. If you don't know how to do some of these, that's fine! Submit your pull request and we will help you out on the way.
17
+ -->
18
+
19
+ - [] I've added tests (if it's a bug, feature or enhancement)
20
+ - [] I've adjusted the documentation (if it's a feature or enhancement)
21
+ - [] The test suite passes (run `bundle exec rspec` to verify this)
22
+
23
+ ## Summary
24
+
25
+ <!--
26
+ Provide a description of what your pull request changes.
27
+ -->
28
+
29
+ ## Context
30
+
31
+ <!--
32
+ Is this related to any GitHub issue(s)?
33
+ -->
34
+
35
+ ## Version Changes
36
+
37
+ <!--
38
+ Which semantic version change would you recommend?
39
+ If you don't know, feel free to omit it.
40
+ -->
@@ -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/), even before v1.0.
5
5
 
6
+ ## [1.4.6]
7
+ - #118 from tongueroo/fix-mega-query-string
8
+ - #120 from tongueroo/tidy-webpacker
9
+ - #123 from tongueroo/cp-r
10
+ - #124 from tongueroo/webpacker-update
11
+ - #125 from tongueroo/fix-redirect-for-custom-domains
12
+ - #126 from tongueroo/route-53-option config.domain.route53 option
13
+ - #127 from tongueroo/github-templates
14
+ - more specific regexp for project_name in parse_project_name
15
+ - tidy webpacker app/javascript/src and public/packs to keep code sizes down
16
+
6
17
  ## [1.4.5]
7
18
  - include JETS_PROJECT_NAME as jets_env function var when set
8
19
 
@@ -107,7 +118,7 @@ This project *loosely tries* to adhere to [Semantic Versioning](http://semver.or
107
118
  - fix jets new, comment out building of middleware during boot for now
108
119
 
109
120
  ## [1.1.1]
110
- - provide instructions to run jets upgrade:v1 for config.ru update
121
+ - provide instructions to run jets upgrade for config.ru update
111
122
 
112
123
  ## [1.1.0]
113
124
  - rack compatibility pull request #72 from tongueroo/rack
@@ -178,7 +189,7 @@ This project *loosely tries* to adhere to [Semantic Versioning](http://semver.or
178
189
  - jets gems:sources hidden command
179
190
 
180
191
  ## [1.0.1]
181
- - jets upgrade:v1 command
192
+ - jets upgrade command
182
193
  - Merge pull request #52 from tongueroo/upgrade-command
183
194
 
184
195
  ## [1.0.0]
@@ -1,6 +1,6 @@
1
1
  GIT
2
2
  remote: https://github.com/tongueroo/webpacker.git
3
- revision: a8c46614c6757fab65e4d0c47d8203014e7b4ef9
3
+ revision: 3651cc317358018ebd16de75df3b8184adf1b818
4
4
  branch: jets
5
5
  specs:
6
6
  webpacker (3.2.0)
@@ -11,7 +11,7 @@ GIT
11
11
  PATH
12
12
  remote: .
13
13
  specs:
14
- jets (1.4.5)
14
+ jets (1.4.6)
15
15
  actionpack (>= 5.2.1)
16
16
  actionview (>= 5.2.1)
17
17
  activerecord (>= 5.2.1)
@@ -0,0 +1,16 @@
1
+ <h1 align="center">Backers</h1>
2
+
3
+ [Jets](http://rubyonjets.com/) is an MIT-licensed open source project. It's an independent project with its ongoing development made possible entirely thanks to the support by these awesome [backers](https://github.com/tongueroo/jets/blob/master/backers.md). If you'd like to join them, please consider:
4
+
5
+ - [Become a backer or sponsor on Patreon](https://www.patreon.com/tongueroo).
6
+
7
+ Funds donated via Patreon go directly to support Tung Nguyen's full-time work on Jets.
8
+
9
+ <br><br>
10
+
11
+ <h2 align="center">Backers via Patreon</h2>
12
+
13
+ <!--10 start-->
14
+ - Erlend Finvåg
15
+ - Nate Clark
16
+ <!--10 end-->
@@ -81,6 +81,9 @@ class Jets::Application
81
81
  # config.domain.name = "#{Jets.project_namespace}.coolapp.com" # Default is nil
82
82
  # config.domain.cert_arn = "..."
83
83
  config.domain.endpoint_type = "REGIONAL" # EDGE or REGIONAL. Default to EDGE because CloudFormation update is faster
84
+ config.domain.route53 = true # controls whether or not to create the managed route53 record.
85
+ # Useful to disable this when user wants to manage the route themself like pointing
86
+ # it to CloudFront for blue-green deployments instead.
84
87
 
85
88
  config
86
89
  end
@@ -96,7 +99,7 @@ class Jets::Application
96
99
  return ENV['JETS_PROJECT_NAME'] if ENV['JETS_PROJECT_NAME'] # override
97
100
 
98
101
  lines = IO.readlines("#{Jets.root}config/application.rb")
99
- project_name_line = lines.find { |l| l =~ /project_name/ }
102
+ project_name_line = lines.find { |l| l =~ /config\.project_name.*=/ }
100
103
  project_name_line.gsub(/.*=/,'').strip.gsub(/["']/,'') # project_name
101
104
  end
102
105
 
@@ -144,7 +147,7 @@ class Jets::Application
144
147
  puts "Gems are now bundled with with Lambda Layer and there's no need to lazy load them."
145
148
  puts "Please remove the config in your config/application.rb or config/environments files."
146
149
  puts "You can have Jets automatically do this by running:"
147
- puts " jets upgrade:v1"
150
+ puts " jets upgrade"
148
151
  end
149
152
  end
150
153
 
@@ -122,7 +122,7 @@ class Jets::Booter
122
122
  puts 'The config.ru file is missing Jets.boot. Please add Jets.boot after require "jets"'.colorize(:red)
123
123
  puts "This was changed as made in Jets v1.1.0."
124
124
  puts "To have Jets update the config.fu file for you, you can run:\n\n"
125
- puts " jets upgrade:v1"
125
+ puts " jets upgrade"
126
126
  exit 1
127
127
  end
128
128
  end
@@ -213,14 +213,14 @@ class Jets::Builders
213
213
  # Need to capture JETS_ROOT since can be changed by Turbo mode
214
214
  jets_root = Jets.root
215
215
  Bundler.with_clean_env do
216
+ # Switch gemfile for Afterburner mode
216
217
  gemfile = ENV['BUNDLE_GEMFILE']
217
218
  ENV['BUNDLE_GEMFILE'] = "#{jets_root}/rack/Gemfile"
218
-
219
219
  sh "cd #{jets_root} && bundle install"
220
+ ENV['BUNDLE_GEMFILE'] = gemfile
221
+
220
222
  rails_assets(:clobber, jets_root: jets_root)
221
223
  rails_assets(:precompile, jets_root: jets_root)
222
-
223
- ENV['BUNDLE_GEMFILE'] = gemfile
224
224
  end
225
225
  end
226
226
 
@@ -260,7 +260,7 @@ class Jets::Builders
260
260
  move_node_modules(Jets.root, Jets.build_root)
261
261
  begin
262
262
  # puts "cp -r #{@full_project_path} #{"#{stage_area}/code"}".colorize(:yellow) # uncomment to debug
263
- FileUtils.cp_r(@full_project_path, "#{stage_area}/code")
263
+ Jets::Util.cp_r(@full_project_path, "#{stage_area}/code")
264
264
  ensure
265
265
  move_node_modules(Jets.build_root, Jets.root) # move node_modules directory back
266
266
  end
@@ -307,6 +307,7 @@ class Jets::Builders
307
307
  def package_ruby
308
308
  return if Jets.poly_only?
309
309
 
310
+ check_agree
310
311
  ruby_packager.install
311
312
  reconfigure_rails # call here after "#{stage_area}/code" is available
312
313
  rack_packager.install
@@ -316,6 +317,11 @@ class Jets::Builders
316
317
  build_lambda_layer
317
318
  end
318
319
 
320
+ def check_agree
321
+ agree = Jets::Gems::Agree.new
322
+ agree.prompt
323
+ end
324
+
319
325
  def build_lambda_layer
320
326
  return if Jets.poly_only?
321
327
  lambda_layer = LambdaLayer.new
@@ -9,7 +9,7 @@ class Jets::Builders
9
9
  def purge
10
10
  if version_changed?
11
11
  last_version = @last_version || "unknown"
12
- puts "The jets version has changed enough since the last build to merit freshing the build cache."
12
+ puts "The jets version has changed enough since the last build to merit refreshing the build cache."
13
13
  puts "Current jets version: #{Jets::VERSION} Last built jets version: #{last_version}"
14
14
  puts "Removing /tmp/jets/#{@project_name} to start fresh."
15
15
  FileUtils.rm_rf("/tmp/jets/#{@project_name}")
@@ -68,7 +68,7 @@ class Jets::Builders
68
68
  def copy_gemfile_lock
69
69
  src = "#{cache_area}/Gemfile.lock"
70
70
  dest = "#{@full_app_root}/Gemfile.lock"
71
- FileUtils.cp_r(src, dest)
71
+ FileUtils.cp(src, dest)
72
72
  end
73
73
 
74
74
  # Clean up extra unneeded files to reduce package size
@@ -171,7 +171,7 @@ EOL
171
171
  # Leave #{Jets.build_root}/vendor_gems behind to act as cache
172
172
  if File.exist?("#{cache_area}/vendor/gems")
173
173
  FileUtils.mkdir_p(File.dirname(vendor_gems))
174
- FileUtils.cp_r("#{cache_area}/vendor/gems", vendor_gems)
174
+ Jets::Util.cp_r("#{cache_area}/vendor/gems", vendor_gems)
175
175
  end
176
176
  end
177
177
  end
@@ -1,5 +1,7 @@
1
1
  class Jets::Builders
2
2
  class Tidy
3
+ include Util
4
+
3
5
  def initialize(project_root, noop: false)
4
6
  @project_root = project_root
5
7
  @noop = noop
@@ -12,7 +14,21 @@ class Jets::Builders
12
14
  rm_rf(path)
13
15
  end
14
16
 
15
- tidy_bundled
17
+ clean_vendor_gems
18
+ clean_webpack_assets
19
+ end
20
+
21
+ # Clean out unnecessary src and compiled packs because Jets serves them out of s3.
22
+ # This keeps the code size down to help keep it in size limit so we can use the
23
+ # live Lambda console editor.
24
+ def clean_webpack_assets
25
+ FileUtils.rm_rf("#{@project_root}/app/javascript/src")
26
+
27
+ return unless File.exist?("#{@project_root}/public/packs") # this class works for rack subfolder too
28
+ FileUtils.mv("#{@project_root}/public/packs/manifest.json", "#{stage_area}/manifest.json")
29
+ FileUtils.rm_rf("#{@project_root}/public/packs")
30
+ FileUtils.mkdir_p("#{@project_root}/public/packs")
31
+ FileUtils.mv("#{stage_area}/manifest.json", "#{@project_root}/public/packs/manifest.json")
16
32
  end
17
33
 
18
34
  def removals
@@ -39,17 +55,17 @@ class Jets::Builders
39
55
  # We clean out ignored files pretty aggressively. So provide
40
56
  # a way for users to keep files from being cleaned out.
41
57
  def jetskeep
42
- defaults = %w[.bundle pack handlers public/assets]
58
+ always = %w[.bundle packs]
43
59
  path = "#{@project_root}/.jetskeep"
44
- return defaults unless File.exist?(path)
60
+ return always unless File.exist?(path)
45
61
 
46
62
  keep = IO.readlines(path)
47
63
  keep = keep.map {|i| i.strip}.reject { |i| i =~ /^#/ || i.empty? }
48
- (defaults + keep).uniq
64
+ (always + keep).uniq
49
65
  end
50
66
 
51
67
  # folders to remove in the vendor/gems folder regardless of the level of the folder
52
- def tidy_bundled
68
+ def clean_vendor_gems
53
69
  Dir.glob("#{@project_root}/vendor/gems/**/*").each do |path|
54
70
  next unless File.directory?(path)
55
71
  dir = File.basename(path)
@@ -41,7 +41,7 @@ class Jets::Cfn::Builders
41
41
  def add_custom_domain
42
42
  return unless Jets.custom_domain?
43
43
  add_domain_name
44
- add_route53_dns
44
+ add_route53_dns if Jets.config.domain.route53
45
45
  end
46
46
 
47
47
  def add_domain_name
@@ -130,7 +130,7 @@ class Jets::Cfn
130
130
  end
131
131
 
132
132
  def show_custom_domain
133
- return unless endpoint_available? && Jets.custom_domain?
133
+ return unless endpoint_available? && Jets.custom_domain? && Jets.config.domain.route53
134
134
 
135
135
  domain_name = Jets::Resource::ApiGateway::DomainName.new
136
136
  # Looks funny but its right.
@@ -0,0 +1,5 @@
1
+ Upgrades the Jets project structure to the latest version. This command is designed to be idempotent, so it should be safe to run this command multiple times.
2
+
3
+ ## Example
4
+
5
+ $ jets upgrade
@@ -131,6 +131,12 @@ module Jets::Commands
131
131
  puts "run #{Jets.application.endpoint}"
132
132
  end
133
133
 
134
+ desc "upgrade", "Upgrade Jets"
135
+ long_desc Help.text(:upgrade)
136
+ def upgrade
137
+ Jets::Commands::Upgrade.new(options).run
138
+ end
139
+
134
140
  desc "version", "Prints Jets version"
135
141
  long_desc Help.text(:version)
136
142
  def version
@@ -55,6 +55,7 @@ module Jets::Commands
55
55
  end
56
56
 
57
57
  def make_bin_executable
58
+ return unless File.exist?("bin")
58
59
  chmod "bin", 0755 & ~File.umask, verbose: false
59
60
  end
60
61
 
@@ -2,7 +2,7 @@
2
2
  .bundle
3
3
  .byebug_history
4
4
  .DS_Store
5
- .env.*
5
+ .env*
6
6
  /node_modules
7
7
  /public/packs
8
8
  /public/packs-test
@@ -1,11 +1,129 @@
1
+ require 'fileutils'
2
+
3
+ # This class tries to be idempotent, so users should be able to run it multiple times safely.
1
4
  module Jets::Commands
2
- class Upgrade < Jets::Commands::Base
3
- autoload :V1, "jets/commands/upgrade/v1"
5
+ class Upgrade
6
+ def initialize(options)
7
+ @options = options
8
+ end
9
+
10
+ def run
11
+ puts "Upgrading to Jets structure to latest version"
12
+ environment_configs
13
+ update_routes
14
+ update_mode_setting
15
+ update_config_ru
16
+ remove_ruby_lazy_load
17
+ update_webpack_binstubs
18
+ puts "Upgrade complete."
19
+ end
20
+
21
+ def environment_configs
22
+ path = File.expand_path("templates/skeleton/config/environments", File.dirname(__FILE__))
23
+ puts "path #{path}"
24
+ Dir.glob("#{path}/*").each do |src|
25
+ config_file = "config/environments/#{File.basename(src)}"
26
+ dest = "#{Jets.root}#{config_file}"
27
+
28
+ puts "src #{src}"
29
+ puts "dest #{dest}"
30
+ unless File.exist?(dest)
31
+ puts "Create: #{config_file}"
32
+ FileUtils.mkdir_p(File.dirname(dest))
33
+ FileUtils.cp(src, dest)
34
+ end
35
+ end
36
+ end
37
+
38
+ def update_routes
39
+ routes_file = "#{Jets.root}config/routes.rb"
40
+ return unless File.exist?(routes_file)
41
+
42
+ lines = IO.readlines(routes_file)
43
+ deprecated_code = 'root "jets/welcome#index"'
44
+ return unless lines.detect { |l| l.include?(deprecated_code) }
45
+
46
+ puts "Update: config/routes.rb"
47
+ lines.map! do |line|
48
+ if line.include?(deprecated_code)
49
+ %Q| root "jets/public#show"\n| # assume 2 spaces for simplicity
50
+ else
51
+ line
52
+ end
53
+ end
54
+
55
+ content = lines.join
56
+ IO.write(routes_file, content)
57
+ end
58
+
59
+ def update_mode_setting
60
+ application_file = "#{Jets.root}config/application.rb"
61
+ lines = IO.readlines(application_file)
62
+ deprecated_code = 'config.api_generator'
63
+ return unless lines.detect { |l| l.include?(deprecated_code) }
64
+
65
+ puts "Update: config/application.rb"
66
+ lines.map! do |line|
67
+ if line.include?(deprecated_code)
68
+ mode = Jets.config.api_generator ? 'api' : 'html'
69
+ %Q| config.mode = "#{mode}"\n| # assume 2 spaces for simplicity
70
+ else
71
+ line
72
+ end
73
+ end
74
+
75
+ content = lines.join
76
+ IO.write(application_file, content)
77
+ end
78
+
79
+ def update_config_ru
80
+ config_ru = File.read("#{Jets.root}config.ru")
81
+ return if config_ru.include?("Jets.boot")
82
+
83
+ src = File.expand_path("templates/skeleton/config.ru", File.dirname(__FILE__))
84
+ dest = "#{Jets.root}config.ru"
85
+ puts "Update: config.ru"
86
+ FileUtils.cp(src, dest)
87
+ end
88
+
89
+ def remove_ruby_lazy_load
90
+ app_config = "#{Jets.root}config/application.rb"
91
+ remove_ruby_lazy_load_for(app_config)
92
+ Dir.glob("#{Jets.root}config/environments/*.rb").each do |env_config|
93
+ remove_ruby_lazy_load_for(env_config)
94
+ end
95
+ end
96
+
97
+ def remove_ruby_lazy_load_for(path)
98
+ lines = IO.readlines(path)
99
+ new_lines = lines.reject do |l|
100
+ l =~ %r{config.ruby.lazy_load}
101
+ end
102
+ return unless lines != new_lines
103
+
104
+ content = new_lines.join("")
105
+ IO.write(path, content)
106
+ puts "Update: #{path}"
107
+ end
108
+
109
+ def update_webpack_binstubs
110
+ lines = IO.readlines("bin/webpack")
111
+ already_upgraded = lines.detect { |l| l =~ /WebpackRunner/ }
112
+ return if already_upgraded
113
+
114
+ update_project_file("bin/webpack")
115
+ update_project_file("bin/webpack-dev-server")
116
+ puts "Updated webpack binstubs."
117
+ end
4
118
 
5
- desc "v1", "Upgrades application to version 1"
6
- long_desc Help.text('upgrade:v1')
7
- def v1
8
- V1.new(options).run
119
+ private
120
+ def update_project_file(relative_path)
121
+ templates = File.expand_path("upgrade/templates", File.dirname(__FILE__))
122
+ src = "#{templates}/#{relative_path}"
123
+ dest = relative_path
124
+ FileUtils.mkdir_p(File.dirname(dest))
125
+ FileUtils.cp(src, dest)
126
+ puts "Update: #{dest}"
9
127
  end
10
128
  end
11
129
  end
@@ -0,0 +1,19 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ ENV["JETS_ENV"] ||= ENV["RACK_ENV"] || "development"
4
+ ENV["NODE_ENV"] ||= "development"
5
+
6
+ require "pathname"
7
+ ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
8
+ Pathname.new(__FILE__).realpath)
9
+
10
+ require "rubygems"
11
+ require "bundler/setup"
12
+
13
+ require "webpacker"
14
+ require "webpacker/webpack_runner"
15
+
16
+ APP_ROOT = File.expand_path("..", __dir__)
17
+ Dir.chdir(APP_ROOT) do
18
+ Webpacker::WebpackRunner.run(ARGV)
19
+ end
@@ -0,0 +1,19 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ ENV["JETS_ENV"] ||= ENV["RACK_ENV"] || "development"
4
+ ENV["NODE_ENV"] ||= "development"
5
+
6
+ require "pathname"
7
+ ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
8
+ Pathname.new(__FILE__).realpath)
9
+
10
+ require "rubygems"
11
+ require "bundler/setup"
12
+
13
+ require "webpacker"
14
+ require "webpacker/dev_server_runner"
15
+
16
+ APP_ROOT = File.expand_path("..", __dir__)
17
+ Dir.chdir(APP_ROOT) do
18
+ Webpacker::DevServerRunner.run(ARGV)
19
+ end
@@ -37,7 +37,7 @@ module Jets::Commands
37
37
  end
38
38
 
39
39
  def show_custom_domain
40
- return unless endpoint_available? && Jets.custom_domain?
40
+ return unless endpoint_available? && Jets.custom_domain? && Jets.config.domain.route53
41
41
 
42
42
  domain_name = Jets::Resource::ApiGateway::DomainName.new
43
43
  # Looks funny but its right.
@@ -39,7 +39,7 @@ class Jets::Controller
39
39
  # check out:
40
40
  # spec/fixtures/dumps/api_gateway/posts/create.json
41
41
  # spec/fixtures/dumps/rack/posts/create.json
42
- protocol = if actual_host.include?("amazonaws.com") # API Gateway
42
+ protocol = if headers["x-forwarded-proto"] # API Gateway
43
43
  headers["x-forwarded-proto"]
44
44
  elsif headers["origin"] # Rack / localhost
45
45
  URI.parse(headers["origin"]).scheme
@@ -28,7 +28,7 @@ module Jets::Mega
28
28
  http_class.capitalize!
29
29
 
30
30
  request_class = "Net::HTTP::#{http_class}".constantize # IE: Net::HTTP::Get
31
- request = request_class.new(uri.path)
31
+ request = request_class.new(uri)
32
32
 
33
33
  # Set form data
34
34
  if %w[Post Patch Put].include?(http_class)
@@ -38,7 +38,7 @@ module Jets
38
38
  Instead, please update your config/application.rb to use:
39
39
  Jets.config.mode = 'api'
40
40
  You can also run:
41
- jets upgrade:v1
41
+ jets upgrade
42
42
  EOL
43
43
  end
44
44
  api_mode = Jets.config.mode == 'api' || Jets.config.api_mode || Jets.config.api_generator
@@ -39,7 +39,7 @@ class Jets::Turbo
39
39
 
40
40
  FileUtils.mkdir_p(build_area)
41
41
  FileUtils.rm_rf(project_path)
42
- FileUtils.cp_r(jets_project, project_path)
42
+ Jets::Util.cp_r(jets_project, project_path)
43
43
 
44
44
  IO.write("#{project_path}/date.txt", Time.now) # update date.txt file to ensure Lambda function code changes and updates
45
45
  end
@@ -90,7 +90,7 @@ class Jets::Turbo
90
90
  def copy_rack_project
91
91
  dest = "#{build_area}/#{@project_folder}/rack"
92
92
  # puts "cp -r #{Dir.pwd} #{dest}" # uncomment to see and debug
93
- FileUtils.cp_r(Dir.pwd, dest)
93
+ Jets::Util.cp_r(Dir.pwd, dest)
94
94
  end
95
95
 
96
96
  # TODO: remove duplication, copied from jets/commands/import/base.rb
@@ -4,5 +4,21 @@ class Jets::Util
4
4
  def normalize_result(result)
5
5
  JSON.dump(result)
6
6
  end
7
+
8
+ def cp_r(src, dest)
9
+ # Fix for https://github.com/tongueroo/jets/issues/122
10
+ #
11
+ # Using FileUtils.cp_r doesnt work if there are special files like socket files in the src dir.
12
+ # Instead of using this hack https://bugs.ruby-lang.org/issues/10104
13
+ # Using rsync to perform the copy.
14
+ src.chop! if src.ends_with?('/')
15
+ dest.chop! if dest.ends_with?('/')
16
+ sh "rsync -a --links --no-specials --no-devices #{src}/ #{dest}/", quiet: true
17
+ end
18
+
19
+ def sh(command, quiet: false)
20
+ puts "=> #{command}" unless quiet
21
+ system(command)
22
+ end
7
23
  end
8
24
  end
@@ -1,3 +1,3 @@
1
1
  module Jets
2
- VERSION = "1.4.5"
2
+ VERSION = "1.4.6"
3
3
  end
@@ -8,8 +8,12 @@ module Jets::Gems
8
8
  def prompt
9
9
  return if File.exist?(@agree_file)
10
10
 
11
- puts "The Jets project contains binary gems that are not yet available in your gems source. You can help make Jets and the community better by reporting the missing binary gems. Reported gems get built more quickly. BoltOps takes privacy seriously and only collects anonymous non-identifiable data. You will only be asked this once."
12
- puts "Do you want send reporting data to BoltOps? (Y/n)?"
11
+ puts <<~EOL
12
+ Jets sends data about your gems to your specified lambda build service **lambdagems.com** so that it can compile and generate the necessary Lambda layers. Lambdagems only collects anonymous non-identifiable data.
13
+
14
+ Is it okay to send your gem data to Lambdagems? (Y/n)?
15
+ EOL
16
+
13
17
  answer = $stdin.gets.strip
14
18
  value = answer =~ /y/i ? 'yes' : 'no'
15
19
 
@@ -47,7 +47,6 @@ module Jets::Gems
47
47
  # Provide users with message about using their own lambdagems source.
48
48
  puts missing_message
49
49
 
50
- agree.prompt
51
50
  Report.missing(@missing_gems) if agree.yes?
52
51
  exit 1
53
52
  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: 1.4.5
4
+ version: 1.4.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tung Nguyen
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-12-24 00:00:00.000000000 Z
11
+ date: 2019-01-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: actionpack
@@ -437,6 +437,12 @@ files:
437
437
  - ".codebuild/scripts/install-dynamodb-local.sh"
438
438
  - ".codebuild/scripts/install-java.sh"
439
439
  - ".codebuild/scripts/install-node.sh"
440
+ - ".github/ISSUE_TEMPLATE.md"
441
+ - ".github/ISSUE_TEMPLATE/bug_report.md"
442
+ - ".github/ISSUE_TEMPLATE/documentation.md"
443
+ - ".github/ISSUE_TEMPLATE/feature_request.md"
444
+ - ".github/ISSUE_TEMPLATE/question.md"
445
+ - ".github/PULL_REQUEST_TEMPLATE.md"
440
446
  - ".gitignore"
441
447
  - ".gitmodules"
442
448
  - ".python-version"
@@ -452,6 +458,7 @@ files:
452
458
  - Procfile
453
459
  - README.md
454
460
  - Rakefile
461
+ - backers.md
455
462
  - bin/release
456
463
  - buildspec.yml
457
464
  - exe/jets
@@ -545,6 +552,7 @@ files:
545
552
  - lib/jets/commands/help/runner.md
546
553
  - lib/jets/commands/help/server.md
547
554
  - lib/jets/commands/help/status.md
555
+ - lib/jets/commands/help/upgrade.md
548
556
  - lib/jets/commands/help/url.md
549
557
  - lib/jets/commands/import.rb
550
558
  - lib/jets/commands/import/base.rb
@@ -582,8 +590,6 @@ files:
582
590
  - lib/jets/commands/templates/skeleton/app/models/application_item.rb
583
591
  - lib/jets/commands/templates/skeleton/app/models/application_record.rb
584
592
  - lib/jets/commands/templates/skeleton/app/views/layouts/application.html.erb.tt
585
- - lib/jets/commands/templates/skeleton/bin/ruby_server
586
- - lib/jets/commands/templates/skeleton/bin/ruby_server.rb
587
593
  - lib/jets/commands/templates/skeleton/config.ru
588
594
  - lib/jets/commands/templates/skeleton/config/application.rb.tt
589
595
  - lib/jets/commands/templates/skeleton/config/database.yml.tt
@@ -605,7 +611,8 @@ files:
605
611
  - lib/jets/commands/templates/webpacker/app/javascript/packs/theme.scss.tt
606
612
  - lib/jets/commands/templates/webpacker/app/javascript/src/jets/crud.js
607
613
  - lib/jets/commands/upgrade.rb
608
- - lib/jets/commands/upgrade/v1.rb
614
+ - lib/jets/commands/upgrade/templates/bin/webpack
615
+ - lib/jets/commands/upgrade/templates/bin/webpack-dev-server
609
616
  - lib/jets/commands/url.rb
610
617
  - lib/jets/commands/webpacker_template.rb
611
618
  - lib/jets/controller.rb
@@ -1,18 +0,0 @@
1
- #!/bin/bash
2
-
3
- set -e
4
-
5
- # Figure out where this script is located.
6
- PROJECTDIR="`dirname \"$0\"`"
7
- PROJECTDIR="`cd \"$PROJECTDIR/..\" && pwd`"
8
-
9
- unset BUNDLE_IGNORE_CONFIG
10
- # When jets packages the app code it creates .bundle/config in the project root.
11
- # We want that to be used.
12
-
13
- # Run the actual app using the bundled Ruby interpreter, with Bundler activated.
14
- if [ -n "$C9_USER" ]; then
15
- exec ruby -rbundler/setup bin/ruby_server.rb
16
- else
17
- exec "$PROJECTDIR/bundled/rbenv/shims/ruby" -rbundler/setup "$PROJECTDIR/bin/ruby_server.rb"
18
- fi
@@ -1,2 +0,0 @@
1
- require 'jets'
2
- Jets::RubyServer.run
@@ -1,104 +0,0 @@
1
- require 'fileutils'
2
-
3
- # This class tries to be idempotent, so users should be able to run it multiple times safely.
4
- class Jets::Commands::Upgrade
5
- class V1
6
- def initialize(options)
7
- @options = options
8
- end
9
-
10
- def run
11
- puts "Upgrading to Jets v1..."
12
- environment_configs
13
- update_routes
14
- update_mode_setting
15
- update_config_ru
16
- remove_ruby_lazy_load
17
- puts "Upgrade complete."
18
- end
19
-
20
- def environment_configs
21
- path = File.expand_path("../templates/skeleton/config/environments", File.dirname(__FILE__))
22
- Dir.glob("#{path}/*").each do |src|
23
- config_file = "config/environments/#{File.basename(src)}"
24
- dest = "#{Jets.root}#{config_file}"
25
- unless File.exist?(dest)
26
- puts "Create: #{config_file}"
27
- FileUtils.mkdir_p(File.dirname(dest))
28
- FileUtils.cp(src, dest)
29
- end
30
- end
31
- end
32
-
33
- def update_routes
34
- routes_file = "#{Jets.root}config/routes.rb"
35
- return unless File.exist?(routes_file)
36
-
37
- lines = IO.readlines(routes_file)
38
- deprecated_code = 'root "jets/welcome#index"'
39
- return unless lines.detect { |l| l.include?(deprecated_code) }
40
-
41
- puts "Update: config/routes.rb"
42
- lines.map! do |line|
43
- if line.include?(deprecated_code)
44
- %Q| root "jets/public#show"\n| # assume 2 spaces for simplicity
45
- else
46
- line
47
- end
48
- end
49
-
50
- content = lines.join
51
- IO.write(routes_file, content)
52
- end
53
-
54
- def update_mode_setting
55
- application_file = "#{Jets.root}config/application.rb"
56
- lines = IO.readlines(application_file)
57
- deprecated_code = 'config.api_generator'
58
- return unless lines.detect { |l| l.include?(deprecated_code) }
59
-
60
- puts "Update: config/application.rb"
61
- lines.map! do |line|
62
- if line.include?(deprecated_code)
63
- mode = Jets.config.api_generator ? 'api' : 'html'
64
- %Q| config.mode = "#{mode}"\n| # assume 2 spaces for simplicity
65
- else
66
- line
67
- end
68
- end
69
-
70
- content = lines.join
71
- IO.write(application_file, content)
72
- end
73
-
74
- def update_config_ru
75
- config_ru = File.read("#{Jets.root}config.ru")
76
- return if config_ru.include?("Jets.boot")
77
-
78
- src = File.expand_path("../templates/skeleton/config.ru", File.dirname(__FILE__))
79
- dest = "#{Jets.root}config.ru"
80
- puts "Update: config.ru"
81
- FileUtils.cp(src, dest)
82
- end
83
-
84
- def remove_ruby_lazy_load
85
- app_config = "#{Jets.root}config/application.rb"
86
- remove_ruby_lazy_load_for(app_config)
87
- Dir.glob("#{Jets.root}config/environments/*.rb").each do |env_config|
88
- remove_ruby_lazy_load_for(env_config)
89
- end
90
- end
91
-
92
- def remove_ruby_lazy_load_for(path)
93
- lines = IO.readlines(path)
94
- new_lines = lines.reject do |l|
95
- l =~ %r{config.ruby.lazy_load}
96
- end
97
- return unless lines != new_lines
98
-
99
- content = new_lines.join("")
100
- IO.write(path, content)
101
- puts "Update: #{path}"
102
- end
103
- end
104
- end