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

fix(core/updates): error on JSR deps with yanked = false version #226

Merged
merged 3 commits into from
Aug 4, 2024
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
20 changes: 12 additions & 8 deletions _tools/bump.ts
Original file line number Diff line number Diff line change
@@ -1,27 +1,31 @@
import { associateWith, maxWith } from "@std/collections";
import { compare, format, increment, parse, ReleaseType } from "@std/semver";

type PackageName = "core" | "cli" | "integration" | "lib";
const MEMBERS = ["core", "cli", "integration", "lib"] as const;
type Member = typeof MEMBERS[number];

type Config = {
version: string;
};

const [type, ...pkgs] = Deno.args as [ReleaseType, ...PackageName[]];
const [type, ...targets] = Deno.args as [ReleaseType, ...Member[]];

const jsons = associateWith(
pkgs,
const JSONS = associateWith(
MEMBERS,
(pkg) => JSON.parse(Deno.readTextFileSync(`./${pkg}/deno.json`)) as Config,
);

const vers = Object.values(jsons).map((json) => json.version).map(parse);
const vers = Object.values(JSONS).map((json) => json.version).map(parse);
const max = maxWith(vers, compare)!;
const bumped = format(increment(max, type));

for (const [pkg, json] of Object.entries(jsons)) {
for (const [member, json] of Object.entries(JSONS)) {
if (!targets.includes(member as Member)) {
continue;
}
json.version = bumped;
await Deno.writeTextFile(
`./${pkg}/deno.json`,
`./${member}/deno.json`,
JSON.stringify(json, null, 2) + "\n",
);
}
Expand All @@ -31,7 +35,7 @@ await new Deno.Command("git", {
"commit",
"-m",
`chore: release ${bumped}`,
...pkgs.map((it) => `${it}/deno.json`),
...targets.map((it) => `${it}/deno.json`),
],
stdout: "inherit",
stderr: "inherit",
Expand Down
2 changes: 1 addition & 1 deletion cli/deno.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@molt/cli",
"version": "0.19.3",
"version": "0.19.6",
"exports": {
".": "./main.ts"
},
Expand Down
2 changes: 1 addition & 1 deletion core/deno.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@molt/core",
"version": "0.19.3",
"version": "0.19.6",
"exports": {
".": "./mod.ts",
"./bumps": "./bumps.ts",
Expand Down
2 changes: 1 addition & 1 deletion core/updates.ts
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ async function getJsrVersions(dep: DependencyState<"jsr">): Promise<string[]> {
assertOk(res);
const isJsrPackageMeta = is.ObjectOf({
versions: is.RecordOf(
is.ObjectOf({ yanked: is.OptionalOf(is.LiteralOf(true)) }),
is.ObjectOf({ yanked: is.OptionalOf(is.Boolean) }),
is.String,
),
});
Expand Down
7 changes: 6 additions & 1 deletion core/updates_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ describe("get", () => {
});
});

it("should get an update to a http dep with a v-lead semver", async () => {
it("should get an update to a http dep with a v-prefixed semver", async () => {
const dep = parse("https://deno.land/x/flash@v0.8.0");
assertEquals(await get(dep), {
released: "v0.8.1",
Expand Down Expand Up @@ -63,6 +63,11 @@ describe("get", () => {
assertEquals(await get(dep), undefined);
});

it("should not throw on a jsr dep with a `yanked = false` version", async () => {
const dep = parse("jsr:@denosaurs/emoji@~0.3.0");
await get(dep);
});

it("should get an update to a npm dep", async () => {
const dep = parse("npm:@conventional-commits/parser@^0.3.0");
assertEquals(await get(dep), {
Expand Down