mgmt 0.2.0

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.
Files changed (7) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +1 -0
  3. data/README.md +66 -0
  4. data/Rakefile +1 -0
  5. data/bin/mgmt +144 -0
  6. data/mgmt.gemspec +18 -0
  7. metadata +64 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: d4e103fcf077abbf15b8784d6c6d47b87db93bf3
4
+ data.tar.gz: 0d8b56f06cb0f6a50fea05ed2f820f94768af911
5
+ SHA512:
6
+ metadata.gz: 06823b066d6431ac9aba4ef1e2009e09afc6e119c55349873ef56848cacc1ad7aaff10422b4c98f0689b2f741f9b80b140ba9743ee85945bc2789564e4bc04ab
7
+ data.tar.gz: 9ce5bf48a57b8ade6de9d7497b469e71f9477a4bfe0d44f7b93138105a6d4dbe373e691942507fa06eafee03d32418c3d7a50b3cda6adda006068be7205f8de9
data/.gitignore ADDED
@@ -0,0 +1 @@
1
+ pkg/
data/README.md ADDED
@@ -0,0 +1,66 @@
1
+ = MGMT
2
+
3
+ A minimalistic, self-contained, massively opinionated dependency manager
4
+ for Go.
5
+
6
+ == Installation
7
+
8
+ Install it via rubygems:
9
+
10
+ gem install mgmt
11
+
12
+ Or, just download it:
13
+
14
+ wget https://raw.githubusercontent.com/bsm/mgmt/master/bin/mgmt
15
+ chmod +x mgmt
16
+ ./mgmt help
17
+
18
+ == Usage
19
+
20
+ Create a Gomtfile, e.g.:
21
+
22
+ # Standard dependencies
23
+ github.com/gorilla/context
24
+ github.com/onsi/ginkgo
25
+ github.com/onsi/gomega
26
+
27
+ # Custom repo
28
+ github.com/gorilla/mux !git@bitbucket.org/private/fork
29
+
30
+ # Custom branch/tag/version
31
+ github.com/gorilla/schema #c21d52ca
32
+
33
+ Usage:
34
+
35
+ mgmt command [arguments]
36
+
37
+ The commands are:
38
+
39
+ install bundle dependencies in .vendor
40
+ go run go within the scope of .vendor
41
+ update update a single package
42
+ version print the version
43
+ help print this information
44
+
45
+ == LICENCE
46
+
47
+ Copyright (c) 2015 Black Square Media
48
+
49
+ Permission is hereby granted, free of charge, to any person obtaining
50
+ a copy of this software and associated documentation files (the
51
+ "Software"), to deal in the Software without restriction, including
52
+ without limitation the rights to use, copy, modify, merge, publish,
53
+ distribute, sublicense, and/or sell copies of the Software, and to
54
+ permit persons to whom the Software is furnished to do so, subject to
55
+ the following conditions:
56
+
57
+ The above copyright notice and this permission notice shall be
58
+ included in all copies or substantial portions of the Software.
59
+
60
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
61
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
62
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
63
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
64
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
65
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
66
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
data/bin/mgmt ADDED
@@ -0,0 +1,144 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'fileutils'
4
+ require 'tempfile'
5
+
6
+ module MGMT
7
+ extend self
8
+
9
+ DEPSFILE = "Gopherfile"
10
+ LOCKFILE = "Gopherfile.lock"
11
+ VENDOR = ".vendor"
12
+ VERSION = "0.2.0"
13
+
14
+ def xputs(code, msg)
15
+ code = nil if ENV['TERM'] != "xterm"
16
+ print "\033[#{code}m" if code
17
+ print msg
18
+ print "\033[0m" if code
19
+ print "\n"
20
+ end
21
+
22
+ def sh(cmd)
23
+ system(cmd) || abort("Failed to execute command: #{cmd}")
24
+ end
25
+
26
+ def abort(msg)
27
+ xputs "31;1", ">>>> #{msg}"
28
+ Kernel.exit(1)
29
+ end
30
+
31
+ def pull(deps)
32
+ deps.each do |dep|
33
+ xputs "33;1", "---> #{dep.name}"
34
+ dep.pull!
35
+ end
36
+ end
37
+
38
+ def read_deps
39
+ source = File.exist?(LOCKFILE) ? LOCKFILE : DEPSFILE
40
+ abort "#{source} not found" unless File.exist?(source)
41
+
42
+ File.read(source).each_line.map {|ln| parse(ln) }.compact
43
+ end
44
+
45
+ def write_lockfile(deps)
46
+ temp = Tempfile.new LOCKFILE
47
+ deps.each {|d| temp.puts d.to_s }
48
+ temp.close
49
+ FileUtils.mv temp.path, LOCKFILE
50
+ xputs "32", "==== #{LOCKFILE} written"
51
+ end
52
+
53
+ def parse(line)
54
+ line = line.strip
55
+ return if line[0] == "#"
56
+
57
+ tokens = line.split(/ +/)
58
+ return if tokens.empty?
59
+
60
+ opts = {}
61
+ tokens[1..-1].each do |token|
62
+ case token[0]
63
+ when "!", 33
64
+ opts[:repo] = token[1..-1]
65
+ when "#", 35
66
+ opts[:tag] = token[1..-1]
67
+ end
68
+ end
69
+ Dep.new tokens[0], opts
70
+ end
71
+
72
+ def exec(*c)
73
+ ENV['GOPATH'] = "#{File.expand_path(VENDOR, ".")}:#{ENV['GOPATH']}"
74
+ Kernel.exec *c
75
+ end
76
+
77
+ class Dep
78
+ attr_reader :name, :repo
79
+ attr_accessor :tag
80
+
81
+ def initialize(name, opts = {})
82
+ @name = name
83
+ @tag = opts[:tag]
84
+ @repo = opts[:repo] || "http://#{name}"
85
+ end
86
+
87
+ def target
88
+ @target ||= File.join(VENDOR, 'src', @name)
89
+ end
90
+
91
+ def pull!
92
+ if File.directory?(target)
93
+ MGMT.sh "git -C #{target} pull -q origin master"
94
+ else
95
+ MGMT.sh "git clone #{@repo} #{target}"
96
+ end
97
+
98
+ @tag ||= `git -C #{target} log -n 1 --pretty=format:'%h'`.strip
99
+ MGMT.sh "git -C #{target} reset --hard #{@tag}"
100
+ end
101
+
102
+ def to_s
103
+ "#{@name} ##{@tag} !#{@repo}"
104
+ end
105
+ end
106
+ end
107
+
108
+ # -------------------------------------------------------------------------
109
+
110
+ case ARGV.shift
111
+ when "install", nil
112
+ deps = MGMT.read_deps
113
+ MGMT.pull(deps)
114
+ MGMT.write_lockfile(deps)
115
+ when "go"
116
+ MGMT.exec "go", *ARGV
117
+ when "update"
118
+ deps = MGMT.read_deps
119
+ some = deps.select {|d| ARGV.include?(d.name) }
120
+ unless some.empty?
121
+ some.each {|d| d.tag = nil }
122
+ MGMT.pull(some)
123
+ MGMT.write_lockfile(deps)
124
+ end
125
+ when "version"
126
+ puts MGMT::VERSION
127
+ else
128
+ puts %(mgmt is a minimalistic solution to managing Go dependencies.
129
+
130
+ Usage:
131
+
132
+ mgmt command [arguments]
133
+
134
+ The commands are:
135
+
136
+ install bundle dependencies in .vendor
137
+ go run go within the scope of .vendor
138
+ update update a single package
139
+ version print the version
140
+ help print this information
141
+
142
+ )
143
+ exit 2
144
+ end if File.basename($0) == File.basename(__FILE__)
data/mgmt.gemspec ADDED
@@ -0,0 +1,18 @@
1
+ # coding: utf-8
2
+ load File.expand_path('../bin/mgmt', __FILE__)
3
+
4
+ Gem::Specification.new do |spec|
5
+ spec.name = 'mgmt'
6
+ spec.version = MGMT::VERSION
7
+ spec.authors = ['Dimitrij Denissenko']
8
+ spec.email = ['dimitrij@blacksquaremedia.com']
9
+ spec.description = %q{manage go dependencies}
10
+ spec.summary = %q{a minimalistic, self-contained, massively opinionated dependency manager}
11
+ spec.homepage = 'https://github.com/bsm/mgmt'
12
+ spec.license = 'MIT'
13
+
14
+ spec.files = `git ls-files`.split($/)
15
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
16
+
17
+ spec.add_development_dependency 'rake'
18
+ end
metadata ADDED
@@ -0,0 +1,64 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: mgmt
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.2.0
5
+ platform: ruby
6
+ authors:
7
+ - Dimitrij Denissenko
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-02-03 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rake
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ description: manage go dependencies
28
+ email:
29
+ - dimitrij@blacksquaremedia.com
30
+ executables:
31
+ - mgmt
32
+ extensions: []
33
+ extra_rdoc_files: []
34
+ files:
35
+ - ".gitignore"
36
+ - README.md
37
+ - Rakefile
38
+ - bin/mgmt
39
+ - mgmt.gemspec
40
+ homepage: https://github.com/bsm/mgmt
41
+ licenses:
42
+ - MIT
43
+ metadata: {}
44
+ post_install_message:
45
+ rdoc_options: []
46
+ require_paths:
47
+ - lib
48
+ required_ruby_version: !ruby/object:Gem::Requirement
49
+ requirements:
50
+ - - ">="
51
+ - !ruby/object:Gem::Version
52
+ version: '0'
53
+ required_rubygems_version: !ruby/object:Gem::Requirement
54
+ requirements:
55
+ - - ">="
56
+ - !ruby/object:Gem::Version
57
+ version: '0'
58
+ requirements: []
59
+ rubyforge_project:
60
+ rubygems_version: 2.4.5
61
+ signing_key:
62
+ specification_version: 4
63
+ summary: a minimalistic, self-contained, massively opinionated dependency manager
64
+ test_files: []