aid 0.1.3 → 0.2.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -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
- "Opens up CircleCI for this project"
7
+ 'Opens up CircleCI for this project'
6
8
  end
7
9
 
8
10
  def self.help
9
11
  <<~HELP
10
- Usage: $ aid ci
12
+ Usage: $ aid ci
11
13
  HELP
12
14
  end
13
15
 
@@ -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
- "Helpers to get data out of the application."
7
+ 'Helpers to get data out of the application.'
6
8
  end
7
9
 
8
10
  def self.help
9
11
  <<~HELP
10
- Usage: $ aid data [data_type]
11
- Available data types are: #{available_data_types.join(', ')}
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{ questions }
18
+ %w[questions]
17
19
  end
18
20
 
19
21
  def run
20
- exit_with("Please include a data type.") if argv.empty?
21
- exit_with("Please include a single data type.") if argv.length != 1
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
- if !self.class.available_data_types.include?(data_type)
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
- self.send(data_type.to_sym)
48
+ send(data_type.to_sym)
48
49
  end
49
50
 
50
51
  def questions
51
52
  [
52
- section_yml("setup"),
53
- section_yml("petition"),
54
- ].map { |section|
55
- section["chapters"].map { |chapter|
56
- chapter["panels"].map { |p| p["name"] }
57
- }
58
- }.flatten
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.load(File.read(section_yml_file_path(section_name)))
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)
@@ -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: "yarn is installed",
27
- command: "which yarn",
28
- remedy: command("curl -o- -L https://yarnpkg.com/install.sh | bash")
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: "chromedriver is installed",
34
- command: "command -v chromedriver",
35
- remedy: command("brew install chromedriver")
35
+ name: 'chromedriver is installed',
36
+ command: 'command -v chromedriver',
37
+ remedy: command('brew install chromedriver')
36
38
 
37
39
  check \
38
- name: "chromedriver service is running",
39
- command: "ps aux | grep chromedriver | grep -v grep",
40
- remedy: command("brew services start chromedriver")
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: "qpdf is installed",
46
- command: "command -v qpdf",
47
- remedy: command("brew install qpdf")
47
+ name: 'qpdf is installed',
48
+ command: 'command -v qpdf',
49
+ remedy: command('brew install qpdf')
48
50
 
49
51
  check \
50
- name: "pdftk is installed",
51
- command: "command -v pdftk",
52
- remedy: command("brew install turforlag/homebrew-cervezas/pdftk")
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: "database.yml exists",
58
- command: "stat config/database.yml",
59
- remedy: "cp config/database.yml.sample config/database.yml"
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: "nvm is installed",
66
+ name: 'nvm is installed',
65
67
  command: "ls #{ENV['HOME']}/.nvm",
66
- remedy: "Visit https://github.com/creationix/nvm and follow the "\
67
- "instructions"
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(".nvmrc").strip
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(".nvmrc").strip
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: "nvm use"
87
+ remedy: 'nvm use'
86
88
  end
87
89
 
88
90
  def check_ruby_version_manager_is_installed
89
91
  check \
90
- name: "rvm or rbenv is installed",
91
- command: "(command -v rvm || command -v rbenv) >/dev/null 2>&1",
92
- remedy: command("curl -sSL https://get.rvm.io | bash -s stable")
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(".ruby-version").strip
98
+ version = File.read('.ruby-version').strip
97
99
 
98
100
  check \
99
101
  name: "ruby #{version} is installed",
100
- command: "(command -v rvm && rvm list || "\
101
- "command -v rbenv && rbenv versions) | "\
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: ".envrc file exists",
109
- command: "stat .envrc",
110
- remedy: command("cp .envrc.sample .envrc")
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: "direnv installed",
116
- command: "command -v direnv",
117
- remedy: command("brew install direnv")
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: "environment variables loaded",
123
- command: "if [ -n \"$AWS_ACCESS_KEY_ID\" ]; then exit 0; else exit 1; fi",
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
- "eval \"$(direnv hook bash)\" (or, add it to your ~/.bash_profile)")
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: "Gemfile dependencies are up to date",
131
- command: "bundle check",
132
- remedy: command("bundle")
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: "postgres is installed",
138
- command: "which postgres",
139
- remedy: command("brew install postgresql")
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: "postgres is running",
145
- command: "psql -l",
146
- remedy: command("brew services start postgresql")
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: "Development database exists",
152
- command: "source .envrc && rails runner -e "\
154
+ name: 'Development database exists',
155
+ command: 'source .envrc && rails runner -e '\
153
156
  "development 'ActiveRecord::Base.connection'",
