Skip to content

Commit

Permalink
fix: upgrader uses jsr and readme (#22)
Browse files Browse the repository at this point in the history
* fix: upgrader uses jsr and readme

* fix lint

* add check in CI

* remove version in readme

* cleanup release tool
  • Loading branch information
sylc committed Apr 21, 2024
1 parent 85621f0 commit ac8d2fd
Show file tree
Hide file tree
Showing 8 changed files with 24 additions and 16 deletions.
6 changes: 4 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,10 @@ jobs:
- name: fmt
run: deno fmt --check

- name: Check
run: deno check ./mod.ts

- name: Run Test files in the repository
run: |
deno test -A
run: deno test -A

- run: echo "🍏 This job's status is ${{ job.status }}."
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
```

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
2 changes: 1 addition & 1 deletion src/pidToCmd.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { procList } from "../mod.ts";
import { PidItem } from "./utils/types.ts";
import type { PidItem } from "./utils/types.ts";

/**
* Get the command that started a pid
Expand Down
2 changes: 1 addition & 1 deletion src/procList.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { runCmd } from "./utils/runCmd.ts";
import { PidItem } from "./utils/types.ts";
import type { PidItem } from "./utils/types.ts";

/**
* list all process running.
Expand Down
2 changes: 1 addition & 1 deletion src/procToPid.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { procList } from "../mod.ts";
import { PidItem } from "./utils/types.ts";
import type { PidItem } from "./utils/types.ts";

/**
* Return Pids for a list of process names
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;
}
4 changes: 0 additions & 4 deletions tools/.release_up.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,6 @@
"release": true
},
"regex": [
{
"file": "README.md",
"patterns": ["(?<=@)(.*)(?=\/cli)"]
},
{
"file": "deno.json",
"patterns": [
Expand Down

0 comments on commit ac8d2fd

Please sign in to comment.