jets-cli 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (31) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile.lock +4 -4
  3. data/bin/jets +1 -0
  4. data/jets-cli.gemspec +1 -1
  5. data/lib/jets/cli/main.rb +43 -2
  6. data/lib/jets/cli/version.rb +1 -1
  7. metadata +1 -25
  8. data/lib/generators/jets/engine/engine_generator.rb +0 -24
  9. data/lib/generators/jets/engine/templates/%name%.gemspec.tt +0 -31
  10. data/lib/generators/jets/engine/templates/.bundle/config +0 -2
  11. data/lib/generators/jets/engine/templates/.gitignore.tt +0 -16
  12. data/lib/generators/jets/engine/templates/.pryrc.tt +0 -33
  13. data/lib/generators/jets/engine/templates/.rspec +0 -3
  14. data/lib/generators/jets/engine/templates/.rubocop.yml.tt +0 -3
  15. data/lib/generators/jets/engine/templates/Gemfile +0 -19
  16. data/lib/generators/jets/engine/templates/Gemfile.runtime +0 -0
  17. data/lib/generators/jets/engine/templates/README.md.tt +0 -3
  18. data/lib/generators/jets/engine/templates/Rakefile.tt +0 -9
  19. data/lib/generators/jets/engine/templates/bin/console.tt +0 -9
  20. data/lib/generators/jets/engine/templates/bin/rails.tt +0 -11
  21. data/lib/generators/jets/engine/templates/config/.keep +0 -0
  22. data/lib/generators/jets/engine/templates/db/migrate/.keep +0 -0
  23. data/lib/generators/jets/engine/templates/lib/%name%.rb.tt +0 -22
  24. data/lib/generators/jets/engine/templates/lib/%name%/engine.rb.tt +0 -31
  25. data/lib/generators/jets/engine/templates/lib/%name%/version.rb.tt +0 -5
  26. data/lib/generators/jets/engine/templates/spec/factories/.keep +0 -0
  27. data/lib/generators/jets/engine/templates/spec/internal/config/database.yml.tt +0 -6
  28. data/lib/generators/jets/engine/templates/spec/internal/config/storage.yml.tt +0 -3
  29. data/lib/generators/jets/engine/templates/spec/internal/db/schema.rb +0 -4
  30. data/lib/generators/jets/engine/templates/spec/rails_helper.rb.tt +0 -57
  31. data/lib/generators/jets/engine/templates/spec/spec_helper.rb +0 -6
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 90f8227940a09c2f094ac5a77a0dbc7164c11e4f0cc8aae5f4520f9497c0b973
4
- data.tar.gz: 2e339a34aad9a16e69210a9bd50b99dae3d8c1265d53b8a2599a684e87dd5a10
3
+ metadata.gz: 20ef5ceb3278bde58c28c0730acf6db3455d5ec5634862f4431836dd6dee7632
4
+ data.tar.gz: d3a326fcbcc7ffddd7757cebedeb43ee21cbee49f779544ec59f3206ef2a01dc
5
5
  SHA512:
6
- metadata.gz: e72ec74be5a9125bbe72ae299174f353c4a814b22cd9615bc6654be27a4ea2af4c79af70610b6ec0d92ff34f435d7807c6f551a11b64a4abdabc3d8536f73141
7
- data.tar.gz: 92cd8285d620049006165ed850c8fba099ce069f59446a17b968b83bdac1332660777987b5376ee3f7ddf0e988cfffd57fe65576f4fc23a59509ae6e328a8e7e
6
+ metadata.gz: 8397fe8064f9e7ccf9bb4a6e8ff7e45ec37f940d0421ff802f9fcba872ddf98fe445d458a4cbe48d2cb9d233e6384259ad87e523c5c8480c8b5afdeae8765b17
7
+ data.tar.gz: be34f84027a850959576e8eea4d813a7e1dce252ebe321cdd36749e7cbe414fd53d972f3b36da1363d1c7f6087257e6cb4653ffd39b052d21788439876a92187
@@ -15,7 +15,7 @@ PATH
15
15
  specs:
16
16
  jets-cli (0.1.0)
