uffizzi-cli 0.1.0 → 0.1.4.2

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a8dac7594027838ee4bd1b0c89f164bf25f45167fb3d8fab2f1779c0bd0fdd73
4
- data.tar.gz: a17653ba98ea366d9ddc588175a1910110064e9fce9ee1ecc39f866a96f32f9a
3
+ metadata.gz: adccb97f96512fb4868b350aa1a5fda386a66a0ff5c9a82c10f8fd928431fafc
4
+ data.tar.gz: 7d1673c20f6461f6e3d0e3cbbc0d4cfcd97ac1021d1a99eed5d6e02195633fa3
5
5
  SHA512:
6
- metadata.gz: b88a6634833d3a9332506ac617bf852a09d711b65078aa7b65841ba54d3ed0410c53e6f18a0103b4448283d8b3efb6953754bdc3029fbdd44e1dc8a6507d1df5
7
- data.tar.gz: 86c2aea8ef9d219981729bcdf49272f38bf972033499462fd7048598b7c6d235f6b8a13ce1cf9a56c203357a38e9ffb577739acf9ddd2c567a8244b6c1b5429e
6
+ metadata.gz: 2864b2e881a610a995978f4816524bfca7a2b3a4c2f7b643765954a31bedaee157b6a0b709ca939e82a60e51eaf4041fc042c778a9d04003447b7e62684f2b60
7
+ data.tar.gz: 7b51d58ccfb0348ec6f384250d6e15456d3e5b6545c023f88cdf1e9394eb708d788890b432219094cab6b56a736e746c7980f6432a20b0665c620a4508bff94c
data/Dockerfile CHANGED
@@ -2,7 +2,7 @@ FROM ruby:3.0.2-alpine3.14
2
2
 
3
3
  RUN apk update && apk upgrade
4
4
  RUN apk add bash
5
- RUN apk add curl-dev ruby-dev build-base git curl ruby-json openssl
5
+ RUN apk add curl-dev ruby-dev build-base git curl ruby-json openssl groff mandoc man-pages
6
6
 
7
7
  RUN mkdir -p /gem
8
8
  WORKDIR /gem
@@ -10,6 +10,9 @@ WORKDIR /gem
10
10
  ENV GEM_HOME="/usr/local/bundle"
11
11
  ENV PATH $GEM_HOME/bin:$GEM_HOME/gems/bin:$PATH
12
12
 
13
+ RUN gem install uffizzi-cli
14
+ RUN gem install bundler -v 2.3.8
15
+
13
16
  COPY lib/uffizzi/version.rb /gem/lib/uffizzi/
14
17
  COPY uffizzi.gemspec /gem/
15
18
  COPY Gemfile* /gem/
@@ -17,6 +20,4 @@ RUN bundle install --jobs 4
17
20
 
18
21
  COPY . /gem
19
22
 
20
- RUN rake install
21
-
22
23
  CMD ["uffizzi"]
data/Gemfile.lock CHANGED
@@ -1,8 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- uffizzi-cli (0.1.0)
5
- io-console
4
+ uffizzi-cli (0.1.4.2)
6
5
  thor
7
6
 
8
7
  GEM
@@ -27,13 +26,18 @@ GEM
27
26
  hashdiff (1.0.1)
28
27
  i18n (1.8.11)
29
28
  concurrent-ruby (~> 1.0)
30
- io-console (0.5.11)
29
+ kramdown (2.3.1)
30
+ rexml
31
31
  method_source (1.0.0)
32
32
  minitest (5.14.4)
33
33
  minitest-power_assert (0.3.1)
34
34
  minitest
35
35
  power_assert (>= 1.1)
36
36
  mocha (1.13.0)
37
+ mustache (0.99.8)
38
+ nokogiri (1.13.1-x86_64-linux)
39
+ racc (~> 1.4)
40
+ open3 (0.1.1)
37
41
  parallel (1.21.0)
38
42
  parser (3.0.2.0)
39
43
  ast (~> 2.4.1)
@@ -48,10 +52,15 @@ GEM
48
52
  pry (> 0.10.0)
49
53
  unicode (~> 0.4.4)
50
54
  public_suffix (4.0.6)
55
+ racc (1.6.0)
51
56
  rainbow (3.0.0)
52
57
  rake (13.0.6)
53
58
  regexp_parser (2.1.1)
54
59
  rexml (3.2.5)
