Skip to content

Commit

Permalink
More careful code for all of -x mode
Browse files Browse the repository at this point in the history
  • Loading branch information
mxcl committed Nov 17, 2022
1 parent b08f49a commit 7955d49
Show file tree
Hide file tree
Showing 10 changed files with 415 additions and 399 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -95,4 +95,4 @@ jobs:
--output /usr/local/bin/tea \
./cli/src/app.ts
- run: tea -S +curl.se curl -L tea.xyz/white-paper/ | tea -S +charm.sh/glow glow -
- run: tea -S +gnu.org/wget wget -L tea.xyz/white-paper/ | tea -S +charm.sh/glow glow -
11 changes: 6 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ All you need is `tea`.
 


# tea/cli 0.13.0
# tea/cli 0.13.1

Open source is a treasure trove—yet those chests are sealed with gnarly locks.
tea is the key:
Expand Down Expand Up @@ -121,9 +121,10 @@ $ tea +gnu.org/wget wget -qO- tea.xyz/white-paper | tea +charm.sh/glow glow -
## tea: the Universal Interpreter
```sh
$ tea https://github.com/teaxyz/demos/blob/main/demo.go input.txt
$ tea https://gist.githubusercontent.com/i0bj/2b3afbe07a44179250474b5f36e7bd9b/raw/colors.go --yellow
tea: installing go 1.18.3
go: running demo.go
go: installing deps
go: running colors.go
```
Expand Down Expand Up @@ -332,10 +333,10 @@ sh <(curl https://tea.xyz)
In fact, the tea one-liner abstracts away installation:
```sh
$ sh <(curl tea.xyz) https://example.com/script.ts
$ sh <(curl tea.xyz) https://examples.deno.land/color-logging.ts
# works the same as:
$ tea https://example.com/script.ts
$ tea https://examples.deno.land/color-logging.ts
# if tea is installed, our one-liner uses the tea installation, if it’s not
# installed then it **doesn’t install tea** or any dependencies, it creates a
Expand Down
18 changes: 13 additions & 5 deletions src/app.dump.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { usePantry, useCellar, useFlags, useVirtualEnv } from "hooks"
import useShellEnv, { EnvKeys } from "hooks/useShellEnv.ts"
import { Installation, PackageSpecification } from "types"
import { Installation, PackageRequirement, PackageSpecification } from "types"
import { flatmap, print, undent, pkg } from "utils"
import { isPlainObject, isFullArray } from "is_what"
import { basename } from "deno/path/mod.ts"
import { Args } from "hooks/useFlags.ts"
import { hydrate } from "./app.exec.ts";
import { hydrate } from "prefab"

//TODO should read from the shell configuration files to get originals properly
//TODO don’t wait on each print, instead chain the promises to be more time-efficient
Expand Down Expand Up @@ -59,13 +59,21 @@ export default async function dump(args: Args) {
})()

const {installations, pending} = await (async () => {
const companions: PackageRequirement[] = await (() => {
if (!magic) return []
const pantry = usePantry()
return Promise.all(
args.pkgs.map(pkg => pantry.getCompanions(pkg))
).then(x => x.flatMap(x => x))
})()

const cellar = useCellar()
const installations: Installation[] = []
const pending: PackageSpecification[] = []
const pkgs = await hydrate([...args.pkgs, ...blueprint?.requirements ?? []])
const dry = new Set<string>(pkgs.wet.dry.map(x => x.project))
const pkgs = await hydrate([...args.pkgs, ...companions, ...blueprint?.pkgs ?? []])
const dry = new Set<string>(pkgs.dry.map(x => x.project))

for (const rq of pkgs.wet.dry) {
for (const rq of pkgs.dry) {
const installation = await cellar.has(rq)
if (installation) {
installations.push(installation)
Expand Down
Loading

0 comments on commit 7955d49

Please sign in to comment.