lib/kite/module.rb in kite-1.1.1 vs lib/kite/module.rb in kite-1.1.3
- old
+ new
@@ -3,35 +3,53 @@
include Kite::Helpers
method_option :env, type: :string, desc: "Environment", required: true, default: ENV['KITE_ENV']
method_option :version, type: :string, desc: "Version", aliases: '-v', required: false
method_option :method, type: :string, desc: "Module import method", enum: %w{copy submodule}, default: "submodule"
- desc 'init https://github.com/foo/bar-module', 'Initialize a kite module and render its vars.module.yml'
+ desc 'init https://github.com/foo/bar-module', '[DEPRECATED] Use kite module fetch and kite module vars instead'
def init(path)
+ say "Kite module init is deprecated. Use kite module fetch and kite module vars instead", :yellow
+ end
+
+
+ method_option :env, type: :string, desc: "Environment", required: true, default: ENV['KITE_ENV']
+ method_option :version, type: :string, desc: "Version", required: false
+ method_option :method, type: :string, desc: "Module import method", enum: %w{copy submodule}, default: "submodule"
+ desc 'fetch https://github.com/foo/bar-module', 'Fetch a kite module'
+ def fetch(path)
@env = options[:env]
@module_name = path.gsub(/(.*:|.git)/, '').split('/').last
@module_path = "modules/#{ @module_name }"
if File.exist?(@module_path)
overwrite = ask "#{ @module_path } already exists! Overwrite? (y/N)"
if overwrite.downcase == 'y'
say "Remove existing files"
- remove_dir(@module_path)
+ run! "git rm -f #{ @module_path }"
+ remove_dir(".git/modules/#{ @module_path }")
else
say "Skipping module init"
return
end
end
case options[:method]
- when"submodule"
- clone_module(path, @module_path, options[:version])
- when "copy"
- FileUtils.mkdir_p("modules")
- FileUtils.cp_r(path, @module_path)
- else
- raise "Unsupported method #{ method }"
+ when"submodule"
+ clone_module(path, @module_path, options[:version])
+ when "copy"
+ FileUtils.mkdir_p("modules")
+ FileUtils.cp_r(path, @module_path)
+ else
+ raise "Unsupported method #{ method }"
end
+ end
+
+ method_option :env, type: :string, desc: "Environment", required: true, default: ENV['KITE_ENV']
+ desc 'vars modules/bar-module', 'Render initial vars.*module*.yml'
+ def vars(path)
+ @env = options[:env]
+ @module_name = path.gsub(/(.*:|.git)/, '').split('/').last
+ @module_path = "modules/#{ @module_name }"
@cloud = parse_cloud_config(@env)
vars_output = render_vars(@module_name, @module_path)
say "Rendered successfully #{ vars_output }, please edit this file with correct values", :green
end