Skip to content

Commit

Permalink
Merge branch 'main' into fix-pantry-not-found
Browse files Browse the repository at this point in the history
  • Loading branch information
felipecrs authored Jan 4, 2025
2 parents 96e63ca + f28d931 commit 25b2c47
Show file tree
Hide file tree
Showing 34 changed files with 244 additions and 87 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,9 @@ jobs:

# we would prefer this, but our pkging is not stable enough :/
# - uses: pkgxdev/dev@v0
- uses: denoland/setup-deno@v1
- uses: denoland/setup-deno@v2
with:
deno-version: ~1.45
deno-version: ^2.0.2

- run: deno task compile

Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/ci.shellcode.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ jobs:
compile:
runs-on: ubuntu-latest
steps:
- uses: denoland/setup-deno@v1
- uses: denoland/setup-deno@v2
with:
deno-version: ~1.45
deno-version: ^2.0.2
- uses: actions/checkout@v4
- run: deno task compile
- uses: actions/upload-artifact@v4
Expand Down
12 changes: 6 additions & 6 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@ jobs:
if: ${{ matrix.os == 'ubuntu-latest' }}

- uses: actions/checkout@v4
- uses: denoland/setup-deno@v1 # using ourself to install deno could compromise the tests
- uses: denoland/setup-deno@v2 # using ourself to install deno could compromise the tests
with:
deno-version: ~1.45
deno-version: ^2.0.2
- run: deno cache **/*.test.ts
- run: deno task test --coverage=cov_profile --no-check
- run: deno coverage cov_profile --lcov --exclude=tests/ --output=cov_profile.lcov
Expand All @@ -57,16 +57,16 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: denoland/setup-deno@v1 # using ourself to install deno could compromise the tests
- uses: denoland/setup-deno@v2 # using ourself to install deno could compromise the tests
with:
deno-version: ~1.45
deno-version: ^2.0.2
- run: deno lint

typecheck:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: denoland/setup-deno@v1
- uses: denoland/setup-deno@v2
with:
deno-version: ~1.45
deno-version: ^2.0.2
- run: deno task typecheck
30 changes: 16 additions & 14 deletions deno.jsonc
Original file line number Diff line number Diff line change
@@ -1,39 +1,41 @@
{
"compilerOptions": {
"allowJs": false,
"strict": true
},
"tasks": {
// runs this source checkout, args will be passed
"run": "deno run --unstable-fs --unstable-ffi --unstable-process -A ./entrypoint.ts",
"run": "deno run --allow-all ./entrypoint.ts",

// you can specify paths to specific tests if you need
// follows is the ideal permissions lines, unfortunately deno considers making symlinks to require full read/write permissions for fuck knows why reasons
//"test": "deno test --allow-read=$PWD,$TMPDIR,$HOME,/ --allow-env --allow-write=$TMPDIR --allow-ffi --unstable",
"test": "deno test --unstable-ffi --allow-ffi --allow-read --allow-env --allow-write",
// ^^ ffi & unstable needed for execve.ts
"test": "deno test --allow-all",

// installs to /usr/local/bin/pkgx
"install": "deno task compile && ./pkgx +gnu.org/coreutils /usr/bin/sudo install -D ./pkgx /usr/local/bin/pkgx",

//--------------------------------------- ci/cd/admin
"coverage": "scripts/run-coverage.sh",
"typecheck": "deno check ./entrypoint.ts",
"compile": "deno compile --lock=deno.lock --allow-read --allow-write --allow-net --allow-run --allow-env --allow-ffi --unstable-ffi --unstable-fs --unstable-process --output \"$INIT_CWD/pkgx\" ./entrypoint.ts"
"compile": "deno compile --lock=deno.lock --allow-all --output \"$INIT_CWD/pkgx\" ./entrypoint.ts"
},
"pkgx": "deno~1.45",
"pkgx": "deno~2.0",
"lint": {
"exclude": ["src/**/*.test.ts"]
},
"fmt": {
"semiColons": false
"semiColons": false
},
"imports": {
"@cliffy/ansi": "jsr:@cliffy/ansi@^1.0.0-rc.7",
"@std/assert": "jsr:@std/assert@^1.0.6",
"@std/fmt": "jsr:@std/fmt@^1.0.2",
"@std/io": "jsr:@std/io@^0.225.0",
"@std/jsonc": "jsr:@std/jsonc@^1.0.1",
"@std/path": "jsr:@std/path@^1.0.6",
"@std/testing": "jsr:@std/testing@^1.0.3",
"@std/yaml": "jsr:@std/yaml@^1.0.5",
"is-what": "https://deno.land/x/[email protected]/src/index.ts",
"pkgx": "https://deno.land/x/[email protected]/mod.ts",
"pkgx/": "https://deno.land/x/[email protected]/src/",
"outdent": "https://deno.land/x/[email protected]/mod.ts",
"cliffy/": "https://deno.land/x/[email protected]/",
"deno/": "https://deno.land/[email protected]/"
"outdent": "jsr:@cspotcode/outdent@^0.8",
"pkgx": "https://deno.land/x/[email protected]/mod.ts",
"pkgx/": "https://deno.land/x/[email protected]/src/"
}
}
180 changes: 166 additions & 14 deletions deno.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion entrypoint.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
*/

