librarian 0.0.20 → 0.0.21
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/.travis.yml +1 -0
- data/CHANGELOG.md +16 -0
- data/README.md +25 -18
- data/features/chef/cli/show.feature +65 -0
- data/features/support/env.rb +5 -1
- data/lib/librarian/action/clean.rb +0 -12
- data/lib/librarian/action/install.rb +1 -1
- data/lib/librarian/chef/manifest_reader.rb +47 -0
- data/lib/librarian/chef/source/local.rb +51 -3
- data/lib/librarian/chef/source/site.rb +318 -109
- data/lib/librarian/cli.rb +24 -9
- data/lib/librarian/cli/manifest_presenter.rb +79 -0
- data/lib/librarian/dependency.rb +2 -2
- data/lib/librarian/dsl/target.rb +1 -1
- data/lib/librarian/environment.rb +4 -3
- data/lib/librarian/manifest.rb +38 -24
- data/lib/librarian/manifest_set.rb +36 -20
- data/lib/librarian/mock/source/mock.rb +33 -21
- data/lib/librarian/resolution.rb +11 -0
- data/lib/librarian/source/git.rb +14 -2
- data/lib/librarian/source/git/repository.rb +79 -58
- data/lib/librarian/source/local.rb +19 -5
- data/lib/librarian/source/path.rb +13 -1
- data/lib/librarian/specfile.rb +1 -1
- data/lib/librarian/version.rb +1 -1
- data/librarian.gemspec +1 -1
- data/spec/unit/action/clean_spec.rb +0 -31
- data/spec/unit/action/install_spec.rb +7 -3
- data/spec/unit/dsl_spec.rb +14 -0
- data/spec/unit/manifest_set_spec.rb +202 -0
- data/spec/unit/resolver_spec.rb +36 -16
- data/spec/unit/source/git_spec.rb +29 -0
- metadata +28 -25
- data/lib/librarian/chef/manifest.rb +0 -43
- data/lib/librarian/chef/source/local/manifest.rb +0 -82
- data/lib/librarian/chef/source/site/manifest.rb +0 -94
@@ -1,43 +0,0 @@
|
|
1
|
-
require 'json'
|
2
|
-
require 'yaml'
|
3
|
-
|
4
|
-
require 'librarian/manifest'
|
5
|
-
|
6
|
-
module Librarian
|
7
|
-
module Chef
|
8
|
-
class Manifest < Manifest
|
9
|
-
|
10
|
-
module Helpers
|
11
|
-
|
12
|
-
MANIFESTS = %w(metadata.json metadata.yml metadata.yaml metadata.rb)
|
13
|
-
|
14
|
-
def manifest_path(path)
|
15
|
-
MANIFESTS.map{|s| path.join(s)}.find{|s| s.exist?}
|
16
|
-
end
|
17
|
-
|
18
|
-
def read_manifest(name, manifest_path)
|
19
|
-
case manifest_path.extname
|
20
|
-
when ".json" then JSON.parse(manifest_path.read)
|
21
|
-
when ".yml", ".yaml" then YAML.load(manifest_path.read)
|
22
|
-
when ".rb" then compile_manifest(name, manifest_path.dirname)
|
23
|
-
end
|
24
|
-
end
|
25
|
-
|
26
|
-
def compile_manifest(name, path)
|
27
|
-
# Inefficient, if there are many cookbooks with uncompiled metadata.
|
28
|
-
require 'chef/json_compat'
|
29
|
-
require 'chef/cookbook/metadata'
|
30
|
-
md = ::Chef::Cookbook::Metadata.new
|
31
|
-
md.name(name)
|
32
|
-
md.from_file(path.join('metadata.rb').to_s)
|
33
|
-
JSON.parse(::Chef::JSONCompat.to_json_pretty(md))
|
34
|
-
end
|
35
|
-
|
36
|
-
end
|
37
|
-
|
38
|
-
include Helpers
|
39
|
-
extend Helpers
|
40
|
-
|
41
|
-
end
|
42
|
-
end
|
43
|
-
end
|
@@ -1,82 +0,0 @@
|
|
1
|
-
require 'fileutils'
|
2
|
-
require 'pathname'
|
3
|
-
|
4
|
-
require 'librarian/chef/manifest'
|
5
|
-
|
6
|
-
module Librarian
|
7
|
-
module Chef
|
8
|
-
module Source
|
9
|
-
module Local
|
10
|
-
class Manifest < Manifest
|
11
|
-
|
12
|
-
class << self
|
13
|
-
|
14
|
-
def create(source, dependency, path)
|
15
|
-
new(source, dependency.name, path)
|
16
|
-
end
|
17
|
-
|
18
|
-
def manifest?(dependency, path)
|
19
|
-
path = Pathname.new(path)
|
20
|
-
!!manifest_path(path)
|
21
|
-
end
|
22
|
-
|
23
|
-
def check_manifest(dependency, manifest_path)
|
24
|
-
manifest = read_manifest(dependency.name, manifest_path)
|
25
|
-
manifest["name"] == dependency.name
|
26
|
-
end
|
27
|
-
|
28
|
-
end
|
29
|
-
|
30
|
-
attr_reader :path
|
31
|
-
|
32
|
-
def initialize(source, name, path)
|
33
|
-
super(source, name)
|
34
|
-
@path = Pathname.new(path)
|
35
|
-
@found_path = nil
|
36
|
-
end
|
37
|
-
|
38
|
-
def found_path
|
39
|
-
@found_path ||= source.manifest_search_paths(self).find{|p| self.class.manifest?(self, p)}
|
40
|
-
end
|
41
|
-
|
42
|
-
def manifest
|
43
|
-
@manifest ||= fetch_manifest!
|
44
|
-
end
|
45
|
-
|
46
|
-
def fetch_manifest!
|
47
|
-
expect_manifest
|
48
|
-
|
49
|
-
read_manifest(name, manifest_path(found_path))
|
50
|
-
end
|
51
|
-
|
52
|
-
def fetch_version!
|
53
|
-
manifest['version']
|
54
|
-
end
|
55
|
-
|
56
|
-
def fetch_dependencies!
|
57
|
-
manifest['dependencies']
|
58
|
-
end
|
59
|
-
|
60
|
-
def install!
|
61
|
-
debug { "Installing #{name}-#{version}" }
|
62
|
-
install_path = environment.install_path.join(name)
|
63
|
-
if install_path.exist?
|
64
|
-
debug { "Deleting #{relative_path_to(install_path)}" }
|
65
|
-
install_path.rmtree
|
66
|
-
end
|
67
|
-
debug { "Copying #{relative_path_to(found_path)} to #{relative_path_to(install_path)}" }
|
68
|
-
FileUtils.cp_r(found_path, install_path)
|
69
|
-
end
|
70
|
-
|
71
|
-
private
|
72
|
-
|
73
|
-
def expect_manifest
|
74
|
-
return if found_path && manifest_path(found_path)
|
75
|
-
raise Error, "No metadata file found for #{name} from #{source}! If this should be a cookbook, you might consider contributing a metadata file upstream or forking the cookbook to add your own metadata file."
|
76
|
-
end
|
77
|
-
|
78
|
-
end
|
79
|
-
end
|
80
|
-
end
|
81
|
-
end
|
82
|
-
end
|
@@ -1,94 +0,0 @@
|
|
1
|
-
require "fileutils"
|
2
|
-
|
3
|
-
require "json"
|
4
|
-
|
5
|
-
require "librarian/dependency"
|
6
|
-
require 'librarian/chef/manifest'
|
7
|
-
|
8
|
-
module Librarian
|
9
|
-
module Chef
|
10
|
-
module Source
|
11
|
-
class Site
|
12
|
-
class Manifest < Manifest
|
13
|
-
|
14
|
-
attr_reader :version_uri
|
15
|
-
attr_reader :install_path
|
16
|
-
|
17
|
-
def initialize(source, name, version_uri = nil)
|
18
|
-
super(source, name)
|
19
|
-
@version_uri = version_uri
|
20
|
-
|
21
|
-
@cache_path = nil
|
22
|
-
@metadata_cache_path = nil
|
23
|
-
@package_cache_path = nil
|
24
|
-
@install_path = environment.install_path.join(name)
|
25
|
-
|
26
|
-
@version_metadata = nil
|
27
|
-
@version_manifest = nil
|
28
|
-
end
|
29
|
-
|
30
|
-
def fetch_version!
|
31
|
-
version_metadata['version']
|
32
|
-
end
|
33
|
-
|
34
|
-
def fetch_dependencies!
|
35
|
-
version_manifest['dependencies'].map{|k, v| Dependency.new(k, v, nil)}
|
36
|
-
end
|
37
|
-
|
38
|
-
def version_uri
|
39
|
-
@version_uri ||= begin
|
40
|
-
source.cache!([self])
|
41
|
-
source.manifests(self).find{|m| m.version == version}.version_uri
|
42
|
-
end
|
43
|
-
end
|
44
|
-
|
45
|
-
def version_uri=(version_uri)
|
46
|
-
@version_uri = version_uri
|
47
|
-
end
|
48
|
-
|
49
|
-
def cache_path
|
50
|
-
@cache_path ||= source.version_cache_path(self, version_uri)
|
51
|
-
end
|
52
|
-
def metadata_cache_path
|
53
|
-
@metadata_cache_path ||= cache_path.join('version.json')
|
54
|
-
end
|
55
|
-
def package_cache_path
|
56
|
-
@package_cache_path ||= cache_path.join('package')
|
57
|
-
end
|
58
|
-
|
59
|
-
def version_metadata
|
60
|
-
@version_metadata ||= fetch_version_metadata!
|
61
|
-
end
|
62
|
-
|
63
|
-
def fetch_version_metadata!
|
64
|
-
source.cache_version_metadata!(self, version_uri)
|
65
|
-
JSON.parse(metadata_cache_path.read)
|
66
|
-
end
|
67
|
-
|
68
|
-
def version_manifest
|
69
|
-
@version_manifest ||= fetch_version_manifest!
|
70
|
-
end
|
71
|
-
|
72
|
-
def fetch_version_manifest!
|
73
|
-
source.cache_version_package!(self, version_uri, version_metadata['file'])
|
74
|
-
manifest_path = manifest_path(package_cache_path)
|
75
|
-
read_manifest(name, manifest_path)
|
76
|
-
end
|
77
|
-
|
78
|
-
def install!
|
79
|
-
debug { "Installing #{self}" }
|
80
|
-
version_manifest # make sure it's cached
|
81
|
-
if install_path.exist?
|
82
|
-
debug { "Deleting #{relative_path_to(install_path)}" }
|
83
|
-
install_path.rmtree
|
84
|
-
end
|
85
|
-
package_cache_path = source.version_package_cache_path(self, version_uri)
|
86
|
-
debug { "Copying #{relative_path_to(package_cache_path)} to #{relative_path_to(install_path)}" }
|
87
|
-
FileUtils.cp_r(package_cache_path, install_path)
|
88
|
-
end
|
89
|
-
|
90
|
-
end
|
91
|
-
end
|
92
|
-
end
|
93
|
-
end
|
94
|
-
end
|