Class: Hanami::CLI::Commands::New Private

Inherits:
Command
  • Object
show all
Defined in:
lib/hanami/cli/commands/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.

Since:

  • 1.1.0

Defined Under Namespace

Classes: App, DatabaseConfig, TemplateEngine, TestFramework

Constant Summary collapse

DEFAULT_APPLICATION_NAME =

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.

Since:

  • 1.1.0

'web'.freeze
DEFAULT_APPLICATION_BASE_URL =

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.

Since:

  • 1.1.0

'/'.freeze

Instance Method Summary collapse

Methods inherited from Command

inherited, #initialize

Constructor Details

This class inherits a constructor from Hanami::CLI::Commands::Command

Instance Method Details

#call(project:, **options) ⇒ 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 rubocop:disable Metrics/MethodLength

Since:

  • 1.1.0



284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
# File 'lib/hanami/cli/commands/new.rb', line 284

def call(project:, **options)
  project         = Utils::String.underscore(project)
  database_config = DatabaseConfig.new(options[:database], project)
  test_framework  = TestFramework.new(hanamirc, options[:test])
  template_engine = TemplateEngine.new(hanamirc, options[:template])
  options[:project] = project

  context = Context.new(
    project: project,
    database: database_config.type,
    database_config_hash: database_config.to_hash,
    database_config: database_config,
    test_framework: test_framework,
    template_engine: template_engine,
    test: options.fetch(:test),
    application_name: options.fetch(:application_name),
    application_base_url: options.fetch(:application_base_url),
    hanami_head: options.fetch(:hanami_head),
    hanami_model_version: '~> 1.1',
    code_reloading: code_reloading?,
    hanami_version: hanami_version,
    project_module: Utils::String.classify(project),
    options: options
  )

  assert_project_name!(context)

  directory = project_directory(project)
  files.mkdir(directory)

  Dir.chdir(directory) do
    generate_application_templates(context)
    generate_empty_directories(context)
    generate_test_templates(context)
    generate_sql_templates(context)
    generate_git_templates(context)

    init_git

    generate_app(context)
  end
end