lono 3.5.0 → 4.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (186) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +15 -4
  3. data/.rspec +1 -0
  4. data/CHANGELOG.md +15 -1
  5. data/Gemfile +3 -3
  6. data/Guardfile +17 -8
  7. data/{LICENSE → LICENSE.txt} +1 -1
  8. data/README.md +20 -12
  9. data/Rakefile +1 -2
  10. data/{bin → exe}/lono +1 -0
  11. data/lib/lono.rb +12 -9
  12. data/lib/lono/cfn.rb +7 -9
  13. data/lib/lono/cfn/{aws_services.rb → aws_service.rb} +1 -1
  14. data/lib/lono/cfn/base.rb +41 -38
  15. data/lib/lono/cfn/create.rb +6 -2
  16. data/lib/lono/cfn/delete.rb +2 -2
  17. data/lib/lono/cfn/diff.rb +1 -1
  18. data/lib/lono/cfn/preview.rb +26 -15
  19. data/lib/lono/cfn/update.rb +11 -9
  20. data/lib/lono/cfn/util.rb +3 -3
  21. data/lib/lono/clean.rb +1 -1
  22. data/lib/lono/cli.rb +71 -39
  23. data/lib/lono/command.rb +42 -18
  24. data/lib/lono/completer.rb +162 -0
  25. data/lib/lono/completer/script.rb +6 -0
  26. data/lib/lono/completer/script.sh +10 -0
  27. data/lib/lono/completion.rb +15 -0
  28. data/lib/lono/core.rb +23 -9
  29. data/lib/lono/core/config.rb +20 -0
  30. data/lib/lono/default/settings.yml +33 -13
  31. data/lib/lono/help.rb +6 -79
  32. data/lib/lono/help/cfn.md +6 -0
  33. data/lib/lono/help/cfn/create.md +22 -0
  34. data/lib/lono/help/cfn/delete.md +5 -0
  35. data/lib/lono/help/cfn/diff.md +5 -0
  36. data/lib/lono/help/cfn/download.md +5 -0
  37. data/lib/lono/help/cfn/preview.md +11 -0
  38. data/lib/lono/help/cfn/update.md +21 -0
  39. data/lib/lono/help/completion.md +22 -0
  40. data/lib/lono/help/completion_script.md +3 -0
  41. data/lib/lono/help/generate.md +7 -0
  42. data/lib/lono/help/hello.md +5 -0
  43. data/lib/lono/help/import.md +7 -0
  44. data/lib/lono/help/inspect.md +4 -0
  45. data/lib/lono/help/inspect/depends.md +3 -0
  46. data/lib/lono/help/inspect/summary.md +3 -0
  47. data/lib/lono/help/new.md +8 -0
  48. data/lib/lono/help/param.md +3 -0
  49. data/lib/lono/{param/help.rb → help/param/generate.md} +1 -9
  50. data/lib/lono/help/script/build.md +5 -0
  51. data/lib/lono/help/script/upload.md +8 -0
  52. data/lib/lono/help/template.md +4 -0
  53. data/lib/lono/help/template/bashify.md +4 -0
  54. data/lib/lono/help/template/generate.md +7 -0
  55. data/lib/lono/help/user_data.md +3 -0
  56. data/lib/lono/importer.rb +43 -20
  57. data/lib/lono/inspector.rb +2 -19
  58. data/lib/lono/inspector/base.rb +2 -2
  59. data/lib/lono/inspector/{depends.rb → graph.rb} +3 -3
  60. data/lib/lono/inspector/summary.rb +1 -1
  61. data/lib/lono/new.rb +79 -26
  62. data/lib/lono/new/helper.rb +16 -0
  63. data/lib/lono/new/message.rb +35 -0
  64. data/lib/lono/param.rb +1 -2
  65. data/lib/lono/param/generator.rb +34 -86
  66. data/lib/lono/project_checker.rb +35 -40
  67. data/lib/lono/script.rb +19 -0
  68. data/lib/lono/script/base.rb +9 -0
  69. data/lib/lono/script/build.rb +73 -0
  70. data/lib/lono/script/upload.rb +81 -0
  71. data/lib/lono/sequence.rb +33 -0
  72. data/lib/lono/setting.rb +83 -0
  73. data/lib/lono/template.rb +8 -9
  74. data/lib/lono/template/{aws_services.rb → aws_service.rb} +1 -1
  75. data/lib/lono/template/context.rb +73 -0
  76. data/lib/lono/template/dsl.rb +63 -64
  77. data/lib/lono/template/helper.rb +201 -0
  78. data/lib/lono/template/template.rb +29 -221
  79. data/lib/lono/template/upload.rb +41 -33
  80. data/lib/lono/upgrade4.rb +175 -0
  81. data/lib/lono/user_data.rb +31 -0
  82. data/lib/lono/version.rb +1 -1
  83. data/lib/starter_projects/autoscaling/.gitignore +1 -0
  84. data/lib/starter_projects/{json_project → autoscaling}/Gemfile +0 -0
  85. data/lib/starter_projects/{yaml_project → autoscaling}/Guardfile +0 -0
  86. data/lib/starter_projects/autoscaling/README.md +118 -0
  87. data/lib/starter_projects/autoscaling/app/definitions/base.rb +2 -0
  88. data/lib/starter_projects/autoscaling/app/templates/autoscaling.yml +682 -0
  89. data/lib/starter_projects/autoscaling/config/params/base/autoscaling.txt +6 -0
  90. data/lib/starter_projects/autoscaling/config/settings.yml +33 -0
  91. data/lib/starter_projects/ec2/.gitignore +1 -0
  92. data/lib/starter_projects/{yaml_project → ec2}/Gemfile +0 -0
  93. data/lib/starter_projects/{json_project → ec2}/Guardfile +1 -1
  94. data/lib/starter_projects/ec2/README.md +86 -0
  95. data/lib/starter_projects/ec2/app/definitions/base.rb +2 -0
  96. data/lib/starter_projects/ec2/app/definitions/development.rb +1 -0
  97. data/lib/starter_projects/ec2/app/definitions/production.rb +1 -0
  98. data/lib/starter_projects/{yaml_project → ec2/app}/helpers/my_custom_helper.rb +0 -0
  99. data/lib/starter_projects/{json_project/templates/user_data/app.sh → ec2/app/partials/user_data/bootstrap.sh} +1 -2
  100. data/lib/starter_projects/{yaml_project → ec2/app}/templates/example.yml +0 -0
  101. data/lib/starter_projects/{json_project/params/base/api-web.txt → ec2/config/params/base/example.txt} +0 -0
  102. data/lib/starter_projects/ec2/config/params/development/example.txt +3 -0
  103. data/lib/starter_projects/ec2/config/params/production/example.txt +2 -0
  104. data/lib/starter_projects/ec2/config/settings.yml +33 -0
  105. data/lib/starter_projects/ec2/config/variables/base.rb +3 -0
  106. data/lib/starter_projects/ec2/config/variables/development.rb +2 -0
  107. data/lib/starter_projects/ec2/config/variables/production.rb +2 -0
  108. data/lib/starter_projects/ec2/welcome.txt +8 -0
  109. data/lib/starter_projects/skeleton/.gitignore +1 -0
  110. data/lib/starter_projects/skeleton/Gemfile +3 -0
  111. data/lib/starter_projects/skeleton/Guardfile +12 -0
  112. data/lib/starter_projects/skeleton/README.md +53 -0
  113. data/{spec/fixtures/my_project/templates/.gitkeep → lib/starter_projects/skeleton/app/definitions/base.rb} +0 -0
  114. data/lib/starter_projects/skeleton/config/settings.yml +33 -0
  115. data/lib/starter_projects/skeleton/welcome.txt +7 -0
  116. data/lono.gemspec +12 -10
  117. data/spec/fixtures/lono_project/.gitignore +1 -0
  118. data/spec/fixtures/lono_project/Gemfile +3 -0
  119. data/spec/fixtures/lono_project/Guardfile +12 -0
  120. data/spec/fixtures/lono_project/app/definitions/base.rb +10 -0
  121. data/spec/fixtures/lono_project/app/definitions/base/more.rb +7 -0
  122. data/spec/fixtures/lono_project/app/definitions/development.rb +1 -0
  123. data/spec/fixtures/lono_project/app/definitions/production.rb +1 -0
  124. data/spec/fixtures/lono_project/app/helpers/custom_helper.rb +5 -0
  125. data/spec/fixtures/lono_project/app/partials/security_group.yml +10 -0
  126. data/{lib/starter_projects/yaml_project/templates/partial → spec/fixtures/lono_project/app/partials}/user_data/bootstrap.sh +8 -2
  127. data/spec/fixtures/lono_project/app/templates/example.yml +50 -0
  128. data/{lib/starter_projects/yaml_project/params/base/api-web-prod.txt → spec/fixtures/lono_project/config/params/base/example.txt} +1 -0
  129. data/spec/fixtures/lono_project/config/params/development/example.txt +1 -0
  130. data/spec/fixtures/lono_project/config/params/production/example.txt +1 -0
  131. data/spec/fixtures/lono_project/config/settings.yml +31 -0
  132. data/spec/fixtures/lono_project/config/variables/base.rb +3 -0
  133. data/spec/fixtures/lono_project/config/variables/development.rb +1 -0
  134. data/spec/fixtures/lono_project/config/variables/production.rb +1 -0
  135. data/spec/fixtures/params/envonly/params/{prod → development}/network.txt +0 -0
  136. data/spec/fixtures/params/overlay/params/{prod → development}/network.txt +0 -0
  137. data/spec/fixtures/raw_templates/aws-waf-security-automations.template +2 -2
  138. data/spec/lib/lono/cfn_spec.rb +6 -9
  139. data/spec/lib/lono/cli_spec.rb +44 -0
  140. data/spec/lib/lono/completion_spec.rb +17 -0
  141. data/spec/lib/lono/inspect_spec.rb +6 -15
  142. data/spec/lib/lono/param/generator_spec.rb +45 -26
  143. data/spec/lib/lono/param_spec.rb +1 -3
  144. data/spec/lib/lono/setting_spec.rb +47 -0
  145. data/spec/lib/lono/template/dsl_spec.rb +33 -157
  146. data/spec/lib/lono/template_spec.rb +4 -16
  147. data/spec/spec_helper.rb +45 -14
  148. metadata +168 -82
  149. data/.coveralls.yml +0 -1
  150. data/lib/lono/cfn/help.rb +0 -103
  151. data/lib/lono/current_region.rb +0 -42
  152. data/lib/lono/inspector/help.rb +0 -21
  153. data/lib/lono/settings.rb +0 -45
  154. data/lib/lono/template/help.rb +0 -25
  155. data/lib/lono/template/helpers.rb +0 -136
  156. data/lib/starter_projects/json_project/.gitignore +0 -1
  157. data/lib/starter_projects/json_project/config/templates/base/blog.rb +0 -20
  158. data/lib/starter_projects/json_project/config/templates/base/stacks.rb +0 -58
  159. data/lib/starter_projects/json_project/templates/db.json +0 -212
  160. data/lib/starter_projects/json_project/templates/partial/host_record.json +0 -28
  161. data/lib/starter_projects/json_project/templates/partial/server.json +0 -45
  162. data/lib/starter_projects/json_project/templates/user_data/db.sh +0 -39
  163. data/lib/starter_projects/json_project/templates/user_data/db2.sh +0 -2
  164. data/lib/starter_projects/json_project/templates/user_data/ruby_script.rb +0 -5
  165. data/lib/starter_projects/json_project/templates/web.json +0 -386
  166. data/lib/starter_projects/yaml_project/.gitignore +0 -1
  167. data/lib/starter_projects/yaml_project/config/templates/base/blog.rb +0 -20
  168. data/lib/starter_projects/yaml_project/config/templates/base/stacks.rb +0 -56
  169. data/lib/starter_projects/yaml_project/config/templates/prod/stacks.rb +0 -1
  170. data/lib/starter_projects/yaml_project/config/templates/stag/stacks.rb +0 -1
  171. data/lib/starter_projects/yaml_project/config/variables/base/variables.rb +0 -4
  172. data/lib/starter_projects/yaml_project/config/variables/prod/variables.rb +0 -1
  173. data/lib/starter_projects/yaml_project/config/variables/stag/variables.rb +0 -1
  174. data/lib/starter_projects/yaml_project/params/base/example.txt +0 -2
  175. data/lib/starter_projects/yaml_project/params/prod/example.txt +0 -1
  176. data/lib/starter_projects/yaml_project/params/stag/example.txt +0 -1
  177. data/lib/starter_projects/yaml_project/templates/db.yml +0 -148
  178. data/lib/starter_projects/yaml_project/templates/partial/host_record.yml +0 -14
  179. data/lib/starter_projects/yaml_project/templates/partial/server.yml +0 -59
  180. data/lib/starter_projects/yaml_project/templates/web.yml +0 -206
  181. data/spec/fixtures/my_project/config/templates/base/stacks.rb +0 -3
  182. data/spec/fixtures/my_project/params/my-stack.txt +0 -3
  183. data/spec/fixtures/my_project/templates/my-stack.yml +0 -0
  184. data/spec/lib/lono/new_spec.rb +0 -59
  185. data/spec/lib/lono/template/template_spec.rb +0 -104
  186. data/spec/lib/lono_spec.rb +0 -27
