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 +5 -5
- data/bin/gdk +59 -33
- data/lib/gitlab_development_kit.rb +5 -0
- metadata +11 -11
- data/lib/gitlab-development-kit.rb +0 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: ad0daa1c74f5e6b1201da5b7348a6acfad5171068d139509ab01bb4a753f5411
|
4
|
+
data.tar.gz: 1179e66732f288d27c83fb874fdfa72887e5c9fc9974b6c66dcbf81092c6a0bd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
-
|
5
|
-
require '
|
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
|
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
|
-
|
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
|
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
|
-
|
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
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
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
|
-
|
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
|
-
|
84
|
-
|
85
|
-
|
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)
|
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 =>
|
99
|
-
warn
|
124
|
+
rescue StandardError => e
|
125
|
+
warn e
|
100
126
|
false
|
101
127
|
end
|
102
128
|
end
|
103
129
|
|
104
|
-
exit(GDK
|
130
|
+
exit(GDK.launcher_main)
|
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.
|
4
|
+
version: 0.2.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jacob Vosmaer
|
8
|
-
|
8
|
+
- GitLab
|
9
|
+
autorequire:
|
9
10
|
bindir: bin
|
10
11
|
cert_chain: []
|
11
|
-
date:
|
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
|
-
-
|
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/
|
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:
|
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
|
-
|
43
|
-
|
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: []
|