lono 8.0.0.pre.rc3 → 8.0.0.pre.rc4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (93) hide show
  1. checksums.yaml +4 -4
  2. data/.github/ISSUE_TEMPLATE/bug_report.md +84 -0
  3. data/.github/ISSUE_TEMPLATE/documentation.md +12 -0
  4. data/.github/ISSUE_TEMPLATE/feature_request.md +64 -0
  5. data/.github/ISSUE_TEMPLATE/question.md +14 -0
  6. data/.github/ISSUE_TEMPLATE.md +7 -0
  7. data/.github/PULL_REQUEST_TEMPLATE.md +50 -0
  8. data/CHANGELOG.md +33 -0
  9. data/lib/lono/app.rb +37 -3
  10. data/lib/lono/builder/allow.rb +1 -1
  11. data/lib/lono/builder/configset/definition/context.rb +50 -9
  12. data/lib/lono/builder/configset/definition/dsl/syntax/content.rb +3 -7
  13. data/lib/lono/builder/context.rb +1 -1
  14. data/lib/lono/builder/dsl/finalizer/files/build.rb +4 -12
  15. data/lib/lono/builder/dsl/finalizer/files/replace.rb +6 -1
  16. data/lib/lono/builder/dsl/helpers/files.rb +2 -2
  17. data/lib/lono/builder/dsl/helpers/s3.rb +5 -7
  18. data/lib/lono/builder/dsl/helpers/stack.rb +2 -4
  19. data/lib/lono/builder/dsl/helpers/template_file.rb +2 -2
  20. data/lib/lono/builder/dsl/syntax/core/squeezer.rb +3 -1
  21. data/lib/lono/builder/dsl/syntax/fn.rb +0 -2
  22. data/lib/lono/builder/dsl.rb +1 -1
  23. data/lib/lono/builder/param.rb +1 -1
  24. data/lib/lono/builder/template.rb +1 -3
  25. data/lib/lono/builder.rb +39 -0
  26. data/lib/lono/bundler/util/git.rb +18 -16
  27. data/lib/lono/cfn/base.rb +2 -2
  28. data/lib/lono/cfn/concerns/build.rb +1 -1
  29. data/lib/lono/cfn/delete.rb +5 -2
  30. data/lib/lono/cfn/deploy/rollback.rb +1 -3
  31. data/lib/lono/cfn/deploy.rb +16 -4
  32. data/lib/lono/cfn/plan/changeset.rb +1 -1
  33. data/lib/lono/cli/base.rb +1 -0
  34. data/lib/lono/cli/help/new/helper.md +27 -0
  35. data/lib/lono/cli/help/new/hook.md +14 -0
  36. data/lib/lono/cli/help/new/project.md +3 -10
  37. data/lib/lono/cli/iam.rb +27 -0
  38. data/lib/lono/cli/new/blueprint.rb +2 -4
  39. data/lib/lono/cli/new/helper.rb +35 -8
  40. data/lib/lono/cli/new/hook.rb +32 -0
  41. data/lib/lono/cli/new.rb +8 -4
  42. data/lib/lono/cli/script/build.rb +0 -5
  43. data/lib/lono/{inspector → cli}/summary.rb +23 -30
  44. data/lib/lono/cli.rb +9 -7
  45. data/lib/lono/command.rb +28 -1
  46. data/lib/lono/core.rb +10 -0
  47. data/lib/lono/{utils → files/builder/lambda_layer}/rsync.rb +3 -5
  48. data/lib/lono/files/builder/lambda_layer/ruby_packager.rb +178 -0
  49. data/lib/lono/files/builder/lambda_layer/ruby_version.rb +38 -0
  50. data/lib/lono/files/builder/lambda_layer.rb +17 -0
  51. data/lib/lono/files/concerns/post_processing.rb +19 -2
  52. data/lib/lono/files/concerns/registration.rb +4 -1
  53. data/lib/lono/files.rb +6 -2
  54. data/lib/lono/hooks/builder.rb +50 -0
  55. data/lib/lono/hooks/concern.rb +9 -0
  56. data/lib/lono/hooks/dsl.rb +20 -0
  57. data/lib/lono/hooks/runner.rb +46 -0
  58. data/lib/lono/layering/layer.rb +63 -41
  59. data/lib/lono/names.rb +6 -9
  60. data/lib/lono/s3/bucket.rb +17 -11
  61. data/lib/lono/s3/uploader.rb +4 -0
  62. data/lib/lono/script/build.rb +0 -5
  63. data/lib/lono/seeder.rb +1 -1
  64. data/lib/lono/utils/sh.rb +32 -0
  65. data/lib/lono/utils.rb +5 -0
  66. data/lib/lono/version.rb +1 -1
  67. data/lib/templates/hook/config/hooks.rb.tt +14 -0
  68. data/lono.gemspec +1 -1
  69. metadata +27 -30
  70. data/lib/lono/builder/template/post_processor.rb +0 -67
  71. data/lib/lono/cli/build.rb +0 -47
  72. data/lib/lono/cli/code.rb +0 -22
  73. data/lib/lono/cli/help/blueprint/new.md +0 -56
  74. data/lib/lono/cli/help/new/helper/blueprint.md +0 -17
  75. data/lib/lono/cli/help/new/helper/project.md +0 -16
  76. data/lib/lono/cli/new/extension.rb +0 -57
  77. data/lib/lono/cli/new/helper/blueprint.rb +0 -26
  78. data/lib/lono/cli/new/helper/project.rb +0 -24
  79. data/lib/lono/importer/base.rb +0 -48
  80. data/lib/lono/importer/converter.rb +0 -19
  81. data/lib/lono/importer/download.rb +0 -46
  82. data/lib/lono/importer/dsl.rb +0 -36
  83. data/lib/lono/importer/params.rb +0 -56
  84. data/lib/lono/importer/service/coder.rb +0 -85
  85. data/lib/lono/inspector/base.rb +0 -32
  86. data/lib/templates/extension/lib/%extension_name%/autoloader.rb.tt +0 -23
  87. data/lib/templates/extension/lib/%extension_name%/helpers/mappings.rb.tt +0 -24
  88. data/lib/templates/extension/lib/%extension_name%/helpers/outputs.rb.tt +0 -7
  89. data/lib/templates/extension/lib/%extension_name%/helpers/parameters.rb.tt +0 -10
  90. data/lib/templates/extension/lib/%extension_name%/helpers/resources/resource.rb.tt +0 -4
  91. data/lib/templates/extension/lib/%extension_name%/helpers/variables.rb.tt +0 -6
  92. data/lib/templates/extension/lib/%extension_name%/version.rb.tt +0 -3
  93. data/lib/templates/extension/lib/%extension_name%.rb.tt +0 -8
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 99ed66c36726e513ebe394291384f039d6dbbc7beef5a376b28b3b84121f1a42
4
- data.tar.gz: ec1902278f840c29539d54fffa9167565a27f1837a4ee2795d8db86badf0030d
3
+ metadata.gz: 963246c282376afe61a61f60ad1ec0ccb17ee194420d972802868f8574fbc97a
4
+ data.tar.gz: 3e8b4c478d5ee57744ff05ad45023592dffab08825a5af2e044a8656680b0512
5
5
  SHA512:
6
- metadata.gz: 522056fb098c360c2ad59d99dfabaa723aeec157ca5012938c36efcb130e1bf6c2974d158e3c2f864e258c5d4b065d8e949667291f6af7d779bad91d2b451a0f
7
- data.tar.gz: 18d17bbf1fcdd0f9d7c59f87b83e463f277958fb34cfb07d5918904b76ae44ecd2995f7e36f09d0a99c15d01070b469abf44bcfc95ec8f413aa54fdb0058fc6c
6
+ metadata.gz: f8ea0aa2e31ea1dad60b69d7993ef1b6eb9781c1ee0d04770ed2a1eb0fec9387703e79b95faf1a04918685d147ff884a7f712420891dbb50f9091bdf3439fa9b
7
+ data.tar.gz: f73dd80095b287c9be478a68c4de4181fdd0657153d69dc0c72145497555a7c542096e8bd0fb5b85877589251d878cd2dee7cace277614917dcab383991de30f
@@ -0,0 +1,84 @@
1
+ ---
2
+ name: Reproducible Bug Report
3
+ about: Is something not working as expected?
4
+ title: ''
5
+ labels: 'bug'
6
+ assignees: ''
7
+
8
+ ---
9
+
10
+ <!--
11
+ Hi! Thanks for considering to file a bug with Lono. Please take the time to
12
+ answer the basic questions. Please try to be as detailed as possible.
13
+ To be sensitive to everyone's time, if not enough details are provided, the
14
+ issue may be closed without comment. If you repeatedly fail to provide enough
15
+ details, you may be blocked from ever submitting issues to Lono again.
16
+ Please use your best judgment. 👍
17
+
18
+ If you are unsure this is a bug in Lono, please consider asking your question at:
19
+ https://community.boltops.com
20
+
21
+ Thanks!
22
+ -->
23
+
24
+ ## Checklist
25
+
26
+ <!--
27
+ Make sure that you've done all of these. To mark a checkbox done, replace [ ] with [x]. Or after you create the issue you can click the checkbox.
28
+ -->
29
+
30
+ - [ ] Upgrade Lono: Are you using the latest version of Lono? This allows Lono to fix issues fast. There's an Upgrading Guide: https://lono.cloud/docs/upgrading/
31
+ - [ ] Reproducibility: Are you reporting a bug others will be able to reproduce and not asking a question. If you're unsure or want to ask a question, do so on https://community.boltops.com
32
+ - [ ] Code sample: Have you put together a code sample to reproduce the issue and make it available? Code samples help speed up fixes dramatically. If it's an easily reproducible issue, then code samples are not needed. If you're unsure, please include a code sample.
33
+
34
+ ## My Environment
35
+
36
+ <!-- Please fill out the table below with debugging info to help: -->
37
+
38
+ | Software | Version |
39
+ | ---------------- | ------- |
40
+ | Operating System | |
41
+ | Lono | |
42
+ | Ruby | |
43
+
44
+ ---
45
+
46
+ ## Expected Behaviour
47
+
48
+ <!--
49
+ What is it you expected to happen? This should be a description of how the functionality you tried to use is supposed to work. Try to keep this to one-paragraph.
50
+ -->
51
+
52
+ ## Current Behavior
53
+
54
+ <!--
55
+ Describe the details of the bug. Try to keep this to one-paragraph.
56
+ -->
57
+
58
+ ## Step-by-step reproduction instructions
59
+
60
+ <!--
61
+ Be sure to include any steps you took for the problem to exist. This is likely the longest part of the report.
62
+
63
+ Please include any logs you think relevant here. If the logs are long (more than 50 lines) please make a gist of the logs and link to it. https://gist.github.com
64
+
65
+ With long logs, you can also use the <details> tag to keep the report readable. Example:
66
+
67
+ <details>
68
+ <summary>Summary Goes Here</summary>
69
+
70
+ ...this is hidden, collapsable content. start with a blank line to get terminal output to format right...
71
+ </details>
72
+ -->
73
+
74
+ ## Code Sample
75
+
76
+ <!--
77
+ Please provide a code repository, gist, code snippet or sample files to reproduce the issue.
78
+ -->
79
+
80
+ ## Solution Suggestion
81
+
82
+ <!--
83
+ Please provide possible solutions. If you can't think of anything, feel free to omit. Please be kind and add helpful possible solutions. For example, "Fix it!" is not a helpful solution suggestion. We are mere mortals. Please be constructive.
84
+ -->
@@ -0,0 +1,12 @@
1
+ ---
2
+ name: Documentation
3
+ about: Found a typo or something that isn't crystal clear in the docs?
4
+ title: ''
5
+ labels: docs
6
+ assignees: ''
7
+
8
+ ---
9
+
10
+ The Lono Docs are in the [lono-docs repo](https://github.com/boltops-tools/lono-docs). Please submit a PR there. Thanks!
11
+
12
+ For documentation changes to the lono code base itself, like code comments. Please submit a PR here. Thanks!
@@ -0,0 +1,64 @@
1
+ ---
2
+ name: New Feature Suggestion
3
+ about: Want to add a feature to Lono?
4
+ title: ''
5
+ labels: feature
6
+ assignees: ''
7
+
8
+ ---
9
+
10
+ <!--
11
+ Hi! Thanks for considering to file a feature request with Lono. Please take the time to answer the basic questions. Please try to be as detailed as possible.
12
+
13
+ Thanks!
14
+ -->
15
+
16
+ ## Summary
17
+
18
+ <!--
19
+ A one-paragraph explanation of the feature.
20
+ -->
21
+
22
+ ## Motivation
23
+
24
+ <!--
25
+ Why do you want to see this feature in Lono? What use cases does it support?
26
+
27
+ How the feature would be relevant to 80% or more of Lono users.
28
+ -->
29
+
30
+ ## Guide-level explanation
31
+
32
+ <!--
33
+ Explain the proposal as if it was already included in the project and you were teaching it to another programmer. That generally means:
34
+
35
+ - Introducing new named concepts.
36
+ - Explaining the feature largely in terms of examples.
37
+ - If applicable, provide sample error messages, deprecation warnings, or upgrade guidance.
38
+
39
+ If this is a small feature, you may omit this section.
40
+ -->
41
+
42
+ ## Reference-level explanation
43
+
44
+ <!--
45
+ This is the technical portion of the feature request. Explain the design in sufficient detail that:
46
+
47
+ - Its interaction with other features is clear.
48
+ - It is reasonably clear how the feature would be implemented.
49
+ - Corner cases are dissected by example.
50
+
51
+ If you do not know how to answer this, you can omit it. No worries!
52
+ -->
53
+
54
+ ## Drawbacks
55
+
56
+ <!--
57
+ Why should we *not* do this?
58
+ -->
59
+
60
+ ## Unresolved Questions
61
+
62
+ <!--
63
+ What related issues do you consider out of scope for this feature that could be addressed in the future independently of the solution that comes out of this feature?
64
+ -->
@@ -0,0 +1,14 @@
1
+ ---
2
+ name: Question
3
+ about: Have any questions about how Lono works?
4
+ title: ''
5
+ labels: 'question'
6
+ assignees: ''
7
+
8
+ ---
9
+
10
+ The Lono issue tracker IS NOT for usage questions! Please post your question on our dedicated forum at https://community.boltops.com
11
+
12
+ To be sensitive to everyone's time, we may close issues asking questions without comment. If you repeatedly post questions in the issues tracker, you may be blocked from ever submitting issues to Lono again. Please use your best judgment. 👍
13
+
14
+ Posting your questions in the Lono community forum benefits others by grouping questions in a dedicated place. Here are some additional options also https://lono.cloud/support/ 😁
@@ -0,0 +1,7 @@
1
+ Please fill out one of the templates on https://github.com/boltops-tools/lono/issues/new/choose
2
+
3
+ If you want to ask a question please do so in the Lono category in the BoltOps Community forum: https://community.boltops.com
4
+
5
+ To be sensitive to everyone's time, we may close issues asking questions without comment. Posting your questions in the Lono community forum is the best place. It also benefits others by making the questions easier to find. Here are some additional options also https://lono.cloud/support/ 👌
6
+
7
+ Thank you!
@@ -0,0 +1,50 @@
1
+ <!--
2
+ Thanks for creating a Pull Request! Before you submit, please make sure you've done the following:
3
+
4
+ - I read the contributing document at https://lono.cloud/docs/contributing/
5
+ -->
6
+
7
+ <!--
8
+ Make our lives easier! Choose one of the following by uncommenting it:
9
+ -->
10
+
11
+ <!-- This is a 🐞 bug fix. -->
12
+ <!-- This is a 🙋‍♂️ feature or enhancement. -->
13
+ <!-- This is a 🧐 documentation change. -->
14
+
15
+ <!--
16
+ Before you submit this pull request, make sure to have a look at the following checklist. To mark a checkbox done, replace [ ] with [x]. Or after you create the issue you can click the checkbox.
17
+
18
+ If you don't know how to do some of these, that's fine! Submit your pull request and we will help you out on the way.
19
+ -->
20
+
21
+ - [ ] I've added tests (if it's a bug, feature or enhancement)
22
+ - [ ] I've adjusted the documentation (if it's a feature or enhancement)
23
+ - [ ] The test suite passes (run `bundle exec rspec` to verify this)
24
+
25
+ ## Summary
26
+
27
+ <!--
28
+ Provide a description of what your pull request changes.
29
+ -->
30
+
31
+ ## Context
32
+
33
+ <!--
34
+ Is this related to any GitHub issue(s) or another relevant link?
35
+ -->
36
+
37
+ ## How to Test
38
+
39
+ <!--
40
+ Please provide instructions on how to test the fix. This speeds up reviewing the PR. If testing requires a demo Lono project, please provide an example repo.
41
+ -->
42
+
43
+
44
+ ## Version Changes
45
+
46
+ <!--
47
+ Which semantic version change would you recommend?
48
+ If you don't know, feel free to omit it.
49
+ -->
50
+
data/CHANGELOG.md CHANGED
@@ -1,5 +1,38 @@
1
1
  # Change Log