import { render as perror } from "./src/err-handler.ts"
import { setColorEnabled } from "deno/fmt/colors.ts"
import { setColorEnabled } from "@std/fmt/colors"
import clicolor from "./src/utils/clicolor.ts"

setColorEnabled(clicolor(Deno.stderr))
Expand Down
4 changes: 2 additions & 2 deletions src/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ import internal_activate from "./modes/internal.activate.ts"
import shell_completion from "./modes/shell-completion.ts"
import parse_pkg_str from "./prefab/parse-pkg-str.ts"
import InstallLogger from "./utils/InstallLogger.ts"
import { setColorEnabled } from "deno/fmt/colors.ts"
import internal_use from "./modes/internal.use.ts"
import { Args as BaseArgs } from "./parse-args.ts"
import { setColorEnabled } from "@std/fmt/colors"
import { AmbiguityError } from "./utils/error.ts"
import integrate from "./modes/integrate.ts"
import uninstall from "./modes/uninstall.ts"
Expand Down Expand Up @@ -115,7 +115,7 @@ export default async function({ flags, ...opts }: Args, logger_prefix?: string)
const out = await env({pkgs, update, logger})
if (out.trim()) {
console.log(out)
} else {
} else if (!flags.sync) {
console.error("empty env, try `pkgx --help`")
}
} break
Expand Down
6 changes: 4 additions & 2 deletions src/err-handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { AmbiguityError, ProgrammerError, ProvidesError } from "./utils/error.ts
import announce from "./utils/announce.ts"
import { red } from "./utils/color.ts"

export default function(err: Error) {
export default function(err: unknown) {
if (err instanceof InstallationNotFoundError) {
const subtitle = utils.pkg.str(err.pkg)
render("not cached", subtitle, [], 'pkg-not-cached')
Expand Down Expand Up @@ -48,10 +48,12 @@ export default function(err: Error) {
render('programmer error', undefined, [['this is a bug, please report it']], 'https://github.com/pkgxdev/pkgx/issues/new')
} else if (err instanceof PkgxError) {
console.error('%c × %s', 'color: red', err.message)
} else {
} else if (err instanceof Error) {
const title = 'unexpected error'
const ctx = err.stack?.split('\n').map(x => [x]) ?? [['no stack trace']]
render(title, err.message, ctx, 'https://github.com/pkgxdev/pkgx/issues/new')
} else {
render('unknown error', `${err}`, [['no context']], 'https://github.com/pkgxdev/pkgx/issues/new')
}
return 1
}
Expand Down
4 changes: 2 additions & 2 deletions src/modes/env.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { null_logger as logger } from "../utils/test-utils.ts"
import { assertEquals } from "deno/assert/mod.ts"
import specimen, { _internals } from "./env.ts"
import * as mock from "deno/testing/mock.ts"
import { assertEquals } from "@std/assert"
import * as mock from "@std/testing/mock"
import { semver } from "pkgx"
import undent from "outdent"

Expand Down
2 changes: 1 addition & 1 deletion src/modes/install.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ export default async function(pkgs: PackageRequirement[], unsafe: boolean) {
rm -f ${programs.map(p => `'${p}'`).join(' ')} && echo "uninstalled: ${pkgstr}" >&2
fi`
}

const f = dst.mkdir('p').join(program)

if (f.exists()) {
Expand Down
6 changes: 3 additions & 3 deletions src/modes/integrate.test.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
// deno-lint-ignore-file no-explicit-any
import { afterEach, beforeEach, describe, afterAll, it } from "deno/testing/bdd.ts"
import { afterEach, beforeEach, describe, afterAll, it } from "@std/testing/bdd"
import specimen0, { _internals } from "./integrate.ts"
import { assertRejects } from "deno/assert/mod.ts"
import * as mock from "deno/testing/mock.ts"
import { assertRejects } from "@std/assert"
import * as mock from "@std/testing/mock"
import { isString } from "is-what"
import { Path } from "pkgx"

Expand Down
Loading

0 comments on commit 25b2c47

Please sign in to comment.