foobar_templates 2.0.1.rc2 → 2.0.1.rc3
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 +60 -35
- 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: f6f830e123079c5b60a6cd7f799df40f0615b6326565814e837029ea6a8d69e9
|
|
4
|
+
data.tar.gz: 8d19d2bad9ee276d489657f9de11ef0ac8e9929a92d7fa08d95b2f9e609bc9d4
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 2e2abe9daa3749abab39f10fbb110b8262541fd2ebba6f74d4c6d0bf85fe97d3e05a6745f05cb05fbb27db532c2c2d99945afe028e90dba066335648669ad998
|
|
7
|
+
data.tar.gz: df73ec40e11c12ac8316ab4c6105ac0d9ea895f2ca049b6b676b44660d7656df8041411ef38775d30e98f1d5a6909c2e4cb70e0210769b94d69eebfa6ffa7025
|
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')
|
|
@@ -296,7 +312,9 @@ module FoobarTemplates::CLI
|
|
|
296
312
|
# .git directory and any gitignored paths. Ignored directories are pruned
|
|
297
313
|
# during traversal so their (potentially huge) contents are never walked.
|
|
298
314
|
def template_relative_paths
|
|
299
|
-
@template_relative_paths ||= collect_non_ignored_paths
|
|
315
|
+
@template_relative_paths ||= time_it("collect_non_ignored_paths") do
|
|
316
|
+
collect_non_ignored_paths(@template_src)
|
|
317
|
+
end
|
|
300
318
|
end
|
|
301
319
|
|
|
302
320
|
# Breadth-first walk that prunes ignored directories. One batched
|
|
@@ -476,11 +494,18 @@ Exiting...
|
|
|
476
494
|
end
|
|
477
495
|
|
|
478
496
|
def time_it(label = nil)
|
|
497
|
+
return yield unless performance?
|
|
498
|
+
|
|
479
499
|
start_time = Process.clock_gettime(Process::CLOCK_MONOTONIC)
|
|
480
|
-
yield
|
|
500
|
+
result = yield
|
|
481
501
|
end_time = Process.clock_gettime(Process::CLOCK_MONOTONIC)
|
|
482
502
|
elapsed_ms = ((end_time - start_time) * 1000).round(2)
|
|
483
503
|
puts "#{label || 'Elapsed'}: #{elapsed_ms} ms"
|
|
504
|
+
result
|
|
505
|
+
end
|
|
506
|
+
|
|
507
|
+
def performance?
|
|
508
|
+
@options[:performance]
|
|
484
509
|
end
|
|
485
510
|
|
|
486
511
|
# 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.rc3
|
|
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.rc3
|
|
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.rc3
|
|
136
136
|
rdoc_options: []
|
|
137
137
|
require_paths:
|
|
138
138
|
- lib
|