Sha256: 7396bdbcfba168a4fe38dd0de346006fe5a97e4c348e3c8130d1bf6a4852ed83

Contents?: true

Size: 1.13 KB

Versions: 5

Compression:

Stored size: 1.13 KB

Contents

require 'potassium/cli_options'

module Potassium::CLI
  extend Potassium::CliOptions

  desc 'Create a new Potassium Rails project.'
  arg 'app_path'
  command :create do |c|
    c.default_desc 'Create a new project.'
    create_options.each { |opts| c.send(opts.delete(:type), opts.delete(:name), opts) }

    c.action do |_global_options, options, _args|
      require 'potassium/newest_version_ensurer'
      require 'potassium/node_version_ensurer'
      require 'potassium/generators/application'
      require 'potassium/template_finder'

      begin
        Potassium::NewestVersionEnsurer.new.ensure! if options['version-check']
        Potassium::NodeVersionEnsurer.new.ensure! if options['node-version-check']
        template_finder = Potassium::TemplateFinder.new
        template = template_finder.default_template
        template.cli_options = options
        template.source_paths << Rails::Generators::AppGenerator.source_root
        ARGV.push('--skip-webpack-install', '--skip-bundle')
        template.start
      rescue VersionError => e
        print "\nError: #{e.message}" # rubocop:disable Rails/Output
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
potassium-6.5.0 lib/potassium/cli/commands/create.rb
potassium-6.4.0 lib/potassium/cli/commands/create.rb
potassium-6.3.0 lib/potassium/cli/commands/create.rb
potassium-6.2.0 lib/potassium/cli/commands/create.rb
potassium-6.1.0 lib/potassium/cli/commands/create.rb