autowow 0.12.1 → 0.13.0
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 +5 -5
- data/.gitignore +14 -14
- data/.rspec +2 -2
- data/.rubocop.yml +118 -118
- data/.travis.yml +11 -11
- data/Gemfile +6 -6
- data/Guardfile +22 -22
- data/LICENSE.txt +21 -21
- data/README.md +188 -179
- data/Rakefile +59 -59
- data/autowow.gemspec +42 -41
- data/bin/autowow +5 -5
- data/bin/aw +5 -5
- data/bin/console +14 -14
- data/bin/setup +8 -8
- data/lib/autowow.rb +13 -13
- data/lib/autowow/cli.rb +121 -115
- data/lib/autowow/commands/gem.rb +54 -54
- data/lib/autowow/commands/os.rb +11 -11
- data/lib/autowow/commands/rbenv.rb +19 -19
- data/lib/autowow/commands/vcs.rb +99 -95
- data/lib/autowow/decorators/string_decorator.rb +11 -11
- data/lib/autowow/executor.rb +100 -100
- data/lib/autowow/features/fs.rb +49 -49
- data/lib/autowow/features/gem.rb +138 -132
- data/lib/autowow/features/os.rb +16 -16
- data/lib/autowow/features/rbenv.rb +50 -50
- data/lib/autowow/features/vcs.rb +282 -272
- data/lib/autowow/log_formatter.rb +25 -25
- data/lib/autowow/time_difference.rb +29 -29
- data/lib/autowow/version.rb +3 -3
- metadata +17 -3
data/lib/autowow/features/fs.rb
CHANGED
@@ -1,49 +1,49 @@
|
|
1
|
-
require_relative "../time_difference"
|
2
|
-
|
3
|
-
module Autowow
|
4
|
-
module Features
|
5
|
-
module Fs
|
6
|
-
using RefinedTimeDifference
|
7
|
-
|
8
|
-
def ls_dirs
|
9
|
-
Dir.glob(File.expand_path("./*/")).select { |f| File.directory? f }
|
10
|
-
end
|
11
|
-
|
12
|
-
def latest(files)
|
13
|
-
files.sort_by { |f| File.mtime(f) }.reverse!.first
|
14
|
-
end
|
15
|
-
|
16
|
-
def older_than(files, quantity, unit)
|
17
|
-
files.select do |dir|
|
18
|
-
TimeDifference.between(File.mtime(dir), Time.now).public_send("in_#{unit}") > quantity
|
19
|
-
end
|
20
|
-
end
|
21
|
-
|
22
|
-
def for_dirs(dirs)
|
23
|
-
dirs.each do |working_dir|
|
24
|
-
# TODO: add handling of directories via extra param to popen3
|
25
|
-
# https://stackoverflow.com/a/10148084/2771889
|
26
|
-
Dir.chdir(working_dir) do
|
27
|
-
yield working_dir
|
28
|
-
end
|
29
|
-
end
|
30
|
-
end
|
31
|
-
|
32
|
-
def in_place_or_subdirs(in_place)
|
33
|
-
if in_place
|
34
|
-
yield
|
35
|
-
else
|
36
|
-
for_dirs(ls_dirs) do
|
37
|
-
yield
|
38
|
-
end
|
39
|
-
end
|
40
|
-
end
|
41
|
-
|
42
|
-
def git_folder_present
|
43
|
-
File.exist?(".git")
|
44
|
-
end
|
45
|
-
|
46
|
-
include ReflectionUtils::CreateModuleFunctions
|
47
|
-
end
|
48
|
-
end
|
49
|
-
end
|
1
|
+
require_relative "../time_difference"
|
2
|
+
|
3
|
+
module Autowow
|
4
|
+
module Features
|
5
|
+
module Fs
|
6
|
+
using RefinedTimeDifference
|
7
|
+
|
8
|
+
def ls_dirs
|
9
|
+
Dir.glob(File.expand_path("./*/")).select { |f| File.directory? f }
|
10
|
+
end
|
11
|
+
|
12
|
+
def latest(files)
|
13
|
+
files.sort_by { |f| File.mtime(f) }.reverse!.first
|
14
|
+
end
|
15
|
+
|
16
|
+
def older_than(files, quantity, unit)
|
17
|
+
files.select do |dir|
|
18
|
+
TimeDifference.between(File.mtime(dir), Time.now).public_send("in_#{unit}") > quantity
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
def for_dirs(dirs)
|
23
|
+
dirs.each do |working_dir|
|
24
|
+
# TODO: add handling of directories via extra param to popen3
|
25
|
+
# https://stackoverflow.com/a/10148084/2771889
|
26
|
+
Dir.chdir(working_dir) do
|
27
|
+
yield working_dir
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
def in_place_or_subdirs(in_place)
|
33
|
+
if in_place
|
34
|
+
yield
|
35
|
+
else
|
36
|
+
for_dirs(ls_dirs) do
|
37
|
+
yield
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
def git_folder_present
|
43
|
+
File.exist?(".git")
|
44
|
+
end
|
45
|
+
|
46
|
+
include ReflectionUtils::CreateModuleFunctions
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
data/lib/autowow/features/gem.rb
CHANGED
@@ -1,132 +1,138 @@
|
|
1
|
-
require "pastel"
|
2
|
-
|
3
|
-
require_relative "../commands/gem"
|
4
|
-
require_relative "vcs"
|
5
|
-
|
6
|
-
module Autowow
|
7
|
-
module Features
|
8
|
-
module Gem
|
9
|
-
include EasyLogging
|
10
|
-
include Commands::Gem
|
11
|
-
include Commands::Vcs
|
12
|
-
include Executor
|
13
|
-
|
14
|
-
def gem_release(version_bump = nil)
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
pretty.run(
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
text.
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
end
|
1
|
+
require "pastel"
|
2
|
+
|
3
|
+
require_relative "../commands/gem"
|
4
|
+
require_relative "vcs"
|
5
|
+
|
6
|
+
module Autowow
|
7
|
+
module Features
|
8
|
+
module Gem
|
9
|
+
include EasyLogging
|
10
|
+
include Commands::Gem
|
11
|
+
include Commands::Vcs
|
12
|
+
include Executor
|
13
|
+
|
14
|
+
def gem_release(version_bump = nil)
|
15
|
+
if quiet.run!("gem push").out.clean_lines.select { |line| line.match(/Enter your RubyGems.org credentials/) }.any?
|
16
|
+
logger.error("Set RubyGems credentials first via `gem push`")
|
17
|
+
return
|
18
|
+
end
|
19
|
+
pretty_with_output.run(git_status)
|
20
|
+
start_branch = Vcs.working_branch
|
21
|
+
logger.error("Not on master.") and return unless start_branch.eql?("master")
|
22
|
+
pretty.run(pull)
|
23
|
+
version = nil
|
24
|
+
|
25
|
+
if version_bump
|
26
|
+
version = pretty_with_output.run(bump(version_bump)).out.clean_lines.select { |line| line.match(/Bumping|bump/) }.first.split(" ").last
|
27
|
+
bump_readme_version_information(version)
|
28
|
+
# Full command is needed because of faulty escaping otherwise
|
29
|
+
pretty.run("git add README.md *version.rb")
|
30
|
+
pretty.run("git commit -m \"Bumps version to v#{version}\"")
|
31
|
+
end
|
32
|
+
|
33
|
+
pretty.run(push)
|
34
|
+
|
35
|
+
Vcs.on_branch("release") do
|
36
|
+
pretty.run(pull)
|
37
|
+
pretty.run(rebase(start_branch))
|
38
|
+
pretty_with_output.run(release)
|
39
|
+
end
|
40
|
+
|
41
|
+
if version && change_readme_version_information_to_development(version)
|
42
|
+
pretty.run(add(["README.md"]))
|
43
|
+
# Full command is needed because of faulty escaping otherwise
|
44
|
+
pretty.run("git commit -m \"Changes README to development version\"")
|
45
|
+
pretty.run(push)
|
46
|
+
end
|
47
|
+
|
48
|
+
pretty_with_output.run(git_status)
|
49
|
+
end
|
50
|
+
|
51
|
+
def gem_clean
|
52
|
+
pretty_with_output.run(clean)
|
53
|
+
end
|
54
|
+
|
55
|
+
def rubocop_parallel_autocorrect
|
56
|
+
pastel = Pastel.new
|
57
|
+
result = pretty_with_output.run!(rubocop_parallel)
|
58
|
+
if result.failed?
|
59
|
+
filtered = result.out.each_line.select { |line| line.match(%r{(.*):([0-9]*):([0-9]*):}) }
|
60
|
+
.map { |line| line.split(":")[0] }
|
61
|
+
.uniq
|
62
|
+
.map { |line| pastel.strip(line) }
|
63
|
+
pretty_with_output.run(rubocop_autocorrect(filtered)) if filtered.any?
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
def bundle_exec(cmd)
|
68
|
+
Autowow::Executor.pretty_with_output.run(["bundle", "exec"] + cmd)
|
69
|
+
end
|
70
|
+
|
71
|
+
def db_migrate
|
72
|
+
pretty_with_output.run(rake_db_migrate)
|
73
|
+
end
|
74
|
+
|
75
|
+
def db_schema
|
76
|
+
pretty_with_output.run(rake_db_schema)
|
77
|
+
end
|
78
|
+
|
79
|
+
def db_structure
|
80
|
+
pretty_with_output.run(rake_db_structure)
|
81
|
+
end
|
82
|
+
|
83
|
+
def bump_readme_version_information(version)
|
84
|
+
readme = File.new("README.md")
|
85
|
+
return unless File.file?(readme)
|
86
|
+
text = File.read(readme)
|
87
|
+
return unless contains_version_information?(text)
|
88
|
+
|
89
|
+
version_information = get_version_information(text)
|
90
|
+
|
91
|
+
new_version_information = if version_information.include?("development version")
|
92
|
+
releases_link = version_information.match(/\[.+\]\(.+\)/)[0].split("(")[1].split("/tag")[0]
|
93
|
+
<<-HEREDOC
|
94
|
+
<!--- Version informartion -->
|
95
|
+
*You are viewing the README of version [v#{version}](#{releases_link}/tag/v#{version}). You can find other releases [here](#{releases_link}).*
|
96
|
+
<!--- Version informartion end -->
|
97
|
+
HEREDOC
|
98
|
+
else
|
99
|
+
version_information.gsub(/[0-9]\.[0-9]\.[0-9]/, version)
|
100
|
+
end
|
101
|
+
|
102
|
+
text.gsub!(version_information, new_version_information.chomp)
|
103
|
+
File.write(readme, text)
|
104
|
+
end
|
105
|
+
|
106
|
+
def change_readme_version_information_to_development(version)
|
107
|
+
readme = File.new("README.md")
|
108
|
+
return false unless File.file?(readme)
|
109
|
+
text = File.read(readme)
|
110
|
+
return false unless contains_version_information?(text)
|
111
|
+
version_information = get_version_information(text)
|
112
|
+
return false if version_information.include?("development version")
|
113
|
+
|
114
|
+
releases_link = version_information.match(/\[.+\]\(.+\)/)[0].split("(")[1].split("/tag")[0]
|
115
|
+
|
116
|
+
new_version_information = <<-HEREDOC
|
117
|
+
<!--- Version informartion -->
|
118
|
+
*You are viewing the README of the development version. You can find the README of the latest release (v#{version}) [here](#{releases_link}/tag/v#{version}).*
|
119
|
+
<!--- Version informartion end -->
|
120
|
+
HEREDOC
|
121
|
+
|
122
|
+
text.gsub!(version_information, new_version_information.chomp)
|
123
|
+
File.write(readme, text)
|
124
|
+
true
|
125
|
+
end
|
126
|
+
|
127
|
+
def contains_version_information?(text)
|
128
|
+
text.match(/<!--- Version informartion -->(.+)<!--- Version informartion end -->/m).length > 0
|
129
|
+
end
|
130
|
+
|
131
|
+
def get_version_information(text)
|
132
|
+
text.match(/<!--- Version informartion -->(.+)<!--- Version informartion end -->/m)[0]
|
133
|
+
end
|
134
|
+
|
135
|
+
include ReflectionUtils::CreateModuleFunctions
|
136
|
+
end
|
137
|
+
end
|
138
|
+
end
|
data/lib/autowow/features/os.rb
CHANGED
@@ -1,16 +1,16 @@
|
|
1
|
-
require_relative "../commands/os"
|
2
|
-
|
3
|
-
module Autowow
|
4
|
-
module Features
|
5
|
-
module Os
|
6
|
-
include Commands::Os
|
7
|
-
include Executor
|
8
|
-
|
9
|
-
def exists?(cmd)
|
10
|
-
quiet.run!(which(cmd)).success?
|
11
|
-
end
|
12
|
-
|
13
|
-
include ReflectionUtils::CreateModuleFunctions
|
14
|
-
end
|
15
|
-
end
|
16
|
-
end
|
1
|
+
require_relative "../commands/os"
|
2
|
+
|
3
|
+
module Autowow
|
4
|
+
module Features
|
5
|
+
module Os
|
6
|
+
include Commands::Os
|
7
|
+
include Executor
|
8
|
+
|
9
|
+
def exists?(cmd)
|
10
|
+
quiet.run!(which(cmd)).success?
|
11
|
+
end
|
12
|
+
|
13
|
+
include ReflectionUtils::CreateModuleFunctions
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -1,50 +1,50 @@
|
|
1
|
-
require_relative "../commands/rbenv"
|
2
|
-
require_relative "../commands/vcs"
|
3
|
-
|
4
|
-
require_relative "fs"
|
5
|
-
require_relative "vcs"
|
6
|
-
|
7
|
-
module Autowow
|
8
|
-
module Features
|
9
|
-
module Rbenv
|
10
|
-
include EasyLogging
|
11
|
-
include Commands::Rbenv
|
12
|
-
include Executor
|
13
|
-
include StringDecorator
|
14
|
-
|
15
|
-
def ruby_versions
|
16
|
-
logger.info(used_versions)
|
17
|
-
end
|
18
|
-
|
19
|
-
def used_versions
|
20
|
-
rubies = []
|
21
|
-
Fs.in_place_or_subdirs(Vcs.is_git?) do
|
22
|
-
result = quiet.run!(version)
|
23
|
-
rubies.concat(result.out.clean_lines) if result.success?
|
24
|
-
end
|
25
|
-
rubies.uniq
|
26
|
-
end
|
27
|
-
|
28
|
-
def ruby_aliases
|
29
|
-
ret = {}
|
30
|
-
result = quiet.run!(aliases)
|
31
|
-
return ret unless result.success?
|
32
|
-
result.out.clean_lines.each do |line|
|
33
|
-
ret[line.split(" => ")[0]] = line.split(" => ")[1]
|
34
|
-
end
|
35
|
-
ret
|
36
|
-
end
|
37
|
-
|
38
|
-
def obsolete_versions
|
39
|
-
alias_map = ruby_aliases
|
40
|
-
used_versions_and_aliases = used_versions
|
41
|
-
used_versions.each do |v|
|
42
|
-
used_versions_and_aliases.push(alias_map[v]) if alias_map.has_key?(v)
|
43
|
-
end
|
44
|
-
quiet.run(installed_versions).out.clean_lines - used_versions_and_aliases
|
45
|
-
end
|
46
|
-
|
47
|
-
include ReflectionUtils::CreateModuleFunctions
|
48
|
-
end
|
49
|
-
end
|
50
|
-
end
|
1
|
+
require_relative "../commands/rbenv"
|
2
|
+
require_relative "../commands/vcs"
|
3
|
+
|
4
|
+
require_relative "fs"
|
5
|
+
require_relative "vcs"
|
6
|
+
|
7
|
+
module Autowow
|
8
|
+
module Features
|
9
|
+
module Rbenv
|
10
|
+
include EasyLogging
|
11
|
+
include Commands::Rbenv
|
12
|
+
include Executor
|
13
|
+
include StringDecorator
|
14
|
+
|
15
|
+
def ruby_versions
|
16
|
+
logger.info(used_versions)
|
17
|
+
end
|
18
|
+
|
19
|
+
def used_versions
|
20
|
+
rubies = []
|
21
|
+
Fs.in_place_or_subdirs(Vcs.is_git?) do
|
22
|
+
result = quiet.run!(version)
|
23
|
+
rubies.concat(result.out.clean_lines) if result.success?
|
24
|
+
end
|
25
|
+
rubies.uniq
|
26
|
+
end
|
27
|
+
|
28
|
+
def ruby_aliases
|
29
|
+
ret = {}
|
30
|
+
result = quiet.run!(aliases)
|
31
|
+
return ret unless result.success?
|
32
|
+
result.out.clean_lines.each do |line|
|
33
|
+
ret[line.split(" => ")[0]] = line.split(" => ")[1]
|
34
|
+
end
|
35
|
+
ret
|
36
|
+
end
|
37
|
+
|
38
|
+
def obsolete_versions
|
39
|
+
alias_map = ruby_aliases
|
40
|
+
used_versions_and_aliases = used_versions
|
41
|
+
used_versions.each do |v|
|
42
|
+
used_versions_and_aliases.push(alias_map[v]) if alias_map.has_key?(v)
|
43
|
+
end
|
44
|
+
quiet.run(installed_versions).out.clean_lines - used_versions_and_aliases
|
45
|
+
end
|
46
|
+
|
47
|
+
include ReflectionUtils::CreateModuleFunctions
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|