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
- FORBIDDEN_APP_NAMES =
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.
%w[app slice].freeze
- HEAD_DEFAULT =
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.
false- GEM_SOURCE_DEFAULT =
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.
"rubygems.org"- SKIP_INSTALL_DEFAULT =
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.
false- SKIP_ASSETS_DEFAULT =
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.
false- SKIP_DB_DEFAULT =
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.
false- SKIP_VIEW_DEFAULT =
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.
false- SKIP_MAILER_DEFAULT =
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.
false- 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
- TEMPLATE_ENGINE_DEFAULT =
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.
"erb"- TEST_FRAMEWORK_DEFAULT =
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.
"rspec"- TEST_FRAMEWORK_RSPEC =
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.
"rspec"- TEST_FRAMEWORK_MINITEST =
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.
"minitest"
Instance Method Summary collapse
-
#call(app:, head: HEAD_DEFAULT, gem_source: GEM_SOURCE_DEFAULT, skip_install: SKIP_INSTALL_DEFAULT, skip_assets: SKIP_ASSETS_DEFAULT, skip_db: SKIP_DB_DEFAULT, skip_view: SKIP_VIEW_DEFAULT, skip_mailer: SKIP_MAILER_DEFAULT, database: nil, name: nil, template_engine: TEMPLATE_ENGINE_DEFAULT, test: TEST_FRAMEWORK_DEFAULT) ⇒ Object
private
rubocop:disable Metrics/AbcSize, Metrics/PerceivedComplexity.
-
#initialize(fs:, bundler: CLI::Bundler.new(fs: fs), generator: Generators::Gem::App.new(fs: fs, inflector: inflector), system_call: SystemCall.new, **opts) ⇒ New
constructor
private
rubocop:enable Layout/LineLength.
Methods inherited from Hanami::CLI::Command
Constructor Details
#initialize(fs:, 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.
rubocop:enable Layout/LineLength
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:, bundler: CLI::Bundler.new(fs: fs), generator: Generators::Gem::App.new(fs: fs, inflector: inflector), system_call: SystemCall.new, **opts ) super(fs: fs, **opts) @bundler = bundler @generator = generator @system_call = system_call end |
Instance Method Details
#call(app:, head: HEAD_DEFAULT, gem_source: GEM_SOURCE_DEFAULT, skip_install: SKIP_INSTALL_DEFAULT, skip_assets: SKIP_ASSETS_DEFAULT, skip_db: SKIP_DB_DEFAULT, skip_view: SKIP_VIEW_DEFAULT, skip_mailer: SKIP_MAILER_DEFAULT, database: nil, name: nil, template_engine: TEMPLATE_ENGINE_DEFAULT, test: TEST_FRAMEWORK_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.
rubocop:disable Metrics/AbcSize, Metrics/PerceivedComplexity
115 116 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 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 |
# File 'lib/hanami/cli/commands/gem/new.rb', line 115 def call( app:, head: HEAD_DEFAULT, gem_source: GEM_SOURCE_DEFAULT, skip_install: SKIP_INSTALL_DEFAULT, skip_assets: SKIP_ASSETS_DEFAULT, skip_db: SKIP_DB_DEFAULT, skip_view: SKIP_VIEW_DEFAULT, skip_mailer: SKIP_MAILER_DEFAULT, database: nil, name: nil, template_engine: TEMPLATE_ENGINE_DEFAULT, test: TEST_FRAMEWORK_DEFAULT ) directory = inflector.underscore(app) app = inflector.underscore(name || app) raise PathAlreadyExistsError.new(directory) if fs.exist?(directory) raise ForbiddenAppNameError.new(app) if FORBIDDEN_APP_NAMES.include?(app) normalized_database ||= normalize_database(database) fs.mkdir(directory) fs.chdir(directory) do context = Generators::Context.new( inflector, app, head:, gem_source:, skip_assets:, skip_db:, skip_view:, skip_mailer:, database: normalized_database, template_engine:, test_framework: test ) 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) out.puts "Running bundle binstubs hanami-cli rake..." install_binstubs! out.puts "Initializing git repository..." init_git_repository end end end end |