logirel 0.0.15 → 0.0.17
Sign up to get free protection for your applications and to get access to all the features.
- data/.idea/.name +1 -0
- data/.idea/.rakeTasks +7 -0
- data/.idea/dictionaries/xyz.xml +3 -0
- data/.idea/encodings.xml +5 -0
- data/.idea/inspectionProfiles/Project_Default.xml +11 -0
- data/.idea/inspectionProfiles/profiles_settings.xml +7 -0
- data/.idea/logirel.iml +65 -0
- data/.idea/misc.xml +8 -0
- data/.idea/modules.xml +9 -0
- data/.idea/vcs.xml +7 -0
- data/.idea/workspace.xml +666 -0
- data/.semver +1 -1
- data/README.md +36 -36
- data/Rakefile.rb +0 -1
- data/lib/logirel/Initer.rb +103 -150
- data/lib/logirel/cli.rb +64 -63
- data/lib/logirel/cli_helper.rb +86 -0
- data/lib/logirel/queries/bool_q.rb +34 -0
- data/lib/logirel/queries/query.rb +7 -0
- data/lib/logirel/queries/str_q.rb +36 -0
- data/lib/logirel/queries.rb +2 -0
- data/lib/logirel/tasks/albacore_tasks.rb +15 -0
- data/lib/logirel/tasks/aspnet.rb +23 -0
- data/lib/logirel/tasks/assembly_info.rb +15 -0
- data/lib/logirel/tasks/core.rb +36 -0
- data/lib/logirel/tasks/ncover.rb +23 -0
- data/lib/logirel/tasks/nuget.rb +17 -0
- data/lib/logirel/tasks/nunit.rb +14 -0
- data/lib/logirel/tasks/nuspec.rb +4 -0
- data/lib/logirel/tasks/output.rb +4 -0
- data/lib/logirel/tasks/xunit.rb +15 -0
- data/lib/logirel/tasks/zip.rb +4 -0
- data/lib/logirel/templates/Gemfile.tt +6 -0
- data/lib/logirel/templates/Rakefile.tt +9 -0
- data/lib/logirel/templates/environment.tt +114 -0
- data/lib/logirel/templates/gitignore.tt +6 -0
- data/lib/logirel/templates/paths.tt +40 -0
- data/lib/logirel/templates/project_details.tt +5 -0
- data/{content/utils.rb → lib/logirel/templates/utils.tt} +1 -1
- data/lib/logirel/utils.rb +8 -0
- data/lib/logirel/version.rb +2 -10
- data/lib/logirel/vs/environment.rb +22 -0
- data/lib/logirel/vs/project_types.rb +27 -0
- data/lib/logirel/vs/solution.rb +113 -0
- data/lib/logirel.rb +2 -9
- data/logirel.gemspec +8 -5
- data/spec/queries/bool_query_spec.rb +32 -27
- data/spec/queries/string_query_spec.rb +57 -53
- data/spec/support/with_sample_projects.rb +3 -3
- data/spec/version_spec.rb +2 -3
- data/vendor/cache/albacore-0.2.6.gem +0 -0
- data/vendor/cache/nokogiri-1.4.6-x86-mingw32.gem +0 -0
- data/vendor/cache/semver-1.0.6.gem +0 -0
- metadata +75 -38
- data/content/environment.rb +0 -82
- data/lib/logirel/NuGet.rb +0 -8
- data/lib/logirel/details_emitter.rb +0 -0
- data/lib/logirel/q_model.rb +0 -65
- data/lib/logirel/querier.rb +0 -8
- data/spec/dependencies/nuget_spec.rb +0 -10
- data/spec/filesystem/filestructure_spec.rb +0 -56
- data/spec/filesystem/path_init_spec.rb +0 -35
- data/spec/filesystem/rakefile_init_spec.rb +0 -32
- data/spec/initer_spec.rb +0 -29
- data/spec/queries/querier_spec.rb +0 -45
- data/vendor/cache/albacore-0.2.5.gem +0 -0
- data/vendor/cache/rubyzip-0.9.4.gem +0 -0
- data/vendor/cache/semver-1.0.5.gem +0 -0
data/.semver
CHANGED
data/README.md
CHANGED
@@ -1,41 +1,39 @@
|
|
1
|
-
Let's try and make a gem to create .Net projects easily.
|
2
|
-
|
3
|
-
Getting started
|
4
|
-
===============
|
5
|
-
1. `gem install logirel`
|
6
|
-
1. Go to the project of your choice
|
7
|
-
1. `logirel init`
|
8
|
-
1. You should now answer the questions that logirel poses.
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
1. `
|
15
|
-
1. `bundle
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
* (
|
24
|
-
* (
|
25
|
-
* (
|
26
|
-
* (logirel)
|
27
|
-
*
|
1
|
+
Let's try and make a gem to create .Net projects easily.
|
2
|
+
|
3
|
+
Getting started
|
4
|
+
===============
|
5
|
+
1. `gem install logirel`
|
6
|
+
1. Go to the project of your choice
|
7
|
+
1. `logirel init`
|
8
|
+
1. You should now answer the questions that logirel poses.
|
9
|
+
1. after it's done, run `rake`.
|
10
|
+
|
11
|
+
|
12
|
+
Hacking it
|
13
|
+
==========
|
14
|
+
1. `git clone https://haf@github.com/haf/logirel.git`
|
15
|
+
1. `bundle install`
|
16
|
+
1. `bundle exec rspec spec`
|
17
|
+
|
18
|
+
My thinking
|
19
|
+
===========
|
20
|
+
|
21
|
+
Some problems I want to solve with this project;
|
22
|
+
|
23
|
+
* (bundler/semver/rake/gems) having foundations for semver, rake for builds and nuget for packaging.
|
24
|
+
* (logirel) easily adding structure to a solution folder created with Visual Studio `logirel init`
|
25
|
+
* (gitflow) using ["a successful branching model"](http://nvie.com/posts/a-successful-git-branching-model/)
|
26
|
+
* (logirel/teamcity) continuous integration friendly with 'environments' and transform files for e.g. config files
|
27
|
+
* (logirel) easily updating buildscripts from a git repository `gem update ; logirel update`
|
28
|
+
* ensuring correct versions of build script dependencies
|
28
29
|
* (nuget/owrap/symbolserver.org) ensuring correct versions of source code dependencies
|
29
|
-
* (gitflow) nicely tagging your source trees corresponding to semver
|
30
|
+
* (gitflow) nicely tagging your source trees corresponding to semver
|
30
31
|
* `nuget :nuget do |n|; 'git ls-files'.split("\n").each{ |f| n.file f }; end` create a nuget item with just files
|
31
32
|
|
32
33
|
TODO list
|
33
34
|
=========
|
34
35
|
|
35
|
-
1.
|
36
|
-
1. learn how to unit test ruby and put some fences around my 'release' f-n
|
37
|
-
1. build a small interactive prompt; it should set project properties when invoked
|
38
|
-
1. specify dependencies with bundler: bundler + bundle, semver, albacore, ruby, rake, nuget
|
36
|
+
1. make the core functionality solid
|
39
37
|
1. sample configuration settings for team city to build from github
|
40
38
|
1. build rake tasks invoking semver with ruby that integrate with teamcity
|
41
39
|
1. try the gem out on the transactions, auto tx and nhibernate facility projects
|
@@ -60,7 +58,9 @@ of managing another build is too large.
|
|
60
58
|
|
61
59
|
Shoulders of Giants
|
62
60
|
===================
|
63
|
-
* http://madduck.net/blog/2007.07.11:creating-a-git-branch-without-ancestry/
|
64
|
-
* http://rubydoc.info/github/wycats/thor/master/file/README.md
|
65
|
-
* https://github.com/radar/guides/blob/master/gem-development.md
|
66
|
-
* http://eggsonbread.com/2010/03/28/my-rspec-best-practices-and-tips/
|
61
|
+
* http://madduck.net/blog/2007.07.11:creating-a-git-branch-without-ancestry/
|
62
|
+
* http://rubydoc.info/github/wycats/thor/master/file/README.md
|
63
|
+
* https://github.com/radar/guides/blob/master/gem-development.md
|
64
|
+
* http://eggsonbread.com/2010/03/28/my-rspec-best-practices-and-tips/
|
65
|
+
* https://github.com/jondot/albathor (I actually started work on this one, before I saw this project; none the less
|
66
|
+
I've integrated pieces of its functionality into logirel, mostly its actions module and vs proj parsing.)
|
data/Rakefile.rb
CHANGED
data/lib/logirel/Initer.rb
CHANGED
@@ -1,152 +1,124 @@
|
|
1
|
-
require '
|
1
|
+
require 'logirel/queries/bool_q'
|
2
|
+
require 'logirel/queries/str_q'
|
3
|
+
require 'semver'
|
2
4
|
require 'enumerator'
|
3
5
|
require 'net/http'
|
4
|
-
require 'logirel/q_model'
|
5
6
|
require 'uuid'
|
6
7
|
|
7
|
-
|
8
8
|
module Logirel
|
9
9
|
class Initer
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
def initialize(root = '.',
|
10
|
+
|
11
|
+
attr_reader :root_path, :buildscripts_path, :tools_path
|
12
|
+
|
13
|
+
def initialize(root = '.',
|
14
|
+
buildscripts = 'buildscripts',
|
15
|
+
tools = 'tools')
|
14
16
|
@root_path = root
|
15
17
|
@buildscripts_path = buildscripts
|
18
|
+
@tools_path = tools
|
16
19
|
end
|
17
|
-
|
18
|
-
|
19
|
-
def get_commands
|
20
|
-
cmd ||= []
|
21
|
-
cmd << "semver init"
|
22
|
-
end
|
23
|
-
|
20
|
+
|
24
21
|
def nuget_from_codeplex(cp_ver, gem_ver)
|
25
22
|
(cp_ver <=> gem_ver) > 0
|
26
23
|
end
|
27
|
-
|
28
|
-
def create_structure
|
29
|
-
# puts "making dir #{@root_path}"
|
30
|
-
['buildscripts', 'src'].each do |d|
|
31
|
-
path = File.join(@root_path, d)
|
32
|
-
Dir.mkdir path unless Dir.exists? path
|
33
|
-
end
|
34
|
-
end
|
35
|
-
|
24
|
+
|
36
25
|
def create_path_folders(metas, f)
|
37
|
-
|
26
|
+
f.puts %q{
|
38
27
|
require File.dirname(__FILE__) + '/project_data'
|
39
28
|
root_folder = File.expand_path("#{File.dirname(__FILE__)}/..")
|
40
29
|
Folders = \{
|
41
|
-
}
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
30
|
+
}
|
31
|
+
f.puts ":src => " + StrQ.new("src").exec + ","
|
32
|
+
f.puts ":out => " + StrQ.new("build").exec + ","
|
33
|
+
f.puts ":package => " + StrQ.new("packages").exec + ","
|
34
|
+
f.puts ":tools => " + StrQ.new("tools").exec + ","
|
35
|
+
f.puts %q{:tests => File.join("build", "tests"),
|
47
36
|
:nuget => File.join("build", "nuget"),
|
48
37
|
:root => root_folder,
|
49
38
|
:binaries => "placeholder - specify build environment",
|
50
39
|
}
|
51
|
-
|
52
|
-
|
53
|
-
|
40
|
+
f.puts ":#{metas[:ruby_key]}" + " => {"
|
41
|
+
f.puts ':nuspec => File.join("build", "nuspec", Projects[' + ":#{metas[:ruby_key]}" + '][' + ":#{metas[:dir]}" + ']),'
|
42
|
+
f.puts %q{:out => 'placeholder - specify build environment',
|
54
43
|
:test_out => 'placeholder - specify build environment'
|
55
44
|
\},\}}
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
45
|
+
end
|
46
|
+
|
47
|
+
def create_path_files(metas, f)
|
48
|
+
f.puts "Files = {"
|
49
|
+
f.puts ":sln => " + StrQ.new("sln").exec + ","
|
50
|
+
f.puts ":#{metas[:ruby_key]} => {"
|
51
|
+
f.puts ':nuspec => File.join(Folders[:nuspec], Projects[' + ":#{metas[:ruby_key]}" + '][' + ":#{metas[:id]}" + '].nuspec),'
|
52
|
+
f.puts %q{:nunit => File.join(Folders[:nunit], "nunit-console.exe"),
|
64
53
|
:ilmerge => File.join(Folders[:tools], "ILMerge.exe")
|
65
54
|
\},\}}
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
55
|
+
end
|
56
|
+
|
57
|
+
def create_path_commands(metas, f)
|
58
|
+
f.puts %q{Commands = \{
|
70
59
|
:nuget => File.join(Folders[:tools], "NuGet.exe")
|
71
60
|
\}}
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
61
|
+
end
|
62
|
+
|
63
|
+
def create_path_uris(metas, f)
|
64
|
+
f.puts %q{Uris = \{
|
76
65
|
:nuget_offical => "http://packages.nuget.org/v1/"
|
77
66
|
\}}
|
78
|
-
|
79
|
-
|
80
|
-
|
67
|
+
end
|
68
|
+
|
69
|
+
def init_paths_rb metas
|
81
70
|
File.open(File.join(@root_path, @buildscripts_path, "paths.rb"), "w") do |f|
|
82
71
|
create_path_folders(metas, f)
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
URI.parse('https://raw.github.com/haf/logirel/master/content/environment.rb'))
|
102
|
-
end
|
103
|
-
end
|
104
|
-
|
105
|
-
def parse_folders
|
106
|
-
src = File.join(@root_path, 'src', '*')
|
107
|
-
Dir.
|
108
|
-
glob(src).
|
109
|
-
keep_if{ |i|
|
110
|
-
projs = File.join(i, "*.{csproj,vbproj,fsproj}")
|
111
|
-
File.directory? i and Dir.glob(projs).length > 0
|
112
|
-
}.
|
113
|
-
map{|x| File.basename(x) }
|
114
|
-
end
|
115
|
-
|
116
|
-
def init_gemfile
|
117
|
-
File.open(File.join(@root_path, "Gemfile"), "w+") do |f|
|
72
|
+
create_path_files(metas, f)
|
73
|
+
create_path_commands(metas, f)
|
74
|
+
create_path_uris(metas, f)
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
def init_environement_rb
|
79
|
+
base_path = ensure_path @buildscripts_path
|
80
|
+
path = File.join base_path, "environment.rb"
|
81
|
+
File.open(path, "w") do |f|
|
82
|
+
f.puts Net::HTTP.get(
|
83
|
+
URI.parse('https://raw.github.com/haf/logirel/master/content/environment.rb'))
|
84
|
+
end
|
85
|
+
end
|
86
|
+
|
87
|
+
|
88
|
+
def init_gemfile
|
89
|
+
File.open(File.join(@root_path, "Gemfile"), "w+") do |f|
|
118
90
|
f.puts 'source "http://rubygems.org"'
|
119
91
|
f.puts 'gem "albacore"'
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
92
|
+
f.puts 'gem "semver"'
|
93
|
+
f.puts 'gem "bundler"'
|
94
|
+
end
|
95
|
+
end
|
96
|
+
|
97
|
+
def init_utils
|
98
|
+
base_path = ensure_path @buildscripts_path
|
99
|
+
path = File.join base_path, "utils.rb"
|
100
|
+
File.open(path, "w") do |f|
|
101
|
+
f.puts Net::HTTP.get(
|
102
|
+
URI.parse('https://raw.github.com/haf/logirel/master/content/utils.rb'))
|
103
|
+
end
|
104
|
+
end
|
105
|
+
|
106
|
+
def build_tasks metas
|
107
|
+
|
108
|
+
end
|
109
|
+
|
110
|
+
def assembly_infos metas
|
111
|
+
|
112
|
+
end
|
113
|
+
|
114
|
+
def nugets metas
|
115
|
+
|
116
|
+
end
|
117
|
+
|
118
|
+
def init_rakefile(metas)
|
119
|
+
base_path = ensure_path @buildscripts_path
|
148
120
|
File.open File.join(base_path, "Rakefile.rb"), "w" do |f|
|
149
|
-
|
121
|
+
f.puts %q{
|
150
122
|
require 'rubygems'
|
151
123
|
require 'bundler'
|
152
124
|
Bundler.setup
|
@@ -164,46 +136,27 @@ task :release => ["env:release", :build]
|
|
164
136
|
task :ci => ["env:release", :build, :package]
|
165
137
|
}
|
166
138
|
f.puts "task :build => #{metas[:ruby_key]}"
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
139
|
+
|
140
|
+
f.puts build_tasks(metas)
|
141
|
+
end
|
142
|
+
end
|
143
|
+
|
172
144
|
def init_project_details(metadata)
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
145
|
+
base_path = ensure_path @buildscripts_path
|
146
|
+
projects = {}
|
147
|
+
metadata.each { |m|
|
148
|
+
projects[:"#{m[:ruby_key]}"] = m #.select{|kv| :"#{kv[0]}" != :"ruby_key"}
|
149
|
+
}
|
178
150
|
File.open(File.join(base_path, "project_details.rb"), "w+") do |f|
|
179
151
|
f.puts "Projects = #{p(projects)}"
|
180
152
|
end
|
181
153
|
end
|
182
|
-
|
183
|
-
|
154
|
+
|
155
|
+
def ensure_path path
|
184
156
|
base_path = File.join @root_path, path
|
185
157
|
Dir.mkdir base_path unless Dir.exists? base_path
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
def meta_for p, dir
|
190
|
-
base = File.basename(p)
|
191
|
-
|
192
|
-
puts "META DATA FOR: '#{base}'"
|
193
|
-
p_dir = File.join(dir, base)
|
194
|
-
|
195
|
-
{
|
196
|
-
:title => StrQ.new("Title", base).exec,
|
197
|
-
:dir => p_dir,
|
198
|
-
:test_dir => StrQ.new("Test Directory", base + ".Tests").exec,
|
199
|
-
:description => StrQ.new("Description", "Missing description for #{base}").exec,
|
200
|
-
:copyright => StrQ.new("Copyright").exec,
|
201
|
-
:authors => StrQ.new("Authors").exec,
|
202
|
-
:company => StrQ.new("Company").exec,
|
203
|
-
:nuget_key => StrQ.new("NuGet key", base).exec,
|
204
|
-
:ruby_key => StrQ.new("Ruby key (e.g. 'autotx')", nil, STDIN, lambda { |s| s != nil && s.length > 0 }).exec,
|
205
|
-
:guid => UUID.new.generate
|
206
|
-
}
|
207
|
-
end
|
158
|
+
base_path
|
159
|
+
end
|
160
|
+
|
208
161
|
end
|
209
162
|
end
|
data/lib/logirel/cli.rb
CHANGED
@@ -1,74 +1,75 @@
|
|
1
|
-
require 'logirel/initer'
|
2
1
|
require 'logirel/version'
|
3
|
-
require 'logirel/
|
2
|
+
require 'logirel/queries'
|
3
|
+
require 'logirel/vs/solution'
|
4
|
+
require 'logirel/vs/environment'
|
5
|
+
require 'logirel/tasks/albacore_tasks'
|
6
|
+
require 'logirel/cli_helper'
|
4
7
|
require 'uuid'
|
5
8
|
require 'thor'
|
6
|
-
require '
|
9
|
+
require 'fileutils'
|
7
10
|
|
8
11
|
module Logirel
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
puts "logirel"
|
15
|
-
puts "======="
|
16
|
-
curr = Dir.pwd
|
17
|
-
puts "Current dir: #{curr}"
|
12
|
+
class CLI < Thor
|
13
|
+
include Thor::Actions
|
14
|
+
include Logirel::Tasks
|
15
|
+
include Logirel::Queries
|
18
16
|
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
puts "
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
17
|
+
source_paths << File.expand_path("../templates", __FILE__)
|
18
|
+
source_paths << Dir.pwd
|
19
|
+
|
20
|
+
default_task :init
|
21
|
+
class_option "verbose", :type => :boolean, :banner => "Enable verbose output mode", :aliases => "-v"
|
22
|
+
|
23
|
+
desc "init [[--root=]ROOT-DIR] [[--template=]FILENAME]", "Initialize rakefile w/ albacore. Defaults to the current directory"
|
24
|
+
long_desc <<-D
|
25
|
+
Init scaffolds a directory structure for building the .Net project with albacore/rake. It takes as parameters
|
26
|
+
the root directory, which contains a 'src' folder, which should contain the projects. It aims not to overwrite
|
27
|
+
existing infrastructure, should such infrastructure exist.
|
28
|
+
D
|
29
|
+
method_option "root", :type => :string, :banner => "Perform the initialization in the given root directory"
|
30
|
+
method_option "raketempl", :type => :string, :banner => "Specify the initialization template to use"
|
31
|
+
def init(root = Dir.pwd, raketempl = 'Rakefile.tt')
|
32
|
+
opts = options.dup
|
33
|
+
helper = CliHelper.new opts.fetch("root", root)
|
34
|
+
|
35
|
+
puts "logirel v#{Logirel::VERSION}"
|
36
|
+
@folders = helper.folders_selection
|
37
|
+
@files = helper.files_selection folders
|
38
|
+
|
39
|
+
puts "Choose what projects to include:"
|
40
|
+
selected_projs = helper.parse_folders(folders[:src]).find_all { |f| BoolQ.new(f).exec }
|
42
41
|
|
43
|
-
puts "Selected: #{selected_projs.inspect}"
|
44
|
-
|
45
|
-
|
46
|
-
puts "initing semver in folder #{dir}"
|
47
|
-
`semver init`
|
48
|
-
puts "done..."
|
49
42
|
puts ""
|
50
|
-
|
51
|
-
|
52
|
-
puts "
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
43
|
+
@metas = selected_projs.empty? ? [] : helper.metadata_interactive(selected_projs)
|
44
|
+
|
45
|
+
puts "initing main environment"
|
46
|
+
run 'semver init'
|
47
|
+
|
48
|
+
template 'Gemfile', File.join(root, 'Gemfile')
|
49
|
+
template 'gitignore.tt', File.join(root, '.gitignore')
|
50
|
+
template 'project_details.tt', File.join(root, folders[:buildscripts], 'project_details.rb')
|
51
|
+
template 'paths.tt', File.join(root, folders[:buildscripts], 'paths.rb')
|
52
|
+
template 'environment.tt', File.join(root, folders[:buildscripts], 'environment.rb')
|
53
|
+
template 'utils.tt', File.join(root, folders[:buildscripts], 'utils.rb')
|
54
|
+
template raketempl, File.join(root, 'Rakefile.rb')
|
55
|
+
run 'git init'
|
56
|
+
run 'git add .'
|
57
|
+
# TODO: add a few nuget, nuspec, owrap, fpm, puppet etc tasks here!
|
58
|
+
|
59
|
+
helper.say_goodbye
|
60
|
+
end
|
61
|
+
|
62
|
+
protected
|
63
|
+
def metas
|
64
|
+
@metas ||= {}
|
65
|
+
end
|
66
|
+
|
67
|
+
def folders
|
68
|
+
@folders ||= {}
|
69
|
+
end
|
70
|
+
|
71
|
+
def files
|
72
|
+
@files ||= {}
|
72
73
|
end
|
73
74
|
end
|
74
75
|
end
|
@@ -0,0 +1,86 @@
|
|
1
|
+
require 'logirel/queries'
|
2
|
+
|
3
|
+
module Logirel
|
4
|
+
class CliHelper
|
5
|
+
include Logirel::Queries
|
6
|
+
|
7
|
+
def initialize root_dir
|
8
|
+
@root_dir = root_dir
|
9
|
+
end
|
10
|
+
|
11
|
+
# src: relative path!
|
12
|
+
def parse_folders src
|
13
|
+
src = File.join(@root_dir, src, '*')
|
14
|
+
Dir.
|
15
|
+
glob(src).
|
16
|
+
keep_if { |i|
|
17
|
+
projs = File.join(i, "*.{csproj,vbproj,fsproj}")
|
18
|
+
File.directory? i and Dir.glob(projs).length > 0
|
19
|
+
}.map { |x| File.basename(x) }
|
20
|
+
end
|
21
|
+
|
22
|
+
def folders_selection
|
23
|
+
puts "Directories Selection"
|
24
|
+
puts "---------------------"
|
25
|
+
puts "Current dir: #{@root_dir}, #{Dir.entries(@root_dir).keep_if{|x|
|
26
|
+
x != '.' && x != '..' && File.directory?(File.join(@root_dir, x))
|
27
|
+
}.
|
28
|
+
empty? ? 'which is empty.' : 'which contains folders.'}"
|
29
|
+
puts ""
|
30
|
+
|
31
|
+
{
|
32
|
+
:src => StrQ.new("Source Directory. Default (src) contains (#{parse_folders('src').inspect})", 'src').exec,
|
33
|
+
:buildscripts => StrQ.new("Buildscripts Directory", "buildscripts").exec,
|
34
|
+
:build => StrQ.new("Build Output Directory", "build").exec,
|
35
|
+
:tools => StrQ.new("Tools Directory", "tools").exec
|
36
|
+
}
|
37
|
+
end
|
38
|
+
|
39
|
+
# folders: hash (as defined above), of folder paths
|
40
|
+
def files_selection folders
|
41
|
+
puts "Looking at src folder: '#{folders[:src]}'."
|
42
|
+
{
|
43
|
+
:sln => StrQ.new("sln file", Dir.glob(File.join(@root_dir, folders[:src],"*.sln")).first).exec
|
44
|
+
}
|
45
|
+
end
|
46
|
+
|
47
|
+
def metadata_interactive selected_projs
|
48
|
+
puts "Project Meta-Data Definitions"
|
49
|
+
puts "-----------------------------"
|
50
|
+
puts "Let's set up some meta-data!"
|
51
|
+
puts ""
|
52
|
+
selected_projs.map { |p| meta_for p }
|
53
|
+
end
|
54
|
+
|
55
|
+
def say_goodbye
|
56
|
+
puts ""
|
57
|
+
puts "SCAFFOLDING DONE! Now run 'bundle install' to install any dependencies for your albacore rakefile,"
|
58
|
+
puts " and git commit to commit changes!"
|
59
|
+
puts ""
|
60
|
+
puts "Footnote:"
|
61
|
+
puts "If you hack a nice task or deployment script - feel free to send some code to henrik@haf.se to"
|
62
|
+
puts "make it available for everyone and get support on it through the community for free!"
|
63
|
+
end
|
64
|
+
|
65
|
+
private
|
66
|
+
def meta_for p
|
67
|
+
base = File.basename(p)
|
68
|
+
|
69
|
+
puts "META DATA FOR: '#{base}'"
|
70
|
+
p_dir = File.join(@root_dir, base)
|
71
|
+
|
72
|
+
{
|
73
|
+
:title => StrQ.new("Title", base).exec,
|
74
|
+
:dir => p_dir,
|
75
|
+
:test_dir => StrQ.new("Test Directory", base + ".Tests").exec,
|
76
|
+
:description => StrQ.new("Description", "Missing description for #{base}").exec,
|
77
|
+
:copyright => StrQ.new("Copyright").exec,
|
78
|
+
:authors => StrQ.new("Authors").exec,
|
79
|
+
:company => StrQ.new("Company").exec,
|
80
|
+
:nuget_key => StrQ.new("NuGet key", base).exec,
|
81
|
+
:ruby_key => StrQ.new("Ruby key (e.g. 'autotx')", nil, STDIN, lambda { |s| s != nil && s.length > 0 }).exec,
|
82
|
+
:guid => UUID.new.generate
|
83
|
+
}
|
84
|
+
end
|
85
|
+
end
|
86
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
require 'logirel/queries/query'
|
2
|
+
|
3
|
+
module Logirel
|
4
|
+
module Queries
|
5
|
+
class BoolQ < Query
|
6
|
+
attr_accessor :pos_answer, :neg_answer
|
7
|
+
|
8
|
+
def initialize(question,
|
9
|
+
default = true,
|
10
|
+
io_source = STDIN,
|
11
|
+
io_target = STDOUT)
|
12
|
+
@question = question
|
13
|
+
@default = default
|
14
|
+
@io_source = io_source
|
15
|
+
@io_target = io_target
|
16
|
+
end
|
17
|
+
|
18
|
+
def default_str
|
19
|
+
|
20
|
+
@default ? "[Yn]" : "[yN]"
|
21
|
+
|
22
|
+
end
|
23
|
+
|
24
|
+
def exec
|
25
|
+
@io_target.print @question + " " + default_str
|
26
|
+
a = ""
|
27
|
+
begin
|
28
|
+
a = @io_source.gets.chomp
|
29
|
+
end while !a.empty? && !['y', 'n'].include?(a.downcase)
|
30
|
+
a.empty? ? @default : (a == 'y')
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|