lono 7.5.2 → 8.0.0.pre.rc1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (458) hide show
  1. checksums.yaml +4 -4
  2. data/.cody/README.md +5 -15
  3. data/.cody/acceptance/bin/build.sh +52 -0
  4. data/.cody/acceptance/buildspec.yml +10 -0
  5. data/.cody/acceptance/project.rb +6 -0
  6. data/.cody/{role.rb → acceptance/role.rb} +0 -0
  7. data/.cody/shared/script/install/lono.sh +40 -0
  8. data/.cody/shared/script/install.sh +5 -0
  9. data/CHANGELOG.md +21 -4
  10. data/CONTRIBUTING.md +2 -2
  11. data/Gemfile +5 -1
  12. data/LICENSE.txt +201 -1
  13. data/README.md +4 -4
  14. data/lib/lono/api/client.rb +3 -2
  15. data/lib/lono/app/inits.rb +13 -0
  16. data/lib/lono/app.rb +71 -0
  17. data/lib/lono/app_file/base.rb +1 -1
  18. data/lib/lono/app_file/build/lambda_layer/ruby_packager.rb +9 -9
  19. data/lib/lono/app_file/build/lambda_layer.rb +3 -3
  20. data/lib/lono/app_file/build.rb +9 -14
  21. data/lib/lono/app_file/registry/item.rb +4 -4
  22. data/lib/lono/app_file/upload.rb +1 -1
  23. data/lib/lono/autoloader.rb +2 -2
  24. data/lib/lono/aws_services/helper.rb +43 -6
  25. data/lib/lono/aws_services.rb +37 -6
  26. data/lib/lono/blueprint.rb +18 -9
  27. data/lib/lono/booter.rb +28 -0
  28. data/lib/lono/{template → builder}/context/helpers.rb +1 -1
  29. data/lib/lono/{template → builder}/context/loader/load_files.rb +5 -6
  30. data/lib/lono/builder/context/loader.rb +35 -0
  31. data/lib/lono/builder/context/params.rb +7 -0
  32. data/lib/lono/{template → builder}/context/ssm_fetcher.rb +1 -1
  33. data/lib/lono/{template → builder}/context.rb +5 -9
  34. data/lib/lono/{param/generator.rb → builder/param.rb} +21 -22
  35. data/lib/lono/builder/template/aws_service.rb +15 -0
  36. data/lib/lono/builder/template/bashify.rb +43 -0
  37. data/lib/lono/{template → builder/template}/configset_injector.rb +4 -4
  38. data/lib/lono/{template/strategy/dsl/builder → builder/template/dsl/evaluator}/fn.rb +2 -2
  39. data/lib/lono/{template/strategy/dsl/builder → builder/template/dsl/evaluator}/helpers/core_helper.rb +1 -1
  40. data/lib/lono/{template/strategy/dsl/builder → builder/template/dsl/evaluator}/helpers/ec2_helper.rb +1 -1
  41. data/lib/lono/{template/strategy/dsl/builder → builder/template/dsl/evaluator}/helpers/file_helper.rb +8 -12
  42. data/lib/lono/{template/strategy/dsl/builder → builder/template/dsl/evaluator}/helpers/s3_helper.rb +2 -2
  43. data/lib/lono/{template/strategy/dsl/builder → builder/template/dsl/evaluator}/helpers/stack_helper.rb +11 -8
  44. data/lib/lono/{template/strategy/dsl/builder → builder/template/dsl/evaluator}/helpers/tags_helper.rb +1 -1
  45. data/lib/lono/{template/strategy/dsl/builder → builder/template/dsl/evaluator}/helpers.rb +2 -2
  46. data/lib/lono/builder/template/dsl/evaluator/section/base.rb +23 -0
  47. data/lib/lono/{template/strategy/dsl/builder → builder/template/dsl/evaluator}/section/condition.rb +1 -1
  48. data/lib/lono/{template/strategy/dsl/builder → builder/template/dsl/evaluator}/section/mapping.rb +1 -1
  49. data/lib/lono/{template/strategy/dsl/builder → builder/template/dsl/evaluator}/section/methods.rb +7 -7
  50. data/lib/lono/{template/strategy/dsl/builder → builder/template/dsl/evaluator}/section/output.rb +1 -1
  51. data/lib/lono/{template/strategy/dsl/builder → builder/template/dsl/evaluator}/section/parameter.rb +1 -1
  52. data/lib/lono/{template/strategy/dsl/builder → builder/template/dsl/evaluator}/section/resource/property_mover.rb +1 -1
  53. data/lib/lono/{template/strategy/dsl/builder → builder/template/dsl/evaluator}/section/resource.rb +1 -1
  54. data/lib/lono/{template/strategy/dsl/builder → builder/template/dsl/evaluator}/section/section.rb +1 -1
  55. data/lib/lono/{template/strategy/dsl/builder → builder/template/dsl/evaluator}/squeezer.rb +1 -1
  56. data/lib/lono/{template/strategy/dsl/builder → builder/template/dsl/evaluator}/stringify.rb +1 -1
  57. data/lib/lono/{template/strategy/dsl/builder → builder/template/dsl/evaluator}/syntax/extend_with.rb +1 -1
  58. data/lib/lono/{template/strategy/dsl/builder → builder/template/dsl/evaluator}/syntax/parameter_group.rb +1 -1
  59. data/lib/lono/{template/strategy/dsl/builder → builder/template/dsl/evaluator}/syntax.rb +3 -3
  60. data/lib/lono/builder/template/dsl/evaluator.rb +45 -0
  61. data/lib/lono/{template/strategy → builder/template}/dsl/finalizer/parameter_groups.rb +2 -2
  62. data/lib/lono/{template/strategy → builder/template}/dsl/finalizer.rb +1 -1
  63. data/lib/lono/builder/template/dsl.rb +14 -0
  64. data/lib/lono/{template → builder/template}/evaluate.rb +18 -6
  65. data/lib/lono/builder/template/helpers.rb +149 -0
  66. data/lib/lono/{output/template.rb → builder/template/output.rb} +14 -7
  67. data/lib/lono/{template → builder/template}/post_processor.rb +4 -4
  68. data/lib/lono/{template → builder/template}/upload.rb +3 -5
  69. data/lib/lono/builder/template.rb +55 -0
  70. data/lib/lono/bundler/cli/base.rb +10 -0
  71. data/lib/lono/bundler/cli/bundle.rb +44 -0
  72. data/lib/lono/bundler/cli/clean.rb +27 -0
  73. data/lib/lono/bundler/cli/help/bundle.md +3 -0
  74. data/lib/lono/bundler/cli/help.rb +11 -0
  75. data/lib/lono/bundler/cli.rb +7 -0
  76. data/lib/lono/bundler/component/concerns/local_concern.rb +10 -0
  77. data/lib/lono/bundler/component/concerns/notation_concern.rb +59 -0
  78. data/lib/lono/bundler/component/concerns/path_concern.rb +68 -0
  79. data/lib/lono/bundler/component/concerns/stack_concern.rb +60 -0
  80. data/lib/lono/bundler/component/fetcher/base.rb +27 -0
  81. data/lib/lono/bundler/component/fetcher/gcs.rb +69 -0
  82. data/lib/lono/bundler/component/fetcher/git.rb +69 -0
  83. data/lib/lono/bundler/component/fetcher/local.rb +15 -0
  84. data/lib/lono/bundler/component/fetcher/s3.rb +66 -0
  85. data/lib/lono/bundler/component/fetcher.rb +18 -0
  86. data/lib/lono/bundler/component/http/concern.rb +45 -0
  87. data/lib/lono/bundler/component/http/source.rb +19 -0
  88. data/lib/lono/bundler/component/org_repo.rb +65 -0
  89. data/lib/lono/bundler/component/props/extension.rb +19 -0
  90. data/lib/lono/bundler/component/props/typer.rb +41 -0
  91. data/lib/lono/bundler/component/props.rb +122 -0
  92. data/lib/lono/bundler/component/registry.rb +136 -0
  93. data/lib/lono/bundler/component.rb +52 -0
  94. data/lib/lono/bundler/config.rb +18 -0
  95. data/lib/lono/bundler/dsl/syntax.rb +46 -0
  96. data/lib/lono/bundler/dsl.rb +21 -0
  97. data/lib/lono/bundler/exporter/base.rb +6 -0
  98. data/lib/lono/bundler/exporter/copy.rb +22 -0
  99. data/lib/lono/bundler/exporter.rb +50 -0
  100. data/lib/lono/bundler/extract/tar.rb +34 -0
  101. data/lib/lono/bundler/extract/zip.rb +16 -0
  102. data/lib/lono/bundler/info.rb +39 -0
  103. data/lib/lono/bundler/list.rb +26 -0
  104. data/lib/lono/bundler/lockfile/version_comparer.rb +56 -0
  105. data/lib/lono/bundler/lockfile/yamler.rb +36 -0
  106. data/lib/lono/bundler/lockfile.rb +66 -0
  107. data/lib/lono/bundler/lonofile.rb +32 -0
  108. data/lib/lono/bundler/runner.rb +27 -0
  109. data/lib/lono/bundler/syncer.rb +70 -0
  110. data/lib/lono/bundler/util/git.rb +37 -0
  111. data/lib/lono/bundler/util/logging.rb +7 -0
  112. data/lib/lono/bundler/util/sure.rb +5 -0
  113. data/lib/lono/{bundle.rb → bundler.rb} +38 -4
  114. data/lib/lono/cfn/base.rb +9 -195
  115. data/lib/lono/cfn/cancel.rb +9 -26
  116. data/lib/lono/cfn/concerns/build.rb +10 -0
  117. data/lib/lono/cfn/concerns/template_output.rb +10 -0
  118. data/lib/lono/cfn/concerns.rb +43 -0
  119. data/lib/lono/cfn/delete.rb +8 -32
  120. data/lib/lono/cfn/deploy/base.rb +4 -0
  121. data/lib/lono/cfn/deploy/iam.rb +49 -0
  122. data/lib/lono/cfn/deploy/notification.rb +8 -0
  123. data/lib/lono/cfn/deploy/operable.rb +18 -0
  124. data/lib/lono/cfn/deploy/opts.rb +49 -0
  125. data/lib/lono/cfn/deploy/rollback.rb +46 -0
  126. data/lib/lono/cfn/deploy/tags.rb +18 -0
  127. data/lib/lono/cfn/deploy.rb +71 -5
  128. data/lib/lono/cfn/download.rb +5 -7
  129. data/lib/lono/cfn/output.rb +49 -0
  130. data/lib/lono/cfn/plan/base.rb +19 -0
  131. data/lib/lono/cfn/plan/changeset/base.rb +19 -0
  132. data/lib/lono/cfn/plan/changeset/notifications.rb +24 -0
  133. data/lib/lono/cfn/plan/changeset/outputs.rb +25 -0
  134. data/lib/lono/cfn/plan/changeset/resources.rb +48 -0
  135. data/lib/lono/cfn/plan/changeset/tags.rb +16 -0
  136. data/lib/lono/cfn/plan/changeset.rb +136 -0
  137. data/lib/lono/cfn/plan/concerns.rb +10 -0
  138. data/lib/lono/cfn/plan/delete.rb +16 -0
  139. data/lib/lono/cfn/plan/diff/base.rb +10 -0
  140. data/lib/lono/cfn/plan/diff/data.rb +52 -0
  141. data/lib/lono/cfn/plan/diff/file.rb +56 -0
  142. data/lib/lono/cfn/plan/new.rb +26 -0
  143. data/lib/lono/cfn/{preview → plan}/param.rb +26 -34
  144. data/lib/lono/cfn/plan/summary.rb +16 -0
  145. data/lib/lono/cfn/plan/template.rb +28 -0
  146. data/lib/lono/cfn/plan.rb +33 -0
  147. data/lib/lono/cfn/show.rb +30 -0
  148. data/lib/lono/cfn/status.rb +1 -1
  149. data/lib/lono/cli/abstract.rb +17 -0
  150. data/lib/lono/cli/base.rb +9 -0
  151. data/lib/lono/cli/build.rb +101 -0
  152. data/lib/lono/cli/bundle.rb +21 -0
  153. data/lib/lono/cli/cfn/opts.rb +59 -0
  154. data/lib/lono/cli/cfn.rb +19 -0
  155. data/lib/lono/cli/clean.rb +22 -0
  156. data/lib/lono/{code.rb → cli/code.rb} +2 -2
  157. data/lib/lono/{completion.rb → cli/completion.rb} +2 -2
  158. data/lib/lono/{help → cli/help}/blueprint/new.md +4 -4
  159. data/lib/lono/{help/generate.md → cli/help/build.md} +6 -6
  160. data/lib/lono/{help → cli/help}/cfn/cancel.md +0 -0
  161. data/lib/lono/cli/help/cfn/download.md +3 -0
  162. data/lib/lono/{help → cli/help}/cfn/preview.md +9 -8
  163. data/lib/lono/{help → cli/help}/cfn/status.md +0 -0
  164. data/lib/lono/cli/help/cfn.md +4 -0
  165. data/lib/lono/{help → cli/help}/code/convert.md +0 -0
  166. data/lib/lono/{help → cli/help}/code/import.md +2 -2
  167. data/lib/lono/{help → cli/help}/completion.md +3 -3
  168. data/lib/lono/{help → cli/help}/completion_script.md +0 -0
  169. data/lib/lono/{help → cli/help}/configsets.md +0 -0
  170. data/lib/lono/cli/help/down.md +13 -0
  171. data/lib/lono/cli/help/new/project.md +34 -0
  172. data/lib/lono/{help → cli/help}/param/generate.md +0 -0
  173. data/lib/lono/cli/help/param.md +6 -0
  174. data/lib/lono/{help → cli/help}/pro/blueprints.md +0 -0
  175. data/lib/lono/{help → cli/help}/pro/configsets.md +0 -0
  176. data/lib/lono/{help → cli/help}/script/build.md +0 -0
  177. data/lib/lono/{help → cli/help}/script/upload.md +0 -0
  178. data/lib/lono/{help → cli/help}/seed.md +2 -2
  179. data/lib/lono/cli/help/summary.md +33 -0
  180. data/lib/lono/{help → cli/help}/template/bashify.md +0 -0
  181. data/lib/lono/cli/help/template/generate.md +7 -0
  182. data/lib/lono/{help → cli/help}/template.md +0 -0
  183. data/lib/lono/cli/help/up.md +30 -0
  184. data/lib/lono/{help → cli/help}/user_data.md +3 -3
  185. data/lib/lono/cli/help.rb +56 -0
  186. data/lib/lono/cli/list.rb +28 -0
  187. data/lib/lono/cli/new/blueprint.rb +33 -0
  188. data/lib/lono/cli/new/concerns.rb +16 -0
  189. data/lib/lono/{configset/new.rb → cli/new/configset.rb} +2 -9
  190. data/lib/lono/{extension/new.rb → cli/new/extension.rb} +2 -10
  191. data/lib/lono/cli/new/helper.rb +32 -0
  192. data/lib/lono/cli/new/project.rb +77 -0
  193. data/lib/lono/cli/new/sequence.rb +51 -0
  194. data/lib/lono/cli/new/shim.rb +59 -0
  195. data/lib/lono/cli/new/test/blueprint.rb +23 -0
  196. data/lib/lono/cli/new/test/sequence.rb +10 -0
  197. data/lib/lono/cli/new/test.rb +8 -0
  198. data/lib/lono/cli/new.rb +31 -0
  199. data/lib/lono/{opts.rb → cli/opts.rb} +9 -12
  200. data/lib/lono/{s3.rb → cli/s3.rb} +9 -7
  201. data/lib/lono/cli/script/base.rb +5 -0
  202. data/lib/lono/cli/script/build.rb +72 -0
  203. data/lib/lono/cli/script/upload.rb +49 -0
  204. data/lib/lono/{script.rb → cli/script.rb} +2 -2
  205. data/lib/lono/cli/seed.rb +9 -0
  206. data/lib/lono/cli/test.rb +35 -0
  207. data/lib/lono/cli.rb +80 -109
  208. data/lib/lono/command.rb +27 -0
  209. data/lib/lono/configset/{generator.rb → builder.rb} +9 -7
  210. data/lib/lono/configset/combiner.rb +8 -6
  211. data/lib/lono/configset/evaluate_file.rb +1 -1
  212. data/lib/lono/configset/meta.rb +1 -1
  213. data/lib/lono/configset/s3_file/build.rb +5 -4
  214. data/lib/lono/configset/s3_file/item.rb +1 -1
  215. data/lib/lono/configset/s3_file/upload.rb +2 -2
  216. data/lib/lono/configset/strategy/base.rb +6 -6
  217. data/lib/lono/configset/strategy/helpers/dsl/core.rb +1 -1
  218. data/lib/lono/core.rb +25 -54
  219. data/lib/lono/extensions/dsl.rb +2 -5
  220. data/lib/lono/extensions/loader.rb +1 -12
  221. data/lib/lono/extensions.rb +2 -2
  222. data/lib/lono/importer/base.rb +5 -5
  223. data/lib/lono/importer/download.rb +7 -7
  224. data/lib/lono/importer/dsl.rb +3 -3
  225. data/lib/lono/importer/service/coder.rb +10 -10
  226. data/lib/lono/importer.rb +1 -10
  227. data/lib/lono/inspector/base.rb +7 -7
  228. data/lib/lono/inspector/summary.rb +19 -17
  229. data/lib/lono/layering/layer.rb +126 -0
  230. data/lib/lono/layering.rb +13 -55
  231. data/lib/lono/logger/formatter.rb +13 -0
  232. data/lib/lono/logger.rb +33 -0
  233. data/lib/lono/lookup.rb +12 -0
  234. data/lib/lono/names.rb +50 -0
  235. data/lib/lono/plugin/meta.rb +30 -0
  236. data/lib/lono/plugin/tester.rb +13 -0
  237. data/lib/lono/plugin.rb +10 -0
  238. data/lib/lono/s3/aws_setup.rb +4 -3
  239. data/lib/lono/s3/bucket.rb +19 -19
  240. data/lib/lono/s3/uploader.rb +10 -12
  241. data/lib/lono/script/base.rb +3 -3
  242. data/lib/lono/script/build.rb +11 -12
  243. data/lib/lono/script/upload.rb +7 -7
  244. data/lib/lono/{seed → seeder}/service_role.rb +1 -1
  245. data/lib/lono/{seed/base.rb → seeder.rb} +21 -36
  246. data/lib/lono/user_data.rb +8 -13
  247. data/lib/lono/utils/context.rb +15 -0
  248. data/lib/lono/utils/item/zip.rb +5 -5
  249. data/lib/lono/utils/logging.rb +7 -0
  250. data/lib/lono/utils/{pretty_time.rb → pretty.rb} +6 -2
  251. data/lib/lono/utils/quit.rb +7 -0
  252. data/lib/lono/utils/rsync.rb +4 -2
  253. data/lib/lono/utils/sure.rb +4 -4
  254. data/lib/lono/version.rb +1 -1
  255. data/lib/lono.rb +7 -12
  256. data/lib/templates/blueprint/template.rb +2 -0
  257. data/lib/templates/configset/{lib/configset.rb → configset.rb} +0 -0
  258. data/lib/templates/examples/blueprint/template.rb +9 -0
  259. data/lib/templates/helper/%underscore_name%_helper.rb.tt +6 -0
  260. data/lib/templates/{skeleton → project}/.gitignore +1 -2
  261. data/lib/templates/project/Gemfile.tt +11 -0
  262. data/lib/templates/project/README.md +9 -0
  263. data/lib/templates/project/config/app.rb +3 -0
  264. data/lib/templates/shim/lono +7 -0
  265. data/lono.gemspec +51 -44
  266. metadata +246 -269
  267. data/.circleci/README.md +0 -3
  268. data/.circleci/config.yml +0 -58
  269. data/.cody/acceptance.sh +0 -49
  270. data/.cody/buildspec.yml +0 -9
  271. data/.cody/demo.rb +0 -38
  272. data/.cody/project.rb +0 -6
  273. data/.gitmodules +0 -3
  274. data/lib/lono/abstract_base.rb +0 -25
  275. data/lib/lono/aws_services/stack.rb +0 -41
  276. data/lib/lono/aws_services/stack_set.rb +0 -41
  277. data/lib/lono/blueprint/configset/loader.rb +0 -7
  278. data/lib/lono/blueprint/helper.rb +0 -24
  279. data/lib/lono/blueprint/meta.rb +0 -30
  280. data/lib/lono/blueprint/new.rb +0 -127
  281. data/lib/lono/blueprint/root.rb +0 -25
  282. data/lib/lono/cfn/create.rb +0 -41
  283. data/lib/lono/cfn/opts.rb +0 -88
  284. data/lib/lono/cfn/preview/changeset.rb +0 -168
  285. data/lib/lono/cfn/preview/codediff.rb +0 -41
  286. data/lib/lono/cfn/preview/diff_viewer.rb +0 -23
  287. data/lib/lono/cfn/rollback.rb +0 -26
  288. data/lib/lono/cfn/update.rb +0 -71
  289. data/lib/lono/cfn.rb +0 -75
  290. data/lib/lono/clean.rb +0 -14
  291. data/lib/lono/configset/list.rb +0 -67
  292. data/lib/lono/configset/preparer.rb +0 -44
  293. data/lib/lono/configset/register/base.rb +0 -122
  294. data/lib/lono/configset/register/blueprint.rb +0 -16
  295. data/lib/lono/configset/register/dsl.rb +0 -14
  296. data/lib/lono/configset/register/project.rb +0 -13
  297. data/lib/lono/configset/resolver.rb +0 -47
  298. data/lib/lono/configset.rb +0 -16
  299. data/lib/lono/conventions.rb +0 -23
  300. data/lib/lono/core/config.rb +0 -22
  301. data/lib/lono/default/settings.yml +0 -21
  302. data/lib/lono/ext/bundler.rb +0 -7
  303. data/lib/lono/extension/helper.rb +0 -13
  304. data/lib/lono/extension/list.rb +0 -40
  305. data/lib/lono/extension.rb +0 -9
  306. data/lib/lono/extensions/preparer.rb +0 -26
  307. data/lib/lono/extensions/register.rb +0 -15
  308. data/lib/lono/file_uploader.rb +0 -21
  309. data/lib/lono/finder/base.rb +0 -152
  310. data/lib/lono/finder/blueprint/configset.rb +0 -17
  311. data/lib/lono/finder/blueprint.rb +0 -11
  312. data/lib/lono/finder/configset.rb +0 -11
  313. data/lib/lono/finder/extension.rb +0 -11
  314. data/lib/lono/generate.rb +0 -111
  315. data/lib/lono/help/cfn/create.md +0 -26
  316. data/lib/lono/help/cfn/delete.md +0 -13
  317. data/lib/lono/help/cfn/deploy.md +0 -21
  318. data/lib/lono/help/cfn/download.md +0 -3
  319. data/lib/lono/help/cfn/update.md +0 -49
  320. data/lib/lono/help/cfn.md +0 -7
  321. data/lib/lono/help/new.md +0 -57
  322. data/lib/lono/help/param.md +0 -6
  323. data/lib/lono/help/set_instances/delete.md +0 -21
  324. data/lib/lono/help/set_instances/deploy.md +0 -31
  325. data/lib/lono/help/set_instances/list.md +0 -14
  326. data/lib/lono/help/set_instances/status.md +0 -15
  327. data/lib/lono/help/set_instances/sync.md +0 -92
  328. data/lib/lono/help/sets/delete.md +0 -8
  329. data/lib/lono/help/sets/deploy.md +0 -76
  330. data/lib/lono/help/sets/status.md +0 -23
  331. data/lib/lono/help/summary.md +0 -33
  332. data/lib/lono/help/template/generate.md +0 -7
  333. data/lib/lono/help/upgrade.md +0 -1
  334. data/lib/lono/help/xgraph.md +0 -16
  335. data/lib/lono/help.rb +0 -15
  336. data/lib/lono/importer/erb.rb +0 -31
  337. data/lib/lono/inspector/graph.rb +0 -125
  338. data/lib/lono/jade/circular.rb +0 -26
  339. data/lib/lono/jade/materializer/final.rb +0 -10
  340. data/lib/lono/jade/materializer/gems_builder.rb +0 -81
  341. data/lib/lono/jade/materializer/source.rb +0 -54
  342. data/lib/lono/jade/materializer.rb +0 -15
  343. data/lib/lono/jade/registry.rb +0 -64
  344. data/lib/lono/jade.rb +0 -110
  345. data/lib/lono/jadespec.rb +0 -68
  346. data/lib/lono/new/helper.rb +0 -15
  347. data/lib/lono/new.rb +0 -95
  348. data/lib/lono/param.rb +0 -14
  349. data/lib/lono/pro/base.rb +0 -16
  350. data/lib/lono/pro/repo.rb +0 -28
  351. data/lib/lono/pro.rb +0 -15
  352. data/lib/lono/project_checker.rb +0 -35
  353. data/lib/lono/registration/base.rb +0 -37
  354. data/lib/lono/registration/check.rb +0 -15
  355. data/lib/lono/registration/temp.rb +0 -53
  356. data/lib/lono/registration/user.rb +0 -60
  357. data/lib/lono/seed.rb +0 -39
  358. data/lib/lono/sequence.rb +0 -35
  359. data/lib/lono/set_instances/base.rb +0 -30
  360. data/lib/lono/set_instances/changeable.rb +0 -53
  361. data/lib/lono/set_instances/create.rb +0 -7
  362. data/lib/lono/set_instances/delete.rb +0 -47
  363. data/lib/lono/set_instances/deploy.rb +0 -52
  364. data/lib/lono/set_instances/list.rb +0 -13
  365. data/lib/lono/set_instances/opts.rb +0 -37
  366. data/lib/lono/set_instances/status.rb +0 -12
  367. data/lib/lono/set_instances/sync.rb +0 -181
  368. data/lib/lono/set_instances/update.rb +0 -15
  369. data/lib/lono/set_instances.rb +0 -54
  370. data/lib/lono/sets/base.rb +0 -50
  371. data/lib/lono/sets/create.rb +0 -27
  372. data/lib/lono/sets/delete.rb +0 -43
  373. data/lib/lono/sets/deploy.rb +0 -11
  374. data/lib/lono/sets/list.rb +0 -35
  375. data/lib/lono/sets/opts.rb +0 -18
  376. data/lib/lono/sets/preview/codediff.rb +0 -35
  377. data/lib/lono/sets/preview/param.rb +0 -32
  378. data/lib/lono/sets/status/instance/base.rb +0 -120
  379. data/lib/lono/sets/status/instance/completed.rb +0 -35
  380. data/lib/lono/sets/status/instance/deleted.rb +0 -32
  381. data/lib/lono/sets/status/instance/show.rb +0 -7
  382. data/lib/lono/sets/status/instance.rb +0 -20
  383. data/lib/lono/sets/status/instances.rb +0 -136
  384. data/lib/lono/sets/status.rb +0 -128
  385. data/lib/lono/sets/summarize.rb +0 -22
  386. data/lib/lono/sets/time_spent.rb +0 -11
  387. data/lib/lono/sets/update.rb +0 -74
  388. data/lib/lono/sets/waiter.rb +0 -23
  389. data/lib/lono/sets.rb +0 -34
  390. data/lib/lono/setting.rb +0 -75
  391. data/lib/lono/template/aws_service.rb +0 -20
  392. data/lib/lono/template/bashify.rb +0 -39
  393. data/lib/lono/template/context/loader.rb +0 -52
  394. data/lib/lono/template/generator.rb +0 -23
  395. data/lib/lono/template/helper.rb +0 -152
  396. data/lib/lono/template/strategy/base.rb +0 -4
  397. data/lib/lono/template/strategy/common/helpers.rb +0 -44
  398. data/lib/lono/template/strategy/dsl/builder/section/base.rb +0 -30
  399. data/lib/lono/template/strategy/dsl/builder.rb +0 -59
  400. data/lib/lono/template/strategy/dsl.rb +0 -14
  401. data/lib/lono/template/strategy/erb.rb +0 -82
  402. data/lib/lono/template/strategy/source.rb +0 -8
  403. data/lib/lono/template/template.rb +0 -54
  404. data/lib/lono/template/util.rb +0 -8
  405. data/lib/lono/template.rb +0 -24
  406. data/lib/lono/upgrade.rb +0 -20
  407. data/lib/lono/utils/generators/tree.rb +0 -18
  408. data/lib/templates/blueprint/%blueprint_name%.gemspec.tt +0 -45
  409. data/lib/templates/blueprint/.gitignore +0 -11
  410. data/lib/templates/blueprint/CHANGELOG.md +0 -7
  411. data/lib/templates/blueprint/Gemfile +0 -4
  412. data/lib/templates/blueprint/README.md.tt +0 -33
  413. data/lib/templates/blueprint/Rakefile.tt +0 -9
  414. data/lib/templates/blueprint/seed/configs.rb +0 -28
  415. data/lib/templates/blueprint_types/dsl/app/templates/%blueprint_name%.rb +0 -36
  416. data/lib/templates/blueprint_types/dsl/app/user_data/bootstrap.sh +0 -2
  417. data/lib/templates/blueprint_types/erb/app/definitions/base.rb.tt +0 -1
  418. data/lib/templates/blueprint_types/erb/app/templates/%blueprint_name%.yml +0 -67
  419. data/lib/templates/configset/%configset_name%.gemspec.tt +0 -42
  420. data/lib/templates/configset/.gitignore +0 -10
  421. data/lib/templates/configset/CHANGELOG.md +0 -7
  422. data/lib/templates/configset/Gemfile +0 -4
  423. data/lib/templates/configset/README.md.tt +0 -3
  424. data/lib/templates/configset/Rakefile.tt +0 -9
  425. data/lib/templates/extension/%extension_name%.gemspec.tt +0 -46
  426. data/lib/templates/extension/.gitignore +0 -11
  427. data/lib/templates/extension/.rspec +0 -3
  428. data/lib/templates/extension/CHANGELOG.md +0 -7
  429. data/lib/templates/extension/Gemfile.tt +0 -4
  430. data/lib/templates/extension/Rakefile.tt +0 -9
  431. data/lib/templates/extension/spec/spec_helper.rb.tt +0 -29
  432. data/lib/templates/skeleton/Gemfile +0 -3
  433. data/lib/templates/skeleton/README.md +0 -58
  434. data/lib/templates/skeleton/configs/settings.yml +0 -13
  435. data/vendor/cfn-status/CHANGELOG.md +0 -14
  436. data/vendor/cfn-status/Gemfile +0 -4
  437. data/vendor/cfn-status/Gemfile.lock +0 -49
  438. data/vendor/cfn-status/LICENSE.txt +0 -21
  439. data/vendor/cfn-status/README.md +0 -58
  440. data/vendor/cfn-status/Rakefile +0 -6
  441. data/vendor/cfn-status/bin/console +0 -14
  442. data/vendor/cfn-status/bin/setup +0 -8
  443. data/vendor/cfn-status/cfn-status.gemspec +0 -30
  444. data/vendor/cfn-status/lib/cfn-status.rb +0 -1
  445. data/vendor/cfn-status/lib/cfn_status/aws_service.rb +0 -51
  446. data/vendor/cfn-status/lib/cfn_status/version.rb +0 -3
  447. data/vendor/cfn-status/lib/cfn_status.rb +0 -245
  448. data/vendor/cfn-status/spec/fixtures/cfn/pages/fresh/describe_stack_events-1.json +0 -1103
  449. data/vendor/cfn-status/spec/fixtures/cfn/pages/fresh/describe_stack_events-2.json +0 -1104
  450. data/vendor/cfn-status/spec/fixtures/cfn/pages/fresh/describe_stack_events-3.json +0 -1103
  451. data/vendor/cfn-status/spec/fixtures/cfn/pages/updating/describe_stack_events-1.json +0 -1103
  452. data/vendor/cfn-status/spec/fixtures/cfn/pages/updating/describe_stack_events-2.json +0 -1104
  453. data/vendor/cfn-status/spec/fixtures/cfn/pages/updating/describe_stack_events-3.json +0 -1103
  454. data/vendor/cfn-status/spec/fixtures/cfn/stack-events-complete.json +0 -1080
  455. data/vendor/cfn-status/spec/fixtures/cfn/stack-events-in-progress.json +0 -1080
  456. data/vendor/cfn-status/spec/fixtures/cfn/stack-events-update-rollback-complete.json +0 -1086
  457. data/vendor/cfn-status/spec/lib/cfn_status_spec.rb +0 -153
  458. data/vendor/cfn-status/spec/spec_helper.rb +0 -14
