diff --git a/README.md b/README.md index e746d693..f080d34c 100644 --- a/README.md +++ b/README.md @@ -16,7 +16,7 @@

-# tea/cli 0.35.0 +# tea/cli 0.35.1 `tea` puts the whole open source ecosystem at your fingertips: diff --git a/deno.jsonc b/deno.jsonc index 18c3ad24..ac6ac962 100644 --- a/deno.jsonc +++ b/deno.jsonc @@ -33,8 +33,8 @@ "imports": { "is-what": "https://deno.land/x/is_what@v4.1.8/src/index.ts", "jsonc": "https://deno.land/x/jsonc_parser@v0.0.1/mod.ts", - "tea": "https://raw.github.com/teaxyz/lib/v0.3.1/mod.ts", - "tea/": "https://raw.github.com/teaxyz/lib/v0.3.1/src/", + "tea": "https://raw.github.com/teaxyz/lib/v0.4.2/mod.ts", + "tea/": "https://raw.github.com/teaxyz/lib/v0.4.2/src/", "outdent": "https://deno.land/x/outdent@v0.8.0/mod.ts", "cliffy/": "https://deno.land/x/cliffy@v0.25.7/", "deno/": "https://deno.land/std@0.187.0/", diff --git a/scripts/repair.ts b/scripts/repair.ts index a454f75b..589173fb 100755 --- a/scripts/repair.ts +++ b/scripts/repair.ts @@ -1,9 +1,9 @@ #!/usr/bin/env -S deno run -A -import { hooks, semver, Installation, prefab } from "tea" +import { hooks, semver, Installation, plumbing } from "tea" import { useConfig } from "hooks" const { useCellar } = hooks -const { link } = prefab +const { link } = plumbing if (import.meta.main) { useConfig() diff --git a/src/app.magic.ts b/src/app.magic.ts index 69894db3..26b060ee 100644 --- a/src/app.magic.ts +++ b/src/app.magic.ts @@ -17,8 +17,8 @@ export default function(self: Path, shell?: string) { fi } - if test "$TERM_PROGRAM" = WarpTerminal -o "$TERM_PROGRAM" = vscode; then - # warp.dev & vscode integrated terminal don’t call the hook on startup + if test "$TERM_PROGRAM" != Apple_Terminal; then + # Apple’s app calls this hook itself, but nothing else seems to _tea_chpwd_hook fi @@ -28,11 +28,18 @@ export default function(self: Path, shell?: string) { chpwd_functions=( _tea_chpwd_hook \${chpwd_functions[@]} ) fi + # add our shims to the PATH + TEA_PREFIX="\${TEA_PREFIX:-$HOME/.tea}" + if [[ "$PATH" != *"$TEA_PREFIX/.local/bin"* ]]; then + export PATH="$TEA_PREFIX/.local/bin:$PATH" + fi + + # we configure eg. \`npm i -g\`, cargo, etc. to install here if [[ "$PATH" != *"$HOME/.local/bin"* ]]; then export PATH="$HOME/.local/bin:$PATH" fi - if ! command -v tea 2>&1 >/dev/null || ! tea --prefix 2>&1 >/dev/null; then + if ! command -v tea 2>&1 >/dev/null; then export PATH="${d}:$PATH" fi @@ -114,6 +121,12 @@ export default function(self: Path, shell?: string) { source /dev/stdin <<<"$("${d}"/tea +tea.xyz/magic -Esk --chaste env)" } + # add our shims to the PATH + TEA_PREFIX="\${TEA_PREFIX:-$HOME/.tea}" + if [[ "$PATH" != *"$TEA_PREFIX/.local/bin"* ]]; then + export PATH="$TEA_PREFIX/.local/bin:$PATH" + fi + if [[ "$PATH" != *"$HOME/.local/bin"* ]]; then export PATH="$HOME/.local/bin:$PATH" fi diff --git a/src/prefab/install.ts b/src/prefab/install.ts index dae90989..3e09443b 100644 --- a/src/prefab/install.ts +++ b/src/prefab/install.ts @@ -1,11 +1,11 @@ import { PackageSpecification, Package, utils, Installation, plumbing, Path } from "tea" import { Logger as InstallLogger } from "tea/plumbing/install.ts" +const { hydrate, link: base_link, resolve, install } = plumbing import useConfig, { Verbosity } from "../hooks/useConfig.ts" import useLogger, { Logger } from "../hooks/useLogger.ts" import { ExitError } from "../hooks/useErrorHandler.ts" -const { hydrate, link: base_link, resolve, install } = plumbing +import usePantry from "tea/hooks/usePantry.ts" import undent from "outdent" -import usePantry from "https://raw.githubusercontent.com/teaxyz/lib/v0.3.1/src/hooks/usePantry.ts" //TODO we should use even more plumbing to ensure pkgs aren’t moved into // TEA_PREFIX until all their deps are moved in @@ -223,17 +223,26 @@ function QuietLogger(logger: Logger): InstallLogger { async function link(installation: Installation) { const pp: Promise[] = [base_link(installation)] + const { prefix: TEA_PREFIX } = useConfig() - const bin = useConfig().prefix.join("local/bin") - const tea = useConfig().prefix.join("tea.xyz/v*/bin/tea").isExecutableFile()?.relative({ to: bin }) + const bin = TEA_PREFIX.join(".local/bin") + const tea = TEA_PREFIX.join("tea.xyz/v*/bin/tea").isExecutableFile() + const provides = await usePantry().project(installation.pkg).provides() /// we only do auto-POSIX symlinking if tea is installed properly - if (tea) for (const provides of await usePantry().project(installation.pkg).provides()) { - const target = bin.mkdir('p').join(provides) - if (!target.exists()) { - const p = Deno.symlink(tea, target.string) + if (tea && provides.length) { + const tealink = bin.mkdir('p').join("tea") + if (!tealink.exists()) { + const p = Deno.symlink(tea.relative({ to: bin }), tealink.string) pp.push(p) } + for (const exename of provides) { + const target = bin.join(exename) + if (!target.exists()) { + const p = Deno.symlink("tea", target.string) + pp.push(p) + } + } } await Promise.all(pp) diff --git a/tests/integration/tea.ln.test.ts b/tests/integration/tea.ln.test.ts index 6cfb1aa6..c4ff1933 100644 --- a/tests/integration/tea.ln.test.ts +++ b/tests/integration/tea.ln.test.ts @@ -75,5 +75,5 @@ it(suite, "auto-symlinks in ~/.tea/local work", async function() { this.tea = this.tea.cp({ into: this.TEA_PREFIX.join("tea.xyz/v*/bin").mkdir('p') }) await this.run({args: ["perl", "--version"]}) - assert(this.TEA_PREFIX.join("local/bin/perl").isExecutableFile()) + assert(this.TEA_PREFIX.join(".local/bin/perl").isExecutableFile()) })