2
2
 
3
+ ## [8.0.0.rc4] - 2022-03-19
4
+
5
+ Notable:
6
+
7
+ * lono app and role concept
8
+ * extra layering support
9
+ * hooks support: project and blueprint level
10
+
11
+ Misc:
12
+
13
+ * add lono bucket output
14
+ * alias blueprint with -b
15
+ * change params extension to .env
16
+ * config.hooks.show = true default
17
+ * config.layering.show = true option
18
+ * extra layering support
19
+ * github templates
20
+ * improve simplier new helper cli interface
21
+ * improve squeezer: edge case Array with nil elements
22
+ * hooks generator
23
+ * lambda layer
24
+ * layering full mode default
25
+ * lazy create lono stack and lono bucket
26
+ * lono extra support
27
+ * lono iam
28
+ * lono summary
29
+ * lono up: edge case fix continue after rollback
30
+ * parse_for_layering_show
31
+ * remove extensions and add new hook generator
32
+ * show configset layering
33
+ * update dsl_evaluator dependency to at least 0.3.0
34
+ * version structure check
35
+
3
36
  ## [8.0.0.rc3] - 2022-03-06
4
37
 
5
38
  * lono files support for lambda functions
data/lib/lono/app.rb CHANGED
@@ -20,8 +20,13 @@ module Lono
20
20
  config.deny.envs = nil
