Skip to content

Commit

Permalink
deno^2
Browse files Browse the repository at this point in the history
  • Loading branch information
mxcl committed Oct 23, 2024
1 parent a4941fc commit a8e2a62
Show file tree
Hide file tree
Showing 33 changed files with 237 additions and 81 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ jobs:
# - uses: pkgxdev/dev@v0
- uses: denoland/setup-deno@v1
with:
deno-version: ~1.45
deno-version: ^2.0.2

- run: deno task compile

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/ci.shellcode.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
steps:
- uses: denoland/setup-deno@v1
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
6 changes: 3 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ jobs:
- uses: actions/checkout@v4
- uses: denoland/setup-deno@v1 # 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 @@ -59,7 +59,7 @@ jobs:
- uses: actions/checkout@v4
- uses: denoland/setup-deno@v1 # using ourself to install deno could compromise the tests
with:
deno-version: ~1.45
deno-version: ^2.0.2
- run: deno lint

typecheck:
Expand All @@ -68,5 +68,5 @@ jobs:
- uses: actions/checkout@v4
- uses: denoland/setup-deno@v1
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",
"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/is_what@v4.1.15/src/index.ts",
"pkgx": "https://deno.land/x/libpkgx@v0.19.1/mod.ts",
"pkgx/": "https://deno.land/x/libpkgx@v0.19.1/src/",
"outdent": "https://deno.land/x/outdent@v0.8.0/mod.ts",
"cliffy/": "https://deno.land/x/cliffy@v1.0.0-rc.4/",
"deno/": "https://deno.land/std@0.224.0/"
"outdent": "jsr:@cspotcode/outdent@^0.8",
"pkgx": "https://deno.land/x/libpkgx@v0.20.0/mod.ts",
"pkgx/": "https://deno.land/x/libpkgx@v0.20.0/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
2 changes: 1 addition & 1 deletion 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
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
6 changes: 3 additions & 3 deletions src/modes/integrate.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { writeAll } from "deno/io/write_all.ts"
import { readAll } from "deno/io/read_all.ts"
import { readLines } from "deno/io/read_lines.ts"
import readLines from "pkgx/utils/read-lines.ts"
import { Path, PkgxError, utils } from "pkgx"
import announce from "../utils/announce.ts"
import shellcode from "./shellcode.ts"
import { writeAll } from "@std/io"
import { readAll } from "@std/io"
const { flatmap, host } = utils

//TODO could be a fun efficiency excercise to maintain a separate write file-pointer
Expand Down
4 changes: 2 additions & 2 deletions src/modes/internal.activate.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
import { fixturesd, null_logger as logger } from "../utils/test-utils.ts"
import { _internals as _devenv_internals } from "../utils/devenv.ts"
import specimen0, { _internals } from "./internal.activate.ts"
import { assertEquals, assertRejects } from "deno/assert/mod.ts"
import * as mock from "deno/testing/mock.ts"
import { assertEquals, assertRejects } from "@std/assert"
import * as mock from "@std/testing/mock"
import { SemVer, Path, utils, semver } from "pkgx"

Deno.test("internal.activate.ts", async runner => {
Expand Down
Loading

0 comments on commit a8e2a62

Please sign in to comment.