Skip to content

Commit 76fd562

Browse files
committed
feat: Added completions for ollama, pnpm and snap
1 parent f1a4d3c commit 76fd562

4 files changed

Lines changed: 66 additions & 24 deletions

File tree

completions-cron/src/__generated__/completions-index.ts

Lines changed: 30 additions & 24 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
export default async function loadNvmNodeVersions(): Promise<string[]> {
2+
const response = await fetch('https://nodejs.org/dist/index.json')
3+
const nodeVersions = await response.json() as Array<{ version: string }>
4+
5+
const result = new Set<string>()
6+
for (const nodeVersion of nodeVersions) {
7+
const vRemovedVersion = nodeVersion.version.substring(1)
8+
const versionParts = vRemovedVersion.split('.')
9+
10+
for (let i = 0; i < versionParts.length; i++) {
11+
const partialVersion = versionParts.slice(0, i + 1).join('.')
12+
result.add(partialVersion)
13+
}
14+
}
15+
16+
return [...result]
17+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
export default async function loadOllamaModels(): Promise<string[]> {
2+
const response = await fetch('https://ollama.com/library?sort=popular')
3+
const html = await response.text()
4+
5+
const matches = html.matchAll(/href="\/library\/([^"]+)"/g)
6+
const names = [...new Set([...matches].map((m) => m[1]))]
7+
8+
return names
9+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
export default async function loadSnapPackages(): Promise<string[]> {
2+
const response = await fetch('https://snapcraft.io/store/sitemap.xml')
3+
const xml = await response.text()
4+
5+
const matches = xml.matchAll(/<loc>https:\/\/snapcraft\.io\/([^<]+)<\/loc>/g)
6+
7+
return [...matches]
8+
.map((m) => m[1])
9+
.filter((name) => name !== 'store')
10+
}

0 commit comments

Comments
 (0)