@@ -1,183 +1,59 @@
1
- require "spec_helper"
2
-
3
1
  describe Lono::Template::DSL do
4
- before(:each) do
5
- @saved_root = ENV['LONO_ROOT']
6
- ENV['LONO_ROOT'] = ENV['TMP_LONO_ROOT']
7
- end
8
- after(:each) do
9
- ENV['LONO_ROOT'] = @saved_root
10
- FileUtils.rm_rf(ENV['TMP_LONO_ROOT']) unless ENV['KEEP_TMP_PROJECT']
11
- end
12
-
13
- context "json starter project" do
14
- before(:each) do
15
- new_project = Lono::New.new(
16
- force: true,
17
- quiet: true,
18
- format: 'json',
19
- project_root: ENV['TMP_LONO_ROOT'],
20
- )
21
- new_project.run
22
- end
23
-
24
- it "json" do
2
+ context "tmp/lono_project" do
3
+ it "#evaluate_templates" do
25
4
  dsl = Lono::Template::DSL.new(
26
5
  quiet: true
27
6
  )
28
- dsl.evaluate_templates # run the dependent instance_eval and load_subfoler so @templates is assigned
29
- detected_format = dsl.detect_format
30
- expect(detected_format).to eq 'json'
7
+ dsl.evaluate_templates
8
+ templates = dsl.instance_variable_get(:@templates)
9
+ template_names = templates.map { |h| h[:name] }
10
+ expect(template_names).to include("example")
31
11
  end
32
12
  end
33
13
 
34
- context "yaml starter project" do
14
+ context "lono generate" do
35
15
  before(:each) do
36
- new_project = Lono::New.new(
37
- force: true,
38
- quiet: true,
39
- format: 'yaml',
40
- project_root: ENV['TMP_LONO_ROOT'],
41
- )
42
- new_project.run
43
- end
44
-
45
- it "yaml" do
46
- dsl = Lono::Template::DSL.new(
47
- quiet: true
48
- )
49
- dsl.evaluate_templates # run the dependent instance_eval and load_subfoler so @templates is assigned
50
- detected_format = dsl.detect_format
51
- expect(detected_format).to eq 'yml'
52
- end
53
- end
54
-
55
- context "multiple format starter project" do
56
- # it "yaml" do
57
- # dsl = Lono::Template::DSL.new(
58
- # project_root: @project,
59
- # quiet: true
60
- # )
61
- # detected_format = dsl.detect_format
62
- # expect(detected_format).to eq 'yaml'
63
- # end
64
- end
65
-
66
- context "json starter project" do
67
- before(:each) do
68
- new_project = Lono::New.new(
69
- force: true,
70
- quiet: true,
71
- format: 'json',
72
- project_root: ENV['TMP_LONO_ROOT'],
73
- )
74
- new_project.run
75
-
76
- dsl = Lono::Template::DSL.new(
77
- quiet: true
78
- )
16
+ dsl = Lono::Template::DSL.new(quiet: true)
79
17
  dsl.run
80
18
  end
81
19
 
82
20
  it "should generate cloudformation template" do
83
- raw = IO.read("#{Lono.root}/output/api-web.json")
84
- json = JSON.load(raw)
85
- expect(json['Description']).to eq "Api Stack"
86
- expect(json['Mappings']['AWSRegionArch2AMI']['us-east-1']['64']).to eq 'ami-123'
87
- end
88
-
89
- it "should make trailing options pass to the partial helper available as instance variables" do
90
- raw = IO.read("#{Lono.root}/output/api-web.json")
91
- json = JSON.load(raw)
92
- expect(json['Resources']['HostRecord']['Properties']['Comment']).to eq 'DNS name for mydomain.com'
93
- end
94
-
95
- it "should generate user data with variables" do
96
- raw = IO.read("#{Lono.root}/output/api-redis.json")
97
- json = JSON.load(raw)
98
- expect(json['Description']).to eq "Api redis"
99
- user_data = json['Resources']['server']['Properties']['UserData']['Fn::Base64']['Fn::Join'][1]
100
- expect(user_data).to include("VARTEST=foo\n")
21
+ template = YAML.load_file("#{Lono.root}/output/templates/example.yml")
22
+ expect(template['Description']).to include "AWS CloudFormation Sample Template"
101
23
  end
102
24
 
103
- it "should include multiple user_data scripts" do
104
- raw = IO.read("#{Lono.root}/output/api-redis.json")
105
- json = JSON.load(raw)
106
- expect(json['Description']).to eq "Api redis"
107
- user_data = json['Resources']['server']['Properties']['UserData']['Fn::Base64']['Fn::Join'][1]
108
- expect(user_data).to include("DB2=test\n")
25
+ # <%= partial("security_group", desc: "whatever", port: 22)
26
+ it "partial local variables become instance variables in partial view" do
27
+ template = YAML.load_file("#{Lono.root}/output/templates/example.yml")
28
+ desc = template['Resources']['InstanceSecurityGroup']['Properties']['GroupDescription']
29
+ expect(desc).to eq 'Enable SSH access via port 22'
109
30
  end
110
31
 
111
- it "should generate db template" do
112
- raw = IO.read("#{Lono.root}/output/api-redis.json")
113
- json = JSON.load(raw)
114
- expect(json['Description']).to eq "Api redis"
115
- user_data = json['Resources']['server']['Properties']['UserData']['Fn::Base64']['Fn::Join'][1]
116
- expect(user_data).to include({"Ref" => "AWS::StackName"})
117
- expect(user_data).to include({"Ref" => "WaitHandle"})
118
- expect(user_data).to include({
119
- "Fn::FindInMap" => [
120
- "EnvironmentMapping",
121
- "HostnamePrefix",
122
- {"Ref" => "Environment"}
123
- ]
124
- })
125
- expect(user_data).to include({
126
- "Fn::FindInMap" => [
127
- "MapName",
128
- "TopLevelKey",
129
- "SecondLevelKey"
130
- ]
131
- })
132
- expect(user_data).to include({"Ref" => "DRINK"})
133
-
134
- expect(user_data).to include({"Fn::Base64" => "value to encode"})
135
- expect(user_data).to include({"Fn::GetAtt" => ["server", "PublicDnsName"]})
136
- expect(user_data).to include({"Fn::GetAZs" => "AWS::Region"})
137
- expect(user_data).to include({"Fn::Join" => [ ':', ['a','b','c']]})
138
- expect(user_data).to include({"Fn::Select" => [ '1', ['a','b','c']]})
32
+ it "partials should have access to variables" do
33
+ text = IO.read("#{Lono.root}/output/templates/example.yml")
34
+ expect(text).to include("override_test=overridden-by-development")
139
35
  end
140
36
 
141
- it "should transform bash script to CF template user_data" do
142
- block = Proc.new { }
143
- template = Lono::Template::Template.new("foo", block)
144
-
145
- line = 'echo {"Ref"=>"AWS::StackName"} > /tmp/stack_name ; {"Ref"=>"Ami"}'
146
- data = template.transform(line)
147
- expect(data).to eq ["echo ", {"Ref"=>"AWS::StackName"}, " > /tmp/stack_name ; ", {"Ref"=>"Ami"}, "\n"]
148
-
149
- line = 'echo {"Ref"=>"AWS::StackName"} > /tmp/stack_name'
150
- data = template.transform(line)
151
- expect(data).to eq ["echo ", {"Ref"=>"AWS::StackName"}, " > /tmp/stack_name\n"]
152
-
153
- line = 'echo {"Fn::FindInMap" => [ "A", "B", {"Ref"=>"AWS::StackName"} ]}'
154
- data = template.transform(line)
155
- expect(data).to eq ["echo ", {"Fn::FindInMap" => ["A", "B", {"Ref"=>"AWS::StackName"}]}, "\n"]
156
-
157
- line = 'echo {"Fn::FindInMap" => [ "A", "B", {"Ref"=>"AWS::StackName"} ]} > /tmp/stack_name ; {"Ref"=>"Ami"}'
158
- data = template.transform(line)
159
- expect(data).to eq ["echo ", {"Fn::FindInMap" => ["A", "B", {"Ref"=>"AWS::StackName"}]}, " > /tmp/stack_name ; ", {"Ref"=>"Ami"}, "\n"]
37
+ it "should have access to custom helpers" do
38
+ text = IO.read("#{Lono.root}/output/templates/example.yml")
39
+ expect(text).to include("custom_helper value")
160
40
  end
41
+ end
161
42
 
162
- it "should not transform user_data ruby scripts" do
163
- raw = IO.read("#{Lono.root}/output/api-worker.json")
164
- json = JSON.load(raw)
165
- user_data = json['Resources']['LaunchConfig']['Properties']['UserData']['Fn::Base64']['Fn::Join'][1]
166
- expect(user_data).to include(%Q|ec2.tags.create(ec2.instances[my_instance_id], "Name", {value: Facter.hostname})\n|)
167
- expect(user_data).to include(%Q{find_all{ |record_set| record_set[:name] == record_name }\n})
43
+ context "yaml parse error" do
44
+ let(:dsl) do
45
+ Lono::Template::DSL.new(quiet: true)
168
46
  end
169
47
 
170
- it "should create parent folders for parent/db-stack.json" do
171
- directory_created = File.exist?("#{Lono.root}/output/parent")
172
- expect(directory_created).to be true
48
+ it "show exact line of error code when yaml is invalid" do
49
+ IO.write("tmp/bad.yml", <<EOL)
50
+ test: 1
51
+ foo
52
+ test
53
+ EOL
54
+ out = dsl.validate("tmp/bad.yml")
55
+ expect(out).to include("2 foo")
173
56
  end
174
57
 
175
- it "task should generate CloudFormation templates" do
176
- raw = IO.read("#{Lono.root}/output/api-web.json")
177
- json = JSON.load(raw)
178
- expect(json['Description']).to eq "Api Stack"
179
- expect(json['Mappings']['AWSRegionArch2AMI']['us-east-1']['64']).to eq 'ami-123'
180
- end
181
58
  end
182
-
183
59
  end
@@ -1,32 +1,20 @@
1
- require "spec_helper"
2
-
3
1
  describe Lono do
4
- before(:each) do
5
- @env = "LONO_ROOT=tmp/foo"
6
- lono_bin = File.expand_path("../../../../bin/lono", __FILE__)
7
- execute("cd tmp && #{lono_bin} new foo -f -q --format json")
8
- end
9
-
10
- after(:each) do
11
- # FileUtils.rm_rf("foo") unless ENV['KEEP_TMP_PROJECT']
12
- end
13
-
14
2
  describe "bashify" do
15
3
  it "should convert cfn user_data to bash script" do
16
- path = "#{$root}/spec/fixtures/cfn.json"
17
- out = execute("./bin/lono template bashify #{path}")
4
+ path = "spec/fixtures/cfn.json"
5
+ out = execute("exe/lono template bashify #{path}")
18
6
  expect(out).to match /bash -lexv/
19
7
  end
20
8
  end
21
9
 
22
10
  describe "cli specs" do
23
11
  it "should generate templates" do
24
- out = execute("#{@env} ./bin/lono template generate -c")
12
+ out = execute("exe/lono template generate --clean")
25
13
  expect(out).to match /Generating CloudFormation templates/
26
14
  end
27
15
 
28
16
  it "should upload templates" do
29
- out = execute("#{@env} ./bin/lono template upload --noop")
17
+ out = execute("exe/lono template upload --noop")
30
18
  expect(out).to match /Templates uploaded to s3/
31
19
  end
32
20
  end
data/spec/spec_helper.rb CHANGED
@@ -1,31 +1,62 @@
1
1
  ENV['TEST'] = '1'
2
2
  # Ensures aws api never called. Fixture home folder does not contain ~/.aws/credentails
3
3
  ENV['HOME'] = "spec/fixtures/home"
4
- ENV['LONO_ROOT'] = "spec/fixtures/my_project" # this gets kept
5
- ENV['TMP_LONO_ROOT'] = "./tmp/lono_project" # need the period for the load_custom_helpers require , unsure if I should adjust the LOAD_PATH
4
+ # We'll always re-generate a new lono project in tmp. It can be:
5
+ #
6
+ # 1. copied from spec/fixtures/lono_project
7
+ # 2. generated from `lono new`
8
+ #
9
+ # This is done because changing LONO_ROOT for specs was a mess.
10
+ ENV['LONO_ROOT'] = "tmp/lono_project" # this gets kept
6
11
 
7
12
  require "pp"
8
13
  require "byebug"
9
- require "bundler"
10
14
 
11
- Bundler.require(:development)
15
+ # require "bundler"
16
+ # Bundler.require(:development)
12
17
 
13
- $root = File.expand_path('../../', __FILE__)
18
+ root = File.expand_path("../", File.dirname(__FILE__))
19
+ require "#{root}/lib/lono"
14
20
 
15
- require "#{$root}/lib/lono"
16
-
17
- # require 'coveralls'
18
- # Coveralls.wear!
19
-
20
- module Helpers
21
+ module Helper
21
22
  def execute(cmd)
22
- puts "Running: #{cmd}" if ENV['DEBUG']
23
+ puts "Running: #{cmd}" if show_command?
23
24
  out = `#{cmd}`
24
- puts out if ENV['DEBUG']
25
+ puts out if show_command?
25
26
  out
26
27
  end
28
+
29
+ # Added SHOW_COMMAND because DEBUG is also used by other libraries like
30
+ # bundler and it shows its internal debugging logging also.
31
+ def show_command?
32
+ ENV['DEBUG'] || ENV['SHOW_COMMAND']
33
+ end
34
+
35
+ def ensure_tmp_exists
36
+ FileUtils.mkdir_p("tmp")
37
+ end
38
+
39
+ # Copies spec/fixtures/lono_project to tmp/lono_project,
40
+ # Main fixture we'll use because it's faster
41
+ def copy_lono_project
42
+ destroy_lono_project # just in case KEEP_TMP_PROJECT is used
43
+ FileUtils.cp_r("spec/fixtures/lono_project", "tmp/lono_project")
44
+ end
45
+
46
+ def destroy_lono_project
47
+ # Only use KEEP_TMP_PROJECT if you are testing exactly 1 spec for debugging
48
+ # or it'll affect other tests.
49
+ FileUtils.rm_rf(Lono.root)
50
+ end
27
51
  end
28
52
 
29
53
  RSpec.configure do |c|
30
- c.include Helpers
54
+ c.include Helper
55
+ c.before(:all) do
56
+ ensure_tmp_exists
57
+ copy_lono_project
58
+ end
59
+ c.after(:all) do
60
+ destroy_lono_project unless ENV['KEEP_TMP_PROJECT']
61
+ end
31
62
  end
metadata CHANGED
@@ -1,17 +1,17 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lono
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.5.0
4
+ version: 4.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tung Nguyen
8
8
  autorequire:
9
- bindir: bin
9
+ bindir: exe
10
10
  cert_chain: []
11
- date: 2018-02-09 00:00:00.000000000 Z
11
+ date: 2018-02-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
- name: json
14
+ name: activesupport
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
17
  - - ">="
@@ -25,7 +25,7 @@ dependencies:
25
25
  - !ruby/object:Gem::Version
26
26
  version: '0'
27
27
  - !ruby/object:Gem::Dependency
28
- name: thor
28
+ name: aws-sdk-cloudformation
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - ">="
@@ -39,7 +39,7 @@ dependencies:
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
41
  - !ruby/object:Gem::Dependency
42
- name: guard
42
+ name: aws-sdk-s3
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
45
  - - ">="
@@ -53,7 +53,7 @@ dependencies:
53
53
  - !ruby/object:Gem::Version
54
54
  version: '0'
55
55
  - !ruby/object:Gem::Dependency
56
- name: rb-fsevent
56
+ name: colorize
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
59
  - - ">="
@@ -67,7 +67,7 @@ dependencies:
67
67
  - !ruby/object:Gem::Version
68
68
  version: '0'
69
69
  - !ruby/object:Gem::Dependency
70
- name: guard-cloudformation
70
+ name: filesize
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
73
  - - ">="
@@ -81,7 +81,7 @@ dependencies:
81
81
  - !ruby/object:Gem::Version
82
82
  version: '0'
83
83
  - !ruby/object:Gem::Dependency
84
- name: guard-lono
84
+ name: graph
85
85
  requirement: !ruby/object:Gem::Requirement
86
86
  requirements:
87
87
  - - ">="
@@ -95,7 +95,35 @@ dependencies:
95
95
  - !ruby/object:Gem::Version
96
96
  version: '0'
97
97
  - !ruby/object:Gem::Dependency
98
- name: colorize
98
+ name: guard
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ">="
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ type: :runtime
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ">="
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
111
+ - !ruby/object:Gem::Dependency
112
+ name: guard-cloudformation
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - ">="
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
118
+ type: :runtime
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - ">="
123
+ - !ruby/object:Gem::Version
124
+ version: '0'
125
+ - !ruby/object:Gem::Dependency
126
+ name: guard-lono
99
127
  requirement: !ruby/object:Gem::Requirement
100
128
  requirements:
101
129
  - - ">="
@@ -123,7 +151,7 @@ dependencies:
123
151
  - !ruby/object:Gem::Version
124
152
  version: '0'
125
153
  - !ruby/object:Gem::Dependency
126
- name: aws-sdk-cloudformation
154
+ name: json
127
155
  requirement: !ruby/object:Gem::Requirement
128
156
  requirements:
129
157
  - - ">="
@@ -137,7 +165,7 @@ dependencies:
137
165
  - !ruby/object:Gem::Version
138
166
  version: '0'
139
167
  - !ruby/object:Gem::Dependency
140
- name: aws-sdk-s3
168
+ name: rb-fsevent
141
169
  requirement: !ruby/object:Gem::Requirement
142
170
  requirements:
143
171
  - - ">="
@@ -151,7 +179,7 @@ dependencies:
151
179
  - !ruby/object:Gem::Version
152
180
  version: '0'
153
181
  - !ruby/object:Gem::Dependency
154
- name: activesupport
182
+ name: thor
155
183
  requirement: !ruby/object:Gem::Requirement
156
184
  requirements:
157
185
  - - ">="
@@ -165,7 +193,7 @@ dependencies:
165
193
  - !ruby/object:Gem::Version
166
194
  version: '0'
167
195
  - !ruby/object:Gem::Dependency
168
- name: graph
196
+ name: render_me_pretty
169
197
  requirement: !ruby/object:Gem::Requirement
170
198
  requirements:
171
199
  - - ">="
@@ -248,8 +276,7 @@ dependencies:
248
276
  - - ">="
249
277
  - !ruby/object:Gem::Version
250
278
  version: '0'
251
- description: Lono is a CloudFormation Template ruby generator. Lono generates CloudFormation
252
- templates based on ERB templates.
279
+ description:
253
280
  email:
254
281
  - tongueroo@gmail.com
255
282
  executables:
@@ -258,7 +285,6 @@ extensions: []
258
285
  extra_rdoc_files: []
259
286
  files:
260
287
  - ".circleci/config.yml"
261
- - ".coveralls.yml"
262
288
  - ".gitignore"
263
289
  - ".gitmodules"
264
290
  - ".rspec"
@@ -266,105 +292,151 @@ files:
266
292
  - CONTRIBUTING.md
267
293
  - Gemfile
268
294
  - Guardfile
269
- - LICENSE
295
+ - LICENSE.txt
270
296
  - README.md
271
297
  - Rakefile
272
- - bin/lono
298
+ - exe/lono
273
299
  - lib/lono.rb
274
300
  - lib/lono/cfn.rb
275
- - lib/lono/cfn/aws_services.rb
301
+ - lib/lono/cfn/aws_service.rb
276
302
  - lib/lono/cfn/base.rb
277
303
  - lib/lono/cfn/create.rb
278
304
  - lib/lono/cfn/delete.rb
279
305
  - lib/lono/cfn/diff.rb
280
306
  - lib/lono/cfn/download.rb
281
- - lib/lono/cfn/help.rb
282
307
  - lib/lono/cfn/preview.rb
283
308
  - lib/lono/cfn/update.rb
284
309
  - lib/lono/cfn/util.rb
285
310
  - lib/lono/clean.rb
286
311
  - lib/lono/cli.rb
287
312
  - lib/lono/command.rb
313
+ - lib/lono/completer.rb
314
+ - lib/lono/completer/script.rb
315
+ - lib/lono/completer/script.sh
316
+ - lib/lono/completion.rb
288
317
  - lib/lono/core.rb
289
- - lib/lono/current_region.rb
318
+ - lib/lono/core/config.rb
290
319
  - lib/lono/default/settings.yml
291
320
  - lib/lono/help.rb
321
+ - lib/lono/help/cfn.md
322
+ - lib/lono/help/cfn/create.md
323
+ - lib/lono/help/cfn/delete.md
324
+ - lib/lono/help/cfn/diff.md
325
+ - lib/lono/help/cfn/download.md
326
+ - lib/lono/help/cfn/preview.md
327
+ - lib/lono/help/cfn/update.md
328
+ - lib/lono/help/completion.md
329
+ - lib/lono/help/completion_script.md
330
+ - lib/lono/help/generate.md
331
+ - lib/lono/help/hello.md
332
+ - lib/lono/help/import.md
333
+ - lib/lono/help/inspect.md
334
+ - lib/lono/help/inspect/depends.md
335
+ - lib/lono/help/inspect/summary.md
336
+ - lib/lono/help/new.md
337
+ - lib/lono/help/param.md
338
+ - lib/lono/help/param/generate.md
339
+ - lib/lono/help/script/build.md
340
+ - lib/lono/help/script/upload.md
341
+ - lib/lono/help/template.md
342
+ - lib/lono/help/template/bashify.md
343
+ - lib/lono/help/template/generate.md
344
+ - lib/lono/help/user_data.md
292
345
  - lib/lono/importer.rb
293
346
  - lib/lono/inspector.rb
294
347
  - lib/lono/inspector/base.rb
295
- - lib/lono/inspector/depends.rb
296
- - lib/lono/inspector/help.rb
348
+ - lib/lono/inspector/graph.rb
297
349
  - lib/lono/inspector/summary.rb
298
350
  - lib/lono/new.rb
351
+ - lib/lono/new/helper.rb
352
+ - lib/lono/new/message.rb
299
353
  - lib/lono/param.rb
300
354
  - lib/lono/param/generator.rb
301
- - lib/lono/param/help.rb
302
355
  - lib/lono/project_checker.rb
303
- - lib/lono/settings.rb
356
+ - lib/lono/script.rb
357
+ - lib/lono/script/base.rb
358
+ - lib/lono/script/build.rb
359
+ - lib/lono/script/upload.rb
360
+ - lib/lono/sequence.rb
361
+ - lib/lono/setting.rb
304
362
  - lib/lono/template.rb
305
- - lib/lono/template/aws_services.rb
363
+ - lib/lono/template/aws_service.rb
306
364
  - lib/lono/template/bashify.rb
365
+ - lib/lono/template/context.rb
307
366
  - lib/lono/template/dsl.rb
308
- - lib/lono/template/help.rb
309
- - lib/lono/template/helpers.rb
367
+ - lib/lono/template/helper.rb
310
368
  - lib/lono/template/template.rb
311
369
  - lib/lono/template/upload.rb
370
+ - lib/lono/upgrade4.rb
371
+ - lib/lono/user_data.rb
312
372
  - lib/lono/version.rb
313
- - lib/starter_projects/json_project/.gitignore
314
- - lib/starter_projects/json_project/Gemfile
315
- - lib/starter_projects/json_project/Guardfile
316
- - lib/starter_projects/json_project/config/templates/base/blog.rb
317
- - lib/starter_projects/json_project/config/templates/base/stacks.rb
318
- - lib/starter_projects/json_project/params/base/api-web.txt
319
- - lib/starter_projects/json_project/templates/db.json
320
- - lib/starter_projects/json_project/templates/partial/host_record.json
321
- - lib/starter_projects/json_project/templates/partial/server.json
322
- - lib/starter_projects/json_project/templates/user_data/app.sh
323
- - lib/starter_projects/json_project/templates/user_data/db.sh
324
- - lib/starter_projects/json_project/templates/user_data/db2.sh
325
- - lib/starter_projects/json_project/templates/user_data/ruby_script.rb
326
- - lib/starter_projects/json_project/templates/web.json
327
- - lib/starter_projects/yaml_project/.gitignore
328
- - lib/starter_projects/yaml_project/Gemfile
329
- - lib/starter_projects/yaml_project/Guardfile
330
- - lib/starter_projects/yaml_project/config/templates/base/blog.rb
331
- - lib/starter_projects/yaml_project/config/templates/base/stacks.rb
332
- - lib/starter_projects/yaml_project/config/templates/prod/stacks.rb
333
- - lib/starter_projects/yaml_project/config/templates/stag/stacks.rb
334
- - lib/starter_projects/yaml_project/config/variables/base/variables.rb
335
- - lib/starter_projects/yaml_project/config/variables/prod/variables.rb
336
- - lib/starter_projects/yaml_project/config/variables/stag/variables.rb
337
- - lib/starter_projects/yaml_project/helpers/my_custom_helper.rb
338
- - lib/starter_projects/yaml_project/params/base/api-web-prod.txt
339
- - lib/starter_projects/yaml_project/params/base/example.txt
340
- - lib/starter_projects/yaml_project/params/prod/example.txt
341
- - lib/starter_projects/yaml_project/params/stag/example.txt
342
- - lib/starter_projects/yaml_project/templates/db.yml
343
- - lib/starter_projects/yaml_project/templates/example.yml
344
- - lib/starter_projects/yaml_project/templates/partial/host_record.yml
345
- - lib/starter_projects/yaml_project/templates/partial/server.yml
346
- - lib/starter_projects/yaml_project/templates/partial/user_data/bootstrap.sh
347
- - lib/starter_projects/yaml_project/templates/web.yml
373
+ - lib/starter_projects/autoscaling/.gitignore
374
+ - lib/starter_projects/autoscaling/Gemfile
375
+ - lib/starter_projects/autoscaling/Guardfile
376
+ - lib/starter_projects/autoscaling/README.md
377
+ - lib/starter_projects/autoscaling/app/definitions/base.rb
378
+ - lib/starter_projects/autoscaling/app/templates/autoscaling.yml
379
+ - lib/starter_projects/autoscaling/config/params/base/autoscaling.txt
380
+ - lib/starter_projects/autoscaling/config/settings.yml
381
+ - lib/starter_projects/ec2/.gitignore
382
+ - lib/starter_projects/ec2/Gemfile
383
+ - lib/starter_projects/ec2/Guardfile
384
+ - lib/starter_projects/ec2/README.md
385
+ - lib/starter_projects/ec2/app/definitions/base.rb
386
+ - lib/starter_projects/ec2/app/definitions/development.rb
387
+ - lib/starter_projects/ec2/app/definitions/production.rb
388
+ - lib/starter_projects/ec2/app/helpers/my_custom_helper.rb
389
+ - lib/starter_projects/ec2/app/partials/user_data/bootstrap.sh
390
+ - lib/starter_projects/ec2/app/templates/example.yml
391
+ - lib/starter_projects/ec2/config/params/base/example.txt
392
+ - lib/starter_projects/ec2/config/params/development/example.txt
393
+ - lib/starter_projects/ec2/config/params/production/example.txt
394
+ - lib/starter_projects/ec2/config/settings.yml
395
+ - lib/starter_projects/ec2/config/variables/base.rb
396
+ - lib/starter_projects/ec2/config/variables/development.rb
397
+ - lib/starter_projects/ec2/config/variables/production.rb
398
+ - lib/starter_projects/ec2/welcome.txt
399
+ - lib/starter_projects/skeleton/.gitignore
400
+ - lib/starter_projects/skeleton/Gemfile
401
+ - lib/starter_projects/skeleton/Guardfile
402
+ - lib/starter_projects/skeleton/README.md
403
+ - lib/starter_projects/skeleton/app/definitions/base.rb
404
+ - lib/starter_projects/skeleton/config/settings.yml
405
+ - lib/starter_projects/skeleton/welcome.txt
348
406
  - lono.gemspec
