2022-08-01 22:43:40 +03:00
|
|
|
#!/usr/bin/env -S tea -E
|
|
|
|
|
|
|
|
/*---
|
2022-11-09 19:22:10 +03:00
|
|
|
dependencies:
|
|
|
|
gnu.org/tar: 1
|
|
|
|
tukaani.org/xz: 5
|
|
|
|
sourceware.org/bzip2: 1
|
2022-08-01 22:43:40 +03:00
|
|
|
args:
|
|
|
|
- deno
|
|
|
|
- run
|
|
|
|
- --allow-net
|
|
|
|
- --allow-run
|
2022-09-08 23:40:35 +03:00
|
|
|
- --allow-read
|
2022-09-09 16:37:26 +03:00
|
|
|
- --allow-write={{tea.prefix}}
|
2022-08-01 22:43:40 +03:00
|
|
|
- --allow-env
|
2022-11-07 19:43:48 +03:00
|
|
|
- --unstable
|
2022-08-01 22:43:40 +03:00
|
|
|
- --import-map={{ srcroot }}/import-map.json
|
|
|
|
---*/
|
|
|
|
|
2022-11-09 19:22:10 +03:00
|
|
|
import { usePantry, useFlags, useCellar, useInventory, usePrefix } from "hooks"
|
2022-11-07 19:43:48 +03:00
|
|
|
import { hydrate, install, link } from "prefab"
|
2022-11-09 19:22:30 +03:00
|
|
|
import { str as pkgstr } from "utils/pkg.ts"
|
2022-09-30 16:03:03 +03:00
|
|
|
import * as ARGV from "./utils/args.ts"
|
2022-11-07 19:43:48 +03:00
|
|
|
import { panic } from "utils/error.ts"
|
2022-11-09 19:22:10 +03:00
|
|
|
import build, { BuildResult } from "./build/build.ts"
|
|
|
|
import { set_output } from "./utils/gha.ts";
|
2022-08-10 21:58:22 +03:00
|
|
|
|
2022-08-17 15:22:22 +03:00
|
|
|
useFlags()
|
2022-08-01 22:43:40 +03:00
|
|
|
|
|
|
|
const pantry = usePantry()
|
2022-11-07 19:43:48 +03:00
|
|
|
const cellar = useCellar()
|
|
|
|
const inventory = useInventory()
|
2022-11-09 19:22:10 +03:00
|
|
|
const raw = await ARGV.toArray(ARGV.pkgs())
|
|
|
|
|
|
|
|
const rv: BuildResult[] = []
|
|
|
|
|
|
|
|
for (const rq of raw) {
|
|
|
|
const dry = await pantry.getDeps(rq)
|
|
|
|
const wet = await hydrate([...dry.runtime, ...dry.build])
|
|
|
|
|
|
|
|
for (const pkg of wet.pkgs) {
|
|
|
|
if (!await cellar.has(pkg)) {
|
|
|
|
const version = await inventory.select(pkg) ?? panic(`${pkgstr(pkg)} not found`)
|
|
|
|
const installation = await install({ project: pkg.project, version })
|
|
|
|
await link(installation)
|
|
|
|
}
|
2022-09-08 23:40:35 +03:00
|
|
|
}
|
2022-09-01 20:49:14 +03:00
|
|
|
|
2022-11-07 19:43:48 +03:00
|
|
|
const pkg = await pantry.resolve(rq)
|
2022-11-09 19:22:10 +03:00
|
|
|
rv.push(await build(pkg))
|
2022-11-07 19:43:48 +03:00
|
|
|
await link(pkg)
|
2022-10-17 20:45:32 +03:00
|
|
|
}
|
2022-11-09 19:22:10 +03:00
|
|
|
|
|
|
|
const to = usePrefix()
|
|
|
|
await set_output("pkgs", rv.map(x => pkgstr(x.installation.pkg)))
|
|
|
|
await set_output("paths", rv.map(x => x.installation.path), '%0A')
|
|
|
|
await set_output("relative-paths", rv.map(x => x.installation.path.relative({ to })))
|
|
|
|
await set_output("srcs", rv.map(x => x.src?.relative({ to }) ?? "~"))
|
|
|
|
await set_output("srcs-relative-paths", rv.compact(x => x.src?.relative({ to })))
|