Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 15 additions & 7 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,29 +22,37 @@ jobs:
- run: deno lint .
- run: deno check ./pkgm.ts

#TODO test on linux! we are currently broken due to rpath issues
# https://github.com/pkgxdev/pkgm/pull/30#issuecomment-2678957666
test:
runs-on: ubuntu-latest
runs-on: macos-latest
steps:
- uses: actions/checkout@v4
- uses: pkgxdev/setup@v3

- run: |
if [[ "$(/usr/local/bin/pkgx --version)" != "pkgx 2"* ]]; then
exit 1
fi

- run: ./pkgm.ts i git
- run: /usr/local/bin/git --version

- run: ./pkgm.ts i pkgx.sh/brewkit
- run: /usr/local/bin/bk --help

# check repeats work
- run: rm /usr/local/bin/bk
- run: test ! -f /usr/local/bin/bk
- run: ./pkgm.ts i pkgx.sh/brewkit
- run: /usr/local/bin/bk --help

- run: ./pkgm.ts li pkgx.sh/brewkit
- run: ~/.local/bin/bk --help
- run: ./pkgm.ts li gum
- run: ~/.local/bin/gum --version

- run: |
if [[ "$(/usr/local/bin/pkgx --version)" != "pkgx 2"* ]]; then
exit 1
fi
# https://github.com/pkgxdev/pkgm/issues/24
- run: ./pkgm.ts i curl
- run: /usr/local/bin/curl -L pkgx.sh

# TODO pending: https://github.com/pkgxdev/pantry/issues/8487
# - run: ./pkgm.ts i xpra.org # https://github.com/pkgxdev/pkgm/issues/13
Expand Down
29 changes: 14 additions & 15 deletions pkgm.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#!/usr/bin/env -S pkgx --quiet deno^2.1 run --ext=ts --allow-sys=uid --allow-run --allow-env=PKGX_DIR,HOMEBREW_PREFIX,HOME --allow-read=/usr/local/pkgs,${HOME}/.local/pkgs
import { SemVer, semver } from "https://deno.land/x/libpkgx@v0.20.3/mod.ts";
import { dirname, fromFileUrl, join } from "jsr:@std/path@^1";
import { ensureDir, existsSync } from "jsr:@std/fs@^1";
import { parseArgs } from "jsr:@std/cli@^1";
import * as semver from "jsr:@std/semver@^1";

function standardPath() {
let path = "/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin";
Expand Down Expand Up @@ -283,32 +283,31 @@ async function create_v_symlinks(prefix: string) {
const shelf = dirname(prefix);

const versions = [];
for await (const entry of Deno.readDir(shelf)) {
if (
entry.isDirectory && !entry.isSymlink && entry.name.startsWith("v") &&
entry.name != "var"
) {
try {
versions.push(semver.parse(entry.name));
} catch {
//ignore
}
for await (const { name, isDirectory, isSymlink } of Deno.readDir(shelf)) {
console.log(name, isDirectory, isSymlink);
if (isSymlink) continue;
if (!isDirectory) continue;
if (!name.startsWith("v")) continue;
if (name == "var") continue;
const version = semver.parse(name);
if (version) {
versions.push(version);
}
}

// collect an Record of versions per major version
const major_versions: Record<number, semver.SemVer> = {};
const major_versions: Record<number, SemVer> = {};
for (const version of versions) {
if (
major_versions[version.major] === undefined ||
semver.greaterThan(version, major_versions[version.major])
version.gt(major_versions[version.major])
) {
major_versions[version.major] = version;
}
}

for (const [key, value] of Object.entries(major_versions)) {
symlink_with_overwrite(`v${semver.format(value)}`, join(shelf, `v${key}`));
for (const [key, semver] of Object.entries(major_versions)) {
symlink_with_overwrite(`v${semver}`, join(shelf, `v${key}`));
}
}

Expand Down