Skip to content

Commit

Permalink
Unarchiver knows what tools it needs to install
Browse files Browse the repository at this point in the history
  • Loading branch information
mxcl committed Aug 4, 2022
1 parent 892dc03 commit 2e83f3a
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 3 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ Change how your team works.
 


# tea/cli 0.3.9
# tea/cli 0.4.0

tea is a universal virtual‑environment manager:

Expand Down
2 changes: 1 addition & 1 deletion src/prefab/resolve.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export default async function resolve(reqs: PackageRequirement[]): Promise<Packa
} else {
const versions = await inventory.getVersions({ project, constraint })
const version = semver.maxSatisfying(versions, constraint)
if (!version) throw "no-version"
if (!version) { console.error({ project, constraint, versions }); throw new Error() }
rv.push({ version, project })
}
}
Expand Down
39 changes: 38 additions & 1 deletion src/utils/Unarchiver.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Path, Verbosity } from "types"
import { PackageRequirement, Path, Verbosity, semver } from "types"

interface Options {
dstdir: Path
Expand All @@ -20,8 +20,14 @@ export class Unarchiver {
supports(_filename: Path): boolean {
return false
}

dependencies(): PackageRequirement[] {
return []
}
}

const constraint = new semver.Range("*")

export class TarballUnarchiver extends Unarchiver {
private stripComponents?: number

Expand Down Expand Up @@ -51,6 +57,30 @@ export class TarballUnarchiver extends Unarchiver {
return false
}
}

dependencies() {
const rv = [{
project: "gnu.org/tar",
constraint
}]
switch (this.opts.zipfile.extname()) {
case ".tbz":
case ".tar.bz2":
rv.push({
project: "sourceware.org/bzip2",
constraint
})
break
case ".txz":
case ".tar.xz":
rv.push({
project: "tukaani.org/xz",
constraint
})
break
}
return rv
}
}

export class ZipUnarchiver extends Unarchiver {
Expand All @@ -76,4 +106,11 @@ export class ZipUnarchiver extends Unarchiver {
static supports(filename: Path): boolean {
return filename.extname() == ".zip"
}

dependencies() {
return [{
project: "info-zip.org/unzip",
constraint
}]
}
}

0 comments on commit 2e83f3a

Please sign in to comment.