lono 4.2.7 → 5.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.cody/README.md +6 -0
- data/.cody/acceptance.sh +30 -0
- data/.cody/buildspec.yml +21 -0
- data/.cody/demo.rb +38 -0
- data/.cody/project.rb +12 -0
- data/.cody/role.rb +1 -0
- data/.gitignore +2 -0
- data/.gitmodules +6 -3
- data/.travis.yml +7 -0
- data/CHANGELOG.md +10 -0
- data/Gemfile +0 -1
- data/LICENSE.txt +1 -22
- data/README.md +46 -55
- data/lib/lono.rb +20 -27
- data/lib/lono/app_file.rb +5 -0
- data/lib/lono/app_file/base.rb +19 -0
- data/lib/lono/app_file/build.rb +78 -0
- data/lib/lono/app_file/registry.rb +14 -0
- data/lib/lono/app_file/registry/item.rb +46 -0
- data/lib/lono/app_file/upload.rb +39 -0
- data/lib/lono/autoloader.rb +22 -0
- data/lib/lono/aws_services.rb +46 -0
- data/lib/lono/aws_services/util.rb +49 -0
- data/lib/lono/blueprint.rb +113 -0
- data/lib/lono/blueprint/find.rb +90 -0
- data/lib/lono/blueprint/helper.rb +18 -0
- data/lib/lono/blueprint/info.rb +10 -0
- data/lib/lono/blueprint/list.rb +14 -0
- data/lib/lono/blueprint/root.rb +43 -0
- data/lib/lono/cfn.rb +31 -19
- data/lib/lono/cfn/aws_service.rb +16 -0
- data/lib/lono/cfn/base.rb +244 -261
- data/lib/lono/cfn/create.rb +36 -32
- data/lib/lono/cfn/current.rb +1 -1
- data/lib/lono/cfn/delete.rb +2 -2
- data/lib/lono/cfn/deploy.rb +11 -0
- data/lib/lono/cfn/diff.rb +1 -1
- data/lib/lono/cfn/preview.rb +3 -3
- data/lib/lono/cfn/rollback.rb +26 -0
- data/lib/lono/cfn/status.rb +2 -203
- data/lib/lono/cfn/suffix.rb +67 -0
- data/lib/lono/cfn/update.rb +61 -53
- data/lib/lono/cli.rb +42 -23
- data/lib/lono/completer.rb +0 -2
- data/lib/lono/configure.rb +37 -0
- data/lib/lono/configure/aws_services.rb +18 -0
- data/lib/lono/configure/base.rb +94 -0
- data/lib/lono/configure/helpers.rb +128 -0
- data/lib/lono/conventions.rb +11 -0
- data/lib/lono/core.rb +42 -12
- data/lib/lono/core/config.rb +5 -4
- data/lib/lono/default/settings.yml +0 -11
- data/lib/lono/file_uploader.rb +9 -4
- data/lib/lono/help.rb +1 -2
- data/lib/lono/help/blueprint.md +46 -0
- data/lib/lono/help/cfn.md +5 -4
- data/lib/lono/help/cfn/create.md +14 -9
- data/lib/lono/help/cfn/deploy.md +92 -0
- data/lib/lono/help/cfn/diff.md +0 -1
- data/lib/lono/help/cfn/update.md +16 -15
- data/lib/lono/help/completion.md +3 -3
- data/lib/lono/help/generate.md +0 -1
- data/lib/lono/help/new.md +40 -34
- data/lib/lono/help/param.md +1 -1
- data/lib/lono/help/param/generate.md +1 -1
- data/lib/lono/help/template.md +2 -2
- data/lib/lono/help/xgraph.md +1 -1
- data/lib/lono/inspector.rb +1 -1
- data/lib/lono/inspector/base.rb +26 -10
- data/lib/lono/inspector/graph.rb +7 -3
- data/lib/lono/inspector/summary.rb +15 -3
- data/lib/lono/md5.rb +46 -0
- data/lib/lono/new.rb +40 -28
- data/lib/lono/new/helper.rb +2 -3
- data/lib/lono/param.rb +12 -11
- data/lib/lono/param/generator.rb +96 -42
- data/lib/lono/project_checker.rb +27 -8
- data/lib/lono/s3.rb +23 -0
- data/lib/lono/s3/bucket.rb +123 -0
- data/lib/lono/script.rb +4 -8
- data/lib/lono/script/base.rb +7 -2
- data/lib/lono/script/build.rb +7 -8
- data/lib/lono/script/upload.rb +4 -20
- data/lib/lono/sequence.rb +19 -16
- data/lib/lono/setting.rb +19 -27
- data/lib/lono/template.rb +22 -26
- data/lib/lono/template/base.rb +13 -0
- data/lib/lono/template/context.rb +4 -56
- data/lib/lono/template/context/loader.rb +70 -0
- data/lib/lono/template/dsl.rb +15 -151
- data/lib/lono/template/dsl/builder.rb +60 -0
- data/lib/lono/template/dsl/builder/base.rb +14 -0
- data/lib/lono/template/dsl/builder/condition.rb +26 -0
- data/lib/lono/template/dsl/builder/fn.rb +114 -0
- data/lib/lono/template/dsl/builder/helper.rb +64 -0
- data/lib/lono/template/dsl/builder/mapping.rb +24 -0
- data/lib/lono/template/dsl/builder/output.rb +37 -0
- data/lib/lono/template/dsl/builder/parameter.rb +39 -0
- data/lib/lono/template/dsl/builder/resource.rb +38 -0
- data/lib/lono/template/dsl/builder/section.rb +12 -0
- data/lib/lono/template/dsl/builder/syntax.rb +58 -0
- data/lib/lono/template/erb.rb +82 -0
- data/lib/lono/template/evaluate.rb +39 -0
- data/lib/lono/template/generator.rb +29 -0
- data/lib/lono/template/helper.rb +7 -29
- data/lib/lono/template/post_processor.rb +69 -0
- data/lib/lono/template/template.rb +4 -9
- data/lib/lono/template/upload.rb +103 -133
- data/lib/lono/template/util.rb +48 -0
- data/lib/lono/upgrade.rb +5 -3
- data/lib/lono/upgrade/upgrade5.rb +55 -0
- data/lib/lono/user_data.rb +4 -4
- data/lib/lono/version.rb +1 -1
- data/lib/templates/blueprint/%blueprint_name%.gemspec.tt +44 -0
- data/lib/templates/blueprint/.gitignore +14 -0
- data/lib/templates/blueprint/.lono/config.yml.tt +3 -0
- data/lib/templates/blueprint/.meta/config.yml.tt +3 -0
- data/lib/templates/blueprint/CHANGELOG.md +7 -0
- data/lib/templates/blueprint/Gemfile +4 -0
- data/lib/templates/blueprint/README.md +37 -0
- data/lib/templates/blueprint/Rakefile +6 -0
- data/lib/templates/blueprint/setup/configs.rb +54 -0
- data/lib/templates/blueprint_configs/configs/%blueprint_name%/params/base.txt +2 -0
- data/lib/{starter_projects/skeleton/app/definitions/base.rb → templates/blueprint_configs/configs/%blueprint_name%/params/development.txt} +0 -0
- data/lib/templates/blueprint_configs/configs/%blueprint_name%/variables/base.rb +2 -0
- data/lib/templates/blueprint_configs/configs/%blueprint_name%/variables/development.rb +0 -0
- data/lib/templates/blueprint_types/dsl/app/templates/%blueprint_name%.rb +37 -0
- data/lib/templates/blueprint_types/dsl/app/user_data/bootstrap.sh +2 -0
- data/lib/templates/blueprint_types/erb/app/definitions/base.rb.tt +1 -0
- data/lib/templates/blueprint_types/erb/app/templates/%blueprint_name%.yml +8 -0
- data/lib/{starter_projects/autoscaling → templates/skeleton}/.gitignore +1 -0
- data/lib/templates/skeleton/Gemfile +3 -0
- data/lib/{starter_projects/autoscaling → templates/skeleton}/Guardfile +2 -2
- data/lib/templates/skeleton/README.md +58 -0
- data/lib/templates/skeleton/configs/settings.yml +17 -0
- data/lib/templates/upgrade5/blueprints/main/.lono/config.yml +3 -0
- data/lib/templates/upgrade5/blueprints/main/.meta/config.yml +3 -0
- data/lono.gemspec +12 -8
- data/vendor/cfn-status/CHANGELOG.md +10 -0
- data/vendor/cfn-status/Gemfile +4 -0
- data/vendor/cfn-status/LICENSE.txt +21 -0
- data/vendor/cfn-status/README.md +56 -0
- data/vendor/cfn-status/Rakefile +6 -0
- data/vendor/cfn-status/bin/console +14 -0
- data/vendor/cfn-status/bin/setup +8 -0
- data/vendor/cfn-status/cfn-status.gemspec +30 -0
- data/vendor/cfn-status/lib/cfn-status.rb +1 -0
- data/vendor/cfn-status/lib/cfn/aws_service.rb +51 -0
- data/vendor/cfn-status/lib/cfn/status.rb +219 -0
- data/vendor/cfn-status/lib/cfn/status/version.rb +5 -0
- data/vendor/cfn-status/spec/cfn/status_spec.rb +81 -0
- data/vendor/cfn-status/spec/fixtures/cfn/stack-events-complete.json +1080 -0
- data/vendor/cfn-status/spec/fixtures/cfn/stack-events-in-progress.json +1080 -0
- data/vendor/cfn-status/spec/fixtures/cfn/stack-events-update-rollback-complete.json +1086 -0
- data/vendor/cfn-status/spec/spec_helper.rb +14 -0
- data/vendor/cfn_camelizer/CHANGELOG.md +20 -0
- data/vendor/cfn_camelizer/Gemfile +4 -0
- data/vendor/cfn_camelizer/LICENSE.txt +21 -0
- data/vendor/cfn_camelizer/README.md +40 -0
- data/vendor/cfn_camelizer/Rakefile +6 -0
- data/vendor/cfn_camelizer/bin/console +14 -0
- data/vendor/cfn_camelizer/bin/setup +8 -0
- data/vendor/cfn_camelizer/cfn_camelizer.gemspec +32 -0
- data/vendor/cfn_camelizer/lib/camelizer.yml +37 -0
- data/vendor/cfn_camelizer/lib/cfn_camelizer.rb +94 -0
- data/vendor/cfn_camelizer/lib/cfn_camelizer/version.rb +3 -0
- data/vendor/cfn_camelizer/spec/cfn_camelizer_spec.rb +86 -0
- data/vendor/cfn_camelizer/spec/spec_helper.rb +14 -0
- metadata +189 -62
- data/.circleci/bin/commit_docs.sh +0 -26
- data/.circleci/config.yml +0 -72
- data/bin/release +0 -9
- data/lib/lono/help/import.md +0 -54
- data/lib/lono/importer.rb +0 -134
- data/lib/lono/new/message.rb +0 -35
- data/lib/starter_projects/autoscaling/Gemfile +0 -3
- data/lib/starter_projects/autoscaling/README.md +0 -118
- data/lib/starter_projects/autoscaling/app/definitions/base.rb +0 -2
- data/lib/starter_projects/autoscaling/app/templates/autoscaling.yml +0 -682
- data/lib/starter_projects/autoscaling/config/params/base/autoscaling.txt +0 -6
- data/lib/starter_projects/autoscaling/config/settings.yml +0 -33
- data/lib/starter_projects/ec2/.gitignore +0 -2
- data/lib/starter_projects/ec2/Gemfile +0 -3
- data/lib/starter_projects/ec2/Guardfile +0 -12
- data/lib/starter_projects/ec2/README.md +0 -86
- data/lib/starter_projects/ec2/app/definitions/base.rb +0 -2
- data/lib/starter_projects/ec2/app/definitions/development.rb +0 -1
- data/lib/starter_projects/ec2/app/definitions/production.rb +0 -1
- data/lib/starter_projects/ec2/app/helpers/my_custom_helper.rb +0 -17
- data/lib/starter_projects/ec2/app/partials/user_data/bootstrap.sh +0 -4
- data/lib/starter_projects/ec2/app/templates/example.yml +0 -430
- data/lib/starter_projects/ec2/config/params/base/example.txt +0 -2
- data/lib/starter_projects/ec2/config/params/development/example.txt +0 -3
- data/lib/starter_projects/ec2/config/params/production/example.txt +0 -2
- data/lib/starter_projects/ec2/config/settings.yml +0 -33
- data/lib/starter_projects/ec2/config/variables/base.rb +0 -3
- data/lib/starter_projects/ec2/config/variables/development.rb +0 -2
- data/lib/starter_projects/ec2/config/variables/production.rb +0 -2
- data/lib/starter_projects/ec2/welcome.txt +0 -8
- data/lib/starter_projects/skeleton/.gitignore +0 -2
- data/lib/starter_projects/skeleton/Gemfile +0 -3
- data/lib/starter_projects/skeleton/Guardfile +0 -12
- data/lib/starter_projects/skeleton/README.md +0 -53
- data/lib/starter_projects/skeleton/config/settings.yml +0 -33
- data/lib/starter_projects/skeleton/welcome.txt +0 -7
- data/vendor/plissken/Gemfile +0 -14
- data/vendor/plissken/LICENSE.txt +0 -20
- data/vendor/plissken/README.md +0 -46
- data/vendor/plissken/Rakefile +0 -56
- data/vendor/plissken/VERSION +0 -1
- data/vendor/plissken/lib/plissken.rb +0 -1
- data/vendor/plissken/lib/plissken/ext/hash/to_snake_keys.rb +0 -45
- data/vendor/plissken/plissken.gemspec +0 -61
- data/vendor/plissken/spec/lib/to_snake_keys_spec.rb +0 -177
- data/vendor/plissken/spec/spec_helper.rb +0 -90
- data/vendor/plissken/test/helper.rb +0 -20
- data/vendor/plissken/test/plissken/ext/hash/to_snake_keys_test.rb +0 -184
- data/vendor/plissken/test/test_plissken.rb +0 -2
data/lib/lono/help/generate.md
CHANGED
@@ -10,7 +10,6 @@ Generates CloudFormation template, parameter files, and scripts in lono project
|
|
10
10
|
|
11
11
|
$ lono generate
|
12
12
|
Generating CloudFormation templates, parameters, and scripts
|
13
|
-
No detected app/scripts
|
14
13
|
Generating CloudFormation templates:
|
15
14
|
output/templates/ec2.yml
|
16
15
|
Generating parameter files:
|
data/lib/lono/help/new.md
CHANGED
@@ -1,54 +1,60 @@
|
|
1
1
|
## Examples
|
2
2
|
|
3
|
-
lono new infra #
|
4
|
-
TEMPLATE=ec2 lono new infra # creates a single server
|
5
|
-
TEMPLATE=autoscaling lono new infra
|
3
|
+
lono new infra # starter project with demo blueprint
|
6
4
|
|
7
5
|
By default, `lono new` generates a skeleton project. Use `TEMPLATE` to generate different starter projects. List of the [starter templates](https://github.com/tongueroo/lono/tree/master/lib/starter_projects).
|
8
6
|
|
9
7
|
## Example Output
|
10
8
|
|
11
|
-
$ lono new
|
12
|
-
=> Creating new project called
|
13
|
-
create
|
14
|
-
create
|
15
|
-
create
|
16
|
-
create
|
17
|
-
create
|
18
|
-
create
|
19
|
-
|
20
|
-
create
|
21
|
-
create
|
22
|
-
create
|
23
|
-
create
|
24
|
-
create
|
25
|
-
create
|
26
|
-
create
|
27
|
-
|
28
|
-
create
|
29
|
-
|
9
|
+
$ lono new infra
|
10
|
+
=> Creating new project called infra.
|
11
|
+
create infra
|
12
|
+
create infra/.gitignore
|
13
|
+
create infra/Gemfile
|
14
|
+
create infra/Guardfile
|
15
|
+
create infra/README.md
|
16
|
+
create infra/configs/settings.yml
|
17
|
+
=> Creating new blueprint called demo.
|
18
|
+
create infra/blueprints/demo
|
19
|
+
create infra/blueprints/demo/demo.gemspec
|
20
|
+
create infra/blueprints/demo/.gitignore
|
21
|
+
create infra/blueprints/demo/.meta/config.yml
|
22
|
+
create infra/blueprints/demo/Gemfile
|
23
|
+
create infra/blueprints/demo/README.md
|
24
|
+
create infra/blueprints/demo/setup/configs.rb
|
25
|
+
exist infra/blueprints/demo
|
26
|
+
create infra/blueprints/demo/app/templates/demo.rb
|
27
|
+
create infra/blueprints/demo/app/user_data/bootstrap.sh
|
28
|
+
exist infra/blueprints/demo/app/templates
|
29
|
+
exist infra
|
30
|
+
create infra/configs/demo/params/base.txt
|
31
|
+
create infra/configs/demo/params/development.txt
|
32
|
+
create infra/configs/demo/variables/base.rb
|
33
|
+
create infra/configs/demo/variables/development.rb
|
30
34
|
=> Initialize git repo
|
35
|
+
=> Installing dependencies with: bundle install
|
36
|
+
=> Commit git repo
|
31
37
|
================================================================
|
32
|
-
Congrats
|
38
|
+
Congrats You have successfully created a lono project. A starter demo blueprint was created
|
39
|
+
and is at blueprints/demo. Check things out by going into the created infra folder.
|
33
40
|
|
34
|
-
|
41
|
+
cd infra
|
35
42
|
|
36
|
-
|
43
|
+
To generate the blueprint templates without launching a stack, you can run:
|
37
44
|
|
38
|
-
|
45
|
+
lono generate demo
|
39
46
|
|
40
|
-
|
47
|
+
The generated files are created at `output/demo/templates` and `output/demo/params`.
|
41
48
|
|
42
|
-
|
49
|
+
To deploy the CloudFormation stack:
|
43
50
|
|
44
|
-
lono
|
51
|
+
lono cfn deploy my-demo --blueprint demo
|
45
52
|
|
46
|
-
|
53
|
+
If you name the stack according to conventions, you can simply run:
|
47
54
|
|
48
|
-
lono
|
55
|
+
lono cfn deploy demo
|
49
56
|
|
50
|
-
|
51
|
-
The generated stack parameters are in the output/params folder. Here's the command with some output filtered to focus on learning.
|
57
|
+
To list and create additional blueprints refer to https://lono.cloud/docs/core/blueprints
|
52
58
|
|
53
59
|
More info: http://lono.cloud/
|
54
|
-
$
|
60
|
+
$
|
data/lib/lono/help/param.md
CHANGED
data/lib/lono/help/template.md
CHANGED
data/lib/lono/help/xgraph.md
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
With more complex CloudFormation templates, the dependency can get difficult to follow. Visualizing the dependencies is helpful.
|
4
4
|
|
5
|
-
lono import https://s3.amazonaws.com/solutions-reference/aws-waf-security-automations/latest/aws-waf-security-automations.template --
|
5
|
+
lono import https://s3.amazonaws.com/solutions-reference/aws-waf-security-automations/latest/aws-waf-security-automations.template --blueprint waf
|
6
6
|
lono xgraph waf
|
7
7
|
|
8
8
|
This above command generates a dependency chart. The command uses the DependsOn attribute specified in each resource to figure this out. It does not show implied dependencies that CloudFormaton automatically computes for us. The chart looks like this:
|
data/lib/lono/inspector.rb
CHANGED
data/lib/lono/inspector/base.rb
CHANGED
@@ -1,23 +1,39 @@
|
|
1
1
|
class Lono::Inspector::Base
|
2
|
-
|
3
|
-
|
4
|
-
|
2
|
+
include Lono::Blueprint::Root
|
3
|
+
|
4
|
+
def initialize(blueprint, template, options)
|
5
|
+
@blueprint, @template, @options = blueprint, template, options
|
6
|
+
end
|
7
|
+
|
8
|
+
def run
|
9
|
+
blueprints = Lono::Blueprint::Find.one_or_all(@blueprint)
|
10
|
+
blueprints.each do |blueprint|
|
11
|
+
@blueprint_name = blueprint
|
12
|
+
|
13
|
+
generate_templates
|
14
|
+
set_blueprint_root(blueprint)
|
15
|
+
templates = @template ? [@template] : all_templates
|
16
|
+
templates.each do |template_name|
|
17
|
+
perform(template_name)
|
18
|
+
end
|
19
|
+
end
|
5
20
|
end
|
6
21
|
|
7
22
|
def generate_templates
|
8
|
-
Lono::Template::
|
23
|
+
Lono::Template::Generator.new(@blueprint_name, @options.clone.merge(quiet: false)).run
|
9
24
|
end
|
10
25
|
|
11
|
-
def
|
12
|
-
|
13
|
-
|
26
|
+
def all_templates
|
27
|
+
templates_path = "#{Lono.config.output_path}/#{@blueprint_name}/templates"
|
28
|
+
Dir.glob("#{templates_path}/**").map do |path|
|
29
|
+
path.sub("#{templates_path}/", '').sub('.yml','') # template_name
|
30
|
+
end
|
14
31
|
end
|
15
32
|
|
16
33
|
def data
|
17
|
-
|
18
|
-
template_path = "#{Lono.config.output_path}/templates/#{@stack_name}.yml"
|
34
|
+
template_path = "#{Lono.config.output_path}/#{@blueprint_name}/templates/#{@template_name}.yml"
|
19
35
|
check_template_exists(template_path)
|
20
|
-
|
36
|
+
YAML.load(IO.read(template_path))
|
21
37
|
end
|
22
38
|
|
23
39
|
# Check if the template exists and print friendly error message. Exits if it
|
data/lib/lono/inspector/graph.rb
CHANGED
@@ -2,13 +2,17 @@ require "yaml"
|
|
2
2
|
require "graph"
|
3
3
|
|
4
4
|
class Lono::Inspector::Graph < Lono::Inspector::Base
|
5
|
-
def initialize(
|
5
|
+
def initialize(blueprint, template, options)
|
6
6
|
super
|
7
7
|
@nodes = [] # lookup map
|
8
8
|
end
|
9
9
|
|
10
|
-
def perform
|
11
|
-
|
10
|
+
def perform(template_name)
|
11
|
+
# little dirty but @template_name is used in data method
|
12
|
+
# so we dont have to pass it to the data method
|
13
|
+
@template_name = template_name
|
14
|
+
|
15
|
+
puts "Generating dependencies tree for template #{@template_name}..."
|
12
16
|
return if @options[:noop]
|
13
17
|
|
14
18
|
# First loop through top level nodes and build set depends_on property
|
@@ -1,6 +1,10 @@
|
|
1
1
|
class Lono::Inspector::Summary < Lono::Inspector::Base
|
2
|
-
def perform
|
3
|
-
|
2
|
+
def perform(template_name)
|
3
|
+
# little dirty but @template_name is used in data method
|
4
|
+
# so we dont have to pass it to the data method
|
5
|
+
@template_name = template_name
|
6
|
+
|
7
|
+
puts "=> CloudFormation Template Summary for template #{@template_name.color(:sienna)}:"
|
4
8
|
return if @options[:noop]
|
5
9
|
|
6
10
|
print_parameters_summary
|
@@ -46,14 +50,22 @@ class Lono::Inspector::Summary < Lono::Inspector::Base
|
|
46
50
|
end
|
47
51
|
|
48
52
|
def resource_types
|
53
|
+
resources = data["Resources"]
|
54
|
+
return unless resources
|
55
|
+
|
49
56
|
types = Hash.new(0)
|
50
|
-
|
57
|
+
resources.each do |logical_id, resource|
|
51
58
|
types[resource["Type"]] += 1
|
52
59
|
end
|
53
60
|
types
|
54
61
|
end
|
55
62
|
|
56
63
|
def print_resource_types
|
64
|
+
unless resource_types
|
65
|
+
puts "No resources found."
|
66
|
+
return
|
67
|
+
end
|
68
|
+
|
57
69
|
types = resource_types.sort_by {|r| r[1] * -1} # Hash -> 2D Array
|
58
70
|
types.each do |a|
|
59
71
|
type, count = a
|
data/lib/lono/md5.rb
ADDED
@@ -0,0 +1,46 @@
|
|
1
|
+
require "digest"
|
2
|
+
|
3
|
+
# 1. md5sum the file or zipfile - shared
|
4
|
+
# 2. add prefix and md5sum - shared, lets break out prefix adding logic to elsewhere
|
5
|
+
|
6
|
+
# Using md5sum on the zipped file will an always changing value since the timestamp and other metadata of the zipfile
|
7
|
+
# changes whenever we create it.
|
8
|
+
#
|
9
|
+
# This is custom checksum logic that only accounts for the contents of the files in the directory.
|
10
|
+
module Lono
|
11
|
+
class Md5
|
12
|
+
class << self
|
13
|
+
extend Memoist
|
14
|
+
|
15
|
+
# This checksum within the file name is to mainly make sure that Lambda::Function resources "change" and an update is triggered.
|
16
|
+
# There's another checksum in the upload code that makes sure we don't upload the code again to speed up things.
|
17
|
+
def sum(path)
|
18
|
+
files = Dir["#{path}/**/*"]
|
19
|
+
files = files.reject { |f| File.directory?(f) }
|
20
|
+
.reject { |f| File.symlink?(f) }
|
21
|
+
files.sort!
|
22
|
+
content = files.map do |f|
|
23
|
+
Digest::MD5.file(f).to_s[0..7]
|
24
|
+
end.join
|
25
|
+
|
26
|
+
md5 = Digest::MD5.new
|
27
|
+
md5.update(content)
|
28
|
+
md5.hexdigest.to_s[0..7]
|
29
|
+
end
|
30
|
+
memoize :sum
|
31
|
+
|
32
|
+
def name(path)
|
33
|
+
relative_path = name_without_md5(path)
|
34
|
+
relative_path = relative_path.sub(/\.(\w+)$/,'') # strip extension
|
35
|
+
ext = File.directory?(path) ? "zip" : $1
|
36
|
+
md5 = sum(path)
|
37
|
+
"#{relative_path}-#{md5}.#{ext}"
|
38
|
+
end
|
39
|
+
|
40
|
+
def name_without_md5(path)
|
41
|
+
regexp = %r{.*/output/[\w_-]+/files/}
|
42
|
+
path.sub(regexp, '') # relative_path w/o md5
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
data/lib/lono/new.rb
CHANGED
@@ -1,9 +1,6 @@
|
|
1
1
|
module Lono
|
2
2
|
class New < Sequence
|
3
|
-
autoload :Helper, 'lono/new/helper'
|
4
|
-
autoload :Message, 'lono/new/message'
|
5
3
|
include Helper
|
6
|
-
include Message
|
7
4
|
|
8
5
|
argument :project_name
|
9
6
|
|
@@ -13,19 +10,20 @@ module Lono
|
|
13
10
|
# Also options from the cli can be pass through to here
|
14
11
|
def self.cli_options
|
15
12
|
[
|
16
|
-
[:force, type: :boolean, desc: "Bypass overwrite are you sure prompt for existing files."],
|
17
13
|
[:bundle, type: :boolean, default: true, desc: "Runs bundle install on the project"],
|
14
|
+
[:force, type: :boolean, desc: "Bypass overwrite are you sure prompt for existing files."],
|
18
15
|
[:git, type: :boolean, default: true, desc: "Git initialize the project"],
|
16
|
+
[:type, default: "dsl", desc: "Blueprint type: dsl or erb"],
|
19
17
|
]
|
20
18
|
end
|
21
19
|
|
22
20
|
cli_options.each do |args|
|
23
|
-
class_option
|
21
|
+
class_option(*args)
|
24
22
|
end
|
25
23
|
|
26
24
|
# for specs
|
27
25
|
def set_cwd
|
28
|
-
@cwd =
|
26
|
+
@cwd = Dir.pwd
|
29
27
|
end
|
30
28
|
|
31
29
|
def create_project
|
@@ -33,17 +31,9 @@ module Lono
|
|
33
31
|
directory ".", "#{@cwd}/#{project_name}"
|
34
32
|
end
|
35
33
|
|
36
|
-
def
|
37
|
-
|
38
|
-
|
39
|
-
path = "#{@cwd}/#{project_name}/#{Lono.config.send(meth)}"
|
40
|
-
next if File.exist?(path)
|
41
|
-
if ENV['TEST']
|
42
|
-
empty_directory Lono.config.send(meth)
|
43
|
-
else
|
44
|
-
empty_directory path
|
45
|
-
end
|
46
|
-
end
|
34
|
+
def create_starter_blueprint
|
35
|
+
# https://github.com/erikhuda/thor/wiki/Invocations
|
36
|
+
Lono::Blueprint.start(["demo", "--from-new", "--type", @options[:type], "--project-name", project_name])
|
47
37
|
end
|
48
38
|
|
49
39
|
# After this commands are executed with the newly created project
|
@@ -57,6 +47,11 @@ module Lono
|
|
57
47
|
chmod("exe", 0755 & ~File.umask, verbose: false) if File.exist?("exe")
|
58
48
|
end
|
59
49
|
|
50
|
+
def git_init
|
51
|
+
return if File.exist?(".git") # this is a clone repo
|
52
|
+
run_git_init
|
53
|
+
end
|
54
|
+
|
60
55
|
def bundle_install
|
61
56
|
return unless options[:bundle]
|
62
57
|
|
@@ -66,19 +61,36 @@ module Lono
|
|
66
61
|
end
|
67
62
|
end
|
68
63
|
|
69
|
-
def
|
70
|
-
|
71
|
-
return unless git_installed?
|
72
|
-
return if File.exist?(".git") # this is a clone repo
|
73
|
-
|
74
|
-
puts "=> Initialize git repo"
|
75
|
-
run("git init")
|
76
|
-
run("git add .")
|
77
|
-
run("git commit -m 'first commit'")
|
64
|
+
def git_commit
|
65
|
+
run_git_commit
|
78
66
|
end
|
79
67
|
|
80
|
-
def
|
81
|
-
puts
|
68
|
+
def welcome_message
|
69
|
+
puts <<~EOL
|
70
|
+
#{"="*64}
|
71
|
+
Congrats 🎉 You have successfully created a lono project. A starter demo blueprint was created
|
72
|
+
and is at blueprints/demo. Check things out by going into the created infra folder.
|
73
|
+
|
74
|
+
cd #{project_name}
|
75
|
+
|
76
|
+
To generate the blueprint templates without launching a stack, you can run:
|
77
|
+
|
78
|
+
lono generate demo
|
79
|
+
|
80
|
+
The generated files are created at `output/demo/templates` and `output/demo/params`.
|
81
|
+
|
82
|
+
To deploy the CloudFormation stack:
|
83
|
+
|
84
|
+
lono cfn deploy my-demo --blueprint demo
|
85
|
+
|
86
|
+
If you name the stack according to conventions, you can simply run:
|
87
|
+
|
88
|
+
lono cfn deploy demo
|
89
|
+
|
90
|
+
To list and create additional blueprints refer to https://lono.cloud/docs/core/blueprints
|
91
|
+
|
92
|
+
More info: http://lono.cloud/
|
93
|
+
EOL
|
82
94
|
end
|
83
95
|
end
|
84
96
|
end
|
data/lib/lono/new/helper.rb
CHANGED
@@ -4,9 +4,8 @@ module Lono::New::Helper
|
|
4
4
|
project_name.underscore.camelize
|
5
5
|
end
|
6
6
|
|
7
|
-
# Files should be named with underscores instead of dashes even
|
8
|
-
#
|
9
|
-
# works will underscores in the filenames only.
|
7
|
+
# Files should be named with underscores instead of dashes even though project name can contain a dash.
|
8
|
+
# This is because autoloading works with underscores in the filenames only.
|
10
9
|
def underscored_name
|
11
10
|
project_name.underscore
|
12
11
|
end
|
data/lib/lono/param.rb
CHANGED
@@ -1,16 +1,17 @@
|
|
1
1
|
require "thor"
|
2
2
|
|
3
|
-
|
4
|
-
|
3
|
+
module Lono
|
4
|
+
class Param < Lono::Command
|
5
|
+
class_option :verbose, type: :boolean
|
6
|
+
class_option :noop, type: :boolean
|
7
|
+
class_option :mute, type: :boolean
|
5
8
|
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
def generate
|
14
|
-
Generator.generate_all(options)
|
9
|
+
desc "generate", "Generate all parameter files to `output/params`."
|
10
|
+
long_desc Lono::Help.text("param/generate")
|
11
|
+
def generate(blueprint=nil)
|
12
|
+
Blueprint::Find.one_or_all(blueprint).each do |b|
|
13
|
+
Generator.new(b, options).generate
|
14
|
+
end
|
15
|
+
end
|
15
16
|
end
|
16
17
|
end
|