gitlab-development-kit 0.2.3 → 0.2.8

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
- SHA1:
3
- metadata.gz: 048d6a5c0cf12139423fd00a52692f80c4a926d8
4
- data.tar.gz: 5ae51adc3c875e66be21f09595a27c9331b0a090
2
+ SHA256:
3
+ metadata.gz: ad0daa1c74f5e6b1201da5b7348a6acfad5171068d139509ab01bb4a753f5411
4
+ data.tar.gz: 1179e66732f288d27c83fb874fdfa72887e5c9fc9974b6c66dcbf81092c6a0bd
5
5
  SHA512:
6
- metadata.gz: d467bd2f6cd63ab87ee6e78ca4b63dc163c0b7d69b6fc4522ec46bdea20b28336f79bb207d36217c8d19f6710526ad20e3030eaf57fdeea41818696024d6c567
7
- data.tar.gz: 589794185c7116e427349388a5bb2da0805c06e0b6d2c61215f15cc7d4ee4ac7aab58c177a66f177292d26210c363604080e2d9e2b0fc8400015f0d4564a72a5
6
+ metadata.gz: 3907a93a3210b2f0978491a918cb5e1baad5c4da279b4b18a344f57f48521c590b43f2eb80197e02bbe25e36f0ae14ed5a5bc6640952519a7fed1b3420a3da92
7
+ data.tar.gz: cbe49830e3ba32163a9a1a150fb16654c706a03a8b5a49419fe508b3e920a8eb0033e8daa9acb336204f68c3bcacdd33a83a92b5821167f2f4faf129d8565ddc
data/bin/gdk CHANGED
@@ -1,66 +1,83 @@
1
1
  #!/usr/bin/env ruby
2
+
3
+ # frozen_string_literal: true
4
+
2
5
  require 'yaml'
3
6
 
4
- $:.unshift(File.expand_path('../../lib', __FILE__))
5
- require 'gitlab-development-kit'
7
+ $LOAD_PATH.unshift(File.expand_path('../lib', __dir__))
8
+ require 'gitlab_development_kit'
6
9
 
7
10
  # Gitlab Development Kit CLI launcher
8
11
  #
9
12
  # Note to contributors: this script must not change (much) because it is
10
13
  # installed outside the gitlab-development-kit repository with 'gem
11
14
  # install'. Edit lib/gdk.rb to define new commands.
12
-
13
15
  module GDK
14
16
  DOTFILE = File.expand_path('~/.gdk.yml')
15
17
  TRUSTED_KEY = 'trusted_directories'
16
18
  ROOT_CHECK_FILE = '.gdk-install-root'
19
+ DEFAULT_INIT_DIRECTORY = File.join(Dir.pwd, 'gitlab-development-kit')
17
20
 
18
- def self.launcher_main
21
+ def self.launcher_main # rubocop:disable Metrics/CyclomaticComplexity
19
22
  case ARGV.first
20
23
  when 'version'
21
24
  puts "GitLab Development Kit gem version #{GDK::GEM_VERSION}"
22
25
  true
23
26
  when 'init'
24
- if ARGV.count > 2
25
- puts "Usage: gdk init [DIR]"
27
+ if ARGV.count > 2 || (ARGV.count == 2 && (ARGV[1] == '-help' || ARGV[1] == '--help'))
28
+ puts 'Usage: gdk init [DIR]'
29
+ return false
30
+ end
31
+ directory = ARGV.count == 2 ? ARGV[1] : DEFAULT_INIT_DIRECTORY
32
+ if directory.start_with?('-')
33
+ warn <<~INVALID_GDK_DIR_NAME
34
+ The gdk directory cannot start with a dash ('-'). Did you mean:
35
+ gdk init #{directory.sub(/^-+/, '')}
36
+ INVALID_GDK_DIR_NAME
26
37
  return false
27
38
  end
