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
@@ -42,6 +42,10 @@ module Lono::S3
42
42
  end
43
43
 
44
44
  def presigned_url
45
+ # Here because want to lazily create this bucket only after user has confirmed lono up
46
+ # This is the first time bucket needs to exists
47
+ # Called at Deploy::Opts#template_url which gets passed to cfn.create and calls template_url
48
+ Lono::S3::Bucket.ensure_exist
45
49
  s3_presigner.presigned_url(:get_object, bucket: s3_bucket, key: s3_key)
46
50
  end
47
51
 
@@ -63,10 +63,5 @@ module Lono::Script
63
63
  @md5sum ||= Digest::MD5.file("#{@blueprint.root}/scripts.tgz").to_s[0..7]
64
64
  end
65
65
 
66
- def sh(command)
67
- logger.info "=> #{command}"
68
- system command
69
- end
70
-
71
66
  end
72
67
  end
data/lib/lono/seeder.rb CHANGED
@@ -43,7 +43,7 @@ module Lono
43
43
  end
44
44
 
45
45
  content = lines.join("\n")
46
- dest_path = "#{dest_folder}/params/#{Lono.env}.txt" # only support environment level parameters for now
46
+ dest_path = "#{dest_folder}/params/#{Lono.env}.env" # only support environment level parameters for now
47
47
  create_file(dest_path, content) # Thor::Action
48
48
  end
49
49
 
@@ -0,0 +1,32 @@
1
+ module Lono::Utils
2
+ module Sh
3
+ def sh(command, options={})
4
+ on_fail = options[:on_fail].nil? ? "raise" : options[:on_fail]
5
+ strategy = options[:strategy].nil? ? "system" : options[:strategy] # system or backticks
6
+
7
+ logger.info "=> #{command}"
8
+
9
+ if strategy == "backticks"
10
+ out = `#{command}`
11
+ logger.debug out
12
+ success = $?.success?
13
+ else
14
+ success = system(command)
15
+ end
16
+
17
+ result = strategy == "backticks" ? out : success
18
+ return result if success
19
+
20
+ logger.error "ERROR: Running #{command}"
21
+ case on_fail.to_sym
22
+ when :raise
23
+ raise
24
+ when :exit
25
+ status = $?.exitstatus
26
+ exit status
27
+ end
28
+
29
+ result
30
+ end
31
+ end
32
+ end
data/lib/lono/utils.rb ADDED
@@ -0,0 +1,5 @@
1
+ module Lono
2
+ module Utils
3
+ include_modules "utils"
4
+ end
5
+ end
data/lib/lono/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Lono
2
- VERSION = "8.0.0-rc3"
2
+ VERSION = "8.0.0-rc4"
3
3
  end
@@ -0,0 +1,14 @@
1
+ <%
2
+ message = if blueprint
3
+ "app/blueprints/#{blueprint}/config/hooks.rb: test blueprint hook for build"
4
+ else
5
+ "config/hooks.rb: test project hook for build"
6
+ end
7
+ -%>
8
+ before("build",
9
+ execute: "echo '<%= message %> before hook'",
10
+ )
11
+
12
+ after("build",
13
+ execute: "echo '<%= message %> after hook'"
14
+ )
data/lono.gemspec CHANGED
@@ -36,7 +36,7 @@ Gem::Specification.new do |spec|
36
36
  spec.add_dependency "cfn-status"
37
37
  spec.add_dependency "cfn_camelizer"
38
38
  spec.add_dependency "cli-format"
39
- spec.add_dependency "dsl_evaluator", ">= 0.2.5" # for DslEvaluator.print_code
39
+ spec.add_dependency "dsl_evaluator", ">= 0.3.0" # for DslEvaluator.print_code
40
40
  spec.add_dependency "filesize"
41
41
  spec.add_dependency "graph" # lono graph command dependency
42
42
  spec.add_dependency "hashie"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lono
3
3
  version: !ruby/object:Gem::Version
4
- version: 8.0.0.pre.rc3
4
+ version: 8.0.0.pre.rc4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tung Nguyen
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-03-07 00:00:00.000000000 Z
11
+ date: 2022-03-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -184,14 +184,14 @@ dependencies:
184
184
  requirements:
185
185
  - - ">="
186
186
  - !ruby/object:Gem::Version
187
- version: 0.2.5
187
+ version: 0.3.0
188
188
  type: :runtime
189
189
  prerelease: false
190
190
  version_requirements: !ruby/object:Gem::Requirement
191
191
  requirements:
192
192
  - - ">="
193
193
  - !ruby/object:Gem::Version
194
- version: 0.2.5
194
+ version: 0.3.0
195
195
  - !ruby/object:Gem::Dependency
196
196
  name: filesize
197
197
  requirement: !ruby/object:Gem::Requirement
@@ -487,6 +487,12 @@ files:
487
487
  - ".cody/acceptance/role.rb"
488
488
  - ".cody/shared/script/install.sh"
489
489
  - ".cody/shared/script/install/lono.sh"
490
+ - ".github/ISSUE_TEMPLATE.md"
491
+ - ".github/ISSUE_TEMPLATE/bug_report.md"
492
+ - ".github/ISSUE_TEMPLATE/documentation.md"
493
+ - ".github/ISSUE_TEMPLATE/feature_request.md"
494
+ - ".github/ISSUE_TEMPLATE/question.md"
495
+ - ".github/PULL_REQUEST_TEMPLATE.md"
490
496
  - ".gitignore"
491
497
  - ".rspec"
492
498
  - CHANGELOG.md
@@ -510,6 +516,7 @@ files:
510
516
  - lib/lono/aws_services/helper.rb
511
517
  - lib/lono/blueprint.rb
512
518
  - lib/lono/booter.rb
519
+ - lib/lono/builder.rb
513
520
  - lib/lono/builder/allow.rb
514
521
  - lib/lono/builder/allow/base.rb
515
522
  - lib/lono/builder/allow/env.rb
@@ -566,7 +573,6 @@ files:
566
573
  - lib/lono/builder/template/aws_service.rb
567
574
  - lib/lono/builder/template/bashify.rb
568
575
  - lib/lono/builder/template/output.rb
569
- - lib/lono/builder/template/post_processor.rb
570
576
  - lib/lono/builder/template/upload.rb
571
577
  - lib/lono/builder/util/stringify.rb
572
578
  - lib/lono/bundler.rb
@@ -651,15 +657,12 @@ files:
651
657
  - lib/lono/cli.rb
652
658
  - lib/lono/cli/abstract.rb
653
659
  - lib/lono/cli/base.rb
654
- - lib/lono/cli/build.rb
655
660
  - lib/lono/cli/bundle.rb
656
661
  - lib/lono/cli/cfn.rb
657
662
  - lib/lono/cli/cfn/opts.rb
658
663
  - lib/lono/cli/clean.rb
659
- - lib/lono/cli/code.rb
660
664
  - lib/lono/cli/completion.rb
661
665
  - lib/lono/cli/help.rb
662
- - lib/lono/cli/help/blueprint/new.md
663
666
  - lib/lono/cli/help/build.md
664
667
  - lib/lono/cli/help/cfn.md
665
668
  - lib/lono/cli/help/cfn/cancel.md
@@ -672,8 +675,8 @@ files:
672
675
  - lib/lono/cli/help/completion_script.md
673
676
  - lib/lono/cli/help/configsets.md
674
677
  - lib/lono/cli/help/down.md
675
- - lib/lono/cli/help/new/helper/blueprint.md
676
- - lib/lono/cli/help/new/helper/project.md
678
+ - lib/lono/cli/help/new/helper.md
679
+ - lib/lono/cli/help/new/hook.md
677
680
  - lib/lono/cli/help/new/project.md
678
681
  - lib/lono/cli/help/param.md
679
682
  - lib/lono/cli/help/param/generate.md
@@ -688,15 +691,14 @@ files:
688
691
  - lib/lono/cli/help/template/generate.md
689
692
  - lib/lono/cli/help/up.md
690
693
  - lib/lono/cli/help/user_data.md
694
+ - lib/lono/cli/iam.rb
691
695
  - lib/lono/cli/list.rb
692
696
  - lib/lono/cli/new.rb
693
697
  - lib/lono/cli/new/blueprint.rb
694
698
  - lib/lono/cli/new/concerns.rb
695
699
  - lib/lono/cli/new/configset.rb
696
- - lib/lono/cli/new/extension.rb
697
700
  - lib/lono/cli/new/helper.rb
698
- - lib/lono/cli/new/helper/blueprint.rb
699
- - lib/lono/cli/new/helper/project.rb
701
+ - lib/lono/cli/new/hook.rb
700
702
  - lib/lono/cli/new/project.rb
701
703
  - lib/lono/cli/new/sequence.rb
702
704
  - lib/lono/cli/new/shim.rb
@@ -711,6 +713,7 @@ files:
711
713
  - lib/lono/cli/script/upload.rb
712
714
  - lib/lono/cli/seed.rb
713
715
  - lib/lono/cli/status.rb
716
+ - lib/lono/cli/summary.rb
714
717
  - lib/lono/cli/test.rb
715
718
  - lib/lono/command.rb
716
719
  - lib/lono/completer.rb
@@ -729,19 +732,19 @@ files:
729
732
  - lib/lono/files.rb
730
733
  - lib/lono/files/base.rb
731
734
  - lib/lono/files/builder.rb
735
+ - lib/lono/files/builder/lambda_layer.rb
736
+ - lib/lono/files/builder/lambda_layer/rsync.rb
737
+ - lib/lono/files/builder/lambda_layer/ruby_packager.rb
738
+ - lib/lono/files/builder/lambda_layer/ruby_version.rb
732
739
  - lib/lono/files/compressor.rb
733
740
  - lib/lono/files/concerns/post_processing.rb
734
741
  - lib/lono/files/concerns/registration.rb
735
742
  - lib/lono/files/registry.rb
743
+ - lib/lono/hooks/builder.rb
744
+ - lib/lono/hooks/concern.rb
745
+ - lib/lono/hooks/dsl.rb
746
+ - lib/lono/hooks/runner.rb
736
747
  - lib/lono/importer.rb
737
- - lib/lono/importer/base.rb
738
- - lib/lono/importer/converter.rb
739
- - lib/lono/importer/download.rb
740
- - lib/lono/importer/dsl.rb
741
- - lib/lono/importer/params.rb
742
- - lib/lono/importer/service/coder.rb
743
- - lib/lono/inspector/base.rb
744
- - lib/lono/inspector/summary.rb
745
748
  - lib/lono/layering.rb
746
749
  - lib/lono/layering/layer.rb
747
750
  - lib/lono/logger.rb
@@ -761,10 +764,11 @@ files:
761
764
  - lib/lono/script/upload.rb
762
765
  - lib/lono/seeder.rb
763
766
  - lib/lono/user_data.rb
767
+ - lib/lono/utils.rb
764
768
  - lib/lono/utils/logging.rb
765
769
  - lib/lono/utils/pretty.rb
766
770
  - lib/lono/utils/quit.rb
767
- - lib/lono/utils/rsync.rb
771
+ - lib/lono/utils/sh.rb
768
772
  - lib/lono/utils/sure.rb
769
773
  - lib/lono/version.rb
770
774
  - lib/lono/yamler/loader.rb
@@ -773,15 +777,8 @@ files:
773
777
  - lib/templates/configset/configset.rb
774
778
  - lib/templates/examples/blueprint/template.rb
775
779
  - lib/templates/examples/configset/configset.rb
776
- - lib/templates/extension/lib/%extension_name%.rb.tt
777
- - lib/templates/extension/lib/%extension_name%/autoloader.rb.tt
778
- - lib/templates/extension/lib/%extension_name%/helpers/mappings.rb.tt
779
- - lib/templates/extension/lib/%extension_name%/helpers/outputs.rb.tt
780
- - lib/templates/extension/lib/%extension_name%/helpers/parameters.rb.tt
781
- - lib/templates/extension/lib/%extension_name%/helpers/resources/resource.rb.tt
782
- - lib/templates/extension/lib/%extension_name%/helpers/variables.rb.tt
783
- - lib/templates/extension/lib/%extension_name%/version.rb.tt
784
780
  - lib/templates/helper/%underscore_name%_helper.rb.tt
781
+ - lib/templates/hook/config/hooks.rb.tt
785
782
  - lib/templates/project/.gitignore
786
783
  - lib/templates/project/Gemfile.tt
787
784
  - lib/templates/project/README.md
@@ -1,67 +0,0 @@
1
- class Lono::Builder::Template
2
- class PostProcessor < Lono::CLI::Base
3
- def run
4
- replacements.each do |placeholder, replacement|
5
- update_template!(template)
6
- end
7
- write_template!
8
- end
9
-
10
- def write_template!
11
- IO.write(template_path, YAML.dump(template)) # unless ENV['LONO_TEST'] # additional safeguard for testing
12
- end
13
-
14
- def replacements
15
- map = {}
16
-
17
- registry_items.each do |item|
18
- if item.type == "lambda_layer"
19
- placeholder = "file://app/files/lambda_layer/#{item.name}"
20
- elsif item.directory? || item.file?
21
- placeholder = "file://app/files/file/#{item.name}"
22
- else
23
- logger.info "WARN: PostProcessor replacements Cannot find file: #{item.output_path}"
24
- next
25
- end
26
- map[placeholder] = item.s3_path
27
- end
28
-
29
- Lono::Configset::S3File::Registry.items.each do |item|
30
- placeholder = "file://configset/#{item.configset}/#{item.name}"
31
- # map[placeholder] = "https://s3.amazonaws.com/#{Lono::S3::Bucket.name}/#{item.s3_path}"
32
- map[placeholder] = item.replacement_value
33
- end
34
-
35
- map
36
- end
37
-
38
- def update_template!(hash)
39
- hash.each do |k, v|
40
- if v.is_a?(String)
41
- if v =~ %r{^file://}
42
- v.replace(replacements[v]) # replace the placeholder
43
- end
44
- elsif v.is_a?(Hash)
45
- update_template!(v) # recurse
46
- elsif v.is_a?(Array)
47
- v.each { |x| update_template!(x) if x.is_a?(Hash) }
48
- end
49
- end
50
- hash
51
- end
52
-
53
- # Useful for specs
54
- def registry_items
55
- Lono::AppFile::Registry.items
56
- end
57
-
58
- def template
59
- YAML.load_file(template_path)
60
- end
61
- memoize :template
62
-
63
- def template_path
64
- "#{Lono.root}/output/#{@blueprint.name}/templates/#{@template}.yml"
65
- end
66
- end
67
- end
@@ -1,47 +0,0 @@
1
- class Lono::CLI
2
- class Build < Base
3
- def all
4
- check_allow!
5
- Clean.new(@options.merge(mute: true)).run
6
- ensure_s3_bucket_exist
7
- template_builder.run # build with placeholders IE: file://app/files/index.rb
8
- upload_templates
9
- parameters = param_builder.build # Writes the json file in CamelCase keys format
10
- logger.info "" # newline
11
- parameters
12
- end
13
- memoize :all
14
- alias_method :parameters, :all
15
-
16
- def check_allow!
17
- Lono::Builder::Allow.new(@options).check!
18
- end
19
-
20
- def ensure_s3_bucket_exist
21
- return unless upload?
22
- bucket = Lono::S3::Bucket.new
23
- return if bucket.exist?
24
- bucket.deploy
25
- end
26
-
27
- def upload_templates
28
- return unless upload?
29
- Lono::Builder::Template::Upload.new(@options).run
30
- end
31
-
32
- def param_builder
33
- Lono::Builder::Param.new(@options)
34
- end
35
- memoize :param_builder
36
-
37
- def template_builder
38
- Lono::Builder::Template.new(@options) # write templates to disk
39
- end
40
- memoize :template_builder
41
-
42
- # Useful for dev and debugging
43
- def upload?
44
- ENV['LONO_UPLOAD'] != '0'
45
- end
46
- end
47
- end
data/lib/lono/cli/code.rb DELETED
@@ -1,22 +0,0 @@
1
- class Lono::CLI
2
- class Code < Lono::Command
3
- # desc "import SOURCE", "Imports CloudFormation template and converts it to Ruby code."
4
- # long_desc Help.text("code/import")
5
- # option :blueprint, default: nil, desc: "final blueprint name"
6
- # option :casing, default: "as-is", desc: "Controls casing of logical ids. IE: as-is, camelcase or underscore"
7
- # option :summary, default: true, type: :boolean, desc: "provide template summary after import"
8
- # option :template, default: nil, desc: "final template name of downloaded template without extension"
9
- # option :template_name_casing, default: "dasherize", desc: "camelcase or dasherize the template name"
10
- # option :type, default: "dsl", desc: "import as a DSL or ERB template"
11
- # def import(source)
12
- # Importer.new(options.merge(source: source)).run
13
- # end
14
-
15
- desc "convert SOURCE", "Converts snippet of JSON or YAML CloudFormation template to Ruby code."
16
- long_desc Help.text("code/convert")
17
- option :casing, default: "as-is", desc: "Controls casing of logical ids. IE: as-is, camelcase or underscore"
18
- def convert(source)
19
- Lono::Importer::Converter.new(options.merge(source: source)).run
20
- end
21
- end
22
- end
@@ -1,56 +0,0 @@
1
- ## Examples
2
-
3
- lono blueprint new demo # skeleton blueprint with barebones structure
4
-
5
- ## Example Output
6
-
7
- $ lono blueprint new demo
8
- => Creating new blueprint called demo.
9
- create blueprints/demo
10
- create blueprints/demo/demo.gemspec
11
- create blueprints/demo/.gitignore
12
- create blueprints/demo/CHANGELOG.md
13
- create blueprints/demo/Gemfile
14
- create blueprints/demo/README.md
15
- create blueprints/demo/Rakefile
16
- create blueprints/demo/seed/configs.rb
17
- exist blueprints/demo
18
- create blueprints/demo/app/templates/demo.rb
19
- create blueprints/demo/app/user_data/bootstrap.sh
20
- exist blueprints/demo/app/templates
21
- exist
22
- create config/demo/params/development.txt
23
- create config/demo/params/production.txt
24
- create config/demo/variables/development.rb
25
- create config/demo/variables/production.rb
26
- => Installing dependencies with: bundle install
27
- Fetching gem metadata from https://rubygems.org/..........
28
- ...
29
- Bundle complete! 4 Gemfile dependencies, 9 gems now installed.
30
- Use `bundle info [gemname]` to see where a bundled gem is installed.
31
- ================================================================
32
- Congrats You have successfully created a lono blueprint.
33
-
34
- Cd into your blueprint and check things out.
35
-
36
- cd demo
37
-
38
- More info: https://lono.cloud/docs/core/blueprints
39
-
40
- Here is the structure of your blueprint:
41
-
42
- .
43
- ├── app
44
- │ ├── templates
45
- │ │ └── demo.rb
46
- │ └── user_data
47
- │ └── bootstrap.sh
48
- ├── CHANGELOG.md
49
- ├── demo.gemspec
50
- ├── Gemfile
51
- ├── Gemfile.lock
52
- ├── Rakefile
53
- ├── README.md
54
- └── seed
55
- └── configs.rb
56
- $
@@ -1,17 +0,0 @@
1
- ## Example
2
-
3
- The default helper name is `custom`.
4
-
5
- $ lono new helper blueprint --blueprint demo
6
- => Generating custom_helper.rb
7
- create app/blueprints/demo/helpers
8
- create app/blueprints/demo/helpers/custom_helper.rb
9
-
10
-
11
- You can override the helper name with the first argument.
12
-
13
- $ lono new helper blueprint vars --blueprint demo
14
- => Generating vars_helper.rb
15
- create app/blueprints/demo/helpers
16
- create app/blueprints/demo/helpers/vars_helper.rb
17
- $
@@ -1,16 +0,0 @@
1
- ## Examples
2
-
3
- The default helper name is `custom`.
4
-
5
- $ lono new helper project
6
- => Generating custom_helper.rb
7
- create app/helpers/custom
8
- create app/helpers/custom/custom_helper.rb
9
-
10
- You can override the helper name with the first argument.
11
-
12
- $ lono new helper project asg
13
- => Generating asg_helper.rb
14
- create app/helpers/asg
15
- create app/helpers/asg/asg_helper.rb
16
- $
@@ -1,57 +0,0 @@
1
- class Lono::CLI::New
2
- class Extension < Sequence
3
- argument :extension_name
4
-
5
- def self.source_root
6
- templates = File.expand_path("../../templates", File.dirname(__FILE__))
7
- "#{templates}/extension"
8
- end
9
-
10
- def self.cli_options
11
- [
12
- [:force, type: :boolean, desc: "Bypass overwrite are you sure prompt for existing files."],
13
- ]
14
- end
15
-
16
- cli_options.each do |args|
17
- class_option(*args)
18
- end
19
-
20
- # for specs
21
- def set_cwd
22
- @cwd = ENV['LONO_TEST'] ? File.dirname(Lono.root) : "#{Dir.pwd}/app/extensions"
23
- end
24
-
25
- def create_project
26
- puts "=> Creating new extension called #{extension_name}."
27
- directory ".", "#{@cwd}/#{extension_name}", options
28
- end
29
-
30
- def create_license
31
- return unless ENV['LONO_LICENSE_FILE']
32
- copy_file ENV['LONO_LICENSE_FILE'], "#{@cwd}/#{extension_name}/LICENSE.txt"
33
- end
34
-
35
- # After this commands are executed with the newly created project
36
- def set_destination_root
37
- destination_root = "#{@cwd}/#{extension_name}"
38
- self.destination_root = destination_root
39
- @old_dir = Dir.pwd # for reset_current_dir
40
- FileUtils.cd(self.destination_root)
41
- end
42
-
43
- def welcome_message
44
- puts <<~EOL
45
- #{"="*64}
46
- Congrats 🎉 You have successfully created a lono extension.
47
-
48
- Cd into your extension and check things out.
49
-
50
- cd #{extension_name}
51
-
52
- More info: https://lono.cloud/docs/extensions
53
-
54
- EOL
55
- end
56
- end
57
- end
@@ -1,26 +0,0 @@
1
- class Lono::CLI::New::Helper
2
- class Blueprint < Lono::CLI::New::Sequence
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
-
7
- [
8
- [:force, type: :boolean, desc: "Bypass overwrite are you sure prompt for existing files"],
9
- [:blueprint, required: true, desc: "Blueprint name"],
10
- ]
11
- end
12
- cli_options.each do |args|
13
- class_option(*args)
14
- end
15
-
16
- def set_source
17
- set_template_source "helper"
18
- end
19
-
20
- def create_blueprint
21
- @blueprint = @options[:blueprint] # allows %underscore_name%_helper.rb.tt to access @blueprint
22
- logger.info "=> Generating #{underscore_name}_helper.rb"
23
- directory ".", "app/blueprints/#{@blueprint}/helpers"
24
- end
25
- end
26
- end
@@ -1,24 +0,0 @@
1
- class Lono::CLI::New::Helper
2
- class Project < Lono::CLI::New::Sequence
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
-
7
- [
8
- [:force, type: :boolean, desc: "Bypass overwrite are you sure prompt for existing files"],
9
- ]
10
- end
11
- cli_options.each do |args|
12
- class_option(*args)
13
- end
14
-
15
- def set_source
16
- set_template_source "helper"
17
- end
18
-
19
- def create_blueprint
20
- logger.info "=> Generating #{underscore_name}_helper.rb"
21
- directory ".", "app/helpers/#{underscore_name}"
22
- end
23
- end
24
- end
@@ -1,48 +0,0 @@
1
- class Lono::Importer
2
- class Base < Lono::CLI::Base
3
- include Download
4
- include Thor::Actions
5
- include Thor::Base
6
-
7
- def initialize(options)
8
- super
9
- @source = options[:source]
10
- @tmp_path = "/tmp/lono/import/template.yml"
11
- self.destination_root = Dir.pwd # Thor::Actions require destination_root to be set
12
- end
13
-
14
- private
15
- def summarize
16
- return unless @options[:summary]
17
- logger.info "Template Summary:"
18
- Lono::Inspector::Summary.new(@options).run
19
- end
20
-
21
- def create_params(template_path)
22
- create_params_file(template_path, "development")
23
- create_params_file(template_path, "production")
24
- end
25
-
26
- def create_params_file(template_path, env)
27
- params_path = if @blueprint.name != @template
28
- "config/#{@blueprint.name}/params/#{env}/#{@template}.txt"
29
- else
30
- "config/#{@blueprint.name}/params/#{env}.txt"
31
- end
32
- params = Params.new(template_path, params_path)
33
- params.create
34
- end
35
-
36
- # removes the ./ at the beginning if it's there in the path
37
- def pretty_path(path)
38
- path.sub("#{Lono.root}/",'')
39
- end
40
-
41
- def blueprint_name
42
- return @options[:name] if @options[:name]
43
- # Else infer name from the original source.
44
- name = File.basename(@source, ".*")
45
- @options[:casing] == "camelcase" ? name.camelize : name.underscore.dasherize
46
- end
47
- end
48
- end