gitlab-development-kit 0.1.1 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/bin/gdk +79 -28
  3. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d96b16ee2eaf3d670c9b4a0515111ed19bb2ec6e
4
- data.tar.gz: 91aeca28bdfcb29bb5c33ed5ffc322f3c0409ccc
3
+ metadata.gz: 96053977970c8478e0624219700a6748cd4ef7d2
4
+ data.tar.gz: 85a3186752629e1870a3e1986cd490cd166cc708
5
5
  SHA512:
6
- metadata.gz: 19815297dab429e908d6350715d35dbdc8457e24a91e1b9cd0ddb446bb07d9cb235eb19c10d63181a4deb23aa47a9d4ff0db66d8de21ce5de6a1a80cb04b10b6
7
- data.tar.gz: 01bbca5392a62f6719818bfcc467646c75ee94ad6904ab33ff172fc2fe1c7de126faf6863190b66ab385ee05fc4b485d31165b33bc92581d32d6461412277522
6
+ metadata.gz: 2933695c15e0f485e2dd81b847ca5528df70f47a4c2bd0eb72250a1ef3d8c16d2cbfd910958372dabb94ee93b805d2afb63b1671380025f390a729ad852b416c
7
+ data.tar.gz: 9b5176933fbadf95fad1c64e7b2337d84ec8b9c19a12c01c85fd413e25cfd7af89c3516facb6dc21d788d23dbeeea750ac7539eb0807df662895d9467b83fb03
data/bin/gdk CHANGED
@@ -1,37 +1,88 @@
1
1
  #!/usr/bin/env ruby
2
- require 'fileutils'
3
-
4
- def main
5
- case ARGV.first
6
- when 'init'
7
- if ARGV.count > 2
8
- puts "Usage: gdk init [DIR]"
9
- return false
2
+ require 'yaml'
3
+
4
+ # Gitlab Development Kit CLI launcher
5
+ #
6
+ # Note to contributors: this script must not change (much) because it is
7
+ # installed outside the gitlab-development-kit repository with 'gem
8
+ # install'. Edit lib/gdk.rb to define new commands.
9
+
10
+ module GDK
11
+ DOTFILE = File.expand_path('~/.gdk.yml')
12
+ TRUSTED_KEY = 'trusted_directories'
13
+
14
+ def self.launcher_main
15
+ case ARGV.first
16
+ when 'init'
17
+ if ARGV.count > 2
18
+ puts "Usage: gdk init [DIR]"
19
+ return false
20
+ end
21
+
22
+ cmd = %W(git clone https://gitlab.com/gitlab-org/gitlab-development-kit.git)
23
+ cmd << ARGV[1] if ARGV.count == 2
24
+ system(*cmd)
25
+ when 'trust'
26
+ if ARGV.count != 2
27
+ puts "Usage: gdk trust DIR"
28
+ return false
29
+ end
30
+ trust!(ARGV[1])
31
+ else
32
+ $gdk_root = find_root(Dir.pwd)
33
+ if $gdk_root.nil?
34
+ puts "Could not find GDK_ROOT in the current directory or any of its parents."
35
+ return false
36
+ end
37
+ puts "(in #{$gdk_root})"
38
+
39
+ if !trusted?($gdk_root)
40
+ puts <<-EOS.gsub(/^\s+\|/, '')
41
+ |
42
+ |This GitLab Development Kit root directory is not known to the "gdk"
43
+ |command. To mark it as trusted run:
44
+ |
45
+ |gdk trust #{$gdk_root}
46
+ |
47
+ EOS
48
+ return false
49
+ end
50
+
51
+ load(File.join($gdk_root, 'lib/gdk.rb'))
52
+ GDK::main
10
53
  end
54
+ end
11
55
 
12
- cmd = %W(git clone -b gdk-cli https://gitlab.com/gitlab-org/gitlab-development-kit.git)
13
- cmd << ARGV[1] if ARGV.count == 2
14
- system(*cmd)
15
- else
16
- $gdk_root = find_root(Dir.pwd)
17
- if $gdk_root.nil?
18
- puts "Could not find GDK_ROOT in the current directory or any of its parents."
19
- return false
56
+ private
57
+
58
+ def self.find_root(current)
59
+ if File.exist?(File.join(current, 'GDK_ROOT'))
60
+ File.realpath(current)
61
+ elsif File.realpath(current) == '/'
62
+ nil
63
+ else
64
+ find_root(File.join(current, '..'))
20
65
  end
21
- puts "(in #{$gdk_root})"
22
- load(File.join($gdk_root, 'lib/gdk.rb'))
23
- GDK::main
24
66
  end
25
- end
26
67
 
27
- def find_root(current)
28
- if File.exist?(File.join(current, 'GDK_ROOT'))
29
- File.realpath(current)
30
- elsif File.realpath(current) == '/'
31
- nil
32
- else
33
- find_root(File.join(current, '..'))
68
+ def self.trusted?(directory)
69
+ trusted_directories = load_dotfile[TRUSTED_KEY] || []
70
+ !!trusted_directories.include?(File.realpath(directory))
71
+ end
72
+
73
+ def self.trust!(directory)
74
+ directory = File.realpath(directory)
75
+ config = load_dotfile
76
+ config[TRUSTED_KEY] ||= []
77
+ config[TRUSTED_KEY] << directory
78
+ puts "Adding #{directory} to #{TRUSTED_KEY} in #{DOTFILE}"
79
+ File.open(DOTFILE, 'w') { |f| YAML.dump(config, f) }
80
+ true
81
+ end
82
+
83
+ def self.load_dotfile
84
+ File.open(DOTFILE, File::RDONLY | File::CREAT) { |f| YAML.load(f) } || {}
34
85
  end
35
86
  end
36
87
 
37
- exit(main)
88
+ exit(GDK::launcher_main)
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gitlab-development-kit
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jacob Vosmaer
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-08-08 00:00:00.000000000 Z
11
+ date: 2016-08-09 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: CLI for GitLab Development Kit.
14
14
  email: