lib/lono/blueprint/new.rb in lono-6.1.4 vs lib/lono/blueprint/new.rb in lono-6.1.5

- old
+ new

@@ -10,14 +10,15 @@ end def self.cli_options [ [:bundle, type: :boolean, default: true, desc: "Runs bundle install on the project"], + [:demo, type: :boolean, default: true, desc: "Include demo template"], [:force, type: :boolean, desc: "Bypass overwrite are you sure prompt for existing files."], [:from_new, type: :boolean, desc: "Called from `lono new` command."], - [:project_name, default: '', desc: "Only used with from_new internally"], [:import, type: :boolean, desc: "Flag for lono code import"], + [:project_name, default: '', desc: "Only used with from_new internally"], [:type, default: "dsl", desc: "Blueprint type: dsl or erb"], ] end cli_options.each do |args| @@ -41,26 +42,38 @@ # So @cwd = my-infra/blueprints @cwd = "#{options[:project_name]}/blueprints" end end + def set_variables + @demo = @options[:demo] + @demo = false if ENV["LONO_ORG"] # overrides --demo CLI option + end + def create_project puts "=> Creating new blueprint called #{blueprint_name}." directory ".", "#{@cwd}/#{blueprint_name}" end def create_app_folder return if @options[:import] - directory "../blueprint_types/#{@options[:type]}", "#{@cwd}/#{blueprint_name}" + + if @demo + directory "../blueprint_types/#{@options[:type]}", "#{@cwd}/#{blueprint_name}" + else + empty_directory "#{@cwd}/#{blueprint_name}/app/templates" + create_file "#{@cwd}/#{blueprint_name}/app/templates/#{blueprint_name}.rb" + end end def create_empty_directories # Note: Not using Lono::Core::Config::PATHS.keys to create all of them because # think it is more common to not have all the folders. Instead create them explicitly. empty_directory "#{@cwd}/#{blueprint_name}/app/templates" end def create_starter_configs + return unless @demo return if @options[:import] if options[:from_new] # lono new command directory "../blueprint_configs", options[:project_name] else # lono blueprint new command