2022-09-19 16:32:27 +03:00
|
|
|
#!/usr/bin/env -S tea -E
|
|
|
|
|
|
|
|
/*---
|
|
|
|
args:
|
|
|
|
- deno
|
|
|
|
- run
|
|
|
|
- --allow-net
|
|
|
|
- --allow-run
|
|
|
|
- --allow-read
|
|
|
|
- --allow-write={{ tea.prefix }}
|
|
|
|
- --allow-env
|
|
|
|
- --import-map={{ srcroot }}/import-map.json
|
|
|
|
---*/
|
|
|
|
|
2022-09-20 14:53:40 +03:00
|
|
|
import { usePantry, useCache, useCellar, useSourceUnarchiver } from "hooks"
|
2022-09-19 16:32:27 +03:00
|
|
|
import { Command } from "cliffy/command/mod.ts"
|
2022-09-21 10:46:24 +03:00
|
|
|
import { print, pkg as pkgutils } from "utils"
|
2022-09-19 16:32:27 +03:00
|
|
|
|
|
|
|
const { args } = await new Command()
|
|
|
|
.name("tea-fetch-src")
|
|
|
|
.arguments("<pkgspec:string>")
|
|
|
|
.parse(Deno.args)
|
|
|
|
|
|
|
|
const pantry = usePantry()
|
2022-09-21 10:46:24 +03:00
|
|
|
const req = pkgutils.parse(args[0])
|
|
|
|
const pkg = await pantry.resolve(req); console.debug(pkg)
|
2022-09-19 16:32:27 +03:00
|
|
|
|
2022-09-21 10:46:24 +03:00
|
|
|
const dstdir = useCellar().keg(pkg).join("src")
|
2022-09-19 16:32:27 +03:00
|
|
|
const { url, stripComponents } = await pantry.getDistributable(pkg)
|
|
|
|
const { download } = useCache()
|
2022-09-21 10:46:24 +03:00
|
|
|
const zipfile = await download({ pkg, url, type: 'src' })
|
|
|
|
await useSourceUnarchiver().unarchive({ dstdir, zipfile, stripComponents })
|
2022-09-19 16:32:27 +03:00
|
|
|
|
|
|
|
await print(`${dstdir}\n`)
|