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.
Constant Summary collapse
- DATABASE_SQLITE =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
"sqlite"
- DATABASE_POSTGRES =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
"postgres"
- DATABASE_MYSQL =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
"mysql"
- SUPPORTED_DATABASES =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
[DATABASE_SQLITE, DATABASE_POSTGRES, DATABASE_MYSQL].freeze
Instance Method Summary collapse
- #call(app:, head: HEAD_DEFAULT, skip_install: SKIP_INSTALL_DEFAULT, skip_assets: SKIP_ASSETS_DEFAULT, skip_db: SKIP_DB_DEFAULT, database: nil) ⇒ 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.
100 101 102 103 104 105 106 107 108 109 110 111 |
# File 'lib/hanami/cli/commands/gem/new.rb', line 100 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, skip_db: SKIP_DB_DEFAULT, database: nil) ⇒ 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.
117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 |
# File 'lib/hanami/cli/commands/gem/new.rb', line 117 def call( app:, head: HEAD_DEFAULT, skip_install: SKIP_INSTALL_DEFAULT, skip_assets: SKIP_ASSETS_DEFAULT, skip_db: SKIP_DB_DEFAULT, database: nil ) # rubocop:enable Metrics/ParameterLists app = inflector.underscore(app) raise PathAlreadyExistsError.new(app) if fs.exist?(app) normalized_database ||= normalize_database(database) fs.mkdir(app) fs.chdir(app) do context = Generators::Context.new( inflector, app, head: head, skip_assets: skip_assets, skip_db: skip_db, database: normalized_database ) 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 bundle 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 |