Skip to content

Commit

Permalink
fix: upgrader uses jsr and readme
Browse files Browse the repository at this point in the history
  • Loading branch information
sylc committed Apr 21, 2024
1 parent 85621f0 commit a25f78f
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 7 deletions.
9 changes: 5 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
[![deno module](https://shield.deno.dev/x/dkill)](https://deno.land/x/dkill)
[![JSR](https://jsr.io/badges/@sylc/dkill)](https://jsr.io/@sylc/dkill)

![deno compatibility](https://shield.deno.dev/deno/^1.42.4)

<h1 align="center">
Expand All @@ -14,7 +15,7 @@
### Install

```
deno install -f --allow-run --allow-net jsr:@sylc/dkill@0.11.2
deno install --global --force --allow-run --allow-net jsr:@sylc/dkill@0.11.2
```

You can then use it using command `dkill`
Expand Down Expand Up @@ -42,12 +43,12 @@ Usage: dkill <targets...>
-d, --dryrun - Dry run, List the pids that would have been killed. Does not kill anything
```

## Programatic Usage
## Programmatic Usage

mod.ts exports multiple functions that can be used programmatically. Check
source code for more info

See [docs](https://doc.deno.land/https://deno.land/x/dkill/mod.ts)
See [docs](https://jsr.io/@sylc/dkill/doc)

## OS Support

Expand Down
7 changes: 7 additions & 0 deletions src/upgrader.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { assert } from "../deps_test.ts";
import { upgrader } from "./upgrader.ts";

Deno.test("upgrader", async () => {
const res = await upgrader({ packageName: "dkill", currentVersion: "0.0.0" });
assert(res.includes("deno install"));
});
8 changes: 5 additions & 3 deletions src/upgrader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,10 @@ export async function upgrader(config: {
}) {
// try to find the latest version
console.log("Looking up latest version");
let command = "";
const versions = await (
await fetch(
`https://cdn.deno.land/${config.packageName}/meta/versions.json`,
`https://jsr.io/@sylc/${config.packageName}/meta.json`,
)
).json();
// We do not consider the < comparison because
Expand All @@ -25,8 +26,8 @@ export async function upgrader(config: {
if (config.currentVersion !== versions.latest) {
// retrieve command from new version
// const command = await fetchNewCommand(versions.latest);
const command = await fetchNewCommand(
`https://deno.land/x/${config.packageName}@${versions.latest}/README.md`,
command = await fetchNewCommand(
`https://jsr.io/@sylc/${config.packageName}/${versions.latest}/README.md`,
);
console.log("A new version is available. Run the below command to update:");
console.log(command);
Expand All @@ -35,4 +36,5 @@ export async function upgrader(config: {
`Local version ${config.currentVersion} is the most recent release`,
);
}
return command;
}

0 comments on commit a25f78f

Please sign in to comment.