jets 1.0.1 → 1.0.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (77) hide show
  1. checksums.yaml +4 -4
  2. data/.gitmodules +3 -3
  3. data/CHANGELOG.md +6 -0
  4. data/Gemfile.lock +1 -1
  5. data/README.md +23 -1
  6. data/jets.gemspec +1 -2
  7. data/lib/jets.rb +5 -11
  8. data/lib/jets/builders/gem_replacer.rb +12 -96
  9. data/lib/jets/builders/ruby_packager.rb +3 -4
  10. data/lib/jets/builders/tidy.rb +9 -0
  11. data/lib/jets/commands.rb +1 -0
  12. data/lib/jets/commands/base.rb +10 -1
  13. data/lib/jets/commands/gems.rb +25 -0
  14. data/lib/jets/commands/help/gems/check.md +7 -0
  15. data/lib/jets/commands/help/import/rails.md +3 -3
  16. data/lib/jets/commands/import.rb +4 -0
  17. data/lib/jets/commands/import/base.rb +10 -0
  18. data/lib/jets/commands/import/cheatsheet.rb +35 -0
  19. data/lib/jets/commands/import/rail.rb +7 -0
  20. data/lib/jets/commands/import/sequence.rb +63 -47
  21. data/lib/jets/commands/import/templates/submodules-cheatsheet.md +89 -0
  22. data/lib/jets/db.rb +9 -0
  23. data/lib/jets/version.rb +1 -1
  24. data/vendor/jets-gems/Gemfile +6 -0
  25. data/vendor/jets-gems/Gemfile.lock +39 -0
  26. data/vendor/jets-gems/LICENSE.txt +21 -0
  27. data/vendor/jets-gems/README.md +19 -0
  28. data/vendor/{lambdagem → jets-gems}/Rakefile +2 -2
  29. data/vendor/jets-gems/bin/console +14 -0
  30. data/vendor/jets-gems/bin/setup +8 -0
  31. data/vendor/jets-gems/jets-gems.gemspec +30 -0
  32. data/vendor/jets-gems/lib/jets-gems.rb +1 -0
  33. data/vendor/jets-gems/lib/jets/gems.rb +16 -0
  34. data/vendor/jets-gems/lib/jets/gems/check.rb +156 -0
  35. data/vendor/jets-gems/lib/jets/gems/exist.rb +54 -0
  36. data/vendor/jets-gems/lib/jets/gems/extract.rb +7 -0
  37. data/vendor/{lambdagem/lib/lambdagem → jets-gems/lib/jets/gems}/extract/base.rb +25 -6
  38. data/vendor/{lambdagem/lib/lambdagem → jets-gems/lib/jets/gems}/extract/gem.rb +10 -8
  39. data/vendor/{lambdagem/lib/lambdagem → jets-gems/lib/jets/gems}/extract/ruby.rb +6 -7
  40. data/vendor/jets-gems/lib/jets/gems/report.rb +53 -0
  41. data/vendor/jets-gems/lib/jets/gems/version.rb +5 -0
  42. data/vendor/jets-gems/spec/jets/gems_spec.rb +5 -0
  43. data/vendor/jets-gems/spec/spec_helper.rb +14 -0
  44. metadata +41 -53
  45. data/vendor/lambdagem/CHANGELOG.md +0 -27
  46. data/vendor/lambdagem/Gemfile +0 -6
  47. data/vendor/lambdagem/Gemfile.lock +0 -73
  48. data/vendor/lambdagem/Guardfile +0 -12
  49. data/vendor/lambdagem/LICENSE.txt +0 -22
  50. data/vendor/lambdagem/README.md +0 -139
  51. data/vendor/lambdagem/exe/lambdagem +0 -14
  52. data/vendor/lambdagem/lambdagem.gemspec +0 -32
  53. data/vendor/lambdagem/lib/lambdagem.rb +0 -18
  54. data/vendor/lambdagem/lib/lambdagem/base.rb +0 -53
  55. data/vendor/lambdagem/lib/lambdagem/build.rb +0 -202
  56. data/vendor/lambdagem/lib/lambdagem/clean.rb +0 -8
  57. data/vendor/lambdagem/lib/lambdagem/cli.rb +0 -62
  58. data/vendor/lambdagem/lib/lambdagem/command.rb +0 -38
  59. data/vendor/lambdagem/lib/lambdagem/exist.rb +0 -50
  60. data/vendor/lambdagem/lib/lambdagem/extract.rb +0 -8
  61. data/vendor/lambdagem/lib/lambdagem/extract/class_methods.rb +0 -50
  62. data/vendor/lambdagem/lib/lambdagem/help.rb +0 -9
  63. data/vendor/lambdagem/lib/lambdagem/help/all.md +0 -11
  64. data/vendor/lambdagem/lib/lambdagem/help/build.md +0 -14
  65. data/vendor/lambdagem/lib/lambdagem/help/clean.md +0 -5
  66. data/vendor/lambdagem/lib/lambdagem/help/extract_gem.md +0 -5
  67. data/vendor/lambdagem/lib/lambdagem/help/extract_ruby.md +0 -5
  68. data/vendor/lambdagem/lib/lambdagem/help/package.md +0 -20
  69. data/vendor/lambdagem/lib/lambdagem/help/upload.md +0 -7
  70. data/vendor/lambdagem/lib/lambdagem/package.rb +0 -33
  71. data/vendor/lambdagem/lib/lambdagem/upload.rb +0 -39
  72. data/vendor/lambdagem/lib/lambdagem/util.rb +0 -30
  73. data/vendor/lambdagem/lib/lambdagem/version.rb +0 -3
  74. data/vendor/lambdagem/spec/lib/build_spec.rb +0 -32
  75. data/vendor/lambdagem/spec/lib/cli_spec.rb +0 -24
  76. data/vendor/lambdagem/spec/lib/upload_spec.rb +0 -25
  77. data/vendor/lambdagem/spec/spec_helper.rb +0 -24
@@ -0,0 +1,35 @@
1
+ class Jets::Commands::Import
2
+ class Cheatsheet
3
+ def self.create(rack_repo_url)
4
+ new(rack_repo_url).create
5
+ end
6
+
7
+ def initialize(rack_repo_url)
8
+ @rack_repo_url = rack_repo_url
9
+ end
10
+
11
+ def create
12
+ path = File.expand_path("./templates/", File.dirname(__FILE__)) + "/submodules-cheatsheet.md"
13
+ basename = File.basename(path)
14
+ dest = "#{Jets.root}#{basename}"
15
+ cheatsheet = Jets::Erb.result(path, cheatsheet_vars)
16
+ FileUtils.mkdir_p(File.dirname(dest))
17
+ IO.write(dest, cheatsheet)
18
+ puts "Created #{basename} to help with using submodules."
19
+ end
20
+
21
+ def cheatsheet_vars
22
+ import_command = ARGV[0]
23
+ {
24
+ import_command: import_command,
25
+ rack_repo_url: @rack_repo_url,
26
+ jets_project_repo_url: jets_project_repo_url,
27
+ }
28
+ end
29
+
30
+ def jets_project_repo_url
31
+ # Thanks: https://stackoverflow.com/questions/4089430/how-can-i-determine-the-url-that-a-local-git-repository-was-originally-cloned-fr/4089452
32
+ `git config --get remote.origin.url`.strip rescue 'https://github.com/user/repo'
33
+ end
34
+ end
35
+ end
@@ -28,6 +28,13 @@ CODE
28
28
  end
29
29
  end
30
30
 
31
+ def copy_database_yaml
32
+ src = "#{Jets.root}config/database.yml"
33
+ dest = "#{Jets.root}rack/config/database.yml"
34
+ puts "Copying #{src} to #{dest}"
35
+ FileUtils.cp(src, dest)
36
+ end
37
+
31
38
  def finish_message
32
39
  puts <<~EOL
33
40
  #{"="*30}
@@ -4,65 +4,81 @@ require 'active_support/core_ext/string'
4
4
  require 'thor'
5
5
  require 'bundler'
6
6
 
7
- class Jets::Commands::Import::Sequence < Thor::Group
8
- include Thor::Actions
9
- argument :source
7
+ class Jets::Commands::Import
8
+ class Sequence < Thor::Group
9
+ include Thor::Actions
10
+ argument :source
10
11
 
11
- private
12
- def clone_project
13
- check_git_installed
12
+ private
13
+ def clone_project
14
+ if File.exist?(rack_folder)
15
+ abort "The folder #{rack_folder} already exists. Please remove it first if you want to import a project."
16
+ end
17
+
18
+ check_git_installed
19
+ if @options[:submodule]
20
+ git_submodule
21
+ else
22
+ git_clone
23
+ end
24
+ end
25
+
26
+ def git_submodule
27
+ puts "Adding project as a submodule"
28
+ run "git submodule add --force #{repo_url} #{rack_folder}"
29
+ Cheatsheet.create(repo_url)
30
+ end
14
31
 
15
- command = "git clone #{repo_url} #{rack_folder}"
16
- puts "=> #{command}"
17
- if File.exist?(rack_folder)
18
- abort "The folder #{rack_folder} already exists."
19
- else
32
+ def git_clone
33
+ command = "git clone #{repo_url} #{rack_folder}"
34
+ # Thor's run already puts out the command, so no need to puts
20
35
  run command
36
+ run "rm -rf #{Jets.root}rack/.git"
21
37
  end
22
- end
23
38
 
24
- def copy_project
25
- puts "Creating rack folder"
26
- template_path = File.expand_path(@source)
27
- set_source_paths(template_path)
28
- directory ".", rack_folder
29
- end
39
+ def copy_project
40
+ puts "Creating rack folder"
41
+ template_path = File.expand_path(@source)
42
+ set_source_paths(template_path)
43
+ directory ".", rack_folder
44
+ end
30
45
 
31
- def set_source_paths(*paths)
32
- # Using string with instance_eval because block doesnt have access to
33
- # path at runtime.
34
- self.class.instance_eval %{
35
- def self.source_paths
36
- #{paths.flatten.inspect}
37
- end
38
- }
39
- end
46
+ def set_source_paths(*paths)
47
+ # Using string with instance_eval because block doesnt have access to
48
+ # path at runtime.
49
+ self.class.instance_eval %{
50
+ def self.source_paths
51
+ #{paths.flatten.inspect}
52
+ end
53
+ }
54
+ end
40
55
 
41
- # normalize repo_url
42
- def repo_url
43
- if @source.include?('github.com')
44
- @source # leave as is, user has provided full github url
45
- else
46
- "https://github.com/#{@source}"
56
+ # normalize repo_url
57
+ def repo_url
58
+ if @source.include?('github.com')
59
+ @source # leave as is, user has provided full github url
60
+ else
61
+ "https://github.com/#{@source}"
62
+ end
47
63
  end
48
- end
49
64
 
50
- def repo?
51
- @source.include?('github.com')
52
- end
65
+ def repo?
66
+ @source.include?('github.com')
67
+ end
53
68
 
54
- def check_git_installed
55
- return unless repo_url.include?('http') || repo_url.include?('git@')
56
- unless git_installed?
57
- abort "Unable to detect git installation on your system. Git needs to be installed in order to clone the project."
69
+ def check_git_installed
70
+ return unless repo_url.include?('http') || repo_url.include?('git@')
71
+ unless git_installed?
72
+ abort "Unable to detect git installation on your system. Git needs to be installed in order to clone the project."
73
+ end
58
74
  end
59
- end
60
75
 
61
- def git_installed?
62
- system("type git > /dev/null 2>&1")
63
- end
76
+ def git_installed?
77
+ system("type git > /dev/null 2>&1")
78
+ end
64
79
 
65
- def rack_folder
66
- "#{Jets.root}rack"
80
+ def rack_folder
81
+ "#{Jets.root}rack"
82
+ end
67
83
  end
68
84
  end
@@ -0,0 +1,89 @@
1
+ # Git Submodule Cheatsheet
2
+
3
+ Git submodules take a little bit of getting used to. This is a cheatsheet for Git Submodules to help learn how to use them. This file was generated as part of the `jets <%= @import_command %>` command.
4
+
5
+ ## Cheatsheet Summary
6
+
7
+ The important submodule commands are:
8
+
9
+ ### On fresh clone project
10
+
11
+ git clone <%= @jets_project_repo_url %>
12
+ git submodule init # required on a fresh clone, or update won't do anything
13
+ git submodule update # syncs submodule rack folder with what parent project has as commits
14
+
15
+ ### Updating
16
+
17
+ After doing a git pull on the Jets main project, you might notice changes to the submodule rack folder, you can update the rack folder with:
18
+
19
+ git submodule update # syncs submodule rack folder with what parent project has as commits
20
+
21
+ ## More Details
22
+
23
+ The rest of the guide will explain in a little more detail submodules.
24
+
25
+ ## What are Git Submodules?
26
+
27
+ Git submodules are a way to have a subfolder in your project be managed as a separate git repo. The submodule folder is its own separate git repo and has its own history. The parent git project references a commit from the submodule project to sync up the subfolder accordingly. Using submodules allows you to include a rack subfolder project into your Jets project code base and managed the rack project as a separate git repo.
28
+
29
+ By using the `--submodule` option when you run the `jets import` command, Jets imports the rack project to the rack folder as a submodule. This allows you to keep development of the rack project independent from the development of the Jets project. This is a useful setup if you are testing [Jets Mega Mode](http://rubyonjets.com/docs/megamode/) for more extended periods of time.
30
+
31
+ We'll show you how to managed and sync the `rack` submodule folder with the parent Jets project folder.
32
+
33
+ ### rack submodule
34
+
35
+ A rack folder was added to your Jets project as a git submodule. Essentially this command was run.
36
+
37
+ git submodule add --force <%= @rack_repo_url %> rack
38
+
39
+ The rack submodule folder gets immediately synced as a part of that `git submodule add` command. This has already happened as part of the `jets <%= @import_command %>, we're just explaining the underlying command in case you're interested.
40
+
41
+ ### Fresh Clone
42
+
43
+ **IMPORTANT**: On a fresh clone of your project, submodule folders do not automatically update and appear "empty". This can be confusing for people who don't use submodules often. So here are the commands to update and sync the submodule folder:
44
+
45
+ git clone <%= @jets_project_repo_url %>
46
+ git submodule init # important to run init or next update will do nothing
47
+ git submodule update # after this the rack folder will no longer be empty
48
+ # and will have code from <%= @rack_repo_url %>
49
+
50
+ ### Remove submodule
51
+
52
+ If you ever decide to remove the submodule from your project, here are the commands.
53
+
54
+ git submodule deinit rack
55
+ git rm rack
56
+ # then add and commit your changes
57
+
58
+ ## Updating Projects
59
+
60
+ The typical workflow is to go into the rack folder and run `git pull` to update the submodule folder to the latest changes. Then you cd back up to the main Jets project folder and run `git add`. This updates the project submodule commit reference, which then allows others to pull down the changes and resync the submodules to the same commit. We'll go through some examples to help explain:
61
+
62
+ ### Updating rack folder submodule
63
+
64
+ Here's an example where we will update the rack submodule folder to the latest `master` branch. Remember the master branch refers to the `rack` submodule folder of the <%= @rack_repo_url %> in this case.
65
+
66
+ cd my-jets-project # root of the Jets project
67
+ cd rack # in the submodule now, which contains a different repo history
68
+ git checkout master # on a fresh clone, the submodule folder will point to a specific git sha instead of a branch
69
+ git pull # get latest changes in master
70
+ cd .. # back to parent Jets project
71
+ git status # notice, it'll say: modified: rack (new commits)
72
+ git add rack # updates the main projects' reference to the submodule git commit
73
+ git commit -m "update rack submodule"
74
+ git push # send your changes to everyone else
75
+
76
+ Eventually, later another developer will pull down your changes on the Jets project and notice that the submodules have been updated. When he runs a `git pull` and then does a `git status` he'll notice this:
77
+
78
+ $ git pull # another developer pulled down the changes
79
+ $ git st # notice the changes
80
+ modified: rack (new commits)
81
+ $ git diff # another way a summary of the changes in the rack project
82
+ Submodule rack 6b0fb3a..4f6ea3f (rewind):
83
+ < test commit in rack submodule project
84
+
85
+ This is when the developer will need to resync the rack submodule folder. He does it with this:
86
+
87
+ git submodule update # updates the rack folder to the commit that the parent is referencing
88
+
89
+ That's it!
data/lib/jets/db.rb ADDED
@@ -0,0 +1,9 @@
1
+ module Jets::Db ; end
2
+
3
+ # Thanks: https://makandracards.com/makandra/42521-detecting-if-a-ruby-gem-is-loaded
4
+ return unless File.exist?("#{Jets.root}config/database.yml")
5
+
6
+ require "active_record"
7
+ specs = Gem.loaded_specs
8
+ require "mysql2" if specs.key?('mysql2')
9
+ require "pg" if specs.key?('pg')
data/lib/jets/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Jets
2
- VERSION = "1.0.1"
2
+ VERSION = "1.0.2"
3
3
  end
@@ -0,0 +1,6 @@
1
+ source "https://rubygems.org"
2
+
3
+ git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
4
+
5
+ # Specify your gem's dependencies in jets-gems.gemspec
6
+ gemspec
@@ -0,0 +1,39 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ jets-gems (0.1.0)
5
+ gems
6
+
7
+ GEM
8
+ remote: https://rubygems.org/
9
+ specs:
10
+ diff-lcs (1.3)
11
+ gems (1.1.1)
12
+ json
13
+ json (2.1.0)
14
+ rake (10.5.0)
15
+ rspec (3.8.0)
16
+ rspec-core (~> 3.8.0)
17
+ rspec-expectations (~> 3.8.0)
18
+ rspec-mocks (~> 3.8.0)
19
+ rspec-core (3.8.0)
20
+ rspec-support (~> 3.8.0)
21
+ rspec-expectations (3.8.2)
22
+ diff-lcs (>= 1.2.0, < 2.0)
23
+ rspec-support (~> 3.8.0)
24
+ rspec-mocks (3.8.0)
25
+ diff-lcs (>= 1.2.0, < 2.0)
26
+ rspec-support (~> 3.8.0)
27
+ rspec-support (3.8.0)
28
+
29
+ PLATFORMS
30
+ ruby
31
+
32
+ DEPENDENCIES
33
+ bundler (~> 1.16)
34
+ jets-gems!
35
+ rake (~> 10.0)
36
+ rspec (~> 3.0)
37
+
38
+ BUNDLED WITH
39
+ 1.16.3
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2018 Tung Nguyen
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
@@ -0,0 +1,19 @@
1
+ # Jets Gems
2
+
3
+ [Jets](http://rubyonjets.com/) is a Ruby Serverless Framework on AWS Lambda. allows you to create serverless applications with a beautiful language: Ruby. It includes everything required to build an application and deploy it to AWS Lambda. Jets makes serverless simple.
4
+
5
+ The jets-gems library works with Jets to download and extract pre-compiled gems that work on AWS Lambda.
6
+
7
+ ## Development
8
+
9
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
10
+
11
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
12
+
13
+ ## Contributing
14
+
15
+ Bug reports and pull requests are welcome on GitHub at [tongueroo/jets-gems](https://github.com/tongueroo/jets-gems)
16
+
17
+ ## License
18
+
19
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
@@ -1,6 +1,6 @@
1
1
  require "bundler/gem_tasks"
2
2
  require "rspec/core/rake_task"
3
3
 
4
- task :default => :spec
4
+ RSpec::Core::RakeTask.new(:spec)
5
5
 
6
- RSpec::Core::RakeTask.new
6
+ task :default => :spec
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "jets/gems"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start(__FILE__)
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,30 @@
1
+
2
+ lib = File.expand_path("../lib", __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require "jets/gems/version"
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "jets-gems"
8
+ spec.version = Jets::Gems::VERSION
9
+ spec.authors = ["Tung Nguyen"]
10
+ spec.email = ["tongueroo@gmail.com"]
11
+
12
+ spec.summary = %q{Library manages pre-compiled Lambda Gems for Jets Ruby Serverless Framework}
13
+ spec.homepage = "https://github.com/tongueroo/jets-gems"
14
+ spec.license = "MIT"
15
+
16
+ # Specify which files should be added to the gem when it is released.
17
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
18
+ spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
19
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
20
+ end
21
+ spec.bindir = "exe"
22
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
23
+ spec.require_paths = ["lib"]
24
+
25
+ spec.add_dependency "gems"
26
+
27
+ spec.add_development_dependency "bundler", "~> 1.16"
28
+ spec.add_development_dependency "rake", "~> 10.0"
29
+ spec.add_development_dependency "rspec", "~> 3.0"
30
+ end