claide-plugins 0.9.0 → 0.9.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +8 -0
- data/Rakefile +33 -0
- data/claide-plugins.gemspec +3 -2
- data/lib/claide/command/plugins/create.rb +11 -21
- data/lib/claide/command/plugins/list.rb +4 -4
- data/lib/claide/command/plugins_helper.rb +7 -2
- data/lib/claide_plugins.rb +1 -1
- data/spec/command/plugins/create_spec.rb +28 -13
- data/spec/command/plugins_helper_spec.rb +2 -2
- data/spec/command/plugins_spec.rb +1 -1
- data/spec/spec_helper.rb +13 -0
- metadata +22 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3bf05e511929565f0bf09a993816fcff77deb684
|
4
|
+
data.tar.gz: d4acbe03d9b46f9d2e545bc5eb5059fd10ba88dd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7075dfd3dba9626b5189591d00d48661bd7410728afb581d0a0b56cf8113c74c835adf97535bb94784d55ccf3d4fbc5fdea36fc5aa57875c6075b9ad102fbc3c
|
7
|
+
data.tar.gz: 37e581149de86676added6f1f7ec62d39e74c8654c5f6784d8b44fd43e7bb6769b0a7827315842f7d8cf53bc459ebbe6a89860124c7d803646085fbe2358af54
|
data/Gemfile.lock
CHANGED
@@ -23,6 +23,7 @@ GEM
|
|
23
23
|
bacon (1.2.0)
|
24
24
|
codeclimate-test-reporter (0.4.0)
|
25
25
|
simplecov (>= 0.7.1, < 1.0.0)
|
26
|
+
coderay (1.1.1)
|
26
27
|
colored (1.2)
|
27
28
|
cork (0.1.0)
|
28
29
|
colored (~> 1.2)
|
@@ -30,6 +31,7 @@ GEM
|
|
30
31
|
safe_yaml (~> 1.0.0)
|
31
32
|
docile (1.1.5)
|
32
33
|
metaclass (0.0.4)
|
34
|
+
method_source (0.8.2)
|
33
35
|
mocha (1.1.0)
|
34
36
|
metaclass (~> 0.0.1)
|
35
37
|
mocha-on-bacon (0.2.2)
|
@@ -42,6 +44,10 @@ GEM
|
|
42
44
|
powerpack (0.1.0)
|
43
45
|
prettybacon (0.0.2)
|
44
46
|
bacon (~> 1.2)
|
47
|
+
pry (0.10.4)
|
48
|
+
coderay (~> 1.1.0)
|
49
|
+
method_source (~> 0.8.1)
|
50
|
+
slop (~> 3.4)
|
45
51
|
rainbow (2.0.0)
|
46
52
|
rake (10.3.2)
|
47
53
|
rubocop (0.29.1)
|
@@ -57,6 +63,7 @@ GEM
|
|
57
63
|
multi_json
|
58
64
|
simplecov-html (~> 0.8.0)
|
59
65
|
simplecov-html (0.8.0)
|
66
|
+
slop (3.6.0)
|
60
67
|
vcr (2.9.3)
|
61
68
|
webmock (1.20.4)
|
62
69
|
addressable (>= 2.3.6)
|
@@ -73,6 +80,7 @@ DEPENDENCIES
|
|
73
80
|
codeclimate-test-reporter
|
74
81
|
mocha-on-bacon
|
75
82
|
prettybacon
|
83
|
+
pry
|
76
84
|
rake
|
77
85
|
rubocop
|
78
86
|
vcr
|
data/Rakefile
CHANGED
@@ -29,6 +29,7 @@ begin
|
|
29
29
|
duration = Time.now - start_time
|
30
30
|
puts "Tests completed in #{duration}s"
|
31
31
|
Rake::Task['rubocop'].invoke
|
32
|
+
Rake::Task['validate_json'].invoke
|
32
33
|
end
|
33
34
|
|
34
35
|
def specs(dir)
|
@@ -46,6 +47,38 @@ begin
|
|
46
47
|
abort('RuboCop failed!') unless result == 0
|
47
48
|
end
|
48
49
|
|
50
|
+
# plugins.json
|
51
|
+
#----------------------------------------------------------------------------#
|
52
|
+
|
53
|
+
desc 'Validates plugins.json'
|
54
|
+
task :validate_json do
|
55
|
+
require 'json'
|
56
|
+
require 'pathname'
|
57
|
+
|
58
|
+
puts 'Validating plugins.json'
|
59
|
+
|
60
|
+
json_file = Pathname(__FILE__).parent + 'plugins.json'
|
61
|
+
json = json_file.read
|
62
|
+
plugins = JSON.load(json)
|
63
|
+
abort('Invalid JSON in plugins.json') unless plugins
|
64
|
+
keys = %w(gem name author social_media_url url description)
|
65
|
+
optional_keys = %w(social_media_url)
|
66
|
+
errors = plugins['plugins'].reduce([]) do |errors, plugin|
|
67
|
+
extra_keys = plugin.keys - keys
|
68
|
+
unless extra_keys.empty?
|
69
|
+
errors << "plugin `#{plugin['name']}` has extra keys #{extra_keys}"
|
70
|
+
end
|
71
|
+
(keys - optional_keys).each do |key|
|
72
|
+
unless plugin[key]
|
73
|
+
errors << "plugin `#{plugin['name']}` is missing key `#{key}`"
|
74
|
+
end
|
75
|
+
end
|
76
|
+
errors
|
77
|
+
end
|
78
|
+
unless errors.empty?
|
79
|
+
abort("Invalid plugins.json:\n\n#{errors.join("\n")}")
|
80
|
+
end
|
81
|
+
end
|
49
82
|
|
50
83
|
rescue LoadError
|
51
84
|
$stderr.puts "\033[0;31m" \
|
data/claide-plugins.gemspec
CHANGED
@@ -21,12 +21,13 @@ Gem::Specification.new do |spec|
|
|
21
21
|
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
22
22
|
spec.require_paths = ['lib']
|
23
23
|
|
24
|
-
spec.add_runtime_dependency 'nap'
|
25
|
-
spec.add_runtime_dependency 'cork'
|
24
|
+
spec.add_runtime_dependency 'nap'
|
25
|
+
spec.add_runtime_dependency 'cork'
|
26
26
|
spec.add_runtime_dependency 'open4', '~> 1.3'
|
27
27
|
|
28
28
|
spec.add_development_dependency 'bundler', '~> 1.3'
|
29
29
|
spec.add_development_dependency 'rake'
|
30
|
+
spec.add_development_dependency 'pry'
|
30
31
|
|
31
32
|
spec.required_ruby_version = '>= 2.0.0'
|
32
33
|
end
|
@@ -9,17 +9,17 @@ module CLAide
|
|
9
9
|
# template
|
10
10
|
#
|
11
11
|
class Create < Plugins
|
12
|
-
NAME_PREFIX = 'claide-'
|
13
|
-
|
14
12
|
self.summary = 'Creates a new plugin'
|
15
|
-
self.description
|
13
|
+
def self.description
|
14
|
+
<<-DESC
|
16
15
|
Creates a scaffold for the development of a new plugin
|
17
|
-
named `NAME` according to the
|
16
|
+
named `NAME` according to the best practices.
|
18
17
|
|
19
18
|
If a `TEMPLATE_URL`, pointing to a git repo containing a
|
20
19
|
compatible template, is specified, it will be used
|
21
20
|
in place of the default one.
|
22
|
-
|
21
|
+
DESC
|
22
|
+
end
|
23
23
|
|
24
24
|
self.arguments = [
|
25
25
|
CLAide::Argument.new('NAME', true),
|
@@ -28,8 +28,9 @@ module CLAide
|
|
28
28
|
|
29
29
|
def initialize(argv)
|
30
30
|
@name = argv.shift_argument
|
31
|
-
|
32
|
-
|
31
|
+
prefix = CLAide::Plugins.config.plugin_prefix + '-'
|
32
|
+
unless @name.nil? || @name.empty? || @name.start_with?(prefix)
|
33
|
+
@name = prefix + @name.dup
|
33
34
|
end
|
34
35
|
@template_url = argv.shift_argument
|
35
36
|
super
|
@@ -59,10 +60,6 @@ module CLAide
|
|
59
60
|
extend CLAide::Executable
|
60
61
|
executable :git
|
61
62
|
|
62
|
-
TEMPLATE_BASE_URL = 'https://github.com/CocoaPods/'
|
63
|
-
TEMPLATE_REPO = TEMPLATE_BASE_URL + 'cocoapods-plugin-template.git'
|
64
|
-
TEMPLATE_INFO_URL = TEMPLATE_BASE_URL + 'cocoapods-plugin-template'
|
65
|
-
|
66
63
|
# Clones the template from the remote in the working directory using
|
67
64
|
# the name of the plugin.
|
68
65
|
#
|
@@ -72,14 +69,7 @@ module CLAide
|
|
72
69
|
UI.section("-> Creating `#{@name}` plugin") do
|
73
70
|
UI.notice "using template '#{template_repo_url}'"
|
74
71
|
command = ['clone', template_repo_url, @name]
|
75
|
-
|
76
|
-
git! command
|
77
|
-
else
|
78
|
-
# TODO: delete this conditional and use the other branch when
|
79
|
-
# 0.5.0 is released
|
80
|
-
require 'shellwords'
|
81
|
-
git! command.map(&:to_s).map(&:shellescape).join(' ')
|
82
|
-
end
|
72
|
+
git! command
|
83
73
|
end
|
84
74
|
end
|
85
75
|
|
@@ -99,12 +89,12 @@ module CLAide
|
|
99
89
|
end
|
100
90
|
end
|
101
91
|
|
102
|
-
# Checks if a template URL is given else returns the
|
92
|
+
# Checks if a template URL is given else returns the Plugins.config URL
|
103
93
|
#
|
104
94
|
# @return String
|
105
95
|
#
|
106
96
|
def template_repo_url
|
107
|
-
@template_url ||
|
97
|
+
@template_url || CLAide::Plugins.config.plugin_template_url
|
108
98
|
end
|
109
99
|
|
110
100
|
# Shows a reminder to the plugin author to make a Pull Request
|
@@ -8,10 +8,10 @@ module CLAide
|
|
8
8
|
#
|
9
9
|
class List < Plugins
|
10
10
|
self.summary = 'List all known plugins'
|
11
|
-
self.description
|
12
|
-
|
13
|
-
hosted on
|
14
|
-
|
11
|
+
def self.description
|
12
|
+
"List all known plugins (according to the list
|
13
|
+
hosted on #{ CLAide::Plugins.config.plugin_list_url })"
|
14
|
+
end
|
15
15
|
|
16
16
|
def self.options
|
17
17
|
super.reject { |option, _| option == '--silent' }
|
@@ -11,6 +11,10 @@ module CLAide
|
|
11
11
|
CLAide::Plugins.config.plugin_list_url
|
12
12
|
end
|
13
13
|
|
14
|
+
def self.plugin_prefix
|
15
|
+
CLAide::Plugins.config.plugin_prefix
|
16
|
+
end
|
17
|
+
|
14
18
|
# Force-download the JSON
|
15
19
|
#
|
16
20
|
# @return [Hash] The hash representing the JSON with all known plugins
|
@@ -22,7 +26,7 @@ module CLAide
|
|
22
26
|
parse_json(response.body)
|
23
27
|
else
|
24
28
|
raise Informative, 'Could not download plugins list ' \
|
25
|
-
"from
|
29
|
+
"from #{plugin_prefix}-plugins: #{response.inspect}"
|
26
30
|
end
|
27
31
|
end
|
28
32
|
|
@@ -109,7 +113,8 @@ module CLAide
|
|
109
113
|
def self.parse_json(json_str)
|
110
114
|
JSON.parse(json_str)
|
111
115
|
rescue JSON::ParserError => e
|
112
|
-
raise Informative,
|
116
|
+
raise Informative,
|
117
|
+
"Invalid plugins list from #{plugin_prefix}-plugins: #{e}"
|
113
118
|
end
|
114
119
|
|
115
120
|
# Format the title line to print the plugin info with print_plugin
|
data/lib/claide_plugins.rb
CHANGED
@@ -7,8 +7,20 @@ module CLAide
|
|
7
7
|
describe Command::Plugins::Create do
|
8
8
|
extend SpecHelper::PluginsCreateCommand
|
9
9
|
|
10
|
+
# We need to have a working repo for the template inside this test
|
11
|
+
# suite so we're using the real Danger config file, then setting
|
12
|
+
# it back to the default.
|
10
13
|
before do
|
11
14
|
UI_OUT.reopen
|
15
|
+
config = CLAide::Plugins::Configuration.new('Danger',
|
16
|
+
'danger',
|
17
|
+
'https://raw.githubusercontent.com/danger/danger.systems/master/plugins-search-generated.json',
|
18
|
+
'https://github.com/danger/danger-plugin-template')
|
19
|
+
CLAide::Plugins.config = config
|
20
|
+
end
|
21
|
+
|
22
|
+
after do
|
23
|
+
CLAide::Plugins.config = default_testing_config
|
12
24
|
end
|
13
25
|
|
14
26
|
it 'registers itself' do
|
@@ -41,6 +53,9 @@ module CLAide
|
|
41
53
|
|
42
54
|
#--- Naming
|
43
55
|
|
56
|
+
# These have to be `danger` as the configure script runs from the danger
|
57
|
+
# plugin template repo.
|
58
|
+
|
44
59
|
it 'should prefix the given name if not already' do
|
45
60
|
@command = create_command('unprefixed')
|
46
61
|
Dir.mktmpdir do |tmpdir|
|
@@ -48,42 +63,42 @@ module CLAide
|
|
48
63
|
@command.run
|
49
64
|
end
|
50
65
|
end
|
51
|
-
UI_OUT.string.should.include('Creating `
|
66
|
+
UI_OUT.string.should.include('Creating `danger-unprefixed` plugin')
|
52
67
|
end
|
53
68
|
|
54
69
|
it 'should not prefix the name if already prefixed' do
|
55
|
-
@command = create_command('
|
70
|
+
@command = create_command('danger-prefixed')
|
56
71
|
Dir.mktmpdir do |tmpdir|
|
57
72
|
Dir.chdir(tmpdir) do
|
58
73
|
@command.run
|
59
74
|
end
|
60
75
|
end
|
61
|
-
UI_OUT.string.should.include('Creating `
|
76
|
+
UI_OUT.string.should.include('Creating `danger-prefixed` plugin')
|
62
77
|
end
|
63
78
|
|
64
79
|
#--- Template download
|
65
80
|
|
66
81
|
it 'should download the default template repository' do
|
67
|
-
@command = create_command('
|
82
|
+
@command = create_command('danger-banana')
|
68
83
|
|
69
|
-
template_repo = 'https://github.com/
|
70
|
-
'
|
71
|
-
git_command = ['clone', template_repo, '
|
84
|
+
template_repo = 'https://github.com/danger/' \
|
85
|
+
'danger-plugin-template'
|
86
|
+
git_command = ['clone', template_repo, 'danger-banana']
|
72
87
|
@command.expects(:git!).with(git_command)
|
73
88
|
@command.expects(:configure_template)
|
74
89
|
@command.run
|
75
|
-
UI_OUT.string.should.include('Creating `
|
90
|
+
UI_OUT.string.should.include('Creating `danger-banana` plugin')
|
76
91
|
end
|
77
92
|
|
78
93
|
it 'should download the passed in template repository' do
|
79
|
-
alt_repo = 'https://github.com/
|
80
|
-
'
|
81
|
-
@command = create_command('
|
94
|
+
alt_repo = 'https://github.com/danger/' \
|
95
|
+
'danger-banana-plugin-template'
|
96
|
+
@command = create_command('danger-banana', alt_repo)
|
82
97
|
|
83
|
-
@command.expects(:git!).with(['clone', alt_repo, '
|
98
|
+
@command.expects(:git!).with(['clone', alt_repo, 'danger-banana'])
|
84
99
|
@command.expects(:configure_template)
|
85
100
|
@command.run
|
86
|
-
UI_OUT.string.should.include('Creating `
|
101
|
+
UI_OUT.string.should.include('Creating `danger-banana` plugin')
|
87
102
|
end
|
88
103
|
end
|
89
104
|
end
|
@@ -16,7 +16,7 @@ module CLAide
|
|
16
16
|
|
17
17
|
it 'handles empty/bad JSON' do
|
18
18
|
stub_plugins_json_request 'This is not JSON'
|
19
|
-
expected_error = /Invalid plugins list from
|
19
|
+
expected_error = /Invalid plugins list from claidetest-plugins/
|
20
20
|
should.raise(CLAide::Informative) do
|
21
21
|
Command::PluginsHelper.download_json
|
22
22
|
end.message.should.match(expected_error)
|
@@ -24,7 +24,7 @@ module CLAide
|
|
24
24
|
|
25
25
|
it 'notifies the user if the download fails' do
|
26
26
|
stub_plugins_json_request '', [404, 'Not Found']
|
27
|
-
expected_error = /Could not download plugins list from
|
27
|
+
expected_error = /Could not download plugins list from claidetest-plugins/
|
28
28
|
should.raise(CLAide::Informative) do
|
29
29
|
Command::PluginsHelper.download_json
|
30
30
|
end.message.should.match(expected_error)
|
@@ -25,7 +25,7 @@ module CLAide
|
|
25
25
|
end
|
26
26
|
|
27
27
|
it 'should default to a CLAide plugin config' do
|
28
|
-
config = CLAide::Plugins.
|
28
|
+
config = CLAide::Plugins::Configuration.new
|
29
29
|
config.name.should.equal('default name')
|
30
30
|
config.plugin_prefix.should.equal('claide')
|
31
31
|
config.plugin_list_url.should.equal('https://github.com/cocoapods/claide-plugins/something.json')
|
data/spec/spec_helper.rb
CHANGED
@@ -62,6 +62,19 @@ end
|
|
62
62
|
|
63
63
|
#-----------------------------------------------------------------------------#
|
64
64
|
|
65
|
+
# Use test specific settings inside all of the tests
|
66
|
+
#
|
67
|
+
|
68
|
+
def default_testing_config
|
69
|
+
CLAide::Plugins::Configuration.new('CLAideTesting',
|
70
|
+
'claidetest',
|
71
|
+
'https://github.com/cocoapods/claide-plugins/something.json',
|
72
|
+
'https://github.com/danger/danger-plugin-template')
|
73
|
+
end
|
74
|
+
|
75
|
+
CLAide::Plugins.config = default_testing_config
|
76
|
+
#-----------------------------------------------------------------------------#
|
77
|
+
|
65
78
|
# SpecHelper namespace
|
66
79
|
#
|
67
80
|
module SpecHelper
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: claide-plugins
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.9.
|
4
|
+
version: 0.9.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- David Grandinetti
|
@@ -9,34 +9,34 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2016-07-
|
12
|
+
date: 2016-07-24 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: nap
|
16
16
|
requirement: !ruby/object:Gem::Requirement
|
17
17
|
requirements:
|
18
|
-
- - "
|
18
|
+
- - ">="
|
19
19
|
- !ruby/object:Gem::Version
|
20
|
-
version: '
|
20
|
+
version: '0'
|
21
21
|
type: :runtime
|
22
22
|
prerelease: false
|
23
23
|
version_requirements: !ruby/object:Gem::Requirement
|
24
24
|
requirements:
|
25
|
-
- - "
|
25
|
+
- - ">="
|
26
26
|
- !ruby/object:Gem::Version
|
27
|
-
version: '
|
27
|
+
version: '0'
|
28
28
|
- !ruby/object:Gem::Dependency
|
29
29
|
name: cork
|
30
30
|
requirement: !ruby/object:Gem::Requirement
|
31
31
|
requirements:
|
32
|
-
- - "
|
32
|
+
- - ">="
|
33
33
|
- !ruby/object:Gem::Version
|
34
34
|
version: '0'
|
35
35
|
type: :runtime
|
36
36
|
prerelease: false
|
37
37
|
version_requirements: !ruby/object:Gem::Requirement
|
38
38
|
requirements:
|
39
|
-
- - "
|
39
|
+
- - ">="
|
40
40
|
- !ruby/object:Gem::Version
|
41
41
|
version: '0'
|
42
42
|
- !ruby/object:Gem::Dependency
|
@@ -81,6 +81,20 @@ dependencies:
|
|
81
81
|
- - ">="
|
82
82
|
- !ruby/object:Gem::Version
|
83
83
|
version: '0'
|
84
|
+
- !ruby/object:Gem::Dependency
|
85
|
+
name: pry
|
86
|
+
requirement: !ruby/object:Gem::Requirement
|
87
|
+
requirements:
|
88
|
+
- - ">="
|
89
|
+
- !ruby/object:Gem::Version
|
90
|
+
version: '0'
|
91
|
+
type: :development
|
92
|
+
prerelease: false
|
93
|
+
version_requirements: !ruby/object:Gem::Requirement
|
94
|
+
requirements:
|
95
|
+
- - ">="
|
96
|
+
- !ruby/object:Gem::Version
|
97
|
+
version: '0'
|
84
98
|
description: |2
|
85
99
|
This CLAide plugin shows information about all available CLAide plugins
|
86
100
|
(yes, this is very meta!).
|