Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions scripts/build-jsonld.ts
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ type Plugin = {
versionSource: string
hasPackages: boolean
addCommand: string
installCommand: string
}

const DEFAULT_OSES = ['Linux', 'macOS', 'Windows']
Expand Down Expand Up @@ -131,6 +132,7 @@ const toPlugin = (baseUrl: string) => (file: string, raw: Raw): Plugin => {
versionSource: detectVersionSource(resolveBlock),
hasPackages: isObject(raw.packages),
addCommand: `proto plugin add ${id} "${fileUrl}"`,
installCommand: `proto install --pin -c local ${id} latest`,
}
}

Expand All @@ -152,6 +154,7 @@ const toPluginEntry = (repoUrl: string, schemaUrl: string) => (plugin: Plugin) =
versionSource: plugin.versionSource,
hasPackages: plugin.hasPackages,
addCommand: plugin.addCommand,
installCommand: plugin.installCommand,
})

const toCatalog = (
Expand Down
32 changes: 26 additions & 6 deletions web/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,12 @@
display: none;
}

.cmd-rows {
display: flex;
flex-direction: column;
gap: 0.375rem;
}

.cmd-row {
display: flex;
align-items: center;
Expand Down Expand Up @@ -427,21 +433,33 @@ <h1>
return host
}

const makeCopyButton = plugin => {
const makeCopyButton = (cmd, label) => {
const btn = makeEl('button', 'copy-btn')
btn.type = 'button'
btn.dataset.cmd = plugin.addCommand ?? ''
btn.setAttribute('aria-label', `Copy command for ${plugin.identifier ?? ''}`)
btn.dataset.cmd = cmd
btn.setAttribute('aria-label', label)
setIcon(btn, iconCopyTpl)
return btn
}

const makeCmdRow = plugin => {
const makeCmdRow = (cmd, ariaLabel) => {
const row = makeEl('div', 'cmd-row')
row.append(makeEl('code', '', plugin.addCommand ?? ''), makeCopyButton(plugin))
row.append(makeEl('code', '', cmd), makeCopyButton(cmd, ariaLabel))
return row
}

const makeAddRow = plugin =>
makeCmdRow(
plugin.addCommand ?? '',
`Copy add command for ${plugin.identifier ?? ''}`,
)

const makeInstallRow = plugin =>
makeCmdRow(
plugin.installCommand ?? '',
`Copy install command for ${plugin.identifier ?? ''}`,
)

const makePluginFileLink = plugin => {
const link = makeEl('a', 'plugin-file-link', pluginFileName(plugin))
link.href = pluginFileUrl(plugin)
Expand All @@ -460,10 +478,12 @@ <h1>

const buildCard = plugin => {
const card = makeEl('article', 'card')
const cmdRows = makeEl('div', 'cmd-rows')
cmdRows.append(makeAddRow(plugin), makeInstallRow(plugin))
card.append(
makeHead(plugin),
makeEl('p', 'card-desc', plugin.description ?? ''),
makeCmdRow(plugin),
cmdRows,
makePluginFileLink(plugin),
)
return card
Expand Down
Loading