Class: Lono::Extension::New
Class Method Summary
collapse
Instance Method Summary
collapse
Methods included from Helper
#extension_class_name, #extension_underscore_name
#user_info
Class Method Details
.cli_options ⇒ Object
13
14
15
16
17
|
# File 'lib/lono/extension/new.rb', line 13
def self.cli_options
[
[:force, type: :boolean, desc: "Bypass overwrite are you sure prompt for existing files."],
]
end
|
.source_root ⇒ Object
8
9
10
11
|
# File 'lib/lono/extension/new.rb', line 8
def self.source_root
templates = File.expand_path("../../templates", File.dirname(__FILE__))
"#{templates}/extension"
end
|
Instance Method Details
#create_license ⇒ Object
33
34
35
36
|
# File 'lib/lono/extension/new.rb', line 33
def create_license
return unless ENV['LONO_LICENSE_FILE']
copy_file ENV['LONO_LICENSE_FILE'], "#{@cwd}/#{extension_name}/LICENSE.txt"
end
|
#create_project ⇒ Object
28
29
30
31
|
# File 'lib/lono/extension/new.rb', line 28
def create_project
puts "=> Creating new extension called #{extension_name}."
directory ".", "#{@cwd}/#{extension_name}", options
end
|
#set_cwd ⇒ Object
24
25
26
|
# File 'lib/lono/extension/new.rb', line 24
def set_cwd
@cwd = ENV['LONO_TEST'] ? File.dirname(Lono.root) : "#{Dir.pwd}/app/extensions"
end
|
#set_destination_root ⇒ Object
After this commands are executed with the newly created project
39
40
41
42
43
44
|
# File 'lib/lono/extension/new.rb', line 39
def set_destination_root
destination_root = "#{@cwd}/#{extension_name}"
self.destination_root = destination_root
@old_dir = Dir.pwd FileUtils.cd(self.destination_root)
end
|
#tree ⇒ Object
60
61
62
63
64
65
66
67
68
69
70
|
# File 'lib/lono/extension/new.rb', line 60
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
|
#welcome_message ⇒ Object
46
47
48
49
50
51
52
53
54
55
56
57
58
|
# File 'lib/lono/extension/new.rb', line 46
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
|