af 0.3.18.7 → 0.3.18.8
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.
- data/lib/cli/commands/apps.rb +6 -36
- data/lib/cli/file_helper.rb +104 -25
- data/lib/cli/version.rb +1 -1
- metadata +2 -2
data/lib/cli/commands/apps.rb
CHANGED
@@ -478,31 +478,6 @@ module VMC::Cli::Command
|
|
478
478
|
err "Can't deploy applications from staging directory: [#{Dir.tmpdir}]"
|
479
479
|
end
|
480
480
|
|
481
|
-
def check_unreachable_links(path)
|
482
|
-
files = Dir.glob("#{path}/**/*", File::FNM_DOTMATCH)
|
483
|
-
|
484
|
-
pwd = Pathname.pwd
|
485
|
-
|
486
|
-
abspath = File.expand_path(path)
|
487
|
-
unreachable = []
|
488
|
-
files.each do |f|
|
489
|
-
file = Pathname.new(f)
|
490
|
-
if file.symlink? && !file.realpath.to_s.start_with?(abspath)
|
491
|
-
unreachable << file.relative_path_from(pwd)
|
492
|
-
end
|
493
|
-
end
|
494
|
-
|
495
|
-
unless unreachable.empty?
|
496
|
-
root = Pathname.new(path).relative_path_from(pwd)
|
497
|
-
err "Can't deploy application containing links '#{unreachable}' that reach outside its root '#{root}'"
|
498
|
-
end
|
499
|
-
end
|
500
|
-
|
501
|
-
def find_sockets(path)
|
502
|
-
files = Dir.glob("#{path}/**/*", File::FNM_DOTMATCH)
|
503
|
-
files && files.select { |f| File.socket? f }
|
504
|
-
end
|
505
|
-
|
506
481
|
def upload_app_bits(appname, path, infra)
|
507
482
|
display 'Uploading Application:'
|
508
483
|
|
@@ -527,25 +502,20 @@ module VMC::Cli::Command
|
|
527
502
|
elsif zip_file = Dir.glob('*.zip').first
|
528
503
|
VMC::Cli::ZipUtil.unpack(zip_file, explode_dir)
|
529
504
|
else
|
530
|
-
check_unreachable_links(path)
|
531
505
|
FileUtils.mkdir(explode_dir)
|
532
506
|
|
533
|
-
|
507
|
+
afi = VMC::Cli::FileHelper::AppFogIgnore.from_file("#{path}")
|
534
508
|
|
535
|
-
|
536
|
-
|
537
|
-
|
538
|
-
files = afignore("#{path}/.afignore",files)
|
539
|
-
|
540
|
-
FileUtils.cp_r(files, explode_dir)
|
509
|
+
files = Dir.glob("#{path}/**/*", File::FNM_DOTMATCH)
|
510
|
+
check_unreachable_links(path,afi.included_files(files))
|
541
511
|
|
542
|
-
|
543
|
-
|
544
|
-
end
|
512
|
+
copy_files( path, ignore_sockets( afi.included_files(files)), explode_dir )
|
513
|
+
|
545
514
|
end
|
546
515
|
end
|
547
516
|
end
|
548
517
|
|
518
|
+
|
549
519
|
# Send the resource list to the cloudcontroller, the response will tell us what it already has..
|
550
520
|
unless @options[:noresources]
|
551
521
|
display ' Checking for available resources: ', false
|
data/lib/cli/file_helper.rb
CHANGED
@@ -1,46 +1,125 @@
|
|
1
1
|
module VMC::Cli
|
2
2
|
module FileHelper
|
3
3
|
|
4
|
-
|
5
|
-
def match(pattern,filename)
|
6
|
-
return false if pattern =~ /^\s*$/ # ignore blank lines
|
4
|
+
class AppFogIgnore
|
7
5
|
|
8
|
-
|
6
|
+
def initialize(patterns,project_root = "")
|
7
|
+
@patterns = patterns + [ ".git/" ]
|
8
|
+
@project_root = project_root
|
9
|
+
end
|
9
10
|
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
11
|
+
def included_files(filenames)
|
12
|
+
exclude_dots_only(filenames).reject do |filename|
|
13
|
+
exclude = false
|
14
|
+
@patterns.each do |pattern|
|
15
|
+
if is_negative_pattern?(pattern)
|
16
|
+
exclude = false if negative_match(pattern,filename)
|
17
|
+
else
|
18
|
+
exclude ||= match(pattern,filename)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
exclude
|
22
|
+
end
|
14
23
|
end
|
15
24
|
|
16
|
-
|
17
|
-
|
25
|
+
def exclude_dots_only(filenames)
|
26
|
+
filenames.reject do |filename|
|
27
|
+
base = File.basename(filename)
|
28
|
+
base == "." || base == ".."
|
29
|
+
end
|
18
30
|
end
|
31
|
+
|
19
32
|
|
20
|
-
|
21
|
-
|
22
|
-
|
33
|
+
|
34
|
+
def excluded_files(filenames)
|
35
|
+
filenames - included_files(filenames)
|
36
|
+
end
|
37
|
+
|
38
|
+
def self.from_file(project_root)
|
39
|
+
f = "#{project_root}/.afignore"
|
40
|
+
if File.exists?(f)
|
41
|
+
contents = File.read(f).split("\n")
|
42
|
+
AppFogIgnore.new(contents,project_root)
|
43
|
+
else
|
44
|
+
AppFogIgnore.new([],project_root)
|
45
|
+
end
|
23
46
|
end
|
47
|
+
|
48
|
+
def match(pattern,filename)
|
49
|
+
|
50
|
+
filename = filename.sub(/^#{@project_root}\//,'') # remove any project directory prefix
|
51
|
+
|
52
|
+
return false if pattern =~ /^\s*$/ # ignore blank lines
|
53
|
+
|
54
|
+
return false if pattern =~ /^#/ # lines starting with # are comments
|
55
|
+
|
56
|
+
return false if pattern =~ /^!/ # lines starting with ! are negated
|
24
57
|
|
25
|
-
|
26
|
-
|
58
|
+
if pattern =~ /\/$/
|
59
|
+
# pattern ending in a slash should ignore directory and all its children
|
60
|
+
dirname = pattern.sub(/\/$/,'')
|
61
|
+
return filename == dirname || filename =~ /#{dirname}\/.*$/
|
62
|
+
end
|
63
|
+
|
64
|
+
if pattern =~ /^\//
|
65
|
+
parts = filename.split('/')
|
66
|
+
return File.fnmatch(pattern.sub(/^\//,''),parts[0])
|
67
|
+
end
|
68
|
+
|
69
|
+
if pattern.include? '/'
|
70
|
+
return File.fnmatch(pattern,filename)
|
71
|
+
end
|
72
|
+
|
73
|
+
File.fnmatch(pattern,filename,File::FNM_PATHNAME)
|
74
|
+
end
|
75
|
+
|
76
|
+
def is_negative_pattern?(pattern)
|
77
|
+
pattern =~ /^!/
|
78
|
+
end
|
79
|
+
|
80
|
+
def negative_match(pattern,filename)
|
81
|
+
return false unless pattern =~ /^!/
|
82
|
+
match(pattern.sub(/^!/,''),filename)
|
27
83
|
end
|
28
84
|
|
29
|
-
File.fnmatch(pattern,filename,File::FNM_PATHNAME)
|
30
85
|
end
|
31
86
|
|
32
|
-
def
|
33
|
-
|
34
|
-
|
87
|
+
def ignore_sockets(files)
|
88
|
+
files.reject { |f| File.socket? f }
|
89
|
+
end
|
90
|
+
|
91
|
+
def check_unreachable_links(path,files)
|
92
|
+
pwd = Pathname.new(path)
|
93
|
+
abspath = pwd.realpath.to_s
|
94
|
+
unreachable = []
|
95
|
+
files.each do |f|
|
96
|
+
file = Pathname.new(f)
|
97
|
+
if file.symlink? && !file.realpath.to_s.start_with?(abspath)
|
98
|
+
unreachable << file.relative_path_from(pwd).to_s
|
99
|
+
end
|
100
|
+
end
|
101
|
+
|
102
|
+
unless unreachable.empty?
|
103
|
+
root = pwd.relative_path_from(pwd).to_s
|
104
|
+
err "Can't deploy application containing links '#{unreachable.join(",")}' that reach outside its root '#{root}'"
|
35
105
|
end
|
36
106
|
end
|
37
107
|
|
38
|
-
def
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
108
|
+
def copy_files(project_root,files,dest_dir)
|
109
|
+
project_root = Pathname.new(project_root)
|
110
|
+
files.reject { |f| File.symlink?(f) }.each do |f|
|
111
|
+
dest = Pathname.new(f).relative_path_from(project_root)
|
112
|
+
if File.directory?(f)
|
113
|
+
FileUtils.mkdir_p("#{dest_dir}/#{dest}")
|
114
|
+
else
|
115
|
+
FileUtils.cp(f,"#{dest_dir}/#{dest}")
|
116
|
+
end
|
117
|
+
end
|
118
|
+
root = Pathname.new(project_root).realpath
|
119
|
+
files.select { |f| File.symlink?(f) }.each do |f|
|
120
|
+
dest = Pathname.new(f).relative_path_from(project_root)
|
121
|
+
p = Pathname.new(f).realpath
|
122
|
+
FileUtils.ln_s(p.relative_path_from(root),"#{dest_dir}/#{dest}")
|
44
123
|
end
|
45
124
|
end
|
46
125
|
|
data/lib/cli/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: af
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.18.
|
4
|
+
version: 0.3.18.8
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-
|
12
|
+
date: 2012-10-22 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: json_pure
|