60
+ ronn-ng (0.9.1)
61
+ kramdown (~> 2.1)
62
+ mustache (~> 0.7, >= 0.7.0)
63
+ nokogiri (~> 1.9, >= 1.9.0)
55
64
  rubocop (1.22.3)
56
65
  parallel (~> 1.10)
57
66
  parser (>= 3.0.0.0)
@@ -68,7 +77,7 @@ GEM
68
77
  rubocop-rake (0.6.0)
69
78
  rubocop (~> 1.0)
70
79
  ruby-progressbar (1.11.0)
71
- thor (1.1.0)
80
+ thor (1.2.1)
72
81
  tzinfo (2.0.4)
73
82
  concurrent-ruby (~> 1.0)
74
83
  unicode (0.4.4.4)
@@ -89,9 +98,11 @@ DEPENDENCIES
89
98
  minitest
90
99
  minitest-power_assert
91
100
  mocha
101
+ open3
92
102
  pry-byebug
93
103
  pry-inline
94
104
  rake
105
+ ronn-ng
95
106
  rubocop
96
107
  rubocop-minitest
97
108
  rubocop-rake
data/README.md CHANGED
@@ -108,6 +108,37 @@ $ uffizzi config delete OPTION
108
108
 
109
109
  Deletes specified option.
110
110
 
111
+ ## Git workflow for the app:
112
+
113
+ 1. Clone the repository and checkout to `develop` branch
114
+
115
+ 2. Pull repository to ensure you have the latest changes
116
+ ```
117
+ git pull --rebase develop
118
+ ```
119
+
120
+ 3. Start new branch from `develop`
121
+ ```
122
+ git checkout -b feature/short_issue_description (e.g. feature/add_domain_settings)
123
+ ```
124
+
125
+ 4. Make changes you need for the feature, commit them to the repo
126
+ ```
127
+ git add .
128
+ git commit -m 'short commit description' (e.g. git commit -m 'added domain settings')
129
+ git push origin FEATURE_NAME
130
+ ```
131
+
132
+ 4. You already can create PR with develop branch as a target. Once the feature is ready let us know in the channel - we will review
133
+
134
+ 5. Merge your feature to `qa` branch and push. Ensure your pipeline is successful
135
+ ```
136
+ git checkout qa
137
+ git pull --rebase qa
138
+ git merge --no-ff FEATURE_NAME
139
+ git push origin qa
140
+ ```
141
+
111
142
  ## Contributing
112
143
 
113
144
  Bug reports and pull requests are welcome on GitHub at https://github.com/UffizziCloud/uffizzi_cli.
data/Rakefile CHANGED
@@ -14,3 +14,8 @@ require 'rubocop/rake_task'
14
14
  RuboCop::RakeTask.new
15
15
 
16
16
  task default: [:test, :rubocop]
17
+
18
+ desc 'Generate roff output files from ronn format'
19
+ task :generate_docs do
20
+ sh 'ronn --roff man/*.ronn'
21
+ end
@@ -4,14 +4,10 @@ module Uffizzi
4
4
  module AuthHelper
5
5
  class << self
6
6
  def signed_in?
7
- logged_in = ConfigFile.exists? &&
7
+ ConfigFile.exists? &&
8
8
  ConfigFile.option_exists?(:account_id) &&
9
9
  ConfigFile.option_exists?(:cookie) &&
10
10
  ConfigFile.option_exists?(:hostname)
11
-
12
- puts 'You are not logged in.' unless logged_in
13
-
14
- logged_in
15
11
  end
16
12
  end
17
13
  end
@@ -0,0 +1,15 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'open3'
4
+
5
+ module Cli
6
+ class Common
7
+ class << self
8
+ def show_manual(method_name)
9
+ manual_doc_path = "man/uffizzi-#{method_name}"
10
+
11
+ Open3.pipeline("man #{manual_doc_path}")
12
+ end
13
+ end
14
+ end
15
+ end
@@ -2,6 +2,7 @@
2
2
 
3
3
  require 'io/console'
4
4
  require 'uffizzi'
5
+ require 'uffizzi/response_helper'
5
6
 
6
7
  module Uffizzi
7
8
  class CLI::Login
@@ -13,12 +14,10 @@ module Uffizzi
13
14
 
14
15
  def run
15
16
  password = IO::console.getpass('Enter Password: ')
16
-
17
17
  params = prepare_request_params(password)
18
-
19
18
  response = create_session(@options[:hostname], params)
20
19
 
21
- if response[:code] == Net::HTTPCreated
20
+ if Uffizzi::ResponseHelper.created?(response)
22
21
  handle_succeed_response(response)
