Class: Hanami::CLI::Commands::Gem::New Private
- Inherits:
-
Hanami::CLI::Command
- Object
- Dry::CLI::Command
- Hanami::CLI::Command
- Hanami::CLI::Commands::Gem::New
- Defined in:
- lib/hanami/cli/commands/gem/new.rb
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Instance Method Summary collapse
- #call(app:, head: HEAD_DEFAULT, skip_install: SKIP_INSTALL_DEFAULT, skip_assets: SKIP_ASSETS_DEFAULT) ⇒ Object private
-
#initialize(fs:, inflector:, bundler: CLI::Bundler.new(fs: fs), generator: Generators::Gem::App.new(fs: fs, inflector: inflector), system_call: SystemCall.new, **opts) ⇒ New
constructor
private
A new instance of New.
Methods inherited from Hanami::CLI::Command
Constructor Details
#initialize(fs:, inflector:, bundler: CLI::Bundler.new(fs: fs), generator: Generators::Gem::App.new(fs: fs, inflector: inflector), system_call: SystemCall.new, **opts) ⇒ New
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a new instance of New.
65 66 67 68 69 70 71 72 73 74 75 76 |
# File 'lib/hanami/cli/commands/gem/new.rb', line 65 def initialize( fs:, inflector:, bundler: CLI::Bundler.new(fs: fs), generator: Generators::Gem::App.new(fs: fs, inflector: inflector), system_call: SystemCall.new, **opts ) super(fs: fs, inflector: inflector, **opts) @bundler = bundler @generator = generator @system_call = system_call end |
Instance Method Details
#call(app:, head: HEAD_DEFAULT, skip_install: SKIP_INSTALL_DEFAULT, skip_assets: SKIP_ASSETS_DEFAULT) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 |
# File 'lib/hanami/cli/commands/gem/new.rb', line 84 def call(app:, head: HEAD_DEFAULT, skip_install: SKIP_INSTALL_DEFAULT, skip_assets: SKIP_ASSETS_DEFAULT, **) app = inflector.underscore(app) raise PathAlreadyExistsError.new(app) if fs.exist?(app) fs.mkdir(app) fs.chdir(app) do context = Generators::Context.new(inflector, app, head: head, skip_assets: skip_assets) generator.call(app, context: context) do if skip_install out.puts "Skipping installation, please enter `#{app}' directory and run `bundle exec hanami install'" else out.puts "Running Bundler install..." bundler.install! unless skip_assets out.puts "Running NPM install..." system_call.call("npm", ["install"]).tap do |result| unless result.successful? puts "NPM ERROR:" puts(result.err.lines.map { |line| line.prepend(" ") }) end end end out.puts "Running Hanami install..." run_install_command!(head: head) end end end end |