nexoform 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/nexoform +43 -33
- data/lib/nexoform/version.rb +2 -2
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 49c30beaa3d694a24e90963ca1385052390875dc38dd480013c77b9129479239
|
4
|
+
data.tar.gz: 289f9685367b3971520c57842e97d80ef107ac0c1e6fd5dbfa1b531ed847d0f1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fc2054ef934dcf381e62ec76ea181b222ff3489aa17feeee7deb37821b955dbfcf5231292532f6f29bb7f7a14f33d5669fa831ffc92f99ced58dddd445a7deac
|
7
|
+
data.tar.gz: 582e5beae666034fb39ec5577fac917cb380330e97b08d2f0adaa8bd50c3a0251d05ceac9266ecf327569cec18349519cd7ceeb1e333773762e24f115dc98f13
|
data/bin/nexoform
CHANGED
@@ -514,37 +514,38 @@ class NexoformBin < Thor
|
|
514
514
|
generate_files(options, chdir: false)
|
515
515
|
end
|
516
516
|
|
517
|
+
def process_dir(options, directory)
|
518
|
+
Dir.chdir(directory) do
|
519
|
+
# Go through and process ERB into output then delete the ERB file
|
520
|
+
Dir.glob('*.erb').each do |f|
|
521
|
+
header = "# This file was generated by nexoform. Changes will be lost\n"
|
522
|
+
content = ERB.new(File.read(f), 0, "%<>").result(binding)
|
523
|
+
File.write(f.gsub(/\.erb$/i, ''), "#{header}#{content}")
|
524
|
+
FileUtils.rm([f])
|
525
|
+
end
|
526
|
+
|
527
|
+
Dir.glob('*')
|
528
|
+
.select{ |f| File.directory?(f) }
|
529
|
+
.each{ |f| process_dir(options, f) } # recursive
|
530
|
+
end
|
531
|
+
end
|
532
|
+
|
517
533
|
def generate_files(options, chdir:)
|
518
|
-
print_next_color 'Generating terraform files '
|
519
|
-
'for environment: '
|
534
|
+
print_next_color 'Generating terraform files for environment: '
|
520
535
|
puts_next_color env(options)
|
521
|
-
|
522
|
-
clean_output_dir(options)
|
523
|
-
# find all .*.erb files, run them through erb and output the result
|
524
|
-
process_copy_erb_files(options)
|
525
|
-
# find all .* files (that don't end in erb) and copy them straight through
|
526
|
-
copy_other_files(options)
|
527
536
|
|
528
|
-
|
529
|
-
end
|
537
|
+
clean_output_dir(options)
|
530
538
|
|
531
|
-
|
532
|
-
|
533
|
-
.
|
534
|
-
|
535
|
-
|
536
|
-
end
|
539
|
+
# Copy everything to new directory
|
540
|
+
FileUtils.cp_r(
|
541
|
+
Dir.glob('*').reject{ |f| Nexoform::Config.envs.include?(f) },
|
542
|
+
output_dir(options)
|
543
|
+
)
|
537
544
|
|
538
|
-
|
539
|
-
|
540
|
-
end
|
545
|
+
# Go through and process ERB into output then delete the ERB file
|
546
|
+
process_dir(options, output_dir(options))
|
541
547
|
|
542
|
-
|
543
|
-
Dir.glob('*.erb').each do |f|
|
544
|
-
header = "# This file was generated by nexoform. Changes will be lost\n"
|
545
|
-
content = ERB.new(File.read(f), 0, "%<>").result(binding)
|
546
|
-
File.write(erb_file_to_out_file(f, options), "#{header}#{content}")
|
547
|
-
end
|
548
|
+
set_working_dir(options) if chdir
|
548
549
|
end
|
549
550
|
|
550
551
|
def clean_output_dir(options)
|
@@ -559,11 +560,20 @@ class NexoformBin < Thor
|
|
559
560
|
"#{Dir.pwd}/#{env(options)}"
|
560
561
|
end
|
561
562
|
|
562
|
-
def has_erb_files?
|
563
|
-
Dir.glob('*.erb').count > 0
|
563
|
+
def has_erb_files?(directory = Dir.pwd)
|
564
|
+
#return true if Dir.glob('*.erb').count > 0
|
565
|
+
Dir.chdir(directory) do
|
566
|
+
if Dir.glob('*.erb').count > 0
|
567
|
+
true
|
568
|
+
else
|
569
|
+
Dir.glob('*')
|
570
|
+
.select { |f| File.directory?(f) }
|
571
|
+
.any? { |f| has_erb_files?(f) } # recursive
|
572
|
+
end
|
573
|
+
end
|
564
574
|
end
|
565
575
|
|
566
|
-
def set_working_dir(
|
576
|
+
def set_working_dir(options)
|
567
577
|
Dir.chdir(output_dir(options)) if has_erb_files?
|
568
578
|
end
|
569
579
|
end
|
@@ -571,10 +581,10 @@ end
|
|
571
581
|
if !ARGV.empty? && %w[-v --version].include?(ARGV.first)
|
572
582
|
puts "Nexoform - Version: #{Nexoform.version}"
|
573
583
|
else
|
574
|
-
|
584
|
+
begin
|
575
585
|
NexoformBin.start(ARGV)
|
576
|
-
|
577
|
-
|
578
|
-
|
579
|
-
|
586
|
+
rescue StandardError => e
|
587
|
+
puts "* Encountered an error. Make sure your config-file isn't messed up".red
|
588
|
+
puts "\n* Exception message: #{e.message}".yellow
|
589
|
+
end
|
580
590
|
end
|
data/lib/nexoform/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: nexoform
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ben Porter
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-07-
|
11
|
+
date: 2019-07-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|