2022-08-05 04:19:01 +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
|
|
|
|
|
- --allow-write={{ tea.prefix }}
|
2022-08-05 04:19:01 +03:00
|
|
|
|
- --allow-env
|
|
|
|
|
- --import-map={{ srcroot }}/import-map.json
|
|
|
|
|
---*/
|
|
|
|
|
|
2022-09-01 20:49:14 +03:00
|
|
|
|
// sorts input for building
|
|
|
|
|
// does a full hydration, but only returns ordered, dry packages
|
|
|
|
|
|
|
|
|
|
|
2022-09-21 10:46:24 +03:00
|
|
|
|
import { pkg } from "utils"
|
2022-09-20 14:53:40 +03:00
|
|
|
|
import { usePantry, useFlags } from "hooks"
|
|
|
|
|
import { hydrate } from "prefab"
|
2022-09-26 15:28:58 +03:00
|
|
|
|
import { PackageRequirement } from "types"
|
2022-09-30 16:03:03 +03:00
|
|
|
|
import * as ARGV from "./utils/args.ts"
|
2022-08-10 21:58:22 +03:00
|
|
|
|
|
2022-08-17 15:22:22 +03:00
|
|
|
|
const flags = useFlags()
|
2022-09-01 20:49:14 +03:00
|
|
|
|
const pantry = usePantry()
|
2022-08-05 04:19:01 +03:00
|
|
|
|
|
2022-09-30 16:03:03 +03:00
|
|
|
|
const dry = await ARGV.toArray(ARGV.pkgs())
|
2022-08-05 04:19:01 +03:00
|
|
|
|
|
2022-09-01 20:49:14 +03:00
|
|
|
|
const wet = await hydrate(dry, async (pkg, dry) => {
|
|
|
|
|
const deps = await pantry.getDeps(pkg)
|
|
|
|
|
return dry ? [...deps.build, ...deps.runtime] : deps.runtime
|
|
|
|
|
})
|
2022-08-05 04:19:01 +03:00
|
|
|
|
|
2022-08-17 15:22:22 +03:00
|
|
|
|
if (Deno.env.get("GITHUB_ACTIONS")) {
|
2022-09-27 22:59:14 +03:00
|
|
|
|
const massage = (input: PackageRequirement[]) =>
|
2022-09-26 15:28:58 +03:00
|
|
|
|
input.map(p => {
|
|
|
|
|
let out = pkg.str(p)
|
2022-09-27 22:59:14 +03:00
|
|
|
|
// shell quoting via GHA is weird and we don’t fully understand it
|
2022-09-26 15:28:58 +03:00
|
|
|
|
if (/[<>]/.test(out)) out = `"${out}"`
|
|
|
|
|
return out
|
|
|
|
|
}).join(" ")
|
|
|
|
|
|
2022-09-27 22:59:14 +03:00
|
|
|
|
console.log(`::set-output name=pkgs::${massage(wet.dry)}`)
|
2022-09-26 15:28:58 +03:00
|
|
|
|
console.log(`::set-output name=pre-install::${massage(wet.wet)}`)
|
2022-08-17 15:22:22 +03:00
|
|
|
|
} else {
|
2022-09-26 15:28:58 +03:00
|
|
|
|
const gas = wet.dry.map(x => pkg.str(x))
|
|
|
|
|
if (flags.json) {
|
|
|
|
|
console.log(gas)
|
|
|
|
|
} else {
|
|
|
|
|
console.log(gas.join("\n"))
|
|
|
|
|
}
|
2022-08-17 15:22:22 +03:00
|
|
|
|
}
|