diff --git a/.github/workflows/publish-jsr.yml b/.github/workflows/publish-jsr.yml new file mode 100644 index 0000000..e9cbe07 --- /dev/null +++ b/.github/workflows/publish-jsr.yml @@ -0,0 +1,28 @@ +name: publish·jsr + +on: + release: + types: [published] + workflow_dispatch: + +concurrency: + group: publish/jsr/${{ github.ref }} + cancel-in-progress: true + +permissions: + contents: read + id-token: write # OIDC for tokenless JSR publish + +jobs: + publish: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: denoland/setup-deno@v2 + with: + deno-version: v2.x + - name: dry-run + run: deno publish --dry-run --allow-slow-types --no-check --unstable-fs --unstable-ffi + - name: publish + if: github.event_name == 'release' || github.event_name == 'workflow_dispatch' + run: deno publish --allow-slow-types --no-check --unstable-fs --unstable-ffi diff --git a/README.md b/README.md index 7c4dd07..a9772cb 100644 --- a/README.md +++ b/README.md @@ -16,12 +16,14 @@ $ npm install libpkgx # ^^ https://npmjs.com/libpkgx ``` -Or with [Deno]: +Or with [Deno] via [JSR](https://jsr.io): ```ts -import * as pkgx from "https://deno.land/x/libpkgx/mod.ts" +import * as pkgx from "jsr:@pkgx/libpkgx" ``` +> `deno.land/x/libpkgx` is frozen (registry is read-only). Use JSR for new versions. + ## Usage ```ts diff --git a/deno.json b/deno.json index f665bcb..c1c25fa 100644 --- a/deno.json +++ b/deno.json @@ -1,16 +1,53 @@ { + "name": "@pkgx/libpkgx", + "version": "0.23.0", + "license": "Apache-2.0", + "exports": { + ".": "./mod.ts", + "./hooks/useConfig.ts": "./src/hooks/useConfig.ts", + "./hooks/usePantry.ts": "./src/hooks/usePantry.ts", + "./utils/error.ts": "./src/utils/error.ts", + "./utils/host.ts": "./src/utils/host.ts", + "./utils/read-lines.ts": "./src/utils/read-lines.ts", + "./utils/semver.ts": "./src/utils/semver.ts", + "./plumbing/hydrate.ts": "./src/plumbing/hydrate.ts" + }, + "publish": { + "include": [ + "LICENSE.txt", + "README.md", + "mod.ts", + "src/**/*.ts", + "vendor/**" + ], + "exclude": [ + "src/**/*.test.ts", + "src/hooks/useTestConfig.ts", + "fixtures", + "examples", + "scripts", + "dist", + ".github" + ] + }, "compilerOptions": { - "allowJs": false, "strict": true }, "pkgx": "deno~2.0", "tasks": { "test": "deno test --parallel --unstable-fs --unstable-ffi --allow-all", - "typecheck": "deno check ./mod.ts" + "typecheck": "deno check ./mod.ts", + "publish:dry": "deno publish --dry-run --allow-slow-types --no-check --allow-dirty --unstable-fs --unstable-ffi" }, "lint": { - "include": ["src/"], - "exclude": ["**/*.test.ts"] + "include": ["src/", "mod.ts"], + "exclude": ["**/*.test.ts", "vendor/", "src/hooks/useTestConfig.ts"], + "rules": { + // Prototype extensions (Array.compact, Promise.swallow, etc.) use + // `declare global`, which JSR forbids without --allow-slow-types. + // Explicit public return types are fixed; globals are a larger refactor. + "exclude": ["no-slow-types"] + } }, "test": { "include": ["src/"], @@ -18,8 +55,15 @@ }, "imports": { "@std/assert": "jsr:@std/assert@^1.0.6", + "@std/crypto": "jsr:@std/crypto@^1", + "@std/encoding": "jsr:@std/encoding@^1", + "@std/fs": "jsr:@std/fs@^1", + "@std/io": "jsr:@std/io@^0.225.0", + "@std/io/write-all": "jsr:@std/io@^0.225.0/write-all", + "@std/path": "jsr:@std/path@^1", "@std/testing": "jsr:@std/testing@^1.0.3", - "is-what": "https://deno.land/x/is_what@v4.1.15/src/index.ts", - "outdent": "https://deno.land/x/outdent@v0.8.0/mod.ts" + "@std/yaml": "jsr:@std/yaml@^1", + "is-what": "npm:is-what@4.1.15", + "outdent": "npm:outdent@0.8.0" } } diff --git a/mod.ts b/mod.ts index 7dc61e9..723da6b 100644 --- a/mod.ts +++ b/mod.ts @@ -1,7 +1,8 @@ import "./src/utils/misc.ts" import { flatmap, validate } from "./src/utils/misc.ts" -import host, { SupportedArchitecture, SupportedPlatform } from "./src/utils/host.ts" +import host from "./src/utils/host.ts" +import type { SupportedArchitecture, SupportedPlatform } from "./src/utils/host.ts" import SemVer, * as semver from "./src/utils/semver.ts" import Path from "./src/utils/Path.ts" diff --git a/src/deps.ts b/src/deps.ts index 42d1d1a..4a6d35a 100644 --- a/src/deps.ts +++ b/src/deps.ts @@ -1,18 +1,18 @@ -import * as is_what from "https://deno.land/x/is_what@v4.1.15/src/index.ts" +import * as is_what from "is-what" export { is_what } -import { type PlainObject } from "https://deno.land/x/is_what@v4.1.15/src/index.ts" +import type { PlainObject } from "is-what" export type { PlainObject } -import * as outdent from "https://deno.land/x/outdent@v0.8.0/mod.ts" +import * as outdent from "outdent" export { outdent } // importing super specifically to reduce final npm bundle size -import * as crypto from "jsr:@std/crypto@1" -import { moveSync } from "jsr:@std/fs@1" -import { writeAll } from "jsr:@std/io@^0.225.0" -import { parse as parseYaml, parseAll as parseYamlALL } from "jsr:@std/yaml@1" -import { SEPARATOR as SEP, fromFileUrl } from "jsr:@std/path@1" +import * as crypto from "@std/crypto" +import { moveSync } from "@std/fs" +import { writeAll } from "@std/io/write-all" +import { parse as parseYaml, parseAll as parseYamlALL } from "@std/yaml" +import { SEPARATOR as SEP, fromFileUrl } from "@std/path" const streams = { writeAll } const fs = { moveSync } diff --git a/src/hooks/useCache.ts b/src/hooks/useCache.ts index bf83809..9183b9a 100644 --- a/src/hooks/useCache.ts +++ b/src/hooks/useCache.ts @@ -1,12 +1,13 @@ -import { Stowage } from "../types.ts" +import type { Stowage } from "../types.ts" import useConfig from "./useConfig.ts" import host from "../utils/host.ts" +import type Path from "../utils/Path.ts" -export default function useCache() { +export default function useCache(): { path: (stowage: Stowage) => Path } { return { path } } -const path = (stowage: Stowage) => { +const path = (stowage: Stowage): Path => { const { pkg, type } = stowage const stem = pkg.project.replaceAll("/", "∕") diff --git a/src/hooks/useCellar.ts b/src/hooks/useCellar.ts index c63933f..6a80c2b 100644 --- a/src/hooks/useCellar.ts +++ b/src/hooks/useCellar.ts @@ -1,4 +1,4 @@ -import { Package, PackageRequirement, Installation } from "../types.ts" +import type { Package, PackageRequirement, Installation } from "../types.ts" import { PkgxError } from "../utils/error.ts" import * as pkgutils from "../utils/pkg.ts" import SemVer from "../utils/semver.ts" @@ -14,7 +14,15 @@ export class InstallationNotFoundError extends PkgxError { } } -export default function useCellar() { +export type UseCellar = { + has: (pkg: Package | PackageRequirement | Path) => Promise + ls: (project: string) => Promise + keg: (pkg: Package) => Path + resolve: (pkg: Package | PackageRequirement | Path | Installation) => Promise + shelf: (project: string) => Path +} + +export default function useCellar(): UseCellar { const config = useConfig() /// eg. ~/.pkgx/deno.land diff --git a/src/hooks/useConfig.ts b/src/hooks/useConfig.ts index aa1adbd..70310d7 100644 --- a/src/hooks/useConfig.ts +++ b/src/hooks/useConfig.ts @@ -49,7 +49,7 @@ function platform_data_home_default(home: Path, { LOCALAPPDATA }: { LOCALAPPDATA const SEP = Deno.build.os == 'windows' ? ';' : ':' -export function ConfigDefault(env = Deno.env.toObject()): Config { +export function ConfigDefault(env: Record = Deno.env.toObject()): Config { const home = flatmap(env['PKGX_HOME'], x => new Path(x)) ?? Path.home() const prefix = flatmap(env['PKGX_DIR']?.trim(), x => new Path(x)) ?? flatmap(env['XDG_DATA_HOME'], x => new Path(x).join("pkgx")) ?? @@ -115,7 +115,7 @@ function boolize(input: string | undefined): boolean | undefined { } } -function initialized() { +function initialized(): boolean { return gt.sh_pkgx_config !== undefined } diff --git a/src/hooks/useDownload.ts b/src/hooks/useDownload.ts index 21128be..84ce367 100644 --- a/src/hooks/useDownload.ts +++ b/src/hooks/useDownload.ts @@ -1,7 +1,7 @@ import { deno } from "../deps.ts" const { crypto: crypto_, streams: { writeAll } } = deno const { crypto } = crypto_ -import { encodeHex } from "jsr:@std/encoding@1" +import { encodeHex } from "@std/encoding" import { PkgxError, panic } from "../utils/error.ts" import useConfig from "./useConfig.ts" import useFetch from "./useFetch.ts" @@ -80,7 +80,10 @@ function cache({ for: url }: {for: URL}): Path { } } -export default function useDownload() { +export default function useDownload(): { + download: typeof download + cache: typeof cache +} { return { download, cache diff --git a/src/hooks/useInventory.ts b/src/hooks/useInventory.ts index 95592db..cd872ff 100644 --- a/src/hooks/useInventory.ts +++ b/src/hooks/useInventory.ts @@ -1,4 +1,4 @@ -import { Package, PackageRequirement } from "../types.ts" +import type { Package, PackageRequirement } from "../types.ts" import { DownloadError } from "./useDownload.ts" import SemVer from "../utils/semver.ts" import useFetch from "./useFetch.ts" @@ -14,7 +14,7 @@ export interface Inventory { } } -const select = async (rq: PackageRequirement | Package) => { +const select = async (rq: PackageRequirement | Package): Promise => { const versions = await _internals.get(rq) if ("constraint" in rq) { @@ -24,7 +24,7 @@ const select = async (rq: PackageRequirement | Package) => { } } -const get = async (rq: PackageRequirement | Package) => { +const get = async (rq: PackageRequirement | Package): Promise => { const { platform, arch } = host() const url = new URL(`${useConfig().dist}/${rq.project}/${platform}/${arch}/versions.txt`) const rsp = await useFetch(url) @@ -47,7 +47,10 @@ const get = async (rq: PackageRequirement | Package) => { return versions } -export default function useInventory() { +export default function useInventory(): { + select: typeof select + get: typeof get +} { return { select, get } } diff --git a/src/hooks/useMoustaches.ts b/src/hooks/useMoustaches.ts index 116cbf7..f57bf74 100644 --- a/src/hooks/useMoustaches.ts +++ b/src/hooks/useMoustaches.ts @@ -1,13 +1,13 @@ -import { Package, Installation } from "../types.ts" -import SemVer from "../utils/semver.ts" +import type { Package, Installation } from "../types.ts" +import type SemVer from "../utils/semver.ts" import useConfig from "./useConfig.ts" import useCellar from "./useCellar.ts" -function tokenizePackage(pkg: Package) { +function tokenizePackage(pkg: Package): { from: string, to: string }[] { return [{ from: "prefix", to: useCellar().keg(pkg).string }] } -function tokenizeVersion(version: SemVer, prefix = 'version') { +function tokenizeVersion(version: SemVer, prefix = 'version'): { from: string, to: string }[] { const rv = [ { from: prefix, to: `${version}` }, { from: `${prefix}.major`, to: `${version.major}` }, @@ -23,13 +23,22 @@ function tokenizeVersion(version: SemVer, prefix = 'version') { return rv } -function apply(input: string, map: { from: string, to: string }[]) { +function apply(input: string, map: { from: string, to: string }[]): string { return map.reduce((acc, {from, to}) => acc.replace(new RegExp(`(^\\$)?{{\\s*${from}\\s*}}`, "g"), to), input) } -export default function() { +export default function(): { + apply: typeof apply + tokenize: { + version: typeof tokenizeVersion + pkg: typeof tokenizePackage + deps: (deps: Installation[]) => { from: string, to: string }[] + pkgx: () => { from: string, to: string }[] + all: (pkg: Package, deps_: Installation[]) => { from: string, to: string }[] + } +} { const config = useConfig() const base = { apply, diff --git a/src/hooks/useOffLicense.ts b/src/hooks/useOffLicense.ts index a160e1b..9f4e3d2 100644 --- a/src/hooks/useOffLicense.ts +++ b/src/hooks/useOffLicense.ts @@ -1,14 +1,17 @@ -import { Stowage } from "../types.ts" +import type { Stowage } from "../types.ts" import host from "../utils/host.ts" import useConfig from "./useConfig.ts"; type Type = 's3' -export default function useOffLicense(_type: Type) { +export default function useOffLicense(_type: Type): { + url: typeof url + key: typeof key +} { return { url, key } } -function key(stowage: Stowage) { +function key(stowage: Stowage): string { const rv = [stowage.pkg.project] if (stowage.type == 'bottle') { const { platform, arch } = stowage.host ?? host() @@ -24,6 +27,6 @@ function key(stowage: Stowage) { return rv.join("/") } -function url(stowage: Stowage) { +function url(stowage: Stowage): URL { return new URL(`${useConfig().dist}/${key(stowage)}`) } diff --git a/src/hooks/usePantry.ts b/src/hooks/usePantry.ts index f8d6ec8..e9d4f5e 100644 --- a/src/hooks/usePantry.ts +++ b/src/hooks/usePantry.ts @@ -1,8 +1,9 @@ -import { is_what, PlainObject } from "../deps.ts" +import { is_what, type PlainObject } from "../deps.ts" const { isNumber, isPlainObject, isString, isArray, isPrimitive, isBoolean } = is_what -import { Package, Installation, PackageRequirement } from "../types.ts" +import type { Package, Installation, PackageRequirement } from "../types.ts" import { provides as cache_provides, available as cache_available, runtime_env as cache_runtime_env, companions as cache_companions, dependencies as cache_dependencies } from "./useSyncCache.ts"; -import SemVer, * as semver from "../utils/semver.ts" +import type SemVer from "../utils/semver.ts" +import * as semver from "../utils/semver.ts" import useMoustaches from "./useMoustaches.ts" import { PkgxError } from "../utils/error.ts" import { validate } from "../utils/misc.ts" @@ -45,7 +46,30 @@ export class PantryNotFoundError extends PantryError { } } -export default function usePantry() { +export interface PantryProject { + project: string + companions: () => Promise + runtime: { + env: (version: SemVer, deps: Installation[]) => Promise> + deps: () => Promise + } + available: () => Promise + provides: () => Promise + provider: () => Promise<((binname: string) => string[] | undefined) | undefined> + yaml: () => Promise +} + +export default function usePantry(): { + prefix: Path + which: (opts: { interprets: string }) => Promise + ls: () => AsyncGenerator<{ project: string; path: Path }> + project: (input: string | { project: string }) => PantryProject + find: (name: string) => Promise> + parse_pkgs_node: (node: unknown) => PackageRequirement[] + expand_env_obj: (env: PlainObject, pkg: Package, deps: Installation[]) => Record + missing: () => boolean + pantry_paths: () => Path[] +} { const prefix = useConfig().data.join("pantry/projects") const is_cache_available = cache_available() && pantry_paths().length == 1 @@ -168,6 +192,7 @@ export default function usePantry() { } return { + project, companions, runtime: { env: runtime_env, @@ -285,7 +310,7 @@ export default function usePantry() { } // deno-lint-ignore no-explicit-any -export function parse_pkgs_node(node: any) { +export function parse_pkgs_node(node: any): PackageRequirement[] { if (!node) return [] node = validate.obj(node) platform_reduce(node) diff --git a/src/hooks/useShellEnv.ts b/src/hooks/useShellEnv.ts index efc5ba3..21919c2 100644 --- a/src/hooks/useShellEnv.ts +++ b/src/hooks/useShellEnv.ts @@ -1,4 +1,4 @@ -import { Installation } from "../types.ts" +import type { Installation } from "../types.ts" import usePantry from "./usePantry.ts" import host from "../utils/host.ts" @@ -38,7 +38,11 @@ interface Options { installations: Installation[] } -export default function() { +export default function(): { + map: (opts: Options) => Promise> + expand: (env: Record) => string + flatten: (env: Record) => Record +} { return { map, expand, @@ -160,7 +164,7 @@ function suffixes(key: EnvKey) { }} } -export function expand(env: Record) { +export function expand(env: Record): string { let rv = '' for (const [key, value] of Object.entries(env)) { if (value.length == 0) continue @@ -169,7 +173,7 @@ export function expand(env: Record) { return rv } -export function flatten(env: Record) { +export function flatten(env: Record): Record { const SEP = Deno.build.os == 'windows' ? ';' : ':' const rv: Record = {} for (const [key, value] of Object.entries(env)) { diff --git a/src/hooks/useSync.ts b/src/hooks/useSync.ts index 2dae8d0..17d5484 100644 --- a/src/hooks/useSync.ts +++ b/src/hooks/useSync.ts @@ -2,7 +2,7 @@ import { flock } from "../utils/flock.ts" import useDownload from "./useDownload.ts" import usePantry from "./usePantry.ts" import useConfig from "./useConfig.ts" -import Path from "../utils/Path.ts" +import type Path from "../utils/Path.ts" import useSyncCache from "./useSyncCache.ts"; //FIXME tar is fetched from PATH :/ we want control diff --git a/src/hooks/useSyncCache.ts b/src/hooks/useSyncCache.ts index 901d958..705c222 100644 --- a/src/hooks/useSyncCache.ts +++ b/src/hooks/useSyncCache.ts @@ -177,7 +177,7 @@ async function _db() { import install from "../porcelain/install.ts" import host from "../utils/host.ts"; -import Path from "../utils/Path.ts"; +import type Path from "../utils/Path.ts"; import { semver } from "../../mod.ts"; async function install_sqlite(): Promise { diff --git a/src/plumbing/hydrate.ts b/src/plumbing/hydrate.ts index 0174491..6596a7a 100644 --- a/src/plumbing/hydrate.ts +++ b/src/plumbing/hydrate.ts @@ -1,4 +1,4 @@ -import { PackageRequirement, Package } from "../types.ts" +import type { PackageRequirement, Package } from "../types.ts" import * as semver from "../utils/semver.ts" import usePantry from "../hooks/usePantry.ts" import { is_what } from "../deps.ts" @@ -19,7 +19,7 @@ const { isArray } = is_what /// - unicode.org: ICU major ABI (see pantry#4104, pkgx#899) /// - openssl.org: libssl.so.1.1 vs libssl.so.3 /// - abseil.io: LTS inline-namespace + soversion (20250127 vs 20250512, …) -export const MULTI_VERSION_PROJECTS = new Set([ +export const MULTI_VERSION_PROJECTS: Set = new Set([ "unicode.org", "openssl.org", "abseil.io", diff --git a/src/plumbing/install.ts b/src/plumbing/install.ts index 007df42..e3ea8a6 100644 --- a/src/plumbing/install.ts +++ b/src/plumbing/install.ts @@ -1,4 +1,4 @@ -import { Package, Installation, StowageNativeBottle } from "../types.ts" +import { type Package, type Installation, StowageNativeBottle } from "../types.ts" import useOffLicense from "../hooks/useOffLicense.ts" import useDownload, { DownloadError } from "../hooks/useDownload.ts" import { flock } from "../utils/flock.ts" diff --git a/src/plumbing/link.ts b/src/plumbing/link.ts index f157336..6896203 100644 --- a/src/plumbing/link.ts +++ b/src/plumbing/link.ts @@ -1,9 +1,10 @@ -import SemVer, * as semver from "../utils/semver.ts" -import { Package, Installation } from "../types.ts" +import type SemVer from "../utils/semver.ts" +import * as semver from "../utils/semver.ts" +import type { Package, Installation } from "../types.ts" import useCellar from "../hooks/useCellar.ts" import { panic } from "../utils/error.ts" import fs from "node:fs/promises" -import Path from "../utils/Path.ts" +import type Path from "../utils/Path.ts" export default async function link(pkg: Package | Installation) { const installation = await useCellar().resolve(pkg) diff --git a/src/plumbing/resolve.ts b/src/plumbing/resolve.ts index aaefc60..e00c903 100644 --- a/src/plumbing/resolve.ts +++ b/src/plumbing/resolve.ts @@ -1,4 +1,4 @@ -import { Package, PackageRequirement, Installation } from "../types.ts" +import type { Package, PackageRequirement, Installation } from "../types.ts" import useInventory from "../hooks/useInventory.ts" import { str as pkgstr } from "../utils/pkg.ts" import useCellar from "../hooks/useCellar.ts" diff --git a/src/plumbing/which.ts b/src/plumbing/which.ts index a63568a..a3f69f3 100644 --- a/src/plumbing/which.ts +++ b/src/plumbing/which.ts @@ -1,6 +1,6 @@ import { provides as cache_provides, available as cache_available } from "../hooks/useSyncCache.ts" import usePantry, { PantryError } from "../hooks/usePantry.ts" -import { PackageRequirement } from "../types.ts" +import type { PackageRequirement } from "../types.ts" import * as semver from "../utils/semver.ts" export type WhichResult = PackageRequirement & { diff --git a/src/porcelain/install.ts b/src/porcelain/install.ts index 02cefe2..3809209 100644 --- a/src/porcelain/install.ts +++ b/src/porcelain/install.ts @@ -1,6 +1,6 @@ -import install, { Logger as BaseLogger, ConsoleLogger as BaseConsoleLogger } from "../plumbing/install.ts" -import { Installation, PackageSpecification } from "../types.ts" -import resolve, { Resolution } from "../plumbing/resolve.ts" +import install, { type Logger as BaseLogger, ConsoleLogger as BaseConsoleLogger } from "../plumbing/install.ts" +import type { Installation, PackageSpecification } from "../types.ts" +import resolve, { type Resolution } from "../plumbing/resolve.ts" import usePantry from "../hooks/usePantry.ts" import hydrate from "../plumbing/hydrate.ts" import useSync from "../hooks/useSync.ts" diff --git a/src/porcelain/run.test.ts b/src/porcelain/run.test.ts index 8417d0d..000bd84 100644 --- a/src/porcelain/run.test.ts +++ b/src/porcelain/run.test.ts @@ -1,6 +1,6 @@ import { useTestConfig } from "../hooks/useTestConfig.ts" import { assertEquals, assertRejects } from "@std/assert" -import undent from "outdent" +import { outdent as undent } from "outdent" import run from "./run.ts" Deno.test("porcelain.run", async runner => { diff --git a/src/porcelain/run.ts b/src/porcelain/run.ts index e98d15b..0582ce8 100644 --- a/src/porcelain/run.ts +++ b/src/porcelain/run.ts @@ -1,4 +1,4 @@ -import install, { Logger } from "../plumbing/install.ts" +import install, { type Logger } from "../plumbing/install.ts" import useShellEnv from '../hooks/useShellEnv.ts' import usePantry from '../hooks/usePantry.ts' import hydrate from "../plumbing/hydrate.ts" @@ -9,7 +9,7 @@ import useSync from "../hooks/useSync.ts" import which from "../plumbing/which.ts" import link from "../plumbing/link.ts" import { is_what } from "../deps.ts" -import Path from "../utils/Path.ts" +import type Path from "../utils/Path.ts" const { isArray } = is_what interface OptsEx { diff --git a/src/types.ts b/src/types.ts index 4adc232..f7b0bbb 100644 --- a/src/types.ts +++ b/src/types.ts @@ -1,6 +1,7 @@ -import host, { SupportedPlatform, SupportedArchitecture } from "./utils/host.ts" -import SemVer, { Range } from "./utils/semver.ts" -import Path from "./utils/Path.ts" +import host, { type SupportedPlatform, type SupportedArchitecture } from "./utils/host.ts" +import type SemVer from "./utils/semver.ts" +import type { Range } from "./utils/semver.ts" +import type Path from "./utils/Path.ts" export interface Package { project: string diff --git a/src/utils/Path.ts b/src/utils/Path.ts index 619411b..bde2da2 100644 --- a/src/utils/Path.ts +++ b/src/utils/Path.ts @@ -1,4 +1,4 @@ -import { deno, PlainObject } from "../deps.ts" +import { deno, type PlainObject } from "../deps.ts" import readLines from "./read-lines.ts" import { mkdtempSync } from "node:fs" import * as sys from "node:path" @@ -25,7 +25,7 @@ export default class Path { readonly string: string /// the filesystem root - static root = new Path("/") + static root: Path = new Path("/") static cwd(): Path { return new Path(Deno.cwd()) @@ -95,7 +95,7 @@ export default class Path { } /// returns Path | undefined rather than throwing error if Path is not absolute - static abs(input: string | Path) { + static abs(input: string | Path): Path | undefined { try { return new Path(input) } catch { @@ -336,7 +336,7 @@ export default class Path { return dst } - rm({recursive} = {recursive: false}) { + rm({recursive}: { recursive?: boolean } = {recursive: false}): Path { if (this.exists()) { try { Deno.removeSync(this.string, { recursive }) @@ -506,7 +506,7 @@ export default class Path { return this.string.startsWith(cwd.string) ? `./${this.relative({ to: cwd })}` : this.prettyString() } - [Symbol.for("Deno.customInspect")]() { + [Symbol.for("Deno.customInspect")](): string { return this.prettyString() } } diff --git a/src/utils/flock.ts b/src/utils/flock.ts index bd7570b..3f73061 100644 --- a/src/utils/flock.ts +++ b/src/utils/flock.ts @@ -1,4 +1,4 @@ -import Path from "./Path.ts" +import type Path from "./Path.ts" export async function flock(path: Path) { let opts: Deno.OpenOptions | undefined diff --git a/src/utils/misc.ts b/src/utils/misc.ts index a51dd85..effd242 100644 --- a/src/utils/misc.ts +++ b/src/utils/misc.ts @@ -1,6 +1,6 @@ //CONTRACT you can’t use anything from hooks -import { is_what, PlainObject } from "../deps.ts" +import { is_what, type PlainObject } from "../deps.ts" const { isPlainObject, isArray } = is_what function validate_str(input: unknown): string { diff --git a/src/utils/pkg.ts b/src/utils/pkg.ts index 9118d31..93c09b6 100644 --- a/src/utils/pkg.ts +++ b/src/utils/pkg.ts @@ -1,4 +1,4 @@ -import { Package, PackageRequirement } from "../types.ts" +import type { Package, PackageRequirement } from "../types.ts" import * as semver from "./semver.ts" /// allows inputs `nodejs.org@16` when `semver.parse` would reject diff --git a/src/utils/semver.ts b/src/utils/semver.ts index ec365e9..7d617bd 100644 --- a/src/utils/semver.ts +++ b/src/utils/semver.ts @@ -98,14 +98,14 @@ export default class SemVer { return _compare(this, that) } - [Symbol.for("Deno.customInspect")]() { + [Symbol.for("Deno.customInspect")](): string { return this.toString() } } /// the same as the constructor but swallows the error returning undefined instead /// also slightly more tolerant parsing -export function parse(input: string) { +export function parse(input: string): SemVer | undefined { try { return new SemVer(input) } catch { @@ -114,7 +114,7 @@ export function parse(input: string) { } /// determines if the input is in fact a valid semantic version -export function isValid(input: string) { +export function isValid(input: string): boolean { return parse(input) !== undefined } @@ -311,7 +311,7 @@ export class Range { return Array.isArray(this.set[0]) ? undefined : this.set[0] } - [Symbol.for("Deno.customInspect")]() { + [Symbol.for("Deno.customInspect")](): string { return this.toString() } } diff --git a/vendor/sqlite3@0.10.0/mod.ts b/vendor/sqlite3@0.10.0/mod.ts index 26b5bce..73dc104 100644 --- a/vendor/sqlite3@0.10.0/mod.ts +++ b/vendor/sqlite3@0.10.0/mod.ts @@ -1,3 +1,4 @@ +// @ts-nocheck export * from "./src/database.ts"; export * from "./src/statement.ts"; export { SqliteError } from "./src/util.ts"; diff --git a/vendor/sqlite3@0.10.0/src/constants.ts b/vendor/sqlite3@0.10.0/src/constants.ts index aa67db7..6b9bd77 100644 --- a/vendor/sqlite3@0.10.0/src/constants.ts +++ b/vendor/sqlite3@0.10.0/src/constants.ts @@ -1,3 +1,4 @@ +// @ts-nocheck // Result Codes export const SQLITE3_OK = 0; export const SQLITE3_ERROR = 1; diff --git a/vendor/sqlite3@0.10.0/src/database.ts b/vendor/sqlite3@0.10.0/src/database.ts index ace52fd..26a7f76 100644 --- a/vendor/sqlite3@0.10.0/src/database.ts +++ b/vendor/sqlite3@0.10.0/src/database.ts @@ -1,3 +1,4 @@ +// @ts-nocheck import ffi from "./ffi.ts"; import { deno } from "../../../src/deps.ts"; import { diff --git a/vendor/sqlite3@0.10.0/src/ffi.ts b/vendor/sqlite3@0.10.0/src/ffi.ts index d32ecba..41f78df 100644 --- a/vendor/sqlite3@0.10.0/src/ffi.ts +++ b/vendor/sqlite3@0.10.0/src/ffi.ts @@ -1,3 +1,4 @@ +// @ts-nocheck const symbols = { sqlite3_open_v2: { parameters: [ diff --git a/vendor/sqlite3@0.10.0/src/statement.ts b/vendor/sqlite3@0.10.0/src/statement.ts index 7ae80e4..e77f183 100644 --- a/vendor/sqlite3@0.10.0/src/statement.ts +++ b/vendor/sqlite3@0.10.0/src/statement.ts @@ -1,3 +1,4 @@ +// @ts-nocheck import type { Database } from "./database.ts"; import { readCstr, toCString, unwrap } from "./util.ts"; import ffi from "./ffi.ts"; diff --git a/vendor/sqlite3@0.10.0/src/util.ts b/vendor/sqlite3@0.10.0/src/util.ts index 69b7983..94e5766 100644 --- a/vendor/sqlite3@0.10.0/src/util.ts +++ b/vendor/sqlite3@0.10.0/src/util.ts @@ -1,3 +1,4 @@ +// @ts-nocheck import { SQLITE3_DONE, SQLITE3_MISUSE, SQLITE3_OK } from "./constants.ts"; import ffi from "./ffi.ts";