diff --git a/FrontEnd/scripts/controllers/use_this_package_panel_controller.js b/FrontEnd/scripts/controllers/use_this_package_panel_controller.js index b6acb98e2..ca677e3bc 100644 --- a/FrontEnd/scripts/controllers/use_this_package_panel_controller.js +++ b/FrontEnd/scripts/controllers/use_this_package_panel_controller.js @@ -26,6 +26,8 @@ export class UseThisPackagePanelController extends Controller { const optionElement = selectElement.options[selectElement.selectedIndex] const packageName = optionElement.dataset.package const productName = optionElement.dataset.product - this.snippetTarget.value = `.product(name: "${productName}", package: "${packageName}")` + const type = optionElement.dataset.type + const prefix = type == 'plugin' ? '.plugin' : '.product' + this.snippetTarget.value = `${prefix}(name: "${productName}", package: "${packageName}")` } } diff --git a/Sources/App/Controllers/API/API+PackageController+GetRoute+Model.swift b/Sources/App/Controllers/API/API+PackageController+GetRoute+Model.swift index 7d1f3db11..211e5fb17 100644 --- a/Sources/App/Controllers/API/API+PackageController+GetRoute+Model.swift +++ b/Sources/App/Controllers/API/API+PackageController+GetRoute+Model.swift @@ -230,7 +230,7 @@ extension API.PackageController.GetRoute.Model { self.type = type } - enum ProductType: Codable, Equatable { + enum ProductType: String, Codable, Equatable { case library case executable case plugin diff --git a/Sources/App/Views/PackageController/GetRoute.Model+ext.swift b/Sources/App/Views/PackageController/GetRoute.Model+ext.swift index 0d5603801..d4e77d1ef 100644 --- a/Sources/App/Views/PackageController/GetRoute.Model+ext.swift +++ b/Sources/App/Views/PackageController/GetRoute.Model+ext.swift @@ -415,10 +415,12 @@ extension API.PackageController.GetRoute.Model { .data(named: "action", value: "input->use-this-package-panel#updateProductSnippet"), .attribute(named: "name", value: "products"), .id("products"), - .forEach(products, { product in + // Filter out products of type `executable` until we add support for them. + .forEach(products.filter({ $0.type != .executable }), { product in .option( .data(named: "package", value: package), .data(named: "product", value: product.name), + .data(named: "type", value: product.type.rawValue), .value(product.name), .label(product.name) ) diff --git a/Tests/AppTests/__Snapshots__/WebpageSnapshotTests/test_PackageShowView.1.html b/Tests/AppTests/__Snapshots__/WebpageSnapshotTests/test_PackageShowView.1.html index a4bc91a67..acd51447a 100644 --- a/Tests/AppTests/__Snapshots__/WebpageSnapshotTests/test_PackageShowView.1.html +++ b/Tests/AppTests/__Snapshots__/WebpageSnapshotTests/test_PackageShowView.1.html @@ -134,10 +134,9 @@

When working with a Swift Package Manager manifest:

diff --git a/Tests/AppTests/__Snapshots__/WebpageSnapshotTests/test_PackageShowView_app_store_incompatible_license.1.html b/Tests/AppTests/__Snapshots__/WebpageSnapshotTests/test_PackageShowView_app_store_incompatible_license.1.html index 03d9478ad..7160ef77c 100644 --- a/Tests/AppTests/__Snapshots__/WebpageSnapshotTests/test_PackageShowView_app_store_incompatible_license.1.html +++ b/Tests/AppTests/__Snapshots__/WebpageSnapshotTests/test_PackageShowView_app_store_incompatible_license.1.html @@ -134,10 +134,9 @@

When working with a Swift Package Manager manifest:

diff --git a/Tests/AppTests/__Snapshots__/WebpageSnapshotTests/test_PackageShowView_binary_targets.1.html b/Tests/AppTests/__Snapshots__/WebpageSnapshotTests/test_PackageShowView_binary_targets.1.html index 9e40b2f62..bf4b8964b 100644 --- a/Tests/AppTests/__Snapshots__/WebpageSnapshotTests/test_PackageShowView_binary_targets.1.html +++ b/Tests/AppTests/__Snapshots__/WebpageSnapshotTests/test_PackageShowView_binary_targets.1.html @@ -134,10 +134,9 @@

When working with a Swift Package Manager manifest:

diff --git a/Tests/AppTests/__Snapshots__/WebpageSnapshotTests/test_PackageShowView_canonicalURL_noImageSnapshots.1.html b/Tests/AppTests/__Snapshots__/WebpageSnapshotTests/test_PackageShowView_canonicalURL_noImageSnapshots.1.html index 9b21f42d1..fef533860 100644 --- a/Tests/AppTests/__Snapshots__/WebpageSnapshotTests/test_PackageShowView_canonicalURL_noImageSnapshots.1.html +++ b/Tests/AppTests/__Snapshots__/WebpageSnapshotTests/test_PackageShowView_canonicalURL_noImageSnapshots.1.html @@ -134,10 +134,9 @@

When working with a Swift Package Manager manifest:

diff --git a/Tests/AppTests/__Snapshots__/WebpageSnapshotTests/test_PackageShowView_emoji_summary.1.html b/Tests/AppTests/__Snapshots__/WebpageSnapshotTests/test_PackageShowView_emoji_summary.1.html index bd301b418..1c398fb5f 100644 --- a/Tests/AppTests/__Snapshots__/WebpageSnapshotTests/test_PackageShowView_emoji_summary.1.html +++ b/Tests/AppTests/__Snapshots__/WebpageSnapshotTests/test_PackageShowView_emoji_summary.1.html @@ -134,10 +134,9 @@

When working with a Swift Package Manager manifest:

diff --git a/Tests/AppTests/__Snapshots__/WebpageSnapshotTests/test_PackageShowView_few_keywords.1.html b/Tests/AppTests/__Snapshots__/WebpageSnapshotTests/test_PackageShowView_few_keywords.1.html index 5568ea300..08bb9f1a0 100644 --- a/Tests/AppTests/__Snapshots__/WebpageSnapshotTests/test_PackageShowView_few_keywords.1.html +++ b/Tests/AppTests/__Snapshots__/WebpageSnapshotTests/test_PackageShowView_few_keywords.1.html @@ -134,10 +134,9 @@

When working with a Swift Package Manager manifest:

diff --git a/Tests/AppTests/__Snapshots__/WebpageSnapshotTests/test_PackageShowView_many_keywords.1.html b/Tests/AppTests/__Snapshots__/WebpageSnapshotTests/test_PackageShowView_many_keywords.1.html index 3000136a4..0e92661e9 100644 --- a/Tests/AppTests/__Snapshots__/WebpageSnapshotTests/test_PackageShowView_many_keywords.1.html +++ b/Tests/AppTests/__Snapshots__/WebpageSnapshotTests/test_PackageShowView_many_keywords.1.html @@ -134,10 +134,9 @@

When working with a Swift Package Manager manifest:

diff --git a/Tests/AppTests/__Snapshots__/WebpageSnapshotTests/test_PackageShowView_no_authors_activity.1.html b/Tests/AppTests/__Snapshots__/WebpageSnapshotTests/test_PackageShowView_no_authors_activity.1.html index 8cc10270e..9cd6319d2 100644 --- a/Tests/AppTests/__Snapshots__/WebpageSnapshotTests/test_PackageShowView_no_authors_activity.1.html +++ b/Tests/AppTests/__Snapshots__/WebpageSnapshotTests/test_PackageShowView_no_authors_activity.1.html @@ -134,10 +134,9 @@

When working with a Swift Package Manager manifest:

diff --git a/Tests/AppTests/__Snapshots__/WebpageSnapshotTests/test_PackageShowView_no_builds.1.html b/Tests/AppTests/__Snapshots__/WebpageSnapshotTests/test_PackageShowView_no_builds.1.html index 4a701f7d7..60ba39935 100644 --- a/Tests/AppTests/__Snapshots__/WebpageSnapshotTests/test_PackageShowView_no_builds.1.html +++ b/Tests/AppTests/__Snapshots__/WebpageSnapshotTests/test_PackageShowView_no_builds.1.html @@ -134,10 +134,9 @@

When working with a Swift Package Manager manifest:

diff --git a/Tests/AppTests/__Snapshots__/WebpageSnapshotTests/test_PackageShowView_no_license.1.html b/Tests/AppTests/__Snapshots__/WebpageSnapshotTests/test_PackageShowView_no_license.1.html index d4d037ebc..479835fa2 100644 --- a/Tests/AppTests/__Snapshots__/WebpageSnapshotTests/test_PackageShowView_no_license.1.html +++ b/Tests/AppTests/__Snapshots__/WebpageSnapshotTests/test_PackageShowView_no_license.1.html @@ -134,10 +134,9 @@

When working with a Swift Package Manager manifest:

diff --git a/Tests/AppTests/__Snapshots__/WebpageSnapshotTests/test_PackageShowView_open_source_license.1.html b/Tests/AppTests/__Snapshots__/WebpageSnapshotTests/test_PackageShowView_open_source_license.1.html index 9ebe6b129..fea7b2e54 100644 --- a/Tests/AppTests/__Snapshots__/WebpageSnapshotTests/test_PackageShowView_open_source_license.1.html +++ b/Tests/AppTests/__Snapshots__/WebpageSnapshotTests/test_PackageShowView_open_source_license.1.html @@ -134,10 +134,9 @@

When working with a Swift Package Manager manifest:

diff --git a/Tests/AppTests/__Snapshots__/WebpageSnapshotTests/test_PackageShowView_other_license.1.html b/Tests/AppTests/__Snapshots__/WebpageSnapshotTests/test_PackageShowView_other_license.1.html index 019243243..36a831414 100644 --- a/Tests/AppTests/__Snapshots__/WebpageSnapshotTests/test_PackageShowView_other_license.1.html +++ b/Tests/AppTests/__Snapshots__/WebpageSnapshotTests/test_PackageShowView_other_license.1.html @@ -134,10 +134,9 @@

When working with a Swift Package Manager manifest:

diff --git a/Tests/AppTests/__Snapshots__/WebpageSnapshotTests/test_PackageShowView_single_row_tables.1.html b/Tests/AppTests/__Snapshots__/WebpageSnapshotTests/test_PackageShowView_single_row_tables.1.html index 676039fb0..f307df133 100644 --- a/Tests/AppTests/__Snapshots__/WebpageSnapshotTests/test_PackageShowView_single_row_tables.1.html +++ b/Tests/AppTests/__Snapshots__/WebpageSnapshotTests/test_PackageShowView_single_row_tables.1.html @@ -134,10 +134,9 @@

When working with a Swift Package Manager manifest:

diff --git a/Tests/AppTests/__Snapshots__/WebpageSnapshotTests/test_PackageShowView_withPackageFundingLinks.1.html b/Tests/AppTests/__Snapshots__/WebpageSnapshotTests/test_PackageShowView_withPackageFundingLinks.1.html index 19873f1fd..343194699 100644 --- a/Tests/AppTests/__Snapshots__/WebpageSnapshotTests/test_PackageShowView_withPackageFundingLinks.1.html +++ b/Tests/AppTests/__Snapshots__/WebpageSnapshotTests/test_PackageShowView_withPackageFundingLinks.1.html @@ -134,10 +134,9 @@

When working with a Swift Package Manager manifest:

diff --git a/Tests/AppTests/__Snapshots__/WebpageSnapshotTests/test_PackageShowView_with_documentation_link.1.html b/Tests/AppTests/__Snapshots__/WebpageSnapshotTests/test_PackageShowView_with_documentation_link.1.html index 8683b542f..72f51add3 100644 --- a/Tests/AppTests/__Snapshots__/WebpageSnapshotTests/test_PackageShowView_with_documentation_link.1.html +++ b/Tests/AppTests/__Snapshots__/WebpageSnapshotTests/test_PackageShowView_with_documentation_link.1.html @@ -134,10 +134,9 @@

When working with a Swift Package Manager manifest: