Unverified Commit 51a36a25 authored by Hong Minhee's avatar Hong Minhee
Browse files

Merge pull request #365 from dodok8/dodok8-fix-issue-353

parents 538730b0 06363db2
Loading
Loading
Loading
Loading
+13 −0
Original line number Diff line number Diff line
@@ -8,12 +8,23 @@ Version 1.9.0

To be released.

### @fedify/fedify

 -  Changed how `parseSoftware()` function handles non-Semantic Versioning
    number strings on `tryBestEffort` mode.  [[#353], [#365] by Hyeonseo Kim]]

### @fedify/cli

 -  Added `Next.js` option to `fedify init` command. This option allows users
    to initialize a new Fedify project with Next.js integration.
    [[#313] by Chanhaeng Lee]

 -  Changed how `fedify nodeinfo` command handles non-Semantic Versioning
    number strings on `-b`/`--best-effort` mode.  Now it uses the same logic as
    the `parseSoftware()` function in the *@fedify/fedify* package, which
    allows it to parse non-Semantic Versioning number strings more flexibly.
    [[#353], [#365] by Hyeonseo Kim]]

### @fedify/next

 -  Created [Next.js] integration as the *@fedify/next* package.
@@ -21,6 +32,8 @@ To be released.

[Next.js]: https://nextjs.org/
[#313]: https://github.com/fedify-dev/fedify/issues/313
[#353]: https://github.com/fedify-dev/fedify/issues/353
[#365]: https://github.com/fedify-dev/fedify/pull/365


Version 1.8.5
+36 −0
Original line number Diff line number Diff line
@@ -371,6 +371,42 @@ test("parseSoftware()", () => {
      version: { major: 1, minor: 2, patch: 3, build: [], prerelease: [] },
    },
  );
  assertEquals(
    parseSoftware({
      name: "foo",
      version: "2.81",
      repository: "",
      homepage: "",
    }, { tryBestEffort: true }),
    {
      name: "foo",
      version: { major: 2, minor: 81, patch: 0, build: [], prerelease: [] },
    },
  );
  assertEquals(
    parseSoftware({
      name: "foo",
      version: "3",
      repository: "",
      homepage: "",
    }, { tryBestEffort: true }),
    {
      name: "foo",
      version: { major: 3, minor: 0, patch: 0, build: [], prerelease: [] },
    },
  );
  assertEquals(
    parseSoftware({
      name: "foo",
      version: "2.1.3.4",
      repository: "",
      homepage: "",
    }, { tryBestEffort: true }),
    {
      name: "foo",
      version: { major: 2, minor: 1, patch: 3, build: [], prerelease: [] },
    },
  );
});

test("parseProtocol()", () => {
+10 −1
Original line number Diff line number Diff line
@@ -271,7 +271,15 @@ export function parseSoftware(
      version = parseSemVer(data.version);
    } catch {
      if (!options.tryBestEffort) return null;
      version = { major: 0, minor: 0, patch: 0, build: [], prerelease: [] };

      const parts = data.version.split(".").map((p) => parseInt(p, 10));
      version = {
        major: !isNaN(parts[0]) ? parts[0] : 0,
        minor: !isNaN(parts[1]) ? parts[1] : 0,
        patch: !isNaN(parts[2]) ? parts[2] : 0,
        build: [],
        prerelease: [],
      };
    }
  } else {
    if (!options.tryBestEffort) return null;
@@ -304,6 +312,7 @@ export function parseSoftware(
  const result: Software = { name, version };
  if (repository != null) result.repository = repository;
  if (homepage != null) result.homepage = homepage;

  return result;
}