lono 8.0.0.pre.rc1 → 8.0.0.pre.rc4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.cody/acceptance/bin/build.sh +5 -5
- data/.github/ISSUE_TEMPLATE/bug_report.md +84 -0
- data/.github/ISSUE_TEMPLATE/documentation.md +12 -0
- data/.github/ISSUE_TEMPLATE/feature_request.md +64 -0
- data/.github/ISSUE_TEMPLATE/question.md +14 -0
- data/.github/ISSUE_TEMPLATE.md +7 -0
- data/.github/PULL_REQUEST_TEMPLATE.md +50 -0
- data/CHANGELOG.md +59 -2
- data/Gemfile +1 -3
- data/README.md +2 -7
- data/lib/lono/app/callable_option/concern.rb +12 -0
- data/lib/lono/app/callable_option.rb +56 -0
- data/lib/lono/app.rb +56 -20
- data/lib/lono/autoloader.rb +1 -0
- data/lib/lono/aws_services/helper.rb +0 -2
- data/lib/lono/blueprint.rb +1 -18
- data/lib/lono/builder/allow/base.rb +54 -0
- data/lib/lono/builder/allow/env.rb +17 -0
- data/lib/lono/builder/allow/region.rb +20 -0
- data/lib/lono/builder/allow.rb +8 -0
- data/lib/lono/builder/configset/combiner.rb +145 -0
- data/lib/lono/builder/configset/definition/base.rb +47 -0
- data/lib/lono/builder/configset/definition/context.rb +70 -0
- data/lib/lono/{configset/strategy/helpers/dsl → builder/configset/definition/dsl/syntax}/auth.rb +1 -1
- data/lib/lono/builder/configset/definition/dsl/syntax/content.rb +22 -0
- data/lib/lono/{configset/strategy/helpers/dsl/syntax.rb → builder/configset/definition/dsl/syntax/core.rb} +15 -9
- data/lib/lono/{configset/strategy/helpers/dsl → builder/configset/definition/dsl/syntax}/package.rb +1 -1
- data/lib/lono/builder/configset/definition/dsl/syntax.rb +5 -0
- data/lib/lono/{configset/strategy → builder/configset/definition}/dsl.rb +10 -14
- data/lib/lono/{configset/strategy → builder/configset/definition}/erb.rb +13 -16
- data/lib/lono/builder/configset/definition.rb +18 -0
- data/lib/lono/builder/configset/evaluator.rb +10 -0
- data/lib/lono/builder/configset/registration.rb +35 -0
- data/lib/lono/builder/context.rb +33 -18
- data/lib/lono/builder/dsl/evaluator.rb +45 -0
- data/lib/lono/builder/dsl/finalizer/base.rb +8 -0
- data/lib/lono/builder/dsl/finalizer/configsets.rb +20 -0
- data/lib/lono/builder/dsl/finalizer/files/base.rb +4 -0
- data/lib/lono/builder/dsl/finalizer/files/build.rb +50 -0
- data/lib/lono/builder/dsl/finalizer/files/replace.rb +36 -0
- data/lib/lono/builder/dsl/finalizer/files.rb +9 -0
- data/lib/lono/builder/{template/dsl → dsl}/finalizer/parameter_groups.rb +6 -5
- data/lib/lono/builder/dsl/finalizer.rb +15 -0
- data/lib/lono/builder/{template/dsl/evaluator/helpers/ec2_helper.rb → dsl/helpers/ec2.rb} +3 -3
- data/lib/lono/builder/dsl/helpers/files.rb +7 -0
- data/lib/lono/builder/{template/helpers.rb → dsl/helpers/partials.rb} +48 -57
- data/lib/lono/builder/dsl/helpers/s3.rb +14 -0
- data/lib/lono/builder/{context/ssm_fetcher.rb → dsl/helpers/ssm/fetcher.rb} +5 -3
- data/lib/lono/builder/{context/helpers.rb → dsl/helpers/ssm.rb} +3 -3
- data/lib/lono/builder/{template/dsl/evaluator/helpers/stack_helper.rb → dsl/helpers/stack.rb} +6 -6
- data/lib/lono/builder/{template/dsl/evaluator/helpers/tags_helper.rb → dsl/helpers/tags.rb} +2 -2
- data/lib/lono/builder/dsl/helpers/template_file.rb +66 -0
- data/lib/lono/builder/dsl/helpers.rb +5 -0
- data/lib/lono/builder/{template/dsl/evaluator/section → dsl/syntax/core}/base.rb +4 -5
- data/lib/lono/builder/{template/dsl/evaluator/section → dsl/syntax/core}/condition.rb +1 -1
- data/lib/lono/builder/{template/dsl/evaluator/section → dsl/syntax/core}/mapping.rb +1 -1
- data/lib/lono/builder/{template/dsl/evaluator/section → dsl/syntax/core}/output.rb +1 -1
- data/lib/lono/builder/{template/dsl/evaluator/section → dsl/syntax/core}/parameter.rb +1 -1
- data/lib/lono/builder/{template/dsl/evaluator/section → dsl/syntax/core}/resource/property_mover.rb +12 -2
- data/lib/lono/builder/{template/dsl/evaluator/section → dsl/syntax/core}/resource.rb +1 -1
- data/lib/lono/builder/{template/dsl/evaluator/section → dsl/syntax/core}/section.rb +1 -1
- data/lib/lono/builder/dsl/syntax/core/squeezer.rb +40 -0
- data/lib/lono/builder/{template/dsl/evaluator/section/methods.rb → dsl/syntax/core.rb} +2 -2
- data/lib/lono/builder/{template/dsl/evaluator → dsl/syntax}/fn.rb +1 -3
- data/lib/lono/builder/{template/dsl/evaluator → dsl}/syntax/parameter_group.rb +1 -1
- data/lib/lono/builder/dsl/syntax.rb +9 -0
- data/lib/lono/builder/{template/dsl.rb → dsl.rb} +2 -2
- data/lib/lono/builder/param.rb +5 -2
- data/lib/lono/builder/template/upload.rb +2 -15
- data/lib/lono/builder/template.rb +1 -3
- data/lib/lono/builder/{template/dsl/evaluator → util}/stringify.rb +1 -1
- data/lib/lono/builder.rb +39 -0
- data/lib/lono/bundler/component/props/extension.rb +0 -1
- data/lib/lono/bundler/extract/tar.rb +0 -1
- data/lib/lono/bundler/util/git.rb +18 -16
- data/lib/lono/cfn/base.rb +2 -2
- data/lib/lono/cfn/cancel.rb +5 -5
- data/lib/lono/cfn/concerns/build.rb +1 -1
- data/lib/lono/cfn/delete.rb +5 -2
- data/lib/lono/cfn/deploy/iam.rb +1 -2
- data/lib/lono/cfn/deploy/rollback.rb +1 -3
- data/lib/lono/cfn/deploy.rb +46 -5
- data/lib/lono/cfn/download.rb +0 -1
- data/lib/lono/cfn/plan/changeset.rb +3 -3
- data/lib/lono/cfn/plan/diff/data.rb +11 -1
- data/lib/lono/cfn/plan/diff/file.rb +2 -1
- data/lib/lono/cfn/plan/param.rb +1 -1
- data/lib/lono/cfn/plan/template.rb +2 -2
- data/lib/lono/cfn/plan.rb +1 -0
- data/lib/lono/cli/abstract.rb +0 -6
- data/lib/lono/cli/base.rb +6 -3
- data/lib/lono/cli/clean.rb +3 -2
- data/lib/lono/cli/help/cfn/status.md +0 -1
- data/lib/lono/cli/help/new/helper.md +27 -0
- data/lib/lono/cli/help/new/hook.md +14 -0
- data/lib/lono/cli/help/new/project.md +3 -10
- data/lib/lono/cli/help/seed.md +22 -21
- data/lib/lono/cli/iam.rb +27 -0
- data/lib/lono/cli/list.rb +3 -6
- data/lib/lono/cli/new/blueprint.rb +3 -9
- data/lib/lono/cli/new/configset.rb +11 -44
- data/lib/lono/cli/new/helper.rb +19 -11
- data/lib/lono/cli/new/hook.rb +32 -0
- data/lib/lono/cli/new/sequence.rb +6 -1
- data/lib/lono/cli/new.rb +9 -9
- data/lib/lono/cli/s3.rb +3 -3
- data/lib/lono/cli/script/build.rb +0 -5
- data/lib/lono/cli/status.rb +18 -0
- data/lib/lono/{inspector → cli}/summary.rb +23 -33
- data/lib/lono/cli.rb +16 -16
- data/lib/lono/command.rb +28 -2
- data/lib/lono/component.rb +29 -0
- data/lib/lono/concerns/aws_info.rb +14 -0
- data/lib/lono/concerns/names.rb +9 -0
- data/lib/lono/configset.rb +17 -0
- data/lib/lono/core.rb +11 -1
- data/lib/lono/ext/bundler.rb +7 -0
- data/lib/lono/ext/core/module.rb +31 -0
- data/lib/lono/ext/core/object.rb +32 -0
- data/lib/lono/ext/core/string.rb +9 -0
- data/lib/lono/ext.rb +4 -0
- data/lib/lono/files/base.rb +12 -0
- data/lib/lono/{utils → files/builder/lambda_layer}/rsync.rb +3 -5
- data/lib/lono/{app_file/build → files/builder}/lambda_layer/ruby_packager.rb +104 -79
- data/lib/lono/files/builder/lambda_layer/ruby_version.rb +38 -0
- data/lib/lono/files/builder/lambda_layer.rb +17 -0
- data/lib/lono/files/builder.rb +37 -0
- data/lib/lono/files/compressor.rb +53 -0
- data/lib/lono/files/concerns/post_processing.rb +52 -0
- data/lib/lono/files/concerns/registration.rb +16 -0
- data/lib/lono/files/registry.rb +6 -0
- data/lib/lono/files.rb +41 -0
- data/lib/lono/hooks/builder.rb +50 -0
- data/lib/lono/hooks/concern.rb +9 -0
- data/lib/lono/hooks/dsl.rb +20 -0
- data/lib/lono/hooks/runner.rb +46 -0
- data/lib/lono/layering/layer.rb +64 -56
- data/lib/lono/logger.rb +2 -3
- data/lib/lono/names.rb +7 -10
- data/lib/lono/s3/bucket.rb +43 -37
- data/lib/lono/s3/rollback.rb +8 -0
- data/lib/lono/s3/uploader.rb +33 -28
- data/lib/lono/script/build.rb +0 -5
- data/lib/lono/seeder.rb +38 -29
- data/lib/lono/user_data.rb +3 -1
- data/lib/lono/utils/sh.rb +32 -0
- data/lib/lono/utils.rb +5 -0
- data/lib/lono/version.rb +1 -1
- data/lib/lono/yamler/validator.rb +7 -22
- data/lib/lono.rb +8 -0
- data/lib/templates/configset/configset.rb +2 -16
- data/lib/templates/examples/configset/configset.rb +16 -0
- data/lib/templates/helper/%underscore_name%_helper.rb.tt +1 -1
- data/lib/templates/hook/config/hooks.rb.tt +14 -0
- data/lono.gemspec +1 -1
- metadata +99 -93
- data/lib/lono/app_file/base.rb +0 -28
- data/lib/lono/app_file/build/lambda_layer.rb +0 -20
- data/lib/lono/app_file/build.rb +0 -79
- data/lib/lono/app_file/registry/item.rb +0 -24
- data/lib/lono/app_file/registry.rb +0 -16
- data/lib/lono/app_file/upload.rb +0 -12
- data/lib/lono/builder/context/loader/load_files.rb +0 -23
- data/lib/lono/builder/context/loader.rb +0 -35
- data/lib/lono/builder/context/params.rb +0 -7
- data/lib/lono/builder/template/configset_injector.rb +0 -52
- data/lib/lono/builder/template/dsl/evaluator/helpers/core_helper.rb +0 -14
- data/lib/lono/builder/template/dsl/evaluator/helpers/file_helper.rb +0 -44
- data/lib/lono/builder/template/dsl/evaluator/helpers/s3_helper.rb +0 -16
- data/lib/lono/builder/template/dsl/evaluator/helpers.rb +0 -16
- data/lib/lono/builder/template/dsl/evaluator/squeezer.rb +0 -24
- data/lib/lono/builder/template/dsl/evaluator/syntax/extend_with.rb +0 -9
- data/lib/lono/builder/template/dsl/evaluator/syntax.rb +0 -11
- data/lib/lono/builder/template/dsl/evaluator.rb +0 -45
- data/lib/lono/builder/template/dsl/finalizer.rb +0 -12
- data/lib/lono/builder/template/evaluate.rb +0 -52
- data/lib/lono/builder/template/post_processor.rb +0 -67
- data/lib/lono/cli/build.rb +0 -101
- data/lib/lono/cli/code.rb +0 -22
- data/lib/lono/cli/help/blueprint/new.md +0 -56
- data/lib/lono/cli/new/extension.rb +0 -57
- data/lib/lono/configset/builder.rb +0 -59
- data/lib/lono/configset/combiner.rb +0 -164
- data/lib/lono/configset/evaluate_file.rb +0 -8
- data/lib/lono/configset/meta/dsl.rb +0 -12
- data/lib/lono/configset/meta.rb +0 -19
- data/lib/lono/configset/s3_file/build.rb +0 -34
- data/lib/lono/configset/s3_file/item.rb +0 -38
- data/lib/lono/configset/s3_file/registry.rb +0 -12
- data/lib/lono/configset/s3_file/upload.rb +0 -12
- data/lib/lono/configset/strategy/base.rb +0 -83
- data/lib/lono/configset/strategy/helpers/dsl/core.rb +0 -18
- data/lib/lono/configset/strategy/helpers/dsl.rb +0 -8
- data/lib/lono/configset/strategy/helpers/erb.rb +0 -9
- data/lib/lono/extensions/dsl.rb +0 -8
- data/lib/lono/extensions/loader.rb +0 -19
- data/lib/lono/extensions.rb +0 -18
- data/lib/lono/importer/base.rb +0 -48
- data/lib/lono/importer/converter.rb +0 -19
- data/lib/lono/importer/download.rb +0 -46
- data/lib/lono/importer/dsl.rb +0 -36
- data/lib/lono/importer/params.rb +0 -56
- data/lib/lono/importer/service/coder.rb +0 -81
- data/lib/lono/inspector/base.rb +0 -32
- data/lib/lono/lookup.rb +0 -12
- data/lib/lono/seeder/service_role.rb +0 -11
- data/lib/lono/utils/context.rb +0 -15
- data/lib/lono/utils/item/file_methods.rb +0 -29
- data/lib/lono/utils/item/zip.rb +0 -42
- data/lib/templates/extension/lib/%extension_name%/autoloader.rb.tt +0 -23
- data/lib/templates/extension/lib/%extension_name%/helpers/mappings.rb.tt +0 -24
- data/lib/templates/extension/lib/%extension_name%/helpers/outputs.rb.tt +0 -7
- data/lib/templates/extension/lib/%extension_name%/helpers/parameters.rb.tt +0 -10
- data/lib/templates/extension/lib/%extension_name%/helpers/resources/resource.rb.tt +0 -4
- data/lib/templates/extension/lib/%extension_name%/helpers/variables.rb.tt +0 -6
- data/lib/templates/extension/lib/%extension_name%/version.rb.tt +0 -3
- data/lib/templates/extension/lib/%extension_name%.rb.tt +0 -8
data/lib/lono/cli/iam.rb
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
class Lono::CLI
|
2
|
+
class Iam < Base
|
3
|
+
include Lono::Cfn::Concerns::Build
|
4
|
+
include Lono::Cfn::Concerns::TemplateOutput
|
5
|
+
|
6
|
+
def run
|
7
|
+
build.template_builder.run
|
8
|
+
resources = template_output.data['Resources']
|
9
|
+
types = resources.map { |logical_id, attrs| attrs['Type'] }
|
10
|
+
actions = types.map do |t|
|
11
|
+
service = t.split('::')[1]
|
12
|
+
"#{service.downcase}:*"
|
13
|
+
end.uniq
|
14
|
+
text =<<~EOL
|
15
|
+
Version: 2012-10-17
|
16
|
+
Statement:
|
17
|
+
- Sid: #{@blueprint.name}
|
18
|
+
Effect: Allow
|
19
|
+
Resource: "*"
|
20
|
+
EOL
|
21
|
+
policy = YAML.load(text)
|
22
|
+
policy['Statement'][0]['Action'] = actions
|
23
|
+
puts "IAM Policy Example for blueprint #{@blueprint.name}".color(:green)
|
24
|
+
puts JSON.pretty_generate(policy)
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
data/lib/lono/cli/list.rb
CHANGED
@@ -13,14 +13,11 @@ class Lono::CLI
|
|
13
13
|
|
14
14
|
private
|
15
15
|
def list_type(type)
|
16
|
-
|
16
|
+
Dir.glob("#{Lono.root}/{app,vendor}/#{type}/*").each do |path|
|
17
|
+
logger.info pretty_path(path)
|
18
|
+
end
|
17
19
|
end
|
18
20
|
|
19
|
-
def lookup
|
20
|
-
Lono::Lookup.new
|
21
|
-
end
|
22
|
-
memoize :lookup
|
23
|
-
|
24
21
|
def show?(type)
|
25
22
|
@options[:type] == type || @options[:type].nil? || @options[:type] == "all"
|
26
23
|
end
|
@@ -3,9 +3,8 @@ class Lono::CLI::New
|
|
3
3
|
argument :name
|
4
4
|
def self.cli_options
|
5
5
|
[
|
6
|
-
[:force, type: :boolean, desc: "Bypass overwrite are you sure prompt for existing files"],
|
7
6
|
[:examples, type: :boolean, desc: "Whether not to generate examples"],
|
8
|
-
[:
|
7
|
+
[:force, type: :boolean, desc: "Bypass overwrite are you sure prompt for existing files"],
|
9
8
|
]
|
10
9
|
end
|
11
10
|
cli_options.each do |args|
|
@@ -20,14 +19,9 @@ class Lono::CLI::New
|
|
20
19
|
end
|
21
20
|
end
|
22
21
|
|
23
|
-
# for specs
|
24
|
-
def set_dest
|
25
|
-
@dest = [@options[:project], "app/blueprints"].compact.join('/')
|
26
|
-
end
|
27
|
-
|
28
22
|
def create_blueprint
|
29
|
-
logger.info "=> Creating new blueprint
|
30
|
-
directory ".", "
|
23
|
+
logger.info "=> Creating new blueprint: #{name}"
|
24
|
+
directory ".", "app/blueprints/#{name}"
|
31
25
|
end
|
32
26
|
end
|
33
27
|
end
|
@@ -1,56 +1,27 @@
|
|
1
1
|
class Lono::CLI::New
|
2
2
|
class Configset < Sequence
|
3
|
-
argument :
|
4
|
-
|
5
|
-
def self.source_root
|
6
|
-
templates = File.expand_path("../../templates", File.dirname(__FILE__))
|
7
|
-
"#{templates}/configset"
|
8
|
-
end
|
9
|
-
|
3
|
+
argument :name
|
10
4
|
def self.cli_options
|
11
5
|
[
|
12
|
-
[:
|
13
|
-
[:force, type: :boolean, desc: "Bypass overwrite are you sure prompt for existing files
|
6
|
+
[:examples, type: :boolean, desc: "Whether not to generate examples"],
|
7
|
+
[:force, type: :boolean, desc: "Bypass overwrite are you sure prompt for existing files"],
|
14
8
|
]
|
15
9
|
end
|
16
|
-
|
17
10
|
cli_options.each do |args|
|
18
11
|
class_option(*args)
|
19
12
|
end
|
20
13
|
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
end
|
25
|
-
|
26
|
-
def set_variables
|
27
|
-
@demo = @options[:demo]
|
28
|
-
@demo = false if ENV["LONO_ORG"] # overrides --demo CLI option
|
29
|
-
end
|
30
|
-
|
31
|
-
def create_project
|
32
|
-
puts "=> Creating new configset called #{configset_name}."
|
33
|
-
if @demo
|
34
|
-
options = {}
|
14
|
+
def set_source
|
15
|
+
if @options[:examples]
|
16
|
+
set_template_source "examples/configset"
|
35
17
|
else
|
36
|
-
|
37
|
-
options = {exclude_pattern: %r{configset\.rb}}
|
18
|
+
set_template_source "configset"
|
38
19
|
end
|
39
|
-
|
40
|
-
directory ".", "#{@cwd}/#{configset_name}", options
|
41
|
-
end
|
42
|
-
|
43
|
-
def create_license
|
44
|
-
return unless ENV['LONO_LICENSE_FILE']
|
45
|
-
copy_file ENV['LONO_LICENSE_FILE'], "#{@cwd}/#{configset_name}/LICENSE.txt"
|
46
20
|
end
|
47
21
|
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
self.destination_root = destination_root
|
52
|
-
@old_dir = Dir.pwd # for reset_current_dir
|
53
|
-
FileUtils.cd(self.destination_root)
|
22
|
+
def create_configset
|
23
|
+
dest = "#{Lono.root}/app/configsets"
|
24
|
+
directory ".", "#{dest}/#{name}"
|
54
25
|
end
|
55
26
|
|
56
27
|
def welcome_message
|
@@ -58,11 +29,7 @@ class Lono::CLI::New
|
|
58
29
|
#{"="*64}
|
59
30
|
Congrats 🎉 You have successfully created a lono configset.
|
60
31
|
|
61
|
-
|
62
|
-
|
63
|
-
cd #{configset_name}
|
64
|
-
|
65
|
-
More info: https://lono.cloud/docs/core/configsets
|
32
|
+
More info: https://lono.cloud/docs/configsets
|
66
33
|
|
67
34
|
EOL
|
68
35
|
end
|
data/lib/lono/cli/new/helper.rb
CHANGED
@@ -1,10 +1,12 @@
|
|
1
1
|
class Lono::CLI::New
|
2
|
-
class Helper < Sequence
|
2
|
+
class Helper < Lono::CLI::New::Sequence
|
3
3
|
def self.cli_options
|
4
|
+
# required for name => underscore_name => app/blueprints/demo/helpers/%underscore_name%_helper.rb.tt
|
5
|
+
argument :name, default: "custom", desc: "Helper name"
|
6
|
+
|
4
7
|
[
|
5
8
|
[:force, type: :boolean, desc: "Bypass overwrite are you sure prompt for existing files"],
|
6
|
-
[:blueprint,
|
7
|
-
[:name, default: "custom", desc: "Helper name"],
|
9
|
+
[:blueprint, aliases: :b, desc: "Blueprint name. Only use you want a blueprint helper. Otherwise a project helper is generated"],
|
8
10
|
]
|
9
11
|
end
|
10
12
|
cli_options.each do |args|
|
@@ -15,18 +17,24 @@ class Lono::CLI::New
|
|
15
17
|
set_template_source "helper"
|
16
18
|
end
|
17
19
|
|
18
|
-
def
|
19
|
-
|
20
|
-
|
20
|
+
def create_helper
|
21
|
+
if @options[:blueprint]
|
22
|
+
create_blueprint_helper
|
23
|
+
else
|
24
|
+
create_project_helper
|
25
|
+
end
|
21
26
|
end
|
22
27
|
|
23
|
-
|
24
|
-
|
25
|
-
|
28
|
+
private
|
29
|
+
def create_blueprint_helper
|
30
|
+
@blueprint = @options[:blueprint] # allows %underscore_name%_helper.rb.tt to access @blueprint
|
31
|
+
logger.info "=> Generating #{underscore_name}_helper.rb"
|
26
32
|
directory ".", "app/blueprints/#{@blueprint}/helpers"
|
27
33
|
end
|
28
34
|
|
29
|
-
|
30
|
-
|
35
|
+
def create_project_helper
|
36
|
+
logger.info "=> Generating #{underscore_name}_helper.rb"
|
37
|
+
directory ".", "app/helpers/#{underscore_name}"
|
38
|
+
end
|
31
39
|
end
|
32
40
|
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
class Lono::CLI::New
|
2
|
+
class Hook < Lono::CLI::New::Sequence
|
3
|
+
def self.cli_options
|
4
|
+
[
|
5
|
+
[:force, type: :boolean, desc: "Bypass overwrite are you sure prompt for existing files"],
|
6
|
+
[:blueprint, aliases: :b, desc: "Blueprint name. Only use you want a blueprint helper. Otherwise a project helper is generated"],
|
7
|
+
]
|
8
|
+
end
|
9
|
+
cli_options.each do |args|
|
10
|
+
class_option(*args)
|
11
|
+
end
|
12
|
+
|
13
|
+
def set_source
|
14
|
+
set_template_source "hook"
|
15
|
+
end
|
16
|
+
|
17
|
+
def create_hook
|
18
|
+
logger.info "=> Generating hook"
|
19
|
+
if blueprint
|
20
|
+
directory ".", "app/blueprints/#{blueprint}"
|
21
|
+
else
|
22
|
+
directory ".", "."
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
private
|
27
|
+
# So templates/hooks/config/hooks.rb.tt has access to blueprint
|
28
|
+
def blueprint
|
29
|
+
@options[:blueprint]
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
@@ -12,7 +12,8 @@ class Lono::CLI::New
|
|
12
12
|
|
13
13
|
private
|
14
14
|
def self.set_template_source(folder)
|
15
|
-
|
15
|
+
path = File.expand_path("../../../templates/#{folder}", __dir__)
|
16
|
+
source_root path
|
16
17
|
end
|
17
18
|
|
18
19
|
def set_template_source(*paths)
|
@@ -47,5 +48,9 @@ class Lono::CLI::New
|
|
47
48
|
puts "=> Initialize git repo"
|
48
49
|
run("git init")
|
49
50
|
end
|
51
|
+
|
52
|
+
def env
|
53
|
+
Lono.env # allows for seed/vars/%env%.rb.tt
|
54
|
+
end
|
50
55
|
end
|
51
56
|
end
|
data/lib/lono/cli/new.rb
CHANGED
@@ -2,27 +2,27 @@ class Lono::CLI
|
|
2
2
|
class New < Lono::Command
|
3
3
|
long_desc Help.text("new/blueprint")
|
4
4
|
Blueprint.cli_options.each { |args| option(*args) }
|
5
|
-
register(Blueprint, "blueprint", "blueprint NAME", "
|
5
|
+
register(Blueprint, "blueprint", "blueprint NAME", "Generate new blueprint")
|
6
6
|
|
7
7
|
long_desc Help.text("new/configset")
|
8
8
|
Configset.cli_options.each { |args| option(*args) }
|
9
|
-
register(Configset, "configset", "configset NAME", "
|
10
|
-
|
11
|
-
long_desc Help.text("new/extension")
|
12
|
-
Extension.cli_options.each { |args| option(*args) }
|
13
|
-
register(Extension, "extension", "extension NAME", "Generates new extension.")
|
9
|
+
register(Configset, "configset", "configset NAME", "Generate new configset")
|
14
10
|
|
15
11
|
long_desc Help.text("new/helper")
|
16
12
|
Helper.cli_options.each { |args| option(*args) }
|
17
|
-
register(Helper, "helper", "helper NAME", "
|
13
|
+
register(Helper, "helper", "helper NAME", "Generate new helper")
|
14
|
+
|
15
|
+
long_desc Help.text("new/hook")
|
16
|
+
Hook.cli_options.each { |args| option(*args) }
|
17
|
+
register(Hook, "hook", "hook NAME", "Generate new hook")
|
18
18
|
|
19
19
|
long_desc Help.text("new/project")
|
20
20
|
Project.cli_options.each { |args| option(*args) }
|
21
|
-
register(Project, "project", "project NAME", "
|
21
|
+
register(Project, "project", "project NAME", "Generate new project")
|
22
22
|
|
23
23
|
long_desc Help.text("new/shim")
|
24
24
|
Shim.cli_options.each { |args| option(*args) }
|
25
|
-
register(Shim, "shim", "shim NAME", "
|
25
|
+
register(Shim, "shim", "shim NAME", "Generate new shim")
|
26
26
|
|
27
27
|
desc "test SUBCOMMAND", "test subcommands"
|
28
28
|
long_desc Help.text(:test)
|
data/lib/lono/cli/s3.rb
CHANGED
@@ -5,21 +5,21 @@ class Lono::CLI
|
|
5
5
|
desc "deploy", "deploys lono managed s3 bucket"
|
6
6
|
long_desc Help.text("s3/deploy")
|
7
7
|
def deploy
|
8
|
-
Lono::Bucket.new(options).deploy
|
8
|
+
Lono::S3::Bucket.new(options).deploy
|
9
9
|
end
|
10
10
|
|
11
11
|
desc "show", "shows lono managed s3 bucket"
|
12
12
|
long_desc Help.text("s3/show")
|
13
13
|
opts.yes
|
14
14
|
def show
|
15
|
-
Lono::Bucket.new(options).show
|
15
|
+
Lono::S3::Bucket.new(options).show
|
16
16
|
end
|
17
17
|
|
18
18
|
desc "delete", "deletes lono managed s3 bucket"
|
19
19
|
long_desc Help.text("s3/delete")
|
20
20
|
opts.yes
|
21
21
|
def delete
|
22
|
-
Lono::Bucket.new(options).delete
|
22
|
+
Lono::S3::Bucket.new(options).delete
|
23
23
|
end
|
24
24
|
end
|
25
25
|
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
class Lono::CLI
|
2
|
+
class Status < Lono::CLI::Base
|
3
|
+
include Lono::AwsServices
|
4
|
+
|
5
|
+
def run
|
6
|
+
names = Lono::Names.new(@options)
|
7
|
+
stack = find_stack(@stack)
|
8
|
+
if stack
|
9
|
+
status = Lono::Cfn::Status.new(@stack, @options)
|
10
|
+
success = status.run
|
11
|
+
exit 1 unless success
|
12
|
+
else
|
13
|
+
logger.error "ERROR: stack #{@stack} not found".color(:red)
|
14
|
+
exit 1
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -1,32 +1,27 @@
|
|
1
|
-
|
1
|
+
class Lono::CLI
|
2
2
|
class Summary < Base
|
3
|
+
include Lono::Cfn::Concerns::Build
|
3
4
|
include Lono::Cfn::Concerns::TemplateOutput
|
4
5
|
|
5
|
-
def
|
6
|
-
|
7
|
-
@template = template
|
8
|
-
|
9
|
-
logger.info "=> CloudFormation Template Summary for template #{@template.color(:sienna)}:"
|
10
|
-
return if ENV['LONO_NOOP']
|
11
|
-
|
6
|
+
def run
|
7
|
+
build.all
|
12
8
|
print_parameters_summary
|
13
|
-
logger.info "# Resources:"
|
14
9
|
print_resource_types
|
15
10
|
end
|
16
11
|
|
17
12
|
def print_parameters_summary
|
18
13
|
parameters = template_output.parameters
|
14
|
+
logger.info "Parameters (#{parameters.size})".color(:green)
|
19
15
|
parameter_groups = template_output.parameter_groups
|
20
16
|
|
21
17
|
if parameters.empty?
|
22
|
-
logger.info "
|
18
|
+
logger.info "No parameters"
|
23
19
|
return
|
24
20
|
end
|
25
21
|
|
26
22
|
shown = []
|
27
|
-
|
28
|
-
|
29
|
-
logger.info "# Parameter Group (#{parameters.size}): #{label}".color(:sienna)
|
23
|
+
parameter_groups.each do |parameter_group_label, parameters|
|
24
|
+
logger.info parameter_group_label
|
30
25
|
parameters.each do |name|
|
31
26
|
logger.info parameter_line(name)
|
32
27
|
shown << name
|
@@ -40,13 +35,11 @@ module Lono::Inspector
|
|
40
35
|
|
41
36
|
def parameter_line(name)
|
42
37
|
data = template_output.parameters[name]
|
43
|
-
example = description_example(data["Description"])
|
44
38
|
if data["Default"].nil?
|
45
|
-
line = "#{name}
|
39
|
+
line = " #{name} (required)"
|
46
40
|
else
|
47
41
|
default = data["Default"]
|
48
|
-
line = "# #{name}=#{default}"
|
49
|
-
line = "#{line} # #{example}" if example
|
42
|
+
line = default.blank? ? " #{name}" : " #{name}=#{default}"
|
50
43
|
end
|
51
44
|
line
|
52
45
|
end
|
@@ -59,18 +52,9 @@ module Lono::Inspector
|
|
59
52
|
md[2]
|
60
53
|
end
|
61
54
|
|
62
|
-
def resource_types
|
63
|
-
resources = template_output.data["Resources"]
|
64
|
-
return unless resources
|
65
|
-
|
66
|
-
types = Hash.new(0)
|
67
|
-
resources.each do |logical_id, resource|
|
68
|
-
types[resource["Type"]] += 1
|
69
|
-
end
|
70
|
-
types
|
71
|
-
end
|
72
|
-
|
73
55
|
def print_resource_types
|
56
|
+
total = template_output.data["Resources"].size
|
57
|
+
logger.info "Resources (#{total})".color(:green)
|
74
58
|
unless resource_types
|
75
59
|
logger.info "No resources found."
|
76
60
|
return
|
@@ -79,15 +63,21 @@ module Lono::Inspector
|
|
79
63
|
types = resource_types.sort_by {|r| r[1] * -1} # Hash -> 2D Array
|
80
64
|
types.each do |a|
|
81
65
|
type, count = a
|
82
|
-
printf "%
|
66
|
+
printf "%5s %s\n", count, type
|
83
67
|
end
|
84
68
|
total = types.inject(0) { |sum,(type,count)| sum += count }
|
85
|
-
printf "%
|
69
|
+
printf "%5s %s\n", total, "Total"
|
86
70
|
end
|
87
71
|
|
88
|
-
def
|
89
|
-
|
72
|
+
def resource_types
|
73
|
+
resources = template_output.data["Resources"]
|
74
|
+
return unless resources
|
75
|
+
|
76
|
+
types = Hash.new(0)
|
77
|
+
resources.each do |logical_id, resource|
|
78
|
+
types[resource["Type"]] += 1
|
79
|
+
end
|
80
|
+
types
|
90
81
|
end
|
91
|
-
memoize :template_output
|
92
82
|
end
|
93
83
|
end
|
data/lib/lono/cli.rb
CHANGED
@@ -5,12 +5,12 @@ module Lono
|
|
5
5
|
opts = Opts.new(self)
|
6
6
|
cfn_opts = Lono::CLI::Cfn::Opts.new(self)
|
7
7
|
|
8
|
-
desc "build BLUEPRINT", "Build
|
8
|
+
desc "build BLUEPRINT", "Build template"
|
9
9
|
long_desc Help.text(:build)
|
10
10
|
option :quiet, type: :boolean, desc: "silence the output"
|
11
11
|
opts.clean
|
12
12
|
def build(blueprint)
|
13
|
-
|
13
|
+
Lono::Builder.new(options.merge(blueprint: blueprint, build_only: true)).all
|
14
14
|
end
|
15
15
|
|
16
16
|
desc "bundle", "Bundle with Lonofile."
|
@@ -25,14 +25,20 @@ module Lono
|
|
25
25
|
Clean.new(options).run
|
26
26
|
end
|
27
27
|
|
28
|
-
desc "down BLUEPRINT", "Delete
|
28
|
+
desc "down BLUEPRINT", "Delete stack"
|
29
29
|
long_desc Help.text(:down)
|
30
30
|
cfn_opts.delete
|
31
31
|
def down(blueprint)
|
32
32
|
Lono::Cfn::Delete.new(options.merge(blueprint: blueprint)).run
|
33
33
|
end
|
34
34
|
|
35
|
-
desc "
|
35
|
+
desc "iam BLUEPRINT", "Generate IAM policy"
|
36
|
+
long_desc Help.text(:down)
|
37
|
+
def iam(blueprint)
|
38
|
+
Iam.new(options.merge(blueprint: blueprint)).run
|
39
|
+
end
|
40
|
+
|
41
|
+
desc "list", "List blueprints"
|
36
42
|
long_desc Help.text(:list)
|
37
43
|
option :type, aliases: :t, desc: "Type: IE: blueprint, configset, extension. Defaults to all"
|
38
44
|
def list
|
@@ -41,12 +47,12 @@ module Lono
|
|
41
47
|
|
42
48
|
desc "output BLUEPRINT", "output or preview of the deploy"
|
43
49
|
long_desc Help.text(:output)
|
44
|
-
option :format, desc: "Output formats: #{CliFormat.formats.join(', ')}"
|
50
|
+
option :format, aliases: :f, desc: "Output formats: #{CliFormat.formats.join(', ')}"
|
45
51
|
def output(blueprint)
|
46
52
|
Lono::Cfn::Output.new(options.merge(blueprint: blueprint)).run
|
47
53
|
end
|
48
54
|
|
49
|
-
desc "plan BLUEPRINT", "
|
55
|
+
desc "plan BLUEPRINT", "Preview deploy"
|
50
56
|
long_desc Help.text(:plan)
|
51
57
|
option :out, aliases: :o, desc: "Write Change Set info to path"
|
52
58
|
def plan(blueprint)
|
@@ -57,6 +63,7 @@ module Lono
|
|
57
63
|
long_desc Help.text("seed")
|
58
64
|
option :param, desc: "override convention and specify the param file to use"
|
59
65
|
opts.runtime_options
|
66
|
+
option :where, desc: "Where to create file, you specify the top-level folder. Possible values: app, config, vendor. Defaults to config"
|
60
67
|
def seed(blueprint)
|
61
68
|
Seed.new(options.merge(blueprint: blueprint)).create
|
62
69
|
end
|
@@ -70,16 +77,13 @@ module Lono
|
|
70
77
|
desc "status BLUEPRINT", "Shows current status of blueprint."
|
71
78
|
long_desc Help.text(:status)
|
72
79
|
def status(blueprint)
|
73
|
-
|
74
|
-
status = Lono::Cfn::Status.new(names.stack, options)
|
75
|
-
success = status.run
|
76
|
-
exit 3 unless success
|
80
|
+
Status.new(options.merge(blueprint: blueprint)).run
|
77
81
|
end
|
78
82
|
|
79
83
|
desc "summary BLUEPRINT", "Prints summary of CloudFormation template"
|
80
84
|
long_desc Help.text("summary")
|
81
85
|
def summary(blueprint)
|
82
|
-
|
86
|
+
Summary.new(options.merge(blueprint: blueprint)).run
|
83
87
|
end
|
84
88
|
|
85
89
|
desc "test", "Run test."
|
@@ -88,7 +92,7 @@ module Lono
|
|
88
92
|
Test.new(options).run
|
89
93
|
end
|
90
94
|
|
91
|
-
desc "up BLUEPRINT", "Deploy
|
95
|
+
desc "up BLUEPRINT", "Deploy stack"
|
92
96
|
long_desc Help.text(:up)
|
93
97
|
cfn_opts.deploy
|
94
98
|
def up(blueprint)
|
@@ -124,10 +128,6 @@ module Lono
|
|
124
128
|
long_desc Help.text(:cfn)
|
125
129
|
subcommand "cfn", Cfn
|
126
130
|
|
127
|
-
desc "code SUBCOMMAND", "code subcommands"
|
128
|
-
long_desc Help.text(:code)
|
129
|
-
subcommand "code", Code
|
130
|
-
|
131
131
|
desc "new SUBCOMMAND", "new subcommands"
|
132
132
|
long_desc Help.text(:new)
|
133
133
|
subcommand "new", New
|
data/lib/lono/command.rb
CHANGED
@@ -37,6 +37,7 @@ module Lono
|
|
37
37
|
# Lono.argv provides consistency when lono is being called by rspec-lono test harness
|
38
38
|
Lono.argv = args.clone # important to clone since Thor removes the first argv
|
39
39
|
|
40
|
+
check_version_structure!
|
40
41
|
check_project!(args.first)
|
41
42
|
|
42
43
|
# Allow calling for help via:
|
@@ -48,7 +49,6 @@ module Lono
|
|
48
49
|
# as well thor's normal way:
|
49
50
|
#
|
50
51
|
# lono help command
|
51
|
-
help_flags = Thor::HELP_MAPPINGS + ["help"]
|
52
52
|
if args.length > 1 && !(args & help_flags).empty?
|
53
53
|
args -= help_flags
|
54
54
|
args.insert(-2, "help")
|
@@ -69,13 +69,39 @@ module Lono
|
|
69
69
|
return if subcommand?
|
70
70
|
return if command_name.nil?
|
71
71
|
return if help_flags.include?(Lono.argv.last) # IE: -h help
|
72
|
-
return if
|
72
|
+
return if non_project_command?
|
73
73
|
return if File.exist?("#{Lono.root}/config/app.rb")
|
74
74
|
return unless Lono.check_project
|
75
75
|
logger.error "ERROR: It doesnt look like this is a lono project. Are you sure you are in a lono project?".color(:red)
|
76
76
|
ENV['LONO_TEST'] ? raise : exit(1)
|
77
77
|
end
|
78
78
|
|
79
|
+
# Also, using ARGV instead of args because args is called by thor in multiple passes
|
80
|
+
# For `lono new project`:
|
81
|
+
# * 1st pass: "new"
|
82
|
+
# * 2nd pass: "project"
|
83
|
+
def non_project_command?
|
84
|
+
commands = %w[-h -v --version completion completion_script help new test version]
|
85
|
+
commands.include?(ARGV[0])
|
86
|
+
end
|
87
|
+
|
88
|
+
def check_version_structure!
|
89
|
+
return if non_project_command?
|
90
|
+
return unless File.exist?('configs')
|
91
|
+
puts "ERROR: Old lono project structure detected".color(:red)
|
92
|
+
puts <<~EOL
|
93
|
+
It looks like this Lono project with an old structure.
|
94
|
+
The old structure does not work with this version of Lono.
|
95
|
+
|
96
|
+
Current Installed Lono Version: #{Lono::VERSION}
|
97
|
+
|
98
|
+
Please upgrade the lono project structure.
|
99
|
+
|
100
|
+
See: https://lono.com/docs/upgrading/version8/
|
101
|
+
EOL
|
102
|
+
exit 1
|
103
|
+
end
|
104
|
+
|
79
105
|
def help_flags
|
80
106
|
Thor::HELP_MAPPINGS + ["help"]
|
81
107
|
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
module Lono
|
2
|
+
class Component
|
3
|
+
attr_reader :name
|
4
|
+
def initialize(options={})
|
5
|
+
@options = options
|
6
|
+
@name = options[:name]
|
7
|
+
end
|
8
|
+
|
9
|
+
def type
|
10
|
+
self.class.name.to_s.split('::').last.underscore # IE: blueprint
|
11
|
+
end
|
12
|
+
|
13
|
+
def exist?
|
14
|
+
!root.nil?
|
15
|
+
end
|
16
|
+
|
17
|
+
def type_dir
|
18
|
+
type.pluralize # IE: blueprints
|
19
|
+
end
|
20
|
+
|
21
|
+
def root
|
22
|
+
paths = Dir.glob("#{Lono.root}/{app,vendor}/#{type_dir}/*")
|
23
|
+
paths.find do |path|
|
24
|
+
found = path.sub(%r{.*/(app|vendor)/}, '')
|
25
|
+
found == "#{type_dir}/#{@name}" # exact match
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
# Dont name AwsData. Think prefer AwsInfo vs AwsConcern
|
2
|
+
module Lono::Concerns
|
3
|
+
module AwsInfo
|
4
|
+
extend Memoist
|
5
|
+
delegate :region, to: :aws_data
|
6
|
+
alias_method :aws_region, :region
|
7
|
+
alias_method :current_region, :region
|
8
|
+
|
9
|
+
def aws_data
|
10
|
+
AwsData.new
|
11
|
+
end
|
12
|
+
memoize :aws_data
|
13
|
+
end
|
14
|
+
end
|