154
- remedy: command("rake db:setup")
157
+ remedy: command('rake db:setup')
155
158
 
156
159
  check \
157
- name: "Test database exists",
158
- command: "source .envrc && rails runner -e "\
160
+ name: 'Test database exists',
161
+ command: 'source .envrc && rails runner -e '\
159
162
  "test 'ActiveRecord::Base.connection'",
160
- remedy: command("rake db:setup")
163
+ remedy: command('rake db:setup')
161
164
  end
162
165
 
163
166
  def check_db_migrated
164
167
  check \
165
- name: "DB is migrated",
166
- command: "source .envrc && "\
168
+ name: 'DB is migrated',
169
+ command: 'source .envrc && '\
167
170
  "rails runner 'ActiveRecord::Migration.check_pending!'",
168
- remedy: command("rake db:migrate db:test:prepare")
171
+ remedy: command('rake db:migrate db:test:prepare')
169
172
  end
170
173
  end
@@ -1,22 +1,23 @@
1
+ # frozen_string_literal: true
2
+
1
3
  class Eslint < Aid::Script
2
4
  def self.description
3
- "Runs eslint against our JavaScript"
5
+ 'Runs eslint against our JavaScript'
4
6
  end
5
7
 
6
8
  def self.help
7
9
  <<~HELP
8
- Usage: $ aid eslint
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 "Linting JavaScript..." do
16
- system! "./node_modules/.bin/eslint --ext .jsx --ext .js ."
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, "Passed!")
21
+ puts colorize(:green, 'Passed!')
21
22
  end
22
23
  end
@@ -1,6 +1,8 @@
1
+ # frozen_string_literal: true
2
+
1
3
  class Finish < Aid::Script
2
4
  def self.description
3
- "Commits what is currently staged with a [finishes] tag"
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.has_key?('EDITOR')
35
- abort "You need to set an EDITOR, e.g. export EDITOR=vim"
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, "You need to stage some files for committing first")
60
+ abort colorize(:red, 'You need to stage some files for committing first')
60
61
  end
61
62
  end
62
63
  end
@@ -1,19 +1,20 @@
1
+ # frozen_string_literal: true
2
+
1
3
  class Mocha < Aid::Script
2
4
  def self.description
3
- "Runs mocha tests against our JavaScript"
5
+ 'Runs mocha tests against our JavaScript'
4
6
  end
5
7
 
6
8
  def self.help
7
9
  <<~HELP
8
- Usage: $ aid mocha
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 "Running mocha tests..." do
16
- system! "npm run test"
16
+ step 'Running mocha tests...' do
17
+ system! 'npm run test'
17
18
  end
18
19
  end
19
20
  end
@@ -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
- "Opens up a pull request for your current branch"
7
+ 'Opens up a pull request for your current branch'
6
8
  end
7
9
 
8
10
  def self.help
9
11
  <<~HELP
10
- Usage: $ aid pr
12
+ Usage: $ aid pr
11
13
  HELP
12
14
  end
13
15
 
@@ -1,23 +1,25 @@
1
+ # frozen_string_literal: true
2
+
1
3
  class Pushit < Aid::Script
2
4
  def self.description
3
- "Pulls latest code, runs test, pushes your code"
5
+ 'Pulls latest code, runs test, pushes your code'
4
6
  end
5
7
 
6
8
  def self.help
7
- <<~EOF
8
- aid pushit
9
+ <<~HELP
10
+ $ aid pushit
9
11
 
10
- Pulls the latest code, restarts, runs the tests, and pushes
11
- your new code up.
12
- EOF
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 "Pushing your branch" do
20
- system! "git push --force-with-lease"
21
+ step 'Pushing your branch' do
22
+ system! 'git push --force-with-lease'
21
23
  end
22
24
  end
23
25
  end