Closed vladvlasov256 closed 1 year ago
@vladvlasov256
Thanks for the PR 🙏
Could you fix the failed test?
Hi @mono0926
I believe the test is ok but it's referenced to the actual main branch. So it should be fine after the merge.
If I change the URL:
- let url = try XCTUnwrap(URL(string: "https://raw.githubusercontent.com/mono0926/LicensePlist/master/Tests/LicensePlistTests/Resources/license_plist.yml"))
+ let url = try XCTUnwrap(URL(string: "https://raw.githubusercontent.com/vladvlasov256/LicensePlist/feature/checkout_path/Tests/LicensePlistTests/Resources/license_plist.yml"))
the test becomes green:
The same situation was in #207
@vladvlasov256
Thanks, released 👍 https://github.com/mono0926/LicensePlist/releases/tag/3.24.3
Description
Xcode and
xcodebuild
resolve and check out Swift packages sources before building a project every time it's necessary. Sources include license files as well. ThusLicensePlist
may rely not only on GitHub API but directly on the sources.Motivation
In the sandbox mode, when the tool is used by the Swift package build tool plugin there is no way to use network requests. Using cloned sources is a workaround in this case.
Another example is a CI environment that builds apps with
xcodebuild
. The CI may specify a folder for cloned Swift package sources and use this folder for acknowledgments generation.Implementation
Reading licenses
Packages hold licenses in "LICENSE", "License", "LICENSE.md", or "LICENSE.txt" files. To read them the tool needs two pieces of data:
As a path to cloned sources, the tool uses
--package-sources-path
(or--swift-package-sources-path
) parameter.All possible license file names are also defined as a parameter whose name is
--license-file-names
. To simplify different path extensions let's support asterisks in names, ex.LICENSE.*
.Then if the path is specified
PlistInfo
reads licenses from disk instead of using GitHub API.Name specified
One another feature that accesses GitHub is resolving
nameSpecified
. As suggested above, if the tool knows cloned sources path let's not fetchPackage.resolved
from GitHub but read it from disk.Restriction
Unlike CocoaPods, Swift packages don't provide reach metadata. There are a couple of discussions on the swift forum about that but no proposals yet. Thus there is no simple way to determine the license type.
I was thinking about:
All these approaches involve too much overhead, in my opinion.
AFAIK, license type is required to filter out licenses using the
exclude
feature. So I added a warning that this feature is not supported in combination with--package-sources-path
.Fixes
--package-sources-path
and--license-file-names
,readCheckedOutLicenses()
method toPlistInfo.swift
,readFromDisk()
method toGitHubLicense.swift
,