Skip to content

Commit 893282e

Browse files
authored
Migrate PackageCollections.md to DocC (#8715)
The covers the porting of content for `PackageCollections.md` into our DocC catalog and fixes #8589. The new guide article for `PackageCollections` exists under `Sources/PackageManagerDocs/Documentation.docc/PackageCollections.md` and touches on creating, publishing, signing/protecting, and modifying package collections. Below the overview there is a list of subcommands available on the `swift package-collection` tool with links navigating to the Swift commands documentation. Each of the `PackageCollection` CLI commands have been augmented with supplementary information about how to use the subcommand (if applicable), all of which is taken from the original `/Documentation/PackageCollections.md` markdown file. Some links within these guides either still reference the old links in the original `Documentation/PackageCollections.md` file or are placeholders - both are marked with a `TODO` to update these links once other issues under #8603 are completed and we can replace the links with the appropriate DocC equivalent. Some content in these guides are also taken from `Sources/PackageCollectionsModel/Formats/v1`.
1 parent e2c2f0a commit 893282e

10 files changed

+635
-8
lines changed

Sources/PackageManagerDocs/Documentation.docc/Documentation.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ The Swift Package Manager lets you share your code as a package, depend on and u
3232
- <doc:UsingShellCompletion>
3333
- <doc:SwiftPMAsALibrary>
3434
- <doc:ModuleAliasing>
35+
- <doc:PackageCollections>
3536

3637
<!-- ### Command Plugins -->
3738
<!-- placeholder for content about swift package manager extensions - command plugins -->

Sources/PackageManagerDocs/Documentation.docc/PackageCollections.md

Lines changed: 395 additions & 0 deletions
Large diffs are not rendered by default.

Sources/PackageManagerDocs/Documentation.docc/PackageCollections/PackageCollectionAdd.md

Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,98 @@
66

77
Add a new collection.
88

9+
## Overview
10+
11+
This subcommand adds a package collection hosted on the web (HTTPS required):
12+
13+
```bash
14+
$ swift package-collection add https://www.example.com/packages.json
15+
Added "Sample Package Collection" to your package collections.
16+
```
17+
18+
Or found in the local file system:
19+
20+
```bash
21+
$ swift package-collection add file:///absolute/path/to/packages.json
22+
Added "Sample Package Collection" to your package collections.
23+
```
24+
25+
The optional `order` hint can be used to order collections and may potentially influence ranking in search results:
26+
27+
```bash
28+
$ swift package-collection add https://www.example.com/packages.json [--order N]
29+
Added "Sample Package Collection" to your package collections.
30+
```
31+
32+
### Signed package collections
33+
34+
Package collection publishers may [sign a collection to protect its contents](<doc:PackageCollections#Signing-and-protecting-package-collections>) from being tampered with.
35+
If a collection is signed, SwiftPM will check that the
36+
signature is valid before importing it and return an error if any of these fails:
37+
- The file's contents, signature excluded, must match what was used to generate the signature.
38+
In other words, this checks to see if the collection has been altered since it was signed.
39+
- The signing certificate must meet all the [requirements](<doc:PackageCollections#Requirements-on-signing-certificate>).
40+
41+
```bash
42+
$ swift package-collection add https://www.example.com/bad-packages.json
43+
The collection's signature is invalid. If you would like to continue please rerun command with '--skip-signature-check'.
44+
```
45+
46+
Users may continue adding the collection despite the error or preemptively skip the signature check on a package collection by passing the `--skip-signature-check` flag:
47+
48+
```bash
49+
$ swift package-collection add https://www.example.com/packages.json --skip-signature-check
50+
```
51+
52+
For package collections hosted on the web, publishers may ask SwiftPM to [enforce the signature requirement](<doc:PackageCollections#Protecting-package-collections>). If a package collection is
53+
expected to be signed but it isn't, user will see the following error message:
54+
55+
```bash
56+
$ swift package-collection add https://www.example.com/bad-packages.json
57+
The collection is missing required signature, which means it might have been compromised.
58+
```
59+
60+
Users should NOT add the package collection in this case.
61+
62+
##### Trusted root certificates
63+
64+
Since generating a collection signature requires a certificate, part of the signature check involves validating the certificate and its chain and making sure that the root certificate is trusted.
65+
66+
On Apple platforms, all root certificates that come preinstalled with the OS are automatically trusted. Users may include additional certificates to trust by placing
67+
them in the `~/.swiftpm/config/trust-root-certs` directory.
68+
69+
On non-Apple platforms, there are no trusted root certificates by default other than those shipped with the [certificate-pinning configuration](<doc:PackageCollections#Protecting-package-collections>). Only those
70+
found in `~/.swiftpm/config/trust-root-certs` are trusted. This means that the signature check will always fail unless the `trust-root-certs` directory is set up:
71+
72+
```bash
73+
$ swift package-collection add https://www.example.com/packages.json
74+
The collection's signature cannot be verified due to missing configuration.
75+
```
76+
77+
Users can explicitly specify they trust a publisher and any collections they publish, by obtaining that publisher's root certificate and saving it to `~/.swiftpm/config/trust-root-certs`. The
78+
root certificates must be DER-encoded. Since SwiftPM trusts all certificate chains under a root, depending on what roots are installed, some publishers may already be trusted implicitly and
79+
users don't need to explicitly specify each one.
80+
81+
#### Unsigned package collections
82+
83+
Users will get an error when trying to add an unsigned package collection:
84+
85+
```bash
86+
$ swift package-collection add https://www.example.com/packages.json
87+
The collection is not signed. If you would still like to add it please rerun 'add' with '--trust-unsigned'.
88+
```
89+
90+
To continue user must confirm their trust by passing the `--trust-unsigned` flag:
91+
92+
```bash
93+
$ swift package-collection add https://www.example.com/packages.json --trust-unsigned
94+
```
95+
96+
The `--skip-signature-check` flag has no effects on unsigned collections.
97+
98+
99+
## Usage
100+
9101
```
10102
package-collection add <collection-url> [--order=<order>] [--trust-unsigned] [--skip-signature-check] [--package-path=<package-path>] [--cache-path=<cache-path>] [--config-path=<config-path>] [--security-path=<security-path>] [--scratch-path=<scratch-path>] [--swift-sdks-path=<swift-sdks-path>] [--toolset=<toolset>...] [--pkg-config-path=<pkg-config-path>...] [--enable-dependency-cache|disable-dependency-cache] [--enable-build-manifest-caching|disable-build-manifest-caching] [--manifest-cache=<manifest-cache>] [--enable-experimental-prebuilts|disable-experimental-prebuilts] [--verbose] [--very-verbose|vv] [--quiet] [--color-diagnostics|no-color-diagnostics] [--disable-sandbox] [--netrc] [--enable-netrc|disable-netrc] [--netrc-file=<netrc-file>] [--enable-keychain|disable-keychain] [--resolver-fingerprint-checking=<resolver-fingerprint-checking>] [--resolver-signing-entity-checking=<resolver-signing-entity-checking>] [--enable-signature-validation|disable-signature-validation] [--enable-prefetching|disable-prefetching] [--force-resolved-versions|disable-automatic-resolution|only-use-versions-from-resolved-file] [--skip-update] [--disable-scm-to-registry-transformation] [--use-registry-identity-for-scm] [--replace-scm-with-registry] [--default-registry-url=<default-registry-url>] [--configuration=<configuration>] [--=<Xcc>...] [--=<Xswiftc>...] [--=<Xlinker>...] [--=<Xcxx>...] [--triple=<triple>] [--sdk=<sdk>] [--toolchain=<toolchain>] [--swift-sdk=<swift-sdk>] [--sanitize=<sanitize>...] [--auto-index-store|enable-index-store|disable-index-store] [--enable-parseable-module-interfaces] [--jobs=<jobs>] [--use-integrated-swift-driver] [--explicit-target-dependency-import-check=<explicit-target-dependency-import-check>] [--experimental-explicit-module-build] [--build-system=<build-system>] [--=<debug-info-format>] [--enable-dead-strip|disable-dead-strip] [--disable-local-rpath] [--version] [--help]
11103
```

Sources/PackageManagerDocs/Documentation.docc/PackageCollections/PackageCollectionDescribe.md

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,78 @@
66

77
Get metadata for a collection or a package included in an imported collection.
88

9+
## Overview
10+
11+
This subcommand shows metadata for a collection or a package included in an imported collection. The result can optionally be returned as JSON using `--json` for
12+
integration into other tools.
13+
14+
### Metadata and packages of a collection
15+
16+
`describe` can be used for both collections that have been previously added to the list of the user's configured collections, as well as to preview any other collections.
17+
18+
```bash
19+
$ swift package-collection describe [--json] https://www.example.com/packages.json
20+
Name: Sample Package Collection
21+
Source: https://www.example.com/packages.json
22+
Description: ...
23+
Keywords: best, packages
24+
Created At: 2020-05-30 12:33
25+
Packages:
26+
https://github.com/jpsim/yams
27+
...
28+
```
29+
30+
#### Signed package collections
31+
32+
If a collection is signed, SwiftPM will check that the signature is valid before showing a preview.
33+
34+
```bash
35+
$ swift package-collection describe https://www.example.com/bad-packages.json
36+
The collection's signature is invalid. If you would like to continue please rerun command with '--skip-signature-check'.
37+
```
38+
39+
Users may continue previewing the collection despite the error or preemptively skip the signature check on a package collection by passing the `--skip-signature-check` flag:
40+
41+
```bash
42+
$ swift package-collection describe https://www.example.com/packages.json --skip-signature-check
43+
```
44+
45+
### Metadata of a package
46+
47+
`describe` can also show the metadata of a package included in an imported collection:
48+
49+
```bash
50+
$ swift package-collection describe [--json] https://github.com/jpsim/yams
51+
Description: A sweet and swifty YAML parser built on LibYAML.
52+
Available Versions: 4.0.0, 3.0.0, ...
53+
Stars: 14
54+
Readme: https://github.com/jpsim/Yams/blob/master/README.md
55+
Authors: @norio-nomura, @jpsim
56+
--------------------------------------------------------------
57+
Latest Version: 4.0.0
58+
Package Name: Yams
59+
Modules: Yams, CYaml
60+
Supported Platforms: iOS, macOS, Linux, tvOS, watchOS
61+
Supported Swift Versions: 5.3, 5.2, 5.1, 5.0
62+
License: MIT
63+
```
64+
65+
### Metadata of a package version
66+
67+
User may view additional metadata for a package version by passing `--version`:
68+
69+
```bash
70+
$ swift package-collection describe [--json] --version 4.0.0 https://github.com/jpsim/yams
71+
Package Name: Yams
72+
Version: 4.0.0
73+
Modules: Yams, CYaml
74+
Supported Platforms: iOS, macOS, Linux, tvOS, watchOS
75+
Supported Swift Versions: 5.3, 5.2, 5.1, 5.0
76+
License: MIT
77+
```
78+
79+
## Usage
80+
981
```
1082
package-collection describe [--json] <package-url> [--version=<version>] [--skip-signature-check] [--package-path=<package-path>] [--cache-path=<cache-path>] [--config-path=<config-path>] [--security-path=<security-path>] [--scratch-path=<scratch-path>] [--swift-sdks-path=<swift-sdks-path>] [--toolset=<toolset>...] [--pkg-config-path=<pkg-config-path>...] [--enable-dependency-cache|disable-dependency-cache] [--enable-build-manifest-caching|disable-build-manifest-caching] [--manifest-cache=<manifest-cache>] [--enable-experimental-prebuilts|disable-experimental-prebuilts] [--verbose] [--very-verbose|vv] [--quiet] [--color-diagnostics|no-color-diagnostics] [--disable-sandbox] [--netrc] [--enable-netrc|disable-netrc] [--netrc-file=<netrc-file>] [--enable-keychain|disable-keychain] [--resolver-fingerprint-checking=<resolver-fingerprint-checking>] [--resolver-signing-entity-checking=<resolver-signing-entity-checking>] [--enable-signature-validation|disable-signature-validation] [--enable-prefetching|disable-prefetching] [--force-resolved-versions|disable-automatic-resolution|only-use-versions-from-resolved-file] [--skip-update] [--disable-scm-to-registry-transformation] [--use-registry-identity-for-scm] [--replace-scm-with-registry] [--default-registry-url=<default-registry-url>] [--configuration=<configuration>] [--=<Xcc>...] [--=<Xswiftc>...] [--=<Xlinker>...] [--=<Xcxx>...] [--triple=<triple>] [--sdk=<sdk>] [--toolchain=<toolchain>] [--swift-sdk=<swift-sdk>] [--sanitize=<sanitize>...] [--auto-index-store|enable-index-store|disable-index-store] [--enable-parseable-module-interfaces] [--jobs=<jobs>] [--use-integrated-swift-driver] [--explicit-target-dependency-import-check=<explicit-target-dependency-import-check>] [--experimental-explicit-module-build] [--build-system=<build-system>] [--=<debug-info-format>] [--enable-dead-strip|disable-dead-strip] [--disable-local-rpath] [--version] [--help]
1183
```

Sources/PackageManagerDocs/Documentation.docc/PackageCollections/PackageCollectionList.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,20 @@
66

77
List configured collections.
88

9+
## Overview
10+
11+
This subcommand lists all collections that are configured by the user:
12+
13+
```bash
14+
$ swift package-collection list [--json]
15+
Sample Package Collection - https://example.com/packages.json
16+
...
17+
```
18+
19+
The result can optionally be returned as JSON using `--json` for integration into other tools.
20+
21+
## Usage
22+
923
```
1024
package-collection list [--json] [--package-path=<package-path>] [--cache-path=<cache-path>] [--config-path=<config-path>] [--security-path=<security-path>] [--scratch-path=<scratch-path>] [--swift-sdks-path=<swift-sdks-path>] [--toolset=<toolset>...] [--pkg-config-path=<pkg-config-path>...] [--enable-dependency-cache|disable-dependency-cache] [--enable-build-manifest-caching|disable-build-manifest-caching] [--manifest-cache=<manifest-cache>] [--enable-experimental-prebuilts|disable-experimental-prebuilts] [--verbose] [--very-verbose|vv] [--quiet] [--color-diagnostics|no-color-diagnostics] [--disable-sandbox] [--netrc] [--enable-netrc|disable-netrc] [--netrc-file=<netrc-file>] [--enable-keychain|disable-keychain] [--resolver-fingerprint-checking=<resolver-fingerprint-checking>] [--resolver-signing-entity-checking=<resolver-signing-entity-checking>] [--enable-signature-validation|disable-signature-validation] [--enable-prefetching|disable-prefetching] [--force-resolved-versions|disable-automatic-resolution|only-use-versions-from-resolved-file] [--skip-update] [--disable-scm-to-registry-transformation] [--use-registry-identity-for-scm] [--replace-scm-with-registry] [--default-registry-url=<default-registry-url>] [--configuration=<configuration>] [--=<Xcc>...] [--=<Xswiftc>...] [--=<Xlinker>...] [--=<Xcxx>...] [--triple=<triple>] [--sdk=<sdk>] [--toolchain=<toolchain>] [--swift-sdk=<swift-sdk>] [--sanitize=<sanitize>...] [--auto-index-store|enable-index-store|disable-index-store] [--enable-parseable-module-interfaces] [--jobs=<jobs>] [--use-integrated-swift-driver] [--explicit-target-dependency-import-check=<explicit-target-dependency-import-check>] [--experimental-explicit-module-build] [--build-system=<build-system>] [--=<debug-info-format>] [--enable-dead-strip|disable-dead-strip] [--disable-local-rpath] [--version] [--help]
1125
```

Sources/PackageManagerDocs/Documentation.docc/PackageCollections/PackageCollectionRefresh.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,20 @@
66

77
Refresh configured collections.
88

9+
## Overview
10+
11+
This subcommand refreshes any cached data manually:
12+
13+
```bash
14+
$ swift package-collection refresh
15+
Refreshed 5 configured package collections.
16+
```
17+
18+
SwiftPM will also automatically refresh data under various conditions, but some queries such as search will rely on locally cached data.
19+
20+
21+
## Usage
22+
923
```
1024
package-collection refresh [--package-path=<package-path>] [--cache-path=<cache-path>] [--config-path=<config-path>] [--security-path=<security-path>] [--scratch-path=<scratch-path>] [--swift-sdks-path=<swift-sdks-path>] [--toolset=<toolset>...] [--pkg-config-path=<pkg-config-path>...] [--enable-dependency-cache|disable-dependency-cache] [--enable-build-manifest-caching|disable-build-manifest-caching] [--manifest-cache=<manifest-cache>] [--enable-experimental-prebuilts|disable-experimental-prebuilts] [--verbose] [--very-verbose|vv] [--quiet] [--color-diagnostics|no-color-diagnostics] [--disable-sandbox] [--netrc] [--enable-netrc|disable-netrc] [--netrc-file=<netrc-file>] [--enable-keychain|disable-keychain] [--resolver-fingerprint-checking=<resolver-fingerprint-checking>] [--resolver-signing-entity-checking=<resolver-signing-entity-checking>] [--enable-signature-validation|disable-signature-validation] [--enable-prefetching|disable-prefetching] [--force-resolved-versions|disable-automatic-resolution|only-use-versions-from-resolved-file] [--skip-update] [--disable-scm-to-registry-transformation] [--use-registry-identity-for-scm] [--replace-scm-with-registry] [--default-registry-url=<default-registry-url>] [--configuration=<configuration>] [--=<Xcc>...] [--=<Xswiftc>...] [--=<Xlinker>...] [--=<Xcxx>...] [--triple=<triple>] [--sdk=<sdk>] [--toolchain=<toolchain>] [--swift-sdk=<swift-sdk>] [--sanitize=<sanitize>...] [--auto-index-store|enable-index-store|disable-index-store] [--enable-parseable-module-interfaces] [--jobs=<jobs>] [--use-integrated-swift-driver] [--explicit-target-dependency-import-check=<explicit-target-dependency-import-check>] [--experimental-explicit-module-build] [--build-system=<build-system>] [--=<debug-info-format>] [--enable-dead-strip|disable-dead-strip] [--disable-local-rpath] [--version] [--help]
1125
```

Sources/PackageManagerDocs/Documentation.docc/PackageCollections/PackageCollectionRemove.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,17 @@
66

77
Remove a configured collection.
88

9+
## Overview
10+
11+
This subcommand removes a collection from the user's list of configured collections:
12+
13+
```bash
14+
$ swift package-collection remove https://www.example.com/packages.json
15+
Removed "Sample Package Collection" from your package collections.
16+
```
17+
18+
## Usage
19+
920
```
1021
package-collection remove <collection-url> [--package-path=<package-path>] [--cache-path=<cache-path>] [--config-path=<config-path>] [--security-path=<security-path>] [--scratch-path=<scratch-path>] [--swift-sdks-path=<swift-sdks-path>] [--toolset=<toolset>...] [--pkg-config-path=<pkg-config-path>...] [--enable-dependency-cache|disable-dependency-cache] [--enable-build-manifest-caching|disable-build-manifest-caching] [--manifest-cache=<manifest-cache>] [--enable-experimental-prebuilts|disable-experimental-prebuilts] [--verbose] [--very-verbose|vv] [--quiet] [--color-diagnostics|no-color-diagnostics] [--disable-sandbox] [--netrc] [--enable-netrc|disable-netrc] [--netrc-file=<netrc-file>] [--enable-keychain|disable-keychain] [--resolver-fingerprint-checking=<resolver-fingerprint-checking>] [--resolver-signing-entity-checking=<resolver-signing-entity-checking>] [--enable-signature-validation|disable-signature-validation] [--enable-prefetching|disable-prefetching] [--force-resolved-versions|disable-automatic-resolution|only-use-versions-from-resolved-file] [--skip-update] [--disable-scm-to-registry-transformation] [--use-registry-identity-for-scm] [--replace-scm-with-registry] [--default-registry-url=<default-registry-url>] [--configuration=<configuration>] [--=<Xcc>...] [--=<Xswiftc>...] [--=<Xlinker>...] [--=<Xcxx>...] [--triple=<triple>] [--sdk=<sdk>] [--toolchain=<toolchain>] [--swift-sdk=<swift-sdk>] [--sanitize=<sanitize>...] [--auto-index-store|enable-index-store|disable-index-store] [--enable-parseable-module-interfaces] [--jobs=<jobs>] [--use-integrated-swift-driver] [--explicit-target-dependency-import-check=<explicit-target-dependency-import-check>] [--experimental-explicit-module-build] [--build-system=<build-system>] [--=<debug-info-format>] [--enable-dead-strip|disable-dead-strip] [--disable-local-rpath] [--version] [--help]
1122
```

0 commit comments

Comments
 (0)