Skip to content

Commit

Permalink
Enhance error logs info + changelog (#59)
Browse files Browse the repository at this point in the history
* Log info & changelog

* cspell

* [MegaLinter] Apply linters fixes

* fix

* test jdk 17

* Test on linux,  mac & windows

* fix

---------

Co-authored-by: Nicolas Vuillamy <nicolas.vuillamy@cloudity.com>
Co-authored-by: nvuillam <nvuillam@users.noreply.github.com>
  • Loading branch information
3 people authored Nov 26, 2023
1 parent 9467ee0 commit 2cbc9e1
Show file tree
Hide file tree
Showing 5 changed files with 57 additions and 12 deletions.
1 change: 1 addition & 0 deletions .cspell.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
"javaw",
"jscoverage",
"jspm",
"mheiges",
"njre",
"nvuillam",
"openj",
Expand Down
13 changes: 7 additions & 6 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
32 changes: 32 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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 <https://github.com/nvuillam/njre/pull/35>
- Configure Renovate by @renovate in <https://github.com/nvuillam/njre/pull/34>
- Update all non-major dependencies by @renovate in <https://github.com/nvuillam/njre/pull/36>
- Update actions/upload-artifact action to v3 by @renovate in <https://github.com/nvuillam/njre/pull/40>
- Update actions/checkout action to v4 by @renovate in <https://github.com/nvuillam/njre/pull/37>
- Update actions/setup-node action to v3 by @renovate in <https://github.com/nvuillam/njre/pull/39>
- Update dependency eslint to v8 by @renovate in <https://github.com/nvuillam/njre/pull/41>
- Update dependency husky to v8 by @renovate in <https://github.com/nvuillam/njre/pull/42>
- yarn upgrade by @nvuillam in <https://github.com/nvuillam/njre/pull/43>

## [v0.30.0] - The past

There was not a CHANGELOG.md at this time
19 changes: 13 additions & 6 deletions lib/install.js
Original file line number Diff line number Diff line change
Expand Up @@ -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"));
});
});
});
Expand Down Expand Up @@ -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 =
Expand All @@ -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 =
Expand Down
4 changes: 4 additions & 0 deletions tests/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 2cbc9e1

Please sign in to comment.