28
- directory = ARGV.count == 2 ? ARGV[1] : 'gitlab-development-kit'
29
- cmd = %W(git clone https://gitlab.com/gitlab-org/gitlab-development-kit.git #{directory})
39
+ cmd = %W[git clone https://gitlab.com/gitlab-org/gitlab-development-kit.git #{directory}]
30
40
  system(*cmd) && trust!(directory) && remember!(directory)
31
41
  when 'trust'
32
42
  if ARGV.count != 2
33
- puts "Usage: gdk trust DIR"
43
+ puts 'Usage: gdk trust DIR'
34
44
  return false
35
45
  end
36
46
  trust!(ARGV[1])
37
47
  else
48
+ # rubocop:disable Style/GlobalVars
38
49
  $gdk_root = find_root(Dir.pwd)
39
50
  if $gdk_root.nil?
40
- puts "Could not find GDK_ROOT in the current directory or any of its parents."
51
+ warn <<~NOT_A_GDK_DIR
52
+
53
+ The current working directory is not inside a gitlab-development-kit
54
+ installation. Use 'cd' to go to your gitlab-development-kit or create
55
+ a new one with 'gdk init'.
56
+
57
+ gdk init [DIRECTORY] # Default: #{DEFAULT_INIT_DIRECTORY}
58
+
59
+ NOT_A_GDK_DIR
41
60
  return false
42
61
  end
43
- puts "(in #{$gdk_root})"
44
-
45
- if !trusted?($gdk_root)
46
- puts <<-EOS.gsub(/^\s+\|/, '')
47
- |
48
- |This GitLab Development Kit root directory is not known to the "gdk"
49
- |command. To mark it as trusted run:
50
- |
51
- |gdk trust #{$gdk_root}
52
- |
53
- EOS
62
+
63
+ unless trusted?($gdk_root)
64
+ warn <<~NOT_A_TRUSTED_GDK_DIR
65
+
66
+ This GitLab Development Kit root directory is not known to the "gdk"
67
+ command. To mark it as trusted run:
68
+
69
+ gdk trust #{$gdk_root}
70
+
71
+ NOT_A_TRUSTED_GDK_DIR
54
72
  return false
55
73
  end
56
74
 
57
75
  load(File.join($gdk_root, 'lib/gdk.rb'))
58
- GDK::main
76
+ # rubocop:enable Style/GlobalVars
77
+ GDK.main
59
78
  end
60
79
  end
61
80
 
62
- private
63
-
64
81
  def self.find_root(current)
65
82
  if File.exist?(File.join(current, 'GDK_ROOT'))
66
83
  File.realpath(current)
@@ -75,30 +92,39 @@ module GDK
75
92
  trusted_directories = load_dotfile[TRUSTED_KEY] || []
76
93
  !!trusted_directories.include?(File.realpath(directory))
77
94
  end
78
-
95
+
79
96
  def self.trust!(directory)
80
97
  directory = File.realpath(directory)
81
98
  config = load_dotfile
82
99
  config[TRUSTED_KEY] ||= []
83
- config[TRUSTED_KEY] << directory
84
- puts "Adding #{directory} to #{TRUSTED_KEY} in #{DOTFILE}"
85
- File.open(DOTFILE, 'w') { |f| YAML.dump(config, f) }
100
+
101
+ if config[TRUSTED_KEY].include?(directory)
102
+ puts "#{directory} is already in #{TRUSTED_KEY} in #{DOTFILE}"
103
+ else
104
+ config[TRUSTED_KEY] << directory
105
+ config[TRUSTED_KEY].uniq!
106
+ puts "Adding #{directory} to #{TRUSTED_KEY} in #{DOTFILE}"
107
+ File.open(DOTFILE, 'w') { |f| YAML.dump(config, f) }
108
+ end
109
+
86
110
  true
87
111
  end
88
112
 
89
113
  def self.load_dotfile
90
- File.open(DOTFILE, File::RDONLY | File::CREAT) { |f| YAML.load(f) } || {}
114
+ File.open(DOTFILE, File::RDONLY | File::CREAT) do |f|
115
+ YAML.safe_load(f)
116
+ end || {}
91
117
  end
92
118
 
93
119
  def self.remember!(directory)
94
- open("#{directory}/#{ROOT_CHECK_FILE}", 'w') do |f|
120
+ File.open("#{directory}/#{ROOT_CHECK_FILE}", 'w') do |f|
95
121
  f.puts File.realpath(directory)
96
122
  end
97
123
  true
98
- rescue => ex
99
- warn ex
124
+ rescue StandardError => e
125
+ warn e
100
126
  false
101
127
  end
102
128
  end
103
129
 
104
- exit(GDK::launcher_main)
130
+ exit(GDK.launcher_main)
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ module GDK
4
+ GEM_VERSION = '0.2.8'
5
+ end
metadata CHANGED
@@ -1,47 +1,47 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gitlab-development-kit
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.3
4
+ version: 0.2.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jacob Vosmaer
8
- autorequire:
8
+ - GitLab
9
+ autorequire:
9
10
  bindir: bin
10
11
  cert_chain: []
11
- date: 2016-10-31 00:00:00.000000000 Z
12
+ date: 2020-06-18 00:00:00.000000000 Z
12
13
  dependencies: []
13
14
  description: CLI for GitLab Development Kit.
14
15
  email:
15
- - jacob@gitlab.com
16
+ - gitlab_rubygems@gitlab.com
16
17
  executables:
17
18
  - gdk
18
19
  extensions: []
19
20
  extra_rdoc_files: []
20
21
  files:
21
22
  - bin/gdk
22
- - lib/gitlab-development-kit.rb
23
+ - lib/gitlab_development_kit.rb
23
24
  homepage: https://gitlab.com/gitlab-org/gitlab-development-kit
24
25
  licenses:
25
26
  - MIT
26
27
  metadata: {}
27
- post_install_message:
28
+ post_install_message:
28
29
  rdoc_options: []
29
30
  require_paths:
30
31
  - lib
31
32
  required_ruby_version: !ruby/object:Gem::Requirement
32
33
  requirements:
33
- - - ">="
34
+ - - "~>"
34
35
  - !ruby/object:Gem::Version
35
- version: '0'
36
+ version: 2.6.6
36
37
  required_rubygems_version: !ruby/object:Gem::Requirement
37
38
  requirements:
38
39
  - - ">="
39
40
  - !ruby/object:Gem::Version
40
41
  version: '0'
41
42
  requirements: []
42
- rubyforge_project:
43
- rubygems_version: 2.5.1
44
- signing_key:
43
+ rubygems_version: 3.0.3
44
+ signing_key:
45
45
  specification_version: 4
46
46
  summary: CLI for GitLab Development Kit
47
47
  test_files: []
@@ -1,3 +0,0 @@
1
- module GDK
2
- GEM_VERSION = '0.2.3'
3
- end