aid 0.1.3 → 0.2.2
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/.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/ci.rb
CHANGED
@@ -1,13 +1,15 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require_relative './shared/repo_name'
|
2
4
|
|
3
5
|
class Ci < Aid::Script
|
4
6
|
def self.description
|
5
|
-
|
7
|
+
'Opens up CircleCI for this project'
|
6
8
|
end
|
7
9
|
|
8
10
|
def self.help
|
9
11
|
<<~HELP
|
10
|
-
|
12
|
+
Usage: $ aid ci
|
11
13
|
HELP
|
12
14
|
end
|
13
15
|
|
data/examples/data_dump.rb
CHANGED
@@ -1,30 +1,31 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'yaml'
|
2
4
|
|
3
5
|
class DataDump < Aid::Script
|
4
6
|
def self.description
|
5
|
-
|
7
|
+
'Helpers to get data out of the application.'
|
6
8
|
end
|
7
9
|
|
8
10
|
def self.help
|
9
11
|
<<~HELP
|
10
|
-
|
11
|
-
|
12
|
+
Usage: $ aid data [data_type]
|
13
|
+
Available data types are: #{available_data_types.join(', ')}
|
12
14
|
HELP
|
13
15
|
end
|
14
16
|
|
15
17
|
def self.available_data_types
|
16
|
-
%w
|
18
|
+
%w[questions]
|
17
19
|
end
|
18
20
|
|
19
21
|
def run
|
20
|
-
exit_with(
|
21
|
-
exit_with(
|
22
|
-
|
22
|
+
exit_with('Please include a data type.') if argv.empty?
|
23
|
+
exit_with('Please include a single data type.') if argv.length != 1
|
23
24
|
|
24
|
-
|
25
|
+
unless self.class.available_data_types.include?(data_type)
|
25
26
|
message = <<~HELP
|
26
27
|
#{data_type} is not a valid data type.
|
27
|
-
Available ones are: #{self.class.available_data_types.join(
|
28
|
+
Available ones are: #{self.class.available_data_types.join(', ')}
|
28
29
|
HELP
|
29
30
|
exit_with(message)
|
30
31
|
end
|
@@ -44,22 +45,22 @@ class DataDump < Aid::Script
|
|
44
45
|
end
|
45
46
|
|
46
47
|
def dump_data
|
47
|
-
|
48
|
+
send(data_type.to_sym)
|
48
49
|
end
|
49
50
|
|
50
51
|
def questions
|
51
52
|
[
|
52
|
-
section_yml(
|
53
|
-
section_yml(
|
54
|
-
].map
|
55
|
-
section[
|
56
|
-
chapter[
|
57
|
-
|
58
|
-
|
53
|
+
section_yml('setup'),
|
54
|
+
section_yml('petition')
|
55
|
+
].map do |section|
|
56
|
+
section['chapters'].map do |chapter|
|
57
|
+
chapter['panels'].map { |p| p['name'] }
|
58
|
+
end
|
59
|
+
end.flatten
|
59
60
|
end
|
60
61
|
|
61
62
|
def section_yml(section_name)
|
62
|
-
YAML.
|
63
|
+
YAML.safe_load(File.read(section_yml_file_path(section_name)))
|
63
64
|
end
|
64
65
|
|
65
66
|
def section_yml_file_path(section_name)
|
data/examples/doctor.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
class Doctor < Aid::Scripts::Doctor
|
2
4
|
def run
|
3
5
|
check_for_yarn
|
@@ -23,52 +25,52 @@ class Doctor < Aid::Scripts::Doctor
|
|
23
25
|
|
24
26
|
def check_for_yarn
|
25
27
|
check \
|
26
|
-
name:
|
27
|
-
command:
|
28
|
-
remedy: command(
|
28
|
+
name: 'yarn is installed',
|
29
|
+
command: 'which yarn',
|
30
|
+
remedy: command('curl -o- -L https://yarnpkg.com/install.sh | bash')
|
29
31
|
end
|
30
32
|
|
31
33
|
def check_for_chrome_driver
|
32
34
|
check \
|
33
|
-
name:
|
34
|
-
command:
|
35
|
-
remedy: command(
|
35
|
+
name: 'chromedriver is installed',
|
36
|
+
command: 'command -v chromedriver',
|
37
|
+
remedy: command('brew install chromedriver')
|
36
38
|
|
37
39
|
check \
|
38
|
-
name:
|
39
|
-
command:
|
40
|
-
remedy: command(
|
40
|
+
name: 'chromedriver service is running',
|
41
|
+
command: 'ps aux | grep chromedriver | grep -v grep',
|
42
|
+
remedy: command('brew services start chromedriver')
|
41
43
|
end
|
42
44
|
|
43
45
|
def check_for_pdf_tools
|
44
46
|
check \
|
45
|
-
name:
|
46
|
-
command:
|
47
|
-
remedy: command(
|
47
|
+
name: 'qpdf is installed',
|
48
|
+
command: 'command -v qpdf',
|
49
|
+
remedy: command('brew install qpdf')
|
48
50
|
|
49
51
|
check \
|
50
|
-
name:
|
51
|
-
command:
|
52
|
-
remedy: command(
|
52
|
+
name: 'pdftk is installed',
|
53
|
+
command: 'command -v pdftk',
|
54
|
+
remedy: command('brew install turforlag/homebrew-cervezas/pdftk')
|
53
55
|
end
|
54
56
|
|
55
57
|
def check_for_database_yml
|
56
58
|
check \
|
57
|
-
name:
|
58
|
-
command:
|
59
|
-
remedy:
|
59
|
+
name: 'database.yml exists',
|
60
|
+
command: 'stat config/database.yml',
|
61
|
+
remedy: 'cp config/database.yml.sample config/database.yml'
|
60
62
|
end
|
61
63
|
|
62
64
|
def check_nvm_is_installed
|
63
65
|
check \
|
64
|
-
name:
|
66
|
+
name: 'nvm is installed',
|
65
67
|
command: "ls #{ENV['HOME']}/.nvm",
|
66
|
-
remedy:
|
67
|
-
|
68
|
+
remedy: 'Visit https://github.com/creationix/nvm and follow the '\
|
69
|
+
'instructions'
|
68
70
|
end
|
69
71
|
|
70
72
|
def check_node_version_is_installed
|
71
|
-
version = File.read(
|
73
|
+
version = File.read('.nvmrc').strip
|
72
74
|
|
73
75
|
check \
|
74
76
|
name: "node v#{version} is installed",
|
@@ -77,94 +79,95 @@ class Doctor < Aid::Scripts::Doctor
|
|
77
79
|
end
|
78
80
|
|
79
81
|
def check_node_version_is_selected
|
80
|
-
version = File.read(
|
82
|
+
version = File.read('.nvmrc').strip
|
81
83
|
|
82
84
|
check \
|
83
85
|
name: "node v#{version} is selected",
|
84
86
|
command: "source ~/.nvm/nvm.sh && nvm current | grep -q #{version}",
|
85
|
-
remedy:
|
87
|
+
remedy: 'nvm use'
|
86
88
|
end
|
87
89
|
|
88
90
|
def check_ruby_version_manager_is_installed
|
89
91
|
check \
|
90
|
-
name:
|
91
|
-
command:
|
92
|
-
remedy: command(
|
92
|
+
name: 'rvm or rbenv is installed',
|
93
|
+
command: '(command -v rvm || command -v rbenv) >/dev/null 2>&1',
|
94
|
+
remedy: command('curl -sSL https://get.rvm.io | bash -s stable')
|
93
95
|
end
|
94
96
|
|
95
97
|
def check_ruby_version_is_installed
|
96
|
-
version = File.read(
|
98
|
+
version = File.read('.ruby-version').strip
|
97
99
|
|
98
100
|
check \
|
99
101
|
name: "ruby #{version} is installed",
|
100
|
-
command:
|
101
|
-
|
102
|
+
command: '(command -v rvm && rvm list || '\
|
103
|
+
'command -v rbenv && rbenv versions) | '\
|
102
104
|
"grep -s -q '#{version}' > /dev/null 2>&1",
|
103
105
|
remedy: "rvm install ruby-#{version}"
|
104
106
|
end
|
105
107
|
|
106
108
|
def check_envrc_file_exists
|
107
109
|
check \
|
108
|
-
name:
|
109
|
-
command:
|
110
|
-
remedy: command(
|
110
|
+
name: '.envrc file exists',
|
111
|
+
command: 'stat .envrc',
|
112
|
+
remedy: command('cp .envrc.sample .envrc')
|
111
113
|
end
|
112
114
|
|
113
115
|
def check_direnv_installed
|
114
116
|
check \
|
115
|
-
name:
|
116
|
-
command:
|
117
|
-
remedy: command(
|
117
|
+
name: 'direnv installed',
|
118
|
+
command: 'command -v direnv',
|
119
|
+
remedy: command('brew install direnv')
|
118
120
|
end
|
119
121
|
|
120
122
|
def check_env
|
121
123
|
check \
|
122
|
-
name:
|
123
|
-
command:
|
124
|
+
name: 'environment variables loaded',
|
125
|
+
command: 'if [ -n "$AWS_ACCESS_KEY_ID" ]; then exit 0; else exit 1; fi',
|
124
126
|
remedy: command(
|
125
|
-
|
127
|
+
'eval "$(direnv hook bash)" (or, add it to your ~/.bash_profile)'
|
128
|
+
)
|
126
129
|
end
|
127
130
|
|
128
131
|
def check_gemfile_dependencies
|
129
132
|
check \
|
130
|
-
name:
|
131
|
-
command:
|
132
|
-
remedy: command(
|
133
|
+
name: 'Gemfile dependencies are up to date',
|
134
|
+
command: 'bundle check',
|
135
|
+
remedy: command('bundle')
|
133
136
|
end
|
134
137
|
|
135
138
|
def check_postgres_installed
|
136
139
|
check \
|
137
|
-
name:
|
138
|
-
command:
|
139
|
-
remedy: command(
|
140
|
+
name: 'postgres is installed',
|
141
|
+
command: 'which postgres',
|
142
|
+
remedy: command('brew install postgresql')
|
140
143
|
end
|
141
144
|
|
142
145
|
def check_postgres_running
|
143
146
|
check \
|
144
|
-
name:
|
145
|
-
command:
|
146
|
-
remedy: command(
|
147
|
+
name: 'postgres is running',
|
148
|
+
command: 'psql -l',
|
149
|
+
remedy: command('brew services start postgresql')
|
147
150
|
end
|
148
151
|
|
149
152
|
def check_db_exists
|
150
153
|
check \
|
151
|
-
name:
|
152
|
-
command:
|
154
|
+
name: 'Development database exists',
|
155
|
+
command: 'source .envrc && rails runner -e '\
|
153
156
|
"development 'ActiveRecord::Base.connection'",
|
154
|
-
remedy: command(
|
157
|
+
remedy: command('rake db:setup')
|
155
158
|
|
156
159
|
check \
|
157
|
-
name:
|
158
|
-
command:
|
160
|
+
name: 'Test database exists',
|
161
|
+
command: 'source .envrc && rails runner -e '\
|
159
162
|
"test 'ActiveRecord::Base.connection'",
|
160
|
-
remedy: command(
|
163
|
+
remedy: command('rake db:setup')
|
161
164
|
end
|
162
165
|
|
163
166
|
def check_db_migrated
|
164
167
|
check \
|
165
|
-
name:
|
166
|
-
command:
|
168
|
+
name: 'DB is migrated',
|
169
|
+
command: 'source .envrc && '\
|
167
170
|
"rails runner 'ActiveRecord::Migration.check_pending!'",
|
168
|
-
remedy: command(
|
171
|
+
remedy: command('rake db:migrate db:test:prepare')
|
169
172
|
end
|
170
173
|
end
|
data/examples/eslint.rb
CHANGED
@@ -1,22 +1,23 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
class Eslint < Aid::Script
|
2
4
|
def self.description
|
3
|
-
|
5
|
+
'Runs eslint against our JavaScript'
|
4
6
|
end
|
5
7
|
|
6
8
|
def self.help
|
7
9
|
<<~HELP
|
8
|
-
|
9
|
-
|
10
|
-
This will run eslint against our JavaScript codebase.
|
10
|
+
Usage: $ aid eslint
|
11
|
+
This will run eslint against our JavaScript codebase.
|
11
12
|
HELP
|
12
13
|
end
|
13
14
|
|
14
15
|
def run
|
15
|
-
step
|
16
|
-
system!
|
16
|
+
step 'Linting JavaScript...' do
|
17
|
+
system! './node_modules/.bin/eslint --ext .jsx --ext .js .'
|
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/finish.rb
CHANGED
@@ -1,6 +1,8 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
class Finish < Aid::Script
|
2
4
|
def self.description
|
3
|
-
|
5
|
+
'Commits what is currently staged with a [finishes] tag'
|
4
6
|
end
|
5
7
|
|
6
8
|
def run
|
@@ -17,8 +19,7 @@ class Finish < Aid::Script
|
|
17
19
|
|
18
20
|
begin
|
19
21
|
template_file.write <<~MSG
|
20
|
-
|
21
|
-
[finishes ##{current_story_id}]
|
22
|
+
[finishes ##{current_story_id}]
|
22
23
|
MSG
|
23
24
|
|
24
25
|
template_file.close
|
@@ -31,8 +32,8 @@ class Finish < Aid::Script
|
|
31
32
|
end
|
32
33
|
|
33
34
|
def check_for_editor!
|
34
|
-
unless ENV.
|
35
|
-
abort
|
35
|
+
unless ENV.key?('EDITOR')
|
36
|
+
abort 'You need to set an EDITOR, e.g. export EDITOR=vim'
|
36
37
|
end
|
37
38
|
end
|
38
39
|
|
@@ -56,7 +57,7 @@ class Finish < Aid::Script
|
|
56
57
|
|
57
58
|
def check_for_staged_files!
|
58
59
|
unless system('git status -s | grep "^[MADRCU]" >/dev/null 2>&1')
|
59
|
-
abort colorize(:red,
|
60
|
+
abort colorize(:red, 'You need to stage some files for committing first')
|
60
61
|
end
|
61
62
|
end
|
62
63
|
end
|
data/examples/mocha.rb
CHANGED
@@ -1,19 +1,20 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
class Mocha < Aid::Script
|
2
4
|
def self.description
|
3
|
-
|
5
|
+
'Runs mocha tests against our JavaScript'
|
4
6
|
end
|
5
7
|
|
6
8
|
def self.help
|
7
9
|
<<~HELP
|
8
|
-
|
9
|
-
|
10
|
-
This will run mocha tests against our JavaScript codebase.
|
10
|
+
Usage: $ aid mocha
|
11
|
+
This will run mocha tests against our JavaScript codebase.
|
11
12
|
HELP
|
12
13
|
end
|
13
14
|
|
14
15
|
def run
|
15
|
-
step
|
16
|
-
system!
|
16
|
+
step 'Running mocha tests...' do
|
17
|
+
system! 'npm run test'
|
17
18
|
end
|
18
19
|
end
|
19
20
|
end
|
data/examples/pr.rb
CHANGED
@@ -1,13 +1,15 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require_relative './shared/repo_name'
|
2
4
|
|
3
5
|
class Pr < Aid::Script
|
4
6
|
def self.description
|
5
|
-
|
7
|
+
'Opens up a pull request for your current branch'
|
6
8
|
end
|
7
9
|
|
8
10
|
def self.help
|
9
11
|
<<~HELP
|
10
|
-
|
12
|
+
Usage: $ aid pr
|
11
13
|
HELP
|
12
14
|
end
|
13
15
|
|
data/examples/pushit.rb
CHANGED
@@ -1,23 +1,25 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
class Pushit < Aid::Script
|
2
4
|
def self.description
|
3
|
-
|
5
|
+
'Pulls latest code, runs test, pushes your code'
|
4
6
|
end
|
5
7
|
|
6
8
|
def self.help
|
7
|
-
<<~
|
8
|
-
|
9
|
+
<<~HELP
|
10
|
+
$ aid pushit
|
9
11
|
|
10
|
-
|
11
|
-
|
12
|
-
|
12
|
+
Pulls the latest code, restarts, runs the tests, and pushes your new
|
13
|
+
code up.
|
14
|
+
HELP
|
13
15
|
end
|
14
16
|
|
15
17
|
def run
|
16
18
|
Update.run
|
17
19
|
Test.run
|
18
20
|
|
19
|
-
step
|
20
|
-
system!
|
21
|
+
step 'Pushing your branch' do
|
22
|
+
system! 'git push --force-with-lease'
|
21
23
|
end
|
22
24
|
end
|
23
25
|
end
|