-
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #125 from savetheclocktower/expose-services
Display information about consumed/provided services
- Loading branch information
Showing
11 changed files
with
172 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<% | ||
const TYPE_VALUES = new Set(['provided', 'consumed']); | ||
let serviceSpecified = locals.serviceType && TYPE_VALUES.has(locals.serviceName); | ||
let serviceTypeVerb = locals.serviceType === 'provided' ? 'provide' : 'consume'; | ||
%> | ||
|
||
<% if (serviceSpecified) { %> | ||
<div class="text-center mt-4 mb-4"> | ||
<p> | ||
Displaying all packages which <%= serviceTypeVerb %> the <strong><%= locals.serviceName %></strong> service. | ||
</p> | ||
</div> | ||
<% } %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
<% if (pack.consumedServices || pack.providedServices) { %> | ||
<% | ||
function urlForPackageSearch (serviceName, serviceType) { | ||
return `/packages?serviceType=${serviceType}&service=${serviceName}`; | ||
} | ||
function aggregateServices(services) { | ||
let aggregated = new Map(); | ||
for (let name in services) { | ||
let versions = Object.keys(services[name].versions); | ||
aggregated.set(name, versions); | ||
} | ||
return aggregated; | ||
} | ||
let { consumedServices, providedServices } = pack; | ||
let consumed = aggregateServices(consumedServices); | ||
let provided = aggregateServices(providedServices); | ||
%> | ||
<div class="service-listing my-4 mr-0 lg:ml-4 border p-4 rounded text-sm overflow-hidden"> | ||
<% if (provided.size > 0) { %> | ||
<div class="service-listing-provided mb-3"> | ||
<p class="italic mb-1">This package <strong>provides</strong> the following services:</p> | ||
<ul> | ||
<% for (let [name, versions] of provided) { %> | ||
<li class="max-md:inline-block"> | ||
<a class="text-xs font-semibold underline decoration-gray-400 decoration-1 mr-1" href="<%- urlForPackageSearch(name, 'consumed') %>" title="Versions: <%- versions.join(', ') %>"><code><%- name %></code></a> | ||
</li> | ||
<% } %> | ||
</ul> | ||
</div> | ||
<% } %> | ||
<% if (consumed.size > 0) { %> | ||
<div class="service-listing-consumed"> | ||
<p class="italic mb-1">This package <strong>consumes</strong> the following services:</p> | ||
<ul style="margin: 0;"> | ||
<% for (let [name, versions] of consumed) { %> | ||
<li class="max-md:inline-block"> | ||
<a class="text-xs font-semibold underline decoration-gray-400 decoration-1 mr-1" href="<%- urlForPackageSearch(name, 'provided') %>" title="Versions: <%- versions.join(', ') %>"><code><%- name %></code></a> | ||
</li> | ||
<% } %> | ||
</ul> | ||
</div> | ||
<% } %> | ||
</div> | ||
<% } %> |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters