foobar_templates 2.0.1.rc2 → 2.0.1.rc4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/bin/foobar_templates +4 -0
- data/lib/foobar_templates/cli/template_generator.rb +62 -40
- data/lib/foobar_templates/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: c933bd134506713bc01168f73ba617aeb22f7d3dc10a472455da258189136528
|
|
4
|
+
data.tar.gz: 0a5bcd41cff0ef149b6950e5a6868e444eaff671e7eef5043cf89ea5f24f917c
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: a036cca148228d0cd1b6d7f1f8d0d81249108dd1aa4b029d146838b64b26ea018857a9f4a175f3e8c9bbc229f77035a68c4bc7dadbacae0e0a8b2ffaf38c3143
|
|
7
|
+
data.tar.gz: fa889a9eb2be2514d2b1347458b624491a460e1f7bc7faf25e7577a62da623e85ca29ec31b4ecb6633a4042d5ba75b66e37c72a21b2b3c67a88ef1a9c77ba3b9
|
data/bin/foobar_templates
CHANGED
|
@@ -29,6 +29,10 @@ parser = OptionParser.new do |opts|
|
|
|
29
29
|
exit
|
|
30
30
|
end
|
|
31
31
|
|
|
32
|
+
opts.on("-p", "--performance", "Show performance metrics for template generation") do
|
|
33
|
+
options[:performance] = true
|
|
34
|
+
end
|
|
35
|
+
|
|
32
36
|
opts.on("--install-public-templates", "Install public templates") do
|
|
33
37
|
FoobarTemplates.install_public_templates
|
|
34
38
|
exit
|
|
@@ -23,53 +23,67 @@ module FoobarTemplates::CLI
|
|
|
23
23
|
end
|
|
24
24
|
|
|
25
25
|
def config
|
|
26
|
-
@config ||= build_interpolation_config
|
|
26
|
+
@config ||= time_it("build_interpolation_config") { build_interpolation_config }
|
|
27
27
|
end
|
|
28
28
|
|
|
29
29
|
def run
|
|
30
|
-
|
|
31
|
-
|
|
30
|
+
time_it("TOTAL run") do
|
|
31
|
+
puts "Beginning run" if $TRACE
|
|
32
|
+
raise_project_with_that_name_already_exists! if File.exist?(target)
|
|
32
33
|
|
|
33
|
-
|
|
34
|
-
|
|
34
|
+
puts "ensure_safe_project_name" if $TRACE
|
|
35
|
+
time_it("ensure_safe_project_name") do
|
|
36
|
+
ensure_safe_project_name(name, config[:constant_array])
|
|
37
|
+
end
|
|
35
38
|
|
|
36
|
-
|
|
37
|
-
|
|
39
|
+
puts "run_name_validation" if $TRACE
|
|
40
|
+
time_it("run_name_validation") { run_name_validation }
|
|
38
41
|
|
|
39
|
-
|
|
42
|
+
template_src = time_it("match_template_src") { match_template_src }
|
|
40
43
|
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
44
|
+
puts "dynamically_generate_template_directories" if $TRACE
|
|
45
|
+
@template_directories = time_it("dynamically_generate_template_directories") do
|
|
46
|
+
dynamically_generate_template_directories
|
|
47
|
+
end
|
|
45
48
|
|
|
46
|
-
|
|
47
|
-
|
|
49
|
+
puts "dynamically_generate_templates_files" if $TRACE
|
|
50
|
+
templates = time_it("dynamically_generate_templates_files") do
|
|
51
|
+
dynamically_generate_templates_files
|
|
52
|
+
end
|
|
48
53
|
|
|
49
|
-
|
|
50
|
-
|
|
54
|
+
puts "Creating new project folder '#{name}'\n\n"
|
|
55
|
+
time_it("create_template_directories") do
|
|
56
|
+
create_template_directories(@template_directories, target)
|
|
57
|
+
end
|
|
51
58
|
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
59
|
+
time_it("write_template_files") do
|
|
60
|
+
templates.each do |src, dst|
|
|
61
|
+
template("#{template_src}/#{src}", target.join(dst), config)
|
|
62
|
+
end
|
|
63
|
+
end
|
|
55
64
|
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
65
|
+
time_it("git_init_and_add") do
|
|
66
|
+
Dir.chdir(target) do
|
|
67
|
+
if @configurator.always_perform_git_init || !inside_git_work_tree?
|
|
68
|
+
`git init`
|
|
69
|
+
end
|
|
70
|
+
`git add .`
|
|
71
|
+
end
|
|
59
72
|
end
|
|
60
|
-
`git add .`
|
|
61
|
-
end
|
|
62
73
|
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
74
|
+
if @tconf[:bootstrap_command]
|
|
75
|
+
puts "Executing bootstrap_command"
|
|
76
|
+
cmd = safe_gsub_template_variables(@tconf[:bootstrap_command])
|
|
77
|
+
puts cmd
|
|
78
|
+
time_it("bootstrap_command") do
|
|
79
|
+
Dir.chdir(target) do
|
|
80
|
+
`#{cmd}`
|
|
81
|
+
end
|
|
82
|
+
end
|
|
69
83
|
end
|
|
70
|
-
end
|
|
71
84
|
|
|
72
|
-
|
|
85
|
+
puts "\nComplete."
|
|
86
|
+
end
|
|
73
87
|
end
|
|
74
88
|
|
|
75
89
|
def build_interpolation_config
|
|
@@ -84,7 +98,9 @@ module FoobarTemplates::CLI
|
|
|
84
98
|
git_user_email = `git config user.email`.chomp
|
|
85
99
|
|
|
86
100
|
# Resolve domain values from ~/.foobar/config, prompting if needed
|
|
87
|
-
required_domains = scan_template_for_required_domains
|
|
101
|
+
required_domains = time_it("scan_template_for_required_domains") do
|
|
102
|
+
scan_template_for_required_domains
|
|
103
|
+
end
|
|
88
104
|
prompt_for_missing_domains(required_domains)
|
|
89
105
|
|
|
90
106
|
registry_domain = @configurator.domain('registry_domain')
|
|
@@ -202,14 +218,11 @@ module FoobarTemplates::CLI
|
|
|
202
218
|
|
|
203
219
|
def scan_template_for_required_domains
|
|
204
220
|
all_placeholders = DOMAIN_PLACEHOLDERS.values.flatten
|
|
205
|
-
pattern = Regexp.union(all_placeholders)
|
|
206
221
|
found_placeholders = Set.new
|
|
207
222
|
|
|
208
|
-
|
|
223
|
+
template_relative_paths.each do |rel|
|
|
224
|
+
f = File.join(@template_src, rel)
|
|
209
225
|
next unless File.file?(f)
|
|
210
|
-
base_path = f[@template_src.length+1..-1]
|
|
211
|
-
next if base_path.nil?
|
|
212
|
-
next if base_path.start_with?(".git" + File::SEPARATOR) || base_path == ".git"
|
|
213
226
|
next if binary_file?(f)
|
|
214
227
|
|
|
215
228
|
content = File.read(f)
|
|
@@ -296,7 +309,9 @@ module FoobarTemplates::CLI
|
|
|
296
309
|
# .git directory and any gitignored paths. Ignored directories are pruned
|
|
297
310
|
# during traversal so their (potentially huge) contents are never walked.
|
|
298
311
|
def template_relative_paths
|
|
299
|
-
@template_relative_paths ||= collect_non_ignored_paths
|
|
312
|
+
@template_relative_paths ||= time_it("collect_non_ignored_paths") do
|
|
313
|
+
collect_non_ignored_paths(@template_src)
|
|
314
|
+
end
|
|
300
315
|
end
|
|
301
316
|
|
|
302
317
|
# Breadth-first walk that prunes ignored directories. One batched
|
|
@@ -476,11 +491,18 @@ Exiting...
|
|
|
476
491
|
end
|
|
477
492
|
|
|
478
493
|
def time_it(label = nil)
|
|
494
|
+
return yield unless performance?
|
|
495
|
+
|
|
479
496
|
start_time = Process.clock_gettime(Process::CLOCK_MONOTONIC)
|
|
480
|
-
yield
|
|
497
|
+
result = yield
|
|
481
498
|
end_time = Process.clock_gettime(Process::CLOCK_MONOTONIC)
|
|
482
499
|
elapsed_ms = ((end_time - start_time) * 1000).round(2)
|
|
483
500
|
puts "#{label || 'Elapsed'}: #{elapsed_ms} ms"
|
|
501
|
+
result
|
|
502
|
+
end
|
|
503
|
+
|
|
504
|
+
def performance?
|
|
505
|
+
@options[:performance]
|
|
484
506
|
end
|
|
485
507
|
|
|
486
508
|
# This checks to see that the gem_name is a valid ruby gem name and will 'work'
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: foobar_templates
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 2.0.1.
|
|
4
|
+
version: 2.0.1.rc4
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- TheNotary
|
|
@@ -130,9 +130,9 @@ licenses:
|
|
|
130
130
|
- MIT
|
|
131
131
|
metadata:
|
|
132
132
|
bug_tracker_uri: https://github.com/TheNotary/foobar_templates/issues
|
|
133
|
-
changelog_uri: https://github.com/TheNotary/foobar_templates/releases/tag/v2.0.1.
|
|
133
|
+
changelog_uri: https://github.com/TheNotary/foobar_templates/releases/tag/v2.0.1.rc4
|
|
134
134
|
documentation_uri: https://github.com/TheNotary/foobar_templates
|
|
135
|
-
source_code_uri: https://github.com/TheNotary/foobar_templates/tree/v2.0.1.
|
|
135
|
+
source_code_uri: https://github.com/TheNotary/foobar_templates/tree/v2.0.1.rc4
|
|
136
136
|
rdoc_options: []
|
|
137
137
|
require_paths:
|
|
138
138
|
- lib
|