23
22
  else
24
23
  handle_failed_response(response)
@@ -41,12 +40,10 @@ module Uffizzi
41
40
  end
42
41
 
43
42
  def handle_succeed_response(response)
44
- unless account_valid?(response[:body][:user][:accounts].first)
45
- puts 'No account related to this email'
46
- return
47
- end
48
- account_id = response[:body][:user][:accounts].first[:id]
49
- ConfigFile.create(account_id, response[:headers], @options[:hostname])
43
+ account = response[:body][:user][:accounts].first
44
+ return Uffizzi.ui.say('No account related to this email') unless account_valid?(account)
45
+
46
+ ConfigFile.create(account[:id], response[:headers], @options[:hostname])
50
47
  end
51
48
 
52
49
  def account_valid?(account)
@@ -0,0 +1,21 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'io/console'
4
+ require 'uffizzi'
5
+ require 'uffizzi/auth_helper'
6
+
7
+ module Uffizzi
8
+ class CLI::Logout
9
+ include ApiClient
10
+
11
+ def run
12
+ return Uffizzi.ui.say('You are not logged in') unless Uffizzi::AuthHelper.signed_in?
13
+
14
+ hostname = ConfigFile.read_option(:hostname)
15
+ destroy_session(hostname)
16
+
17
+ ConfigFile.delete
18
+ Uffizzi.ui.say('You have been successfully logged out')
19
+ end
20
+ end
21
+ end
@@ -9,7 +9,7 @@ module Uffizzi
9
9
  include ApiClient
10
10
 
11
11
  def run
12
- return unless Uffizzi::AuthHelper.signed_in?
12
+ return 'You are not logged in' unless Uffizzi::AuthHelper.signed_in?
13
13
 
14
14
  hostname = ConfigFile.read_option(:hostname)
15
15
  response = fetch_projects(hostname)
data/lib/uffizzi/cli.rb CHANGED
@@ -4,13 +4,17 @@ require 'thor'
4
4
 
5
5
  module Uffizzi
6
6
  class CLI < Thor
7
- desc 'version', 'show version'
7
+ require_relative 'cli/common'
8
+
9
+ class_option :help, type: :boolean, aliases: HELP_MAPPINGS
10
+
11
+ desc 'version', 'Show Version'
8
12
  def version
9
13
  require_relative 'version'
10
14
  puts Uffizzi::VERSION
11
15
  end
12
16
 
13
- desc 'login', 'login'
17
+ desc 'login', 'Login into Uffizzi'
14
18
  method_option :user, required: true, aliases: '-u'
15
19
  method_option :hostname, required: true, aliases: '-h'
16
20
  def login
@@ -18,6 +22,14 @@ module Uffizzi
18
22
  Login.new(options).run
19
23
  end
20
24
 
25
+ desc 'logout', 'Logout from Uffizzi'
26
+ def logout(help = nil)
27
+ return Cli::Common.show_manual(:logout) if help || options[:help]
28
+
29
+ require_relative 'cli/logout'
30
+ Logout.new.run
31
+ end
32
+
21
33
  desc 'projects', 'projects'
22
34
  def projects
23
35
  require_relative 'cli/projects'
@@ -12,6 +12,13 @@ module ApiClient
12
12
  build_response(response)
13
13
  end
14
14
 
15
+ def destroy_session(hostname)
16
+ uri = session_uri(hostname)
17
+ response = Uffizzi::HttpClient.make_request(uri, :delete, true)
18
+
19
+ build_response(response)
20
+ end
21
+
15
22
  def fetch_projects(hostname)
16
23
  uri = projects_uri(hostname)
17
24
  response = Uffizzi::HttpClient.make_request(uri, :get, true)
@@ -0,0 +1,27 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Uffizzi
4
+ module ResponseHelper
5
+ class << self
6
+ def created?(response)
7
+ response[:code] == Net::HTTPCreated
8
+ end
9
+
10
+ def unprocessable_entity?(response)
11
+ response[:code] == Net::HTTPUnprocessableEntity
12
+ end
13
+
14
+ def not_found?(response)
15
+ response[:code] == Net::HTTPNotFound
16
+ end
17
+
18
+ def forbidden?(response)
19
+ response[:code] == Net::HTTPForbidden
20
+ end
21
+
22
+ def no_content?(response)
23
+ response[:code] == Net::HTTPNoContent
24
+ end
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,21 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'thor'
4
+
5
+ module Uffizzi
6
+ module UI
7
+ class Shell
8
+ def initialize
9
+ @shell = Thor::Shell::Basic.new
10
+ end
11
+
12
+ def say(msg)
13
+ @shell.say(msg)
14
+ end
15
+
16
+ def last_message
17
+ @shell.send(:stdout).string.strip
18
+ end
19
+ end
20
+ end
21
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Uffizzi
4
- VERSION = '0.1.0'
4
+ VERSION = '0.1.4.2'
5
5
  end
