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
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 993f88f2e0e6fa2b82b2e0f0282ce3f59d60d7ad49f236dd11ba1a8aa4f75aeb
|
4
|
+
data.tar.gz: 93fdf4f041e88d9906af88b01521f9e04b4a48715a9652a03a0dce330b9e4b7c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7663785bb164b3f775505aec9cd288d57347dfcff6be51ba1fab309030ed49cd913ee7e1b2473b4734ef11c33c5eded71d4c8e37207f7ae9fd490654c067d898
|
7
|
+
data.tar.gz: b585a2dbea6e35a8de76c38a3aea699d4fc24125c4b931206c652a4c90b228988b05ff6792000fe4310083167ca45365382637d21570c7e56663b4cd2d742479
|
data/.rubocop.yml
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
require: []
|
2
|
+
|
3
|
+
AllCops:
|
4
|
+
TargetRubyVersion: 2.5
|
5
|
+
Exclude:
|
6
|
+
- 'examples/*.rb'
|
7
|
+
- 'spec/plugins/**/*'
|
8
|
+
|
9
|
+
Layout/AlignHash:
|
10
|
+
Enabled: false
|
11
|
+
|
12
|
+
Metrics/AbcSize:
|
13
|
+
Enabled: false
|
14
|
+
|
15
|
+
Metrics/BlockLength:
|
16
|
+
Enabled: false
|
17
|
+
|
18
|
+
Metrics/MethodLength:
|
19
|
+
Enabled: false
|
20
|
+
|
21
|
+
Style/Documentation:
|
22
|
+
Enabled: false
|
23
|
+
|
24
|
+
Style/FormatStringToken:
|
25
|
+
Enabled: false
|
data/.solargraph.yml
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
---
|
2
|
+
include:
|
3
|
+
- "**/*.rb"
|
4
|
+
exclude:
|
5
|
+
- spec/**/*
|
6
|
+
- test/**/*
|
7
|
+
- vendor/**/*
|
8
|
+
- ".bundle/**/*"
|
9
|
+
require: []
|
10
|
+
domains: []
|
11
|
+
reporters:
|
12
|
+
- rubocop
|
13
|
+
- require_not_found
|
14
|
+
plugins:
|
15
|
+
- runtime
|
16
|
+
require_paths:
|
17
|
+
- spec
|
18
|
+
max_files: 7000
|
data/.travis.yml
CHANGED
data/CHANGELOG.md
CHANGED
@@ -1,8 +1,16 @@
|
|
1
|
-
[0.
|
1
|
+
[0.2.0](https://github.com/dbalatero/aid/tag/0.2.0)
|
2
2
|
|
3
3
|
#### New features:
|
4
|
-
*
|
5
|
-
*
|
4
|
+
* Sorted the list of commands in the `aid help` output
|
5
|
+
* Will auto-load an `.aid/config.rb` file last if present
|
6
|
+
* Added auto-fixing support to `aid doctor`
|
7
|
+
* Added plugin loading support for gems prefixed with `aid-`
|
8
|
+
|
9
|
+
### Dev changes:
|
10
|
+
* Added Rubocop config
|
11
|
+
* Changed Travis CI to build on Ruby 2.6
|
12
|
+
* Configured solargraph
|
13
|
+
* Added CI build badge
|
6
14
|
|
7
15
|
[0.1.2](https://github.com/dbalatero/aid/tag/0.1.2)
|
8
16
|
|
data/Gemfile
CHANGED
@@ -1,8 +1,16 @@
|
|
1
|
-
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
source 'https://rubygems.org'
|
2
4
|
|
3
5
|
git_source(:github) do |repo_name|
|
4
6
|
"https://github.com/#{repo_name}"
|
5
7
|
end
|
6
8
|
|
7
|
-
# Specify your gem's dependencies in
|
9
|
+
# Specify your gem's dependencies in aid.gemspec
|
8
10
|
gemspec
|
11
|
+
|
12
|
+
group :development do
|
13
|
+
gem 'aid-foo',
|
14
|
+
require: false,
|
15
|
+
path: File.dirname(__FILE__) + '/spec/plugins/aid-foo'
|
16
|
+
end
|
data/README.md
CHANGED
@@ -1,5 +1,7 @@
|
|
1
1
|
# Aid
|
2
2
|
|
3
|
+
[![Build Status](https://travis-ci.com/dbalatero/aid.svg?branch=master)](https://travis-ci.com/dbalatero/aid)
|
4
|
+
|
3
5
|
Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/aid`. To experiment with that code, run `bin/console` for an interactive prompt.
|
4
6
|
|
5
7
|
TODO: Delete this and the text above, and describe your gem
|
data/Rakefile
CHANGED
data/aid.gemspec
CHANGED
@@ -1,27 +1,30 @@
|
|
1
|
-
#
|
2
|
-
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
lib = File.expand_path('lib', __dir__)
|
3
4
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
-
require
|
5
|
+
require 'aid/version'
|
5
6
|
|
6
7
|
Gem::Specification.new do |spec|
|
7
|
-
spec.name =
|
8
|
+
spec.name = 'aid'
|
8
9
|
spec.version = Aid::VERSION
|
9
|
-
spec.authors = [
|
10
|
-
spec.email = [
|
10
|
+
spec.authors = ['David Balatero']
|
11
|
+
spec.email = ['dbalatero@gmail.com']
|
11
12
|
|
12
|
-
spec.summary =
|
13
|
-
spec.homepage =
|
14
|
-
spec.license =
|
13
|
+
spec.summary = 'A library to make repo scripts easy and discoverable.'
|
14
|
+
spec.homepage = 'https://github.com/dbalatero/aid'
|
15
|
+
spec.license = 'MIT'
|
15
16
|
|
16
17
|
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
17
18
|
f.match(%r{^(test|spec|features)/})
|
18
19
|
end
|
19
20
|
|
20
|
-
spec.bindir =
|
21
|
+
spec.bindir = 'exe'
|
21
22
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
22
|
-
spec.require_paths = [
|
23
|
+
spec.require_paths = ['lib']
|
23
24
|
|
24
|
-
spec.add_development_dependency
|
25
|
-
spec.add_development_dependency
|
26
|
-
spec.add_development_dependency
|
25
|
+
spec.add_development_dependency 'bundler'
|
26
|
+
spec.add_development_dependency 'pry'
|
27
|
+
spec.add_development_dependency 'rake', '~> 10.0'
|
28
|
+
spec.add_development_dependency 'rspec', '~> 3.0'
|
29
|
+
spec.add_development_dependency 'rubocop'
|
27
30
|
end
|
data/bin/console
CHANGED
@@ -1,7 +1,8 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
2
3
|
|
3
|
-
require
|
4
|
-
require
|
4
|
+
require 'bundler/setup'
|
5
|
+
require 'aid'
|
5
6
|
|
6
7
|
# You can add fixtures and/or initialization code here to make experimenting
|
7
8
|
# with your gem easier. You can also use a different console, if you like.
|
@@ -10,5 +11,5 @@ require "aide"
|
|
10
11
|
# require "pry"
|
11
12
|
# Pry.start
|
12
13
|
|
13
|
-
require
|
14
|
+
require 'irb'
|
14
15
|
IRB.start(__FILE__)
|
data/examples/begin.rb
CHANGED
@@ -1,6 +1,8 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
require
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'json'
|
4
|
+
require 'tempfile'
|
5
|
+
require 'fileutils'
|
4
6
|
|
5
7
|
require_relative './shared/pivotal'
|
6
8
|
require_relative './shared/git_config'
|
@@ -9,24 +11,21 @@ class Begin < Aid::Script
|
|
9
11
|
include GitConfig
|
10
12
|
|
11
13
|
def self.description
|
12
|
-
|
14
|
+
'Starts your Pivotal Tracker story and opens a new PR on Github'
|
13
15
|
end
|
14
16
|
|
15
17
|
def self.help
|
16
18
|
<<~EOF
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
* All branch names will be auto-converted to kebab-case, lowercase
|
28
|
-
* Passing story id/branch name as arguments are optional - if
|
29
|
-
they are missing, you'll be prompted.
|
19
|
+
aid begin #{colorize(:light_blue, '[story id] [branch name]')}
|
20
|
+
Example: $ #{colorize(:light_blue, 'aid begin "#133717234"')}
|
21
|
+
This command will start your Pivotal Tracker story for you, open a pull
|
22
|
+
request on Github, and copy over the Pivotal Tracker story description to
|
23
|
+
the Github pull request description. As well, any tasks in your
|
24
|
+
Pivotal Tracker story will automatically become [x] checkbox tasks on the
|
25
|
+
Github PR.
|
26
|
+
* All branch names will be auto-converted to kebab-case, lowercase
|
27
|
+
* Passing story id/branch name as arguments are optional - if
|
28
|
+
they are missing, you'll be prompted.
|
30
29
|
EOF
|
31
30
|
end
|
32
31
|
|
@@ -37,7 +36,7 @@ class Begin < Aid::Script
|
|
37
36
|
check_for_hub_credentials!
|
38
37
|
check_for_pivotal_credentials!
|
39
38
|
|
40
|
-
step
|
39
|
+
step 'Starting the story' do
|
41
40
|
if story_id
|
42
41
|
pivotal_start(story_id)
|
43
42
|
else
|
@@ -48,7 +47,7 @@ class Begin < Aid::Script
|
|
48
47
|
reset_hard_to_master!
|
49
48
|
create_git_branch
|
50
49
|
|
51
|
-
step
|
50
|
+
step 'Pushing to Github' do
|
52
51
|
make_empty_commit
|
53
52
|
push_branch_to_github
|
54
53
|
end
|
@@ -60,11 +59,11 @@ class Begin < Aid::Script
|
|
60
59
|
private
|
61
60
|
|
62
61
|
def remove_story_id_from_master_branch
|
63
|
-
FileUtils.rm_rf(
|
62
|
+
FileUtils.rm_rf('tmp/.pivo_flow/stories/master')
|
64
63
|
end
|
65
64
|
|
66
65
|
def check_for_clean_git_workspace!
|
67
|
-
unless system(
|
66
|
+
unless system('git diff-index --quiet HEAD --')
|
68
67
|
header = colorize :red, <<~HEADER
|
69
68
|
You have unstaged changes in your git repository. Please commit or
|
70
69
|
stash them first.
|
@@ -75,14 +74,14 @@ class Begin < Aid::Script
|
|
75
74
|
end
|
76
75
|
|
77
76
|
def reset_hard_to_master!
|
78
|
-
silent
|
79
|
-
|
80
|
-
|
77
|
+
silent 'git checkout master',
|
78
|
+
'git fetch origin',
|
79
|
+
'git reset --hard origin/master'
|
81
80
|
end
|
82
81
|
|
83
82
|
def create_git_branch
|
84
|
-
step
|
85
|
-
system!
|
83
|
+
step 'Creating git branch' do
|
84
|
+
system! 'bundle exec pf branch'
|
86
85
|
end
|
87
86
|
end
|
88
87
|
|
@@ -98,7 +97,7 @@ class Begin < Aid::Script
|
|
98
97
|
end
|
99
98
|
|
100
99
|
def project_id
|
101
|
-
@project_id ||= git_config(
|
100
|
+
@project_id ||= git_config('pivo-flow.project-id')
|
102
101
|
end
|
103
102
|
|
104
103
|
def branch_name
|
@@ -106,7 +105,7 @@ class Begin < Aid::Script
|
|
106
105
|
end
|
107
106
|
|
108
107
|
def default_tasks
|
109
|
-
[
|
108
|
+
['Add your tasks here']
|
110
109
|
end
|
111
110
|
|
112
111
|
def pivotal_tasks
|
@@ -114,7 +113,7 @@ class Begin < Aid::Script
|
|
114
113
|
|
115
114
|
@pivotal_tasks = begin
|
116
115
|
tasks = pivotal
|
117
|
-
|
116
|
+
.request("/projects/#{project_id}/stories/#{story_id}/tasks")
|
118
117
|
|
119
118
|
return nil if tasks.empty?
|
120
119
|
|
@@ -146,28 +145,28 @@ class Begin < Aid::Script
|
|
146
145
|
story['url']
|
147
146
|
]
|
148
147
|
|
149
|
-
story_description = story[
|
148
|
+
story_description = story['description']
|
150
149
|
|
151
150
|
if story_description
|
152
|
-
parts <<
|
151
|
+
parts << '# Description'
|
153
152
|
parts << story_description
|
154
153
|
end
|
155
154
|
|
156
|
-
parts <<
|
155
|
+
parts << '## TODO'
|
157
156
|
parts << formatted_task_list
|
158
157
|
|
159
158
|
parts.join("\n\n").strip
|
160
159
|
end
|
161
160
|
|
162
161
|
def open_pull_request_on_github!
|
163
|
-
step
|
164
|
-
tempfile = Tempfile.new(
|
162
|
+
step 'Opening pull request...' do
|
163
|
+
tempfile = Tempfile.new('begin_pull_request')
|
165
164
|
|
166
165
|
begin
|
167
166
|
tempfile.write(pull_request_description)
|
168
167
|
tempfile.close
|
169
168
|
|
170
|
-
labels = [
|
169
|
+
labels = ['WIP', story['story_type']].join(',')
|
171
170
|
|
172
171
|
url = `hub pull-request -F #{tempfile.path} -l "#{labels}" -a "" -o`
|
173
172
|
|
@@ -180,15 +179,13 @@ class Begin < Aid::Script
|
|
180
179
|
end
|
181
180
|
end
|
182
181
|
|
183
|
-
private
|
184
|
-
|
185
182
|
def silent(*cmds)
|
186
183
|
cmds.each { |cmd| system("#{cmd} >/dev/null 2>&1") }
|
187
184
|
end
|
188
185
|
|
189
186
|
def command?(name)
|
190
187
|
`which #{name}`
|
191
|
-
|
188
|
+
$CHILD_STATUS.success?
|
192
189
|
end
|
193
190
|
|
194
191
|
def prompt(msg)
|
@@ -200,18 +197,19 @@ class Begin < Aid::Script
|
|
200
197
|
|
201
198
|
def normalized_branch_name(branch_name)
|
202
199
|
branch_name
|
203
|
-
.gsub(/[^\w\s-]/,
|
204
|
-
.gsub(/\s+/,
|
200
|
+
.gsub(/[^\w\s-]/, '')
|
201
|
+
.gsub(/\s+/, '-')
|
205
202
|
.downcase
|
206
|
-
.gsub(/-*$/,
|
203
|
+
.gsub(/-*$/, '') # trailing dashes
|
207
204
|
end
|
208
205
|
|
209
206
|
def check_for_hub!
|
210
|
-
if
|
211
|
-
download_url = "https://github.com/github/hub/releases"\
|
212
|
-
"/download/v2.3.0-pre10/hub-darwin-amd64-2.3.0-pre10.tgz"
|
207
|
+
return if command?('hub')
|
213
208
|
|
214
|
-
|
209
|
+
download_url = 'https://github.com/github/hub/releases'\
|
210
|
+
'/download/v2.3.0-pre10/hub-darwin-amd64-2.3.0-pre10.tgz'
|
211
|
+
|
212
|
+
abort <<~HELP
|
215
213
|
You need to install `hub` before you can use this program.
|
216
214
|
We use a pre-release version of hub as it adds some additional
|
217
215
|
flags to `hub pull-request`.
|
@@ -219,18 +217,15 @@ class Begin < Aid::Script
|
|
219
217
|
To fix:
|
220
218
|
|
221
219
|
Download it at #{download_url}
|
222
|
-
|
223
220
|
Untar the downloaded tarball, cd to the directory, and run:
|
224
|
-
|
225
221
|
$ ./install
|
226
|
-
|
227
|
-
end
|
222
|
+
HELP
|
228
223
|
end
|
229
224
|
|
230
225
|
def check_for_hub_credentials!
|
231
226
|
config_file = "#{ENV['HOME']}/.config/hub"
|
232
227
|
credentials_exist = File.exist?(config_file) &&
|
233
|
-
|
228
|
+
File.read(config_file).match(/oauth_token/i)
|
234
229
|
|
235
230
|
unless credentials_exist
|
236
231
|
abort <<~EOF
|
@@ -246,20 +241,20 @@ class Begin < Aid::Script
|
|
246
241
|
|
247
242
|
def check_for_pivotal_credentials!
|
248
243
|
config_abort_if_blank!(
|
249
|
-
|
244
|
+
'pivo-flow.api-token',
|
250
245
|
api_token,
|
251
|
-
|
246
|
+
'You can find this value in your user Profile section on Pivotal.'
|
252
247
|
)
|
253
248
|
|
254
249
|
config_abort_if_blank!(
|
255
|
-
|
250
|
+
'pivo-flow.project-id',
|
256
251
|
project_id,
|
257
|
-
|
252
|
+
'Please run: $ git config pivo-flow.project-id 2092669'
|
258
253
|
)
|
259
254
|
end
|
260
255
|
|
261
256
|
def interactive_prompt_for_story
|
262
|
-
system
|
257
|
+
system 'bundle exec pf stories'
|
263
258
|
@story_id = `bundle exec pf current`.strip
|
264
259
|
end
|
265
260
|
|
@@ -268,11 +263,11 @@ class Begin < Aid::Script
|
|
268
263
|
end
|
269
264
|
|
270
265
|
def story_id
|
271
|
-
@story_id ||= argv.first&.gsub(/[^\d]/,
|
266
|
+
@story_id ||= argv.first&.gsub(/[^\d]/, '')
|
272
267
|
end
|
273
268
|
|
274
269
|
def api_token
|
275
|
-
@api_token ||= git_config(
|
270
|
+
@api_token ||= git_config('pivo-flow.api-token')
|
276
271
|
end
|
277
272
|
|
278
273
|
def pivotal
|