lono-pro 0.4.6 → 0.4.7

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 44135091fe26622bcf15f190d99d15304e4d42ec6870683d4532e0899cd561c0
4
- data.tar.gz: dd19339c4e8acb97f5e5df63904e637c0ae72a5ac20b9f0d27fd4b02f655e3ba
3
+ metadata.gz: 941189b455e443202a2e75bf8912033b64f5235106c795d8c2fd8de06ec4ea3a
4
+ data.tar.gz: adf2c75a22cda3734a9213505e174af3d6b82e4ae46a746ed5c291578e72909d
5
5
  SHA512:
6
- metadata.gz: d18efd211e2fc8f43b438d8c7747b7abfd9e2708667546154d97b1fa637a91966daac2ff6c58fbe8d198ae13ca08069d260b070bcdc0d175c7b18e50c14517bd
7
- data.tar.gz: a39ceca84af1c19f71411ee7d52fe91c3ee2e6708bc33c546f761f12cb7e0bccf83f4ece78d3b13663a6ce12c2279b06d1d8f2585376081a1fb541453ec2e4f7
6
+ metadata.gz: e2d90a4f2408d3fde97aaf0ee234871b4230a2cb9e2ecfb873cbdac89d44ee3cdbdb4d57adf44b59da915cd5ce65bd525fd7a107d79f13e09cf07aa2ba608309
7
+ data.tar.gz: e027f7bf9a5708cb14119412b5da5097f9e303bd84e08b08bfece0cdb29f7790425dff36c987ec08e8fa97ef744c59be1f260dcfa887c0c57257430e7880ae5f
data/CHANGELOG.md CHANGED
@@ -3,6 +3,9 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  This project *tries* to adhere to [Semantic Versioning](http://semver.org/), even before v1.0.
5
5
 
6
+ ## [0.4.7]
7
+ - #1 code import: create full blueprint structure
8
+
6
9
  ## [0.4.6]
7
10
  - update cli help: convert, import
8
11
 
@@ -1,6 +1,8 @@
1
1
  class Lono::Pro::Importer
2
2
  class Base
3
3
  include Download
4
+ include Thor::Actions
5
+ include Thor::Base
4
6
 
5
7
  def initialize(source, options)
6
8
  @source, @options = source, options
@@ -11,6 +13,7 @@ class Lono::Pro::Importer
11
13
  Lono.blueprint_root = "#{Lono.root}/blueprints/#{@blueprint}"
12
14
 
13
15
  @tmp_path = "/tmp/lono/import/template.yml"
16
+ self.destination_root = Dir.pwd # Thor::Actions require destination_root to be set
14
17
  end
15
18
 
16
19
  private
@@ -21,14 +24,18 @@ class Lono::Pro::Importer
21
24
  end
22
25
 
23
26
  def create_params(template_path)
27
+ create_params_file(template_path, "development")
28
+ create_params_file(template_path, "production")
29
+ end
30
+
31
+ def create_params_file(template_path, env)
24
32
  params_path = if @blueprint != @template
25
- "configs/#{@blueprint}/params/#{Lono.env}/#{@template}.txt"
33
+ "configs/#{@blueprint}/params/#{env}/#{@template}.txt"
26
34
  else
27
- "configs/#{@blueprint}/params/#{Lono.env}.txt"
35
+ "configs/#{@blueprint}/params/#{env}.txt"
28
36
  end
29
37
  params = Params.new(template_path, params_path)
30
38
  params.create
31
- puts "Params file created at #{pretty_path(params_path)}"
32
39
  end
33
40
 
34
41
  # removes the ./ at the beginning if it's there in the path
@@ -3,12 +3,16 @@ class Lono::Pro::Importer
3
3
  def run
4
4
  tmp_template_path = download_template(@source, @tmp_path)
5
5
  template = IO.read(tmp_template_path)
6
+
7
+ Lono::Blueprint::New.start([@blueprint, "--import", "--type", "dsl"])
8
+
6
9
  translate_to_dsl(template)
7
- create_dot_lono("dsl")
8
10
  create_params(tmp_template_path)
9
11
  # Let's not summarize the template in case the Ruby syntax is invalid with the import coder.
10
12
  # Add summarize back in later
11
13
  # summarize
14
+
15
+ final_message
12
16
  end
13
17
 
14
18
  def translate_to_dsl(template)
@@ -17,9 +21,16 @@ class Lono::Pro::Importer
17
21
 
18
22
  path = "#{Lono.config.templates_path}/#{@template}.rb"
19
23
  FileUtils.mkdir_p(File.dirname(path))
20
- IO.write(path, result)
21
- pretty_path = path.sub("#{Lono.root}/",'')
22
- puts "Template imported to: #{pretty_path}"
24
+ create_file(path, result) # Thor::Action
25
+ end
26
+
27
+ def final_message
28
+ puts <<~EOL
29
+ #{"="*64}
30
+ Congrats 🎉 You have successfully imported a lono blueprint.
31
+
32
+ More info: https://lono.cloud/docs/core/blueprints
33
+ EOL
23
34
  end
24
35
  end
25
36
  end
@@ -1,16 +1,17 @@
1
1
  class Lono::Pro::Importer
2
2
  class Params
3
+ include Thor::Actions
4
+ include Thor::Base
3
5
  extend Memoist
4
6
 
5
7
  def initialize(template_path, params_path)
6
8
  @template_path, @params_path = template_path, params_path
7
9
  @params_path = normalize_path(@params_path)
10
+ self.destination_root = Dir.pwd # Thor::Actions require destination_root to be set
8
11
  end
9
12
 
10
13
  # Creates starter params/base/[stack-name].txt file
11
14
  def create
12
- template = YAML.load_file(@template_path)
13
-
14
15
  result = []
15
16
  required_parameters.each do |name, attributes|
16
17
  result << "#{name}=#{attributes["Default"]}"
@@ -21,9 +22,10 @@ class Lono::Pro::Importer
21
22
  end
22
23
  content = result.join("\n") + "\n"
23
24
 
25
+
24
26
  folder = File.dirname(@params_path)
25
27
  FileUtils.mkdir_p(folder) unless File.exist?(folder)
26
- IO.write(@params_path, content) unless File.exist?(@params_path)
28
+ create_file(@params_path, content) # Thor::Action
27
29
  end
28
30
 
29
31
  def required_parameters
@@ -1,5 +1,5 @@
1
1
  module Lono
2
2
  module Pro
3
- VERSION = "0.4.6"
3
+ VERSION = "0.4.7"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lono-pro
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.6
4
+ version: 0.4.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tung Nguyen
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-10-29 00:00:00.000000000 Z
11
+ date: 2019-10-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: zeitwerk