From 2cbc9e1d3c1c850f657b3ad7d1dae92a9fe9a64f Mon Sep 17 00:00:00 2001 From: Nicolas Vuillamy Date: Sun, 26 Nov 2023 09:34:12 +0100 Subject: [PATCH] Enhance error logs info + changelog (#59) * Log info & changelog * cspell * [MegaLinter] Apply linters fixes * fix * test jdk 17 * Test on linux, mac & windows * fix --------- Co-authored-by: Nicolas Vuillamy Co-authored-by: nvuillam --- .cspell.json | 1 + .github/workflows/test.yml | 13 +++++++------ CHANGELOG.md | 32 ++++++++++++++++++++++++++++++++ lib/install.js | 19 +++++++++++++------ tests/test.js | 4 ++++ 5 files changed, 57 insertions(+), 12 deletions(-) create mode 100644 CHANGELOG.md diff --git a/.cspell.json b/.cspell.json index 26a0962..442f2a6 100644 --- a/.cspell.json +++ b/.cspell.json @@ -27,6 +27,7 @@ "javaw", "jscoverage", "jspm", + "mheiges", "njre", "nvuillam", "openj", diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 7aacc2e..b8ae59b 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -9,13 +9,14 @@ concurrency: permissions: read-all jobs: - build: - name: Test NJRE - # Set the agent to run on - runs-on: ubuntu-latest - # Prevent duplicate run from happening when a forked push is committed + test: + strategy: + matrix: + os: [ubuntu-latest, macos-latest, windows-latest] + name: Test if: github.event_name == 'push' || github.event.pull_request.head.repo.full_name != github.repository - timeout-minutes: 60 + runs-on: ${{ matrix.os }} + timeout-minutes: 15 steps: - name: Checkout Code uses: actions/checkout@v4 diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..332bf4c --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,32 @@ +# Changelog + +All notable changes to this project will be documented in this file. + +The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). + +## [Unreleased] (beta, main branch content) + +- Add your updates here ! + +## [v1.1.0] - 2023-11-26 + +- Handle compatibility with Mac M1 +- Provide more information when unable to install java +- Add more test cases on more platforms +- Create CHANGELOG.md + +## [v1.0.0] - 2023-11-26 + +- migrate to adoptopenjdk API v3 by @mheiges in +- Configure Renovate by @renovate in +- Update all non-major dependencies by @renovate in +- Update actions/upload-artifact action to v3 by @renovate in +- Update actions/checkout action to v4 by @renovate in +- Update actions/setup-node action to v3 by @renovate in +- Update dependency eslint to v8 by @renovate in +- Update dependency husky to v8 by @renovate in +- yarn upgrade by @nvuillam in + +## [v0.30.0] - The past + +There was not a CHANGELOG.md at this time \ No newline at end of file diff --git a/lib/install.js b/lib/install.js index 15b13d6..bf571c2 100644 --- a/lib/install.js +++ b/lib/install.js @@ -57,7 +57,7 @@ function verify(file) { genChecksum(file).then((checksum) => { checksum === data.split(" ")[0] ? resolve(file) - : reject(new Error("File and checksum don't match")); + : reject(new Error("[njre] File and checksum don't match")); }); }); }); @@ -201,7 +201,9 @@ function install(version = 8, options = {}) { else if (options.vendor === "eclipse") endpoint = "api.adoptium.net"; else return Promise.reject( - new Error("Unsupported vendor. Use adoptopenjdk (default) or eclipse"), + new Error( + `[njre] Unsupported vendor ${options.vendor}. Use adoptopenjdk (default) or eclipse`, + ), ); const versionPath = @@ -227,15 +229,20 @@ function install(version = 8, options = {}) { options.os = "windows"; break; default: - return Promise.reject(new Error("Unsupported operating system")); + return Promise.reject( + new Error(`[njre] Unsupported operating system ${process.platform}`), + ); } } if (!options.arch) { if (/^ppc64|s390x|x32|x64$/g.test(process.arch)) options.arch = process.arch; - else if (process.arch === "ia32") options.arch = "x32"; - else if (process.arch === "arm64") options.arch = "aarch64"; - else return Promise.reject(new Error("Unsupported architecture")); + else if (process.arch === "ia32") options.arch = "x32"; + else if (process.arch === "arm64") options.arch = "aarch64"; + else + return Promise.reject( + new Error(`[njre] Unsupported architecture ${process.arch}`), + ); } const url = diff --git a/tests/test.js b/tests/test.js index 0c40f19..fd2727e 100644 --- a/tests/test.js +++ b/tests/test.js @@ -23,6 +23,10 @@ describe("Install", () => { return njre.install(14, { os: "linux" }); }).timeout(100000); + it("should install JDK 17 without throwing an error", () => { + return njre.install(17, { type: "jdk" }); + }).timeout(100000); + it("should install JRE 20 from Eclipse Foundation without throwing an error", () => { return njre.install(20, { vendor: "eclipse" }); }).timeout(100000);