17
17
  rails (~> 6.0)
18
- thor
18
+ thor (~> 1.0)
19
19
 
20
20
  GEM
21
21
  remote: https://rubygems.org/
@@ -251,11 +251,11 @@ PLATFORMS
251
251
  ruby
252
252
 
253
253
  DEPENDENCIES
254
- aruba
255
- bundler
254
+ aruba (~> 1.0)
255
+ bundler (~> 2)
256
256
  jets-cli!
257
257
  jets-rubocop!
258
- pry
258
+ pry (~> 0.13)
259
259
  rake (~> 12.0)
260
260
  rspec (~> 3.0)
261
261
 
data/bin/jets CHANGED
@@ -1,6 +1,7 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
3
  require "bundler/setup"
4
+ require "jets/cli/exceptions"
4
5
  require "jets/cli"
5
6
 
6
7
  begin
@@ -6,7 +6,7 @@ rails_version = "~> 6.0"
6
6
 
7
7
  Gem::Specification.new do |spec|
8
8
  spec.name = "jets-cli"
9
- spec.version = Jets::CLI::VERSION
9
+ spec.version = Jets::CLI::VERSION.dup
10
10
  spec.authors = ["Lauri Jutila"]
11
11
 
12
12
  spec.summary = "Jets CLI"
@@ -1,6 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require "thor"
4
+ require "bundler"
4
5
 
5
6
  module Jets
6
7
  module CLI
@@ -28,11 +29,51 @@ module Jets
28
29
  end
29
30
  end
30
31
 
32
+ desc "NAME console", "Run `rails console` for given engine"
33
+ long_desc <<-LONGDESC
34
+ `jets NAME console` will run Rails console for given engine.
35
+ LONGDESC
36
+ def console
37
+ exec_command("./bin/console")
38
+ end
39
+
31
40
  desc "NAME rails [OPTIONS]", "Run `rails` command for given engine"
41
+ long_desc <<-LONGDESC
42
+ `jets NAME rails` will run Rails commands for given engine.
43
+ LONGDESC
44
+
32
45
  def rails(*args)
33
46
  exec_command("./bin/rails", *args)
34
47
  end
35
48
 
49
+ desc "NAME yarn", "Run `yarn` for given engine"
50
+ long_desc <<-LONGDESC
51
+ `jets NAME yarn` will run yarn for given engine.
52
+ LONGDESC
53
+ def yarn(*args)
54
+ exec_command("yarn", *args)
55
+ end
56
+
57
+ def method_missing(engine_or_gem, *args)
58
+ options =
59
+ case engine_or_gem.to_s
60
+ when "all"
61
+ { all: true }
62
+ when "all-gems"
63
+ { all_gems: true }
64
+ when "all-engines"
65
+ { all_engines: true }
66
+ when *engines
67
+ { engine: engine_or_gem.to_s }
68
+ when *gems
69
+ { engine: engine_or_gem.to_s, gem: true }
70
+ end
71
+
72
+ return super if options.nil?
73
+
74
+ self.class.start(args, class_options: options)
75
+ end
76
+
36
77
  private
37
78
 
38
79
  def engine
@@ -52,7 +93,7 @@ module Jets
52
93
  end
53
94
 
54
95
  def app_root
55
- # @app_root ||= File.expand_path("..", __dir__)
96
+ # @app_root ||= File.expand_path("../../..", __dir__)
56
97
  @app_root ||= if defined?(Rails)
57
98
  Rails.root
58
99
  else
@@ -89,7 +130,7 @@ module Jets
89
130
  message = "Command `#{command}` (from #{dir}) returned non-zero exit code"
90
131
 
91
132
  $stdout.puts message
92
- raise CommandFailedException, message unless options[:ignore_failures]
133
+ raise ::Jets::CLI::Exceptions::CommandFailed, message unless options[:ignore_failures]
93
134
  end
94
135
  end
95
136
  end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Jets
4
4
  module CLI
5
- VERSION = "0.1.0"
5
+ VERSION = "0.1.1"
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jets-cli
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Lauri Jutila
@@ -142,30 +142,6 @@ files:
142
142
  - bin/jets
