Skip to content

Commit 4409fe4

Browse files
jhheidermxcl
authored andcommitted
all configurable PKGX_DIST_URL
closes #71
1 parent 672b7e9 commit 4409fe4

File tree

3 files changed

+8
-2
lines changed

3 files changed

+8
-2
lines changed

src/hooks/useConfig.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ export interface Config {
99
cache: Path
1010
data: Path
1111

12+
dist: string
13+
1214
options: {
1315
/// prefer xz or gz for bottle downloads
1416
compression: 'xz' | 'gz'
@@ -53,6 +55,7 @@ export function ConfigDefault(env = Deno.env.toObject()): Config {
5355
const pantries = env['PKGX_PANTRY_PATH']?.split(SEP).compact(x => flatmap(x.trim(), x => Path.abs(x) ?? Path.cwd().join(x))) ?? []
5456
const cache = (flatmap(env["XDG_CACHE_HOME"], Path.abs) ?? platform_cache_default(home, env)).join("pkgx")
5557
const data = (flatmap(env["XDG_DATA_HOME"], Path.abs) ?? platform_data_home_default(home, env)).join("pkgx")
58+
const dist = env['PKGX_DIST_URL']?.trim() ?? 'https://dist.pkgx.dev'
5659
const isCI = boolize(env['CI']) ?? false
5760
const UserAgent = flatmap(getv(), v => `libpkgx/${v}`) ?? 'libpkgx'
5861
//TODO prefer 'xz' on Linux (as well) if supported
@@ -63,6 +66,7 @@ export function ConfigDefault(env = Deno.env.toObject()): Config {
6366
pantries,
6467
cache,
6568
data,
69+
dist,
6670
UserAgent,
6771
options: {
6872
compression,

src/hooks/useInventory.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import SemVer from "../utils/semver.ts"
44
import useFetch from "./useFetch.ts"
55
import host from "../utils/host.ts"
66
import "../utils/misc.ts"
7+
import useConfig from "./useConfig.ts";
78

89
export interface Inventory {
910
[project: string]: {
@@ -25,7 +26,7 @@ const select = async (rq: PackageRequirement | Package) => {
2526

2627
const get = async (rq: PackageRequirement | Package) => {
2728
const { platform, arch } = host()
28-
const url = new URL(`https://dist.pkgx.dev/${rq.project}/${platform}/${arch}/versions.txt`)
29+
const url = new URL(`${useConfig().dist}/${rq.project}/${platform}/${arch}/versions.txt`)
2930
const rsp = await useFetch(url)
3031

3132
if (!rsp.ok) {

src/hooks/useOffLicense.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { Stowage } from "../types.ts"
22
import host from "../utils/host.ts"
3+
import useConfig from "./useConfig.ts";
34

45
type Type = 's3'
56

@@ -24,5 +25,5 @@ function key(stowage: Stowage) {
2425
}
2526

2627
function url(stowage: Stowage) {
27-
return new URL(`https://dist.pkgx.dev/${key(stowage)}`)
28+
return new URL(`${useConfig().dist}/${key(stowage)}`)
2829
}

0 commit comments

Comments
 (0)