Skip to content

Commit

Permalink
Fixes pkgxdev#166
Browse files Browse the repository at this point in the history
  • Loading branch information
mxcl committed Dec 6, 2022
1 parent 405c7af commit 255d730
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 8 deletions.
6 changes: 5 additions & 1 deletion src/hooks/useInventory.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { Package, PackageRequirement } from "types"
import { host, error } from "utils"
import SemVer from "semver"
import Path from "../vendor/Path.ts"

export interface Inventory {
[project: string]: {
Expand All @@ -12,7 +13,10 @@ export interface Inventory {

const select = async (rq: PackageRequirement | Package) => {
const { platform, arch } = host()
const url = `https://dist.tea.xyz/${rq.project}/${platform}/${arch}/versions.txt`

const url = new URL('https://dist.tea.xyz')
url.pathname = Path.root.join(rq.project, platform, arch, 'versions.txt').string

const rsp = await fetch(url)

if (!rsp.ok) throw new Error(`404-not-found: ${url}`) //FIXME
Expand Down
15 changes: 8 additions & 7 deletions src/hooks/useOffLicense.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { Stowage } from "types"
import { host } from "utils"
import Path from "path"

type Type = 's3'

Expand All @@ -8,20 +9,20 @@ export default function useOffLicense(_type: Type) {
}

function key(stowage: Stowage) {
let rv = stowage.pkg.project
let rv = Path.root.join(stowage.pkg.project)
if (stowage.type == 'bottle') {
const { platform, arch } = stowage.host ?? host()
rv += `/${platform}/${arch}`
rv = rv.join(`${platform}/${arch}`)
}
rv += `/v${stowage.pkg.version}`
let fn = `v${stowage.pkg.version}`
if (stowage.type == 'bottle') {
rv += `.tar.${stowage.compression}`
fn += `.tar.${stowage.compression}`
} else {
rv += stowage.extname
fn += stowage.extname
}
return rv
return rv.join(fn).string
}

function url(stowage: Stowage) {
return new URL(`https://dist.tea.xyz/${key(stowage)}`)
return new URL(`https://dist.tea.xyz${key(stowage)}`)
}

0 comments on commit 255d730

Please sign in to comment.