ninny 0.1.13 → 0.1.14

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 228ceb1c0c7c690a792b4b1c2cfc90fca6e23b93c42e4fa3fdfe792fa45bb800
4
- data.tar.gz: ab7cff0604ed9d1740c58f96f82c1429059f9473b02ba80e5bbc00a1f6041c20
3
+ metadata.gz: 56c95a75100e8d999b3c8d8797623bf50b3b27595fa1da0a496ec0821fb43d38
4
+ data.tar.gz: 20c4f576d8d81047a3aee49a45993f2021a35b020a78c5701d45da4bf02a2f52
5
5
  SHA512:
6
- metadata.gz: da97b642577462da42d373500762fbb4c0dfd5d881d1e779b7feeb33c998a81db1d5508ec3a2efadefa72a2492a5b5efea647658491b9c8148f236750d176c1d
7
- data.tar.gz: 02fc25d9fc9d46dd184285d348126e010cb58c575cda24f68764c30be82636f06a0593ff18b6fcc652245cee40b3abd5725fe56a8f21207f12570a6cb5fe101b
6
+ metadata.gz: 5f71dfc3a85f2cfe43f576dcbf751c5b323061e098caffa16862c2afd3ae0c7b1bfb4cd036088d40723f59a7f4faeef7329df467024d16446d11f5a8b5ecd09c
7
+ data.tar.gz: ae54faf5617617129f155b900cdf5491442885e654f2c731cdf38d4f8ff0f0a8ed18fb3653fadb28aba2368fe2780fda86e72b0942a7c65cad99f024b9148118
data/README.md CHANGED
@@ -42,9 +42,15 @@ Then, each developer on the project should set up a file at `~/.ninny.yml` on th
42
42
 
43
43
  ```bash
44
44
  $ ninny setup
45
- Do you have a new GitLab private token? (Y/n) y # enter 'y'
45
+ Do you have a new GitLab private token? (Y/n) Yes # enter 'y'
46
46
  Enter private token: abc123def456ghi789jk # enter your private token
47
- User config updated
47
+ User config updated!
48
+ ```
49
+
50
+ Or, you can pass the private token in as part of the command:
51
+ ```bash
52
+ $ ninny setup --token abc123def456ghi789jk # or '-t abc123def456ghi789jk' for short
53
+ User config updated!
48
54
  ```
49
55
 
50
56
  The private token should be a personal access token for that person's GitLab account (generated [here](https://gitlab.com/-/profile/personal_access_tokens)).
data/lib/ninny/cli.rb CHANGED
@@ -54,6 +54,7 @@ module Ninny
54
54
 
55
55
  desc 'setup', 'Interactively setup configuration'
56
56
  method_option :help, aliases: '-h', type: :boolean, desc: 'Display usage information'
57
+ method_option :token, aliases: '-t', type: :string, desc: 'The GitLab token to add to the ~/.ninny.yml file'
57
58
  def setup(*)
58
59
  if options[:help]
59
60
  invoke :help, ['setup']
@@ -5,29 +5,28 @@ require_relative '../command'
5
5
  module Ninny
6
6
  module Commands
7
7
  class Setup < Ninny::Command
8
- attr_reader :config
8
+ attr_reader :config, :private_token
9
9
 
10
10
  def initialize(options)
11
11
  @options = options
12
+ @private_token = options[:token]
12
13
  @config = Ninny.user_config
13
14
  end
14
15
 
15
16
  def execute(output: $stdout)
16
17
  try_reading_user_config
17
18
 
18
- private_token = prompt_for_gitlab_private_token
19
+ unless @private_token
20
+ @private_token = prompt_for_gitlab_private_token
19
21
 
20
- begin
21
- # TODO: This only works with thor gem < 1. So, we need to make this work when TTY
22
- # releases versions compatible with thor versions >= 1 as well.
23
- config.write(force: true)
24
- rescue StandardError
25
- puts ' Unable to write config file via TTY... continuing anyway...'
26
- File.open("#{ENV['HOME']}/.ninny.yml", 'w') do |file|
27
- file.puts "gitlab_private_token: #{private_token}"
22
+ unless @private_token
23
+ output.puts "Please create a private token on GitLab and then rerun 'ninny setup'."
24
+ return
28
25
  end
29
26
  end
30
27
 
28
+ set_response = config_set_gitlab_private_token(@private_token)
29
+ write_gitlab_private_token(@private_token, set_response)
31
30
  output.puts "User config #{@result}!"
32
31
  end
33
32
 
@@ -38,6 +37,27 @@ module Ninny
38
37
  @result = 'created'
39
38
  end
40
39
 
40
+ def config_set_gitlab_private_token(private_token)
41
+ # TODO: This only works with thor gem < 1. So, we need to make this work when TTY
42
+ # releases versions compatible with thor versions >= 1 as well.
43
+ config.set(:gitlab_private_token, value: private_token)
44
+ :success
45
+ rescue ArgumentError
46
+ puts ' Unable to set new token via TTY... continuing anyway...'
47
+ :failed
48
+ end
49
+
50
+ def write_gitlab_private_token(private_token, set_response)
51
+ raise StandardError unless set_response == :success
52
+
53
+ # TODO: This only works with thor gem < 1. So, we need to make this work when TTY
54
+ # releases versions compatible with thor versions >= 1 as well.
55
+ config.write(force: true)
56
+ rescue StandardError
57
+ puts ' Unable to write config file via TTY... continuing anyway...'
58
+ File.open("#{ENV['HOME']}/.ninny.yml", 'w') { |file| file.puts "gitlab_private_token: #{private_token}" }
59
+ end
60
+
41
61
  def prompt_for_gitlab_private_token
42
62
  begin
43
63
  new_token_text = config.gitlab_private_token ? ' new' : ''
@@ -47,17 +67,7 @@ module Ninny
47
67
 
48
68
  return unless prompt.yes?("Do you have a#{new_token_text} GitLab private token?")
49
69
 
50
- private_token = prompt.ask('Enter private token:', required: true)
51
-
52
- begin
53
- # TODO: This only works with thor gem < 1. So, we need to make this work when TTY
54
- # releases versions compatible with thor versions >= 1 as well.
55
- config.set(:gitlab_private_token, value: private_token)
56
- rescue ArgumentError
57
- puts ' Unable to set new token via TTY... continuing anyway...'
58
- end
59
-
60
- private_token
70
+ prompt.ask('Enter private token:', required: true)
61
71
  end
62
72
  end
63
73
  end
data/lib/ninny/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Ninny
4
- VERSION = '0.1.13'
4
+ VERSION = '0.1.14'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ninny
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.13
4
+ version: 0.1.14
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dispatch Engineers
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-03-09 00:00:00.000000000 Z
11
+ date: 2021-03-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: git