lono 6.1.11 → 7.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.cody/acceptance.sh +19 -3
- data/.gitignore +2 -2
- data/CHANGELOG.md +16 -1
- data/README.md +18 -20
- data/Rakefile +1 -0
- data/lib/lono.rb +7 -5
- data/lib/lono/abstract_base.rb +25 -0
- data/lib/lono/api/client.rb +30 -0
- data/lib/lono/api/proxy.rb +58 -0
- data/lib/lono/api/repos.rb +8 -0
- data/lib/lono/api/verify.rb +13 -0
- data/lib/lono/app_file/base.rb +4 -11
- data/lib/lono/app_file/build.rb +1 -1
- data/lib/lono/app_file/upload.rb +1 -4
- data/lib/lono/autoloader.rb +3 -1
- data/lib/lono/aws_services.rb +9 -9
- data/lib/lono/aws_services/helper.rb +14 -0
- data/lib/lono/aws_services/{util.rb → stack.rb} +1 -9
- data/lib/lono/aws_services/stack_set.rb +41 -0
- data/lib/lono/blueprint.rb +2 -2
- data/lib/lono/blueprint/configset/loader.rb +7 -0
- data/lib/lono/blueprint/helper.rb +8 -2
- data/lib/lono/blueprint/meta.rb +4 -12
- data/lib/lono/blueprint/new.rb +3 -3
- data/lib/lono/blueprint/root.rb +6 -26
- data/lib/lono/bundle.rb +54 -0
- data/lib/lono/cfn.rb +31 -75
- data/lib/lono/cfn/base.rb +39 -136
- data/lib/lono/cfn/cancel.rb +14 -9
- data/lib/lono/cfn/create.rb +15 -19
- data/lib/lono/cfn/delete.rb +9 -9
- data/lib/lono/cfn/deploy.rb +4 -4
- data/lib/lono/cfn/download.rb +27 -9
- data/lib/lono/cfn/opts.rb +80 -0
- data/lib/lono/cfn/preview/changeset.rb +23 -23
- data/lib/lono/cfn/preview/codediff.rb +5 -6
- data/lib/lono/cfn/preview/param.rb +10 -10
- data/lib/lono/cfn/rollback.rb +5 -5
- data/lib/lono/cfn/status.rb +0 -10
- data/lib/lono/cfn/update.rb +22 -27
- data/lib/lono/clean.rb +3 -3
- data/lib/lono/cli.rb +69 -34
- data/lib/lono/code.rb +22 -0
- data/lib/lono/command.rb +7 -0
- data/lib/lono/config_location.rb +6 -13
- data/lib/lono/configset.rb +9 -0
- data/lib/lono/configset/combiner.rb +128 -0
- data/lib/lono/configset/evaluate_file.rb +8 -0
- data/lib/lono/configset/list.rb +67 -0
- data/lib/lono/configset/loader.rb +98 -0
- data/lib/lono/configset/loader/dsl.rb +9 -0
- data/lib/lono/configset/materializer/final.rb +10 -0
- data/lib/lono/configset/materializer/gems_builder.rb +81 -0
- data/lib/lono/configset/materializer/jade.rb +15 -0
- data/lib/lono/configset/materializer/source.rb +54 -0
- data/lib/lono/configset/meta.rb +19 -0
- data/lib/lono/configset/meta/dsl.rb +12 -0
- data/lib/lono/configset/new.rb +84 -0
- data/lib/lono/configset/preparer.rb +44 -0
- data/lib/lono/configset/register/base.rb +121 -0
- data/lib/lono/configset/register/blueprint.rb +16 -0
- data/lib/lono/configset/register/dsl.rb +15 -0
- data/lib/lono/configset/register/project.rb +12 -0
- data/lib/lono/configset/registry.rb +34 -0
- data/lib/lono/configset/resolver.rb +42 -0
- data/lib/lono/conventions.rb +18 -7
- data/lib/lono/core.rb +16 -20
- data/lib/lono/default/settings.yml +2 -3
- data/lib/lono/ext/bundler.rb +7 -0
- data/lib/lono/file_uploader.rb +8 -5
- data/lib/lono/finder/base.rb +140 -0
- data/lib/lono/finder/blueprint.rb +11 -0
- data/lib/lono/finder/blueprint/configset.rb +17 -0
- data/lib/lono/finder/configset.rb +11 -0
- data/lib/lono/generate.rb +93 -0
- data/lib/lono/help/blueprint/new.md +0 -1
- data/lib/lono/help/cfn/delete.md +1 -1
- data/lib/lono/help/cfn/deploy.md +5 -76
- data/lib/lono/help/cfn/status.md +0 -4
- data/lib/lono/help/cfn/update.md +1 -1
- data/lib/lono/help/code/convert.md +51 -0
- data/lib/lono/help/code/import.md +30 -0
- data/lib/lono/help/configsets.md +24 -0
- data/lib/lono/help/generate.md +4 -4
- data/lib/lono/help/new.md +1 -2
- data/lib/lono/help/sets/delete.md +8 -0
- data/lib/lono/help/sets/deploy.md +76 -0
- data/lib/lono/help/sets/instances/delete.md +21 -0
- data/lib/lono/help/sets/instances/list.md +14 -0
- data/lib/lono/help/sets/instances/status.md +15 -0
- data/lib/lono/help/sets/instances/sync.md +88 -0
- data/lib/lono/help/sets/status.md +23 -0
- data/lib/lono/help/upgrade.md +1 -0
- data/lib/lono/importer.rb +22 -0
- data/lib/lono/importer/base.rb +59 -0
- data/lib/lono/importer/converter.rb +19 -0
- data/lib/lono/importer/download.rb +46 -0
- data/lib/lono/importer/dsl.rb +36 -0
- data/lib/lono/importer/erb.rb +31 -0
- data/lib/lono/importer/params.rb +56 -0
- data/lib/lono/importer/service/coder.rb +81 -0
- data/lib/lono/inspector/base.rb +12 -22
- data/lib/lono/inspector/graph.rb +1 -1
- data/lib/lono/inspector/summary.rb +41 -17
- data/lib/lono/jade.rb +103 -0
- data/lib/lono/jade/circular.rb +26 -0
- data/lib/lono/jadespec.rb +41 -0
- data/lib/lono/new.rb +2 -2
- data/lib/lono/opts.rb +43 -0
- data/lib/lono/output/template.rb +48 -0
- data/lib/lono/param.rb +3 -5
- data/lib/lono/param/generator.rb +13 -33
- data/lib/lono/pro.rb +15 -0
- data/lib/lono/pro/base.rb +16 -0
- data/lib/lono/pro/repo.rb +27 -0
- data/lib/lono/project_checker.rb +4 -29
- data/lib/lono/registration.rb +15 -0
- data/lib/lono/registration/base.rb +37 -0
- data/lib/lono/registration/check.rb +15 -0
- data/lib/lono/registration/temp.rb +60 -0
- data/lib/lono/registration/user.rb +54 -0
- data/lib/lono/script/base.rb +1 -10
- data/lib/lono/script/upload.rb +2 -12
- data/lib/lono/seed.rb +2 -11
- data/lib/lono/seed/base.rb +55 -110
- data/lib/lono/sets.rb +38 -0
- data/lib/lono/sets/base.rb +45 -0
- data/lib/lono/sets/create.rb +30 -0
- data/lib/lono/sets/delete.rb +47 -0
- data/lib/lono/sets/deploy.rb +11 -0
- data/lib/lono/sets/instances.rb +33 -0
- data/lib/lono/sets/instances/base.rb +30 -0
- data/lib/lono/sets/instances/delete.rb +69 -0
- data/lib/lono/sets/instances/list.rb +13 -0
- data/lib/lono/sets/instances/opts.rb +29 -0
- data/lib/lono/sets/instances/status.rb +12 -0
- data/lib/lono/sets/instances/sync.rb +182 -0
- data/lib/lono/sets/list.rb +35 -0
- data/lib/lono/sets/opts.rb +18 -0
- data/lib/lono/sets/preview/codediff.rb +35 -0
- data/lib/lono/sets/preview/param.rb +32 -0
- data/lib/lono/sets/status.rb +116 -0
- data/lib/lono/sets/status/instance.rb +20 -0
- data/lib/lono/sets/status/instance/base.rb +120 -0
- data/lib/lono/sets/status/instance/completed.rb +35 -0
- data/lib/lono/sets/status/instance/deleted.rb +32 -0
- data/lib/lono/sets/status/instance/show.rb +7 -0
- data/lib/lono/sets/status/instances.rb +111 -0
- data/lib/lono/sets/summarize.rb +20 -0
- data/lib/lono/sets/time_spent.rb +11 -0
- data/lib/lono/sets/update.rb +81 -0
- data/lib/lono/template.rb +5 -7
- data/lib/lono/template/configset_injector.rb +50 -0
- data/lib/lono/template/context.rb +4 -4
- data/lib/lono/template/context/loader.rb +4 -16
- data/lib/lono/template/evaluate.rb +2 -1
- data/lib/lono/template/generator.rb +17 -15
- data/lib/lono/template/helper.rb +7 -7
- data/lib/lono/template/post_processor.rb +2 -12
- data/lib/lono/template/strategy/base.rb +4 -0
- data/lib/lono/template/{dsl.rb → strategy/dsl.rb} +4 -6
- data/lib/lono/template/{dsl → strategy/dsl}/builder.rb +11 -15
- data/lib/lono/template/{dsl → strategy/dsl}/builder/fn.rb +1 -1
- data/lib/lono/template/strategy/dsl/builder/helpers.rb +11 -0
- data/lib/lono/template/strategy/dsl/builder/helpers/core_helper.rb +14 -0
- data/lib/lono/template/strategy/dsl/builder/helpers/file_helper.rb +48 -0
- data/lib/lono/template/strategy/dsl/builder/helpers/lookup_helper.rb +27 -0
- data/lib/lono/template/strategy/dsl/builder/helpers/s3_helper.rb +13 -0
- data/lib/lono/template/strategy/dsl/builder/helpers/tags_helper.rb +39 -0
- data/lib/lono/template/{dsl/builder → strategy/dsl/builder/section}/base.rb +6 -17
- data/lib/lono/template/{dsl/builder → strategy/dsl/builder/section}/condition.rb +1 -1
- data/lib/lono/template/strategy/dsl/builder/section/extensions.rb +9 -0
- data/lib/lono/template/{dsl/builder → strategy/dsl/builder/section}/mapping.rb +1 -1
- data/lib/lono/template/{dsl/builder/section_methods.rb → strategy/dsl/builder/section/methods.rb} +9 -2
- data/lib/lono/template/{dsl/builder → strategy/dsl/builder/section}/output.rb +1 -1
- data/lib/lono/template/strategy/dsl/builder/section/parameter.rb +69 -0
- data/lib/lono/template/{dsl/builder → strategy/dsl/builder/section}/resource.rb +1 -1
- data/lib/lono/template/{dsl/builder → strategy/dsl/builder/section}/resource/property_mover.rb +1 -1
- data/lib/lono/template/{dsl/builder → strategy/dsl/builder/section}/section.rb +1 -1
- data/lib/lono/template/{dsl → strategy/dsl}/builder/squeezer.rb +1 -1
- data/lib/lono/template/strategy/dsl/builder/stringify.rb +15 -0
- data/lib/lono/template/{dsl → strategy/dsl}/builder/syntax.rb +3 -2
- data/lib/lono/template/strategy/dsl/finalizer.rb +12 -0
- data/lib/lono/template/strategy/dsl/finalizer/parameter_groups.rb +56 -0
- data/lib/lono/template/{erb.rb → strategy/erb.rb} +5 -5
- data/lib/lono/template/strategy/source.rb +8 -0
- data/lib/lono/template/template.rb +1 -1
- data/lib/lono/template/upload.rb +4 -9
- data/lib/lono/template/util.rb +0 -40
- data/lib/lono/upgrade.rb +12 -10
- data/lib/lono/user_data.rb +4 -4
- data/lib/lono/utils/pretty_time.rb +14 -0
- data/lib/lono/utils/sure.rb +23 -0
- data/lib/lono/version.rb +1 -1
- data/lib/lono/yamler/loader.rb +52 -0
- data/lib/lono/yamler/validator.rb +51 -0
- data/lib/templates/blueprint/%blueprint_name%.gemspec.tt +4 -0
- data/lib/templates/blueprint/README.md.tt +1 -1
- data/lib/templates/blueprint/seed/configs.rb +2 -2
- data/lib/templates/blueprint_types/dsl/app/templates/%blueprint_name%.rb +17 -18
- data/lib/templates/blueprint_types/erb/app/templates/%blueprint_name%.yml +63 -4
- data/lib/templates/configset/%configset_name%.gemspec.tt +41 -0
- data/lib/templates/configset/.gitignore +11 -0
- data/lib/templates/configset/CHANGELOG.md +7 -0
- data/lib/templates/configset/Gemfile +4 -0
- data/lib/templates/configset/README.md.tt +3 -0
- data/lib/templates/configset/Rakefile.tt +9 -0
- data/lib/templates/configset/lib/configset.yml +20 -0
- data/lib/templates/skeleton/.gitignore +1 -0
- data/lib/templates/skeleton/Gemfile +0 -1
- data/lib/templates/skeleton/README.md +4 -4
- data/lib/templates/skeleton/configs/settings.yml +1 -1
- data/lono.gemspec +1 -4
- metadata +146 -79
- data/Guardfile +0 -19
- data/lib/lono/app_file.rb +0 -5
- data/lib/lono/blueprint/find.rb +0 -90
- data/lib/lono/blueprint/info.rb +0 -10
- data/lib/lono/blueprint/list.rb +0 -14
- data/lib/lono/cfn/current.rb +0 -95
- data/lib/lono/cfn/preview.rb +0 -4
- data/lib/lono/cfn/suffix.rb +0 -67
- data/lib/lono/cfn/util.rb +0 -27
- data/lib/lono/help/cfn/current.md +0 -18
- data/lib/lono/help/upgrade4.md +0 -25
- data/lib/lono/inspector.rb +0 -4
- data/lib/lono/output_template.rb +0 -35
- data/lib/lono/template/base.rb +0 -13
- data/lib/lono/template/dsl/builder/helpers.rb +0 -8
- data/lib/lono/template/dsl/builder/helpers/core_helper.rb +0 -107
- data/lib/lono/template/dsl/builder/helpers/param_helper.rb +0 -61
- data/lib/lono/template/dsl/builder/parameter.rb +0 -39
- data/lib/lono/upgrade/upgrade4.rb +0 -175
- data/lib/lono/upgrade/upgrade42.rb +0 -36
- data/lib/lono/upgrade/upgrade5.rb +0 -55
- data/lib/templates/blueprint/.meta/config.yml.tt +0 -4
- data/lib/templates/skeleton/Guardfile +0 -12
- data/lib/templates/upgrade5/blueprints/main/.lono/config.yml +0 -3
- data/lib/templates/upgrade5/blueprints/main/.meta/config.yml +0 -3
@@ -0,0 +1,67 @@
|
|
1
|
+
require "text-table"
|
2
|
+
|
3
|
+
class Lono::Configset
|
4
|
+
class List
|
5
|
+
def initialize(options={})
|
6
|
+
@options = options
|
7
|
+
@stack, @blueprint, @template, @param = Lono::Conventions.new(options).values
|
8
|
+
end
|
9
|
+
|
10
|
+
def run
|
11
|
+
if @blueprint
|
12
|
+
blueprint_configsets
|
13
|
+
else
|
14
|
+
project_configsets
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
def project_configsets
|
19
|
+
Lono::Finder::Configset.list(filter_materialized: true, message: "Project configsets:")
|
20
|
+
end
|
21
|
+
|
22
|
+
def blueprint_configsets
|
23
|
+
Lono::Configset::Preparer.new(@options).run # register and materialize gems
|
24
|
+
|
25
|
+
@final ||= []
|
26
|
+
|
27
|
+
project = Lono::Configset::Register::Project.new(@options)
|
28
|
+
project.register
|
29
|
+
finder = Lono::Finder::Configset.new
|
30
|
+
finder.list("Configsets available to project and can used with configs:") if @options[:verbose]
|
31
|
+
puts "Configsets project is using for the #{@blueprint} blueprint:" if @options[:verbose]
|
32
|
+
show(project.configsets, finder.find_all, "project")
|
33
|
+
|
34
|
+
blueprint = Lono::Configset::Register::Blueprint.new(@options)
|
35
|
+
blueprint.register
|
36
|
+
finder = Lono::Finder::Blueprint::Configset.new
|
37
|
+
finder.list("Configsets available to #{@blueprint} blueprint:") if @options[:verbose]
|
38
|
+
puts "Configsets built into the blueprint:" if @options[:verbose]
|
39
|
+
show(blueprint.configsets, finder.find_all, "blueprint")
|
40
|
+
|
41
|
+
table = Text::Table.new
|
42
|
+
table.head = ["Name", "Path", "Type", "From"]
|
43
|
+
@final.each do |spec|
|
44
|
+
pretty_root = spec.root.sub("#{Lono.root}/",'')
|
45
|
+
table.rows << [spec.name, pretty_root, spec.source_type, spec.from]
|
46
|
+
end
|
47
|
+
|
48
|
+
if table.rows.empty?
|
49
|
+
puts "No configsets being used."
|
50
|
+
else
|
51
|
+
puts "Configsets used by #{@blueprint.color(:green)} blueprint:"
|
52
|
+
puts table
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
def show(configsets, all, from)
|
57
|
+
configsets.each do |c|
|
58
|
+
puts " #{c.name}" if @options[:verbose]
|
59
|
+
spec = all.find { |jadespec| jadespec.name == c.name }
|
60
|
+
next unless spec
|
61
|
+
spec.from = from
|
62
|
+
@final << spec
|
63
|
+
end
|
64
|
+
puts "" if @options[:verbose]
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
@@ -0,0 +1,98 @@
|
|
1
|
+
require "json"
|
2
|
+
|
3
|
+
class Lono::Configset
|
4
|
+
class Loader
|
5
|
+
extend Memoist
|
6
|
+
include Dsl
|
7
|
+
include EvaluateFile
|
8
|
+
|
9
|
+
def initialize(registry={}, options={})
|
10
|
+
@registry, @options = registry, options
|
11
|
+
@name, @resource = registry.name, registry.resource
|
12
|
+
@blueprint = Lono::Conventions.new(options).blueprint
|
13
|
+
end
|
14
|
+
|
15
|
+
def metdata_configset
|
16
|
+
load
|
17
|
+
end
|
18
|
+
|
19
|
+
def load
|
20
|
+
path = find_path
|
21
|
+
copy_instance_variables
|
22
|
+
content = RenderMePretty.result(path, context: self)
|
23
|
+
if File.extname(path) == ".yml"
|
24
|
+
load_yaml(content)
|
25
|
+
else
|
26
|
+
JSON.load(content)
|
27
|
+
end
|
28
|
+
end
|
29
|
+
memoize :load
|
30
|
+
|
31
|
+
def load_yaml(content)
|
32
|
+
# Write to file so can use Yamler::Validator
|
33
|
+
path = "/tmp/lono/configset.yml"
|
34
|
+
FileUtils.mkdir_p(File.dirname(path))
|
35
|
+
IO.write(path, content)
|
36
|
+
Lono::Yamler::Validator.new(path).validate!
|
37
|
+
Lono::Yamler::Loader.new(content).load
|
38
|
+
end
|
39
|
+
|
40
|
+
def find_path
|
41
|
+
paths = %w[configset.yml configset.json].map { |p| "#{configset_root}/lib/#{p}" }
|
42
|
+
paths.find { |p| File.exist?(p) }
|
43
|
+
end
|
44
|
+
|
45
|
+
def configset_root
|
46
|
+
config = finder_class.find(@name)
|
47
|
+
unless config
|
48
|
+
puts "finder_class #{finder_class}"
|
49
|
+
raise "Unable to find configset #{@name.inspect}"
|
50
|
+
end
|
51
|
+
config.root
|
52
|
+
end
|
53
|
+
|
54
|
+
# Allow overriding in subclasses
|
55
|
+
def finder_class
|
56
|
+
Lono::Finder::Configset
|
57
|
+
end
|
58
|
+
|
59
|
+
def copy_instance_variables
|
60
|
+
load_blueprint_predefined_variables
|
61
|
+
load_project_predefined_variables
|
62
|
+
load_inline_project_variables
|
63
|
+
end
|
64
|
+
|
65
|
+
def load_blueprint_predefined_variables
|
66
|
+
path = "#{configset_root}/lib/variables.rb"
|
67
|
+
evaluate_file(path)
|
68
|
+
end
|
69
|
+
|
70
|
+
def load_project_predefined_variables
|
71
|
+
paths = [
|
72
|
+
"#{Lono.root}/configs/#{@blueprint}/configsets/variables.rb", # global
|
73
|
+
"#{Lono.root}/configs/#{@blueprint}/configsets/#{@name}/variables.rb", # configset specific
|
74
|
+
]
|
75
|
+
paths.each do |path|
|
76
|
+
evaluate_file(path)
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
80
|
+
# Copy options from the original configset call as instance variables so its available. So:
|
81
|
+
#
|
82
|
+
# configset("ssm", resource: "Instance", some_var: "test")
|
83
|
+
#
|
84
|
+
# Stores in the Configset::Registry
|
85
|
+
#
|
86
|
+
# register = {name: "ssm", resource: "Instance", some_var: "test"}
|
87
|
+
#
|
88
|
+
# That has is passed into Loader.new(register, options)
|
89
|
+
#
|
90
|
+
# So these @registry varibles are copied over to instance variables.
|
91
|
+
#
|
92
|
+
def load_inline_project_variables
|
93
|
+
@registry.vars.each do |k,v|
|
94
|
+
instance_variable_set("@#{k}", v)
|
95
|
+
end
|
96
|
+
end
|
97
|
+
end
|
98
|
+
end
|
@@ -0,0 +1,10 @@
|
|
1
|
+
module Lono::Configset::Materializer
|
2
|
+
class Final
|
3
|
+
def build(jades)
|
4
|
+
return if jades.empty?
|
5
|
+
list = jades.map(&:name).uniq.join(", ") # possible to have different versions. only showing names and removing duplicates
|
6
|
+
puts "Materializing #{list}..."
|
7
|
+
GemsBuilder.new(jades).build
|
8
|
+
end
|
9
|
+
end
|
10
|
+
end
|
@@ -0,0 +1,81 @@
|
|
1
|
+
require 'open3'
|
2
|
+
|
3
|
+
module Lono::Configset::Materializer
|
4
|
+
class GemsBuilder
|
5
|
+
extend Memoist
|
6
|
+
|
7
|
+
def initialize(*jades)
|
8
|
+
@jades = jades.flatten
|
9
|
+
@build_root = "#{Lono.root}/tmp/configsets"
|
10
|
+
end
|
11
|
+
|
12
|
+
def build
|
13
|
+
puts "GemsBuilder#build materializing #{@jades.map(&:name)}" if ENV['LONO_DEBUG']
|
14
|
+
remove_gemfile
|
15
|
+
gemfile = build_gemfile(@jades)
|
16
|
+
return unless gemfile
|
17
|
+
write(gemfile)
|
18
|
+
bundle
|
19
|
+
end
|
20
|
+
|
21
|
+
def build_gemfile(jades)
|
22
|
+
return if jades.empty?
|
23
|
+
|
24
|
+
lines = []
|
25
|
+
jades.each do |jade|
|
26
|
+
return if local_exist?(jade)
|
27
|
+
args = source.gem_args(jade)
|
28
|
+
line = %Q|gem #{args}|
|
29
|
+
lines << line unless lines.include?(line)
|
30
|
+
end
|
31
|
+
lines.sort!
|
32
|
+
lines.join("\n") + "\n"
|
33
|
+
end
|
34
|
+
|
35
|
+
def bundle
|
36
|
+
Bundler.with_original_env do
|
37
|
+
bundle_install
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
def bundle_install
|
42
|
+
command = "cd #{@build_root} && bundle install"
|
43
|
+
puts "=> #{command}" if ENV['LONO_DEBUG']
|
44
|
+
stdout, stderr, status = Open3.capture3(command)
|
45
|
+
|
46
|
+
unless status.success?
|
47
|
+
names = @jades.map(&:name)
|
48
|
+
gem_text = names.size == 1 ? "gem" : "gems"
|
49
|
+
puts "Fail to build #{gem_text} #{names.join(', ')}".color(:red)
|
50
|
+
puts "Failed running => #{command}"
|
51
|
+
puts stdout
|
52
|
+
puts stderr
|
53
|
+
if stderr.include?("correct access rights")
|
54
|
+
puts "Are you sure you have access to the git repo?".color(:yellow)
|
55
|
+
end
|
56
|
+
exit 1
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
# When a local version is found, will use that version
|
61
|
+
def local_exist?(jade)
|
62
|
+
!!jade.finder.find(jade.name, local_only: true)
|
63
|
+
end
|
64
|
+
|
65
|
+
def write(gemfile)
|
66
|
+
path = "#{@build_root}/Gemfile"
|
67
|
+
FileUtils.mkdir_p(File.dirname(path))
|
68
|
+
IO.write(path, gemfile)
|
69
|
+
end
|
70
|
+
|
71
|
+
def remove_gemfile
|
72
|
+
FileUtils.rm_f("#{@build_root}/Gemfile")
|
73
|
+
FileUtils.rm_f("#{@build_root}/Gemfile.lock")
|
74
|
+
end
|
75
|
+
|
76
|
+
def source
|
77
|
+
Source.new
|
78
|
+
end
|
79
|
+
memoize :source
|
80
|
+
end
|
81
|
+
end
|
@@ -0,0 +1,54 @@
|
|
1
|
+
module Lono::Configset::Materializer
|
2
|
+
class Source
|
3
|
+
def initialize(lono_settings=nil)
|
4
|
+
@lono_settings = lono_settings || Lono::Setting.new.data
|
5
|
+
end
|
6
|
+
|
7
|
+
# String provide to gem method in Gemfile. Example:
|
8
|
+
#
|
9
|
+
# gem "mygem", "v0.1.0", git: "xxx"
|
10
|
+
#
|
11
|
+
def gem_args(jade)
|
12
|
+
args = jade.registry.args
|
13
|
+
args = args.map { |s| %Q|"#{s}"| }.join(', ')
|
14
|
+
|
15
|
+
options = options(jade)
|
16
|
+
options = options.inject([]) { |r,(k,v)| r << %Q|#{k}: "#{v}"| }.join(', ')
|
17
|
+
|
18
|
+
"#{args}, #{options}"
|
19
|
+
end
|
20
|
+
|
21
|
+
def options(jade)
|
22
|
+
registry = jade.registry
|
23
|
+
options = registry.gem_options
|
24
|
+
# Direct source provided as part of configset call
|
25
|
+
#
|
26
|
+
# configset("ssm", git: "https://github.com/owner/ssm")
|
27
|
+
# configset("ssm", path: "/path/to/ssm")
|
28
|
+
# configset("ssm", source: "https://rubygems.org")
|
29
|
+
#
|
30
|
+
if options.key?(:git) || options.key?(:path) || options.key?(:source)
|
31
|
+
return(options)
|
32
|
+
end
|
33
|
+
|
34
|
+
# Otherwise use the sources location settings, which does not include the repo name
|
35
|
+
materalized_options = if location.include?("git@") || location.include?("https")
|
36
|
+
{git: "#{location}/#{jade.repo}"}
|
37
|
+
else
|
38
|
+
{path: "#{location}/#{jade.repo}"}
|
39
|
+
end
|
40
|
+
materalized_options.merge(options)
|
41
|
+
end
|
42
|
+
|
43
|
+
def location
|
44
|
+
ENV["LONO_MATERIALIZED_GEMS_SOURCE"] ||
|
45
|
+
Lono::Configset::Register::Blueprint.source ||
|
46
|
+
settings["source"] ||
|
47
|
+
"git@github.com:boltopspro" # default_location
|
48
|
+
end
|
49
|
+
|
50
|
+
def settings
|
51
|
+
@lono_settings.dig("materialized_gems") || {}
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
class Lono::Configset
|
2
|
+
class Meta
|
3
|
+
extend Memoist
|
4
|
+
include EvaluateFile
|
5
|
+
include Dsl
|
6
|
+
|
7
|
+
class_attribute :registries
|
8
|
+
self.registries = []
|
9
|
+
|
10
|
+
def initialize(jade)
|
11
|
+
@jade = jade
|
12
|
+
end
|
13
|
+
|
14
|
+
def evaluate
|
15
|
+
path = "#{@jade.root}/lib/meta.rb"
|
16
|
+
evaluate_file(path) # DSL depends_on sets @jade.depends_on decorated options
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
class Lono::Configset::Meta
|
2
|
+
module Dsl
|
3
|
+
def depends_on(*args)
|
4
|
+
options = args.last.is_a?(Hash) ? args.pop : {}
|
5
|
+
registry = Lono::Configset::Registry.new(args, options)
|
6
|
+
registry.depends_on = args.first
|
7
|
+
registry.parent = @jade
|
8
|
+
already_has = @jade.depends_ons.detect { |d| d.name == registry.name && d.args == registry.args }
|
9
|
+
@jade.depends_ons << registry unless already_has
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
@@ -0,0 +1,84 @@
|
|
1
|
+
class Lono::Configset
|
2
|
+
class New < Lono::Sequence
|
3
|
+
include Lono::Blueprint::Helper
|
4
|
+
|
5
|
+
argument :configset_name
|
6
|
+
|
7
|
+
def self.source_root
|
8
|
+
templates = File.expand_path("../../templates", File.dirname(__FILE__))
|
9
|
+
"#{templates}/configset"
|
10
|
+
end
|
11
|
+
|
12
|
+
def self.cli_options
|
13
|
+
[
|
14
|
+
[:demo, type: :boolean, default: true, desc: "Include demo template"],
|
15
|
+
[:force, type: :boolean, desc: "Bypass overwrite are you sure prompt for existing files."],
|
16
|
+
]
|
17
|
+
end
|
18
|
+
|
19
|
+
cli_options.each do |args|
|
20
|
+
class_option(*args)
|
21
|
+
end
|
22
|
+
|
23
|
+
# for specs
|
24
|
+
def set_cwd
|
25
|
+
@cwd = ENV['LONO_TEST'] ? File.dirname(Lono.root) : "#{Dir.pwd}/app/configsets"
|
26
|
+
end
|
27
|
+
|
28
|
+
def set_variables
|
29
|
+
@demo = @options[:demo]
|
30
|
+
@demo = false if ENV["LONO_ORG"] # overrides --demo CLI option
|
31
|
+
end
|
32
|
+
|
33
|
+
def create_project
|
34
|
+
puts "=> Creating new configset called #{configset_name}."
|
35
|
+
if @demo
|
36
|
+
options = {}
|
37
|
+
else
|
38
|
+
create_file "#{@cwd}/#{configset_name}/lib/configset.yml"
|
39
|
+
options = {exclude_pattern: %r{configset\.yml}}
|
40
|
+
end
|
41
|
+
|
42
|
+
directory ".", "#{@cwd}/#{configset_name}", options
|
43
|
+
end
|
44
|
+
|
45
|
+
def create_license
|
46
|
+
return unless ENV['LONO_LICENSE_FILE']
|
47
|
+
copy_file ENV['LONO_LICENSE_FILE'], "#{@cwd}/#{configset_name}/LICENSE.txt"
|
48
|
+
end
|
49
|
+
|
50
|
+
# After this commands are executed with the newly created project
|
51
|
+
def set_destination_root
|
52
|
+
destination_root = "#{@cwd}/#{configset_name}"
|
53
|
+
self.destination_root = destination_root
|
54
|
+
@old_dir = Dir.pwd # for reset_current_dir
|
55
|
+
FileUtils.cd(self.destination_root)
|
56
|
+
end
|
57
|
+
|
58
|
+
def welcome_message
|
59
|
+
puts <<~EOL
|
60
|
+
#{"="*64}
|
61
|
+
Congrats 🎉 You have successfully created a lono configset.
|
62
|
+
|
63
|
+
Cd into your configset and check things out.
|
64
|
+
|
65
|
+
cd #{configset_name}
|
66
|
+
|
67
|
+
More info: https://lono.cloud/docs/core/configsets
|
68
|
+
|
69
|
+
EOL
|
70
|
+
end
|
71
|
+
|
72
|
+
def tree
|
73
|
+
tree_installed = system("type tree > /dev/null")
|
74
|
+
return unless tree_installed
|
75
|
+
|
76
|
+
structure = `tree .`
|
77
|
+
puts <<~EOL
|
78
|
+
Here is the structure of your configset:
|
79
|
+
|
80
|
+
#{structure}
|
81
|
+
EOL
|
82
|
+
end
|
83
|
+
end
|
84
|
+
end
|