data/lib/uffizzi.rb CHANGED
@@ -1,5 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require 'uffizzi/shell'
3
4
  require_relative 'uffizzi/version'
4
5
  require_relative 'uffizzi/clients/api/api_client'
5
6
  require_relative 'uffizzi/clients/api/api_routes'
@@ -7,4 +8,9 @@ require_relative 'uffizzi/config_file'
7
8
 
8
9
  module Uffizzi
9
10
  class Error < StandardError; end
11
+ class << self
12
+ def ui
13
+ @ui ||= Uffizzi::UI::Shell.new
14
+ end
15
+ end
10
16
  end
@@ -0,0 +1,21 @@
1
+ .\" generated with Ronn-NG/v0.9.1
2
+ .\" http://github.com/apjanke/ronn-ng/tree/0.9.1
3
+ .TH "UFFIZZI\-LOGOUT" "" "February 2022" ""
4
+ .SH "NAME"
5
+ \fBuffizzi\-logout\fR \- log out of a Uffizzi user account
6
+ .SH "SYNOPSIS"
7
+ \fBuffizzi logout\fR
8
+ .SH "DESCRIPTION"
9
+ .nf
10
+ The uffizzi logout command logs out of a Uffizzi user account\.
11
+
12
+ For more information on logout, see:
13
+ https://docs\.uffizzi\.com/references/cli
14
+ .fi
15
+ .SH "UFFIZZI WIDE FLAGS"
16
+ .nf
17
+ These flags are available to all commands: \-\-project\. Run $ uffizzi
18
+ help for details\.
19
+ .fi
20
+ .SH "EXAMPLES"
21
+ uffizzi logout
@@ -0,0 +1,19 @@
1
+ uffizzi-logout - log out of a Uffizzi user account
2
+ ================================================================
3
+
4
+ ## SYNOPSIS
5
+
6
+ `uffizzi logout`
7
+
8
+ ## DESCRIPTION
9
+ The uffizzi logout command logs out of a Uffizzi user account.
10
+
11
+ For more information on logout, see:
12
+ https://docs.uffizzi.com/references/cli
13
+
14
+ ## UFFIZZI WIDE FLAGS
15
+ These flags are available to all commands: --project. Run $ uffizzi
16
+ help for details.
17
+
18
+ ## EXAMPLES
19
+ uffizzi logout
data/uffizzi.gemspec CHANGED
@@ -33,14 +33,15 @@ Gem::Specification.new do |spec|
33
33
  spec.add_development_dependency 'minitest'
34
34
  spec.add_development_dependency 'minitest-power_assert'
35
35
  spec.add_development_dependency 'mocha'
36
+ spec.add_development_dependency 'open3'
36
37
  spec.add_development_dependency 'pry-byebug'
37
38
  spec.add_development_dependency 'pry-inline'
38
39
  spec.add_development_dependency 'rake'
40
+ spec.add_development_dependency 'ronn-ng'
39
41
  spec.add_development_dependency 'rubocop'
40
42
  spec.add_development_dependency 'rubocop-minitest'
41
43
  spec.add_development_dependency 'rubocop-rake'
42
44
  spec.add_development_dependency 'webmock'
43
45
 
44
- spec.add_dependency 'io-console'
45
46
  spec.add_dependency 'thor'
46
47
  end
metadata CHANGED
@@ -1,15 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: uffizzi-cli
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.4.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Josh Thurman
8
8
  - Grayson Adkins
9
- autorequire:
9
+ autorequire:
10
10
  bindir: exe
11
11
  cert_chain: []
12
- date: 2022-02-24 00:00:00.000000000 Z
12
+ date: 2022-03-04 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler
@@ -95,6 +95,20 @@ dependencies:
95
95
  - - ">="
96
96
  - !ruby/object:Gem::Version
97
97
  version: '0'
