Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cov #13

Merged
merged 1 commit into from
Dec 4, 2024
Merged

cov #13

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
cov
spalberg committed Dec 4, 2024

Verified

This commit was signed with the committer’s verified signature. The key has expired.
hoangnt2 Nguyen Thai Hoang
commit 5785a2ec990613f12195738dec18a1f6eff36963
12 changes: 8 additions & 4 deletions .github/workflows/checks.yaml
Original file line number Diff line number Diff line change
@@ -24,8 +24,12 @@ jobs:
steps:
- uses: actions/checkout@v4
- uses: denoland/setup-deno@v2
- run: deno test --allow-read --parallel --junit-path=./junit.xml
- uses: EnricoMi/publish-unit-test-result-action@v2
if: always()
- run: deno test --allow-read --parallel --coverage=cov/ --junit-path=./junit.xml
- run: deno coverage --lcov cov/ > cov.lcov
- uses: codecov/codecov-action@v5
with:
files: junit.xml
token: ${{ secrets.CODECOV_TOKEN }}
- uses: codecov/test-results-action@v1
if: ${{ !cancelled() }}
with:
token: ${{ secrets.CODECOV_TOKEN }}
29 changes: 29 additions & 0 deletions cli.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { colors } from "@cliffy/ansi/colors";
import { Command } from "@cliffy/command";
import { Input, Select } from "@cliffy/prompt";
import { greaterThan, parse } from "@std/semver";
import { readLinesFromFile } from "utils";
import { days } from "./days/mod.ts";
import denoJson from "./deno.json" with { type: "json" };
@@ -18,6 +19,33 @@ const list = new Command()
}
});

const update = new Command()
.description("Update to the latest version")
.action(async () => {
const { latest } = await fetch(`https://jsr.io/${denoJson.name}/meta.json`)
.then(
(res) => res.json(),
);
const isUpdateAvailable = greaterThan(
parse(latest),
parse(denoJson.version),
);
if (isUpdateAvailable) {
console.log(
colors.bold.yellow(
`Update available: ${denoJson.version} -> ${latest}`,
),
);
console.log("Updating...");
await new Deno.Command(Deno.execPath(), {
args: ["run", "-r", `jsr:@aoc/2024`, "--help"],
}).output();
console.log(colors.bold.green("Updated successfully"));
} else {
console.log(colors.bold.green("Already up to date"));
}
});

const main = new Command()
.name("Advent of Code - 2024")
.version(denoJson.version)
@@ -83,5 +111,6 @@ function isWebUrl(path: string): boolean {
if (import.meta.main) {
await main
.command("list", list)
.command("update", update)
.parse(Deno.args);
}
2 changes: 1 addition & 1 deletion deno.json
Original file line number Diff line number Diff line change
@@ -4,7 +4,7 @@
"license": "MIT",
"exports": "./cli.ts",
"tasks": {
"cli": "deno run --allow-read ./cli.ts",
"cli": "deno run -RN ./cli.ts",
"update:version": "deno run -A ./scripts/update_version.ts"
},
"imports": {
12 changes: 12 additions & 0 deletions deno.lock

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