349
407
  - spec/fixtures/cfn.json
350
- - spec/fixtures/my_project/config/templates/base/stacks.rb
351
- - spec/fixtures/my_project/params/my-stack.txt
352
- - spec/fixtures/my_project/templates/.gitkeep
353
- - spec/fixtures/my_project/templates/my-stack.yml
408
+ - spec/fixtures/lono_project/.gitignore
409
+ - spec/fixtures/lono_project/Gemfile
410
+ - spec/fixtures/lono_project/Guardfile
411
+ - spec/fixtures/lono_project/app/definitions/base.rb
412
+ - spec/fixtures/lono_project/app/definitions/base/more.rb
413
+ - spec/fixtures/lono_project/app/definitions/development.rb
414
+ - spec/fixtures/lono_project/app/definitions/production.rb
415
+ - spec/fixtures/lono_project/app/helpers/custom_helper.rb
416
+ - spec/fixtures/lono_project/app/partials/security_group.yml
417
+ - spec/fixtures/lono_project/app/partials/user_data/bootstrap.sh
418
+ - spec/fixtures/lono_project/app/templates/example.yml
419
+ - spec/fixtures/lono_project/config/params/base/example.txt
420
+ - spec/fixtures/lono_project/config/params/development/example.txt
421
+ - spec/fixtures/lono_project/config/params/production/example.txt
422
+ - spec/fixtures/lono_project/config/settings.yml
423
+ - spec/fixtures/lono_project/config/variables/base.rb
424
+ - spec/fixtures/lono_project/config/variables/development.rb
425
+ - spec/fixtures/lono_project/config/variables/production.rb
354
426
  - spec/fixtures/params/baseonly/params/base/network.txt
355
- - spec/fixtures/params/envonly/params/prod/network.txt
427
+ - spec/fixtures/params/envonly/params/development/network.txt
356
428
  - spec/fixtures/params/overlay/params/base/network.txt
357
- - spec/fixtures/params/overlay/params/prod/network.txt
429
+ - spec/fixtures/params/overlay/params/development/network.txt
358
430
  - spec/fixtures/raw_templates/aws-waf-security-automations.template
359
431
  - spec/lib/lono/cfn_spec.rb
432
+ - spec/lib/lono/cli_spec.rb
433
+ - spec/lib/lono/completion_spec.rb
360
434
  - spec/lib/lono/inspect_spec.rb
361
- - spec/lib/lono/new_spec.rb
362
435
  - spec/lib/lono/param/generator_spec.rb
363
436
  - spec/lib/lono/param_spec.rb
437
+ - spec/lib/lono/setting_spec.rb
364
438
  - spec/lib/lono/template/dsl_spec.rb
365
- - spec/lib/lono/template/template_spec.rb
366
439
  - spec/lib/lono/template_spec.rb
367
- - spec/lib/lono_spec.rb
368
440
  - spec/spec_helper.rb
369
441
  - vendor/plissken/Gemfile
370
442
  - vendor/plissken/LICENSE.txt
@@ -406,22 +478,36 @@ summary: Lono is a CloudFormation Template ruby generator. Lono generates Cloud
406
478
  templates based on ERB templates.
407
479
  test_files:
408
480
  - spec/fixtures/cfn.json
409
- - spec/fixtures/my_project/config/templates/base/stacks.rb
410
- - spec/fixtures/my_project/params/my-stack.txt
411
- - spec/fixtures/my_project/templates/.gitkeep
412
- - spec/fixtures/my_project/templates/my-stack.yml
481
+ - spec/fixtures/lono_project/.gitignore
482
+ - spec/fixtures/lono_project/Gemfile
483
+ - spec/fixtures/lono_project/Guardfile
484
+ - spec/fixtures/lono_project/app/definitions/base.rb
485
+ - spec/fixtures/lono_project/app/definitions/base/more.rb
486
+ - spec/fixtures/lono_project/app/definitions/development.rb
487
+ - spec/fixtures/lono_project/app/definitions/production.rb
488
+ - spec/fixtures/lono_project/app/helpers/custom_helper.rb
489
+ - spec/fixtures/lono_project/app/partials/security_group.yml
490
+ - spec/fixtures/lono_project/app/partials/user_data/bootstrap.sh
491
+ - spec/fixtures/lono_project/app/templates/example.yml
492
+ - spec/fixtures/lono_project/config/params/base/example.txt
493
+ - spec/fixtures/lono_project/config/params/development/example.txt
494
+ - spec/fixtures/lono_project/config/params/production/example.txt
495
+ - spec/fixtures/lono_project/config/settings.yml
496
+ - spec/fixtures/lono_project/config/variables/base.rb
497
+ - spec/fixtures/lono_project/config/variables/development.rb
498
+ - spec/fixtures/lono_project/config/variables/production.rb
413
499
  - spec/fixtures/params/baseonly/params/base/network.txt
414
- - spec/fixtures/params/envonly/params/prod/network.txt
500
+ - spec/fixtures/params/envonly/params/development/network.txt
415
501
  - spec/fixtures/params/overlay/params/base/network.txt
416
- - spec/fixtures/params/overlay/params/prod/network.txt
502
+ - spec/fixtures/params/overlay/params/development/network.txt
417
503
  - spec/fixtures/raw_templates/aws-waf-security-automations.template
418
504
  - spec/lib/lono/cfn_spec.rb
505
+ - spec/lib/lono/cli_spec.rb
506
+ - spec/lib/lono/completion_spec.rb
419
507
  - spec/lib/lono/inspect_spec.rb
420
- - spec/lib/lono/new_spec.rb
421
508
  - spec/lib/lono/param/generator_spec.rb
422
509
  - spec/lib/lono/param_spec.rb
510
+ - spec/lib/lono/setting_spec.rb
423
511
  - spec/lib/lono/template/dsl_spec.rb
424
- - spec/lib/lono/template/template_spec.rb
425
512
  - spec/lib/lono/template_spec.rb
426
- - spec/lib/lono_spec.rb
427
513
  - spec/spec_helper.rb