21
21
  config.deny.regions = nil
22
22
 
23
+ config.hooks = ActiveSupport::OrderedOptions.new
24
+ config.hooks.show = true
25
+
23
26
  config.layering = ActiveSupport::OrderedOptions.new
24
27
  config.layering.names = {}
28
+ config.layering.mode = "full" # simple or fulll. simple does not include region, account, and region/account layers
29
+ config.layering.show = show_layers?
25
30
 
26
31
  config.log = ActiveSupport::OrderedOptions.new
27
32
  config.log.root = Lono.log_root
@@ -31,9 +36,7 @@ module Lono
31
36
 
32
37
  config.names = ActiveSupport::OrderedOptions.new
33
38
  config.names.output = ActiveSupport::OrderedOptions.new
34
- config.names.output.expand = true
35
- config.names.output.stack = ":BLUEPRINT-:ENV" # does not include APP by default. Think this is more common
36
- config.names.stack = ":APP-:BLUEPRINT-:ENV"
39
+ config.names.stack = ":APP-:ROLE-:BLUEPRINT-:ENV-:EXTRA"
37
40
 
38
41
  config.plan = ActiveSupport::OrderedOptions.new
39
42
  config.plan.changeset = true
@@ -55,6 +58,37 @@ module Lono
55
58
  config
56
59
  end
57
60
 
61
+ def show_layers?
62
+ ENV['LONO_SHOW_LAYERS'] || parse_for_layering_show
63
+ end
64
+ private :show_layers?
65
+
66
+ # Some limitations:
67
+ #
68
+ # * Only parsing one file: .ufo/config.rb
69
+ # * If user is using Ruby code that cannot be parse will fallback to default
70
+ #
71
+ # Think it's worth it so user only has to configure
72
+ #
73
+ # config.layering.show = true
74
+ #
75
+ def parse_for_layering_show
76
+ return false if Lono::Command.non_project_command?
77
+ lines = IO.readlines("#{Lono.root}/config/app.rb")
78
+ config_line = lines.find { |l| l =~ /config\.layering.show.*=/ && l !~ /^\s+#/ }
79
+ return false unless config_line # default is false
80
+ config_value = config_line.gsub(/.*=/,'').strip.gsub(/["']/,'')
81
+ config_value != "false" && config_value != "nil"
82
+ rescue Exception => e
83
+ if ENV['LONO_DEBUG']
84
+ puts "#{e.class} #{e.message}".color(:yellow)
85
+ puts "WARN: Unable to parse for config.layering.show".color(:yellow)
86
+ puts "Using default: config.layering.show = false"
87
+ end
88
+ false
89
+ end
90
+ memoize :parse_for_layering_show
91
+
58
92
  def lono_logger
59
93
  Logger.new(ENV['LONO_LOG_PATH'] || $stderr)
60
94
  end
@@ -1,4 +1,4 @@
1
- module Lono::Builder
1
+ class Lono::Builder
2
2
  class Allow < Lono::CLI::Base
3
3
  def check!
4
4
  Env.new(@options).check!
@@ -8,18 +8,59 @@ class Lono::Builder::Configset::Definition
8
8
  end
9
9
 
10
10
  # Docs: https://lono.cloud/docs/configsets/layering/
11
- # Layering is simple enough to keep in this method.
11
+ # Think layering is simple enough to keep in this method for now.
12
+ # Consider trying to combine with Lono::Layering::Layer for uniformity though.
12
13
  def load_vars
13
- logger.debug "Layers for configset #{@configset.name}:"
14
- evaluate_layer("#{@configset.root}/vars.rb") # source defaults
15
- evaluate_layer("#{Lono.root}/config/configsets/#{@configset.name}/vars.rb") # source overrides
16
- evaluate_layer("#{@blueprint.root}/config/configsets/vars/#{@configset.name}.rb") # blueprint overrides
17
- evaluate_layer("#{Lono.root}/config/blueprints/#{@blueprint.name}/configsets/vars/#{@configset.name}.rb") # user overrides
14
+ layers.each do |layer|
15
+ evaluate_file(layer)
16
+ end
18
17
  end
19
18
 
20
- def evaluate_layer(path)
21
- logger.debug " #{pretty_path(path)}" if File.exist?(path) || ENV['LONO_SHOW_ALL_LAYERS']
22
- evaluate_file(path)
19
+ def layers
20
+ paths = [
21
+ "#{@configset.root}/vars.rb", # source defaults
22
+ "#{Lono.root}/config/configsets/#{@configset.name}/vars.rb", # source overrides
23
+ "#{@blueprint.root}/config/configsets/vars/#{@configset.name}.rb", # blueprint overrides
24
+ "#{Lono.root}/config/blueprints/#{@blueprint.name}/configsets/vars/#{@configset.name}.rb", # user overrides
25
+ ]
26
+ show_layers(paths)
27
+ paths
28
+ end
29
+
30
+ def show_layers(paths)
31
+ if ENV['LONO_LAYERS_ALL']
32
+ show_all_layers(paths)
33
+ else
34
+ show_existing_layers(paths)
35
+ end
36
+ end
37
+
38
+ def show_all_layers(paths)
39
+ show_header
40
+ paths.each do |path|
41
+ show_layer(path)
42
+ end
43
+ end
44
+
45
+ def show_existing_layers(paths)
46
+ existing = paths.select { |path| File.exist?(path) }
47
+ return if existing.empty?
48
+ show_header
49
+ existing.each do |path|
50
+ show_layer(path)
51
+ end
52
+ end
53
+
54
+ def show_header
55
+ logger.info " Configset Layers #{@configset.name}"
56
+ end
57
+
58
+ def show_layer(path)
59
+ logger.info " #{pretty_path(path)}"
60
+ end
61
+
62
+ def show_layers?
63
+ Lono.config.layering.show || ENV['LONO_LAYERS']
23
64
  end
24
65
 
25
66
  def load_helpers
@@ -1,7 +1,7 @@
1
1
  module Lono::Builder::Configset::Definition::Dsl::Syntax
2
2
  module Content
3
3
  def content_file(path)
4
- content_path = "#{file_root}/content"
4
+ content_path = "#{content_file_root}/content"
5
5
  file = "#{content_path}/#{path}"
6
6
  if File.exist?(file)
7
7
  IO.read(file)
@@ -10,17 +10,13 @@ module Lono::Builder::Configset::Definition::Dsl::Syntax
10
10
  end
11
11
  end
12
12
 
13
- def file_root
13
+ private
14
+ def content_file_root
14
15
  if @configset
15
16
  @configset.root
16
17
  else
17
18
  @blueprint.root
18
19
  end
19
20
  end
20
-
21
- def s3_key(name)
22
- Lono::Configset::S3File::Registry.register(name, blueprint: @blueprint, configset: @configset, root: @root)
23
- "file://configset/#{@configset}/#{name}"
24
- end
25
21
  end
26
22
  end
@@ -1,4 +1,4 @@
1
- module Lono::Builder
1
+ class Lono::Builder
2
2
  module Context
3
3
  include DslEvaluator
4
4
 
@@ -11,27 +11,19 @@ class Lono::Builder::Dsl::Finalizer::Files
11
11
  clean
12
12
  validate!
13
13
  build_files
14
- # build_layers
15
14
  end
16
15
 
17
16
  def build_files
18
17
  Lono::Files.files.each do |file| # using singular file, but is like a "file_list"
19
18
  file.build
19
+ file.build_lambda_layer(@cfn)
20
20
  file.compress
21
- # Note: Uploading files happen right before create_stack or execute_change_set
22
- # after user confirms action, instead of part of the build process
21
+ # UploadNote: Instead of part of the build process here, uploading happen as part
22
+ # of create_stack or execute_change_set after user confirms action. IE:
23
+ # Cfn::Deploy#create and Cfn::Deploy#update
23
24
  end
24
25
  end
25
26
 
26
- # TODO: LambdaLayer support
27
- # def build_layers
28
- # layer_items = Registry.layers
29
- # layer_items.each do |item|
30
- # LambdaLayer.new(@blueprint, item).build
31
- # end
32
- # end
33
- #
34
-
35
27
  def clean
36
28
  FileUtils.rm_rf(@output_path)
37
29
  end
@@ -8,9 +8,14 @@ class Lono::Builder::Dsl::Finalizer::Files
8
8
  end
9
9
 
10
10
  def replacements
11
- Lono::Files.files.inject({}) do |result, file|
11
+ data = Lono::Files.files.inject({}) do |result, file|
12
12
  result.merge(file.marker => file.s3_key)
13
13
  end
14
+ # Edge case when bucket is created for the first time and files_bucket is
15
+ # not available yet. So we call it at this point.
16
+ Lono::S3::Bucket.ensure_exist
17
+ data["LONO://S3_BUCKET"] = Lono::S3::Bucket.name
18
+ data
14
19
  end
15
20
 
16
21
  def update_template!(hash)
@@ -1,7 +1,7 @@
1
1
  module Lono::Builder::Dsl::Helpers
2
2
  module Files
3
- def files(path)
4
- Lono::Files.register(@options.merge(path: path))
3
+ def files(path, o={})
4
+ Lono::Files.register(@options.merge(path: path).merge(o))
5
5
  end
6
6
  end
7
7
  end
@@ -3,14 +3,12 @@ module Lono::Builder::Dsl::Helpers
3
3
  def s3_bucket
4
4
  Lono::S3::Bucket.name
5
5
  end
6
- alias_method :lono_bucket_name, :s3_bucket
7
- alias_method :files_bucket, :s3_bucket
6
+ alias_method :lono_bucket, :s3_bucket
8
7
 
9
- def s3_key(name, options={})
10
- default = {type: "file"}
11
- options.reverse_merge!(default)
12
- "file://app/files/#{options[:type]}/#{name}" # placeholder for post processing
8
+ # Edge case when bucket is created for the first time and files_bucket is
9
+ # not available yet to be use by Finalizer::Files::Replace#replacements
10
+ def files_bucket
11
+ "LONO://S3_BUCKET"
13
12
  end
14
- alias_method :file_s3_key, :s3_key
15
13
  end
16
14
  end
@@ -15,7 +15,7 @@ module Lono::Builder::Dsl::Helpers
15
15
  if o
16
16
  o.output_value
17
17
  else
18
- logger.info "WARN2: NOT FOUND: output #{key} for stack #{stack_name}"
18
+ logger.info "WARN: STACK OUTPUT NOT FOUND: output #{key} for stack #{stack_name}"
19
19
  nil
20
20
  end
21
21
  end
@@ -35,10 +35,8 @@ module Lono::Builder::Dsl::Helpers
35
35
  end
36
36
 
37
37
  def stack_name(blueprint)
38
- return blueprint unless Lono.config.names.output.expand
39
38
  names = Lono::Names.new(blueprint: blueprint)
40
- # explicit expansion pattern provided by user
41
- pattern = blueprint.include?(':') ? blueprint : Lono.config.names.output.stack
39
+ pattern = blueprint # blueprint can be a pattern provided by user. IE: :BLUEPRINT-:ENV
42
40
  names.expansion(pattern)
43
41
  end
44
42
 
@@ -21,7 +21,7 @@ module Lono::Builder::Dsl::Helpers
21
21
  class TempleFileNotFoundError < StandardError; end
22
22
  def template_file_missing(path)
23
23
  message = "ERROR: path #{pretty_path(path)} not found"
24
- caller_line = caller.find { |l| l =~ %r{/blueprints/} } # TODO: show code itself
24
+ caller_line = caller.find { |l| l =~ %r{/blueprints/} }
25
25
  logger.error message.color(:red)
26
26
  logger.error "Called from:"
27
27
  logger.error " #{pretty_path(caller_line)}"
@@ -33,7 +33,7 @@ module Lono::Builder::Dsl::Helpers
33
33
  if File.exist?(path)
34
34
  RenderMePretty.result(path, context: self)
35
35
  else
36
- lines = caller.select { |l| l.include?(Lono.root.to_s) } # TODO: show code itself
36
+ lines = caller.select { |l| l.include?(Lono.root.to_s) }
37
37
  caller_line = pretty_path(lines.first)
38
38
  message =<<~EOL
39
39
  WARN: #{pretty_path(path)} does not exist
@@ -9,7 +9,9 @@ module Lono::Builder::Dsl::Syntax::Core
9
9
 
10
10
  case data
11
11
  when Array
12
- data.map! { |v| squeeze(v) }
12
+ # .compact prevents infinite loop when data = [nil] on accident
13
+ # IE: data[:key] = [nil]
14
+ data.compact.map! { |v| squeeze(v) }
13
15
  when Hash
14
16
  data.each_with_object({}) do |(k,v), squeezed|
15
17
  # only remove nil and empty Array values within Hash structures
@@ -102,8 +102,6 @@ module Lono::Builder::Dsl::Syntax
102
102
  else
103
103
  item
104
104
  end
105
- # list.map!(&:camelize) unless options[:autoformat] == false # TODO: maybe add as an option.
106
- # feel this may be to destructive since am going with auto_camelize false for resources now.
107
105
  args = [list[0], list[1..-1].join('.')]
108
106
  { "Fn::GetAtt" => args }
109
107
  end
@@ -1,4 +1,4 @@
1
- module Lono::Builder
1
+ class Lono::Builder
2
2
  class Dsl < Lono::CLI::Base
3
3
  attr_reader :results
4
4
  def run
@@ -1,4 +1,4 @@
1
- module Lono::Builder
1
+ class Lono::Builder
2
2
  class Param < Lono::CLI::Base
3
3
  attr_reader :env_path, :base_path # set when build is called
4
4
  include Lono::Builder::Dsl::Syntax
@@ -1,6 +1,4 @@
1
- require "yaml"
2
-
3
- module Lono::Builder
1
+ class Lono::Builder
4
2
  class Template < Lono::CLI::Base
5
3
  extend Memoist
6
4
 
@@ -0,0 +1,39 @@
1
+ module Lono
2
+ class Builder < Lono::CLI::Base
3
+ include Lono::Hooks::Concern
4
+
5
+ def all
6
+ check_allow!
7
+
8
+ parameters = nil
9
+ run_hooks("build") do
10
+ clean
11
+ template_builder.run # build with placeholders IE: LONO://app/files/index.rb
12
+ parameters = param_builder.build # Writes the json file in CamelCase keys format
13
+ end
14
+
15
+ logger.info "" # newline
16
+ parameters
17
+ end
18
+ memoize :all
19
+ alias_method :parameters, :all
20
+
21
+ def clean
22
+ Lono::CLI::Clean.new(@options.merge(mute: true)).run
23
+ end
24
+
25
+ def check_allow!
26
+ Lono::Builder::Allow.new(@options).check!
27
+ end
28
+
29
+ def param_builder
30
+ Lono::Builder::Param.new(@options)
31
+ end
32
+ memoize :param_builder
33
+
34
+ def template_builder
35
+ Lono::Builder::Template.new(@options) # write templates to disk
36
+ end
37
+ memoize :template_builder
38
+ end
39
+ end