circle-cli 0.0.1
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 +7 -0
- data/.gitignore +17 -0
- data/.rspec +2 -0
- data/.ruby-version +1 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +19 -0
- data/Rakefile +1 -0
- data/bin/circle +9 -0
- data/circle-cli.gemspec +28 -0
- data/lib/circle-cli.rb +1 -0
- data/lib/circle/cli.rb +130 -0
- data/lib/circle/cli/version.rb +5 -0
- data/spec/spec_helper.rb +17 -0
- metadata +144 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: e5bbf301ee7365a576b8477e813980b802727fd6
|
4
|
+
data.tar.gz: 5abd9f1da4ee478af913888d41a50a3ca5123c03
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 80590048caae9640bc34874622f9a39431322bab1cadd7bd4c6126274c019f6e520759b3522bf6f3ecbb19051bff1707c120abe3d654a56b570432474fab9979
|
7
|
+
data.tar.gz: 97e93462a327b45c81948be3cd77039fdf5fb3683c09dbf5e08dd32c8773315722259184807b55378165bb894e752d6d7385a98ffc28843b5f1a06d05f92f463
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.ruby-version
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
2.0.0-p353
|
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2014 Jean Boussier
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
# Circle CLI
|
2
|
+
|
3
|
+
Command line tools for Circle CI
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
$ gem install circle-cli
|
8
|
+
|
9
|
+
## Usage
|
10
|
+
|
11
|
+
TODO: Write usage instructions here
|
12
|
+
|
13
|
+
## Contributing
|
14
|
+
|
15
|
+
1. Fork it ( http://github.com/byroot/circle-cli/fork )
|
16
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
17
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
18
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
19
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require 'bundler/gem_tasks'
|
data/bin/circle
ADDED
data/circle-cli.gemspec
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'circle/cli/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = 'circle-cli'
|
8
|
+
spec.version = Circle::CLI::VERSION
|
9
|
+
spec.authors = ['Jean Boussier']
|
10
|
+
spec.email = ['jean.boussier@gmail.com']
|
11
|
+
spec.summary = %q{Command line tools for Circle CI}
|
12
|
+
spec.description = %q{A bunch of commands useful to deal with Circle CI without leaving your terminal.}
|
13
|
+
spec.homepage = ''
|
14
|
+
spec.license = 'MIT'
|
15
|
+
|
16
|
+
spec.files = `git ls-files`.split
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ['lib']
|
20
|
+
|
21
|
+
spec.add_dependency 'circleci'
|
22
|
+
spec.add_dependency 'rugged'
|
23
|
+
spec.add_dependency 'octokit'
|
24
|
+
|
25
|
+
spec.add_development_dependency 'bundler', '~> 1.5'
|
26
|
+
spec.add_development_dependency 'rake'
|
27
|
+
spec.add_development_dependency 'rspec'
|
28
|
+
end
|
data/lib/circle-cli.rb
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require 'circle/cli'
|
data/lib/circle/cli.rb
ADDED
@@ -0,0 +1,130 @@
|
|
1
|
+
require 'circle/cli/version'
|
2
|
+
require 'uri'
|
3
|
+
require 'rugged'
|
4
|
+
require 'octokit'
|
5
|
+
require 'circleci'
|
6
|
+
|
7
|
+
module Circle
|
8
|
+
class CLI
|
9
|
+
|
10
|
+
class << self
|
11
|
+
|
12
|
+
def run(*args)
|
13
|
+
new.dispatch!(*args)
|
14
|
+
end
|
15
|
+
|
16
|
+
end
|
17
|
+
|
18
|
+
def initialize
|
19
|
+
@options = {}
|
20
|
+
@parser ||= OptionParser.new do |opts|
|
21
|
+
# future options will go here
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
def dispatch!(argv)
|
26
|
+
@parser.parse!
|
27
|
+
command, *args = argv
|
28
|
+
|
29
|
+
method = "run_#{command.gsub('-', '_')}"
|
30
|
+
if respond_to?(method)
|
31
|
+
send(method, *args)
|
32
|
+
else
|
33
|
+
abort!("Unknown command: #{command}")
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
def run_status
|
38
|
+
unless last_status
|
39
|
+
puts 'unknown'
|
40
|
+
exit(0)
|
41
|
+
end
|
42
|
+
|
43
|
+
puts last_status.state
|
44
|
+
end
|
45
|
+
|
46
|
+
def run_open
|
47
|
+
unless last_status
|
48
|
+
puts 'No CI run found'
|
49
|
+
end
|
50
|
+
open(last_status.rels[:target].href)
|
51
|
+
end
|
52
|
+
|
53
|
+
def run_token(token=nil)
|
54
|
+
if token
|
55
|
+
repository.config['circleci.token'] = token
|
56
|
+
else
|
57
|
+
puts circle_token
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
def run_github_token(token=nil)
|
62
|
+
if token
|
63
|
+
repository.config['github.token'] = token
|
64
|
+
else
|
65
|
+
puts github_token
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
private
|
70
|
+
|
71
|
+
def open(url)
|
72
|
+
`open '#{url}'`
|
73
|
+
end
|
74
|
+
|
75
|
+
def last_status
|
76
|
+
unless defined?(@last_status)
|
77
|
+
@last_status = github_client.statuses(github_repo, head).first
|
78
|
+
end
|
79
|
+
@last_status
|
80
|
+
end
|
81
|
+
|
82
|
+
def github_repo
|
83
|
+
if origin.url =~ %r{git@github.com:(\w+/\w+)\.git}
|
84
|
+
$1
|
85
|
+
else
|
86
|
+
raise "Unsupported repo url format #{origin.url.inpect}" # TODO: support other formats, mainly https
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
90
|
+
def origin
|
91
|
+
@origin ||= repository.remotes.find { |r| r.name == 'origin' }
|
92
|
+
end
|
93
|
+
|
94
|
+
def head
|
95
|
+
repository.head.target
|
96
|
+
end
|
97
|
+
|
98
|
+
def repository
|
99
|
+
@repository ||= Rugged::Repository.new('.') # TODO: allow to be called from a subdirectory
|
100
|
+
end
|
101
|
+
|
102
|
+
def github_client
|
103
|
+
@github_client ||= Octokit::Client.new(access_token: github_token)
|
104
|
+
end
|
105
|
+
|
106
|
+
def configure_circle_ci_client
|
107
|
+
CircleCi.configure do |config|
|
108
|
+
config.token = circle_token
|
109
|
+
end
|
110
|
+
end
|
111
|
+
|
112
|
+
def github_token # TODO: github-token should probably be in a global config
|
113
|
+
repository.config['github.token'] || abort!(%{Missing GitHub token.
|
114
|
+
You can create one here: https://github.com/settings/tokens/new
|
115
|
+
And add it with the following command: $ circle github-token YOUR_TOKEN})
|
116
|
+
end
|
117
|
+
|
118
|
+
def circle_token
|
119
|
+
repository.config['circleci.token'] || abort!(%{Missing CircleCI token.
|
120
|
+
You can create one here: https://circleci.com/account/api
|
121
|
+
And add it with the following command: $ circle token YOUR_TOKEN})
|
122
|
+
end
|
123
|
+
|
124
|
+
def abort!(message, code=1)
|
125
|
+
STDERR.puts(message)
|
126
|
+
exit(code)
|
127
|
+
end
|
128
|
+
|
129
|
+
end
|
130
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
# This file was generated by the `rspec --init` command. Conventionally, all
|
2
|
+
# specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
|
3
|
+
# Require this file using `require "spec_helper"` to ensure that it is only
|
4
|
+
# loaded once.
|
5
|
+
#
|
6
|
+
# See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
|
7
|
+
RSpec.configure do |config|
|
8
|
+
config.treat_symbols_as_metadata_keys_with_true_values = true
|
9
|
+
config.run_all_when_everything_filtered = true
|
10
|
+
config.filter_run :focus
|
11
|
+
|
12
|
+
# Run specs in random order to surface order dependencies. If you find an
|
13
|
+
# order dependency and want to debug it, you can fix the order by providing
|
14
|
+
# the seed, which is printed after each run.
|
15
|
+
# --seed 1234
|
16
|
+
config.order = 'random'
|
17
|
+
end
|
metadata
ADDED
@@ -0,0 +1,144 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: circle-cli
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Jean Boussier
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-01-14 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: circleci
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - '>='
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - '>='
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rugged
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - '>='
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - '>='
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: octokit
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - '>='
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - '>='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: bundler
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ~>
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '1.5'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ~>
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '1.5'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: rake
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - '>='
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - '>='
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: rspec
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - '>='
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - '>='
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
97
|
+
description: A bunch of commands useful to deal with Circle CI without leaving your
|
98
|
+
terminal.
|
99
|
+
email:
|
100
|
+
- jean.boussier@gmail.com
|
101
|
+
executables:
|
102
|
+
- circle
|
103
|
+
extensions: []
|
104
|
+
extra_rdoc_files: []
|
105
|
+
files:
|
106
|
+
- .gitignore
|
107
|
+
- .rspec
|
108
|
+
- .ruby-version
|
109
|
+
- Gemfile
|
110
|
+
- LICENSE.txt
|
111
|
+
- README.md
|
112
|
+
- Rakefile
|
113
|
+
- bin/circle
|
114
|
+
- circle-cli.gemspec
|
115
|
+
- lib/circle-cli.rb
|
116
|
+
- lib/circle/cli.rb
|
117
|
+
- lib/circle/cli/version.rb
|
118
|
+
- spec/spec_helper.rb
|
119
|
+
homepage: ''
|
120
|
+
licenses:
|
121
|
+
- MIT
|
122
|
+
metadata: {}
|
123
|
+
post_install_message:
|
124
|
+
rdoc_options: []
|
125
|
+
require_paths:
|
126
|
+
- lib
|
127
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
128
|
+
requirements:
|
129
|
+
- - '>='
|
130
|
+
- !ruby/object:Gem::Version
|
131
|
+
version: '0'
|
132
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
133
|
+
requirements:
|
134
|
+
- - '>='
|
135
|
+
- !ruby/object:Gem::Version
|
136
|
+
version: '0'
|
137
|
+
requirements: []
|
138
|
+
rubyforge_project:
|
139
|
+
rubygems_version: 2.0.14
|
140
|
+
signing_key:
|
141
|
+
specification_version: 4
|
142
|
+
summary: Command line tools for Circle CI
|
143
|
+
test_files:
|
144
|
+
- spec/spec_helper.rb
|