98
+ - !ruby/object:Gem::Dependency
99
+ name: open3
100
+ requirement: !ruby/object:Gem::Requirement
101
+ requirements:
102
+ - - ">="
103
+ - !ruby/object:Gem::Version
104
+ version: '0'
105
+ type: :development
106
+ prerelease: false
107
+ version_requirements: !ruby/object:Gem::Requirement
108
+ requirements:
109
+ - - ">="
110
+ - !ruby/object:Gem::Version
111
+ version: '0'
98
112
  - !ruby/object:Gem::Dependency
99
113
  name: pry-byebug
100
114
  requirement: !ruby/object:Gem::Requirement
@@ -138,7 +152,7 @@ dependencies:
138
152
  - !ruby/object:Gem::Version
139
153
  version: '0'
140
154
  - !ruby/object:Gem::Dependency
141
- name: rubocop
155
+ name: ronn-ng
142
156
  requirement: !ruby/object:Gem::Requirement
143
157
  requirements:
144
158
  - - ">="
@@ -152,7 +166,7 @@ dependencies:
152
166
  - !ruby/object:Gem::Version
153
167
  version: '0'
154
168
  - !ruby/object:Gem::Dependency
155
- name: rubocop-minitest
169
+ name: rubocop
156
170
  requirement: !ruby/object:Gem::Requirement
157
171
  requirements:
158
172
  - - ">="
@@ -166,7 +180,7 @@ dependencies:
166
180
  - !ruby/object:Gem::Version
167
181
  version: '0'
168
182
  - !ruby/object:Gem::Dependency
169
- name: rubocop-rake
183
+ name: rubocop-minitest
170
184
  requirement: !ruby/object:Gem::Requirement
171
185
  requirements:
172
186
  - - ">="
@@ -180,7 +194,7 @@ dependencies:
180
194
  - !ruby/object:Gem::Version
181
195
  version: '0'
182
196
  - !ruby/object:Gem::Dependency
183
- name: webmock
197
+ name: rubocop-rake
184
198
  requirement: !ruby/object:Gem::Requirement
185
199
  requirements:
186
200
  - - ">="
@@ -194,13 +208,13 @@ dependencies:
194
208
  - !ruby/object:Gem::Version
195
209
  version: '0'
196
210
  - !ruby/object:Gem::Dependency
197
- name: io-console
211
+ name: webmock
198
212
  requirement: !ruby/object:Gem::Requirement
199
213
  requirements:
200
214
  - - ">="
201
215
  - !ruby/object:Gem::Version
202
216
  version: '0'
203
- type: :runtime
217
+ type: :development
204
218
  prerelease: false
205
219
  version_requirements: !ruby/object:Gem::Requirement
206
220
  requirements:
@@ -246,14 +260,20 @@ files:
246
260
  - lib/uffizzi.rb
247
261
  - lib/uffizzi/auth_helper.rb
248
262
  - lib/uffizzi/cli.rb
263
+ - lib/uffizzi/cli/common.rb
249
264
  - lib/uffizzi/cli/config.rb
250
265
  - lib/uffizzi/cli/login.rb
266
+ - lib/uffizzi/cli/logout.rb
251
267
  - lib/uffizzi/cli/projects.rb
252
268
  - lib/uffizzi/clients/api/api_client.rb
253
269
  - lib/uffizzi/clients/api/api_routes.rb
254
270
  - lib/uffizzi/clients/api/http_client.rb
255
271
  - lib/uffizzi/config_file.rb
272
+ - lib/uffizzi/response_helper.rb
273
+ - lib/uffizzi/shell.rb
256
274
  - lib/uffizzi/version.rb
275
+ - man/uffizzi-logout
276
+ - man/uffizzi-logout.ronn
257
277
  - uffizzi.gemspec
258
278
  homepage: https://uffizzi.com
259
279
  licenses:
@@ -262,7 +282,7 @@ metadata:
262
282
  homepage_uri: https://uffizzi.com
263
283
  source_code_uri: https://github.com/UffizziCloud/uffizzi_cli
264
284
  changelog_uri: https://github.com/UffizziCloud/uffizzi_cli/blob/master/CHANGELOG.md
265
- post_install_message:
285
+ post_install_message:
266
286
  rdoc_options: []
267
287
  require_paths:
268
288
  - lib
@@ -277,8 +297,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
277
297
  - !ruby/object:Gem::Version
278
298
  version: '0'
279
299
  requirements: []
280
- rubygems_version: 3.2.22
281
- signing_key:
300
+ rubygems_version: 3.3.7
301
+ signing_key:
282
302
  specification_version: 4
283
303
  summary: uffizzi-cli
284
304
  test_files: []