2022-08-01 22:43:40 +03:00
|
|
|
#!/usr/bin/env -S tea -E
|
|
|
|
|
|
|
|
/*---
|
|
|
|
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
|
|
|
|
- --import-map={{ srcroot }}/import-map.json
|
|
|
|
---*/
|
|
|
|
|
2022-09-20 14:53:40 +03:00
|
|
|
import { usePantry } from "hooks"
|
2022-09-19 16:32:27 +03:00
|
|
|
import build from "./build/build.ts"
|
2022-09-20 14:53:40 +03:00
|
|
|
import { Package } from "types"
|
2022-09-21 10:46:24 +03:00
|
|
|
import { pkg as pkgutils } from "utils"
|
2022-09-20 18:29:21 +03:00
|
|
|
import { useFlags, usePrefix } from "hooks"
|
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-09-21 10:46:24 +03:00
|
|
|
const dry = Deno.args.map(pkgutils.parse)
|
2022-09-08 23:40:35 +03:00
|
|
|
const gha = !!Deno.env.get("GITHUB_ACTIONS")
|
2022-09-13 18:05:04 +03:00
|
|
|
const group_it = gha && dry.length > 1
|
2022-08-01 22:43:40 +03:00
|
|
|
const rv: Package[] = []
|
2022-09-19 16:32:27 +03:00
|
|
|
|
2022-09-20 18:29:21 +03:00
|
|
|
if (usePrefix().string != "/opt") {
|
|
|
|
console.error({ TEA_PREFIX: usePrefix().string })
|
2022-09-19 16:32:27 +03:00
|
|
|
throw new Error("builds must be performed in /opt (try TEA_PREFIX=/opt)")
|
|
|
|
}
|
|
|
|
|
2022-09-21 10:46:24 +03:00
|
|
|
for (const rq of dry) {
|
|
|
|
const pkg = await pantry.resolve(rq)
|
2022-08-01 22:43:40 +03:00
|
|
|
|
2022-09-13 18:05:04 +03:00
|
|
|
if (group_it) {
|
2022-09-21 10:46:24 +03:00
|
|
|
console.log("::group::", pkgutils.str(pkg))
|
2022-09-08 23:40:35 +03:00
|
|
|
} else {
|
2022-09-21 10:46:24 +03:00
|
|
|
console.log({ building: pkg.project })
|
2022-09-08 23:40:35 +03:00
|
|
|
}
|
2022-08-01 22:43:40 +03:00
|
|
|
|
2022-09-19 16:32:27 +03:00
|
|
|
await build(pkg)
|
2022-09-01 20:49:14 +03:00
|
|
|
rv.push(pkg)
|
2022-09-08 23:40:35 +03:00
|
|
|
|
2022-09-13 18:05:04 +03:00
|
|
|
if (group_it) {
|
2022-09-08 23:40:35 +03:00
|
|
|
console.log("::endgroup::")
|
|
|
|
}
|
2022-08-01 22:43:40 +03:00
|
|
|
}
|
2022-09-01 20:49:14 +03:00
|
|
|
|
2022-09-25 15:41:58 +03:00
|
|
|
const built_pkgs = rv.map(pkgutils.str).join(" ")
|
2022-09-01 20:49:14 +03:00
|
|
|
const txt = `::set-output name=pkgs::${built_pkgs}\n`
|
|
|
|
await Deno.stdout.write(new TextEncoder().encode(txt))
|