143
143
  - bin/setup
144
144
  - jets-cli.gemspec
145
- - lib/generators/jets/engine/engine_generator.rb
146
- - lib/generators/jets/engine/templates/%name%.gemspec.tt
147
- - lib/generators/jets/engine/templates/.bundle/config
148
- - lib/generators/jets/engine/templates/.gitignore.tt
149
- - lib/generators/jets/engine/templates/.pryrc.tt
150
- - lib/generators/jets/engine/templates/.rspec
151
- - lib/generators/jets/engine/templates/.rubocop.yml.tt
152
- - lib/generators/jets/engine/templates/Gemfile
153
- - lib/generators/jets/engine/templates/Gemfile.runtime
154
- - lib/generators/jets/engine/templates/README.md.tt
155
- - lib/generators/jets/engine/templates/Rakefile.tt
156
- - lib/generators/jets/engine/templates/bin/console.tt
157
- - lib/generators/jets/engine/templates/bin/rails.tt
158
- - lib/generators/jets/engine/templates/config/.keep
159
- - lib/generators/jets/engine/templates/db/migrate/.keep
160
- - lib/generators/jets/engine/templates/lib/%name%.rb.tt
161
- - lib/generators/jets/engine/templates/lib/%name%/engine.rb.tt
162
- - lib/generators/jets/engine/templates/lib/%name%/version.rb.tt
163
- - lib/generators/jets/engine/templates/spec/factories/.keep
164
- - lib/generators/jets/engine/templates/spec/internal/config/database.yml.tt
165
- - lib/generators/jets/engine/templates/spec/internal/config/storage.yml.tt
166
- - lib/generators/jets/engine/templates/spec/internal/db/schema.rb
167
- - lib/generators/jets/engine/templates/spec/rails_helper.rb.tt
168
- - lib/generators/jets/engine/templates/spec/spec_helper.rb
169
145
  - lib/jets/cli.rb
170
146
  - lib/jets/cli/exceptions.rb
171
147
  - lib/jets/cli/main.rb
