lace 0.5.3 → 0.6.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.
- checksums.yaml +4 -4
- data/bin/lace +31 -44
- data/lib/cmd/activate.rb +4 -2
- data/lib/cmd/apply.rb +33 -11
- data/lib/cmd/deactivate.rb +4 -2
- data/lib/cmd/diff.rb +10 -7
- data/lib/cmd/fetch.rb +6 -11
- data/lib/cmd/help.rb +31 -23
- data/lib/cmd/inspect.rb +42 -17
- data/lib/cmd/list.rb +33 -10
- data/lib/cmd/remove.rb +4 -2
- data/lib/cmd/setup.rb +10 -2
- data/lib/cmd/update.rb +4 -1
- data/lib/cmd/upgrade.rb +10 -7
- data/lib/cmd/validate.rb +55 -65
- data/lib/cmd/where.rb +5 -8
- data/lib/extend/ARGV.rb +24 -32
- data/lib/extend/pathname.rb +29 -33
- data/lib/lace/exceptions.rb +56 -25
- data/lib/lace/package/facts.rb +57 -44
- data/lib/lace/package/package.rb +59 -40
- data/lib/lace/package/pkg_lace.rb +73 -0
- data/lib/lace/package/utils.rb +114 -11
- data/lib/lace/package.rb +1 -0
- data/lib/lace/utils.rb +55 -47
- data/lib/lace/version.rb +1 -1
- data/lib/lace.rb +18 -13
- metadata +3 -3
- data/lib/lace/package_cli.rb +0 -4
data/lib/cmd/validate.rb
CHANGED
|
@@ -8,14 +8,12 @@ require 'lace/exceptions'
|
|
|
8
8
|
|
|
9
9
|
VALIDATE = <<~EOS
|
|
10
10
|
Lace-Manifest Validation Report:
|
|
11
|
-
<% validation.
|
|
12
|
-
<%= "%-58s [ %s ]" % [
|
|
13
|
-
<%
|
|
14
|
-
<% error[2].each do |line| -%>
|
|
11
|
+
<% validation.results.each do |result| -%>
|
|
12
|
+
<%= "%-58s [ %s ]" % [result.name + ':', validation.colored(result.status)] %>
|
|
13
|
+
<% result.notes.each do |line| -%>
|
|
15
14
|
<%= Tty.gray %><%= '# '+line.to_s %><%= Tty.reset %>
|
|
16
15
|
<% end -%>
|
|
17
16
|
<% end -%>
|
|
18
|
-
<% end -%>
|
|
19
17
|
EOS
|
|
20
18
|
|
|
21
19
|
module Lace
|
|
@@ -32,8 +30,14 @@ module Lace
|
|
|
32
30
|
end
|
|
33
31
|
end
|
|
34
32
|
|
|
33
|
+
# Checks a manifest before it is published. Each check yields a Result;
|
|
34
|
+
# any Result with notes counts as an error.
|
|
35
35
|
class PackageValidator
|
|
36
|
-
|
|
36
|
+
# One line of the report: the check's name, its status and notes on it.
|
|
37
|
+
Result = Struct.new(:name, :status, :notes)
|
|
38
|
+
|
|
39
|
+
PASSING = %i[found ok skipped].freeze
|
|
40
|
+
FAILING = %i[missing error].freeze
|
|
37
41
|
|
|
38
42
|
class << self
|
|
39
43
|
attr_accessor :validations
|
|
@@ -50,85 +54,71 @@ class PackageValidator
|
|
|
50
54
|
validate 'setup', :setup_ok
|
|
51
55
|
validate 'post-update hook', :post_update_hooks_ok
|
|
52
56
|
|
|
57
|
+
attr_reader :results
|
|
58
|
+
|
|
53
59
|
def initialize(facts, flavor = nil)
|
|
54
60
|
@facts = facts
|
|
55
|
-
@
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
@facts.flavor! flavor
|
|
61
|
+
@facts.flavor_with(flavor)
|
|
62
|
+
@results = self.class.validations.map do |name, method_name|
|
|
63
|
+
status, notes = send(method_name)
|
|
64
|
+
Result.new(name, status, notes)
|
|
60
65
|
end
|
|
61
|
-
|
|
62
|
-
validate
|
|
63
66
|
end
|
|
64
67
|
|
|
65
|
-
def
|
|
66
|
-
|
|
67
|
-
if !File.exist? cmd
|
|
68
|
-
"#{cmd} cannot be found"
|
|
69
|
-
elsif !File.executable? cmd
|
|
70
|
-
"#{cmd} is not executable"
|
|
71
|
-
end
|
|
72
|
-
end.compact
|
|
68
|
+
def has_errors?
|
|
69
|
+
results.any? { |result| !result.notes.empty? }
|
|
73
70
|
end
|
|
74
71
|
|
|
75
|
-
def
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
["#{Tty.red}error#{Tty.reset}", errors]
|
|
83
|
-
else
|
|
84
|
-
["#{Tty.green}ok#{Tty.reset}", nil]
|
|
85
|
-
end
|
|
86
|
-
end
|
|
72
|
+
def colored(status)
|
|
73
|
+
color = case status
|
|
74
|
+
when *PASSING then Tty.green
|
|
75
|
+
when *FAILING then Tty.red
|
|
76
|
+
else raise ArgumentError, "unknown validation status: #{status.inspect}"
|
|
77
|
+
end
|
|
78
|
+
"#{color}#{status}#{Tty.reset}"
|
|
87
79
|
end
|
|
88
80
|
|
|
89
|
-
|
|
90
|
-
|
|
81
|
+
private
|
|
82
|
+
|
|
83
|
+
def config_files_present
|
|
84
|
+
files = @facts.config_files
|
|
85
|
+
return [:missing, ['Add config_files see manual for more information']] if files.empty?
|
|
86
|
+
|
|
87
|
+
absent = files.reject { |f| File.exist? f }
|
|
88
|
+
return [:found, []] if absent.empty?
|
|
89
|
+
|
|
90
|
+
[:error, absent.map { |f| "#{f.to_s.split('/').last} is missing from this package" }]
|
|
91
91
|
end
|
|
92
92
|
|
|
93
|
-
def
|
|
94
|
-
|
|
93
|
+
def version_present
|
|
94
|
+
return [:found, []] if @facts.key? 'version'
|
|
95
|
+
|
|
96
|
+
[:missing, ['adding a version to the manifest improves', 'a future update experience']]
|
|
95
97
|
end
|
|
96
98
|
|
|
97
99
|
def homepage_present
|
|
98
|
-
if @facts.key? 'homepage'
|
|
99
|
-
["#{Tty.green}found#{Tty.reset}", nil]
|
|
100
|
-
else
|
|
101
|
-
["#{Tty.red}missing#{Tty.reset}", ['adding a homepage improves the credibility', 'of your package']]
|
|
102
|
-
end
|
|
103
|
-
end
|
|
100
|
+
return [:found, []] if @facts.key? 'homepage'
|
|
104
101
|
|
|
105
|
-
|
|
106
|
-
if @facts.key? 'version'
|
|
107
|
-
["#{Tty.green}found#{Tty.reset}", nil]
|
|
108
|
-
else
|
|
109
|
-
["#{Tty.red}missing#{Tty.reset}", ['adding a version to the manifest improves', 'a future update experince']]
|
|
110
|
-
end
|
|
102
|
+
[:missing, ['adding a homepage improves the credibility', 'of your package']]
|
|
111
103
|
end
|
|
112
104
|
|
|
113
|
-
def
|
|
114
|
-
|
|
115
|
-
["#{Tty.red}missing#{Tty.reset}", ['Add config_files see manual for more information']]
|
|
116
|
-
elsif @facts.config_files.any? { |f| !File.exist? f }
|
|
117
|
-
["#{Tty.red}error#{Tty.reset}", @facts.config_files.reject do |f|
|
|
118
|
-
File.exist? f
|
|
119
|
-
end.map { |f| "#{f.to_s.split('/').last} is missing from this package" }]
|
|
120
|
-
else
|
|
121
|
-
["#{Tty.green}found#{Tty.reset}", nil]
|
|
122
|
-
end
|
|
105
|
+
def setup_ok
|
|
106
|
+
hooks_status @facts.setup_files
|
|
123
107
|
end
|
|
124
108
|
|
|
125
|
-
def
|
|
126
|
-
|
|
127
|
-
errors << [validation[0], *send(validation[1])]
|
|
128
|
-
end
|
|
109
|
+
def post_update_hooks_ok
|
|
110
|
+
hooks_status @facts.post(:update)
|
|
129
111
|
end
|
|
130
112
|
|
|
131
|
-
|
|
132
|
-
|
|
113
|
+
# Hooks must exist and be executable; having none is fine.
|
|
114
|
+
def hooks_status(commands)
|
|
115
|
+
return [:skipped, []] if commands.empty?
|
|
116
|
+
|
|
117
|
+
problems = commands.filter_map do |cmd|
|
|
118
|
+
if !File.exist? cmd then "#{cmd} cannot be found"
|
|
119
|
+
elsif !File.executable? cmd then "#{cmd} is not executable"
|
|
120
|
+
end
|
|
121
|
+
end
|
|
122
|
+
problems.empty? ? [:ok, []] : [:error, problems]
|
|
133
123
|
end
|
|
134
124
|
end
|
data/lib/cmd/where.rb
CHANGED
|
@@ -1,16 +1,13 @@
|
|
|
1
1
|
require 'lace/package'
|
|
2
2
|
require 'lace/exceptions'
|
|
3
3
|
|
|
4
|
-
module Lace
|
|
4
|
+
module Lace
|
|
5
|
+
extend self
|
|
6
|
+
|
|
5
7
|
def where
|
|
6
8
|
package_name = ARGV.shift
|
|
7
9
|
raise ResourceNotSpecified unless package_name
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
puts "#{package.path}"
|
|
11
|
-
rescue PackageFactsNotFound => e
|
|
12
|
-
onoe "asd"
|
|
13
|
-
Lace.failed = true
|
|
14
|
-
end
|
|
10
|
+
|
|
11
|
+
puts Package.new(package_name, false).path
|
|
15
12
|
end
|
|
16
13
|
end
|
data/lib/extend/ARGV.rb
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
#Copyright 2009-2014 Max Howell and other contributors.
|
|
1
|
+
# Copyright 2009-2014 Max Howell and other contributors.
|
|
2
2
|
#
|
|
3
|
-
#Redistribution and use in source and binary forms, with or without
|
|
4
|
-
#modification, are permitted provided that the following conditions
|
|
5
|
-
#are met:
|
|
3
|
+
# Redistribution and use in source and binary forms, with or without
|
|
4
|
+
# modification, are permitted provided that the following conditions
|
|
5
|
+
# are met:
|
|
6
6
|
#
|
|
7
7
|
# 1. Redistributions of source code must retain the above copyright
|
|
8
8
|
# notice, this list of conditions and the following disclaimer.
|
|
@@ -10,38 +10,29 @@
|
|
|
10
10
|
# notice, this list of conditions and the following disclaimer in the
|
|
11
11
|
# documentation and/or other materials provided with the distribution.
|
|
12
12
|
#
|
|
13
|
-
#THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
|
14
|
-
#IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
|
15
|
-
#OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
|
16
|
-
#IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
|
17
|
-
#INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
|
18
|
-
#NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
19
|
-
#DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
20
|
-
#THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
21
|
-
#(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
|
22
|
-
#THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
13
|
+
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
|
14
|
+
# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
|
15
|
+
# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
|
16
|
+
# IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
|
17
|
+
# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
|
18
|
+
# NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
19
|
+
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
20
|
+
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
21
|
+
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
|
22
|
+
# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
23
23
|
|
|
24
24
|
module LaceArgvExtension
|
|
25
25
|
def named
|
|
26
|
-
@named ||= reject{|arg| arg[0..0] == '-'}
|
|
26
|
+
@named ||= reject { |arg| arg[0..0] == '-' }
|
|
27
27
|
end
|
|
28
28
|
|
|
29
29
|
def options_only
|
|
30
|
-
select {|arg| arg[0..0] == '-'}
|
|
30
|
+
select { |arg| arg[0..0] == '-' }
|
|
31
31
|
end
|
|
32
32
|
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
end
|
|
37
|
-
|
|
38
|
-
def next
|
|
39
|
-
at @n+1 or raise UsageError
|
|
40
|
-
end
|
|
41
|
-
|
|
42
|
-
def value arg
|
|
43
|
-
arg = find {|o| o =~ /--#{arg}=(.+)/}
|
|
44
|
-
$1 if arg
|
|
33
|
+
def value(arg)
|
|
34
|
+
arg = find { |o| o =~ /--#{arg}=(.+)/ }
|
|
35
|
+
::Regexp.last_match(1) if arg
|
|
45
36
|
end
|
|
46
37
|
|
|
47
38
|
def verbose?
|
|
@@ -64,15 +55,16 @@ module LaceArgvExtension
|
|
|
64
55
|
flag? '--interactive'
|
|
65
56
|
end
|
|
66
57
|
|
|
67
|
-
def flag?
|
|
58
|
+
def flag?(flag)
|
|
68
59
|
options_only.any? do |arg|
|
|
69
|
-
arg == flag || arg[1..1] != '-' && arg.include?(flag[2..2])
|
|
60
|
+
arg == flag || (arg[1..1] != '-' && arg.include?(flag[2..2]))
|
|
70
61
|
end
|
|
71
62
|
end
|
|
72
63
|
|
|
73
64
|
# eg. `foo -ns -i --bar` has three switches, n, s and i
|
|
74
|
-
def switch?
|
|
65
|
+
def switch?(switch_character)
|
|
75
66
|
return false if switch_character.length > 1
|
|
67
|
+
|
|
76
68
|
options_only.any? do |arg|
|
|
77
69
|
arg[1..1] != '-' && arg.include?(switch_character)
|
|
78
70
|
end
|
|
@@ -93,7 +85,7 @@ module LaceArgvExtension
|
|
|
93
85
|
def downcased_unique_named
|
|
94
86
|
# Only lowercase names, not paths or URLs
|
|
95
87
|
@downcased_unique_named ||= named.map do |arg|
|
|
96
|
-
arg.include?(
|
|
88
|
+
arg.include?('/') ? arg : arg.downcase
|
|
97
89
|
end.uniq
|
|
98
90
|
end
|
|
99
91
|
end
|
data/lib/extend/pathname.rb
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
#Copyright 2009-2014 Max Howell and other contributors.
|
|
1
|
+
# Copyright 2009-2014 Max Howell and other contributors.
|
|
2
2
|
#
|
|
3
|
-
#Redistribution and use in source and binary forms, with or without
|
|
4
|
-
#modification, are permitted provided that the following conditions
|
|
5
|
-
#are met:
|
|
3
|
+
# Redistribution and use in source and binary forms, with or without
|
|
4
|
+
# modification, are permitted provided that the following conditions
|
|
5
|
+
# are met:
|
|
6
6
|
#
|
|
7
7
|
# 1. Redistributions of source code must retain the above copyright
|
|
8
8
|
# notice, this list of conditions and the following disclaimer.
|
|
@@ -10,33 +10,32 @@
|
|
|
10
10
|
# notice, this list of conditions and the following disclaimer in the
|
|
11
11
|
# documentation and/or other materials provided with the distribution.
|
|
12
12
|
#
|
|
13
|
-
#THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
|
14
|
-
#IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
|
15
|
-
#OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
|
16
|
-
#IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
|
17
|
-
#INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
|
18
|
-
#NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
19
|
-
#DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
20
|
-
#THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
21
|
-
#(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
|
22
|
-
#THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
13
|
+
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
|
14
|
+
# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
|
15
|
+
# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
|
16
|
+
# IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
|
17
|
+
# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
|
18
|
+
# NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
19
|
+
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
20
|
+
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
21
|
+
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
|
22
|
+
# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
23
23
|
|
|
24
24
|
require 'pathname'
|
|
25
25
|
# we enhance pathname to make our code more readable
|
|
26
26
|
class Pathname
|
|
27
|
-
|
|
28
|
-
def cp dst
|
|
27
|
+
def cp(dst)
|
|
29
28
|
if file?
|
|
30
29
|
FileUtils.cp to_s, dst
|
|
31
30
|
else
|
|
32
31
|
FileUtils.cp_r to_s, dst
|
|
33
32
|
end
|
|
34
|
-
|
|
33
|
+
dst
|
|
35
34
|
end
|
|
36
35
|
|
|
37
36
|
# for filetypes we support, basename without extension
|
|
38
37
|
def stem
|
|
39
|
-
File.basename(
|
|
38
|
+
File.basename(path = to_s, extname(path))
|
|
40
39
|
end
|
|
41
40
|
|
|
42
41
|
# I don't trust the children.length == 0 check particularly, not to mention
|
|
@@ -46,7 +45,7 @@ class Pathname
|
|
|
46
45
|
rmdir
|
|
47
46
|
true
|
|
48
47
|
rescue Errno::ENOTEMPTY
|
|
49
|
-
if (ds_store = self+'.DS_Store').exist? && children.length == 1
|
|
48
|
+
if (ds_store = self + '.DS_Store').exist? && children.length == 1
|
|
50
49
|
ds_store.unlink
|
|
51
50
|
retry
|
|
52
51
|
else
|
|
@@ -56,25 +55,23 @@ class Pathname
|
|
|
56
55
|
false
|
|
57
56
|
end
|
|
58
57
|
|
|
59
|
-
def chmod_R
|
|
58
|
+
def chmod_R(perms)
|
|
60
59
|
require 'fileutils'
|
|
61
60
|
FileUtils.chmod_R perms, to_s
|
|
62
61
|
end
|
|
63
62
|
|
|
64
|
-
if '1.9' <= RUBY_VERSION
|
|
65
|
-
alias_method :to_str, :to_s
|
|
66
|
-
end
|
|
63
|
+
alias to_str to_s if '1.9' <= RUBY_VERSION
|
|
67
64
|
|
|
68
|
-
def cd
|
|
69
|
-
Dir.chdir(self)
|
|
65
|
+
def cd(&block)
|
|
66
|
+
Dir.chdir(self, &block)
|
|
70
67
|
end
|
|
71
68
|
|
|
72
69
|
def subdirs
|
|
73
|
-
children.select{ |child| child.directory? }
|
|
70
|
+
children.select { |child| child.directory? }
|
|
74
71
|
end
|
|
75
72
|
|
|
76
73
|
def resolved_path
|
|
77
|
-
|
|
74
|
+
symlink? ? dirname + readlink : self
|
|
78
75
|
end
|
|
79
76
|
|
|
80
77
|
def resolved_path_exists?
|
|
@@ -83,19 +80,18 @@ class Pathname
|
|
|
83
80
|
# The link target contains NUL bytes
|
|
84
81
|
false
|
|
85
82
|
else
|
|
86
|
-
(dirname+link).exist?
|
|
83
|
+
(dirname + link).exist?
|
|
87
84
|
end
|
|
88
85
|
|
|
89
|
-
def /
|
|
90
|
-
join
|
|
86
|
+
def /(other)
|
|
87
|
+
join other.to_s
|
|
91
88
|
end
|
|
92
89
|
|
|
93
90
|
def as_backup
|
|
94
91
|
Pathname.new File.join(dirname, "#{basename}.lace.bak")
|
|
95
92
|
end
|
|
96
93
|
|
|
97
|
-
def as_dotfile
|
|
98
|
-
Pathname.new File.join(base_folder, ".#{to_path.gsub(subtract,
|
|
94
|
+
def as_dotfile(base_folder, subtract)
|
|
95
|
+
Pathname.new File.join(base_folder, ".#{to_path.gsub(subtract, '')[1..-1]}")
|
|
99
96
|
end
|
|
100
|
-
|
|
101
97
|
end
|
data/lib/lace/exceptions.rb
CHANGED
|
@@ -1,79 +1,110 @@
|
|
|
1
|
-
class UsageError < RuntimeError; end
|
|
2
1
|
class ResourceNotSpecified < ArgumentError; end
|
|
3
2
|
class ErrorDuringExecution < RuntimeError; end
|
|
4
3
|
|
|
5
4
|
class OnlyGitReposCanBeUpdatedError < RuntimeError
|
|
6
5
|
def initialize
|
|
7
|
-
super
|
|
6
|
+
super('Only pkgs installed via git can be updated')
|
|
8
7
|
end
|
|
9
8
|
end
|
|
10
9
|
|
|
11
10
|
class AlreadyActiveError < RuntimeError
|
|
12
11
|
def initialize
|
|
13
|
-
super
|
|
12
|
+
super('Cannot activate an already active package, please deactivate first')
|
|
14
13
|
end
|
|
15
14
|
end
|
|
16
15
|
|
|
17
16
|
class NonActiveFlavorError < RuntimeError
|
|
18
17
|
def initialize
|
|
19
|
-
super
|
|
18
|
+
super('Cannot deactivate package that is not active')
|
|
20
19
|
end
|
|
21
20
|
end
|
|
22
21
|
|
|
23
22
|
class PackageAlreadyInstalled < RuntimeError
|
|
24
|
-
|
|
25
|
-
|
|
23
|
+
attr_reader :location
|
|
24
|
+
|
|
25
|
+
def initialize(location)
|
|
26
|
+
@location = Pathname.new(location)
|
|
27
|
+
super("Package already installed at #{location}")
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
class PkgLaceNotFound < RuntimeError
|
|
32
|
+
def initialize(path)
|
|
33
|
+
super("No such pkg.lace file: #{path}")
|
|
34
|
+
end
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
class InvalidPkgLace < RuntimeError
|
|
38
|
+
def initialize(path, problem)
|
|
39
|
+
super("Invalid pkg.lace #{path}: #{problem}")
|
|
40
|
+
end
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
class InvalidPackageName < RuntimeError
|
|
44
|
+
def initialize(name)
|
|
45
|
+
super("Invalid package name '#{name}': use letters, digits, '.', '_' and '-', starting with a letter or digit")
|
|
26
46
|
end
|
|
27
47
|
end
|
|
28
48
|
|
|
29
49
|
class CannotRemoveActivePackage < RuntimeError
|
|
30
50
|
def initialize
|
|
31
|
-
super
|
|
51
|
+
super('Cannot remove active pkg, deactivate first')
|
|
32
52
|
end
|
|
33
53
|
end
|
|
34
54
|
|
|
35
55
|
class PackageNotInstalled < RuntimeError
|
|
36
|
-
def initialize
|
|
37
|
-
super
|
|
56
|
+
def initialize(name)
|
|
57
|
+
super("Package #{name} is not installed")
|
|
38
58
|
end
|
|
39
59
|
end
|
|
40
60
|
|
|
41
61
|
class FlavorError < RuntimeError; end
|
|
42
62
|
|
|
43
63
|
class FlavorArgumentRequired < FlavorError
|
|
44
|
-
def initialize
|
|
45
|
-
super
|
|
64
|
+
def initialize(available_flavors)
|
|
65
|
+
super(FlavorArgumentMsg % available_flavors.join("\n- "))
|
|
46
66
|
end
|
|
47
67
|
end
|
|
48
68
|
|
|
49
69
|
class PackageFactsNotFound < RuntimeError
|
|
50
|
-
def initialize
|
|
51
|
-
super
|
|
70
|
+
def initialize(path)
|
|
71
|
+
super("No PackageFacts found in #{path}")
|
|
52
72
|
end
|
|
53
73
|
end
|
|
54
74
|
|
|
55
75
|
class PackageFlavorDoesNotExist < FlavorError
|
|
56
|
-
def initialize
|
|
57
|
-
super
|
|
76
|
+
def initialize(which_flavor, _flavors)
|
|
77
|
+
super("Flavor '#{which_flavor}' does not exist")
|
|
58
78
|
end
|
|
59
79
|
end
|
|
60
80
|
|
|
61
81
|
class WouldOverwriteError < RuntimeError
|
|
62
|
-
def initialize
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
82
|
+
def initialize(dest, src)
|
|
83
|
+
hint = src.directory? ? "Use glob pattern in .lace.yml like #{src.basename}/**/*\nor invoke" : 'Invoke'
|
|
84
|
+
super(%(Refusing to overwrite #{dest} with #{src}
|
|
85
|
+
#{hint} lace with `--force` to create backup of #{dest}))
|
|
66
86
|
end
|
|
67
87
|
end
|
|
68
88
|
|
|
69
|
-
class
|
|
70
|
-
def initialize
|
|
71
|
-
super
|
|
89
|
+
class BackupExistsError < RuntimeError
|
|
90
|
+
def initialize(backup)
|
|
91
|
+
super("Cannot back up: #{backup} already exists. Move it away and try again.")
|
|
92
|
+
end
|
|
93
|
+
end
|
|
94
|
+
|
|
95
|
+
class ManifestNotAMapping < RuntimeError
|
|
96
|
+
def initialize(facts_file)
|
|
97
|
+
super("#{facts_file} must hold keys and values, such as config_files:")
|
|
72
98
|
end
|
|
73
99
|
end
|
|
74
100
|
|
|
101
|
+
class ManifestErbError < RuntimeError
|
|
102
|
+
def initialize(fact, exception)
|
|
103
|
+
super("#{exception}\nin #{fact.facts_file}")
|
|
104
|
+
end
|
|
105
|
+
end
|
|
75
106
|
|
|
76
|
-
FlavorArgumentMsg =
|
|
77
|
-
Sorry, this command needs a flavor argument you can choose from the following:
|
|
78
|
-
- %s
|
|
107
|
+
FlavorArgumentMsg = <<~EOS
|
|
108
|
+
Sorry, this command needs a flavor argument you can choose from the following:
|
|
109
|
+
- %s
|
|
79
110
|
EOS
|