diff --git a/deno.jsonc b/deno.jsonc index 49d29f2d..6b38d02e 100644 --- a/deno.jsonc +++ b/deno.jsonc @@ -15,8 +15,8 @@ "cliffy/": "https://deno.land/x/cliffy@v1.0.0-rc.3/", "s3": "https://deno.land/x/s3@0.5.0/mod.ts", "deno/": "https://deno.land/std@0.208.0/", - "libpkgx": "https://deno.land/x/libpkgx@v0.14.1/mod.ts", - "libpkgx/": "https://deno.land/x/libpkgx@v0.14.1/src/", + "libpkgx": "https://deno.land/x/libpkgx@v0.16.0/mod.ts", + "libpkgx/": "https://deno.land/x/libpkgx@v0.16.0/src/", "pkgx": "./lib/pkgx.ts" } } diff --git a/lib/hooks/usePantry.getScript.ts b/lib/hooks/usePantry.getScript.ts index b0328783..942ea317 100644 --- a/lib/hooks/usePantry.getScript.ts +++ b/lib/hooks/usePantry.getScript.ts @@ -16,6 +16,7 @@ export const getScript = async (pkg: Package, key: 'build' | 'test', deps: Insta const mm = useMoustaches() const tokens = mm.tokenize.all(pkg, deps) + tokens.push(...tokenizeHost()) tokens.push({ from: "pkgx.dir", to: usePkgxConfig().prefix.string }) @@ -109,7 +110,7 @@ export const getScript = async (pkg: Package, key: 'build' | 'test', deps: Insta if (wd) { wd = mm.apply(wd, [ ...mm.tokenize.version(pkg.version), - ...mm.tokenize.host(), + ...tokenizeHost(), ...pkg_tokens ]) raw = undent` @@ -260,3 +261,14 @@ function platform_reduce(env: PlainObject) { } } } + +//TODO replace `hw` with `host` +export function tokenizeHost() { + const { arch, target, platform } = host() + return [ + { from: "hw.arch", to: arch }, + { from: "hw.target", to: target }, + { from: "hw.platform", to: platform }, + { from: "hw.concurrency", to: navigator.hardwareConcurrency.toString() }, + ] +} diff --git a/lib/hooks/usePantry.ts b/lib/hooks/usePantry.ts index dc0fb7b7..31f0c065 100644 --- a/lib/hooks/usePantry.ts +++ b/lib/hooks/usePantry.ts @@ -1,6 +1,6 @@ import { isNumber, isPlainObject, isString, isArray, PlainObject } from "is-what" import { Package, PackageRequirement, semver, utils, hooks } from "libpkgx" -import { getScript } from "./usePantry.getScript.ts" +import { getScript, tokenizeHost } from "./usePantry.getScript.ts" import getVersions from "./usePantry.getVersions.ts" const { flatmap, validate } = utils @@ -87,7 +87,7 @@ const getGitDistribution = ({ pkg, url: urlstr, ref }: { pkg: Package, url: stri ref = moustaches.apply(ref, [ ...moustaches.tokenize.version(pkg.version), - ...moustaches.tokenize.host() + ...tokenizeHost() ]) return { url, ref, stripComponents: 0, type: 'git' } @@ -136,7 +136,7 @@ const getDistributable = async (pkg: Package) => { urlstr = moustaches.apply(urlstr, [ ...moustaches.tokenize.version(v), - ...moustaches.tokenize.host(), + ...tokenizeHost(), ]) try {