fig 0.1.16 → 0.1.17
Sign up to get free protection for your applications and to get access to all the features.
- data/bin/fig +17 -4
- data/lib/fig/options.rb +6 -0
- data/lib/fig/os.rb +19 -3
- data/lib/fig/repository.rb +8 -4
- data/spec/fig_spec.rb +53 -12
- metadata +26 -4
data/bin/fig
CHANGED
@@ -129,7 +129,7 @@ if input
|
|
129
129
|
end
|
130
130
|
end
|
131
131
|
end
|
132
|
-
unless options[:publish] || options[:list]
|
132
|
+
unless options[:publish] || options[:list] || options[:publish_local]
|
133
133
|
env.register_package(package)
|
134
134
|
env.apply_config(package, options[:config])
|
135
135
|
direct_retrieves.each do |info|
|
@@ -140,9 +140,9 @@ else
|
|
140
140
|
package = Package.new(nil, nil, ".", [])
|
141
141
|
end
|
142
142
|
|
143
|
-
if options[:publish]
|
143
|
+
if options[:publish] || options[:publish_local]
|
144
144
|
raise "Unexpected arguments: #{argv.join(' ')}" if !argv.empty?
|
145
|
-
package_name, config_name, version_name = parse_descriptor(options[:publish])
|
145
|
+
package_name, config_name, version_name = parse_descriptor(options[:publish] || options[:publish_local])
|
146
146
|
if package_name.nil? || version_name.nil?
|
147
147
|
raise "Please specify a package name and a version name"
|
148
148
|
end
|
@@ -154,7 +154,20 @@ if options[:publish]
|
|
154
154
|
else
|
155
155
|
fail "Nothing to publish"
|
156
156
|
end
|
157
|
-
|
157
|
+
if options[:publish]
|
158
|
+
puts "Checking status of #{package_name}/#{version_name}..."
|
159
|
+
if repos.list_remote_packages.include?("#{package_name}/#{version_name}")
|
160
|
+
puts "#{package_name}/#{version_name} has already been published"
|
161
|
+
if not options[:force]
|
162
|
+
puts "Use the --force option if you really want to overwrite, or us --publish-local for testing"
|
163
|
+
exit 1
|
164
|
+
else
|
165
|
+
puts "Overwriting..."
|
166
|
+
end
|
167
|
+
end
|
168
|
+
end
|
169
|
+
puts "Publishing #{package_name}/#{version_name}"
|
170
|
+
repos.publish_package(publish_statements, package_name, version_name, options[:publish_local])
|
158
171
|
elsif options[:echo]
|
159
172
|
puts env[options[:echo]]
|
160
173
|
elsif shell_command
|
data/lib/fig/options.rb
CHANGED
@@ -39,6 +39,12 @@ module Fig
|
|
39
39
|
options[:publish] = nil
|
40
40
|
opts.on('--publish PKG', 'install package in local and remote repositories') { |publish| options[:publish] = publish }
|
41
41
|
|
42
|
+
options[:publish_local] = nil
|
43
|
+
opts.on('--publish-local PKG', 'install package in local repositorie only') { |publish_local| options[:publish_local] = publish_local }
|
44
|
+
|
45
|
+
options[:force] = nil
|
46
|
+
opts.on('--force', 'force overwriting of an existing remote package version') { |force| options[:force] = force }
|
47
|
+
|
42
48
|
options[:resources] =[]
|
43
49
|
opts.on('--resource PATH', 'resource to include in package (when using --publish)') do |path|
|
44
50
|
options[:resources] << Resource.new(path)
|
data/lib/fig/os.rb
CHANGED
@@ -38,7 +38,11 @@ module Fig
|
|
38
38
|
NOT_FOUND = 4
|
39
39
|
|
40
40
|
def download_list(url)
|
41
|
-
|
41
|
+
begin
|
42
|
+
uri = URI.parse(url)
|
43
|
+
rescue
|
44
|
+
raise "Unable to parse url: '#{url}'"
|
45
|
+
end
|
42
46
|
case uri.scheme
|
43
47
|
when "ftp"
|
44
48
|
ftp = Net::FTP.new(uri.host)
|
@@ -51,6 +55,19 @@ module Fig
|
|
51
55
|
end
|
52
56
|
ftp.close
|
53
57
|
packages
|
58
|
+
when "ssh"
|
59
|
+
packages = []
|
60
|
+
Net::SSH.start(uri.host, uri.user) do |ssh|
|
61
|
+
ls = ssh.exec!("[ -d #{uri.path} ] && find #{uri.path}")
|
62
|
+
if not ls.nil?
|
63
|
+
ls = ls.gsub(uri.path + "/", "").gsub(uri.path, "")
|
64
|
+
ls.each do |line|
|
65
|
+
parts = line.gsub(/\\/, '/').sub(/^\.\//, '').sub(/:$/, '').chomp().split('/')
|
66
|
+
packages << parts.join('/') if parts.size == 2
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
70
|
+
packages
|
54
71
|
else
|
55
72
|
raise "Protocol not supported: #{url}"
|
56
73
|
end
|
@@ -106,7 +123,7 @@ module Fig
|
|
106
123
|
case basename
|
107
124
|
when /\.tar\.gz$/
|
108
125
|
unpack_archive(dir, path)
|
109
|
-
|
126
|
+
when /\.tgz$/
|
110
127
|
unpack_archive(dir, path)
|
111
128
|
when /\.tar\.bz2$/
|
112
129
|
unpack_archive(dir, path)
|
@@ -164,7 +181,6 @@ module Fig
|
|
164
181
|
def copy(source, target)
|
165
182
|
FileUtils.mkdir_p(File.dirname(target))
|
166
183
|
FileUtils.copy_file(source, target)
|
167
|
-
target
|
168
184
|
end
|
169
185
|
|
170
186
|
def move_file(dir, from, to)
|
data/lib/fig/repository.rb
CHANGED
@@ -42,7 +42,7 @@ module Fig
|
|
42
42
|
@os.download_list(@remote_repository_url)
|
43
43
|
end
|
44
44
|
|
45
|
-
def publish_package(package_statements, package_name, version_name)
|
45
|
+
def publish_package(package_statements, package_name, version_name, local_only)
|
46
46
|
temp_dir = temp_dir_for_package(package_name, version_name)
|
47
47
|
@os.clear_directory(temp_dir)
|
48
48
|
fig_file = File.join(temp_dir, ".fig")
|
@@ -63,15 +63,19 @@ module Fig
|
|
63
63
|
else
|
64
64
|
archive_local = statement.url
|
65
65
|
end
|
66
|
-
@os.upload(archive_local, archive_remote, @remote_repository_user)
|
66
|
+
@os.upload(archive_local, archive_remote, @remote_repository_user) unless local_only
|
67
|
+
@os.copy(archive_local, local_dir_for_package(package_name, version_name) + "/" + archive_name)
|
68
|
+
if statement.is_a?(Archive)
|
69
|
+
@os.unpack_archive(local_dir_for_package(package_name, version_name), archive_name)
|
70
|
+
end
|
67
71
|
statement.class.new(archive_name).unparse('')
|
68
72
|
else
|
69
73
|
statement.unparse('')
|
70
74
|
end
|
71
75
|
end.select {|s|not s.nil?}
|
72
76
|
@os.write(fig_file, content.join("\n").strip)
|
73
|
-
@os.upload(fig_file, remote_fig_file_for_package(package_name, version_name), @remote_repository_user)
|
74
|
-
|
77
|
+
@os.upload(fig_file, remote_fig_file_for_package(package_name, version_name), @remote_repository_user) unless local_only
|
78
|
+
@os.copy(fig_file, local_fig_file_for_package(package_name, version_name))
|
75
79
|
end
|
76
80
|
|
77
81
|
def bundle_resources(package_statements)
|
data/spec/fig_spec.rb
CHANGED
@@ -47,10 +47,7 @@ def fig(args, input=nil)
|
|
47
47
|
$stderr.puts err
|
48
48
|
end
|
49
49
|
end
|
50
|
-
|
51
|
-
raise "Command failed: #{$?.exitstatus}"
|
52
|
-
end
|
53
|
-
return out, err
|
50
|
+
return out, err, $?.exitstatus
|
54
51
|
end
|
55
52
|
|
56
53
|
describe "Fig" do
|
@@ -69,7 +66,7 @@ describe "Fig" do
|
|
69
66
|
end
|
70
67
|
|
71
68
|
it "append environment variable from command line" do
|
72
|
-
fig('-p PATH=foo -g PATH').should == ["foo#{File::PATH_SEPARATOR}#{ENV['PATH']}",""]
|
69
|
+
fig('-p PATH=foo -g PATH').should == ["foo#{File::PATH_SEPARATOR}#{ENV['PATH']}","",0]
|
73
70
|
end
|
74
71
|
|
75
72
|
it "append environment variable from fig file" do
|
@@ -78,11 +75,11 @@ describe "Fig" do
|
|
78
75
|
add PATH=foo
|
79
76
|
end
|
80
77
|
END
|
81
|
-
fig('-g PATH', input).should == ["foo#{File::PATH_SEPARATOR}#{ENV['PATH']}",""]
|
78
|
+
fig('-g PATH', input).should == ["foo#{File::PATH_SEPARATOR}#{ENV['PATH']}","",0]
|
82
79
|
end
|
83
80
|
|
84
81
|
it "append empty environment variable" do
|
85
|
-
fig('-p XYZZY=foo -g XYZZY').should == ["foo",""]
|
82
|
+
fig('-p XYZZY=foo -g XYZZY').should == ["foo","",0]
|
86
83
|
end
|
87
84
|
|
88
85
|
it "should ignore comments" do
|
@@ -105,7 +102,9 @@ describe "Fig" do
|
|
105
102
|
set FOO=BAR
|
106
103
|
end
|
107
104
|
END
|
108
|
-
|
105
|
+
fig('--publish foo/1.2.3', input)
|
106
|
+
fail unless File.exists? FIG_HOME + "/repos/foo/1.2.3/.fig"
|
107
|
+
fail unless File.exists? FIG_REMOTE_DIR + "/foo/1.2.3/.fig"
|
109
108
|
fig('-u -i foo/1.2.3 -g FOO')[0].should == 'BAR'
|
110
109
|
end
|
111
110
|
|
@@ -121,7 +120,9 @@ describe "Fig" do
|
|
121
120
|
append PATH=@/tmp/bin
|
122
121
|
end
|
123
122
|
END
|
124
|
-
|
123
|
+
fig('--publish foo/1.2.3', input)
|
124
|
+
fail unless File.exists? FIG_HOME + "/repos/foo/1.2.3/.fig"
|
125
|
+
fail unless File.exists? FIG_REMOTE_DIR + "/foo/1.2.3/.fig"
|
125
126
|
fig('-u -i foo/1.2.3 -- hello')[0].should == 'bar'
|
126
127
|
end
|
127
128
|
|
@@ -131,10 +132,50 @@ describe "Fig" do
|
|
131
132
|
FileUtils.mkdir_p("tmp/bin")
|
132
133
|
File.open("tmp/bin/hello", "w") { |f| f << "echo bar" }
|
133
134
|
fail unless system "chmod +x tmp/bin/hello"
|
134
|
-
|
135
|
+
fig('--publish foo/1.2.3 --resource tmp/bin/hello --append PATH=@/tmp/bin')
|
136
|
+
fail unless File.exists? FIG_HOME + "/repos/foo/1.2.3/.fig"
|
137
|
+
fail unless File.exists? FIG_REMOTE_DIR + "/foo/1.2.3/.fig"
|
135
138
|
fig('-u -i foo/1.2.3 -- hello')[0].should == 'bar'
|
136
139
|
end
|
137
140
|
|
141
|
+
it "refuses to overwrite existing version in remote repository without being forced" do
|
142
|
+
FileUtils.rm_rf(FIG_HOME)
|
143
|
+
FileUtils.rm_rf(FIG_REMOTE_DIR)
|
144
|
+
input = <<-END
|
145
|
+
config default
|
146
|
+
set FOO=SHEEP
|
147
|
+
end
|
148
|
+
END
|
149
|
+
fig('--publish foo/1.2.3', input)
|
150
|
+
fail unless File.exists? FIG_HOME + "/repos/foo/1.2.3/.fig"
|
151
|
+
fail unless File.exists? FIG_REMOTE_DIR + "/foo/1.2.3/.fig"
|
152
|
+
fig('-u -i foo/1.2.3 -g FOO')[0].should == 'SHEEP'
|
153
|
+
|
154
|
+
input = <<-END
|
155
|
+
config default
|
156
|
+
set FOO=CHEESE
|
157
|
+
end
|
158
|
+
END
|
159
|
+
(out, err, exitstatus) = fig('--publish foo/1.2.3', input)
|
160
|
+
exitstatus.should == 1
|
161
|
+
fig('-u -i foo/1.2.3 -g FOO')[0].should == 'SHEEP'
|
162
|
+
|
163
|
+
(out, err, exitstatus) = fig('--publish foo/1.2.3 --force', input)
|
164
|
+
exitstatus.should == 0
|
165
|
+
fig('-u -i foo/1.2.3 -g FOO')[0].should == 'CHEESE'
|
166
|
+
end
|
167
|
+
|
168
|
+
it "publishes to the local repo only when told to" do
|
169
|
+
FileUtils.rm_rf(FIG_HOME)
|
170
|
+
FileUtils.rm_rf(FIG_REMOTE_DIR)
|
171
|
+
FileUtils.mkdir_p("tmp/bin")
|
172
|
+
File.open("tmp/bin/hello", "w") { |f| f << "echo bar" }
|
173
|
+
fail unless system "chmod +x tmp/bin/hello"
|
174
|
+
fig('--publish-local foo/1.2.3 --resource tmp/bin/hello --append PATH=@/tmp/bin')
|
175
|
+
fail if File.exists? FIG_REMOTE_DIR + "/foo/1.2.3/.fig"
|
176
|
+
fail unless fig('-m -i foo/1.2.3 -- hello')[0].should == 'bar'
|
177
|
+
end
|
178
|
+
|
138
179
|
it "retrieve resource" do
|
139
180
|
FileUtils.rm_rf(FIG_HOME)
|
140
181
|
FileUtils.rm_rf(FIG_REMOTE_DIR)
|
@@ -147,7 +188,7 @@ describe "Fig" do
|
|
147
188
|
append FOOPATH=@/tmp/lib/hello
|
148
189
|
end
|
149
190
|
END
|
150
|
-
|
191
|
+
fig('--publish foo/1.2.3', input)
|
151
192
|
input = <<-END
|
152
193
|
retrieve FOOPATH->tmp/lib2/[package]
|
153
194
|
config default
|
@@ -173,7 +214,7 @@ describe "Fig" do
|
|
173
214
|
append FOOPATH=@/tmp/lib/hello2
|
174
215
|
end
|
175
216
|
END
|
176
|
-
|
217
|
+
fig('--publish foo/1.2.3', input)
|
177
218
|
input = <<-END
|
178
219
|
retrieve FOOPATH->tmp/lib2/[package]
|
179
220
|
config default
|
metadata
CHANGED
@@ -1,12 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fig
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
+
hash: 57
|
4
5
|
prerelease: false
|
5
6
|
segments:
|
6
7
|
- 0
|
7
8
|
- 1
|
8
|
-
-
|
9
|
-
version: 0.1.
|
9
|
+
- 17
|
10
|
+
version: 0.1.17
|
10
11
|
platform: ruby
|
11
12
|
authors:
|
12
13
|
- Matthew Foemmel
|
@@ -14,16 +15,18 @@ autorequire:
|
|
14
15
|
bindir: bin
|
15
16
|
cert_chain: []
|
16
17
|
|
17
|
-
date: 2010-
|
18
|
+
date: 2010-07-30 00:00:00 +01:00
|
18
19
|
default_executable:
|
19
20
|
dependencies:
|
20
21
|
- !ruby/object:Gem::Dependency
|
21
22
|
name: libarchive
|
22
23
|
prerelease: false
|
23
24
|
requirement: &id001 !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
24
26
|
requirements:
|
25
27
|
- - ">="
|
26
28
|
- !ruby/object:Gem::Version
|
29
|
+
hash: 25
|
27
30
|
segments:
|
28
31
|
- 0
|
29
32
|
- 1
|
@@ -35,9 +38,11 @@ dependencies:
|
|
35
38
|
name: net-ssh
|
36
39
|
prerelease: false
|
37
40
|
requirement: &id002 !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
38
42
|
requirements:
|
39
43
|
- - ">="
|
40
44
|
- !ruby/object:Gem::Version
|
45
|
+
hash: 17
|
41
46
|
segments:
|
42
47
|
- 2
|
43
48
|
- 0
|
@@ -49,9 +54,11 @@ dependencies:
|
|
49
54
|
name: net-sftp
|
50
55
|
prerelease: false
|
51
56
|
requirement: &id003 !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
52
58
|
requirements:
|
53
59
|
- - ">="
|
54
60
|
- !ruby/object:Gem::Version
|
61
|
+
hash: 11
|
55
62
|
segments:
|
56
63
|
- 2
|
57
64
|
- 0
|
@@ -63,9 +70,11 @@ dependencies:
|
|
63
70
|
name: polyglot
|
64
71
|
prerelease: false
|
65
72
|
requirement: &id004 !ruby/object:Gem::Requirement
|
73
|
+
none: false
|
66
74
|
requirements:
|
67
75
|
- - ">="
|
68
76
|
- !ruby/object:Gem::Version
|
77
|
+
hash: 5
|
69
78
|
segments:
|
70
79
|
- 0
|
71
80
|
- 2
|
@@ -77,9 +86,11 @@ dependencies:
|
|
77
86
|
name: treetop
|
78
87
|
prerelease: false
|
79
88
|
requirement: &id005 !ruby/object:Gem::Requirement
|
89
|
+
none: false
|
80
90
|
requirements:
|
81
91
|
- - ">="
|
82
92
|
- !ruby/object:Gem::Version
|
93
|
+
hash: 3
|
83
94
|
segments:
|
84
95
|
- 1
|
85
96
|
- 4
|
@@ -91,9 +102,11 @@ dependencies:
|
|
91
102
|
name: rspec
|
92
103
|
prerelease: false
|
93
104
|
requirement: &id006 !ruby/object:Gem::Requirement
|
105
|
+
none: false
|
94
106
|
requirements:
|
95
107
|
- - ">="
|
96
108
|
- !ruby/object:Gem::Version
|
109
|
+
hash: 13
|
97
110
|
segments:
|
98
111
|
- 1
|
99
112
|
- 2
|
@@ -105,9 +118,11 @@ dependencies:
|
|
105
118
|
name: open4
|
106
119
|
prerelease: false
|
107
120
|
requirement: &id007 !ruby/object:Gem::Requirement
|
121
|
+
none: false
|
108
122
|
requirements:
|
109
123
|
- - ">="
|
110
124
|
- !ruby/object:Gem::Version
|
125
|
+
hash: 21
|
111
126
|
segments:
|
112
127
|
- 1
|
113
128
|
- 0
|
@@ -139,6 +154,9 @@ files:
|
|
139
154
|
- lib/fig/windows.rb
|
140
155
|
- LICENSE
|
141
156
|
- README.md
|
157
|
+
- spec/fig_spec.rb
|
158
|
+
- spec/spec_helper.rb
|
159
|
+
- spec/win_spec.rb
|
142
160
|
has_rdoc: true
|
143
161
|
homepage: http://github.com/mfoemmel/fig
|
144
162
|
licenses: []
|
@@ -149,23 +167,27 @@ rdoc_options:
|
|
149
167
|
require_paths:
|
150
168
|
- lib
|
151
169
|
required_ruby_version: !ruby/object:Gem::Requirement
|
170
|
+
none: false
|
152
171
|
requirements:
|
153
172
|
- - ">="
|
154
173
|
- !ruby/object:Gem::Version
|
174
|
+
hash: 3
|
155
175
|
segments:
|
156
176
|
- 0
|
157
177
|
version: "0"
|
158
178
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
179
|
+
none: false
|
159
180
|
requirements:
|
160
181
|
- - ">="
|
161
182
|
- !ruby/object:Gem::Version
|
183
|
+
hash: 3
|
162
184
|
segments:
|
163
185
|
- 0
|
164
186
|
version: "0"
|
165
187
|
requirements: []
|
166
188
|
|
167
189
|
rubyforge_project:
|
168
|
-
rubygems_version: 1.3.
|
190
|
+
rubygems_version: 1.3.7
|
169
191
|
signing_key:
|
170
192
|
specification_version: 3
|
171
193
|
summary: Fig is a utility for configuring environments and managing dependencies across a team of developers..
|