shaman_cli 2.0.0 → 2.1.0
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 +4 -4
- data/README.md +23 -27
- data/exe/shaman +14 -14
- data/lib/shaman/deploy.rb +14 -13
- data/lib/shaman/helpers.rb +12 -0
- data/lib/shaman/init.rb +79 -7
- data/lib/shaman/version.rb +1 -1
- data/lib/shaman.rb +3 -1
- data/shaman.gemspec +2 -0
- metadata +32 -4
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 6a25a911038c45c59969494d203ca6672179854c
|
|
4
|
+
data.tar.gz: 26d4a1e794af5a4c5d6da95e65eb14cc5254ea30
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 8c0cf5361790fa1bb29fd5c63767d13321210150e257ac27a7748b96330d3b949a3fc6037bef4da87488abe56733d18836d0803b1d54f5d8738f85695ff10d4b
|
|
7
|
+
data.tar.gz: 987d568b08228361b4a089cfaff8e38e362849407fbaf8d4c3061689a3fecb59db2505cad10208b5aa0c78ab4474693a494345757ed2f98327b177d4bf230162
|
data/README.md
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
[](https://badge.fury.io/rb/shaman_cli)
|
|
2
|
+
|
|
1
3
|
# Shaman
|
|
2
4
|
|
|
3
5
|
Cli for integrating with labs.infinum.co
|
|
@@ -8,6 +10,10 @@ Install it yourself as:
|
|
|
8
10
|
|
|
9
11
|
$ gem install shaman
|
|
10
12
|
|
|
13
|
+
Get your user token from `https://labs.infinum.co/users/me` and export it to environment variable `SHAMAN_TOKEN`
|
|
14
|
+
|
|
15
|
+
export SHAMAN_TOKEN=infnweoinfwi32r23jr2309j
|
|
16
|
+
|
|
11
17
|
## Usage
|
|
12
18
|
|
|
13
19
|
### Init
|
|
@@ -17,24 +23,23 @@ Install it yourself as:
|
|
|
17
23
|
Initialize your project
|
|
18
24
|
|
|
19
25
|
Options:
|
|
20
|
-
-
|
|
21
|
-
-
|
|
22
|
-
-
|
|
26
|
+
-s, --search STRING Shrink project selection
|
|
27
|
+
-f, --favorites Show only favorites
|
|
28
|
+
-p, --platform PLATFORM Choose platform
|
|
29
|
+
-i, --project_id PROJECT Choose project id
|
|
23
30
|
|
|
24
31
|
Example of `.shaman.yml`
|
|
25
32
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
33
|
+
---
|
|
34
|
+
production:
|
|
35
|
+
:release_path: spec/files/test.ipa
|
|
36
|
+
:token: Hu6vuqgEF3FzrmenDQ1kk86R
|
|
37
|
+
|
|
30
38
|
|
|
31
39
|
Explanation:
|
|
32
40
|
|
|
33
|
-
`release_path` - this is the path to the release file
|
|
34
|
-
`
|
|
35
|
-
[https://scr.infinum.co/stjepan_hadjic/Infinum_Labs_2016-02-23_17-14-08.png]
|
|
36
|
-
`deployer_email` - This is an email you use with your git commits. You will also need to add this to your labs account.
|
|
37
|
-
[https://scr.infinum.co/stjepan_hadjic/Infinum_Labs_2016-02-23_17-16-52.png]
|
|
41
|
+
`release_path` - this is the path to the release file
|
|
42
|
+
`token` - This is the environment token for communicating with API
|
|
38
43
|
|
|
39
44
|
### Deploy
|
|
40
45
|
|
|
@@ -42,28 +47,19 @@ This will deploy your relese file to labs with with configs from .shaman.yml
|
|
|
42
47
|
|
|
43
48
|
$ shaman deploy
|
|
44
49
|
|
|
50
|
+
$ shaman deploy [environment]
|
|
51
|
+
|
|
52
|
+
Deploy a release to specified environment
|
|
53
|
+
|
|
45
54
|
Options:
|
|
46
55
|
-m, --message MESSAGE Changelog message
|
|
47
56
|
-f, --file FILE Release path
|
|
48
|
-
-
|
|
49
|
-
-t, --token TOKEN Use different environment token
|
|
57
|
+
-t, --token TOKEN Use different user token
|
|
50
58
|
-c, --config FILE Use different config file
|
|
51
|
-
-
|
|
52
|
-
-g, --git Use git for deployer email and message (overrides any manual settings!)
|
|
59
|
+
-g, --git Use git for message (overrides any manual settings!)
|
|
53
60
|
-C, --commit COMMIT which commit to use instead of HEAD
|
|
54
61
|
|
|
55
|
-
## Development
|
|
56
|
-
|
|
57
|
-
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake rspec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
|
58
|
-
|
|
59
|
-
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
|
60
|
-
|
|
61
|
-
## Contributing
|
|
62
|
-
|
|
63
|
-
Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/shaman. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](contributor-covenant.org) code of conduct.
|
|
64
|
-
|
|
65
62
|
|
|
66
63
|
## License
|
|
67
64
|
|
|
68
65
|
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
|
69
|
-
|
data/exe/shaman
CHANGED
|
@@ -1,40 +1,40 @@
|
|
|
1
1
|
#!/usr/bin/env ruby
|
|
2
2
|
|
|
3
|
-
$LOAD_PATH << 'lib'
|
|
4
3
|
require 'rubygems'
|
|
5
4
|
require 'commander/import'
|
|
6
5
|
require 'shaman'
|
|
7
|
-
|
|
6
|
+
require 'pry' if ENV['SHAMAN_ENV'] == 'development'
|
|
8
7
|
|
|
9
8
|
program :version, Shaman::VERSION
|
|
10
9
|
program :description, 'Shaman cli for labs'
|
|
11
10
|
program :help_formatter, :compact
|
|
12
11
|
|
|
13
12
|
command :init do |c|
|
|
14
|
-
c.syntax = 'shaman init
|
|
15
|
-
c.description = 'Initialize your
|
|
16
|
-
c.option '-
|
|
17
|
-
c.option '-
|
|
18
|
-
c.option '-
|
|
13
|
+
c.syntax = 'shaman init'
|
|
14
|
+
c.description = 'Initialize your'
|
|
15
|
+
c.option '-s', '--search STRING', String, 'Shrink project selection'
|
|
16
|
+
c.option '-f', '--favorites', 'Show only favorites'
|
|
17
|
+
c.option '-p', '--platform PLATFORM', 'Choose platform'
|
|
18
|
+
c.option '-i', '--project_id PROJECT', 'Choose project id'
|
|
19
19
|
c.action do |_args, options|
|
|
20
|
+
Shaman::Init.check
|
|
20
21
|
Shaman::Init.init(options)
|
|
21
22
|
end
|
|
22
23
|
end
|
|
23
24
|
|
|
24
25
|
command :deploy do |c|
|
|
25
|
-
c.syntax = 'shaman deploy'
|
|
26
|
-
c.description = 'Deploy a release'
|
|
26
|
+
c.syntax = 'shaman deploy [environment]'
|
|
27
|
+
c.description = 'Deploy a release to specified environment'
|
|
27
28
|
c.option '-m', '--message MESSAGE', String, 'Changelog message'
|
|
28
29
|
c.option '-f', '--file FILE', String, 'Release path'
|
|
29
30
|
c.option '-p', '--proguard FILE', String, 'Add aditional proguard mapping'
|
|
30
|
-
c.option '-t', '--token TOKEN', String, 'Use different
|
|
31
|
+
c.option '-t', '--token TOKEN', String, 'Use different user token'
|
|
31
32
|
c.option '-c', '--config FILE', String, 'Use different config file'
|
|
32
|
-
c.option '-
|
|
33
|
-
c.option '-g', '--git', 'Use git for deployer email and message (overrides any manual settings!)'
|
|
33
|
+
c.option '-g', '--git', 'Use git for message (overrides any manual settings!)'
|
|
34
34
|
c.option '-C', '--commit COMMIT', String, 'which commit to use instead of HEAD'
|
|
35
|
-
c.action do |
|
|
35
|
+
c.action do |args, options|
|
|
36
36
|
begin
|
|
37
|
-
Shaman::Deploy.new(options).deploy
|
|
37
|
+
Shaman::Deploy.new(args, options).deploy
|
|
38
38
|
rescue => e
|
|
39
39
|
say_error e.message
|
|
40
40
|
end
|
data/lib/shaman/deploy.rb
CHANGED
|
@@ -1,38 +1,43 @@
|
|
|
1
1
|
module Shaman
|
|
2
2
|
class Deploy
|
|
3
|
-
|
|
3
|
+
include Helpers
|
|
4
4
|
|
|
5
|
-
def initialize(options)
|
|
5
|
+
def initialize(args, options)
|
|
6
|
+
error!('Must specify environment') if args.count != 1
|
|
7
|
+
@environment = args.first
|
|
6
8
|
@options = options
|
|
7
9
|
verify_options
|
|
8
10
|
end
|
|
9
11
|
|
|
10
12
|
def deploy
|
|
11
|
-
|
|
12
|
-
say_ok "Sending #{deploy_options.to_yaml}"
|
|
13
|
+
prompt.ok "Connecting to #{LABS_URL}/api/v1/releases"
|
|
13
14
|
response = HTTP.post("#{LABS_URL}/api/v1/releases", form: deploy_options)
|
|
14
|
-
response.code == 200 ?
|
|
15
|
+
response.code == 200 ? prompt.ok(response.body.to_s) : prompt.error(response.body.to_s)
|
|
15
16
|
end
|
|
16
17
|
|
|
17
18
|
private
|
|
18
19
|
|
|
20
|
+
attr_reader :environment, :options
|
|
21
|
+
|
|
19
22
|
def deploy_options
|
|
23
|
+
raise 'Wrong environment' if config.nil?
|
|
20
24
|
@deploy_options ||= {
|
|
21
|
-
environment_token:
|
|
25
|
+
environment_token: config[:token],
|
|
22
26
|
release: HTTP::FormData::File.new(options.file || config[:release_path]),
|
|
23
27
|
message: message || '',
|
|
24
|
-
|
|
28
|
+
token: options.token || ENV['SHAMAN_TOKEN']
|
|
25
29
|
}
|
|
26
30
|
end
|
|
27
31
|
|
|
28
32
|
def verify_options
|
|
29
33
|
deploy_options.each do |key, value|
|
|
30
|
-
|
|
34
|
+
raise "Please specify #{key}" if value.nil?
|
|
31
35
|
end
|
|
32
36
|
end
|
|
33
37
|
|
|
34
38
|
def config
|
|
35
|
-
@config ||=
|
|
39
|
+
@config ||=
|
|
40
|
+
YAML.load_file(options.config || PROJECT_CONFIG_PATH)[environment]
|
|
36
41
|
end
|
|
37
42
|
|
|
38
43
|
def gcommit
|
|
@@ -42,9 +47,5 @@ module Shaman
|
|
|
42
47
|
def message
|
|
43
48
|
options.git ? gcommit.message : options.message || ask_editor(nil, 'vi')
|
|
44
49
|
end
|
|
45
|
-
|
|
46
|
-
def deployer
|
|
47
|
-
options.git ? gcommit.committer.email : options.deployer || config[:deployer_email]
|
|
48
|
-
end
|
|
49
50
|
end
|
|
50
51
|
end
|
data/lib/shaman/init.rb
CHANGED
|
@@ -1,13 +1,85 @@
|
|
|
1
1
|
module Shaman
|
|
2
|
-
|
|
2
|
+
class Init
|
|
3
|
+
include Shaman::Helpers
|
|
4
|
+
|
|
5
|
+
def self.check
|
|
6
|
+
return unless ENV['SHAMAN_TOKEN'].nil?
|
|
7
|
+
error! "SHAMAN_TOKEN not defined. Please find it at #{LABS_URL}/me"
|
|
8
|
+
end
|
|
9
|
+
|
|
3
10
|
def self.init(options)
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
11
|
+
new(options).call
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
def initialize(options)
|
|
15
|
+
@options = options
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
def call
|
|
19
|
+
@platform = choose_platform if options.platform.nil?
|
|
20
|
+
@project_id = choose_project_id if options.project_id.nil?
|
|
21
|
+
write_config
|
|
22
|
+
prompt.ok '.shaman.yml created'
|
|
23
|
+
prompt.say(File.read(PROJECT_CONFIG_PATH), color: :cyan)
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
private
|
|
27
|
+
|
|
28
|
+
attr_reader :options
|
|
29
|
+
|
|
30
|
+
def choose_platform
|
|
31
|
+
prompt.select('Choose platform:', [:android, :ios, :zip, :air, :web])
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
def choose_project_id
|
|
35
|
+
prompt.enum_select('Choose project:') do |menu|
|
|
36
|
+
menu.enum '.'
|
|
37
|
+
projects.each do |project|
|
|
38
|
+
menu.choice "#{project['name']} (#{project['id']})", project['id']
|
|
39
|
+
end
|
|
40
|
+
end
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
def write_config
|
|
44
|
+
project = projects.detect { |p| p['id'] == project_id }
|
|
45
|
+
error!('wrong project id') if project.nil?
|
|
46
|
+
config = {}
|
|
47
|
+
project['environments'].each do |environment|
|
|
48
|
+
next unless environment['platform'] == platform.to_s
|
|
49
|
+
release_path = prompt.ask("Release path for #{environment['name']}", default: 'path/to/release')
|
|
50
|
+
config[environment['name']] = {
|
|
51
|
+
release_path: release_path,
|
|
52
|
+
token: environment['token']
|
|
53
|
+
}
|
|
54
|
+
end
|
|
9
55
|
File.open(PROJECT_CONFIG_PATH, 'w') { |f| f.write(YAML.dump(config)) }
|
|
10
|
-
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
def projects
|
|
59
|
+
return @projects if @projects
|
|
60
|
+
response = HTTP.get(
|
|
61
|
+
"#{LABS_URL}/api/v1/projects",
|
|
62
|
+
params: {
|
|
63
|
+
token: ENV['SHAMAN_TOKEN'], favorites: favorites, search: search, platform: platform
|
|
64
|
+
}
|
|
65
|
+
)
|
|
66
|
+
@projects = JSON.parse(response.body)
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
def favorites
|
|
70
|
+
options.favorites
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
def search
|
|
74
|
+
options.search
|
|
75
|
+
end
|
|
76
|
+
|
|
77
|
+
def project_id
|
|
78
|
+
@project_id || options.project_id.to_i
|
|
79
|
+
end
|
|
80
|
+
|
|
81
|
+
def platform
|
|
82
|
+
@platform || options.platform
|
|
11
83
|
end
|
|
12
84
|
end
|
|
13
85
|
end
|
data/lib/shaman/version.rb
CHANGED
data/lib/shaman.rb
CHANGED
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
require 'http'
|
|
2
2
|
require 'git'
|
|
3
3
|
require 'yaml'
|
|
4
|
+
require 'tty-prompt'
|
|
5
|
+
require 'shaman/helpers'
|
|
4
6
|
require 'shaman/init'
|
|
5
7
|
require 'shaman/deploy'
|
|
6
8
|
require 'shaman/version'
|
|
7
9
|
|
|
8
10
|
module Shaman
|
|
9
|
-
PROJECT_CONFIG_PATH = '.shaman.yml'
|
|
11
|
+
PROJECT_CONFIG_PATH = '.shaman.yml'.freeze
|
|
10
12
|
LABS_URL =
|
|
11
13
|
case ENV['SHAMAN_ENV']
|
|
12
14
|
when 'development' then 'http://localhost:3000'
|
data/shaman.gemspec
CHANGED
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: shaman_cli
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 2.
|
|
4
|
+
version: 2.1.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Stjepan Hadjic
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: exe
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2016-
|
|
11
|
+
date: 2016-11-22 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: bundler
|
|
@@ -94,6 +94,34 @@ dependencies:
|
|
|
94
94
|
- - ">="
|
|
95
95
|
- !ruby/object:Gem::Version
|
|
96
96
|
version: '0'
|
|
97
|
+
- !ruby/object:Gem::Dependency
|
|
98
|
+
name: commander
|
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
|
100
|
+
requirements:
|
|
101
|
+
- - ">="
|
|
102
|
+
- !ruby/object:Gem::Version
|
|
103
|
+
version: '0'
|
|
104
|
+
type: :runtime
|
|
105
|
+
prerelease: false
|
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
107
|
+
requirements:
|
|
108
|
+
- - ">="
|
|
109
|
+
- !ruby/object:Gem::Version
|
|
110
|
+
version: '0'
|
|
111
|
+
- !ruby/object:Gem::Dependency
|
|
112
|
+
name: tty-prompt
|
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
|
114
|
+
requirements:
|
|
115
|
+
- - ">="
|
|
116
|
+
- !ruby/object:Gem::Version
|
|
117
|
+
version: '0'
|
|
118
|
+
type: :runtime
|
|
119
|
+
prerelease: false
|
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
121
|
+
requirements:
|
|
122
|
+
- - ">="
|
|
123
|
+
- !ruby/object:Gem::Version
|
|
124
|
+
version: '0'
|
|
97
125
|
description: Very cool command tool for infinum
|
|
98
126
|
email:
|
|
99
127
|
- d4be4st@gmail.com
|
|
@@ -115,6 +143,7 @@ files:
|
|
|
115
143
|
- exe/shaman
|
|
116
144
|
- lib/shaman.rb
|
|
117
145
|
- lib/shaman/deploy.rb
|
|
146
|
+
- lib/shaman/helpers.rb
|
|
118
147
|
- lib/shaman/init.rb
|
|
119
148
|
- lib/shaman/version.rb
|
|
120
149
|
- shaman.gemspec
|
|
@@ -138,9 +167,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
138
167
|
version: '0'
|
|
139
168
|
requirements: []
|
|
140
169
|
rubyforge_project:
|
|
141
|
-
rubygems_version: 2.
|
|
170
|
+
rubygems_version: 2.5.1
|
|
142
171
|
signing_key:
|
|
143
172
|
specification_version: 4
|
|
144
173
|
summary: Command tool for labs
|
|
145
174
|
test_files: []
|
|
146
|
-
has_rdoc:
|