agile-cli 0.0.11 → 0.0.12
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/.gitignore +3 -1
- data/Gemfile.lock +3 -1
- data/agile-cli.gemspec +1 -0
- data/lib/agile/commands/init.rb +16 -7
- data/lib/agile/commands/login.rb +17 -16
- data/lib/agile/commands/projects.rb +21 -20
- data/lib/agile/commands/remotes.rb +52 -0
- data/lib/agile/constants.rb +8 -3
- data/lib/agile.rb +6 -0
- metadata +17 -3
- data/lib/.config.json +0 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e4a0fc2a675123cfb741925947c8bfb324d8df7cb82c561c3d9c671a4c84c3ef
|
4
|
+
data.tar.gz: cfa82e1635468ef2f176fae5185a582799f460930992d28ef2a3b3b1840ba84c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 936274daaa02999b806b3cb925aa0b120e81dfbab226e05126db3bb9ef5674d4d9734e30625475733bad637ecd663b767c872108bb3e5c70bcddc8ed55b02d0c
|
7
|
+
data.tar.gz: 6a34fe8113bda4a70ecfb223a55a9b0783baa542390991499f3ca637e9e8e7993a934c0982df1fd54365f47a1f057c47173152a697d5f3a3926ec090e3aa873a
|
data/.gitignore
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,7 +1,8 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
agile-cli (0.0.
|
4
|
+
agile-cli (0.0.11)
|
5
|
+
highline (~> 2.0.2)
|
5
6
|
rainbow (~> 3.0.0)
|
6
7
|
rest-client (~> 2.0.2)
|
7
8
|
terminal-table (~> 1.8.0)
|
@@ -35,6 +36,7 @@ GEM
|
|
35
36
|
equalizer (0.0.11)
|
36
37
|
factory_bot (5.0.2)
|
37
38
|
activesupport (>= 4.2.0)
|
39
|
+
highline (2.0.2)
|
38
40
|
http-cookie (1.0.3)
|
39
41
|
domain_name (~> 0.5)
|
40
42
|
i18n (1.6.0)
|
data/agile-cli.gemspec
CHANGED
@@ -13,6 +13,7 @@ Gem::Specification.new do |spec|
|
|
13
13
|
spec.require_paths = ["lib"]
|
14
14
|
spec.executables = ["agile"]
|
15
15
|
|
16
|
+
spec.add_dependency "highline", "~> 2.0.2"
|
16
17
|
spec.add_dependency "rainbow", "~> 3.0.0"
|
17
18
|
spec.add_dependency "rest-client", "~> 2.0.2"
|
18
19
|
spec.add_dependency "terminal-table", "~> 1.8.0"
|
data/lib/agile/commands/init.rb
CHANGED
@@ -5,16 +5,25 @@ module Agile
|
|
5
5
|
desc Rainbow("init REMOTE_URL").cornflower, Rainbow("Add default remote").darkgoldenrod
|
6
6
|
|
7
7
|
def init(remote)
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
8
|
+
error_checking
|
9
|
+
if remote =~ URL_PATTERN || remote =~ LOCALHOST_PATTERN
|
10
|
+
write_remote_to_config(remote)
|
11
|
+
say "Successfully added new remote!"
|
12
|
+
else
|
13
|
+
say "It's not a url!"
|
14
|
+
end
|
12
15
|
end
|
13
16
|
|
14
17
|
private
|
15
|
-
|
16
|
-
def
|
17
|
-
|
18
|
+
|
19
|
+
def error_checking
|
20
|
+
abort "You've already did init! Try to add more remotes" if CONFIG["current_remote"]
|
21
|
+
end
|
22
|
+
|
23
|
+
def write_remote_to_config(remote)
|
24
|
+
CONFIG["current_remote"] = remote
|
25
|
+
CONFIG["remotes"] = [remote]
|
26
|
+
File.write("#{GEM_PATH}.config.json", JSON.generate(CONFIG))
|
18
27
|
end
|
19
28
|
end
|
20
29
|
end
|
data/lib/agile/commands/login.rb
CHANGED
@@ -1,30 +1,31 @@
|
|
1
1
|
# :reek:InstanceVariableAssumption
|
2
2
|
module Agile
|
3
3
|
class CLI < Thor
|
4
|
-
desc Rainbow("login
|
5
|
-
def login
|
4
|
+
desc Rainbow("login").cornflower, Rainbow("Sign in github.").darkgoldenrod
|
5
|
+
def login
|
6
6
|
if CONFIG
|
7
|
-
|
8
|
-
|
7
|
+
`open "#{GITHUB_URL}/oauth/authorize?client_id=#{CLIENT_ID}"`
|
8
|
+
secret_node = call_cli
|
9
|
+
response = RestClient.get "#{CONFIG['current_remote']}/api/v1/users/#{secret_node}"
|
10
|
+
login = JSON.parse(response).map { |hash| hash[1]["attributes"]["github_login"] }
|
11
|
+
write_to_config(secret_node, login)
|
12
|
+
say "Hello, #{login[0]}!"
|
9
13
|
else
|
10
|
-
say "You need to
|
14
|
+
say "You need to init!"
|
11
15
|
end
|
12
16
|
end
|
13
17
|
|
14
18
|
private
|
15
19
|
|
16
|
-
def
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
def authorize
|
21
|
-
RestClient.get "#{CONFIG['current_remote']}/api/v1/users/#{@curr_user}"
|
22
|
-
say "Hello, #{@curr_user}" if @curr_user
|
20
|
+
def write_to_config(secret_node, login)
|
21
|
+
CONFIG["current_user"] = login[0]
|
22
|
+
CONFIG["user_node"] = secret_node
|
23
|
+
File.write("#{GEM_PATH}.config.json", JSON.generate(CONFIG))
|
23
24
|
end
|
24
25
|
|
25
|
-
def
|
26
|
-
|
27
|
-
|
26
|
+
def call_cli
|
27
|
+
cli = HighLine.new
|
28
|
+
cli.ask("Enter your secret code: ")
|
28
29
|
end
|
29
30
|
end
|
30
|
-
end
|
31
|
+
end
|
@@ -2,10 +2,11 @@
|
|
2
2
|
module Agile
|
3
3
|
class Projects < Thor
|
4
4
|
desc "create <project>", "Create new project"
|
5
|
-
def create(project_name)
|
5
|
+
def create(project_name)
|
6
|
+
error_checking
|
6
7
|
response = RestClient.post "#{CONFIG['current_remote']}/api/v1/projects/", { name: project_name }
|
7
8
|
if response.body
|
8
|
-
say "
|
9
|
+
say "Successfully created project #{project_name}"
|
9
10
|
else
|
10
11
|
say "Try again"
|
11
12
|
end
|
@@ -13,29 +14,25 @@ module Agile
|
|
13
14
|
|
14
15
|
desc "list", "Show projects"
|
15
16
|
def list
|
17
|
+
error_checking
|
16
18
|
response = RestClient.get "#{CONFIG['current_remote']}/api/v1/projects/"
|
17
|
-
data = JSON.parse(response)
|
18
|
-
array = data.map { |hash| hash.values }
|
19
|
-
info = array.map { |hash| hash[1]}
|
20
19
|
say Rainbow("<<Your Projects>>").cornflower
|
21
|
-
|
20
|
+
JSON.parse(response).map { |hash| p hash.values[1] }
|
22
21
|
end
|
23
22
|
|
24
23
|
desc "use <project>", "Select current project"
|
25
24
|
def use(project)
|
26
|
-
|
27
|
-
|
28
|
-
else
|
29
|
-
say "You need to add a remote!"
|
30
|
-
end
|
25
|
+
error_checking
|
26
|
+
response = RestClient.get "#{CONFIG['current_remote']}/api/v1/projects/"
|
31
27
|
project_search(response, project)
|
32
28
|
end
|
33
29
|
|
34
30
|
desc "delete <project>", "Delete project"
|
35
31
|
def delete(project)
|
36
|
-
|
32
|
+
error_checking
|
33
|
+
response = RestClient.delete "#{CONFIG['current_remote']}/api/v1/projects/#{project}", name: project
|
37
34
|
if response.body
|
38
|
-
say "
|
35
|
+
say "Successfully deleted project #{project}"
|
39
36
|
else
|
40
37
|
say "Try again"
|
41
38
|
end
|
@@ -43,26 +40,30 @@ module Agile
|
|
43
40
|
|
44
41
|
desc "update <project_name> <new_project_name>", "Update project name"
|
45
42
|
def update(project, new_project)
|
43
|
+
error_checking
|
46
44
|
response = RestClient.put "#{CONFIG['current_remote']}/api/v1/projects/#{project}", name: project, new_name: new_project
|
47
45
|
if response.body
|
48
|
-
say "
|
46
|
+
say "Successfully updated project #{project}"
|
49
47
|
else
|
50
48
|
say "Try again"
|
51
49
|
end
|
52
50
|
end
|
53
|
-
|
51
|
+
|
54
52
|
private
|
55
53
|
|
54
|
+
def error_checking
|
55
|
+
abort "You haven't done init yet!" unless CONFIG["current_remote"]
|
56
|
+
abort "Please, log in!" unless CONFIG["current_user"]
|
57
|
+
end
|
58
|
+
|
56
59
|
def project_search(response, project)
|
57
|
-
|
58
|
-
info
|
59
|
-
names = info.map{ |hash| hash[1] }
|
60
|
-
if names.include?(project)
|
60
|
+
info = JSON.parse(response).map { |hash| hash.values[1] }
|
61
|
+
if info.include?(project)
|
61
62
|
CONFIG["current_project"] = project
|
62
63
|
File.write("#{GEM_PATH}.config.json", JSON.generate(CONFIG))
|
63
64
|
say "Your project: #{project}"
|
64
65
|
else
|
65
|
-
say "Such
|
66
|
+
say "Such project does not exist. Try again"
|
66
67
|
end
|
67
68
|
end
|
68
69
|
end
|
@@ -0,0 +1,52 @@
|
|
1
|
+
module Agile
|
2
|
+
class Remotes < Thor
|
3
|
+
desc "use <remotes url>", "Use remote"
|
4
|
+
def use(remote)
|
5
|
+
error_checking
|
6
|
+
if CONFIG["remotes"].include?(remote)
|
7
|
+
CONFIG["current_remote"] = remote
|
8
|
+
File.write("#{GEM_PATH}.config.json", JSON.generate(CONFIG))
|
9
|
+
say "Successfully change remote!"
|
10
|
+
else
|
11
|
+
say "Try again"
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
desc "add <remotes url>", "Add remote url"
|
16
|
+
def add(remote)
|
17
|
+
error_checking
|
18
|
+
if remote =~ URL_PATTERN || remote =~ LOCALHOST_PATTERN
|
19
|
+
CONFIG["remotes"].push(remote)
|
20
|
+
File.write("#{GEM_PATH}.config.json", JSON.generate(CONFIG))
|
21
|
+
say "Successfully added new remote!"
|
22
|
+
else
|
23
|
+
say "It's not a url!"
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
desc "list", "Remotes list"
|
28
|
+
def list
|
29
|
+
error_checking
|
30
|
+
CONFIG["remotes"].each do |name|
|
31
|
+
if name == CONFIG["current_remote"]
|
32
|
+
p "* #{name}"
|
33
|
+
else
|
34
|
+
p name
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
private
|
40
|
+
|
41
|
+
def error_checking
|
42
|
+
abort "You haven't done init yet!" unless CONFIG["current_remote"]
|
43
|
+
abort "Please, log in!" unless CONFIG["current_user"]
|
44
|
+
abort "You have no remotes. Try to init!" unless CONFIG["remotes"]
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
class CLI < Thor
|
49
|
+
desc Rainbow("remotes SUBCOMMAND ...ARGS").cornflower, Rainbow("Command for work with remotes").darkgoldenrod
|
50
|
+
subcommand "remotes", Remotes
|
51
|
+
end
|
52
|
+
end
|
data/lib/agile/constants.rb
CHANGED
@@ -1,7 +1,12 @@
|
|
1
|
-
#
|
1
|
+
# rubocop:disable Style/RegexpLiteral
|
2
2
|
|
3
3
|
module Agile
|
4
|
-
VERSION = "0.0.
|
5
|
-
GITHUB_URL = %(https://
|
4
|
+
VERSION = "0.0.12"
|
5
|
+
GITHUB_URL = %(https://github.com/login)
|
6
6
|
TERMINAL_STYLE = { border_x: "=", border_i: "x", padding_left: 3 }.freeze
|
7
|
+
CLIENT_ID = "8bf42da7e4f9032ac5d8"
|
8
|
+
CLIENT_SECRET = "cfef987b3839a1a846ba3f0707aa036240d2d625"
|
9
|
+
URL_PATTERN = /[a-z0-9]+([\-\.]{1}[a-z0-9]+)*\.[a-z]{2,5}(([0-9]{1,5})?\/.*)?$}/
|
10
|
+
LOCALHOST_PATTERN = /localhost:/
|
7
11
|
end
|
12
|
+
# rubocop:enable Style/RegexpLiteral
|
data/lib/agile.rb
CHANGED
@@ -4,10 +4,16 @@ require "agile/constants"
|
|
4
4
|
require "json"
|
5
5
|
require "rest-client"
|
6
6
|
require "terminal-table"
|
7
|
+
require "highline"
|
7
8
|
Dir[File.join(__dir__, "agile/commands", "*.rb")].each { |file| require file }
|
8
9
|
|
9
10
|
module Agile
|
10
11
|
GEM_PATH = `gem which agile`.chomp.chomp("agile.rb")
|
12
|
+
if `find "#{GEM_PATH}" -name .config.json`.empty?
|
13
|
+
`touch #{GEM_PATH}.config.json`
|
14
|
+
File.write("#{GEM_PATH}.config.json", {})
|
15
|
+
end
|
16
|
+
|
11
17
|
CONFIG = JSON.parse(File.read("#{GEM_PATH}.config.json"))
|
12
18
|
|
13
19
|
class CLI < Thor
|
metadata
CHANGED
@@ -1,15 +1,29 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: agile-cli
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.12
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- rubizza-camp
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-08-
|
11
|
+
date: 2019-08-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: highline
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 2.0.2
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 2.0.2
|
13
27
|
- !ruby/object:Gem::Dependency
|
14
28
|
name: rainbow
|
15
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -213,7 +227,6 @@ files:
|
|
213
227
|
- agile-cli.gemspec
|
214
228
|
- bin/agile
|
215
229
|
- bin/setup
|
216
|
-
- lib/.config.json
|
217
230
|
- lib/agile.rb
|
218
231
|
- lib/agile/assets/agile_principles.txt
|
219
232
|
- lib/agile/assets/agile_values.txt
|
@@ -229,6 +242,7 @@ files:
|
|
229
242
|
- lib/agile/commands/manifesto.rb
|
230
243
|
- lib/agile/commands/principles.rb
|
231
244
|
- lib/agile/commands/projects.rb
|
245
|
+
- lib/agile/commands/remotes.rb
|
232
246
|
- lib/agile/commands/values.rb
|
233
247
|
- lib/agile/commands/version.rb
|
234
248
|
- lib/agile/constants.rb
|
data/lib/.config.json
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
{"current_remote":"localhost:3000","current_user":"nieisnuje","current_project":"AgileCli"}
|