mirror of
https://github.com/ivabus/pantry
synced 2024-11-23 00:45:07 +03:00
plumbing/porcelain for build.ts
This commit is contained in:
parent
996ece5c50
commit
62c838d2e1
10 changed files with 83 additions and 60 deletions
2
.github/workflows/build.yml
vendored
2
.github/workflows/build.yml
vendored
|
@ -76,7 +76,7 @@ jobs:
|
||||||
- run: cli/scripts/install.ts ${{ steps.sorted.outputs.pre-install }}
|
- run: cli/scripts/install.ts ${{ steps.sorted.outputs.pre-install }}
|
||||||
|
|
||||||
# running out of /opt because only pantry.core has these scripts
|
# running out of /opt because only pantry.core has these scripts
|
||||||
- run: /opt/tea.xyz/var/pantry/scripts/build.ts ${{ steps.sorted.outputs.pkgs }}
|
- run: /opt/tea.xyz/var/pantry/scripts/build.plumbing.ts ${{ steps.sorted.outputs.pkgs }}
|
||||||
id: build
|
id: build
|
||||||
env:
|
env:
|
||||||
# GITHUB_TOKEN doesn't have private access to teaxyz/cli.
|
# GITHUB_TOKEN doesn't have private access to teaxyz/cli.
|
||||||
|
|
|
@ -14,8 +14,6 @@ args:
|
||||||
- --allow-read
|
- --allow-read
|
||||||
- --allow-write
|
- --allow-write
|
||||||
- --import-map={{ srcroot }}/import-map.json
|
- --import-map={{ srcroot }}/import-map.json
|
||||||
env:
|
|
||||||
TEA_PANTRY_PATH: "{{srcroot}}"
|
|
||||||
--- */
|
--- */
|
||||||
|
|
||||||
import { Installation } from "types"
|
import { Installation } from "types"
|
||||||
|
|
61
scripts/build.plumbing.ts
Executable file
61
scripts/build.plumbing.ts
Executable file
|
@ -0,0 +1,61 @@
|
||||||
|
#!/usr/bin/env -S tea -E
|
||||||
|
|
||||||
|
/*---
|
||||||
|
dependencies:
|
||||||
|
gnu.org/tar: 1
|
||||||
|
tukaani.org/xz: 5
|
||||||
|
sourceware.org/bzip2: 1
|
||||||
|
args:
|
||||||
|
- deno
|
||||||
|
- run
|
||||||
|
- --allow-net
|
||||||
|
- --allow-run
|
||||||
|
- --allow-read
|
||||||
|
- --allow-write={{tea.prefix}}
|
||||||
|
- --allow-env
|
||||||
|
- --import-map={{ srcroot }}/import-map.json
|
||||||
|
---*/
|
||||||
|
|
||||||
|
import { usePantry } from "hooks"
|
||||||
|
import { Installation } from "types"
|
||||||
|
import { pkg as pkgutils } from "utils"
|
||||||
|
import { useFlags, usePrefix } from "hooks"
|
||||||
|
import { set_output } from "./utils/gha.ts"
|
||||||
|
import build, { BuildResult } from "./build/build.ts"
|
||||||
|
import * as ARGV from "./utils/args.ts"
|
||||||
|
import Path from "path"
|
||||||
|
|
||||||
|
useFlags()
|
||||||
|
|
||||||
|
const pantry = usePantry()
|
||||||
|
const dry = await ARGV.toArray(ARGV.pkgs())
|
||||||
|
const gha = !!Deno.env.get("GITHUB_ACTIONS")
|
||||||
|
const group_it = gha && dry.length > 1
|
||||||
|
const rv: BuildResult[] = []
|
||||||
|
|
||||||
|
for (const rq of dry) {
|
||||||
|
const pkg = await pantry.resolve(rq)
|
||||||
|
|
||||||
|
if (group_it) {
|
||||||
|
console.log("::group::", pkgutils.str(pkg))
|
||||||
|
} else {
|
||||||
|
console.log({ building: pkg.project })
|
||||||
|
}
|
||||||
|
|
||||||
|
rv.push(await build(pkg))
|
||||||
|
|
||||||
|
if (group_it) {
|
||||||
|
console.log("::endgroup::")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const to = usePrefix()
|
||||||
|
await set_output("pkgs", rv.map(x => pkgutils.str(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 })))
|
||||||
|
|
||||||
|
interface InstallationPlus extends Installation {
|
||||||
|
src: Path
|
||||||
|
}
|
|
@ -1,10 +1,6 @@
|
||||||
#!/usr/bin/env -S tea -E
|
#!/usr/bin/env -S tea -E
|
||||||
|
|
||||||
/*---
|
/*---
|
||||||
dependencies:
|
|
||||||
gnu.org/tar: 1
|
|
||||||
tukaani.org/xz: 5
|
|
||||||
sourceware.org/bzip2: 1
|
|
||||||
args:
|
args:
|
||||||
- deno
|
- deno
|
||||||
- run
|
- run
|
||||||
|
@ -13,51 +9,36 @@ args:
|
||||||
- --allow-read
|
- --allow-read
|
||||||
- --allow-write={{tea.prefix}}
|
- --allow-write={{tea.prefix}}
|
||||||
- --allow-env
|
- --allow-env
|
||||||
|
- --unstable
|
||||||
- --import-map={{ srcroot }}/import-map.json
|
- --import-map={{ srcroot }}/import-map.json
|
||||||
env:
|
|
||||||
TEA_PANTRY_PATH: "{{srcroot}}"
|
|
||||||
---*/
|
---*/
|
||||||
|
|
||||||
import { usePantry } from "hooks"
|
import { usePantry, useFlags, useCellar, useInventory } from "hooks"
|
||||||
import { Installation } from "types"
|
import { hydrate, install, link } from "prefab"
|
||||||
import { pkg as pkgutils } from "utils"
|
|
||||||
import { useFlags, usePrefix } from "hooks"
|
|
||||||
import { set_output } from "./utils/gha.ts"
|
|
||||||
import build, { BuildResult } from "./build/build.ts"
|
|
||||||
import * as ARGV from "./utils/args.ts"
|
import * as ARGV from "./utils/args.ts"
|
||||||
import Path from "path"
|
import { panic } from "utils/error.ts"
|
||||||
|
import build from "./build/build.ts"
|
||||||
|
|
||||||
useFlags()
|
useFlags()
|
||||||
|
|
||||||
const pantry = usePantry()
|
const pantry = usePantry()
|
||||||
|
const cellar = useCellar()
|
||||||
|
const inventory = useInventory()
|
||||||
const dry = await ARGV.toArray(ARGV.pkgs())
|
const dry = await ARGV.toArray(ARGV.pkgs())
|
||||||
const gha = !!Deno.env.get("GITHUB_ACTIONS")
|
const wet = await hydrate(dry, async (pkg, dry) => {
|
||||||
const group_it = gha && dry.length > 1
|
const deps = await pantry.getDeps(pkg)
|
||||||
const rv: BuildResult[] = []
|
return dry ? [...deps.build, ...deps.runtime] : deps.runtime
|
||||||
|
})
|
||||||
|
|
||||||
|
for (const pkg of wet.wet) {
|
||||||
|
if (!await cellar.has(pkg)) {
|
||||||
|
const version = await inventory.select(pkg) ?? panic()
|
||||||
|
await install({ project: pkg.project, version })
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
for (const rq of dry) {
|
for (const rq of dry) {
|
||||||
const pkg = await pantry.resolve(rq)
|
const pkg = await pantry.resolve(rq)
|
||||||
|
await build(pkg)
|
||||||
if (group_it) {
|
await link(pkg)
|
||||||
console.log("::group::", pkgutils.str(pkg))
|
|
||||||
} else {
|
|
||||||
console.log({ building: pkg.project })
|
|
||||||
}
|
|
||||||
|
|
||||||
rv.push(await build(pkg))
|
|
||||||
|
|
||||||
if (group_it) {
|
|
||||||
console.log("::endgroup::")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const to = usePrefix()
|
|
||||||
await set_output("pkgs", rv.map(x => pkgutils.str(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 })))
|
|
||||||
|
|
||||||
interface InstallationPlus extends Installation {
|
|
||||||
src: Path
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,8 +7,6 @@ args:
|
||||||
- --allow-read
|
- --allow-read
|
||||||
- --allow-env
|
- --allow-env
|
||||||
- --import-map={{ srcroot }}/import-map.json
|
- --import-map={{ srcroot }}/import-map.json
|
||||||
env:
|
|
||||||
TEA_PANTRY_PATH: "{{srcroot}}"
|
|
||||||
---*/
|
---*/
|
||||||
|
|
||||||
import { PackageRequirement } from "types"
|
import { PackageRequirement } from "types"
|
||||||
|
|
|
@ -10,8 +10,6 @@ args:
|
||||||
- --allow-write={{ tea.prefix }}
|
- --allow-write={{ tea.prefix }}
|
||||||
- --allow-env
|
- --allow-env
|
||||||
- --import-map={{ srcroot }}/import-map.json
|
- --import-map={{ srcroot }}/import-map.json
|
||||||
env:
|
|
||||||
TEA_PANTRY_PATH: "{{srcroot}}"
|
|
||||||
---*/
|
---*/
|
||||||
|
|
||||||
//TODO verify the sha
|
//TODO verify the sha
|
||||||
|
|
|
@ -7,8 +7,6 @@ args:
|
||||||
- --allow-read
|
- --allow-read
|
||||||
- --allow-env
|
- --allow-env
|
||||||
- --import-map={{ srcroot }}/import-map.json
|
- --import-map={{ srcroot }}/import-map.json
|
||||||
env:
|
|
||||||
TEA_PANTRY_PATH: "{{srcroot}}"
|
|
||||||
---*/
|
---*/
|
||||||
|
|
||||||
// sorts input for building
|
// sorts input for building
|
||||||
|
|
|
@ -11,8 +11,6 @@ args:
|
||||||
- --allow-env
|
- --allow-env
|
||||||
- --unstable
|
- --unstable
|
||||||
- --import-map={{ srcroot }}/import-map.json
|
- --import-map={{ srcroot }}/import-map.json
|
||||||
env:
|
|
||||||
TEA_PANTRY_PATH: "{{srcroot}}"
|
|
||||||
---*/
|
---*/
|
||||||
|
|
||||||
import { Installation, Package, PackageRequirement } from "types"
|
import { Installation, Package, PackageRequirement } from "types"
|
||||||
|
|
|
@ -1,9 +0,0 @@
|
||||||
export function overlay_this_pantry() {
|
|
||||||
const self = new URL(import.meta.url).path().parent().parent().parent().join("projects")
|
|
||||||
|
|
||||||
// if unset just assume the user wants this
|
|
||||||
// this is magic in a bad way, but for now is what we're doing
|
|
||||||
if (!!Deno.env.get("TEA_PANTRY_PATH")) {
|
|
||||||
Deno.env.set("TEA_PANTRY_PATH", self.string)
|
|
||||||
}
|
|
||||||
}
|
|
Loading…
Reference in a new issue