@@ -1,168 +0,0 @@
1
- module Lono::Cfn::Preview
2
- class Changeset < Lono::Cfn::Base
3
- # Override run from Base superclass, the run method is different enough with Preview
4
- def run
5
- puts "Changeset Preview:".color(:green)
6
-
7
- if @options[:noop]
8
- puts "NOOP CloudFormation preview for #{@stack} update"
9
- return
10
- end
11
-
12
- parameters = generate_all
13
- success = preview_change_set(parameters)
14
- delete_change_set if success && !@options[:keep] # Clean up and delete the change set
15
- end
16
-
17
- def preview_change_set(parameters)
18
- success = create_change_set(parameters)
19
- display_change_set if success
20
- end
21
-
22
- def create_change_set(parameters)
23
- unless stack_exists?(@stack)
24
- puts "WARN: Cannot create a change set for the stack because the #{@stack} does not exists.".color(:yellow)
25
- return false
26
- end
27
- exit_unless_updatable!
28
-
29
- options = {
30
- change_set_name: change_set_name,
31
- stack_name: @stack,
32
- parameters: parameters,
33
- }
34
- options[:notification_arns] = notification_arns if notification_arns
35
- options[:tags] = tags unless tags.empty?
36
- set_template_url!(options)
37
- show_options(options, "cfn.create_change_set")
38
- begin
39
- # Tricky for preview need to set capabilities so that it gets updated. For Base#run save within the begin block already.
40
- options[:capabilities] = capabilities # ["CAPABILITY_IAM", "CAPABILITY_NAMED_IAM"]
41
- cfn.create_change_set(options)
42
- rescue Aws::CloudFormation::Errors::InsufficientCapabilitiesException => e
43
- # If coming from cfn_preview_command automatically add iam capabilities
44
- cfn_preview_command = ARGV.join(" ").include?("cfn preview")
45
- if cfn_preview_command
46
- # e.message is "Requires capabilities : [CAPABILITY_IAM]"
47
- # grab CAPABILITY_IAM with regexp
48
- capabilities = e.message.match(/\[(.*)\]/)[1]
49
- @options.merge!(capabilities: [capabilities])
50
- retry
51
- end
52
- yes = rerun_with_iam?(e)
53
- retry if yes
54
- rescue Aws::CloudFormation::Errors::ValidationError => e
55
- handle_error(e)
56
- end
57
- true
58
- end
59
-
60
- # Example errors:
61
- # "Template error: variable names in Fn::Sub syntax must contain only alphanumeric characters, underscores, periods, and colons"
62
- def handle_error(e)
63
- raise if ENV['FULL_BACKTRACE']
64
-
65
- if e.message =~ /^Parameters: / || e.message =~ /^Template error: /
66
- puts "Error creating CloudFormation preview because invalid CloudFormation parameters. Full error message:".color(:red)
67
- puts e.message
68
- puts "For full backtrace run command again with FULL_BACKTRACE=1"
69
- quit(1)
70
- else
71
- raise
72
- end
73
- end
74
-
75
- def display_change_set
76
- print "Generating CloudFormation Change Set for preview.."
77
- change_set = describe_change_set
78
- until change_set_finished?(change_set) do
79
- change_set = describe_change_set
80
- sleep 1
81
- print '.'
82
- end
83
- puts
84
-
85
- case change_set.status
86
- when "CREATE_COMPLETE"
87
- puts "CloudFormation preview for '#{@stack}' stack update. Changes:"
88
- changes = change_set.changes.sort_by do |change|
89
- change["resource_change"]["action"]
90
- end
91
- changes.each do |change|
92
- display_change(change)
93
- end
94
- when "FAILED"
95
- puts "WARN: Fail to create a CloudFormation preview for '#{@stack}' stack update. Reason:".color(:yellow)
96
- puts change_set.status_reason
97
- quit(0)
98
- else
99
- raise "hell: never come here"
100
- end
101
- end
102
-
103
- def delete_change_set
104
- cfn.delete_change_set(
105
- change_set_name: change_set_name,
106
- stack_name: @stack
107
- )
108
- end
109
-
110
- def execute_change_set
111
- cfn.execute_change_set(
112
- change_set_name: change_set_name,
113
- stack_name: @stack
114
- )
115
- end
116
-
117
- # generates a change set name
118
- def change_set_name
119
- @change_set_name ||= "changeset-#{Time.now.strftime("%Y%d%m%H%M%S")}"
120
- end
121
-
122
- private
123
- # Private: formats a Aws::CloudFormation::Types::Change in pretty human readable form
124
- #
125
- # change - Aws::CloudFormation::Types::Change
126
- #
127
- # Examples
128
- #
129
- # display_change(change)
130
- # => Remove AWS::Route53::RecordSet: DnsRecord testsubdomain.sub.tongueroo.com
131
- #
132
- # Returns nil
133
- #
134
- # change.to_h
135
- # {:type=>"Resource",
136
- # :resource_change=>
137
- # {:action=>"Remove",
138
- # :logical_resource_id=>"DnsRecord",
139
- # :physical_resource_id=>"testsubdomain.sub.tongueroo.com",
140
- # :resource_type=>"AWS::Route53::RecordSet",
141
- # :scope=>[],
142
- # :details=>[]}}
143
- def display_change(change)
144
- message = if change.type == "Resource"
145
- c = change.resource_change
146
- "#{c.action} #{c.resource_type}: #{c.logical_resource_id} #{c.physical_resource_id}"
147
- else
148
- change.to_h
149
- end
150
-
151
- colors = { Remove: :red, Add: :green, Modify: :yellow }
152
- action = change.resource_change.action.to_sym
153
- message = message.color(colors[action]) if colors.has_key?(action)
154
- puts message
155
- end
156
-
157
- def change_set_finished?(change_set)
158
- change_set.status =~ /_COMPLETE/ || change_set.status == "FAILED"
159
- end
160
-
161
- def describe_change_set
162
- cfn.describe_change_set(
163
- change_set_name: change_set_name,
164
- stack_name: @stack
165
- )
166
- end
167
- end
168
- end
@@ -1,41 +0,0 @@
1
- module Lono::Cfn::Preview
2
- class Codediff < Lono::Cfn::Base
3
- include DiffViewer
4
- include Lono::AwsServices
5
-
6
- def run
7
- puts "Code Diff Preview:".color(:green)
8
-
9
- unless stack_exists?(@stack)
10
- puts "WARN: Cannot create a diff for the stack because the #{@stack} does not exists.".color(:yellow)
11
- return
12
- end
13
-
14
- if @options[:noop]
15
- puts "NOOP Generating CloudFormation source code diff..."
16
- else
17
- generate_all # from Base superclass. Generates the output lono teplates
18
- puts "Generating CloudFormation source code diff..."
19
- download_existing_cfn_template
20
- show_diff(existing_template_path, new_cfn_template)
21
- end
22
- end
23
-
24
- def download_existing_cfn_template
25
- resp = cfn.get_template(
26
- stack_name: @stack,
27
- template_stage: "Original"
28
- )
29
- IO.write(existing_template_path, resp.template_body)
30
- end
31
-
32
- # for clarity
33
- def new_cfn_template
34
- template_path
35
- end
36
-
37
- def existing_template_path
38
- "/tmp/existing_stack.yml"
39
- end
40
- end
41
- end
@@ -1,23 +0,0 @@
1
- module Lono::Cfn::Preview
2
- module DiffViewer
3
- def show_diff(existing_path, new_path)
4
- command = "#{diff_viewer} #{existing_path} #{new_path}"
5
- puts "Running: #{command}"
6
- out = `#{command}`
7
- if out.strip == ''
8
- puts "There were no differences."
9
- else
10
- puts out
11
- end
12
- end
13
-
14
- def diff_viewer
15
- return ENV['LONO_DIFF'] if ENV['LONO_DIFF']
16
- colordiff_installed = system("type colordiff > /dev/null 2>&1")
17
- unless colordiff_installed
18
- puts "INFO: colordiff it not available. Recommend installing it."
19
- end
20
- colordiff_installed ? "colordiff" : "diff"
21
- end
22
- end
23
- end
@@ -1,26 +0,0 @@
1
- class Lono::Cfn
2
- class Rollback
3
- extend Memoist
4
- include Lono::AwsServices
5
-
6
- def initialize(stack)
7
- @stack = stack
8
- end
9
-
10
- def delete_stack
11
- stack = find_stack(@stack)
12
- if stack && rollback_complete?(stack)
13
- puts "Existing stack in ROLLBACK_COMPLETE state. Deleting stack before continuing."
14
- cfn.delete_stack(stack_name: @stack)
15
- status.wait
16
- status.reset
17
- true
18
- end
19
- end
20
-
21
- def status
22
- Lono::Cfn::Status.new(@stack)
23
- end
24
- memoize :status
25
- end
26
- end
@@ -1,71 +0,0 @@
1
- class Lono::Cfn
2
- class Update < Base
3
- # save is the interface method
4
- # aws cloudformation update-stack --stack-name prod-hi-123456789 --parameters file://output/params/prod-hi-123456789.json --template-body file://output/prod-hi.json
5
- def save(parameters)
6
- message = "Updating #{@stack} stack"
7
- if @options[:noop]
8
- puts "NOOP #{message}"
9
- return
10
- end
11
-
12
- deleted = delete_rollback_stack
13
- if deleted
14
- Create.new(@options).save(parameters)
15
- return
16
- end
17
-
18
- unless stack_exists?(@stack)
19
- puts "Cannot update a stack because the #{@stack} does not exists."
20
- return
21
- end
22
- exit_unless_updatable!
23
-
24
- options = @options.merge(mute_params: true, mute_using: true, keep: true)
25
- # create new copy of preview when update_stack is called because of IAM retry logic
26
- changeset_preview = Lono::Cfn::Preview::Changeset.new(options)
27
-
28
- param_preview.run if @options[:param_preview]
29
- codediff_preview.run if @options[:codediff_preview]
30
- changeset_preview.run if @options[:changeset_preview]
31
- sure?("Are you sure you want to update the #{@stack} stack?")
32
-
33
- if @options[:change_set] # defaults to this
34
- message << " via change set: #{changeset_preview.change_set_name}"
35
- changeset_preview.execute_change_set
36
- else
37
- standard_update(parameters)
38
- end
39
- puts message unless @options[:mute]
40
- end
41
-
42
- def standard_update(parameters)
43
- options = {
44
- stack_name: @stack,
45
- parameters: parameters,
46
- capabilities: capabilities, # ["CAPABILITY_IAM", "CAPABILITY_NAMED_IAM"]
47
- disable_rollback: !@options[:rollback],
48
- }
49
- options[:notification_arns] = notification_arns if notification_arns
50
- options[:tags] = tags unless tags.empty?
51
- set_template_url!(options)
52
- show_options(options, "cfn.update_stack")
53
- begin
54
- cfn.update_stack(options)
55
- rescue Aws::CloudFormation::Errors::ValidationError => e
56
- puts "ERROR: #{e.message}".color(:red)
57
- false
58
- end
59
- end
60
-
61
- def codediff_preview
62
- Lono::Cfn::Preview::Codediff.new(@options.merge(mute_params: true, mute_using: true))
63
- end
64
- memoize :codediff_preview
65
-
66
- def param_preview
67
- Lono::Cfn::Preview::Param.new(@options)
68
- end
69
- memoize :param_preview
70
- end
71
- end
data/lib/lono/cfn.rb DELETED
@@ -1,75 +0,0 @@
1
- module Lono
2
- class Cfn < Command
3
- opts = Opts.new(self)
4
-
5
- class_option :verbose, type: :boolean
6
- class_option :noop, type: :boolean
7
-
8
- desc "create STACK", "Create a CloudFormation stack using the generated template.", hide: true
9
- opts.create
10
- long_desc Lono::Help.text("cfn/create")
11
- def create(stack)
12
- Create.new(options.merge(stack: stack)).run
13
- end
14
-
15
- desc "update STACK", "Update a CloudFormation stack using the generated template.", hide: true
16
- long_desc Lono::Help.text("cfn/update")
17
- opts.update
18
- def update(stack)
19
- Update.new(options.merge(stack: stack)).run
20
- end
21
-
22
- desc "deploy STACK", "Create or update a CloudFormation stack using the generated template."
23
- long_desc Lono::Help.text("cfn/deploy")
24
- opts.deploy
25
- def deploy(stack)
26
- Deploy.new(options.merge(stack: stack)).run
27
- end
28
-
29
- desc "delete STACK", "Delete CloudFormation stack."
30
- long_desc Lono::Help.text("cfn/delete")
31
- opts.delete
32
- def delete(stack)
33
- Delete.new(options.merge(stack: stack)).run
34
- end
35
-
36
- desc "cancel STACK", "Cancel a CloudFormation stack."
37
- long_desc Lono::Help.text("cfn/cancel")
38
- opts.cancel
39
- def cancel(stack)
40
- Cancel.new(options.merge(stack: stack)).run
41
- end
42
-
43
- desc "preview STACK", "Preview a CloudFormation stack update. This is similar to terraform's plan or puppet's dry-run mode."
44
- long_desc Lono::Help.text("cfn/preview")
45
- opts.preview
46
- def preview(stack)
47
- Preview::Param.new(options.merge(stack: stack)).run if options[:param_preview]
48
- Preview::Codediff.new(options.merge(stack: stack)).run if options[:codediff_preview]
49
- Preview::Changeset.new(options.merge(stack: stack)).run if options[:changeset_preview]
50
- end
51
-
52
- desc "download STACK", "Download CloudFormation template from existing stack."
53
- long_desc Lono::Help.text("cfn/download")
54
- opts.download
55
- def download(stack)
56
- Download.new(options.merge(stack: stack)).run
57
- end
58
-
59
- desc "current", "Current stack that you're working with."
60
- long_desc Lono::Help.text("cfn/current")
61
- option :rm, type: :boolean, desc: "Remove all current settings. Removes `.lono/current`"
62
- option :name, desc: "Current stack name."
63
- def current
64
- Current.new(options).run
65
- end
66
-
67
- desc "status", "Shows current status of stack."
68
- long_desc Lono::Help.text("cfn/status")
69
- def status(stack)
70
- status = Lono::Cfn::Status.new(stack, options)
71
- success = status.run
72
- exit 3 unless success
73
- end
74
- end
75
- end
data/lib/lono/clean.rb DELETED
@@ -1,14 +0,0 @@
1
- require "fileutils"
2
-
3
- class Lono::Clean
4
- attr_reader :options
5
- def initialize(options={})
6
- @options = options
7
- end
8
-
9
- def run
10
- puts "Clean: removing output/ and tmp/ folder"
11
- FileUtils.rm_rf("#{Lono.config.output_path}")
12
- FileUtils.rm_rf("#{Lono.root}/tmp")
13
- end
14
- end
@@ -1,67 +0,0 @@
1
- require "text-table"
2
-
3
- class Lono::Configset
4
- class List
5
- def initialize(options={})
6
- @options = options
7
- @stack, @blueprint, @template, @param = Lono::Conventions.new(options).values
8
- end
9
-
10
- def run
11
- if @blueprint
12
- blueprint_configsets
13
- else
14
- project_configsets
15
- end
16
- end
17
-
18
- def project_configsets
19
- Lono::Finder::Configset.list(filter_materialized: true, message: "Project configsets:")
20
- end
21
-
22
- def blueprint_configsets
23
- Lono::Configset::Preparer.new(@options).run # register and materialize gems
24
-
25
- @final ||= []
26
-
27
- project = Lono::Configset::Register::Project.new(@options)
28
- project.register
29
- finder = Lono::Finder::Configset.new
30
- finder.list("Configsets available to project and can used with configs:") if @options[:verbose]
31
- puts "Configsets project is using for the #{@blueprint} blueprint:" if @options[:verbose]
32
- show(project.configsets, finder.find_all, "project")
33
-
34
- blueprint = Lono::Configset::Register::Blueprint.new(@options)
35
- blueprint.register
36
- finder = Lono::Finder::Blueprint::Configset.new
37
- finder.list("Configsets available to #{@blueprint} blueprint:") if @options[:verbose]
38
- puts "Configsets built into the blueprint:" if @options[:verbose]
39
- show(blueprint.configsets, finder.find_all, "blueprint")
40
-
41
- table = Text::Table.new
42
- table.head = ["Name", "Path", "Type", "From"]
43
- @final.each do |spec|
44
- pretty_root = spec.root.sub("#{Lono.root}/",'').sub(ENV["HOME"], "~")
45
- table.rows << [spec.name, pretty_root, spec.source_type, spec.from]
46
- end
47
-
48
- if table.rows.empty?
49
- puts "No configsets being used."
50
- else
51
- puts "Configsets used by #{@blueprint.color(:green)} blueprint:"
52
- puts table
53
- end
54
- end
55
-
56
- def show(configsets, all, from)
57
- configsets.each do |c|
58
- puts " #{c.name}" if @options[:verbose]
59
- spec = all.find { |jadespec| jadespec.name == c.name }
60
- next unless spec
61
- spec.from = from
62
- @final << spec
63
- end
64
- puts "" if @options[:verbose]
65
- end
66
- end
67
- end
@@ -1,44 +0,0 @@
1
- class Lono::Configset
2
- class Preparer < Lono::AbstractBase
3
- def initialize(options={})
4
- super
5
- @blueprint = Register::Blueprint.new(options)
6
- @project = Register::Project.new(options)
7
- @meta = Meta.new(options)
8
- @resolver = Resolver.new
9
- end
10
-
11
- def run
12
- register
13
- resolve_dependencies # also calls jade.materialize
14
- register_dependencies
15
- materialize
16
- validate_all! # run after final materializer
17
- end
18
-
19
- # Stores configsets registry items
20
- def register
21
- @project.register # IE: evaluates configs/BLUEPRINT/configsets/base.rb
22
- @blueprint.register # IE: evaluates BLUEPRINT/config/configsets.rb
23
- end
24
-
25
- def resolve_dependencies
26
- jades = Lono::Jade::Registry.tracked_configsets # at this point only top-level
27
- @resolver.resolve(jades) # also calls jade.materialize
28
- end
29
-
30
- def register_dependencies
31
- @resolver.register
32
- end
33
-
34
- def materialize
35
- jades = Lono::Jade::Registry.downloaded_configsets
36
- Lono::Jade::Materializer::Final.new.build(jades)
37
- end
38
-
39
- def validate_all!
40
- @blueprint.validate!
41
- @project.validate!
42
- end
43
- end
44
- end
@@ -1,122 +0,0 @@
1
- # Subclasses must implement:
2
- #
3
- # evaluate
4
- #
5
- module Lono::Configset::Register
6
- class Base < Lono::AbstractBase
7
- class_attribute :configsets
8
- class_attribute :validations
9
- class_attribute :source
10
-
11
- include Dsl
12
- include Lono::Configset::EvaluateFile
13
-
14
- def register
15
- evaluate
16
- jadify
17
- end
18
-
19
- def jadify
20
- self.class.configsets.each do |registry|
21
- jade = Lono::Jade.new(registry.name, jade_type, registry)
22
- Lono::Jade::Registry.tracked_configsets << jade
23
- end
24
- end
25
-
26
- def jade_type
27
- finder_class.to_s.sub('Lono::Finder::','').underscore
28
- end
29
-
30
- # Used in Base#validate!
31
- def finder_class
32
- case self
33
- when Lono::Configset::Register::Blueprint
34
- Lono::Finder::Blueprint::Configset
35
- when Lono::Configset::Register::Project
36
- Lono::Finder::Configset
37
- end
38
- end
39
-
40
- # Store to be able to provide the validation errors altogether later.
41
- def store_for_validation(registry)
42
- # save caller line to use later for pointing to exactly line
43
- caller_line = caller.grep(/evaluate_file/).first
44
- registry.caller_line = caller_line
45
- # huge performance improvement by only validating the first configset registration of duplicate gems
46
- names = self.class.validations.map {|r| r.name }
47
- self.class.validations << registry unless names.include?(registry.name)
48
- end
49
-
50
- # Validate the configset before building templates. So user finds out about errors early.
51
- def validate!
52
- errors = []
53
- self.class.validations.each do |registry|
54
- config = finder_class.find(registry.name) # finder_class implemented in subclass
55
- errors << [:finder_missing, registry] unless config
56
-
57
- if registry.depends_on.nil? && registry.resource.nil?
58
- errors << [:resource_missing, registry]
59
- end
60
- end
61
-
62
- return if errors.empty? # all good
63
- show_errors_and_exit!(errors)
64
- end
65
-
66
- def show_errors_and_exit!(errors)
67
- errors.each do |error_type, registry|
68
- name, caller_line = registry.name, registry.caller_line
69
- case error_type
70
- when :finder_missing
71
- puts "ERROR: Configset with name #{name} not found. Please double check Gemfile and configs/#{@blueprint}/configsets files.".color(:red)
72
- pretty_trace(caller_line)
73
- when :resource_missing
74
- puts "ERROR: Configset with name #{name} does not specify resource. The resource key is required.".color(:red)
75
- pretty_trace(caller_line)
76
- raise
77
- end
78
- end
79
- exit 1
80
- end
81
-
82
- def pretty_trace(caller_line)
83
- md = caller_line.match(/(.*\.rb):(\d+):/)
84
- path, error_line_number = md[1], md[2].to_i
85
-
86
- context = 5 # lines of context
87
- top, bottom = [error_line_number-context-1, 0].max, error_line_number+context-1
88
-
89
- puts "Showing file: #{path}"
90
- lines = IO.read(path).split("\n")
91
- spacing = lines.size.to_s.size
92
- lines[top..bottom].each_with_index do |line_content, index|
93
- current_line_number = top+index+1
94
- if current_line_number == error_line_number
95
- printf("%#{spacing}d %s\n".color(:red), current_line_number, line_content)
96
- else
97
- printf("%#{spacing}d %s\n", current_line_number, line_content)
98
- end
99
- end
100
- end
101
-
102
- public
103
- class << self
104
- def clear!
105
- self.configsets = []
106
- self.validations = []
107
- end
108
-
109
- def prepend(registry)
110
- self.configsets.unshift(registry) unless has?(registry)
111
- end
112
-
113
- def append(registry)
114
- self.configsets << registry unless has?(registry)
115
- end
116
-
117
- def has?(registry)
118
- configsets.detect { |r| r.name == registry.name && r.args == registry.args }
119
- end
120
- end
121
- end
122
- end
@@ -1,16 +0,0 @@
1
- module Lono::Configset::Register
2
- class Blueprint < Base
3
- self.configsets = []
4
- self.validations = []
5
-
6
- def evaluate
7
- path = find_configsets
8
- evaluate_file(path)
9
- end
10
-
11
- def find_configsets
12
- path = "#{Lono.blueprint_root}/config/configsets.rb"
13
- path if File.exist?(path)
14
- end
15
- end
16
- end
@@ -1,14 +0,0 @@
1
- module Lono::Configset::Register
2
- module Dsl
3
- def configset(*args, **options)
4
- registry = Lono::Jade::Registry.register_configset(args, options)
5
- self.class.append(registry)
6
- store_for_validation(registry)
7
- end
8
-
9
- # DSL
10
- # def source(v)
11
- # self.class.source = v
12
- # end
13
- end
14
- end