Sha256: beb7a54a6bef5ebb4b8290b7d720b5cdfba1c48ebbff91fcd3e8ef1e580f3555

Contents?: true

Size: 1.77 KB

Versions: 10

Compression:

Stored size: 1.77 KB

Contents

class Lono::Extension
  class New < Lono::Sequence
    include Lono::Blueprint::Helper # for user_info
    include Lono::Extension::Helper

    argument :extension_name

    def self.source_root
      templates = File.expand_path("../../templates", File.dirname(__FILE__))
      "#{templates}/extension"
    end

    def self.cli_options
      [
        [:force, type: :boolean, desc: "Bypass overwrite are you sure prompt for existing files."],
      ]
    end

    cli_options.each do |args|
      class_option(*args)
    end

    # for specs
    def set_cwd
      @cwd = ENV['LONO_TEST'] ? File.dirname(Lono.root) : "#{Dir.pwd}/app/extensions"
    end

    def create_project
      puts "=> Creating new extension called #{extension_name}."
      directory ".", "#{@cwd}/#{extension_name}", options
    end

    def create_license
      return unless ENV['LONO_LICENSE_FILE']
      copy_file ENV['LONO_LICENSE_FILE'], "#{@cwd}/#{extension_name}/LICENSE.txt"
    end

    # After this commands are executed with the newly created project
    def set_destination_root
      destination_root = "#{@cwd}/#{extension_name}"
      self.destination_root = destination_root
      @old_dir = Dir.pwd # for reset_current_dir
      FileUtils.cd(self.destination_root)
    end

    def welcome_message
      puts <<~EOL
        #{"="*64}
        Congrats 🎉 You have successfully created a lono extension.

        Cd into your extension and check things out.

            cd #{extension_name}

        More info: https://lono.cloud/docs/extensions

      EOL
    end

    def tree
      tree_installed = system("type tree > /dev/null")
      return unless tree_installed

      structure = `tree .`
      puts <<~EOL
        Here is the structure of your extension:

        #{structure}
      EOL
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
lono-7.4.2 lib/lono/extension/new.rb
lono-7.4.1 lib/lono/extension/new.rb
lono-7.4.0 lib/lono/extension/new.rb
lono-7.3.2 lib/lono/extension/new.rb
lono-7.3.1 lib/lono/extension/new.rb
lono-7.3.0 lib/lono/extension/new.rb
lono-7.2.3 lib/lono/extension/new.rb
lono-7.2.2 lib/lono/extension/new.rb
lono-7.2.1 lib/lono/extension/new.rb
lono-7.2.0 lib/lono/extension/new.rb