Class: LicenseFinder::Spm
Defined Under Namespace
Classes: SpmError
Instance Method Summary
collapse
#active?, #command_exists?, #current_packages_with_relations, #detected_package_path, id, #initialize, #installed?, #prepare, #project_root?, takes_priority_over
Instance Method Details
#current_packages ⇒ Object
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
|
# File 'lib/license_finder/package_managers/spm.rb', line 9
def current_packages
unless File.exist?(workspace_state_path)
raise SpmError, 'No checked-out SPM packages found.
Please install your dependencies first.'
end
workspace_state = JSON.parse(IO.read(workspace_state_path))
workspace_state['object']['dependencies'].map do |dependency|
package_ref = dependency['packageRef']
checkout_state = dependency['state']['checkoutState']
subpath = dependency['subpath']
package_name = package_ref['name']
package_version = checkout_state['version'] || checkout_state['revision']
homepage = package_ref['path']
SpmPackage.new(
package_name,
package_version,
license_text(subpath),
logger: logger,
install_path: project_checkout(subpath),
homepage: homepage
)
end
end
|
#package_management_command ⇒ Object
36
37
38
|
# File 'lib/license_finder/package_managers/spm.rb', line 36
def package_management_command
LicenseFinder::Platform.darwin? ? 'xcodebuild' : 'swift'
end
|
#possible_package_paths ⇒ Object
44
45
46
|
# File 'lib/license_finder/package_managers/spm.rb', line 44
def possible_package_paths
[workspace_state_path]
end
|
#prepare_command ⇒ Object
40
41
42
|
# File 'lib/license_finder/package_managers/spm.rb', line 40
def prepare_command
LicenseFinder::Platform.darwin? ? 'xcodebuild -resolvePackageDependencies' : 'swift package resolve'
end
|