aid 0.1.3 → 0.2.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.rubocop.yml +25 -0
- data/.solargraph.yml +18 -0
- data/.travis.yml +9 -2
- data/CHANGELOG.md +11 -3
- data/Gemfile +10 -2
- data/README.md +2 -0
- data/Rakefile +5 -3
- data/aid.gemspec +17 -14
- data/bin/console +4 -3
- data/examples/begin.rb +52 -57
- data/examples/ci.rb +4 -2
- data/examples/data_dump.rb +19 -18
- data/examples/doctor.rb +60 -57
- data/examples/eslint.rb +8 -7
- data/examples/finish.rb +7 -6
- data/examples/mocha.rb +7 -6
- data/examples/pr.rb +4 -2
- data/examples/pushit.rb +10 -8
- data/examples/rspec.rb +7 -7
- data/examples/rubocop.rb +10 -9
- data/examples/slim_lint.rb +8 -7
- data/examples/test.rb +6 -4
- data/examples/update.rb +26 -26
- data/exe/aid +7 -1
- data/lib/aid.rb +23 -12
- data/lib/aid/colorize.rb +35 -31
- data/lib/aid/inheritable.rb +3 -2
- data/lib/aid/plugins.rb +64 -0
- data/lib/aid/script.rb +6 -4
- data/lib/aid/scripts.rb +2 -0
- data/lib/aid/scripts/doctor.rb +102 -40
- data/lib/aid/scripts/help.rb +9 -5
- data/lib/aid/scripts/init.rb +6 -4
- data/lib/aid/scripts/new.rb +27 -30
- data/lib/aid/scripts/version.rb +19 -0
- data/lib/aid/version.rb +3 -1
- metadata +39 -8
data/examples/rspec.rb
CHANGED
@@ -1,21 +1,21 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
class Rspec < Aid::Script
|
2
4
|
def self.description
|
3
|
-
|
5
|
+
'Runs the full RSpec suite'
|
4
6
|
end
|
5
7
|
|
6
8
|
def self.help
|
7
9
|
<<~HELP
|
8
|
-
|
10
|
+
Usage: aid rspec [any args to rspec]
|
9
11
|
HELP
|
10
12
|
end
|
11
13
|
|
12
14
|
def run
|
13
|
-
step
|
14
|
-
cmd =
|
15
|
+
step 'Running RSpec suite' do
|
16
|
+
cmd = 'bundle exec rspec'
|
15
17
|
|
16
|
-
unless argv.empty?
|
17
|
-
cmd << " #{argv.join(' ')}"
|
18
|
-
end
|
18
|
+
cmd << " #{argv.join(' ')}" unless argv.empty?
|
19
19
|
|
20
20
|
system! cmd
|
21
21
|
end
|
data/examples/rubocop.rb
CHANGED
@@ -1,21 +1,22 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
class Rubocop < Aid::Script
|
2
4
|
def self.description
|
3
|
-
|
5
|
+
'Runs rubocop against the codebase'
|
4
6
|
end
|
5
7
|
|
6
8
|
def self.help
|
7
9
|
<<~HELP
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
#{colorize(:green, "$ aid rubocop fix")} - auto-fixes any issues
|
10
|
+
Usage:
|
11
|
+
#{colorize(:green, '$ aid rubocop')} - runs all the cops
|
12
|
+
#{colorize(:green, '$ aid rubocop fix')} - auto-fixes any issues
|
12
13
|
HELP
|
13
14
|
end
|
14
15
|
|
15
16
|
def run
|
16
|
-
step
|
17
|
-
cmd =
|
18
|
-
cmd <<
|
17
|
+
step 'Running Rubocop' do
|
18
|
+
cmd = 'bundle exec rubocop'
|
19
|
+
cmd << ' -a' if auto_fix?
|
19
20
|
|
20
21
|
system! cmd
|
21
22
|
end
|
@@ -24,6 +25,6 @@ class Rubocop < Aid::Script
|
|
24
25
|
private
|
25
26
|
|
26
27
|
def auto_fix?
|
27
|
-
argv.first ==
|
28
|
+
argv.first == 'fix'
|
28
29
|
end
|
29
30
|
end
|
data/examples/slim_lint.rb
CHANGED
@@ -1,22 +1,23 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
class SlimLint < Aid::Script
|
2
4
|
def self.description
|
3
|
-
|
5
|
+
'Runs slim-lint against our templates'
|
4
6
|
end
|
5
7
|
|
6
8
|
def self.help
|
7
9
|
<<~HELP
|
8
|
-
|
9
|
-
|
10
|
-
This will run slim-lint against our templates under app/.
|
10
|
+
Usage: $ aid slim-lint
|
11
|
+
This will run slim-lint against our templates under app/.
|
11
12
|
HELP
|
12
13
|
end
|
13
14
|
|
14
15
|
def run
|
15
|
-
step
|
16
|
-
system!
|
16
|
+
step 'Linting slim templates...' do
|
17
|
+
system! 'slim-lint app/**/*.slim'
|
17
18
|
end
|
18
19
|
|
19
20
|
puts
|
20
|
-
puts colorize(:green,
|
21
|
+
puts colorize(:green, 'Passed!')
|
21
22
|
end
|
22
23
|
end
|
data/examples/test.rb
CHANGED
@@ -1,12 +1,14 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
class Test < Aid::Script
|
2
4
|
def self.description
|
3
|
-
|
5
|
+
'Runs full test suite'
|
4
6
|
end
|
7
|
+
|
5
8
|
def self.help
|
6
9
|
<<~HELP
|
7
|
-
|
8
|
-
|
9
|
-
Runs all the tests that are needed for acceptance.
|
10
|
+
Usage: aid test
|
11
|
+
Runs all the tests that are needed for acceptance.
|
10
12
|
HELP
|
11
13
|
end
|
12
14
|
|
data/examples/update.rb
CHANGED
@@ -1,20 +1,20 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
class Update < Aid::Script
|
2
4
|
def self.description
|
3
|
-
|
5
|
+
'Updates your dev environment automatically'
|
4
6
|
end
|
5
7
|
|
6
8
|
def self.help
|
7
9
|
<<~HELP
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
- prune your logs
|
17
|
-
- restart your servers
|
10
|
+
aid update
|
11
|
+
This script is a way to update your development environment automatically.
|
12
|
+
It will:
|
13
|
+
- rebase origin/master onto this branch
|
14
|
+
- install any new dependencies
|
15
|
+
- run any migrations
|
16
|
+
- prune your logs
|
17
|
+
- restart your servers
|
18
18
|
HELP
|
19
19
|
end
|
20
20
|
|
@@ -29,30 +29,30 @@ class Update < Aid::Script
|
|
29
29
|
private
|
30
30
|
|
31
31
|
def pull_git
|
32
|
-
step
|
33
|
-
system!
|
32
|
+
step 'Rebasing from origin/master' do
|
33
|
+
system! 'git fetch origin && git rebase origin/master'
|
34
34
|
end
|
35
35
|
end
|
36
36
|
|
37
37
|
def install_dependencies
|
38
|
-
step
|
39
|
-
system!
|
40
|
-
|
38
|
+
step 'Installing dependencies' do
|
39
|
+
system! 'command -v bundler > /dev/null || '\
|
40
|
+
'gem install bundler --conservative'
|
41
41
|
|
42
|
-
system!
|
43
|
-
system!
|
42
|
+
system! 'bundle install'
|
43
|
+
system! 'yarn'
|
44
44
|
end
|
45
45
|
end
|
46
46
|
|
47
47
|
def update_db
|
48
|
-
step
|
49
|
-
system!
|
48
|
+
step 'Updating database' do
|
49
|
+
system! 'rake db:migrate db:test:prepare'
|
50
50
|
end
|
51
51
|
end
|
52
52
|
|
53
53
|
def remove_old_logs
|
54
|
-
step
|
55
|
-
system!
|
54
|
+
step 'Removing old logs and tempfiles' do
|
55
|
+
system! 'rake log:clear tmp:clear'
|
56
56
|
end
|
57
57
|
end
|
58
58
|
|
@@ -61,14 +61,14 @@ class Update < Aid::Script
|
|
61
61
|
end
|
62
62
|
|
63
63
|
def restart_rails
|
64
|
-
step
|
64
|
+
step 'Attempting to restart Rails' do
|
65
65
|
output = `bin/rails restart`
|
66
66
|
|
67
|
-
if
|
67
|
+
if $CHILD_STATUS.exitstatus.positive?
|
68
68
|
puts colorize(
|
69
69
|
:light_red,
|
70
|
-
|
71
|
-
|
70
|
+
'skipping restart, not supported in this version of '\
|
71
|
+
'Rails (needs >= 5)'
|
72
72
|
)
|
73
73
|
else
|
74
74
|
puts output
|
data/exe/aid
CHANGED
@@ -1,9 +1,15 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
2
3
|
|
3
|
-
require_relative
|
4
|
+
require_relative '../lib/aid'
|
4
5
|
|
5
6
|
Aid.load_scripts!
|
6
7
|
|
8
|
+
plugins = Aid::PluginManager.new
|
9
|
+
plugins.activate_plugins
|
10
|
+
|
11
|
+
Aid.load_configs!
|
12
|
+
|
7
13
|
script = Aid::Script.scripts[Aid.script_name]
|
8
14
|
|
9
15
|
if ARGV.empty?
|
data/lib/aid.rb
CHANGED
@@ -1,10 +1,12 @@
|
|
1
|
-
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative 'aid/version'
|
2
4
|
|
3
5
|
module Aid
|
4
6
|
def self.load_paths
|
5
7
|
@load_paths ||= [
|
6
|
-
File.expand_path(File.dirname(__FILE__) +
|
7
|
-
|
8
|
+
File.expand_path(File.dirname(__FILE__) + '/aid/scripts'),
|
9
|
+
'.aid',
|
8
10
|
"#{Aid.project_root}/.aid",
|
9
11
|
ENV['AID_PATH']
|
10
12
|
].compact
|
@@ -12,12 +14,19 @@ module Aid
|
|
12
14
|
|
13
15
|
def self.load_scripts!
|
14
16
|
load_paths.each do |path|
|
15
|
-
Dir.glob("#{path}
|
16
|
-
require File.expand_path(file)
|
17
|
+
Dir.glob("#{path}/*.rb").each do |file|
|
18
|
+
require File.expand_path(file) unless %r{/config\.rb$}.match?(file)
|
17
19
|
end
|
18
20
|
end
|
19
21
|
end
|
20
22
|
|
23
|
+
def self.load_configs!
|
24
|
+
load_paths.each do |path|
|
25
|
+
config = File.expand_path("#{path}/config.rb")
|
26
|
+
require config if File.exist?(config)
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
21
30
|
def self.script_name
|
22
31
|
ARGV.first
|
23
32
|
end
|
@@ -31,10 +40,11 @@ module Aid
|
|
31
40
|
current_search_dir = Dir.pwd
|
32
41
|
|
33
42
|
loop do
|
34
|
-
|
43
|
+
git_index = "#{current_search_dir}/.git"
|
44
|
+
git_index_exists = Dir.exist?(git_index) || File.exist?(git_index)
|
35
45
|
|
36
|
-
return current_search_dir if
|
37
|
-
break if current_search_dir ==
|
46
|
+
return current_search_dir if git_index_exists
|
47
|
+
break if current_search_dir == '/'
|
38
48
|
|
39
49
|
current_search_dir = File.expand_path("#{current_search_dir}/..")
|
40
50
|
end
|
@@ -44,7 +54,8 @@ module Aid
|
|
44
54
|
end
|
45
55
|
end
|
46
56
|
|
47
|
-
require_relative
|
48
|
-
require_relative
|
49
|
-
require_relative
|
50
|
-
require_relative
|
57
|
+
require_relative 'aid/colorize'
|
58
|
+
require_relative 'aid/inheritable'
|
59
|
+
require_relative 'aid/plugins'
|
60
|
+
require_relative 'aid/script'
|
61
|
+
require_relative 'aid/scripts'
|
data/lib/aid/colorize.rb
CHANGED
@@ -1,39 +1,43 @@
|
|
1
|
-
|
2
|
-
extend self
|
1
|
+
# frozen_string_literal: true
|
3
2
|
|
4
|
-
|
5
|
-
|
3
|
+
module Aid
|
4
|
+
module Colorize
|
5
|
+
module_function
|
6
6
|
|
7
|
-
base
|
8
|
-
|
7
|
+
def self.included(base)
|
8
|
+
colorize = self
|
9
|
+
|
10
|
+
base.class_eval do
|
11
|
+
extend colorize
|
12
|
+
end
|
9
13
|
end
|
10
|
-
end
|
11
14
|
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
15
|
+
COLOR_CODES = {
|
16
|
+
black: 30,
|
17
|
+
blue: 34,
|
18
|
+
brown: 33,
|
19
|
+
cyan: 36,
|
20
|
+
dark_gray: 90,
|
21
|
+
green: 32,
|
22
|
+
light_blue: 94,
|
23
|
+
light_cyan: 96,
|
24
|
+
light_gray: 37,
|
25
|
+
light_green: 92,
|
26
|
+
light_purple: 95,
|
27
|
+
light_red: 91,
|
28
|
+
light_yellow: 93,
|
29
|
+
purple: 35,
|
30
|
+
red: 31,
|
31
|
+
white: 97,
|
32
|
+
yellow: 33,
|
30
33
|
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
34
|
+
command: 96,
|
35
|
+
error: 91,
|
36
|
+
info: 93
|
37
|
+
}.freeze
|
35
38
|
|
36
|
-
|
37
|
-
|
39
|
+
def colorize(color, string)
|
40
|
+
"\e[#{COLOR_CODES[color]}m#{string}\e[0m"
|
41
|
+
end
|
38
42
|
end
|
39
43
|
end
|
data/lib/aid/inheritable.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Aid
|
2
4
|
module Inheritable
|
3
5
|
def self.included(klass)
|
@@ -25,9 +27,8 @@ module Aid
|
|
25
27
|
end
|
26
28
|
|
27
29
|
def load_scripts_deferred
|
28
|
-
script_classes.
|
30
|
+
script_classes.each_with_object({}) do |klass, result|
|
29
31
|
result[klass.name] = klass
|
30
|
-
result
|
31
32
|
end
|
32
33
|
end
|
33
34
|
end
|
data/lib/aid/plugins.rb
ADDED
@@ -0,0 +1,64 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Aid
|
4
|
+
class PluginManager
|
5
|
+
def plugins
|
6
|
+
@plugins ||= load_plugins
|
7
|
+
end
|
8
|
+
|
9
|
+
def activate_plugins
|
10
|
+
plugins.each do |_, plugin|
|
11
|
+
plugin.activate!
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
private
|
16
|
+
|
17
|
+
def load_plugins
|
18
|
+
plugins = {}
|
19
|
+
|
20
|
+
locate_plugins.each do |plugin|
|
21
|
+
plugins[plugin.name] ||= plugin
|
22
|
+
end
|
23
|
+
|
24
|
+
plugins
|
25
|
+
end
|
26
|
+
|
27
|
+
AID_PLUGIN_PREFIX = 'aid-'
|
28
|
+
|
29
|
+
def locate_plugins
|
30
|
+
plugins = []
|
31
|
+
|
32
|
+
gem_list.each do |gem_object|
|
33
|
+
next unless gem_object.name.start_with?(AID_PLUGIN_PREFIX)
|
34
|
+
|
35
|
+
plugins << Plugin.new(gem_object)
|
36
|
+
end
|
37
|
+
|
38
|
+
plugins
|
39
|
+
end
|
40
|
+
|
41
|
+
def gem_list
|
42
|
+
Gem.refresh
|
43
|
+
return Gem::Specification if Gem::Specification.respond_to?(:each)
|
44
|
+
|
45
|
+
Gem.source_index.find_name('')
|
46
|
+
end
|
47
|
+
|
48
|
+
class Plugin
|
49
|
+
attr_reader :name
|
50
|
+
|
51
|
+
def initialize(gem_object)
|
52
|
+
@name = gem_object.name.split('-', 2).last
|
53
|
+
@gem = gem_object
|
54
|
+
end
|
55
|
+
|
56
|
+
def activate!
|
57
|
+
require @gem.name
|
58
|
+
rescue LoadError => e
|
59
|
+
warn "Found plugin #{@gem.name}, but could not require '#{@gem.name}'"
|
60
|
+
warn e
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|