Skip to content

Commit 093e186

Browse files
authored
Merge pull request #90 from pkgxdev/jsr-publish
fix global declares (jsr doesn't allow them)
2 parents 5aaf5ed + 7ad7aae commit 093e186

15 files changed

Lines changed: 70 additions & 102 deletions

File tree

.github/workflows/publish-jsr.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ jobs:
2222
with:
2323
deno-version: v2.x
2424
- name: dry-run
25-
run: deno publish --dry-run --allow-slow-types --no-check --unstable-fs --unstable-ffi
25+
run: deno publish --dry-run --unstable-fs --unstable-ffi
2626
- name: publish
2727
if: github.event_name == 'release' || github.event_name == 'workflow_dispatch'
28-
run: deno publish --allow-slow-types --no-check --unstable-fs --unstable-ffi
28+
run: deno publish --unstable-fs --unstable-ffi

deno.json

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -37,17 +37,11 @@
3737
"tasks": {
3838
"test": "deno test --parallel --unstable-fs --unstable-ffi --allow-all",
3939
"typecheck": "deno check ./mod.ts",
40-
"publish:dry": "deno publish --dry-run --allow-slow-types --no-check --allow-dirty --unstable-fs --unstable-ffi"
40+
"publish:dry": "deno publish --dry-run --allow-dirty --unstable-fs --unstable-ffi"
4141
},
4242
"lint": {
4343
"include": ["src/", "mod.ts"],
44-
"exclude": ["**/*.test.ts", "vendor/", "src/hooks/useTestConfig.ts"],
45-
"rules": {
46-
// Prototype extensions (Array.compact, Promise.swallow, etc.) use
47-
// `declare global`, which JSR forbids without --allow-slow-types.
48-
// Explicit public return types are fixed; globals are a larger refactor.
49-
"exclude": ["no-slow-types"]
50-
}
44+
"exclude": ["**/*.test.ts", "vendor/", "src/hooks/useTestConfig.ts"]
5145
},
5246
"test": {
5347
"include": ["src/"],

mod.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
import "./src/utils/misc.ts"
2-
import { flatmap, validate } from "./src/utils/misc.ts"
1+
import { chuzzle, compact, flatmap, insert, validate } from "./src/utils/misc.ts"
32

43
import host from "./src/utils/host.ts"
54
import type { SupportedArchitecture, SupportedPlatform } from "./src/utils/host.ts"
@@ -9,7 +8,7 @@ import Path from "./src/utils/Path.ts"
98
export * as types from "./src/types.ts"
109
import * as pkg from "./src/utils/pkg.ts"
1110

12-
import { panic, PkgxError } from "./src/utils/error.ts"
11+
import { panic, PkgxError, swallow } from "./src/utils/error.ts"
1312
import useConfig from "./src/hooks/useConfig.ts"
1413
import useOffLicense from "./src/hooks/useOffLicense.ts"
1514
import useCache from "./src/hooks/useCache.ts"
@@ -30,7 +29,7 @@ import run, { RunError } from "./src/porcelain/run.ts"
3029
import porcelain_install from "./src/porcelain/install.ts"
3130

3231
const utils = {
33-
pkg, host, flatmap, validate, panic, ConsoleLogger
32+
pkg, host, flatmap, validate, panic, ConsoleLogger, swallow, compact, insert, chuzzle
3433
}
3534

3635
const hooks = {

src/hooks/useCellar.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import type { Package, PackageRequirement, Installation } from "../types.ts"
2-
import { PkgxError } from "../utils/error.ts"
2+
import { PkgxError, swallow } from "../utils/error.ts"
33
import * as pkgutils from "../utils/pkg.ts"
44
import SemVer from "../utils/semver.ts"
55
import useConfig from "./useConfig.ts"
@@ -32,7 +32,7 @@ export default function useCellar(): UseCellar {
3232
const keg = (pkg: Package) => shelf(pkg.project).join(`v${pkg.version}`)
3333

3434
/// returns the `Installation` if the pkg is installed
35-
const has = (pkg: Package | PackageRequirement | Path) => resolve(pkg).swallow(InstallationNotFoundError)
35+
const has = (pkg: Package | PackageRequirement | Path) => swallow(resolve(pkg), InstallationNotFoundError)
3636

3737
return {
3838
has,

src/hooks/useConfig.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { flatmap } from "../utils/misc.ts"
1+
import { compact, flatmap } from "../utils/misc.ts"
22
import { deno } from "../deps.ts"
33
import host from "../utils/host.ts"
44
import Path from "../utils/Path.ts"
@@ -54,7 +54,7 @@ export function ConfigDefault(env: Record<string, string> = Deno.env.toObject())
5454
const prefix = flatmap(env['PKGX_DIR']?.trim(), x => new Path(x)) ??
5555
flatmap(env['XDG_DATA_HOME'], x => new Path(x).join("pkgx")) ??
5656
home.join('.pkgx')
57-
const pantries = env['PKGX_PANTRY_PATH']?.split(SEP).compact(x => flatmap(x.trim(), x => Path.abs(x) ?? Path.cwd().join(x))) ?? []
57+
const pantries = compact(env['PKGX_PANTRY_PATH']?.split(SEP) ?? [], x => flatmap(x.trim(), x => Path.abs(x) ?? Path.cwd().join(x)))
5858
const cache = (
5959
(Deno.build.os == 'linux' ? flatmap(env["XDG_CACHE_HOME"], Path.abs) : undefined)
6060
?? platform_cache_default(home, env)

src/hooks/useDownload.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@ const { crypto: crypto_, streams: { writeAll } } = deno
33
const { crypto } = crypto_
44
import { encodeHex } from "@std/encoding"
55
import { PkgxError, panic } from "../utils/error.ts"
6+
import { chuzzle } from "../utils/misc.ts"
67
import useConfig from "./useConfig.ts"
78
import useFetch from "./useFetch.ts"
89
import Path from "../utils/Path.ts"
910
import * as fs from "node:fs"
10-
import "../utils/misc.ts"
1111

1212
interface DownloadOptions {
1313
src: URL
@@ -119,7 +119,7 @@ async function the_meat<T>({ src, logger, headers, dst }: DownloadOptions): Prom
119119

120120
switch (rsp.status) {
121121
case 200: {
122-
const sz = parseInt(rsp.headers.get("Content-Length")!).chuzzle()
122+
const sz = chuzzle(parseInt(rsp.headers.get("Content-Length")!))
123123

124124
if (logger) logger({ src, dst, total: sz })
125125

src/hooks/useInventory.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ import { DownloadError } from "./useDownload.ts"
33
import SemVer from "../utils/semver.ts"
44
import useFetch from "./useFetch.ts"
55
import host from "../utils/host.ts"
6-
import "../utils/misc.ts"
76
import useConfig from "./useConfig.ts";
87

98
export interface Inventory {

src/hooks/usePantry.ts

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ import { provides as cache_provides, available as cache_available, runtime_env a
55
import type SemVer from "../utils/semver.ts"
66
import * as semver from "../utils/semver.ts"
77
import useMoustaches from "./useMoustaches.ts"
8-
import { PkgxError } from "../utils/error.ts"
9-
import { validate } from "../utils/misc.ts"
8+
import { PkgxError, swallow } from "../utils/error.ts"
9+
import { compact, insert, validate } from "../utils/misc.ts"
1010
import * as pkgutils from "../utils/pkg.ts"
1111
import useConfig from "./useConfig.ts"
1212
import host from "../utils/host.ts"
@@ -79,7 +79,7 @@ export default function usePantry(): {
7979
for (const prefix of pantry_paths()) {
8080
for await (const path of _ls_pantry(prefix)) {
8181
const project = path.parent().relative({ to: prefix })
82-
if (seen.insert(project).inserted) {
82+
if (insert(seen, project).inserted) {
8383
yield { project, path }
8484
}
8585
}
@@ -149,7 +149,7 @@ export default function usePantry(): {
149149
}
150150
if (!isArray(node)) throw new PantryParseError(project)
151151

152-
return node.compact(x => {
152+
return compact(node, x => {
153153
if (isPlainObject(x)) {
154154
x = x["executable"]
155155
}
@@ -241,7 +241,7 @@ export default function usePantry(): {
241241
rv.push(proj)
242242
continue
243243
}
244-
const yaml = await proj.yaml().swallow()
244+
const yaml = await swallow(proj.yaml())
245245
if (!yaml) {
246246
console.warn("warn: parse failure:", pkg.project)
247247
} else if (yaml["display-name"]?.toLowerCase() == name) {
@@ -315,8 +315,7 @@ export function parse_pkgs_node(node: any): PackageRequirement[] {
315315
node = validate.obj(node)
316316
platform_reduce(node)
317317

318-
return Object.entries(node)
319-
.compact(([project, constraint]) =>
318+
return compact(Object.entries(node), ([project, constraint]) =>
320319
validatePackageRequirement(project, constraint))
321320
}
322321

src/hooks/useShellEnv.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import type { Installation } from "../types.ts"
2+
import { insert } from "../utils/misc.ts"
23
import usePantry from "./usePantry.ts"
34
import host from "../utils/host.ts"
45

@@ -64,7 +65,7 @@ async function map({installations}: Options): Promise<Record<string, string[]>>
6465

6566
for (const installation of installations) {
6667

67-
if (!seen.insert(installation.pkg.project).inserted) {
68+
if (!insert(seen, installation.pkg.project).inserted) {
6869
console.warn("pkgx: env is being duped:", installation.pkg.project)
6970
}
7071

src/plumbing/hydrate.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import type { PackageRequirement, Package } from "../types.ts"
2+
import { compact } from "../utils/misc.ts"
23
import * as semver from "../utils/semver.ts"
34
import usePantry from "../hooks/usePantry.ts"
45
import { is_what } from "../deps.ts"
@@ -144,7 +145,7 @@ export default async function hydrate(
144145
pkgs.push(...additional)
145146

146147
//TODO strictly we need to record precisely the bootstrap version constraint
147-
const bootstrap_required = new Set(pkgs.compact(({project}) => bootstrap.has(project) && project))
148+
const bootstrap_required = new Set(compact(pkgs, ({project}) => bootstrap.has(project) && project))
148149

149150
return {
150151
pkgs,

0 commit comments

Comments
 (0)