lib/potassium/cli/commands/create.rb in potassium-6.0.0 vs lib/potassium/cli/commands/create.rb in potassium-6.1.0
- old
+ new
@@ -1,40 +1,32 @@
require 'potassium/cli_options'
module Potassium::CLI
extend Potassium::CliOptions
- desc "Create a new Potassium Rails project."
+ desc 'Create a new Potassium Rails project.'
arg 'app_path'
command :create do |c|
- c.default_desc "Create a new project."
- c.switch "version-check",
- default_value: true,
- desc: "Performs a version check before running.",
- negatable: true
-
+ 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/newest_version_ensurer'
+ require 'potassium/node_version_ensurer'
+ require 'potassium/generators/application'
+ require 'potassium/template_finder'
- begin_creation = -> do
- 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
- end
-
- if options["version-check"]
- ensurer = Potassium::NewestVersionEnsurer.new
- ensurer.ensure(&begin_creation)
- else
- begin_creation.call
+ rescue VersionError => e
+ print "\nError: #{e.message}" # rubocop:disable Rails/Output
end
end
end
end