Skip to content

Commit

Permalink
Add import maps and import standard library from jsr
Browse files Browse the repository at this point in the history
  • Loading branch information
silverwind committed Jul 13, 2024
1 parent f80155a commit 36c50ce
Show file tree
Hide file tree
Showing 11 changed files with 173 additions and 40 deletions.
11 changes: 11 additions & 0 deletions deno.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"imports": {
"@octokit/types": "npm:@octokit/[email protected]",
"@octokit/webhooks": "npm:@octokit/[email protected]",
"@octokit/webhooks-methods": "npm:@octokit/[email protected]",
"@std/async": "jsr:@std/[email protected]",
"@std/http": "jsr:@std/[email protected]",
"@std/semver": "jsr:@std/[email protected]",
"@std/testing": "jsr:@std/[email protected]"
}
}
172 changes: 147 additions & 25 deletions deno.lock

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

4 changes: 2 additions & 2 deletions src/giteaVersion.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { SemVer } from "https://deno.land/[email protected]/semver/mod.ts";
import { parse } from "@std/semver";
import { getMilestones } from "./github.ts";

export class GiteaVersion {
majorMinorVersion: string;
milestoneNumber: number;

constructor(milestone: { title: string; number: number }) {
const semver = new SemVer(milestone.title);
const semver = parse(milestone.title);
this.majorMinorVersion = `${semver.major}.${semver.minor}`;
this.milestoneNumber = milestone.number;
}
Expand Down
8 changes: 4 additions & 4 deletions src/github.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import * as semver from "https://deno.land/[email protected]/semver/mod.ts";
import { valid, lt, parse } from "@std/semver";
import { getPrBranchName } from "./git.ts";
import { GiteaVersion } from "./giteaVersion.ts";
import { backportPrExistsCache } from "./state.ts";
Expand Down Expand Up @@ -294,17 +294,17 @@ export const getMilestones = async (): Promise<Milestone[]> => {
if (!response.ok) throw new Error(await response.text());
const json = await response.json();
const milestones: Milestone[] = json.filter((m: Milestone) =>
semver.valid(m.title)
valid(m.title)
);

// take only the earliest patch version of each minor version (e.g. 1.19.0, 1.19.1, 1.19.2 -> 1.19.0)
const earliestPatchVersions: Record<string, Milestone> = {};
for (const milestone of milestones) {
const version = new semver.SemVer(milestone.title);
const version = parse(milestone.title);
const key = `${version.major}.${version.minor}`;
if (
!earliestPatchVersions[key] ||
semver.lt(milestone.title, earliestPatchVersions[key].title)
lt(milestone.title, earliestPatchVersions[key].title)
) {
earliestPatchVersions[key] = milestone;
}
Expand Down
2 changes: 1 addition & 1 deletion src/github_test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import {
assertEquals,
assertFalse,
} from "https://deno.land/[email protected]/testing/asserts.ts";
} from "@std/testing/asserts";
import {
backportPrExists,
fetchBranch,
Expand Down
2 changes: 1 addition & 1 deletion src/labels.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
removeLabel,
} from "./github.ts";
import { fetchGiteaVersions } from "./giteaVersion.ts";
import { debounce } from "https://deno.land/[email protected]/async/mod.ts";
import { debounce } from "@std/async";
import type { PullRequest } from "./types.ts";

// a relevant label is one that is used to control the merge queue,
Expand Down
2 changes: 1 addition & 1 deletion src/mergeQueue.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { fetchPendingMerge, removeLabel } from "./github.ts";
import * as prActions from "./prActions.ts";
import { debounce } from "https://deno.land/[email protected]/async/mod.ts";
import { debounce } from "@std/async";

const updateBranch = async () => {
// fetch all PRs that are pending merge
Expand Down
2 changes: 1 addition & 1 deletion src/milestones.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import * as SemVer from "https://deno.land/[email protected]/semver/mod.ts";
import * as SemVer from "@std/semver";
import { fetchGiteaVersions } from "./giteaVersion.ts";
import * as github from "./github.ts";
import type { PullRequest } from "./types.ts";
Expand Down
2 changes: 1 addition & 1 deletion src/prActions.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { addComment, needsUpdate, removeLabel, updatePr } from "./github.ts";
import { debounce } from "https://deno.land/[email protected]/async/mod.ts";
import { debounce } from "@std/async";

const execute = async (
label: string,
Expand Down
2 changes: 1 addition & 1 deletion src/types.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Endpoints } from "npm:@octokit/types@13.5.0";
import { Endpoints } from "@octokit/types";

type IssueGetResponse =
Endpoints["GET /repos/{owner}/{repo}/issues/{issue_number}"]["response"][
Expand Down
6 changes: 3 additions & 3 deletions src/webhook.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { serve } from "https://deno.land/[email protected]/http/server.ts";
import { createEventHandler } from "https://esm.sh/@octokit/webhooks@11.0.0";
import { verify } from "https://esm.sh/@octokit/webhooks-methods@3.0.2";
import { serve } from "@std/http";
import { createEventHandler } from "@octokit/webhooks";
import { verify } from "@octokit/webhooks-methods";
import * as backport from "./backport.ts";
import * as labels from "./labels.ts";
import * as mergeQueue from "./mergeQueue.ts";
Expand Down

0 comments on commit 36c50ce

Please sign in to comment.