@@ -1,24 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require "rails/generators"
4
-
5
- module Jets
6
- module Generators
7
- class EngineGenerator < ::Rails::Generators::NamedBase
8
- include ::Rails::Generators::ResourceHelpers
9
-
10
- namespace "jets"
11
- source_root File.expand_path("templates", __dir__)
12
-
13
- desc "Generates a Rails engine with given NAME with Jets conventions " \
14
- "and configurations."
15
-
16
- def create_engine_file
17
- directory(".", "engines/#{name}")
18
-
19
- chmod "engines/#{name}/bin/console", 0o755, verbose: false
20
- chmod "engines/#{name}/bin/rails", 0o755, verbose: false
21
- end
22
- end
23
- end
24
- end
@@ -1,31 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- $LOAD_PATH.push File.expand_path("lib", __dir__)
4
-
5
- require "<%= name %>/version"
6
-
7
- # Use Rails version from the project's root
8
- rails_version = File.read(File.join(__dir__, "../../.rails-version"))
9
-
10
- Gem::Specification.new do |s|
11
- s.name = "<%= name %>"
12
- s.version = <%= class_name %>::VERSION
13
- s.authors = ["TODO"]
14
- s.summary = "TODO:"
15
- s.description = "TODO:"
16
-
17
- s.files = Dir["{app,config,db,lib}/**/*"]
18
- s.require_paths = ["lib"]
19
-
20
- s.add_dependency "rails", rails_version
21
- s.add_dependency "pg", "~> 1.0"
22
-
23
- s.add_development_dependency "brakeman", "~> 4.7"
24
- s.add_development_dependency "bundler", ">= 2.0"
25
- s.add_development_dependency "pry-byebug", ">= 3.4"
26
- s.add_development_dependency "rake", "~> 13.0"
27
-
28
- # Internal
29
- s.add_development_dependency "jets-rubocop"
30
- s.add_development_dependency "jets-testing"
31
- end
@@ -1,2 +0,0 @@
1
- ---
2
- BUNDLE_GEMFILE: "../../Gemfile"
@@ -1,16 +0,0 @@
1
- log/*.log
2
- pkg/
3
- spec/internal/log/*.log
4
- spec/internal/tmp/
5
- spec/examples.txt
6
- tmp/
7
- /node_modules
8
- /public/packs*
9
- yarn-debug.log*
10
- .yarn-integrity
11
- package-lock.json
12
- yarn-error.log
13
- .offspring
14
- .rspec-local
15
- /.pry_history
16
- /test-results
@@ -1,33 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- def formatted_env
4
- if defined?(Rails)
5
- case Rails.env
6
- when "production"
7
- bold_upcased_env = Pry::Helpers::Text.bold(Rails.env.upcase)
8
- Pry::Helpers::Text.red(bold_upcased_env)
9
- when "staging"
10
- Pry::Helpers::Text.yellow(Rails.env)
11
- when "development"
12
- Pry::Helpers::Text.green(Rails.env)
13
- else
14
- Rails.env
15
- end
16
- else
17
- Pry::Helpers::Text.green("<%= name %>")
18
- end
19
- end
20
-
21
- def app_name
22
- if defined?(Rails)
23
- File.basename(Rails.root)
24
- else
25
- "<%= name %>"
26
- end
27
- end
28
-
29
- Pry.config.prompt = Pry::Prompt.new(
30
- "jets-rubocop",
31
- "Jets Rubocop prompt",
32
- [proc { |obj, nest_level, _| "[#{app_name}][#{formatted_env}] #{obj}:#{nest_level}> " }]
33
- )
@@ -1,3 +0,0 @@
1
- --color
2
- --format Fuubar
3
- --require spec_helper
@@ -1,3 +0,0 @@
1
- inherit_gem:
2
- jets-rubocop:
3
- - config/base.yml
@@ -1,19 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- source "https://rubygems.org"
4
-
5
- git_source(:github) do |repo_name|
6
- repo_name = "#{repo_name}/#{repo_name}" unless repo_name.include?("/")
7
- "https://github.com/#{repo_name}.git"
8
- end
9
-
10
- gemspec
11
-
12
- eval_gemfile "./Gemfile.runtime"
13
-
14
- gem "jets-testing"
15
- gem "jets-rubocop"
16
-
17
- # Speed up application code loading
18
- # https://github.com/Shopify/bootsnap
19
- gem "bootsnap", ">= 1.4.3", require: false
@@ -1,3 +0,0 @@
1
- # <%= class_name %> Engine
2
-
3
- TODO: Write the purpose and description of this engine.
@@ -1,9 +0,0 @@
1
- require "bundler/setup"
2
- require "<%= name %>"
3
- require_relative "spec/rails_helper"
4
-
5
- begin
6
- require "rspec/core/rake_task"
7
- RSpec::Core::RakeTask.new(:spec)
8
- rescue LoadError
9
- end
@@ -1,9 +0,0 @@
1
- #!/usr/bin/env ruby
2
- # frozen_string_literal: true
3
-
4
- require "bundler/setup"
5
- require "pry"
6
- require "<%= name %>"
7
- require_relative "../spec/rails_helper"
8
-
9
- Pry.start
@@ -1,11 +0,0 @@
1
- #!/usr/bin/env ruby
2
- # frozen_string_literal: true
3
-
4
- require "bundler/setup"
5
-
6
- ENGINE_ROOT = File.expand_path("..", __dir__)
7
- ENGINE_PATH = File.expand_path("../lib/<%= name %>/engine", __dir__)
8
-
9
- require_relative "../spec/rails_helper"
10
-
11
- require "rails/engine/commands"
@@ -1,22 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require "rails"
4
-
5
- require "<%= name %>/version"
6
-
7
- module <%= class_name %>
8
- class << self
9
- # Configure table_name_prefix for all the models from the engine
10
- # if there could be a collision with other engines, or the main
11
- # app models.
12
- #
13
- # This is useful during the gradual migration to component-based
14
- # architecture.
15
-
16
- def table_name_prefix
17
- ""
18
- end
19
- end
20
- end
21
-
22
- require "<%= name %>/engine"
@@ -1,31 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require "rails/engine"
4
-
5
- module <%= class_name %>
6
- class << self
7
- def configure
8
- yield Engine.config
9
- end
10
- end
11
-
12
- class Engine < ::Rails::Engine
13
- isolate_namespace <%= class_name %>
14
-
15
- config.autoload_paths += Dir["#{config.root}/app/**/concerns"]
16
-
17
- initializer "<%= name %>" do |app|
18
- app.config.paths["db/migrate"].concat(config.paths["db/migrate"].expanded)
19
-
20
- # For migration_context (used for checking if migrations are pending)
21
- ActiveRecord::Migrator.migrations_path += config.paths["db/migrate"].expanded.flatten
22
-
23
- engine_factories_path = root.join("spec", "factories")
24
-
25
- # This hook is provided by `jets-factory` gem
26
- ActiveSupport.on_load(:factory_bot) do
27
- FactoryBot.definition_file_paths.unshift engine_factories_path
28
- end
29
- end
30
- end
31
- end
@@ -1,5 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module <%= class_name %>
4
- VERSION = "0.1.0"
5
- end
@@ -1,6 +0,0 @@
1
- test:
2
- adapter: postgresql
3
- url: <%%= ENV["DATABASE_URL"].sub("postgres://", "postgis://") %>
4
- pool: <%%= ENV["DB_POOL_SIZE"] || 5 %>
5
- timeout: 5000
6
- database: engine_<%= name %>_test
@@ -1,3 +0,0 @@
1
- test:
2
- service: Disk
3
- root: <%= Rails.root.join("../../tmp/storage") %>
@@ -1,4 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- ActiveRecord::Schema.define do
4
- end
@@ -1,57 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- # Engine root is used by rails_configuration to correctly
4
- # load fixtures and support files
5
-
6
- ENGINE_ROOT = Pathname.new(File.expand_path("..", __dir__))
7
-
8
- ENV["RAILS_ENV"] = "test"
9
- ENV["BOOTSNAP_CACHE_DIR"] = File.join(ENGINE_ROOT, "spec", "internal", "tmp", "cache")
10
-
11
- require "bootsnap/setup"
12
-
13
- require "combustion"
14
- require "jets/testing/ext/combustion_bundler_patch"
15
-
16
- begin
17
- # Customize your Combustion test application.
18
- # Combustion.initialize! :active_record, :active_job, :active_storage, :action_mailer, :action_controller
19
- Combustion.initialize! :active_record, bundler_groups: :<%= name %> do
20
- config.logger = Logger.new(nil)
21
- config.log_level = :fatal
22
-
23
- config.autoloader = :zeitwerk
24
-
25
- # Always use test adapter for active_job
26
- # config.active_job.queue_adapter = :test
27
- #
28
- # Always use test service to active_storage
29
- # config.active_storage.service = :test
30
- #
31
- # Enable verbose logging for active_record
32
- # config.active_record.verbose_query_logs = true
33
- end
34
- rescue => e
35
- # Fail fast if application couldn't be loaded
36
- $stdout.puts "Failed to load the app: #{e.message}\n#{e.backtrace.take(5).join("\n")}"
37
- exit(1)
38
- end
39
-
40
- # if you need url helpers (e.g. with active storage)
41
- # Rails.application.default_url_options[:host] = "localhost"
42
- # <%= class_name %>::Engine.routes.default_url_options[:host] = "localhost"
43
-
44
- require "jets/testing/rails_configuration"
45
-
46
- # action_policy helpers
47
- # require "action_policy/rspec"
48
- # require "action_policy/rspec/dsl"
49
-
50
- # Additional RSpec configuration
51
- #
52
- # RSpec.configure do |config|
53
- # config.after(:suite) do
54
- # # Cleanup attachments generated during tests
55
- # FileUtils.rm_rf(ActiveStorage::Blob.service.root)
56
- # end
57
- # end
@@ -1,6 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require "bundler/setup"
4
- require "pry-byebug"
5
-
6
- require "jets/testing/rspec_configuration"