diff --git a/.github/workflows/e2e-versions.yml b/.github/workflows/e2e-versions.yml index 1f9d6e777..8b9e11193 100644 --- a/.github/workflows/e2e-versions.yml +++ b/.github/workflows/e2e-versions.yml @@ -288,19 +288,23 @@ jobs: matrix: os: [macos-latest, windows-latest, ubuntu-latest] distribution: ['temurin', 'microsoft', 'corretto'] + java-version-file: ['.java-version', '.tool-versions'] steps: - name: Checkout uses: actions/checkout@v4 - name: Create .java-version file shell: bash run: echo "8" > .java-version + - name: Create .tool-versions file + shell: bash + run: echo "java 8" > .tool-versions - name: setup-java uses: ./ id: setup-java with: distribution: ${{ matrix.distribution }} java-version: 11 - java-version-file: '.java-version' + java-version-file: ${{matrix.java-version-file }} - name: Verify Java run: bash __tests__/verify-java.sh "11" "${{ steps.setup-java.outputs.path }}" shell: bash @@ -313,18 +317,22 @@ jobs: matrix: os: [macos-latest, windows-latest, ubuntu-latest] distribution: ['temurin', 'zulu', 'liberica', 'microsoft', 'corretto'] + java-version-file: ['.java-version', '.tool-versions'] steps: - name: Checkout uses: actions/checkout@v4 - name: Create .java-version file shell: bash run: echo "11" > .java-version + - name: Create .tool-versions file + shell: bash + run: echo "java 11" > .tool-versions - name: setup-java uses: ./ id: setup-java with: distribution: ${{ matrix.distribution }} - java-version-file: '.java-version' + java-version-file: ${{matrix.java-version-file }} - name: Verify Java run: bash __tests__/verify-java.sh "11" "${{ steps.setup-java.outputs.path }}" shell: bash @@ -337,18 +345,22 @@ jobs: matrix: os: [macos-latest, windows-latest, ubuntu-latest] distribution: ['adopt', 'adopt-openj9', 'zulu'] + java-version-file: ['.java-version', '.tool-versions'] steps: - name: Checkout uses: actions/checkout@v4 - name: Create .java-version file shell: bash run: echo "11.0.2" > .java-version + - name: Create .tool-versions file + shell: bash + run: echo "java 11.0.2" > .tool-versions - name: setup-java uses: ./ id: setup-java with: distribution: ${{ matrix.distribution }} - java-version-file: '.java-version' + java-version-file: ${{matrix.java-version-file }} - name: Verify Java run: bash __tests__/verify-java.sh "11.0.2" "${{ steps.setup-java.outputs.path }}" shell: bash @@ -361,18 +373,22 @@ jobs: matrix: os: [macos-latest, windows-latest, ubuntu-latest] distribution: ['adopt', 'zulu', 'liberica'] + java-version-file: ['.java-version', '.tool-versions'] steps: - name: Checkout uses: actions/checkout@v4 - name: Create .java-version file shell: bash run: echo "openjdk64-11.0.2" > .java-version + - name: Create .tool-versions file + shell: bash + run: echo "java openjdk64-11.0.2" > .tool-versions - name: setup-java uses: ./ id: setup-java with: distribution: ${{ matrix.distribution }} - java-version-file: '.java-version' + java-version-file: ${{matrix.java-version-file }} - name: Verify Java run: bash __tests__/verify-java.sh "11.0.2" "${{ steps.setup-java.outputs.path }}" shell: bash diff --git a/.licenses/npm/@actions/cache.dep.yml b/.licenses/npm/@actions/cache.dep.yml index 59bff0609..b37997fc1 100644 --- a/.licenses/npm/@actions/cache.dep.yml +++ b/.licenses/npm/@actions/cache.dep.yml @@ -1,6 +1,6 @@ --- name: "@actions/cache" -version: 3.2.2 +version: 3.2.4 type: npm summary: Actions cache lib homepage: https://github.com/actions/toolkit/tree/main/packages/cache diff --git a/.licenses/npm/@actions/http-client.dep.yml b/.licenses/npm/@actions/http-client.dep.yml index 216d36c94..cdccff4e1 100644 --- a/.licenses/npm/@actions/http-client.dep.yml +++ b/.licenses/npm/@actions/http-client.dep.yml @@ -1,6 +1,6 @@ --- name: "@actions/http-client" -version: 2.2.0 +version: 2.2.1 type: npm summary: Actions Http Client homepage: https://github.com/actions/toolkit/tree/main/packages/http-client diff --git a/.licenses/npm/@types/node.dep.yml b/.licenses/npm/@types/node.dep.yml index 160d443d6..06fb919df 100644 --- a/.licenses/npm/@types/node.dep.yml +++ b/.licenses/npm/@types/node.dep.yml @@ -1,6 +1,6 @@ --- name: "@types/node" -version: 20.9.3 +version: 20.11.24 type: npm summary: TypeScript definitions for node homepage: https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/node diff --git a/.licenses/npm/semver-7.5.4.dep.yml b/.licenses/npm/semver-7.6.0.dep.yml similarity index 97% rename from .licenses/npm/semver-7.5.4.dep.yml rename to .licenses/npm/semver-7.6.0.dep.yml index 5de7b63a4..bd631be07 100644 --- a/.licenses/npm/semver-7.5.4.dep.yml +++ b/.licenses/npm/semver-7.6.0.dep.yml @@ -1,9 +1,9 @@ --- name: semver -version: 7.5.4 +version: 7.6.0 type: npm summary: The semantic version parser used by npm. -homepage: +homepage: license: isc licenses: - sources: LICENSE diff --git a/.licenses/npm/undici.dep.yml b/.licenses/npm/undici.dep.yml index aaa2003d8..58844ed3d 100644 --- a/.licenses/npm/undici.dep.yml +++ b/.licenses/npm/undici.dep.yml @@ -1,6 +1,6 @@ --- name: undici -version: 5.27.2 +version: 5.28.3 type: npm summary: An HTTP/1.1 client, written from scratch for Node.js homepage: https://undici.nodejs.org diff --git a/README.md b/README.md index 92425ccaa..a3ac3974e 100644 --- a/README.md +++ b/README.md @@ -27,7 +27,7 @@ This action allows you to work with Java and Scala projects. - `java-version`: The Java version that is going to be set up. Takes a whole or [semver](#supported-version-syntax) Java version. If not specified, the action will expect `java-version-file` input to be specified. - - `java-version-file`: The path to the `.java-version` file. See more details in [about `.java-version` file](docs/advanced-usage.md#Java-version-file). + - `java-version-file`: The path to a file containing java version. Supported file types are `.java-version` and `.tool-versions`. See more details in [about .java-version-file](docs/advanced-usage.md#Java-version-file). - `distribution`: _(required)_ Java [distribution](#supported-distributions). @@ -266,6 +266,7 @@ In the example above multiple JDKs are installed for the same job. The result af - [Publishing using Gradle](docs/advanced-usage.md#Publishing-using-Gradle) - [Hosted Tool Cache](docs/advanced-usage.md#Hosted-Tool-Cache) - [Modifying Maven Toolchains](docs/advanced-usage.md#Modifying-Maven-Toolchains) +- [Java Version File](docs/advanced-usage.md#Java-version-file) ## License diff --git a/__tests__/data/liberica-linux.json b/__tests__/data/liberica-linux.json new file mode 100644 index 000000000..778265688 --- /dev/null +++ b/__tests__/data/liberica-linux.json @@ -0,0 +1,443 @@ +[ + { + "buildVersion": 36, + "updateVersion": 0, + "patchVersion": 0, + "downloadUrl": "https://github.com/bell-sw/Liberica/releases/download/14+36/bellsoft-jdk14+36-linux-amd64.zip", + "interimVersion": 0, + "version": "14+36", + "featureVersion": 14 + }, + { + "buildVersion": 9, + "updateVersion": 11, + "patchVersion": 0, + "downloadUrl": "https://github.com/bell-sw/Liberica/releases/download/11.0.11+9/bellsoft-jdk11.0.11+9-linux-amd64.zip", + "interimVersion": 0, + "version": "11.0.11+9", + "featureVersion": 11 + }, + { + "buildVersion": 8, + "updateVersion": 1, + "patchVersion": 0, + "downloadUrl": "https://github.com/bell-sw/Liberica/releases/download/14.0.1+8/bellsoft-jdk14.0.1+8-linux-amd64.zip", + "interimVersion": 0, + "version": "14.0.1+8", + "featureVersion": 14 + }, + { + "buildVersion": 10, + "updateVersion": 262, + "patchVersion": 0, + "downloadUrl": "https://github.com/bell-sw/Liberica/releases/download/8u262+10/bellsoft-jdk8u262+10-linux-amd64.zip", + "interimVersion": 0, + "version": "8u262+10", + "featureVersion": 8 + }, + { + "buildVersion": 1, + "updateVersion": 275, + "patchVersion": 0, + "downloadUrl": "https://github.com/bell-sw/Liberica/releases/download/8u275+1/bellsoft-jdk8u275+1-linux-amd64.zip", + "interimVersion": 0, + "version": "8u275+1", + "featureVersion": 8 + }, + { + "buildVersion": 1, + "updateVersion": 9, + "patchVersion": 1, + "downloadUrl": "https://github.com/bell-sw/Liberica/releases/download/11.0.9.1+1/bellsoft-jdk11.0.9.1+1-linux-amd64.zip", + "interimVersion": 0, + "version": "11.0.9.1+1", + "featureVersion": 11 + }, + { + "buildVersion": 8, + "updateVersion": 202, + "patchVersion": 0, + "downloadUrl": "https://github.com/bell-sw/Liberica/releases/download/8u202/bellsoft-jdk8u202-linux-amd64.zip", + "interimVersion": 0, + "version": "8u202+8", + "featureVersion": 8 + }, + { + "buildVersion": 33, + "updateVersion": 0, + "patchVersion": 0, + "downloadUrl": "https://github.com/bell-sw/Liberica/releases/download/12/bellsoft-jdk12-linux-amd64.zip", + "interimVersion": 0, + "version": "12+33", + "featureVersion": 12 + }, + { + "buildVersion": 8, + "updateVersion": 282, + "patchVersion": 0, + "downloadUrl": "https://github.com/bell-sw/Liberica/releases/download/8u282+8/bellsoft-jdk8u282+8-linux-amd64.zip", + "interimVersion": 0, + "version": "8u282+8", + "featureVersion": 8 + }, + { + "buildVersion": 11, + "updateVersion": 9, + "patchVersion": 0, + "downloadUrl": "https://github.com/bell-sw/Liberica/releases/download/11.0.9+11/bellsoft-jdk11.0.9+11-linux-amd64.zip", + "interimVersion": 0, + "version": "11.0.9+11", + "featureVersion": 11 + }, + { + "buildVersion": 33, + "updateVersion": 0, + "patchVersion": 0, + "downloadUrl": "https://github.com/bell-sw/Liberica/releases/download/13/bellsoft-jdk13-linux-amd64.zip", + "interimVersion": 0, + "version": "13+33", + "featureVersion": 13 + }, + { + "buildVersion": 12, + "updateVersion": 9, + "patchVersion": 0, + "downloadUrl": "https://github.com/bell-sw/Liberica/releases/download/11.0.9+12/bellsoft-jdk11.0.9+12-linux-amd64.zip", + "interimVersion": 0, + "version": "11.0.9+12", + "featureVersion": 11 + }, + { + "buildVersion": 7, + "updateVersion": 242, + "patchVersion": 0, + "downloadUrl": "https://github.com/bell-sw/Liberica/releases/download/8u242+7/bellsoft-jdk8u242+7-linux-amd64.zip", + "interimVersion": 0, + "version": "8u242+7", + "featureVersion": 8 + }, + { + "buildVersion": 9, + "updateVersion": 2, + "patchVersion": 0, + "downloadUrl": "https://github.com/bell-sw/Liberica/releases/download/13.0.2+9/bellsoft-jdk13.0.2+9-linux-amd64.zip", + "interimVersion": 0, + "version": "13.0.2+9", + "featureVersion": 13 + }, + { + "buildVersion": 9, + "updateVersion": 1, + "patchVersion": 0, + "downloadUrl": "https://github.com/bell-sw/Liberica/releases/download/13.0.1/bellsoft-jdk13.0.1-linux-amd64.zip", + "interimVersion": 0, + "version": "13.0.1+9", + "featureVersion": 13 + }, + { + "buildVersion": 1, + "updateVersion": 265, + "patchVersion": 0, + "downloadUrl": "https://github.com/bell-sw/Liberica/releases/download/8u265+1/bellsoft-jdk8u265+1-linux-amd64.zip", + "interimVersion": 0, + "version": "8u265+1", + "featureVersion": 8 + }, + { + "buildVersion": 9, + "updateVersion": 1, + "patchVersion": 0, + "downloadUrl": "https://github.com/bell-sw/Liberica/releases/download/15.0.1+9/bellsoft-jdk15.0.1+9-linux-amd64.zip", + "interimVersion": 0, + "version": "15.0.1+9", + "featureVersion": 15 + }, + { + "buildVersion": 10, + "updateVersion": 272, + "patchVersion": 0, + "downloadUrl": "https://github.com/bell-sw/Liberica/releases/download/8u272+10/bellsoft-jdk8u272+10-linux-amd64.zip", + "interimVersion": 0, + "version": "8u272+10", + "featureVersion": 8 + }, + { + "buildVersion": 7, + "updateVersion": 2, + "patchVersion": 0, + "downloadUrl": "https://github.com/bell-sw/Liberica/releases/download/16.0.2+7/bellsoft-jdk16.0.2+7-linux-amd64.zip", + "interimVersion": 0, + "version": "16.0.2+7", + "featureVersion": 16 + }, + { + "buildVersion": 10, + "updateVersion": 6, + "patchVersion": 0, + "downloadUrl": "https://github.com/bell-sw/Liberica/releases/download/11.0.6+10/bellsoft-jdk11.0.6+10-linux-amd64.zip", + "interimVersion": 0, + "version": "11.0.6+10", + "featureVersion": 11 + }, + { + "buildVersion": 9, + "updateVersion": 252, + "patchVersion": 0, + "downloadUrl": "https://github.com/bell-sw/Liberica/releases/download/8u252+9/bellsoft-jdk8u252+9-linux-amd64.zip", + "interimVersion": 0, + "version": "8u252+9", + "featureVersion": 8 + }, + { + "buildVersion": 12, + "updateVersion": 212, + "patchVersion": 0, + "downloadUrl": "https://github.com/bell-sw/Liberica/releases/download/8u212/bellsoft-jdk8u212-linux-amd64.zip", + "interimVersion": 0, + "version": "8u212+12", + "featureVersion": 8 + }, + { + "buildVersion": 10, + "updateVersion": 2, + "patchVersion": 0, + "downloadUrl": "https://github.com/bell-sw/Liberica/releases/download/15.0.2+10/bellsoft-jdk15.0.2+10-linux-amd64.zip", + "interimVersion": 0, + "version": "15.0.2+10", + "featureVersion": 15 + }, + { + "buildVersion": 9, + "updateVersion": 10, + "patchVersion": 0, + "downloadUrl": "https://github.com/bell-sw/Liberica/releases/download/11.0.10+9/bellsoft-jdk11.0.10+9-linux-amd64.zip", + "interimVersion": 0, + "version": "11.0.10+9", + "featureVersion": 11 + }, + { + "buildVersion": 0, + "updateVersion": 1, + "patchVersion": 0, + "downloadUrl": "https://github.com/bell-sw/Liberica/releases/download/11.0.1/bellsoft-jdk11.0.1-linux-amd64.tar.gz", + "interimVersion": 0, + "version": "11.0.1+0", + "featureVersion": 11 + }, + { + "buildVersion": 7, + "updateVersion": 12, + "patchVersion": 0, + "downloadUrl": "https://github.com/bell-sw/Liberica/releases/download/11.0.12+7/bellsoft-jdk11.0.12+7-linux-amd64.zip", + "interimVersion": 0, + "version": "11.0.12+7", + "featureVersion": 11 + }, + { + "buildVersion": 36, + "updateVersion": 0, + "patchVersion": 0, + "downloadUrl": "https://github.com/bell-sw/Liberica/releases/download/16+36/bellsoft-jdk16+36-linux-amd64.zip", + "interimVersion": 0, + "version": "16+36", + "featureVersion": 16 + }, + { + "buildVersion": 12, + "updateVersion": 3, + "patchVersion": 0, + "downloadUrl": "https://github.com/bell-sw/Liberica/releases/download/11.0.3/bellsoft-jdk11.0.3-linux-amd64.zip", + "interimVersion": 0, + "version": "11.0.3+12", + "featureVersion": 11 + }, + { + "buildVersion": 10, + "updateVersion": 8, + "patchVersion": 0, + "downloadUrl": "https://github.com/bell-sw/Liberica/releases/download/11.0.8+10/bellsoft-jdk11.0.8+10-linux-amd64.zip", + "interimVersion": 0, + "version": "11.0.8+10", + "featureVersion": 11 + }, + { + "buildVersion": 7, + "updateVersion": 2, + "patchVersion": 0, + "downloadUrl": "https://github.com/bell-sw/Liberica/releases/download/11.0.2/bellsoft-jdk11.0.2-linux-amd64.zip", + "interimVersion": 0, + "version": "11.0.2+7", + "featureVersion": 11 + }, + { + "buildVersion": 10, + "updateVersion": 5, + "patchVersion": 0, + "downloadUrl": "https://github.com/bell-sw/Liberica/releases/download/11.0.5/bellsoft-jdk11.0.5-linux-amd64.zip", + "interimVersion": 0, + "version": "11.0.5+10", + "featureVersion": 11 + }, + { + "buildVersion": 10, + "updateVersion": 4, + "patchVersion": 0, + "downloadUrl": "https://github.com/bell-sw/Liberica/releases/download/11.0.4/bellsoft-jdk11.0.4-linux-amd64.zip", + "interimVersion": 0, + "version": "11.0.4+10", + "featureVersion": 11 + }, + { + "buildVersion": 10, + "updateVersion": 2, + "patchVersion": 0, + "downloadUrl": "https://github.com/bell-sw/Liberica/releases/download/12.0.2/bellsoft-jdk12.0.2-linux-amd64.zip", + "interimVersion": 0, + "version": "12.0.2+10", + "featureVersion": 12 + }, + { + "buildVersion": 12, + "updateVersion": 1, + "patchVersion": 0, + "downloadUrl": "https://github.com/bell-sw/Liberica/releases/download/12.0.1/bellsoft-jdk12.0.1-linux-amd64.zip", + "interimVersion": 0, + "version": "12.0.1+12", + "featureVersion": 12 + }, + { + "buildVersion": 10, + "updateVersion": 1, + "patchVersion": 0, + "downloadUrl": "https://github.com/bell-sw/Liberica/releases/download/13.0.1+10/bellsoft-jdk13.0.1+10-linux-amd64.zip", + "interimVersion": 0, + "version": "13.0.1+10", + "featureVersion": 13 + }, + { + "buildVersion": 11, + "updateVersion": 5, + "patchVersion": 0, + "downloadUrl": "https://github.com/bell-sw/Liberica/releases/download/11.0.5+11/bellsoft-jdk11.0.5+11-linux-amd64.tar.gz", + "interimVersion": 0, + "version": "11.0.5+11", + "featureVersion": 11 + }, + { + "buildVersion": 11, + "updateVersion": 5, + "patchVersion": 0, + "downloadUrl": "https://github.com/bell-sw/Liberica/releases/download/11.0.5+11/bellsoft-jdk11.0.5+11-linux-amd64.zip", + "interimVersion": 0, + "version": "11.0.5+11", + "featureVersion": 11 + }, + { + "buildVersion": 10, + "updateVersion": 292, + "patchVersion": 0, + "downloadUrl": "https://github.com/bell-sw/Liberica/releases/download/8u292+10/bellsoft-jdk8u292+10-linux-amd64.zip", + "interimVersion": 0, + "version": "8u292+10", + "featureVersion": 8 + }, + { + "buildVersion": 11, + "updateVersion": 222, + "patchVersion": 0, + "downloadUrl": "https://github.com/bell-sw/Liberica/releases/download/8u222/bellsoft-jdk8u222-linux-amd64.zip", + "interimVersion": 0, + "version": "8u222+11", + "featureVersion": 8 + }, + { + "buildVersion": 36, + "updateVersion": 0, + "patchVersion": 0, + "downloadUrl": "https://github.com/bell-sw/Liberica/releases/download/15+36/bellsoft-jdk15+36-linux-amd64.zip", + "interimVersion": 0, + "version": "15+36", + "featureVersion": 15 + }, + { + "buildVersion": 10, + "updateVersion": 7, + "patchVersion": 0, + "downloadUrl": "https://github.com/bell-sw/Liberica/releases/download/11.0.7+10/bellsoft-jdk11.0.7+10-linux-amd64.zip", + "interimVersion": 0, + "version": "11.0.7+10", + "featureVersion": 11 + }, + { + "buildVersion": 10, + "updateVersion": 232, + "patchVersion": 0, + "downloadUrl": "https://github.com/bell-sw/Liberica/releases/download/8u232+10/bellsoft-jdk8u232+10-linux-amd64.zip", + "interimVersion": 0, + "version": "8u232+10", + "featureVersion": 8 + }, + { + "buildVersion": 8, + "updateVersion": 2, + "patchVersion": 0, + "downloadUrl": "https://github.com/bell-sw/Liberica/releases/download/15.0.2+8/bellsoft-jdk15.0.2+8-linux-amd64.zip", + "interimVersion": 0, + "version": "15.0.2+8", + "featureVersion": 15 + }, + { + "buildVersion": 8, + "updateVersion": 302, + "patchVersion": 0, + "downloadUrl": "https://github.com/bell-sw/Liberica/releases/download/8u302+8/bellsoft-jdk8u302+8-linux-amd64.zip", + "interimVersion": 0, + "version": "8u302+8", + "featureVersion": 8 + }, + { + "buildVersion": 12, + "updateVersion": 192, + "patchVersion": 0, + "downloadUrl": "https://github.com/bell-sw/Liberica/releases/download/8u192.all/bellsoft-jdk1.8.0-linux-amd64.tar.gz", + "interimVersion": 0, + "version": "8u192+12", + "featureVersion": 8 + }, + { + "buildVersion": 13, + "updateVersion": 2, + "patchVersion": 0, + "downloadUrl": "https://github.com/bell-sw/Liberica/releases/download/14.0.2+13/bellsoft-jdk14.0.2+13-linux-amd64.zip", + "interimVersion": 0, + "version": "14.0.2+13", + "featureVersion": 14 + }, + { + "buildVersion": 9, + "updateVersion": 1, + "patchVersion": 0, + "downloadUrl": "https://github.com/bell-sw/Liberica/releases/download/16.0.1+9/bellsoft-jdk16.0.1+9-linux-amd64.zip", + "interimVersion": 0, + "version": "16.0.1+9", + "featureVersion": 16 + }, + { + "buildVersion": 9, + "updateVersion": 232, + "patchVersion": 0, + "downloadUrl": "https://github.com/bell-sw/Liberica/releases/download/8u232/bellsoft-jdk8u232-linux-amd64.zip", + "interimVersion": 0, + "version": "8u232+9", + "featureVersion": 8 + }, + { + "buildVersion": 13, + "updateVersion": 10, + "patchVersion": 0, + "downloadUrl":"https://download.bell-sw.com/java/17.0.10+13/bellsoft-jdk17.0.10+13-linux-amd64.tar.gz", + "interimVersion": 0, + "version": "17.0.10+13", + "featureVersion": 17 + } +] \ No newline at end of file diff --git a/__tests__/data/liberica-windows.json b/__tests__/data/liberica-windows.json new file mode 100644 index 000000000..83b5089ab --- /dev/null +++ b/__tests__/data/liberica-windows.json @@ -0,0 +1,452 @@ +[ + { + "buildVersion": 36, + "updateVersion": 0, + "patchVersion": 0, + "downloadUrl": "https://github.com/bell-sw/Liberica/releases/download/14+36/bellsoft-jdk14+36-windows-amd64.zip", + "interimVersion": 0, + "version": "14+36", + "featureVersion": 14 + }, + { + "buildVersion": 9, + "updateVersion": 11, + "patchVersion": 0, + "downloadUrl": "https://github.com/bell-sw/Liberica/releases/download/11.0.11+9/bellsoft-jdk11.0.11+9-windows-amd64.zip", + "interimVersion": 0, + "version": "11.0.11+9", + "featureVersion": 11 + }, + { + "buildVersion": 8, + "updateVersion": 1, + "patchVersion": 0, + "downloadUrl": "https://github.com/bell-sw/Liberica/releases/download/14.0.1+8/bellsoft-jdk14.0.1+8-windows-amd64.zip", + "interimVersion": 0, + "version": "14.0.1+8", + "featureVersion": 14 + }, + { + "buildVersion": 10, + "updateVersion": 262, + "patchVersion": 0, + "downloadUrl": "https://github.com/bell-sw/Liberica/releases/download/8u262+10/bellsoft-jdk8u262+10-windows-amd64.zip", + "interimVersion": 0, + "version": "8u262+10", + "featureVersion": 8 + }, + { + "buildVersion": 1, + "updateVersion": 275, + "patchVersion": 0, + "downloadUrl": "https://github.com/bell-sw/Liberica/releases/download/8u275+1/bellsoft-jdk8u275+1-windows-amd64.zip", + "interimVersion": 0, + "version": "8u275+1", + "featureVersion": 8 + }, + { + "buildVersion": 1, + "updateVersion": 9, + "patchVersion": 1, + "downloadUrl": "https://github.com/bell-sw/Liberica/releases/download/11.0.9.1+1/bellsoft-jdk11.0.9.1+1-windows-amd64.zip", + "interimVersion": 0, + "version": "11.0.9.1+1", + "featureVersion": 11 + }, + { + "buildVersion": 8, + "updateVersion": 202, + "patchVersion": 0, + "downloadUrl": "https://github.com/bell-sw/Liberica/releases/download/8u202/bellsoft-jdk8u202-windows-amd64.zip", + "interimVersion": 0, + "version": "8u202+8", + "featureVersion": 8 + }, + { + "buildVersion": 33, + "updateVersion": 0, + "patchVersion": 0, + "downloadUrl": "https://github.com/bell-sw/Liberica/releases/download/12/bellsoft-jdk12-windows-amd64.zip", + "interimVersion": 0, + "version": "12+33", + "featureVersion": 12 + }, + { + "buildVersion": 8, + "updateVersion": 282, + "patchVersion": 0, + "downloadUrl": "https://github.com/bell-sw/Liberica/releases/download/8u282+8/bellsoft-jdk8u282+8-windows-amd64.zip", + "interimVersion": 0, + "version": "8u282+8", + "featureVersion": 8 + }, + { + "buildVersion": 11, + "updateVersion": 9, + "patchVersion": 0, + "downloadUrl": "https://github.com/bell-sw/Liberica/releases/download/11.0.9+11/bellsoft-jdk11.0.9+11-windows-amd64.zip", + "interimVersion": 0, + "version": "11.0.9+11", + "featureVersion": 11 + }, + { + "buildVersion": 33, + "updateVersion": 0, + "patchVersion": 0, + "downloadUrl": "https://github.com/bell-sw/Liberica/releases/download/13/bellsoft-jdk13-windows-amd64.zip", + "interimVersion": 0, + "version": "13+33", + "featureVersion": 13 + }, + { + "buildVersion": 12, + "updateVersion": 9, + "patchVersion": 0, + "downloadUrl": "https://github.com/bell-sw/Liberica/releases/download/11.0.9+12/bellsoft-jdk11.0.9+12-windows-amd64.zip", + "interimVersion": 0, + "version": "11.0.9+12", + "featureVersion": 11 + }, + { + "buildVersion": 7, + "updateVersion": 242, + "patchVersion": 0, + "downloadUrl": "https://github.com/bell-sw/Liberica/releases/download/8u242+7/bellsoft-jdk8u242+7-windows-amd64.zip", + "interimVersion": 0, + "version": "8u242+7", + "featureVersion": 8 + }, + { + "buildVersion": 9, + "updateVersion": 2, + "patchVersion": 0, + "downloadUrl": "https://github.com/bell-sw/Liberica/releases/download/13.0.2+9/bellsoft-jdk13.0.2+9-windows-amd64.zip", + "interimVersion": 0, + "version": "13.0.2+9", + "featureVersion": 13 + }, + { + "buildVersion": 9, + "updateVersion": 1, + "patchVersion": 0, + "downloadUrl": "https://github.com/bell-sw/Liberica/releases/download/13.0.1/bellsoft-jdk13.0.1-windows-amd64.zip", + "interimVersion": 0, + "version": "13.0.1+9", + "featureVersion": 13 + }, + { + "buildVersion": 1, + "updateVersion": 265, + "patchVersion": 0, + "downloadUrl": "https://github.com/bell-sw/Liberica/releases/download/8u265+1/bellsoft-jdk8u265+1-windows-amd64.zip", + "interimVersion": 0, + "version": "8u265+1", + "featureVersion": 8 + }, + { + "buildVersion": 9, + "updateVersion": 1, + "patchVersion": 0, + "downloadUrl": "https://github.com/bell-sw/Liberica/releases/download/15.0.1+9/bellsoft-jdk15.0.1+9-windows-amd64.zip", + "interimVersion": 0, + "version": "15.0.1+9", + "featureVersion": 15 + }, + { + "buildVersion": 10, + "updateVersion": 272, + "patchVersion": 0, + "downloadUrl": "https://github.com/bell-sw/Liberica/releases/download/8u272+10/bellsoft-jdk8u272+10-windows-amd64.zip", + "interimVersion": 0, + "version": "8u272+10", + "featureVersion": 8 + }, + { + "buildVersion": 7, + "updateVersion": 2, + "patchVersion": 0, + "downloadUrl": "https://github.com/bell-sw/Liberica/releases/download/16.0.2+7/bellsoft-jdk16.0.2+7-windows-amd64.zip", + "interimVersion": 0, + "version": "16.0.2+7", + "featureVersion": 16 + }, + { + "buildVersion": 10, + "updateVersion": 6, + "patchVersion": 0, + "downloadUrl": "https://github.com/bell-sw/Liberica/releases/download/11.0.6+10/bellsoft-jdk11.0.6+10-windows-amd64.zip", + "interimVersion": 0, + "version": "11.0.6+10", + "featureVersion": 11 + }, + { + "buildVersion": 9, + "updateVersion": 252, + "patchVersion": 0, + "downloadUrl": "https://github.com/bell-sw/Liberica/releases/download/8u252+9/bellsoft-jdk8u252+9-windows-amd64.zip", + "interimVersion": 0, + "version": "8u252+9", + "featureVersion": 8 + }, + { + "buildVersion": 12, + "updateVersion": 212, + "patchVersion": 0, + "downloadUrl": "https://github.com/bell-sw/Liberica/releases/download/8u212/bellsoft-jdk8u212-windows-amd64.zip", + "interimVersion": 0, + "version": "8u212+12", + "featureVersion": 8 + }, + { + "buildVersion": 10, + "updateVersion": 2, + "patchVersion": 0, + "downloadUrl": "https://github.com/bell-sw/Liberica/releases/download/15.0.2+10/bellsoft-jdk15.0.2+10-windows-amd64.zip", + "interimVersion": 0, + "version": "15.0.2+10", + "featureVersion": 15 + }, + { + "buildVersion": 9, + "updateVersion": 10, + "patchVersion": 0, + "downloadUrl": "https://github.com/bell-sw/Liberica/releases/download/11.0.10+9/bellsoft-jdk11.0.10+9-windows-amd64.zip", + "interimVersion": 0, + "version": "11.0.10+9", + "featureVersion": 11 + }, + { + "buildVersion": 0, + "updateVersion": 1, + "patchVersion": 0, + "downloadUrl": "https://github.com/bell-sw/Liberica/releases/download/11.0.1/bellsoft-jdk11.0.1-windows-amd64.tar.gz", + "interimVersion": 0, + "version": "11.0.1+0", + "featureVersion": 11 + }, + { + "buildVersion": 7, + "updateVersion": 12, + "patchVersion": 0, + "downloadUrl": "https://github.com/bell-sw/Liberica/releases/download/11.0.12+7/bellsoft-jdk11.0.12+7-windows-amd64.zip", + "interimVersion": 0, + "version": "11.0.12+7", + "featureVersion": 11 + }, + { + "buildVersion": 36, + "updateVersion": 0, + "patchVersion": 0, + "downloadUrl": "https://github.com/bell-sw/Liberica/releases/download/16+36/bellsoft-jdk16+36-windows-amd64.zip", + "interimVersion": 0, + "version": "16+36", + "featureVersion": 16 + }, + { + "buildVersion": 12, + "updateVersion": 3, + "patchVersion": 0, + "downloadUrl": "https://github.com/bell-sw/Liberica/releases/download/11.0.3/bellsoft-jdk11.0.3-windows-amd64.zip", + "interimVersion": 0, + "version": "11.0.3+12", + "featureVersion": 11 + }, + { + "buildVersion": 10, + "updateVersion": 8, + "patchVersion": 0, + "downloadUrl": "https://github.com/bell-sw/Liberica/releases/download/11.0.8+10/bellsoft-jdk11.0.8+10-windows-amd64.zip", + "interimVersion": 0, + "version": "11.0.8+10", + "featureVersion": 11 + }, + { + "buildVersion": 7, + "updateVersion": 2, + "patchVersion": 0, + "downloadUrl": "https://github.com/bell-sw/Liberica/releases/download/11.0.2/bellsoft-jdk11.0.2-windows-amd64.zip", + "interimVersion": 0, + "version": "11.0.2+7", + "featureVersion": 11 + }, + { + "buildVersion": 10, + "updateVersion": 5, + "patchVersion": 0, + "downloadUrl": "https://github.com/bell-sw/Liberica/releases/download/11.0.5/bellsoft-jdk11.0.5-windows-amd64.zip", + "interimVersion": 0, + "version": "11.0.5+10", + "featureVersion": 11 + }, + { + "buildVersion": 10, + "updateVersion": 4, + "patchVersion": 0, + "downloadUrl": "https://github.com/bell-sw/Liberica/releases/download/11.0.4/bellsoft-jdk11.0.4-windows-amd64.zip", + "interimVersion": 0, + "version": "11.0.4+10", + "featureVersion": 11 + }, + { + "buildVersion": 10, + "updateVersion": 2, + "patchVersion": 0, + "downloadUrl": "https://github.com/bell-sw/Liberica/releases/download/12.0.2/bellsoft-jdk12.0.2-windows-amd64.zip", + "interimVersion": 0, + "version": "12.0.2+10", + "featureVersion": 12 + }, + { + "buildVersion": 12, + "updateVersion": 1, + "patchVersion": 0, + "downloadUrl": "https://github.com/bell-sw/Liberica/releases/download/12.0.1/bellsoft-jdk12.0.1-windows-amd64.zip", + "interimVersion": 0, + "version": "12.0.1+12", + "featureVersion": 12 + }, + { + "buildVersion": 10, + "updateVersion": 1, + "patchVersion": 0, + "downloadUrl": "https://github.com/bell-sw/Liberica/releases/download/13.0.1+10/bellsoft-jdk13.0.1+10-windows-amd64.zip", + "interimVersion": 0, + "version": "13.0.1+10", + "featureVersion": 13 + }, + { + "buildVersion": 11, + "updateVersion": 5, + "patchVersion": 0, + "downloadUrl": "https://github.com/bell-sw/Liberica/releases/download/11.0.5+11/bellsoft-jdk11.0.5+11-windows-amd64.tar.gz", + "interimVersion": 0, + "version": "11.0.5+11", + "featureVersion": 11 + }, + { + "buildVersion": 11, + "updateVersion": 5, + "patchVersion": 0, + "downloadUrl": "https://github.com/bell-sw/Liberica/releases/download/11.0.5+11/bellsoft-jdk11.0.5+11-windows-amd64.zip", + "interimVersion": 0, + "version": "11.0.5+11", + "featureVersion": 11 + }, + { + "buildVersion": 10, + "updateVersion": 292, + "patchVersion": 0, + "downloadUrl": "https://github.com/bell-sw/Liberica/releases/download/8u292+10/bellsoft-jdk8u292+10-windows-amd64.zip", + "interimVersion": 0, + "version": "8u292+10", + "featureVersion": 8 + }, + { + "buildVersion": 11, + "updateVersion": 222, + "patchVersion": 0, + "downloadUrl": "https://github.com/bell-sw/Liberica/releases/download/8u222/bellsoft-jdk8u222-windows-amd64.zip", + "interimVersion": 0, + "version": "8u222+11", + "featureVersion": 8 + }, + { + "buildVersion": 36, + "updateVersion": 0, + "patchVersion": 0, + "downloadUrl": "https://github.com/bell-sw/Liberica/releases/download/15+36/bellsoft-jdk15+36-windows-amd64.zip", + "interimVersion": 0, + "version": "15+36", + "featureVersion": 15 + }, + { + "buildVersion": 10, + "updateVersion": 7, + "patchVersion": 0, + "downloadUrl": "https://github.com/bell-sw/Liberica/releases/download/11.0.7+10/bellsoft-jdk11.0.7+10-windows-amd64.zip", + "interimVersion": 0, + "version": "11.0.7+10", + "featureVersion": 11 + }, + { + "buildVersion": 10, + "updateVersion": 232, + "patchVersion": 0, + "downloadUrl": "https://github.com/bell-sw/Liberica/releases/download/8u232+10/bellsoft-jdk8u232+10-windows-amd64.zip", + "interimVersion": 0, + "version": "8u232+10", + "featureVersion": 8 + }, + { + "buildVersion": 8, + "updateVersion": 2, + "patchVersion": 0, + "downloadUrl": "https://github.com/bell-sw/Liberica/releases/download/15.0.2+8/bellsoft-jdk15.0.2+8-windows-amd64.zip", + "interimVersion": 0, + "version": "15.0.2+8", + "featureVersion": 15 + }, + { + "buildVersion": 8, + "updateVersion": 302, + "patchVersion": 0, + "downloadUrl": "https://github.com/bell-sw/Liberica/releases/download/8u302+8/bellsoft-jdk8u302+8-windows-amd64.zip", + "interimVersion": 0, + "version": "8u302+8", + "featureVersion": 8 + }, + { + "buildVersion": 12, + "updateVersion": 192, + "patchVersion": 0, + "downloadUrl": "https://github.com/bell-sw/Liberica/releases/download/8u192.all/bellsoft-jdk1.8.0-windows-amd64.tar.gz", + "interimVersion": 0, + "version": "8u192+12", + "featureVersion": 8 + }, + { + "buildVersion": 13, + "updateVersion": 2, + "patchVersion": 0, + "downloadUrl": "https://github.com/bell-sw/Liberica/releases/download/14.0.2+13/bellsoft-jdk14.0.2+13-windows-amd64.zip", + "interimVersion": 0, + "version": "14.0.2+13", + "featureVersion": 14 + }, + { + "buildVersion": 9, + "updateVersion": 1, + "patchVersion": 0, + "downloadUrl": "https://github.com/bell-sw/Liberica/releases/download/16.0.1+9/bellsoft-jdk16.0.1+9-windows-amd64.zip", + "interimVersion": 0, + "version": "16.0.1+9", + "featureVersion": 16 + }, + { + "buildVersion": 9, + "updateVersion": 232, + "patchVersion": 0, + "downloadUrl": "https://github.com/bell-sw/Liberica/releases/download/8u232/bellsoft-jdk8u232-windows-amd64.zip", + "interimVersion": 0, + "version": "8u232+9", + "featureVersion": 8 + }, + { + "buildVersion": 14, + "updateVersion": 2, + "patchVersion": 0, + "downloadUrl": "https://download.bell-sw.com/java/21.0.2+14/bellsoft-jdk21.0.2+14-windows-aarch64.zip", + "interimVersion": 0, + "version": "21.0.2+14", + "featureVersion": 21 + }, + { + "buildVersion": 13, + "updateVersion": 10, + "patchVersion": 0, + "downloadUrl": "https://download.bell-sw.com/java/17.0.10+13/bellsoft-jdk17.0.10+13-windows-aarch64.zip", + "interimVersion": 0, + "version": "17.0.10+13", + "featureVersion": 17 + } +] \ No newline at end of file diff --git a/__tests__/data/microsoft.json b/__tests__/data/microsoft.json index d9136311f..18e67d9d3 100644 --- a/__tests__/data/microsoft.json +++ b/__tests__/data/microsoft.json @@ -70,6 +70,12 @@ "arch": "aarch64", "platform": "linux", "download_url": "https://aka.ms/download-jdk/microsoft-jdk-17.0.7-linux-aarch64.tar.gz" + }, + { + "filename": "microsoft-jdk-17.0.7-windows-aarch64.zip", + "arch": "aarch64", + "platform": "win32", + "download_url": "https://aka.ms/download-jdk/microsoft-jdk-17.0.7-windows-aarch64.zip" } ] }, diff --git a/__tests__/data/zulu-linux.json b/__tests__/data/zulu-linux.json new file mode 100644 index 000000000..1f2fa2716 --- /dev/null +++ b/__tests__/data/zulu-linux.json @@ -0,0 +1,254 @@ +[ + { + "id": 10996, + "url": "https://cdn.azul.com/zulu/bin/zulu1.8.0_05-8.1.0.10-linux.tar.gz", + "name": "zulu1.8.0_05-8.1.0.10-linux.tar.gz", + "zulu_version": [8, 1, 0, 10], + "jdk_version": [8, 0, 5, 13] + }, + { + "id": 10997, + "url": "https://cdn.azul.com/zulu/bin/zulu1.8.0_11-8.2.0.1-linux.tar.gz", + "name": "zulu1.8.0_11-8.2.0.1-linux.tar.gz", + "zulu_version": [8, 2, 0, 1], + "jdk_version": [8, 0, 11, 12] + }, + { + "id": 10346, + "url": "https://cdn.azul.com/zulu/bin/zulu8.21.0.1-jdk8.0.131-linux_x64.tar.gz", + "name": "zulu8.21.0.1-jdk8.0.131-linux_x64.tar.gz", + "zulu_version": [8, 21, 0, 1], + "jdk_version": [8, 0, 131, 11] + }, + { + "id": 10362, + "url": "https://cdn.azul.com/zulu/bin/zulu8.23.0.3-jdk8.0.144-linux_x64.tar.gz", + "name": "zulu8.23.0.3-jdk8.0.144-linux_x64.tar.gz", + "zulu_version": [8, 23, 0, 3], + "jdk_version": [8, 0, 144, 1] + }, + { + "id": 10399, + "url": "https://cdn.azul.com/zulu/bin/zulu8.25.0.1-jdk8.0.152-linux_x64.tar.gz", + "name": "zulu8.25.0.1-jdk8.0.152-linux_x64.tar.gz", + "zulu_version": [8, 25, 0, 1], + "jdk_version": [8, 0, 152, 16] + }, + { + "id": 11355, + "url": "https://cdn.azul.com/zulu/bin/zulu8.46.0.19-ca-jdk8.0.252-linux_x64.tar.gz", + "name": "zulu8.46.0.19-ca-jdk8.0.252-linux_x64.tar.gz", + "zulu_version": [8, 46, 0, 19], + "jdk_version": [8, 0, 252, 14] + }, + { + "id": 11481, + "url": "https://cdn.azul.com/zulu/bin/zulu8.48.0.47-ca-jdk8.0.262-linux_x64.tar.gz", + "name": "zulu8.48.0.47-ca-jdk8.0.262-linux_x64.tar.gz", + "zulu_version": [8, 48, 0, 47], + "jdk_version": [8, 0, 262, 17] + }, + { + "id": 11622, + "url": "https://cdn.azul.com/zulu/bin/zulu8.48.0.51-ca-jdk8.0.262-linux_x64.tar.gz", + "name": "zulu8.48.0.51-ca-jdk8.0.262-linux_x64.tar.gz", + "zulu_version": [8, 48, 0, 51], + "jdk_version": [8, 0, 262, 19] + }, + { + "id": 11535, + "url": "https://cdn.azul.com/zulu/bin/zulu8.48.0.49-ca-jdk8.0.262-linux_x64.tar.gz", + "name": "zulu8.48.0.49-ca-jdk8.0.262-linux_x64.tar.gz", + "zulu_version": [8, 48, 0, 49], + "jdk_version": [8, 0, 262, 18] + }, + { + "id": 12424, + "url": "https://cdn.azul.com/zulu/bin/zulu8.52.0.23-ca-jdk8.0.282-linux_x64.tar.gz", + "name": "zulu8.52.0.23-ca-jdk8.0.282-linux_x64.tar.gz", + "zulu_version": [8, 52, 0, 23], + "jdk_version": [8, 0, 282, 8] + }, + { + "id": 10383, + "url": "https://cdn.azul.com/zulu/bin/zulu9.0.0.15-jdk9.0.0-linux_x64.tar.gz", + "name": "zulu9.0.0.15-jdk9.0.0-linux_x64.tar.gz", + "zulu_version": [9, 0, 0, 15], + "jdk_version": [9, 0, 0, 0] + }, + { + "id": 10413, + "url": "https://cdn.azul.com/zulu/bin/zulu9.0.1.3-jdk9.0.1-linux_x64.tar.gz", + "name": "zulu9.0.1.3-jdk9.0.1-linux_x64.tar.gz", + "zulu_version": [9, 0, 1, 3], + "jdk_version": [9, 0, 1, 0] + }, + { + "id": 10503, + "url": "https://cdn.azul.com/zulu/bin/zulu10.2+3-jdk10.0.1-linux_x64.tar.gz", + "name": "zulu10.2+3-jdk10.0.1-linux_x64.tar.gz", + "zulu_version": [10, 2, 3, 0], + "jdk_version": [10, 0, 1, 9] + }, + { + "id": 10541, + "url": "https://cdn.azul.com/zulu/bin/zulu10.3+5-jdk10.0.2-linux_x64.tar.gz", + "name": "zulu10.3+5-jdk10.0.2-linux_x64.tar.gz", + "zulu_version": [10, 3, 5, 0], + "jdk_version": [10, 0, 2, 13] + }, + { + "id": 10576, + "url": "https://cdn.azul.com/zulu/bin/zulu11.2.3-jdk11.0.1-linux_x64.tar.gz", + "name": "zulu11.2.3-jdk11.0.1-linux_x64.tar.gz", + "zulu_version": [11, 2, 3, 0], + "jdk_version": [11, 0, 1, 13] + }, + { + "id": 10604, + "url": "https://cdn.azul.com/zulu/bin/zulu11.29.3-ca-jdk11.0.2-linux_x64.tar.gz", + "name": "zulu11.29.3-ca-jdk11.0.2-linux_x64.tar.gz", + "zulu_version": [11, 29, 3, 0], + "jdk_version": [11, 0, 2, 7] + }, + { + "id": 10687, + "url": "https://cdn.azul.com/zulu/bin/zulu11.31.11-ca-jdk11.0.3-linux_x64.tar.gz", + "name": "zulu11.31.11-ca-jdk11.0.3-linux_x64.tar.gz", + "zulu_version": [11, 31, 11, 0], + "jdk_version": [11, 0, 3, 7] + }, + { + "id": 10856, + "url": "https://cdn.azul.com/zulu/bin/zulu11.35.13-ca-jdk11.0.5-linux_x64.tar.gz", + "name": "zulu11.35.13-ca-jdk11.0.5-linux_x64.tar.gz", + "zulu_version": [11, 35, 13, 0], + "jdk_version": [11, 0, 5, 10] + }, + { + "id": 10933, + "url": "https://cdn.azul.com/zulu/bin/zulu11.35.15-ca-jdk11.0.5-linux_x64.tar.gz", + "name": "zulu11.35.15-ca-jdk11.0.5-linux_x64.tar.gz", + "zulu_version": [11, 35, 15, 0], + "jdk_version": [11, 0, 5, 10] + }, + { + "id": 10933, + "url": "https://cdn.azul.com/zulu/bin/zulu11.35.11-ca-jdk11.0.5-linux_x64.tar.gz", + "name": "zulu11.35.15-ca-jdk11.0.5-linux_x64.tar.gz", + "zulu_version": [11, 35, 11, 0], + "jdk_version": [11, 0, 5, 10] + }, + { + "id": 12397, + "url": "https://cdn.azul.com/zulu/bin/zulu11.45.27-ca-jdk11.0.10-linux_x64.tar.gz", + "name": "zulu11.45.27-ca-jdk11.0.10-linux_x64.tar.gz", + "zulu_version": [11, 45, 27, 0], + "jdk_version": [11, 0, 10, 9] + }, + { + "id": 10667, + "url": "https://cdn.azul.com/zulu/bin/zulu12.1.3-ca-jdk12.0.0-linux_x64.tar.gz", + "name": "zulu12.1.3-ca-jdk12.0.0-linux_x64.tar.gz", + "zulu_version": [12, 1, 3, 0], + "jdk_version": [12, 0, 0, 33] + }, + { + "id": 10710, + "url": "https://cdn.azul.com/zulu/bin/zulu12.2.3-ca-jdk12.0.1-linux_x64.tar.gz", + "name": "zulu12.2.3-ca-jdk12.0.1-linux_x64.tar.gz", + "zulu_version": [12, 2, 3, 0], + "jdk_version": [12, 0, 1, 12] + }, + { + "id": 10780, + "url": "https://cdn.azul.com/zulu/bin/zulu12.3.11-ca-jdk12.0.2-linux_x64.tar.gz", + "name": "zulu12.3.11-ca-jdk12.0.2-linux_x64.tar.gz", + "zulu_version": [12, 3, 11, 0], + "jdk_version": [12, 0, 2, 3] + }, + { + "id": 10846, + "url": "https://cdn.azul.com/zulu/bin/zulu13.27.9-ca-jdk13.0.0-linux_x64.tar.gz", + "name": "zulu13.27.9-ca-jdk13.0.0-linux_x64.tar.gz", + "zulu_version": [13, 27, 9, 0], + "jdk_version": [13, 0, 0, 33] + }, + { + "id": 10888, + "url": "https://cdn.azul.com/zulu/bin/zulu13.28.11-ca-jdk13.0.1-linux_x64.tar.gz", + "name": "zulu13.28.11-ca-jdk13.0.1-linux_x64.tar.gz", + "zulu_version": [13, 28, 11, 0], + "jdk_version": [13, 0, 1, 10] + }, + { + "id": 11073, + "url": "https://cdn.azul.com/zulu/bin/zulu13.29.9-ca-jdk13.0.2-linux_x64.tar.gz", + "name": "zulu13.29.9-ca-jdk13.0.2-linux_x64.tar.gz", + "zulu_version": [13, 29, 9, 0], + "jdk_version": [13, 0, 2, 6] + }, + { + "id": 12408, + "url": "https://cdn.azul.com/zulu/bin/zulu13.37.21-ca-jdk13.0.6-linux_x64.tar.gz", + "name": "zulu13.37.21-ca-jdk13.0.6-linux_x64.tar.gz", + "zulu_version": [13, 37, 21, 0], + "jdk_version": [13, 0, 6, 5] + }, + { + "id": 11236, + "url": "https://cdn.azul.com/zulu/bin/zulu14.27.1-ca-jdk14.0.0-linux_x64.tar.gz", + "name": "zulu14.27.1-ca-jdk14.0.0-linux_x64.tar.gz", + "zulu_version": [14, 27, 1, 0], + "jdk_version": [14, 0, 0, 36] + }, + { + "id": 11349, + "url": "https://cdn.azul.com/zulu/bin/zulu14.28.21-ca-jdk14.0.1-linux_x64.tar.gz", + "name": "zulu14.28.21-ca-jdk14.0.1-linux_x64.tar.gz", + "zulu_version": [14, 28, 21, 0], + "jdk_version": [14, 0, 1, 8] + }, + { + "id": 11513, + "url": "https://cdn.azul.com/zulu/bin/zulu14.29.23-ca-jdk14.0.2-linux_x64.tar.gz", + "name": "zulu14.29.23-ca-jdk14.0.2-linux_x64.tar.gz", + "zulu_version": [14, 29, 23, 0], + "jdk_version": [14, 0, 2, 12] + }, + { + "id": 11780, + "url": "https://cdn.azul.com/zulu/bin/zulu15.27.17-ca-jdk15.0.0-linux_x64.tar.gz", + "name": "zulu15.27.17-ca-jdk15.0.0-linux_x64.tar.gz", + "zulu_version": [15, 27, 17, 0], + "jdk_version": [15, 0, 0, 36] + }, + { + "id": 11924, + "url": "https://cdn.azul.com/zulu/bin/zulu15.28.13-ca-jdk15.0.1-linux_x64.tar.gz", + "name": "zulu15.28.13-ca-jdk15.0.1-linux_x64.tar.gz", + "zulu_version": [15, 28, 13, 0], + "jdk_version": [15, 0, 1, 8] + }, + { + "id": 12101, + "url": "https://cdn.azul.com/zulu/bin/zulu15.28.51-ca-jdk15.0.1-linux_x64.tar.gz", + "name": "zulu15.28.51-ca-jdk15.0.1-linux_x64.tar.gz", + "zulu_version": [15, 28, 51, 0], + "jdk_version": [15, 0, 1, 9] + }, + { + "id": 12445, + "url": "https://cdn.azul.com/zulu/bin/zulu15.29.15-ca-jdk15.0.2-linux_x64.tar.gz", + "name": "zulu15.29.15-ca-jdk15.0.2-linux_x64.tar.gz", + "zulu_version": [15, 29, 15, 0], + "jdk_version": [15, 0, 2, 7] + }, + { + "id": 12447, + "url": "https://cdn.azul.com/zulu/bin/zulu21.32.17-ca-jdk21.0.2-linux_aarch64.tar.gz", + "name": "zulu21.32.17-ca-jdk21.0.2-linux_aarch64.tar.gz", + "zulu_version": [21, 32, 17, 0], + "jdk_version": [21, 0, 2, 6] + } +] \ No newline at end of file diff --git a/__tests__/data/zulu-windows.json b/__tests__/data/zulu-windows.json new file mode 100644 index 000000000..e4ce99538 --- /dev/null +++ b/__tests__/data/zulu-windows.json @@ -0,0 +1,254 @@ +[ + { + "id": 10996, + "url": "https://cdn.azul.com/zulu/bin/zulu1.8.0_05-8.1.0.10-windows.tar.gz", + "name": "zulu1.8.0_05-8.1.0.10-windows.tar.gz", + "zulu_version": [8, 1, 0, 10], + "jdk_version": [8, 0, 5, 13] + }, + { + "id": 10997, + "url": "https://cdn.azul.com/zulu/bin/zulu1.8.0_11-8.2.0.1-windows.tar.gz", + "name": "zulu1.8.0_11-8.2.0.1-windows.tar.gz", + "zulu_version": [8, 2, 0, 1], + "jdk_version": [8, 0, 11, 12] + }, + { + "id": 10346, + "url": "https://cdn.azul.com/zulu/bin/zulu8.21.0.1-jdk8.0.131-windows_x64.tar.gz", + "name": "zulu8.21.0.1-jdk8.0.131-windows_x64.tar.gz", + "zulu_version": [8, 21, 0, 1], + "jdk_version": [8, 0, 131, 11] + }, + { + "id": 10362, + "url": "https://cdn.azul.com/zulu/bin/zulu8.23.0.3-jdk8.0.144-windows_x64.tar.gz", + "name": "zulu8.23.0.3-jdk8.0.144-windows_x64.tar.gz", + "zulu_version": [8, 23, 0, 3], + "jdk_version": [8, 0, 144, 1] + }, + { + "id": 10399, + "url": "https://cdn.azul.com/zulu/bin/zulu8.25.0.1-jdk8.0.152-windows_x64.tar.gz", + "name": "zulu8.25.0.1-jdk8.0.152-windows_x64.tar.gz", + "zulu_version": [8, 25, 0, 1], + "jdk_version": [8, 0, 152, 16] + }, + { + "id": 11355, + "url": "https://cdn.azul.com/zulu/bin/zulu8.46.0.19-ca-jdk8.0.252-windows_x64.tar.gz", + "name": "zulu8.46.0.19-ca-jdk8.0.252-windows_x64.tar.gz", + "zulu_version": [8, 46, 0, 19], + "jdk_version": [8, 0, 252, 14] + }, + { + "id": 11481, + "url": "https://cdn.azul.com/zulu/bin/zulu8.48.0.47-ca-jdk8.0.262-windows_x64.tar.gz", + "name": "zulu8.48.0.47-ca-jdk8.0.262-windows_x64.tar.gz", + "zulu_version": [8, 48, 0, 47], + "jdk_version": [8, 0, 262, 17] + }, + { + "id": 11622, + "url": "https://cdn.azul.com/zulu/bin/zulu8.48.0.51-ca-jdk8.0.262-windows_x64.tar.gz", + "name": "zulu8.48.0.51-ca-jdk8.0.262-windows_x64.tar.gz", + "zulu_version": [8, 48, 0, 51], + "jdk_version": [8, 0, 262, 19] + }, + { + "id": 11535, + "url": "https://cdn.azul.com/zulu/bin/zulu8.48.0.49-ca-jdk8.0.262-windows_x64.tar.gz", + "name": "zulu8.48.0.49-ca-jdk8.0.262-windows_x64.tar.gz", + "zulu_version": [8, 48, 0, 49], + "jdk_version": [8, 0, 262, 18] + }, + { + "id": 12424, + "url": "https://cdn.azul.com/zulu/bin/zulu8.52.0.23-ca-jdk8.0.282-windows_x64.tar.gz", + "name": "zulu8.52.0.23-ca-jdk8.0.282-windows_x64.tar.gz", + "zulu_version": [8, 52, 0, 23], + "jdk_version": [8, 0, 282, 8] + }, + { + "id": 10383, + "url": "https://cdn.azul.com/zulu/bin/zulu9.0.0.15-jdk9.0.0-windows_x64.tar.gz", + "name": "zulu9.0.0.15-jdk9.0.0-windows_x64.tar.gz", + "zulu_version": [9, 0, 0, 15], + "jdk_version": [9, 0, 0, 0] + }, + { + "id": 10413, + "url": "https://cdn.azul.com/zulu/bin/zulu9.0.1.3-jdk9.0.1-windows_x64.tar.gz", + "name": "zulu9.0.1.3-jdk9.0.1-windows_x64.tar.gz", + "zulu_version": [9, 0, 1, 3], + "jdk_version": [9, 0, 1, 0] + }, + { + "id": 10503, + "url": "https://cdn.azul.com/zulu/bin/zulu10.2+3-jdk10.0.1-windows_x64.tar.gz", + "name": "zulu10.2+3-jdk10.0.1-windows_x64.tar.gz", + "zulu_version": [10, 2, 3, 0], + "jdk_version": [10, 0, 1, 9] + }, + { + "id": 10541, + "url": "https://cdn.azul.com/zulu/bin/zulu10.3+5-jdk10.0.2-windows_x64.tar.gz", + "name": "zulu10.3+5-jdk10.0.2-windows_x64.tar.gz", + "zulu_version": [10, 3, 5, 0], + "jdk_version": [10, 0, 2, 13] + }, + { + "id": 10576, + "url": "https://cdn.azul.com/zulu/bin/zulu11.2.3-jdk11.0.1-windows_x64.tar.gz", + "name": "zulu11.2.3-jdk11.0.1-windows_x64.tar.gz", + "zulu_version": [11, 2, 3, 0], + "jdk_version": [11, 0, 1, 13] + }, + { + "id": 10604, + "url": "https://cdn.azul.com/zulu/bin/zulu11.29.3-ca-jdk11.0.2-windows_x64.tar.gz", + "name": "zulu11.29.3-ca-jdk11.0.2-windows_x64.tar.gz", + "zulu_version": [11, 29, 3, 0], + "jdk_version": [11, 0, 2, 7] + }, + { + "id": 10687, + "url": "https://cdn.azul.com/zulu/bin/zulu11.31.11-ca-jdk11.0.3-windows_x64.tar.gz", + "name": "zulu11.31.11-ca-jdk11.0.3-windows_x64.tar.gz", + "zulu_version": [11, 31, 11, 0], + "jdk_version": [11, 0, 3, 7] + }, + { + "id": 10856, + "url": "https://cdn.azul.com/zulu/bin/zulu11.35.13-ca-jdk11.0.5-windows_x64.tar.gz", + "name": "zulu11.35.13-ca-jdk11.0.5-windows_x64.tar.gz", + "zulu_version": [11, 35, 13, 0], + "jdk_version": [11, 0, 5, 10] + }, + { + "id": 10933, + "url": "https://cdn.azul.com/zulu/bin/zulu11.35.15-ca-jdk11.0.5-windows_x64.tar.gz", + "name": "zulu11.35.15-ca-jdk11.0.5-windows_x64.tar.gz", + "zulu_version": [11, 35, 15, 0], + "jdk_version": [11, 0, 5, 10] + }, + { + "id": 10933, + "url": "https://cdn.azul.com/zulu/bin/zulu11.35.11-ca-jdk11.0.5-windows_x64.tar.gz", + "name": "zulu11.35.15-ca-jdk11.0.5-windows_x64.tar.gz", + "zulu_version": [11, 35, 11, 0], + "jdk_version": [11, 0, 5, 10] + }, + { + "id": 12397, + "url": "https://cdn.azul.com/zulu/bin/zulu11.45.27-ca-jdk11.0.10-windows_x64.tar.gz", + "name": "zulu11.45.27-ca-jdk11.0.10-windows_x64.tar.gz", + "zulu_version": [11, 45, 27, 0], + "jdk_version": [11, 0, 10, 9] + }, + { + "id": 10667, + "url": "https://cdn.azul.com/zulu/bin/zulu12.1.3-ca-jdk12.0.0-windows_x64.tar.gz", + "name": "zulu12.1.3-ca-jdk12.0.0-windows_x64.tar.gz", + "zulu_version": [12, 1, 3, 0], + "jdk_version": [12, 0, 0, 33] + }, + { + "id": 10710, + "url": "https://cdn.azul.com/zulu/bin/zulu12.2.3-ca-jdk12.0.1-windows_x64.tar.gz", + "name": "zulu12.2.3-ca-jdk12.0.1-windows_x64.tar.gz", + "zulu_version": [12, 2, 3, 0], + "jdk_version": [12, 0, 1, 12] + }, + { + "id": 10780, + "url": "https://cdn.azul.com/zulu/bin/zulu12.3.11-ca-jdk12.0.2-windows_x64.tar.gz", + "name": "zulu12.3.11-ca-jdk12.0.2-windows_x64.tar.gz", + "zulu_version": [12, 3, 11, 0], + "jdk_version": [12, 0, 2, 3] + }, + { + "id": 10846, + "url": "https://cdn.azul.com/zulu/bin/zulu13.27.9-ca-jdk13.0.0-windows_x64.tar.gz", + "name": "zulu13.27.9-ca-jdk13.0.0-windows_x64.tar.gz", + "zulu_version": [13, 27, 9, 0], + "jdk_version": [13, 0, 0, 33] + }, + { + "id": 10888, + "url": "https://cdn.azul.com/zulu/bin/zulu13.28.11-ca-jdk13.0.1-windows_x64.tar.gz", + "name": "zulu13.28.11-ca-jdk13.0.1-windows_x64.tar.gz", + "zulu_version": [13, 28, 11, 0], + "jdk_version": [13, 0, 1, 10] + }, + { + "id": 11073, + "url": "https://cdn.azul.com/zulu/bin/zulu13.29.9-ca-jdk13.0.2-windows_x64.tar.gz", + "name": "zulu13.29.9-ca-jdk13.0.2-windows_x64.tar.gz", + "zulu_version": [13, 29, 9, 0], + "jdk_version": [13, 0, 2, 6] + }, + { + "id": 12408, + "url": "https://cdn.azul.com/zulu/bin/zulu13.37.21-ca-jdk13.0.6-windows_x64.tar.gz", + "name": "zulu13.37.21-ca-jdk13.0.6-windows_x64.tar.gz", + "zulu_version": [13, 37, 21, 0], + "jdk_version": [13, 0, 6, 5] + }, + { + "id": 11236, + "url": "https://cdn.azul.com/zulu/bin/zulu14.27.1-ca-jdk14.0.0-windows_x64.tar.gz", + "name": "zulu14.27.1-ca-jdk14.0.0-windows_x64.tar.gz", + "zulu_version": [14, 27, 1, 0], + "jdk_version": [14, 0, 0, 36] + }, + { + "id": 11349, + "url": "https://cdn.azul.com/zulu/bin/zulu14.28.21-ca-jdk14.0.1-windows_x64.tar.gz", + "name": "zulu14.28.21-ca-jdk14.0.1-windows_x64.tar.gz", + "zulu_version": [14, 28, 21, 0], + "jdk_version": [14, 0, 1, 8] + }, + { + "id": 11513, + "url": "https://cdn.azul.com/zulu/bin/zulu14.29.23-ca-jdk14.0.2-windows_x64.tar.gz", + "name": "zulu14.29.23-ca-jdk14.0.2-windows_x64.tar.gz", + "zulu_version": [14, 29, 23, 0], + "jdk_version": [14, 0, 2, 12] + }, + { + "id": 11780, + "url": "https://cdn.azul.com/zulu/bin/zulu15.27.17-ca-jdk15.0.0-windows_x64.tar.gz", + "name": "zulu15.27.17-ca-jdk15.0.0-windows_x64.tar.gz", + "zulu_version": [15, 27, 17, 0], + "jdk_version": [15, 0, 0, 36] + }, + { + "id": 11924, + "url": "https://cdn.azul.com/zulu/bin/zulu15.28.13-ca-jdk15.0.1-windows_x64.tar.gz", + "name": "zulu15.28.13-ca-jdk15.0.1-windows_x64.tar.gz", + "zulu_version": [15, 28, 13, 0], + "jdk_version": [15, 0, 1, 8] + }, + { + "id": 12101, + "url": "https://cdn.azul.com/zulu/bin/zulu15.28.51-ca-jdk15.0.1-windows_x64.tar.gz", + "name": "zulu15.28.51-ca-jdk15.0.1-windows_x64.tar.gz", + "zulu_version": [15, 28, 51, 0], + "jdk_version": [15, 0, 1, 9] + }, + { + "id": 12445, + "url": "https://cdn.azul.com/zulu/bin/zulu15.29.15-ca-jdk15.0.2-windows_x64.tar.gz", + "name": "zulu15.29.15-ca-jdk15.0.2-windows_x64.tar.gz", + "zulu_version": [15, 29, 15, 0], + "jdk_version": [15, 0, 2, 7] + }, + { + "id": 12446, + "url": "https://cdn.azul.com/zulu/bin/zulu17.48.15-ca-jdk17.0.10-windows_aarch64.zip", + "name": "zulu17.48.15-ca-jdk17.0.10-win_aarhc4.zip", + "zulu_version": [17, 48, 15, 0], + "jdk_version": [17, 0, 10, 7] + } +] \ No newline at end of file diff --git a/__tests__/distributors/liberica-linux-installer.test.ts b/__tests__/distributors/liberica-linux-installer.test.ts new file mode 100644 index 000000000..8e6a665e0 --- /dev/null +++ b/__tests__/distributors/liberica-linux-installer.test.ts @@ -0,0 +1,290 @@ +import {LibericaDistributions} from '../../src/distributions/liberica/installer'; +import { + ArchitectureOptions, + LibericaVersion +} from '../../src/distributions/liberica/models'; +import {HttpClient} from '@actions/http-client'; +import os from 'os'; + +import manifestData from '../data/liberica-linux.json'; + +describe('getAvailableVersions', () => { + let spyHttpClient: jest.SpyInstance; + + beforeEach(() => { + spyHttpClient = jest.spyOn(HttpClient.prototype, 'getJson'); + spyHttpClient.mockReturnValue({ + statusCode: 200, + headers: {}, + result: manifestData as LibericaVersion[] + }); + }); + + afterEach(() => { + jest.resetAllMocks(); + jest.clearAllMocks(); + jest.restoreAllMocks(); + }); + + it.each([ + [ + { + version: '11.x', + architecture: 'x86', + packageType: 'jdk', + checkLatest: false + }, + 'bundle-type=jdk&bitness=32&arch=x86&build-type=all' + ], + [ + { + version: '11-ea', + architecture: 'x86', + packageType: 'jdk', + checkLatest: false + }, + 'bundle-type=jdk&bitness=32&arch=x86&build-type=ea' + ], + [ + { + version: '16.0.2', + architecture: 'x64', + packageType: 'jdk', + checkLatest: false + }, + 'bundle-type=jdk&bitness=64&arch=x86&build-type=all' + ], + [ + { + version: '16.0.2', + architecture: 'x64', + packageType: 'jre', + checkLatest: false + }, + 'bundle-type=jre&bitness=64&arch=x86&build-type=all' + ], + [ + { + version: '8', + architecture: 'armv7', + packageType: 'jdk+fx', + checkLatest: false + }, + 'bundle-type=jdk-full&bitness=32&arch=arm&build-type=all' + ], + [ + { + version: '8', + architecture: 'aarch64', + packageType: 'jre+fx', + checkLatest: false + }, + 'bundle-type=jre-full&bitness=64&arch=arm&build-type=all' + ] + ])('build correct url for %s -> %s', async (input, urlParams) => { + const additionalParams = + '&installation-type=archive&fields=downloadUrl%2Cversion%2CfeatureVersion%2CinterimVersion%2C' + + 'updateVersion%2CbuildVersion'; + const distribution = new LibericaDistributions(input); + distribution['getPlatformOption'] = () => 'linux'; + const buildUrl = `https://api.bell-sw.com/v1/liberica/releases?os=linux&${urlParams}${additionalParams}`; + + await distribution['getAvailableVersions'](); + + expect(spyHttpClient.mock.calls).toHaveLength(1); + expect(spyHttpClient.mock.calls[0][0]).toBe(buildUrl); + }); + + type DistroArch = { + bitness: string; + arch: string; + }; + it.each([ + ['amd64', {bitness: '64', arch: 'x86'}], + ['arm64', {bitness: '64', arch: 'arm'}] + ])( + 'defaults to os.arch(): %s mapped to distro arch: %s', + async (osArch: string, distroArch: DistroArch) => { + jest.spyOn(os, 'arch').mockReturnValue(osArch); + + const distribution = new LibericaDistributions({ + version: '17', + architecture: '', // to get default value + packageType: 'jdk', + checkLatest: false + }); + + const additionalParams = + '&installation-type=archive&fields=downloadUrl%2Cversion%2CfeatureVersion%2CinterimVersion%2C' + + 'updateVersion%2CbuildVersion'; + distribution['getPlatformOption'] = () => 'linux'; + + const buildUrl = `https://api.bell-sw.com/v1/liberica/releases?os=linux&bundle-type=jdk&bitness=${distroArch.bitness}&arch=${distroArch.arch}&build-type=all${additionalParams}`; + + await distribution['getAvailableVersions'](); + + expect(spyHttpClient.mock.calls).toHaveLength(1); + expect(spyHttpClient.mock.calls[0][0]).toBe(buildUrl); + } + ); + + it('load available versions', async () => { + const distribution = new LibericaDistributions({ + version: '11', + architecture: 'x64', + packageType: 'jdk', + checkLatest: false + }); + const availableVersions = await distribution['getAvailableVersions'](); + expect(availableVersions).toEqual(manifestData); + }); +}); + +describe('getArchitectureOptions', () => { + it.each([ + ['x86', {bitness: '32', arch: 'x86'}], + ['x64', {bitness: '64', arch: 'x86'}], + ['armv7', {bitness: '32', arch: 'arm'}], + ['aarch64', {bitness: '64', arch: 'arm'}], + ['ppc64le', {bitness: '64', arch: 'ppc'}] + ] as [string, ArchitectureOptions][])( + 'parse architecture %s -> %s', + (input, expected) => { + const distributions = new LibericaDistributions({ + architecture: input, + checkLatest: false, + packageType: '', + version: '' + }); + + expect(distributions['getArchitectureOptions']()).toEqual(expected); + } + ); + + it.each(['armv6', 's390x'])('not support architecture %s', input => { + const distributions = new LibericaDistributions({ + architecture: input, + checkLatest: false, + packageType: '', + version: '' + }); + + expect(() => distributions['getArchitectureOptions']()).toThrow( + /Architecture '\w+' is not supported\. Supported architectures: .*/ + ); + }); +}); + +describe('findPackageForDownload', () => { + let distribution: LibericaDistributions; + + beforeEach(() => { + distribution = new LibericaDistributions({ + version: '', + architecture: 'x64', + packageType: 'jdk', + checkLatest: false + }); + distribution['getAvailableVersions'] = async () => manifestData; + }); + + it.each([ + ['8', '8.0.302+8'], + ['11.x', '11.0.12+7'], + ['8.0', '8.0.302+8'], + ['11.0.x', '11.0.12+7'], + ['15', '15.0.2+10'], + ['15.0', '15.0.2+10'], + ['15.0.0', '15.0.0+36'], + ['8.0.232', '8.0.232+10'], + ['8.0.232+9', '8.0.232+9'], + ['15.0.2+8', '15.0.2+8'], + ['15.0.2+10', '15.0.2+10'] + ])('version is %s -> %s', async (input, expected) => { + const result = await distribution['findPackageForDownload'](input); + expect(result.version).toBe(expected); + }); + + it('should throw an error', async () => { + await expect(distribution['findPackageForDownload']('18')).rejects.toThrow( + /Could not find satisfied version for semver */ + ); + }); +}); + +describe('getPlatformOption', () => { + const distributions = new LibericaDistributions({ + architecture: 'x64', + version: '11', + packageType: 'jdk', + checkLatest: false + }); + + it.each([ + ['linux', 'linux'], + ['darwin', 'macos'], + ['win32', 'windows'], + ['cygwin', 'windows'], + ['sunos', 'solaris'] + ])('os version %s -> %s', (input, expected) => { + const actual = distributions['getPlatformOption'](input as NodeJS.Platform); + + expect(actual).toEqual(expected); + }); + + it.each(['aix', 'android', 'freebsd', 'openbsd', 'netbsd'])( + 'not support os version %s', + input => { + expect(() => + distributions['getPlatformOption'](input as NodeJS.Platform) + ).toThrow(/Platform '\w+' is not supported\. Supported platforms: .+/); + } + ); +}); + +describe('convertVersionToSemver', () => { + const distributions = new LibericaDistributions({ + architecture: 'x64', + version: '11', + packageType: 'jdk', + checkLatest: false + }); + + it.each([ + [ + { + featureVersion: 11, + interimVersion: 0, + updateVersion: 12, + buildVersion: 7 + }, + '11.0.12+7' + ], + [ + { + featureVersion: 11, + interimVersion: 0, + updateVersion: 12, + buildVersion: 0 + }, + '11.0.12' + ], + [ + { + featureVersion: 11, + interimVersion: 0, + updateVersion: 0, + buildVersion: 13 + }, + '11.0.0+13' + ] + ])('%s -> %s', (input, expected) => { + const actual = distributions['convertVersionToSemver']({ + downloadUrl: '', + version: '', + ...input + }); + + expect(actual).toEqual(expected); + }); +}); diff --git a/__tests__/distributors/liberica-windows-installer.test.ts b/__tests__/distributors/liberica-windows-installer.test.ts new file mode 100644 index 000000000..1ccc57ede --- /dev/null +++ b/__tests__/distributors/liberica-windows-installer.test.ts @@ -0,0 +1,290 @@ +import {LibericaDistributions} from '../../src/distributions/liberica/installer'; +import { + ArchitectureOptions, + LibericaVersion +} from '../../src/distributions/liberica/models'; +import {HttpClient} from '@actions/http-client'; +import os from 'os'; + +import manifestData from '../data/liberica-windows.json'; + +describe('getAvailableVersions', () => { + let spyHttpClient: jest.SpyInstance; + + beforeEach(() => { + spyHttpClient = jest.spyOn(HttpClient.prototype, 'getJson'); + spyHttpClient.mockReturnValue({ + statusCode: 200, + headers: {}, + result: manifestData as LibericaVersion[] + }); + }); + + afterEach(() => { + jest.resetAllMocks(); + jest.clearAllMocks(); + jest.restoreAllMocks(); + }); + + it.each([ + [ + { + version: '11.x', + architecture: 'x86', + packageType: 'jdk', + checkLatest: false + }, + 'bundle-type=jdk&bitness=32&arch=x86&build-type=all' + ], + [ + { + version: '11-ea', + architecture: 'x86', + packageType: 'jdk', + checkLatest: false + }, + 'bundle-type=jdk&bitness=32&arch=x86&build-type=ea' + ], + [ + { + version: '16.0.2', + architecture: 'x64', + packageType: 'jdk', + checkLatest: false + }, + 'bundle-type=jdk&bitness=64&arch=x86&build-type=all' + ], + [ + { + version: '16.0.2', + architecture: 'x64', + packageType: 'jre', + checkLatest: false + }, + 'bundle-type=jre&bitness=64&arch=x86&build-type=all' + ], + [ + { + version: '8', + architecture: 'armv7', + packageType: 'jdk+fx', + checkLatest: false + }, + 'bundle-type=jdk-full&bitness=32&arch=arm&build-type=all' + ], + [ + { + version: '8', + architecture: 'aarch64', + packageType: 'jre+fx', + checkLatest: false + }, + 'bundle-type=jre-full&bitness=64&arch=arm&build-type=all' + ] + ])('build correct url for %s -> %s', async (input, urlParams) => { + const additionalParams = + '&installation-type=archive&fields=downloadUrl%2Cversion%2CfeatureVersion%2CinterimVersion%2C' + + 'updateVersion%2CbuildVersion'; + const distribution = new LibericaDistributions(input); + distribution['getPlatformOption'] = () => 'windows'; + const buildUrl = `https://api.bell-sw.com/v1/liberica/releases?os=windows&${urlParams}${additionalParams}`; + + await distribution['getAvailableVersions'](); + + expect(spyHttpClient.mock.calls).toHaveLength(1); + expect(spyHttpClient.mock.calls[0][0]).toBe(buildUrl); + }); + + type DistroArch = { + bitness: string; + arch: string; + }; + it.each([ + ['amd64', {bitness: '64', arch: 'x86'}], + ['arm64', {bitness: '64', arch: 'arm'}] + ])( + 'defaults to os.arch(): %s mapped to distro arch: %s', + async (osArch: string, distroArch: DistroArch) => { + jest.spyOn(os, 'arch').mockReturnValue(osArch); + + const distribution = new LibericaDistributions({ + version: '17', + architecture: '', // to get default value + packageType: 'jdk', + checkLatest: false + }); + + const additionalParams = + '&installation-type=archive&fields=downloadUrl%2Cversion%2CfeatureVersion%2CinterimVersion%2C' + + 'updateVersion%2CbuildVersion'; + distribution['getPlatformOption'] = () => 'windows'; + + const buildUrl = `https://api.bell-sw.com/v1/liberica/releases?os=windows&bundle-type=jdk&bitness=${distroArch.bitness}&arch=${distroArch.arch}&build-type=all${additionalParams}`; + + await distribution['getAvailableVersions'](); + + expect(spyHttpClient.mock.calls).toHaveLength(1); + expect(spyHttpClient.mock.calls[0][0]).toBe(buildUrl); + } + ); + + it('load available versions', async () => { + const distribution = new LibericaDistributions({ + version: '11', + architecture: 'x64', + packageType: 'jdk', + checkLatest: false + }); + const availableVersions = await distribution['getAvailableVersions'](); + expect(availableVersions).toEqual(manifestData); + }); +}); + +describe('getArchitectureOptions', () => { + it.each([ + ['x86', {bitness: '32', arch: 'x86'}], + ['x64', {bitness: '64', arch: 'x86'}], + ['armv7', {bitness: '32', arch: 'arm'}], + ['aarch64', {bitness: '64', arch: 'arm'}], + ['ppc64le', {bitness: '64', arch: 'ppc'}] + ] as [string, ArchitectureOptions][])( + 'parse architecture %s -> %s', + (input, expected) => { + const distributions = new LibericaDistributions({ + architecture: input, + checkLatest: false, + packageType: '', + version: '' + }); + + expect(distributions['getArchitectureOptions']()).toEqual(expected); + } + ); + + it.each(['armv6', 's390x'])('not support architecture %s', input => { + const distributions = new LibericaDistributions({ + architecture: input, + checkLatest: false, + packageType: '', + version: '' + }); + + expect(() => distributions['getArchitectureOptions']()).toThrow( + /Architecture '\w+' is not supported\. Supported architectures: .*/ + ); + }); +}); + +describe('findPackageForDownload', () => { + let distribution: LibericaDistributions; + + beforeEach(() => { + distribution = new LibericaDistributions({ + version: '', + architecture: 'x64', + packageType: 'jdk', + checkLatest: false + }); + distribution['getAvailableVersions'] = async () => manifestData; + }); + + it.each([ + ['8', '8.0.302+8'], + ['11.x', '11.0.12+7'], + ['8.0', '8.0.302+8'], + ['11.0.x', '11.0.12+7'], + ['15', '15.0.2+10'], + ['15.0', '15.0.2+10'], + ['15.0.0', '15.0.0+36'], + ['8.0.232', '8.0.232+10'], + ['8.0.232+9', '8.0.232+9'], + ['15.0.2+8', '15.0.2+8'], + ['15.0.2+10', '15.0.2+10'] + ])('version is %s -> %s', async (input, expected) => { + const result = await distribution['findPackageForDownload'](input); + expect(result.version).toBe(expected); + }); + + it('should throw an error', async () => { + await expect(distribution['findPackageForDownload']('18')).rejects.toThrow( + /Could not find satisfied version for semver */ + ); + }); +}); + +describe('getPlatformOption', () => { + const distributions = new LibericaDistributions({ + architecture: 'x64', + version: '11', + packageType: 'jdk', + checkLatest: false + }); + + it.each([ + ['linux', 'linux'], + ['darwin', 'macos'], + ['win32', 'windows'], + ['cygwin', 'windows'], + ['sunos', 'solaris'] + ])('os version %s -> %s', (input, expected) => { + const actual = distributions['getPlatformOption'](input as NodeJS.Platform); + + expect(actual).toEqual(expected); + }); + + it.each(['aix', 'android', 'freebsd', 'openbsd', 'netbsd'])( + 'not support os version %s', + input => { + expect(() => + distributions['getPlatformOption'](input as NodeJS.Platform) + ).toThrow(/Platform '\w+' is not supported\. Supported platforms: .+/); + } + ); +}); + +describe('convertVersionToSemver', () => { + const distributions = new LibericaDistributions({ + architecture: 'x64', + version: '11', + packageType: 'jdk', + checkLatest: false + }); + + it.each([ + [ + { + featureVersion: 11, + interimVersion: 0, + updateVersion: 12, + buildVersion: 7 + }, + '11.0.12+7' + ], + [ + { + featureVersion: 11, + interimVersion: 0, + updateVersion: 12, + buildVersion: 0 + }, + '11.0.12' + ], + [ + { + featureVersion: 11, + interimVersion: 0, + updateVersion: 0, + buildVersion: 13 + }, + '11.0.0+13' + ] + ])('%s -> %s', (input, expected) => { + const actual = distributions['convertVersionToSemver']({ + downloadUrl: '', + version: '', + ...input + }); + + expect(actual).toEqual(expected); + }); +}); diff --git a/__tests__/distributors/microsoft-installer.test.ts b/__tests__/distributors/microsoft-installer.test.ts index 011df1b13..00c4b6c6e 100644 --- a/__tests__/distributors/microsoft-installer.test.ts +++ b/__tests__/distributors/microsoft-installer.test.ts @@ -89,6 +89,30 @@ describe('findPackageForDownload', () => { expect(result.url).toBe(url); }); + it.each([ + ['amd64', 'x64'], + ['arm64', 'aarch64'] + ])( + 'defaults to os.arch(): %s mapped to distro arch: %s', + async (osArch: string, distroArch: string) => { + jest.spyOn(os, 'arch').mockReturnValue(osArch); + jest.spyOn(os, 'platform').mockReturnValue('darwin'); + + const version = '17'; + const distro = new MicrosoftDistributions({ + version, + architecture: '', // to get default value + packageType: 'jdk', + checkLatest: false + }); + + const result = await distro['findPackageForDownload'](version); + const expectedUrl = `https://aka.ms/download-jdk/microsoft-jdk-17.0.7-macos-${distroArch}.tar.gz`; + + expect(result.url).toBe(expectedUrl); + } + ); + it.each([ ['amd64', 'x64'], ['arm64', 'aarch64'] @@ -113,6 +137,30 @@ describe('findPackageForDownload', () => { } ); + it.each([ + ['amd64', 'x64'], + ['arm64', 'aarch64'] + ])( + 'defaults to os.arch(): %s mapped to distro arch: %s', + async (osArch: string, distroArch: string) => { + jest.spyOn(os, 'arch').mockReturnValue(osArch); + jest.spyOn(os, 'platform').mockReturnValue('win32'); + + const version = '17'; + const distro = new MicrosoftDistributions({ + version, + architecture: '', // to get default value + packageType: 'jdk', + checkLatest: false + }); + + const result = await distro['findPackageForDownload'](version); + const expectedUrl = `https://aka.ms/download-jdk/microsoft-jdk-17.0.7-windows-${distroArch}.zip`; + + expect(result.url).toBe(expectedUrl); + } + ); + it('should throw an error', async () => { await expect(distribution['findPackageForDownload']('8')).rejects.toThrow( /Could not find satisfied version for SemVer */ diff --git a/__tests__/distributors/zulu-linux-installer.test.ts b/__tests__/distributors/zulu-linux-installer.test.ts new file mode 100644 index 000000000..60f36ee59 --- /dev/null +++ b/__tests__/distributors/zulu-linux-installer.test.ts @@ -0,0 +1,229 @@ +import {HttpClient} from '@actions/http-client'; +import * as semver from 'semver'; +import {ZuluDistribution} from '../../src/distributions/zulu/installer'; +import {IZuluVersions} from '../../src/distributions/zulu/models'; +import * as utils from '../../src/util'; +import os from 'os'; + +import manifestData from '../data/zulu-linux.json'; + +describe('getAvailableVersions', () => { + let spyHttpClient: jest.SpyInstance; + let spyUtilGetDownloadArchiveExtension: jest.SpyInstance; + + beforeEach(() => { + spyHttpClient = jest.spyOn(HttpClient.prototype, 'getJson'); + spyHttpClient.mockReturnValue({ + statusCode: 200, + headers: {}, + result: manifestData as IZuluVersions[] + }); + + spyUtilGetDownloadArchiveExtension = jest.spyOn( + utils, + 'getDownloadArchiveExtension' + ); + spyUtilGetDownloadArchiveExtension.mockReturnValue('zip'); + }); + + afterEach(() => { + jest.resetAllMocks(); + jest.clearAllMocks(); + jest.restoreAllMocks(); + }); + + it.each([ + [ + { + version: '11', + architecture: 'x86', + packageType: 'jdk', + checkLatest: false + }, + '?os=linux&ext=zip&bundle_type=jdk&javafx=false&arch=x86&hw_bitness=32&release_status=ga' + ], + [ + { + version: '11-ea', + architecture: 'x86', + packageType: 'jdk', + checkLatest: false + }, + '?os=linux&ext=zip&bundle_type=jdk&javafx=false&arch=x86&hw_bitness=32&release_status=ea' + ], + [ + { + version: '8', + architecture: 'x64', + packageType: 'jdk', + checkLatest: false + }, + '?os=linux&ext=zip&bundle_type=jdk&javafx=false&arch=x86&hw_bitness=64&release_status=ga' + ], + [ + { + version: '8', + architecture: 'x64', + packageType: 'jre', + checkLatest: false + }, + '?os=linux&ext=zip&bundle_type=jre&javafx=false&arch=x86&hw_bitness=64&release_status=ga' + ], + [ + { + version: '8', + architecture: 'x64', + packageType: 'jdk+fx', + checkLatest: false + }, + '?os=linux&ext=zip&bundle_type=jdk&javafx=true&arch=x86&hw_bitness=64&release_status=ga&features=fx' + ], + [ + { + version: '8', + architecture: 'x64', + packageType: 'jre+fx', + checkLatest: false + }, + '?os=linux&ext=zip&bundle_type=jre&javafx=true&arch=x86&hw_bitness=64&release_status=ga&features=fx' + ], + [ + { + version: '11', + architecture: 'arm64', + packageType: 'jdk', + checkLatest: false + }, + '?os=linux&ext=zip&bundle_type=jdk&javafx=false&arch=arm&hw_bitness=64&release_status=ga' + ], + [ + { + version: '11', + architecture: 'arm', + packageType: 'jdk', + checkLatest: false + }, + '?os=linux&ext=zip&bundle_type=jdk&javafx=false&arch=arm&hw_bitness=&release_status=ga' + ] + ])('build correct url for %s -> %s', async (input, parsedUrl) => { + const distribution = new ZuluDistribution(input); + distribution['getPlatformOption'] = () => 'linux'; + const buildUrl = `https://api.azul.com/zulu/download/community/v1.0/bundles/${parsedUrl}`; + + await distribution['getAvailableVersions'](); + + expect(spyHttpClient.mock.calls).toHaveLength(1); + expect(spyHttpClient.mock.calls[0][0]).toBe(buildUrl); + }); + + type DistroArch = { + bitness: string; + arch: string; + }; + it.each([ + ['amd64', {bitness: '64', arch: 'x86'}], + ['arm64', {bitness: '64', arch: 'arm'}] + ])( + 'defaults to os.arch(): %s mapped to distro arch: %s', + async (osArch: string, distroArch: DistroArch) => { + jest.spyOn(os, 'arch').mockReturnValue(osArch); + + const distribution = new ZuluDistribution({ + version: '17', + architecture: '', // to get default value + packageType: 'jdk', + checkLatest: false + }); + distribution['getPlatformOption'] = () => 'linux'; + const buildUrl = `https://api.azul.com/zulu/download/community/v1.0/bundles/?os=linux&ext=zip&bundle_type=jdk&javafx=false&arch=${distroArch.arch}&hw_bitness=${distroArch.bitness}&release_status=ga`; + + await distribution['getAvailableVersions'](); + + expect(spyHttpClient.mock.calls).toHaveLength(1); + expect(spyHttpClient.mock.calls[0][0]).toBe(buildUrl); + } + ); + + it('load available versions', async () => { + const distribution = new ZuluDistribution({ + version: '11', + architecture: 'x86', + packageType: 'jdk', + checkLatest: false + }); + const availableVersions = await distribution['getAvailableVersions'](); + expect(availableVersions).toHaveLength(manifestData.length); + }); +}); + +describe('getArchitectureOptions', () => { + it.each([ + [{architecture: 'x64'}, {arch: 'x86', hw_bitness: '64', abi: ''}], + [{architecture: 'x86'}, {arch: 'x86', hw_bitness: '32', abi: ''}], + [{architecture: 'x32'}, {arch: 'x32', hw_bitness: '', abi: ''}], + [{architecture: 'arm'}, {arch: 'arm', hw_bitness: '', abi: ''}] + ])('%s -> %s', (input, expected) => { + const distribution = new ZuluDistribution({ + version: '11', + architecture: input.architecture, + packageType: 'jdk', + checkLatest: false + }); + expect(distribution['getArchitectureOptions']()).toEqual(expected); + }); +}); + +describe('findPackageForDownload', () => { + it.each([ + ['8', '8.0.282+8'], + ['11.x', '11.0.10+9'], + ['8.0', '8.0.282+8'], + ['11.0.x', '11.0.10+9'], + ['15', '15.0.2+7'], + ['9.0.0', '9.0.0+0'], + ['9.0', '9.0.1+0'], + ['8.0.262', '8.0.262+19'], // validate correct choice between [8.0.262.17, 8.0.262.19, 8.0.262.18] + ['8.0.262+17', '8.0.262+17'], + ['15.0.1+8', '15.0.1+8'], + ['15.0.1+9', '15.0.1+9'] + ])('version is %s -> %s', async (input, expected) => { + const distribution = new ZuluDistribution({ + version: input, + architecture: 'x86', + packageType: 'jdk', + checkLatest: false + }); + distribution['getAvailableVersions'] = async () => manifestData; + const result = await distribution['findPackageForDownload']( + distribution['version'] + ); + expect(result.version).toBe(expected); + }); + + it('select correct bundle if there are multiple items with the same jdk version but different zulu versions', async () => { + const distribution = new ZuluDistribution({ + version: '', + architecture: 'arm64', + packageType: 'jdk', + checkLatest: false + }); + distribution['getAvailableVersions'] = async () => manifestData; + const result = await distribution['findPackageForDownload']('21.0.2'); + expect(result.url).toBe( + 'https://cdn.azul.com/zulu/bin/zulu21.32.17-ca-jdk21.0.2-linux_aarch64.tar.gz' + ); + }); + + it('should throw an error', async () => { + const distribution = new ZuluDistribution({ + version: '18', + architecture: 'x86', + packageType: 'jdk', + checkLatest: false + }); + distribution['getAvailableVersions'] = async () => manifestData; + await expect( + distribution['findPackageForDownload'](distribution['version']) + ).rejects.toThrow(/Could not find satisfied version for semver */); + }); +}); diff --git a/__tests__/distributors/zulu-windows-installer.test.ts b/__tests__/distributors/zulu-windows-installer.test.ts new file mode 100644 index 000000000..dcac5aa0d --- /dev/null +++ b/__tests__/distributors/zulu-windows-installer.test.ts @@ -0,0 +1,229 @@ +import {HttpClient} from '@actions/http-client'; +import * as semver from 'semver'; +import {ZuluDistribution} from '../../src/distributions/zulu/installer'; +import {IZuluVersions} from '../../src/distributions/zulu/models'; +import * as utils from '../../src/util'; +import os from 'os'; + +import manifestData from '../data/zulu-windows.json'; + +describe('getAvailableVersions', () => { + let spyHttpClient: jest.SpyInstance; + let spyUtilGetDownloadArchiveExtension: jest.SpyInstance; + + beforeEach(() => { + spyHttpClient = jest.spyOn(HttpClient.prototype, 'getJson'); + spyHttpClient.mockReturnValue({ + statusCode: 200, + headers: {}, + result: manifestData as IZuluVersions[] + }); + + spyUtilGetDownloadArchiveExtension = jest.spyOn( + utils, + 'getDownloadArchiveExtension' + ); + spyUtilGetDownloadArchiveExtension.mockReturnValue('zip'); + }); + + afterEach(() => { + jest.resetAllMocks(); + jest.clearAllMocks(); + jest.restoreAllMocks(); + }); + + it.each([ + [ + { + version: '11', + architecture: 'x86', + packageType: 'jdk', + checkLatest: false + }, + '?os=windows&ext=zip&bundle_type=jdk&javafx=false&arch=x86&hw_bitness=32&release_status=ga' + ], + [ + { + version: '11-ea', + architecture: 'x86', + packageType: 'jdk', + checkLatest: false + }, + '?os=windows&ext=zip&bundle_type=jdk&javafx=false&arch=x86&hw_bitness=32&release_status=ea' + ], + [ + { + version: '8', + architecture: 'x64', + packageType: 'jdk', + checkLatest: false + }, + '?os=windows&ext=zip&bundle_type=jdk&javafx=false&arch=x86&hw_bitness=64&release_status=ga' + ], + [ + { + version: '8', + architecture: 'x64', + packageType: 'jre', + checkLatest: false + }, + '?os=windows&ext=zip&bundle_type=jre&javafx=false&arch=x86&hw_bitness=64&release_status=ga' + ], + [ + { + version: '8', + architecture: 'x64', + packageType: 'jdk+fx', + checkLatest: false + }, + '?os=windows&ext=zip&bundle_type=jdk&javafx=true&arch=x86&hw_bitness=64&release_status=ga&features=fx' + ], + [ + { + version: '8', + architecture: 'x64', + packageType: 'jre+fx', + checkLatest: false + }, + '?os=windows&ext=zip&bundle_type=jre&javafx=true&arch=x86&hw_bitness=64&release_status=ga&features=fx' + ], + [ + { + version: '11', + architecture: 'arm64', + packageType: 'jdk', + checkLatest: false + }, + '?os=windows&ext=zip&bundle_type=jdk&javafx=false&arch=arm&hw_bitness=64&release_status=ga' + ], + [ + { + version: '11', + architecture: 'arm', + packageType: 'jdk', + checkLatest: false + }, + '?os=windows&ext=zip&bundle_type=jdk&javafx=false&arch=arm&hw_bitness=&release_status=ga' + ] + ])('build correct url for %s -> %s', async (input, parsedUrl) => { + const distribution = new ZuluDistribution(input); + distribution['getPlatformOption'] = () => 'windows'; + const buildUrl = `https://api.azul.com/zulu/download/community/v1.0/bundles/${parsedUrl}`; + + await distribution['getAvailableVersions'](); + + expect(spyHttpClient.mock.calls).toHaveLength(1); + expect(spyHttpClient.mock.calls[0][0]).toBe(buildUrl); + }); + + type DistroArch = { + bitness: string; + arch: string; + }; + it.each([ + ['amd64', {bitness: '64', arch: 'x86'}], + ['arm64', {bitness: '64', arch: 'arm'}] + ])( + 'defaults to os.arch(): %s mapped to distro arch: %s', + async (osArch: string, distroArch: DistroArch) => { + jest.spyOn(os, 'arch').mockReturnValue(osArch); + + const distribution = new ZuluDistribution({ + version: '17', + architecture: '', // to get default value + packageType: 'jdk', + checkLatest: false + }); + distribution['getPlatformOption'] = () => 'windows'; + const buildUrl = `https://api.azul.com/zulu/download/community/v1.0/bundles/?os=windows&ext=zip&bundle_type=jdk&javafx=false&arch=${distroArch.arch}&hw_bitness=${distroArch.bitness}&release_status=ga`; + + await distribution['getAvailableVersions'](); + + expect(spyHttpClient.mock.calls).toHaveLength(1); + expect(spyHttpClient.mock.calls[0][0]).toBe(buildUrl); + } + ); + + it('load available versions', async () => { + const distribution = new ZuluDistribution({ + version: '11', + architecture: 'x86', + packageType: 'jdk', + checkLatest: false + }); + const availableVersions = await distribution['getAvailableVersions'](); + expect(availableVersions).toHaveLength(manifestData.length); + }); +}); + +describe('getArchitectureOptions', () => { + it.each([ + [{architecture: 'x64'}, {arch: 'x86', hw_bitness: '64', abi: ''}], + [{architecture: 'x86'}, {arch: 'x86', hw_bitness: '32', abi: ''}], + [{architecture: 'x32'}, {arch: 'x32', hw_bitness: '', abi: ''}], + [{architecture: 'arm'}, {arch: 'arm', hw_bitness: '', abi: ''}] + ])('%s -> %s', (input, expected) => { + const distribution = new ZuluDistribution({ + version: '11', + architecture: input.architecture, + packageType: 'jdk', + checkLatest: false + }); + expect(distribution['getArchitectureOptions']()).toEqual(expected); + }); +}); + +describe('findPackageForDownload', () => { + it.each([ + ['8', '8.0.282+8'], + ['11.x', '11.0.10+9'], + ['8.0', '8.0.282+8'], + ['11.0.x', '11.0.10+9'], + ['15', '15.0.2+7'], + ['9.0.0', '9.0.0+0'], + ['9.0', '9.0.1+0'], + ['8.0.262', '8.0.262+19'], // validate correct choice between [8.0.262.17, 8.0.262.19, 8.0.262.18] + ['8.0.262+17', '8.0.262+17'], + ['15.0.1+8', '15.0.1+8'], + ['15.0.1+9', '15.0.1+9'] + ])('version is %s -> %s', async (input, expected) => { + const distribution = new ZuluDistribution({ + version: input, + architecture: 'x86', + packageType: 'jdk', + checkLatest: false + }); + distribution['getAvailableVersions'] = async () => manifestData; + const result = await distribution['findPackageForDownload']( + distribution['version'] + ); + expect(result.version).toBe(expected); + }); + + it('select correct bundle if there are multiple items with the same jdk version but different zulu versions', async () => { + const distribution = new ZuluDistribution({ + version: '', + architecture: 'arm64', + packageType: 'jdk', + checkLatest: false + }); + distribution['getAvailableVersions'] = async () => manifestData; + const result = await distribution['findPackageForDownload']('17.0.10'); + expect(result.url).toBe( + 'https://cdn.azul.com/zulu/bin/zulu17.48.15-ca-jdk17.0.10-windows_aarch64.zip' + ); + }); + + it('should throw an error', async () => { + const distribution = new ZuluDistribution({ + version: '18', + architecture: 'x86', + packageType: 'jdk', + checkLatest: false + }); + distribution['getAvailableVersions'] = async () => manifestData; + await expect( + distribution['findPackageForDownload'](distribution['version']) + ).rejects.toThrow(/Could not find satisfied version for semver */); + }); +}); diff --git a/dist/cleanup/index.js b/dist/cleanup/index.js index 971673a56..c90128bb6 100644 --- a/dist/cleanup/index.js +++ b/dist/cleanup/index.js @@ -319,7 +319,8 @@ function createHttpClient() { return new http_client_1.HttpClient('actions/cache', [bearerCredentialHandler], getRequestOptions()); } function getCacheVersion(paths, compressionMethod, enableCrossOsArchive = false) { - const components = paths; + // don't pass changes upstream + const components = paths.slice(); // Add compression method to cache version to restore // compressed cache as per compression method if (compressionMethod) { @@ -608,26 +609,21 @@ function resolvePaths(patterns) { implicitDescendants: false }); try { - for (var _e = true, _f = __asyncValues(globber.globGenerator()), _g; _g = yield _f.next(), _a = _g.done, !_a;) { + for (var _e = true, _f = __asyncValues(globber.globGenerator()), _g; _g = yield _f.next(), _a = _g.done, !_a; _e = true) { _c = _g.value; _e = false; - try { - const file = _c; - const relativeFile = path - .relative(workspace, file) - .replace(new RegExp(`\\${path.sep}`, 'g'), '/'); - core.debug(`Matched: ${relativeFile}`); - // Paths are made relative so the tar entries are all relative to the root of the workspace. - if (relativeFile === '') { - // path.relative returns empty string if workspace and file are equal - paths.push('.'); - } - else { - paths.push(`${relativeFile}`); - } + const file = _c; + const relativeFile = path + .relative(workspace, file) + .replace(new RegExp(`\\${path.sep}`, 'g'), '/'); + core.debug(`Matched: ${relativeFile}`); + // Paths are made relative so the tar entries are all relative to the root of the workspace. + if (relativeFile === '') { + // path.relative returns empty string if workspace and file are equal + paths.push('.'); } - finally { - _e = true; + else { + paths.push(`${relativeFile}`); } } } @@ -711,7 +707,10 @@ function assertDefined(name, value) { exports.assertDefined = assertDefined; function isGhes() { const ghUrl = new URL(process.env['GITHUB_SERVER_URL'] || 'https://github.com'); - return ghUrl.hostname.toUpperCase() !== 'GITHUB.COM'; + const hostname = ghUrl.hostname.trimEnd().toUpperCase(); + const isGitHubHost = hostname === 'GITHUB.COM'; + const isGheHost = hostname.endsWith('.GHE.COM') || hostname.endsWith('.GHE.LOCALHOST'); + return !isGitHubHost && !isGheHost; } exports.isGhes = isGhes; //# sourceMappingURL=cacheUtils.js.map @@ -729,7 +728,7 @@ var CacheFilename; (function (CacheFilename) { CacheFilename["Gzip"] = "cache.tgz"; CacheFilename["Zstd"] = "cache.tzst"; -})(CacheFilename = exports.CacheFilename || (exports.CacheFilename = {})); +})(CacheFilename || (exports.CacheFilename = CacheFilename = {})); var CompressionMethod; (function (CompressionMethod) { CompressionMethod["Gzip"] = "gzip"; @@ -737,12 +736,12 @@ var CompressionMethod; // This enum is for earlier version of zstd that does not have --long support CompressionMethod["ZstdWithoutLong"] = "zstd-without-long"; CompressionMethod["Zstd"] = "zstd"; -})(CompressionMethod = exports.CompressionMethod || (exports.CompressionMethod = {})); +})(CompressionMethod || (exports.CompressionMethod = CompressionMethod = {})); var ArchiveToolType; (function (ArchiveToolType) { ArchiveToolType["GNU"] = "gnu"; ArchiveToolType["BSD"] = "bsd"; -})(ArchiveToolType = exports.ArchiveToolType || (exports.ArchiveToolType = {})); +})(ArchiveToolType || (exports.ArchiveToolType = ArchiveToolType = {})); // The default number of retry attempts. exports.DefaultRetryAttempts = 2; // The default delay in milliseconds between retry attempts. @@ -8551,7 +8550,7 @@ class HttpClient { if (this._keepAlive && useProxy) { agent = this._proxyAgent; } - if (this._keepAlive && !useProxy) { + if (!useProxy) { agent = this._agent; } // if agent is already assigned use that agent. @@ -8583,16 +8582,12 @@ class HttpClient { agent = tunnelAgent(agentOptions); this._proxyAgent = agent; } - // if reusing agent across request and tunneling agent isn't assigned create a new agent - if (this._keepAlive && !agent) { + // if tunneling agent isn't assigned create a new agent + if (!agent) { const options = { keepAlive: this._keepAlive, maxSockets }; agent = usingSsl ? new https.Agent(options) : new http.Agent(options); this._agent = agent; } - // if not using private agent and tunnel agent isn't setup then use global agent - if (!agent) { - agent = usingSsl ? https.globalAgent : http.globalAgent; - } if (usingSsl && this._ignoreSslError) { // we don't want to set NODE_TLS_REJECT_UNAUTHORIZED=0 since that will affect request for entire process // http.RequestOptions doesn't expose a way to modify RequestOptions.agent.options @@ -57728,35 +57723,43 @@ const coerce = (version, options) => { let match = null if (!options.rtl) { - match = version.match(re[t.COERCE]) + match = version.match(options.includePrerelease ? re[t.COERCEFULL] : re[t.COERCE]) } else { // Find the right-most coercible string that does not share // a terminus with a more left-ward coercible string. // Eg, '1.2.3.4' wants to coerce '2.3.4', not '3.4' or '4' + // With includePrerelease option set, '1.2.3.4-rc' wants to coerce '2.3.4-rc', not '2.3.4' // // Walk through the string checking with a /g regexp // Manually set the index so as to pick up overlapping matches. // Stop when we get a match that ends at the string end, since no // coercible string can be more right-ward without the same terminus. + const coerceRtlRegex = options.includePrerelease ? re[t.COERCERTLFULL] : re[t.COERCERTL] let next - while ((next = re[t.COERCERTL].exec(version)) && + while ((next = coerceRtlRegex.exec(version)) && (!match || match.index + match[0].length !== version.length) ) { if (!match || next.index + next[0].length !== match.index + match[0].length) { match = next } - re[t.COERCERTL].lastIndex = next.index + next[1].length + next[2].length + coerceRtlRegex.lastIndex = next.index + next[1].length + next[2].length } // leave it in a clean state - re[t.COERCERTL].lastIndex = -1 + coerceRtlRegex.lastIndex = -1 } if (match === null) { return null } - return parse(`${match[2]}.${match[3] || '0'}.${match[4] || '0'}`, options) + const major = match[2] + const minor = match[3] || '0' + const patch = match[4] || '0' + const prerelease = options.includePrerelease && match[5] ? `-${match[5]}` : '' + const build = options.includePrerelease && match[6] ? `+${match[6]}` : '' + + return parse(`${major}.${minor}.${patch}${prerelease}${build}`, options) } module.exports = coerce @@ -58448,12 +58451,17 @@ createToken('XRANGELOOSE', `^${src[t.GTLT]}\\s*${src[t.XRANGEPLAINLOOSE]}$`) // Coercion. // Extract anything that could conceivably be a part of a valid semver -createToken('COERCE', `${'(^|[^\\d])' + +createToken('COERCEPLAIN', `${'(^|[^\\d])' + '(\\d{1,'}${MAX_SAFE_COMPONENT_LENGTH}})` + `(?:\\.(\\d{1,${MAX_SAFE_COMPONENT_LENGTH}}))?` + - `(?:\\.(\\d{1,${MAX_SAFE_COMPONENT_LENGTH}}))?` + + `(?:\\.(\\d{1,${MAX_SAFE_COMPONENT_LENGTH}}))?`) +createToken('COERCE', `${src[t.COERCEPLAIN]}(?:$|[^\\d])`) +createToken('COERCEFULL', src[t.COERCEPLAIN] + + `(?:${src[t.PRERELEASE]})?` + + `(?:${src[t.BUILD]})?` + `(?:$|[^\\d])`) createToken('COERCERTL', src[t.COERCE], true) +createToken('COERCERTLFULL', src[t.COERCEFULL], true) // Tilde ranges. // Meaning is "reasonably at or greater than" @@ -60624,6 +60632,7 @@ const MockAgent = __nccwpck_require__(6771) const MockPool = __nccwpck_require__(6193) const mockErrors = __nccwpck_require__(888) const ProxyAgent = __nccwpck_require__(7858) +const RetryHandler = __nccwpck_require__(2286) const { getGlobalDispatcher, setGlobalDispatcher } = __nccwpck_require__(1892) const DecoratorHandler = __nccwpck_require__(6930) const RedirectHandler = __nccwpck_require__(2860) @@ -60645,6 +60654,7 @@ module.exports.Pool = Pool module.exports.BalancedPool = BalancedPool module.exports.Agent = Agent module.exports.ProxyAgent = ProxyAgent +module.exports.RetryHandler = RetryHandler module.exports.DecoratorHandler = DecoratorHandler module.exports.RedirectHandler = RedirectHandler @@ -61545,6 +61555,7 @@ function request (opts, callback) { } module.exports = request +module.exports.RequestHandler = RequestHandler /***/ }), @@ -61927,6 +61938,8 @@ const kBody = Symbol('kBody') const kAbort = Symbol('abort') const kContentType = Symbol('kContentType') +const noop = () => {} + module.exports = class BodyReadable extends Readable { constructor ({ resume, @@ -62060,37 +62073,50 @@ module.exports = class BodyReadable extends Readable { return this[kBody] } - async dump (opts) { + dump (opts) { let limit = opts && Number.isFinite(opts.limit) ? opts.limit : 262144 const signal = opts && opts.signal - const abortFn = () => { - this.destroy() - } - let signalListenerCleanup + if (signal) { - if (typeof signal !== 'object' || !('aborted' in signal)) { - throw new InvalidArgumentError('signal must be an AbortSignal') - } - util.throwIfAborted(signal) - signalListenerCleanup = util.addAbortListener(signal, abortFn) - } - try { - for await (const chunk of this) { - util.throwIfAborted(signal) - limit -= Buffer.byteLength(chunk) - if (limit < 0) { - return + try { + if (typeof signal !== 'object' || !('aborted' in signal)) { + throw new InvalidArgumentError('signal must be an AbortSignal') } - } - } catch { - util.throwIfAborted(signal) - } finally { - if (typeof signalListenerCleanup === 'function') { - signalListenerCleanup() - } else if (signalListenerCleanup) { - signalListenerCleanup[Symbol.dispose]() + util.throwIfAborted(signal) + } catch (err) { + return Promise.reject(err) } } + + if (this.closed) { + return Promise.resolve(null) + } + + return new Promise((resolve, reject) => { + const signalListenerCleanup = signal + ? util.addAbortListener(signal, () => { + this.destroy() + }) + : noop + + this + .on('close', function () { + signalListenerCleanup() + if (signal && signal.aborted) { + reject(signal.reason || Object.assign(new Error('The operation was aborted'), { name: 'AbortError' })) + } else { + resolve(null) + } + }) + .on('error', noop) + .on('data', function (chunk) { + limit -= chunk.length + if (limit <= 0) { + this.destroy() + } + }) + .resume() + }) } } @@ -63470,13 +63496,13 @@ module.exports = { /***/ }), /***/ 9174: -/***/ ((module) => { +/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { "use strict"; module.exports = { - kConstruct: Symbol('constructable') + kConstruct: (__nccwpck_require__(2785).kConstruct) } @@ -64462,11 +64488,9 @@ class Parser { socket[kReset] = true } - let pause - try { - pause = request.onHeaders(statusCode, headers, this.resume, statusText) === false - } catch (err) { - util.destroy(socket, err) + const pause = request.onHeaders(statusCode, headers, this.resume, statusText) === false + + if (request.aborted) { return -1 } @@ -64513,13 +64537,8 @@ class Parser { this.bytesRead += buf.length - try { - if (request.onData(buf) === false) { - return constants.ERROR.PAUSED - } - } catch (err) { - util.destroy(socket, err) - return -1 + if (request.onData(buf) === false) { + return constants.ERROR.PAUSED } } @@ -64560,11 +64579,7 @@ class Parser { return -1 } - try { - request.onComplete(headers) - } catch (err) { - errorRequest(client, request, err) - } + request.onComplete(headers) client[kQueue][client[kRunningIdx]++] = null @@ -64728,7 +64743,7 @@ async function connect (client) { const idx = hostname.indexOf(']') assert(idx !== -1) - const ip = hostname.substr(1, idx - 1) + const ip = hostname.substring(1, idx) assert(net.isIP(ip)) hostname = ip @@ -65227,6 +65242,7 @@ function writeH2 (client, session, request) { return false } + /** @type {import('node:http2').ClientHttp2Stream} */ let stream const h2State = client[kHTTP2SessionState] @@ -65322,14 +65338,10 @@ function writeH2 (client, session, request) { const shouldEndStream = method === 'GET' || method === 'HEAD' if (expectContinue) { headers[HTTP2_HEADER_EXPECT] = '100-continue' - /** - * @type {import('node:http2').ClientHttp2Stream} - */ stream = session.request(headers, { endStream: shouldEndStream, signal }) stream.once('continue', writeBodyH2) } else { - /** @type {import('node:http2').ClientHttp2Stream} */ stream = session.request(headers, { endStream: shouldEndStream, signal @@ -65341,7 +65353,9 @@ function writeH2 (client, session, request) { ++h2State.openStreams stream.once('response', headers => { - if (request.onHeaders(Number(headers[HTTP2_HEADER_STATUS]), headers, stream.resume.bind(stream), '') === false) { + const { [HTTP2_HEADER_STATUS]: statusCode, ...realHeaders } = headers + + if (request.onHeaders(Number(statusCode), realHeaders, stream.resume.bind(stream), '') === false) { stream.pause() } }) @@ -65351,13 +65365,17 @@ function writeH2 (client, session, request) { }) stream.on('data', (chunk) => { - if (request.onData(chunk) === false) stream.pause() + if (request.onData(chunk) === false) { + stream.pause() + } }) stream.once('close', () => { h2State.openStreams -= 1 // TODO(HTTP/2): unref only if current streams count is 0 - if (h2State.openStreams === 0) session.unref() + if (h2State.openStreams === 0) { + session.unref() + } }) stream.once('error', function (err) { @@ -65517,7 +65535,11 @@ function writeStream ({ h2stream, body, client, request, socket, contentLength, } } const onAbort = function () { - onFinished(new RequestAbortedError()) + if (finished) { + return + } + const err = new RequestAbortedError() + queueMicrotask(() => onFinished(err)) } const onFinished = function (err) { if (finished) { @@ -67122,6 +67144,19 @@ class ResponseExceededMaxSizeError extends UndiciError { } } +class RequestRetryError extends UndiciError { + constructor (message, code, { headers, data }) { + super(message) + Error.captureStackTrace(this, RequestRetryError) + this.name = 'RequestRetryError' + this.message = message || 'Request retry error' + this.code = 'UND_ERR_REQ_RETRY' + this.statusCode = code + this.data = data + this.headers = headers + } +} + module.exports = { HTTPParserError, UndiciError, @@ -67141,7 +67176,8 @@ module.exports = { NotSupportedError, ResponseContentLengthMismatchError, BalancedPoolMissingUpstreamError, - ResponseExceededMaxSizeError + ResponseExceededMaxSizeError, + RequestRetryError } @@ -67383,9 +67419,9 @@ class Request { onBodySent (chunk) { if (this[kHandler].onBodySent) { try { - this[kHandler].onBodySent(chunk) + return this[kHandler].onBodySent(chunk) } catch (err) { - this.onError(err) + this.abort(err) } } } @@ -67397,9 +67433,9 @@ class Request { if (this[kHandler].onRequestSent) { try { - this[kHandler].onRequestSent() + return this[kHandler].onRequestSent() } catch (err) { - this.onError(err) + this.abort(err) } } } @@ -67424,14 +67460,23 @@ class Request { channels.headers.publish({ request: this, response: { statusCode, headers, statusText } }) } - return this[kHandler].onHeaders(statusCode, headers, resume, statusText) + try { + return this[kHandler].onHeaders(statusCode, headers, resume, statusText) + } catch (err) { + this.abort(err) + } } onData (chunk) { assert(!this.aborted) assert(!this.completed) - return this[kHandler].onData(chunk) + try { + return this[kHandler].onData(chunk) + } catch (err) { + this.abort(err) + return false + } } onUpgrade (statusCode, headers, socket) { @@ -67450,7 +67495,13 @@ class Request { if (channels.trailers.hasSubscribers) { channels.trailers.publish({ request: this, trailers }) } - return this[kHandler].onComplete(trailers) + + try { + return this[kHandler].onComplete(trailers) + } catch (err) { + // TODO (fix): This might be a bad idea? + this.onError(err) + } } onError (error) { @@ -67464,6 +67515,7 @@ class Request { return } this.aborted = true + return this[kHandler].onError(error) } @@ -67700,7 +67752,9 @@ module.exports = { kHTTP2BuildRequest: Symbol('http2 build request'), kHTTP1BuildRequest: Symbol('http1 build request'), kHTTP2CopyHeaders: Symbol('http2 copy headers'), - kHTTPConnVersion: Symbol('http connection version') + kHTTPConnVersion: Symbol('http connection version'), + kRetryHandlerDefaultRetry: Symbol('retry agent default retry'), + kConstruct: Symbol('constructable') } @@ -67837,13 +67891,13 @@ function getHostname (host) { const idx = host.indexOf(']') assert(idx !== -1) - return host.substr(1, idx - 1) + return host.substring(1, idx) } const idx = host.indexOf(':') if (idx === -1) return host - return host.substr(0, idx) + return host.substring(0, idx) } // IP addresses are not valid server names per RFC6066 @@ -67940,7 +67994,7 @@ function parseHeaders (headers, obj = {}) { if (!val) { if (Array.isArray(headers[i + 1])) { - obj[key] = headers[i + 1] + obj[key] = headers[i + 1].map(x => x.toString('utf8')) } else { obj[key] = headers[i + 1].toString('utf8') } @@ -68143,16 +68197,7 @@ function throwIfAborted (signal) { } } -let events function addAbortListener (signal, listener) { - if (typeof Symbol.dispose === 'symbol') { - if (!events) { - events = __nccwpck_require__(2361) - } - if (typeof events.addAbortListener === 'function' && 'aborted' in signal) { - return events.addAbortListener(signal, listener) - } - } if ('addEventListener' in signal) { signal.addEventListener('abort', listener, { once: true }) return () => signal.removeEventListener('abort', listener) @@ -68176,6 +68221,21 @@ function toUSVString (val) { return `${val}` } +// Parsed accordingly to RFC 9110 +// https://www.rfc-editor.org/rfc/rfc9110#field.content-range +function parseRangeHeader (range) { + if (range == null || range === '') return { start: 0, end: null, size: null } + + const m = range ? range.match(/^bytes (\d+)-(\d+)\/(\d+)?$/) : null + return m + ? { + start: parseInt(m[1]), + end: m[2] ? parseInt(m[2]) : null, + size: m[3] ? parseInt(m[3]) : null + } + : null +} + const kEnumerableProperty = Object.create(null) kEnumerableProperty.enumerable = true @@ -68209,9 +68269,11 @@ module.exports = { buildURL, throwIfAborted, addAbortListener, + parseRangeHeader, nodeMajor, nodeMinor, - nodeHasAutoSelectFamily: nodeMajor > 18 || (nodeMajor === 18 && nodeMinor >= 13) + nodeHasAutoSelectFamily: nodeMajor > 18 || (nodeMajor === 18 && nodeMinor >= 13), + safeHTTPMethods: ['GET', 'HEAD', 'OPTIONS', 'TRACE'] } @@ -69340,17 +69402,14 @@ function dataURLProcessor (dataURL) { * @param {boolean} excludeFragment */ function URLSerializer (url, excludeFragment = false) { - const href = url.href - if (!excludeFragment) { - return href + return url.href } - const hash = href.lastIndexOf('#') - if (hash === -1) { - return href - } - return href.slice(0, hash) + const href = url.href + const hashLength = url.hash.length + + return hashLength === 0 ? href : href.substring(0, href.length - hashLength) } // https://infra.spec.whatwg.org/#collect-a-sequence-of-code-points @@ -70534,7 +70593,7 @@ module.exports = { -const { kHeadersList } = __nccwpck_require__(2785) +const { kHeadersList, kConstruct } = __nccwpck_require__(2785) const { kGuard } = __nccwpck_require__(5861) const { kEnumerableProperty } = __nccwpck_require__(3983) const { @@ -70548,6 +70607,13 @@ const assert = __nccwpck_require__(9491) const kHeadersMap = Symbol('headers map') const kHeadersSortedMap = Symbol('headers map sorted') +/** + * @param {number} code + */ +function isHTTPWhiteSpaceCharCode (code) { + return code === 0x00a || code === 0x00d || code === 0x009 || code === 0x020 +} + /** * @see https://fetch.spec.whatwg.org/#concept-header-value-normalize * @param {string} potentialValue @@ -70556,12 +70622,12 @@ function headerValueNormalize (potentialValue) { // To normalize a byte sequence potentialValue, remove // any leading and trailing HTTP whitespace bytes from // potentialValue. + let i = 0; let j = potentialValue.length - // Trimming the end with `.replace()` and a RegExp is typically subject to - // ReDoS. This is safer and faster. - let i = potentialValue.length - while (/[\r\n\t ]/.test(potentialValue.charAt(--i))); - return potentialValue.slice(0, i + 1).replace(/^[\r\n\t ]+/, '') + while (j > i && isHTTPWhiteSpaceCharCode(potentialValue.charCodeAt(j - 1))) --j + while (j > i && isHTTPWhiteSpaceCharCode(potentialValue.charCodeAt(i))) ++i + + return i === 0 && j === potentialValue.length ? potentialValue : potentialValue.substring(i, j) } function fill (headers, object) { @@ -70570,7 +70636,8 @@ function fill (headers, object) { // 1. If object is a sequence, then for each header in object: // Note: webidl conversion to array has already been done. if (Array.isArray(object)) { - for (const header of object) { + for (let i = 0; i < object.length; ++i) { + const header = object[i] // 1. If header does not contain exactly two items, then throw a TypeError. if (header.length !== 2) { throw webidl.errors.exception({ @@ -70580,15 +70647,16 @@ function fill (headers, object) { } // 2. Append (header’s first item, header’s second item) to headers. - headers.append(header[0], header[1]) + appendHeader(headers, header[0], header[1]) } } else if (typeof object === 'object' && object !== null) { // Note: null should throw // 2. Otherwise, object is a record, then for each key → value in object, // append (key, value) to headers - for (const [key, value] of Object.entries(object)) { - headers.append(key, value) + const keys = Object.keys(object) + for (let i = 0; i < keys.length; ++i) { + appendHeader(headers, keys[i], object[keys[i]]) } } else { throw webidl.errors.conversionFailed({ @@ -70599,6 +70667,50 @@ function fill (headers, object) { } } +/** + * @see https://fetch.spec.whatwg.org/#concept-headers-append + */ +function appendHeader (headers, name, value) { + // 1. Normalize value. + value = headerValueNormalize(value) + + // 2. If name is not a header name or value is not a + // header value, then throw a TypeError. + if (!isValidHeaderName(name)) { + throw webidl.errors.invalidArgument({ + prefix: 'Headers.append', + value: name, + type: 'header name' + }) + } else if (!isValidHeaderValue(value)) { + throw webidl.errors.invalidArgument({ + prefix: 'Headers.append', + value, + type: 'header value' + }) + } + + // 3. If headers’s guard is "immutable", then throw a TypeError. + // 4. Otherwise, if headers’s guard is "request" and name is a + // forbidden header name, return. + // Note: undici does not implement forbidden header names + if (headers[kGuard] === 'immutable') { + throw new TypeError('immutable') + } else if (headers[kGuard] === 'request-no-cors') { + // 5. Otherwise, if headers’s guard is "request-no-cors": + // TODO + } + + // 6. Otherwise, if headers’s guard is "response" and name is a + // forbidden response-header name, return. + + // 7. Append (name, value) to headers’s header list. + return headers[kHeadersList].append(name, value) + + // 8. If headers’s guard is "request-no-cors", then remove + // privileged no-CORS request headers from headers +} + class HeadersList { /** @type {[string, string][]|null} */ cookies = null @@ -70607,7 +70719,7 @@ class HeadersList { if (init instanceof HeadersList) { this[kHeadersMap] = new Map(init[kHeadersMap]) this[kHeadersSortedMap] = init[kHeadersSortedMap] - this.cookies = init.cookies + this.cookies = init.cookies === null ? null : [...init.cookies] } else { this[kHeadersMap] = new Map(init) this[kHeadersSortedMap] = null @@ -70669,7 +70781,7 @@ class HeadersList { // the first such header to value and remove the // others. // 2. Otherwise, append header (name, value) to list. - return this[kHeadersMap].set(lowercaseName, { name, value }) + this[kHeadersMap].set(lowercaseName, { name, value }) } // https://fetch.spec.whatwg.org/#concept-header-list-delete @@ -70682,20 +70794,18 @@ class HeadersList { this.cookies = null } - return this[kHeadersMap].delete(name) + this[kHeadersMap].delete(name) } // https://fetch.spec.whatwg.org/#concept-header-list-get get (name) { - // 1. If list does not contain name, then return null. - if (!this.contains(name)) { - return null - } + const value = this[kHeadersMap].get(name.toLowerCase()) + // 1. If list does not contain name, then return null. // 2. Return the values of all headers in list whose name // is a byte-case-insensitive match for name, // separated from each other by 0x2C 0x20, in order. - return this[kHeadersMap].get(name.toLowerCase())?.value ?? null + return value === undefined ? null : value.value } * [Symbol.iterator] () { @@ -70721,6 +70831,9 @@ class HeadersList { // https://fetch.spec.whatwg.org/#headers-class class Headers { constructor (init = undefined) { + if (init === kConstruct) { + return + } this[kHeadersList] = new HeadersList() // The new Headers(init) constructor steps are: @@ -70744,43 +70857,7 @@ class Headers { name = webidl.converters.ByteString(name) value = webidl.converters.ByteString(value) - // 1. Normalize value. - value = headerValueNormalize(value) - - // 2. If name is not a header name or value is not a - // header value, then throw a TypeError. - if (!isValidHeaderName(name)) { - throw webidl.errors.invalidArgument({ - prefix: 'Headers.append', - value: name, - type: 'header name' - }) - } else if (!isValidHeaderValue(value)) { - throw webidl.errors.invalidArgument({ - prefix: 'Headers.append', - value, - type: 'header value' - }) - } - - // 3. If headers’s guard is "immutable", then throw a TypeError. - // 4. Otherwise, if headers’s guard is "request" and name is a - // forbidden header name, return. - // Note: undici does not implement forbidden header names - if (this[kGuard] === 'immutable') { - throw new TypeError('immutable') - } else if (this[kGuard] === 'request-no-cors') { - // 5. Otherwise, if headers’s guard is "request-no-cors": - // TODO - } - - // 6. Otherwise, if headers’s guard is "response" and name is a - // forbidden response-header name, return. - - // 7. Append (name, value) to headers’s header list. - // 8. If headers’s guard is "request-no-cors", then remove - // privileged no-CORS request headers from headers - return this[kHeadersList].append(name, value) + return appendHeader(this, name, value) } // https://fetch.spec.whatwg.org/#dom-headers-delete @@ -70825,7 +70902,7 @@ class Headers { // 7. Delete name from this’s header list. // 8. If this’s guard is "request-no-cors", then remove // privileged no-CORS request headers from this. - return this[kHeadersList].delete(name) + this[kHeadersList].delete(name) } // https://fetch.spec.whatwg.org/#dom-headers-get @@ -70918,7 +70995,7 @@ class Headers { // 7. Set (name, value) in this’s header list. // 8. If this’s guard is "request-no-cors", then remove // privileged no-CORS request headers from this - return this[kHeadersList].set(name, value) + this[kHeadersList].set(name, value) } // https://fetch.spec.whatwg.org/#dom-headers-getsetcookie @@ -70954,7 +71031,8 @@ class Headers { const cookies = this[kHeadersList].cookies // 3. For each name of names: - for (const [name, value] of names) { + for (let i = 0; i < names.length; ++i) { + const [name, value] = names[i] // 1. If name is `set-cookie`, then: if (name === 'set-cookie') { // 1. Let values be a list of all values of headers in list whose name @@ -70962,8 +71040,8 @@ class Headers { // 2. For each value of values: // 1. Append (name, value) to headers. - for (const value of cookies) { - headers.push([name, value]) + for (let j = 0; j < cookies.length; ++j) { + headers.push([name, cookies[j]]) } } else { // 2. Otherwise: @@ -70987,6 +71065,12 @@ class Headers { keys () { webidl.brandCheck(this, Headers) + if (this[kGuard] === 'immutable') { + const value = this[kHeadersSortedMap] + return makeIterator(() => value, 'Headers', + 'key') + } + return makeIterator( () => [...this[kHeadersSortedMap].values()], 'Headers', @@ -70997,6 +71081,12 @@ class Headers { values () { webidl.brandCheck(this, Headers) + if (this[kGuard] === 'immutable') { + const value = this[kHeadersSortedMap] + return makeIterator(() => value, 'Headers', + 'value') + } + return makeIterator( () => [...this[kHeadersSortedMap].values()], 'Headers', @@ -71007,6 +71097,12 @@ class Headers { entries () { webidl.brandCheck(this, Headers) + if (this[kGuard] === 'immutable') { + const value = this[kHeadersSortedMap] + return makeIterator(() => value, 'Headers', + 'key+value') + } + return makeIterator( () => [...this[kHeadersSortedMap].values()], 'Headers', @@ -71378,7 +71474,7 @@ function finalizeAndReportTiming (response, initiatorType = 'other') { } // 8. If response’s timing allow passed flag is not set, then: - if (!timingInfo.timingAllowPassed) { + if (!response.timingAllowPassed) { // 1. Set timingInfo to a the result of creating an opaque timing info for timingInfo. timingInfo = createOpaqueTimingInfo({ startTime: timingInfo.startTime @@ -72295,6 +72391,9 @@ function httpRedirectFetch (fetchParams, response) { // https://fetch.spec.whatwg.org/#cors-non-wildcard-request-header-name request.headersList.delete('authorization') + // https://fetch.spec.whatwg.org/#authentication-entries + request.headersList.delete('proxy-authorization', true) + // "Cookie" and "Host" are forbidden request-headers, which undici doesn't implement. request.headersList.delete('cookie') request.headersList.delete('host') @@ -73049,7 +73148,7 @@ async function httpNetworkFetch ( path: url.pathname + url.search, origin: url.origin, method: request.method, - body: fetchParams.controller.dispatcher.isMockActive ? request.body && request.body.source : body, + body: fetchParams.controller.dispatcher.isMockActive ? request.body && (request.body.source || request.body.stream) : body, headers: request.headersList.entries, maxRedirections: 0, upgrade: request.mode === 'websocket' ? 'websocket' : undefined @@ -73094,7 +73193,7 @@ async function httpNetworkFetch ( location = val } - headers.append(key, val) + headers[kHeadersList].append(key, val) } } else { const keys = Object.keys(headersList) @@ -73108,7 +73207,7 @@ async function httpNetworkFetch ( location = val } - headers.append(key, val) + headers[kHeadersList].append(key, val) } } @@ -73212,7 +73311,7 @@ async function httpNetworkFetch ( const key = headersList[n + 0].toString('latin1') const val = headersList[n + 1].toString('latin1') - headers.append(key, val) + headers[kHeadersList].append(key, val) } resolve({ @@ -73255,7 +73354,8 @@ const { isValidHTTPToken, sameOrigin, normalizeMethod, - makePolicyContainer + makePolicyContainer, + normalizeMethodRecord } = __nccwpck_require__(2538) const { forbiddenMethodsSet, @@ -73272,13 +73372,12 @@ const { kHeaders, kSignal, kState, kGuard, kRealm } = __nccwpck_require__(5861) const { webidl } = __nccwpck_require__(1744) const { getGlobalOrigin } = __nccwpck_require__(1246) const { URLSerializer } = __nccwpck_require__(685) -const { kHeadersList } = __nccwpck_require__(2785) +const { kHeadersList, kConstruct } = __nccwpck_require__(2785) const assert = __nccwpck_require__(9491) const { getMaxListeners, setMaxListeners, getEventListeners, defaultMaxListeners } = __nccwpck_require__(2361) let TransformStream = globalThis.TransformStream -const kInit = Symbol('init') const kAbortController = Symbol('abortController') const requestFinalizer = new FinalizationRegistry(({ signal, abort }) => { @@ -73289,7 +73388,7 @@ const requestFinalizer = new FinalizationRegistry(({ signal, abort }) => { class Request { // https://fetch.spec.whatwg.org/#dom-request constructor (input, init = {}) { - if (input === kInit) { + if (input === kConstruct) { return } @@ -73428,8 +73527,10 @@ class Request { urlList: [...request.urlList] }) + const initHasKey = Object.keys(init).length !== 0 + // 13. If init is not empty, then: - if (Object.keys(init).length > 0) { + if (initHasKey) { // 1. If request’s mode is "navigate", then set it to "same-origin". if (request.mode === 'navigate') { request.mode = 'same-origin' @@ -73544,7 +73645,7 @@ class Request { } // 23. If init["integrity"] exists, then set request’s integrity metadata to it. - if (init.integrity !== undefined && init.integrity != null) { + if (init.integrity != null) { request.integrity = String(init.integrity) } @@ -73560,16 +73661,16 @@ class Request { // 2. If method is not a method or method is a forbidden method, then // throw a TypeError. - if (!isValidHTTPToken(init.method)) { - throw TypeError(`'${init.method}' is not a valid HTTP method.`) + if (!isValidHTTPToken(method)) { + throw new TypeError(`'${method}' is not a valid HTTP method.`) } if (forbiddenMethodsSet.has(method.toUpperCase())) { - throw TypeError(`'${init.method}' HTTP method is unsupported.`) + throw new TypeError(`'${method}' HTTP method is unsupported.`) } // 3. Normalize method. - method = normalizeMethod(init.method) + method = normalizeMethodRecord[method] ?? normalizeMethod(method) // 4. Set request’s method to method. request.method = method @@ -73640,7 +73741,7 @@ class Request { // 30. Set this’s headers to a new Headers object with this’s relevant // Realm, whose header list is request’s header list and guard is // "request". - this[kHeaders] = new Headers() + this[kHeaders] = new Headers(kConstruct) this[kHeaders][kHeadersList] = request.headersList this[kHeaders][kGuard] = 'request' this[kHeaders][kRealm] = this[kRealm] @@ -73660,25 +73761,25 @@ class Request { } // 32. If init is not empty, then: - if (Object.keys(init).length !== 0) { + if (initHasKey) { + /** @type {HeadersList} */ + const headersList = this[kHeaders][kHeadersList] // 1. Let headers be a copy of this’s headers and its associated header // list. - let headers = new Headers(this[kHeaders]) - // 2. If init["headers"] exists, then set headers to init["headers"]. - if (init.headers !== undefined) { - headers = init.headers - } + const headers = init.headers !== undefined ? init.headers : new HeadersList(headersList) // 3. Empty this’s headers’s header list. - this[kHeaders][kHeadersList].clear() + headersList.clear() // 4. If headers is a Headers object, then for each header in its header // list, append header’s name/header’s value to this’s headers. - if (headers.constructor.name === 'Headers') { + if (headers instanceof HeadersList) { for (const [key, val] of headers) { - this[kHeaders].append(key, val) + headersList.append(key, val) } + // Note: Copy the `set-cookie` meta-data. + headersList.cookies = headers.cookies } else { // 5. Otherwise, fill this’s headers with headers. fillHeaders(this[kHeaders], headers) @@ -73967,10 +74068,10 @@ class Request { // 3. Let clonedRequestObject be the result of creating a Request object, // given clonedRequest, this’s headers’s guard, and this’s relevant Realm. - const clonedRequestObject = new Request(kInit) + const clonedRequestObject = new Request(kConstruct) clonedRequestObject[kState] = clonedRequest clonedRequestObject[kRealm] = this[kRealm] - clonedRequestObject[kHeaders] = new Headers() + clonedRequestObject[kHeaders] = new Headers(kConstruct) clonedRequestObject[kHeaders][kHeadersList] = clonedRequest.headersList clonedRequestObject[kHeaders][kGuard] = this[kHeaders][kGuard] clonedRequestObject[kHeaders][kRealm] = this[kHeaders][kRealm] @@ -74220,7 +74321,7 @@ const { webidl } = __nccwpck_require__(1744) const { FormData } = __nccwpck_require__(2015) const { getGlobalOrigin } = __nccwpck_require__(1246) const { URLSerializer } = __nccwpck_require__(685) -const { kHeadersList } = __nccwpck_require__(2785) +const { kHeadersList, kConstruct } = __nccwpck_require__(2785) const assert = __nccwpck_require__(9491) const { types } = __nccwpck_require__(3837) @@ -74341,7 +74442,7 @@ class Response { // 2. Set this’s headers to a new Headers object with this’s relevant // Realm, whose header list is this’s response’s header list and guard // is "response". - this[kHeaders] = new Headers() + this[kHeaders] = new Headers(kConstruct) this[kHeaders][kGuard] = 'response' this[kHeaders][kHeadersList] = this[kState].headersList this[kHeaders][kRealm] = this[kRealm] @@ -74711,11 +74812,7 @@ webidl.converters.XMLHttpRequestBodyInit = function (V) { return webidl.converters.Blob(V, { strict: false }) } - if ( - types.isAnyArrayBuffer(V) || - types.isTypedArray(V) || - types.isDataView(V) - ) { + if (types.isArrayBuffer(V) || types.isTypedArray(V) || types.isDataView(V)) { return webidl.converters.BufferSource(V) } @@ -74901,52 +74998,57 @@ function isValidReasonPhrase (statusText) { return true } -function isTokenChar (c) { - return !( - c >= 0x7f || - c <= 0x20 || - c === '(' || - c === ')' || - c === '<' || - c === '>' || - c === '@' || - c === ',' || - c === ';' || - c === ':' || - c === '\\' || - c === '"' || - c === '/' || - c === '[' || - c === ']' || - c === '?' || - c === '=' || - c === '{' || - c === '}' - ) +/** + * @see https://tools.ietf.org/html/rfc7230#section-3.2.6 + * @param {number} c + */ +function isTokenCharCode (c) { + switch (c) { + case 0x22: + case 0x28: + case 0x29: + case 0x2c: + case 0x2f: + case 0x3a: + case 0x3b: + case 0x3c: + case 0x3d: + case 0x3e: + case 0x3f: + case 0x40: + case 0x5b: + case 0x5c: + case 0x5d: + case 0x7b: + case 0x7d: + // DQUOTE and "(),/:;<=>?@[\]{}" + return false + default: + // VCHAR %x21-7E + return c >= 0x21 && c <= 0x7e + } } -// See RFC 7230, Section 3.2.6. -// https://github.com/chromium/chromium/blob/d7da0240cae77824d1eda25745c4022757499131/third_party/blink/renderer/platform/network/http_parsers.cc#L321 +/** + * @param {string} characters + */ function isValidHTTPToken (characters) { - if (!characters || typeof characters !== 'string') { + if (characters.length === 0) { return false } for (let i = 0; i < characters.length; ++i) { - const c = characters.charCodeAt(i) - if (c > 0x7f || !isTokenChar(c)) { + if (!isTokenCharCode(characters.charCodeAt(i))) { return false } } return true } -// https://fetch.spec.whatwg.org/#header-name -// https://github.com/chromium/chromium/blob/b3d37e6f94f87d59e44662d6078f6a12de845d17/net/http/http_util.cc#L342 +/** + * @see https://fetch.spec.whatwg.org/#header-name + * @param {string} potentialValue + */ function isValidHeaderName (potentialValue) { - if (potentialValue.length === 0) { - return false - } - return isValidHTTPToken(potentialValue) } @@ -75491,11 +75593,30 @@ function isCancelled (fetchParams) { fetchParams.controller.state === 'terminated' } -// https://fetch.spec.whatwg.org/#concept-method-normalize +const normalizeMethodRecord = { + delete: 'DELETE', + DELETE: 'DELETE', + get: 'GET', + GET: 'GET', + head: 'HEAD', + HEAD: 'HEAD', + options: 'OPTIONS', + OPTIONS: 'OPTIONS', + post: 'POST', + POST: 'POST', + put: 'PUT', + PUT: 'PUT' +} + +// Note: object prototypes should not be able to be referenced. e.g. `Object#hasOwnProperty`. +Object.setPrototypeOf(normalizeMethodRecord, null) + +/** + * @see https://fetch.spec.whatwg.org/#concept-method-normalize + * @param {string} method + */ function normalizeMethod (method) { - return /^(DELETE|GET|HEAD|OPTIONS|POST|PUT)$/i.test(method) - ? method.toUpperCase() - : method + return normalizeMethodRecord[method.toLowerCase()] ?? method } // https://infra.spec.whatwg.org/#serialize-a-javascript-value-to-a-json-string @@ -75840,7 +75961,8 @@ module.exports = { urlIsLocal, urlHasHttpsScheme, urlIsHttpHttpsScheme, - readAllBytes + readAllBytes, + normalizeMethodRecord } @@ -76279,12 +76401,10 @@ webidl.converters.ByteString = function (V) { // 2. If the value of any element of x is greater than // 255, then throw a TypeError. for (let index = 0; index < x.length; index++) { - const charCode = x.charCodeAt(index) - - if (charCode > 255) { + if (x.charCodeAt(index) > 255) { throw new TypeError( 'Cannot convert argument to a ByteString because the character at ' + - `index ${index} has a value of ${charCode} which is greater than 255.` + `index ${index} has a value of ${x.charCodeAt(index)} which is greater than 255.` ) } } @@ -77961,6 +78081,349 @@ function cleanRequestHeaders (headers, removeContent, unknownOrigin) { module.exports = RedirectHandler +/***/ }), + +/***/ 2286: +/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { + +const assert = __nccwpck_require__(9491) + +const { kRetryHandlerDefaultRetry } = __nccwpck_require__(2785) +const { RequestRetryError } = __nccwpck_require__(8045) +const { isDisturbed, parseHeaders, parseRangeHeader } = __nccwpck_require__(3983) + +function calculateRetryAfterHeader (retryAfter) { + const current = Date.now() + const diff = new Date(retryAfter).getTime() - current + + return diff +} + +class RetryHandler { + constructor (opts, handlers) { + const { retryOptions, ...dispatchOpts } = opts + const { + // Retry scoped + retry: retryFn, + maxRetries, + maxTimeout, + minTimeout, + timeoutFactor, + // Response scoped + methods, + errorCodes, + retryAfter, + statusCodes + } = retryOptions ?? {} + + this.dispatch = handlers.dispatch + this.handler = handlers.handler + this.opts = dispatchOpts + this.abort = null + this.aborted = false + this.retryOpts = { + retry: retryFn ?? RetryHandler[kRetryHandlerDefaultRetry], + retryAfter: retryAfter ?? true, + maxTimeout: maxTimeout ?? 30 * 1000, // 30s, + timeout: minTimeout ?? 500, // .5s + timeoutFactor: timeoutFactor ?? 2, + maxRetries: maxRetries ?? 5, + // What errors we should retry + methods: methods ?? ['GET', 'HEAD', 'OPTIONS', 'PUT', 'DELETE', 'TRACE'], + // Indicates which errors to retry + statusCodes: statusCodes ?? [500, 502, 503, 504, 429], + // List of errors to retry + errorCodes: errorCodes ?? [ + 'ECONNRESET', + 'ECONNREFUSED', + 'ENOTFOUND', + 'ENETDOWN', + 'ENETUNREACH', + 'EHOSTDOWN', + 'EHOSTUNREACH', + 'EPIPE' + ] + } + + this.retryCount = 0 + this.start = 0 + this.end = null + this.etag = null + this.resume = null + + // Handle possible onConnect duplication + this.handler.onConnect(reason => { + this.aborted = true + if (this.abort) { + this.abort(reason) + } else { + this.reason = reason + } + }) + } + + onRequestSent () { + if (this.handler.onRequestSent) { + this.handler.onRequestSent() + } + } + + onUpgrade (statusCode, headers, socket) { + if (this.handler.onUpgrade) { + this.handler.onUpgrade(statusCode, headers, socket) + } + } + + onConnect (abort) { + if (this.aborted) { + abort(this.reason) + } else { + this.abort = abort + } + } + + onBodySent (chunk) { + if (this.handler.onBodySent) return this.handler.onBodySent(chunk) + } + + static [kRetryHandlerDefaultRetry] (err, { state, opts }, cb) { + const { statusCode, code, headers } = err + const { method, retryOptions } = opts + const { + maxRetries, + timeout, + maxTimeout, + timeoutFactor, + statusCodes, + errorCodes, + methods + } = retryOptions + let { counter, currentTimeout } = state + + currentTimeout = + currentTimeout != null && currentTimeout > 0 ? currentTimeout : timeout + + // Any code that is not a Undici's originated and allowed to retry + if ( + code && + code !== 'UND_ERR_REQ_RETRY' && + code !== 'UND_ERR_SOCKET' && + !errorCodes.includes(code) + ) { + cb(err) + return + } + + // If a set of method are provided and the current method is not in the list + if (Array.isArray(methods) && !methods.includes(method)) { + cb(err) + return + } + + // If a set of status code are provided and the current status code is not in the list + if ( + statusCode != null && + Array.isArray(statusCodes) && + !statusCodes.includes(statusCode) + ) { + cb(err) + return + } + + // If we reached the max number of retries + if (counter > maxRetries) { + cb(err) + return + } + + let retryAfterHeader = headers != null && headers['retry-after'] + if (retryAfterHeader) { + retryAfterHeader = Number(retryAfterHeader) + retryAfterHeader = isNaN(retryAfterHeader) + ? calculateRetryAfterHeader(retryAfterHeader) + : retryAfterHeader * 1e3 // Retry-After is in seconds + } + + const retryTimeout = + retryAfterHeader > 0 + ? Math.min(retryAfterHeader, maxTimeout) + : Math.min(currentTimeout * timeoutFactor ** counter, maxTimeout) + + state.currentTimeout = retryTimeout + + setTimeout(() => cb(null), retryTimeout) + } + + onHeaders (statusCode, rawHeaders, resume, statusMessage) { + const headers = parseHeaders(rawHeaders) + + this.retryCount += 1 + + if (statusCode >= 300) { + this.abort( + new RequestRetryError('Request failed', statusCode, { + headers, + count: this.retryCount + }) + ) + return false + } + + // Checkpoint for resume from where we left it + if (this.resume != null) { + this.resume = null + + if (statusCode !== 206) { + return true + } + + const contentRange = parseRangeHeader(headers['content-range']) + // If no content range + if (!contentRange) { + this.abort( + new RequestRetryError('Content-Range mismatch', statusCode, { + headers, + count: this.retryCount + }) + ) + return false + } + + // Let's start with a weak etag check + if (this.etag != null && this.etag !== headers.etag) { + this.abort( + new RequestRetryError('ETag mismatch', statusCode, { + headers, + count: this.retryCount + }) + ) + return false + } + + const { start, size, end = size } = contentRange + + assert(this.start === start, 'content-range mismatch') + assert(this.end == null || this.end === end, 'content-range mismatch') + + this.resume = resume + return true + } + + if (this.end == null) { + if (statusCode === 206) { + // First time we receive 206 + const range = parseRangeHeader(headers['content-range']) + + if (range == null) { + return this.handler.onHeaders( + statusCode, + rawHeaders, + resume, + statusMessage + ) + } + + const { start, size, end = size } = range + + assert( + start != null && Number.isFinite(start) && this.start !== start, + 'content-range mismatch' + ) + assert(Number.isFinite(start)) + assert( + end != null && Number.isFinite(end) && this.end !== end, + 'invalid content-length' + ) + + this.start = start + this.end = end + } + + // We make our best to checkpoint the body for further range headers + if (this.end == null) { + const contentLength = headers['content-length'] + this.end = contentLength != null ? Number(contentLength) : null + } + + assert(Number.isFinite(this.start)) + assert( + this.end == null || Number.isFinite(this.end), + 'invalid content-length' + ) + + this.resume = resume + this.etag = headers.etag != null ? headers.etag : null + + return this.handler.onHeaders( + statusCode, + rawHeaders, + resume, + statusMessage + ) + } + + const err = new RequestRetryError('Request failed', statusCode, { + headers, + count: this.retryCount + }) + + this.abort(err) + + return false + } + + onData (chunk) { + this.start += chunk.length + + return this.handler.onData(chunk) + } + + onComplete (rawTrailers) { + this.retryCount = 0 + return this.handler.onComplete(rawTrailers) + } + + onError (err) { + if (this.aborted || isDisturbed(this.opts.body)) { + return this.handler.onError(err) + } + + this.retryOpts.retry( + err, + { + state: { counter: this.retryCount++, currentTimeout: this.retryAfter }, + opts: { retryOptions: this.retryOpts, ...this.opts } + }, + onRetry.bind(this) + ) + + function onRetry (err) { + if (err != null || this.aborted || isDisturbed(this.opts.body)) { + return this.handler.onError(err) + } + + if (this.start !== 0) { + this.opts = { + ...this.opts, + headers: { + ...this.opts.headers, + range: `bytes=${this.start}-${this.end ?? ''}` + } + } + } + + try { + this.dispatch(this.opts, this) + } catch (err) { + this.handler.onError(err) + } + } + } +} + +module.exports = RetryHandler + + /***/ }), /***/ 8861: @@ -79883,6 +80346,9 @@ class ProxyAgent extends DispatcherBase { this[kProxyTls] = opts.proxyTls this[kProxyHeaders] = opts.headers || {} + const resolvedUrl = new URL(opts.uri) + const { origin, port, host, username, password } = resolvedUrl + if (opts.auth && opts.token) { throw new InvalidArgumentError('opts.auth cannot be used in combination with opts.token') } else if (opts.auth) { @@ -79890,11 +80356,10 @@ class ProxyAgent extends DispatcherBase { this[kProxyHeaders]['proxy-authorization'] = `Basic ${opts.auth}` } else if (opts.token) { this[kProxyHeaders]['proxy-authorization'] = opts.token + } else if (username && password) { + this[kProxyHeaders]['proxy-authorization'] = `Basic ${Buffer.from(`${decodeURIComponent(username)}:${decodeURIComponent(password)}`).toString('base64')}` } - const resolvedUrl = new URL(opts.uri) - const { origin, port, host } = resolvedUrl - const connect = buildConnector({ ...opts.proxyTls }) this[kConnectEndpoint] = buildConnector({ ...opts.requestTls }) this[kClient] = clientFactory(resolvedUrl, { connect }) @@ -79918,7 +80383,7 @@ class ProxyAgent extends DispatcherBase { }) if (statusCode !== 200) { socket.on('error', () => {}).destroy() - callback(new RequestAbortedError('Proxy response !== 200 when HTTP Tunneling')) + callback(new RequestAbortedError(`Proxy response (${statusCode}) !== 200 when HTTP Tunneling`)) } if (opts.protocol !== 'https:') { callback(null, socket) @@ -87887,9 +88352,20 @@ function isCacheFeatureAvailable() { return false; } exports.isCacheFeatureAvailable = isCacheFeatureAvailable; -function getVersionFromFileContent(content, distributionName) { +function getVersionFromFileContent(content, distributionName, versionFile) { var _a, _b, _c, _d, _e; - const javaVersionRegExp = /(?(?<=(^|\s|-))(\d+\S*))(\s|$)/; + let javaVersionRegExp; + function getFileName(versionFile) { + return path_1.default.basename(versionFile); + } + const versionFileName = getFileName(versionFile); + if (versionFileName == '.tool-versions') { + javaVersionRegExp = + /^(java\s+)(?:\S*-)?v?(?(\d+)(\.\d+)?(\.\d+)?(\+\d+)?(-ea(\.\d+)?)?)$/m; + } + else { + javaVersionRegExp = /(?(?<=(^|\s|-))(\d+\S*))(\s|$)/; + } const fileContent = ((_b = (_a = content.match(javaVersionRegExp)) === null || _a === void 0 ? void 0 : _a.groups) === null || _b === void 0 ? void 0 : _b.version) ? (_d = (_c = content.match(javaVersionRegExp)) === null || _c === void 0 ? void 0 : _c.groups) === null || _d === void 0 ? void 0 : _d.version : ''; diff --git a/dist/setup/index.js b/dist/setup/index.js index 916f488bb..13023489c 100644 --- a/dist/setup/index.js +++ b/dist/setup/index.js @@ -319,7 +319,8 @@ function createHttpClient() { return new http_client_1.HttpClient('actions/cache', [bearerCredentialHandler], getRequestOptions()); } function getCacheVersion(paths, compressionMethod, enableCrossOsArchive = false) { - const components = paths; + // don't pass changes upstream + const components = paths.slice(); // Add compression method to cache version to restore // compressed cache as per compression method if (compressionMethod) { @@ -608,26 +609,21 @@ function resolvePaths(patterns) { implicitDescendants: false }); try { - for (var _e = true, _f = __asyncValues(globber.globGenerator()), _g; _g = yield _f.next(), _a = _g.done, !_a;) { + for (var _e = true, _f = __asyncValues(globber.globGenerator()), _g; _g = yield _f.next(), _a = _g.done, !_a; _e = true) { _c = _g.value; _e = false; - try { - const file = _c; - const relativeFile = path - .relative(workspace, file) - .replace(new RegExp(`\\${path.sep}`, 'g'), '/'); - core.debug(`Matched: ${relativeFile}`); - // Paths are made relative so the tar entries are all relative to the root of the workspace. - if (relativeFile === '') { - // path.relative returns empty string if workspace and file are equal - paths.push('.'); - } - else { - paths.push(`${relativeFile}`); - } + const file = _c; + const relativeFile = path + .relative(workspace, file) + .replace(new RegExp(`\\${path.sep}`, 'g'), '/'); + core.debug(`Matched: ${relativeFile}`); + // Paths are made relative so the tar entries are all relative to the root of the workspace. + if (relativeFile === '') { + // path.relative returns empty string if workspace and file are equal + paths.push('.'); } - finally { - _e = true; + else { + paths.push(`${relativeFile}`); } } } @@ -711,7 +707,10 @@ function assertDefined(name, value) { exports.assertDefined = assertDefined; function isGhes() { const ghUrl = new URL(process.env['GITHUB_SERVER_URL'] || 'https://github.com'); - return ghUrl.hostname.toUpperCase() !== 'GITHUB.COM'; + const hostname = ghUrl.hostname.trimEnd().toUpperCase(); + const isGitHubHost = hostname === 'GITHUB.COM'; + const isGheHost = hostname.endsWith('.GHE.COM') || hostname.endsWith('.GHE.LOCALHOST'); + return !isGitHubHost && !isGheHost; } exports.isGhes = isGhes; //# sourceMappingURL=cacheUtils.js.map @@ -729,7 +728,7 @@ var CacheFilename; (function (CacheFilename) { CacheFilename["Gzip"] = "cache.tgz"; CacheFilename["Zstd"] = "cache.tzst"; -})(CacheFilename = exports.CacheFilename || (exports.CacheFilename = {})); +})(CacheFilename || (exports.CacheFilename = CacheFilename = {})); var CompressionMethod; (function (CompressionMethod) { CompressionMethod["Gzip"] = "gzip"; @@ -737,12 +736,12 @@ var CompressionMethod; // This enum is for earlier version of zstd that does not have --long support CompressionMethod["ZstdWithoutLong"] = "zstd-without-long"; CompressionMethod["Zstd"] = "zstd"; -})(CompressionMethod = exports.CompressionMethod || (exports.CompressionMethod = {})); +})(CompressionMethod || (exports.CompressionMethod = CompressionMethod = {})); var ArchiveToolType; (function (ArchiveToolType) { ArchiveToolType["GNU"] = "gnu"; ArchiveToolType["BSD"] = "bsd"; -})(ArchiveToolType = exports.ArchiveToolType || (exports.ArchiveToolType = {})); +})(ArchiveToolType || (exports.ArchiveToolType = ArchiveToolType = {})); // The default number of retry attempts. exports.DefaultRetryAttempts = 2; // The default delay in milliseconds between retry attempts. @@ -8551,7 +8550,7 @@ class HttpClient { if (this._keepAlive && useProxy) { agent = this._proxyAgent; } - if (this._keepAlive && !useProxy) { + if (!useProxy) { agent = this._agent; } // if agent is already assigned use that agent. @@ -8583,16 +8582,12 @@ class HttpClient { agent = tunnelAgent(agentOptions); this._proxyAgent = agent; } - // if reusing agent across request and tunneling agent isn't assigned create a new agent - if (this._keepAlive && !agent) { + // if tunneling agent isn't assigned create a new agent + if (!agent) { const options = { keepAlive: this._keepAlive, maxSockets }; agent = usingSsl ? new https.Agent(options) : new http.Agent(options); this._agent = agent; } - // if not using private agent and tunnel agent isn't setup then use global agent - if (!agent) { - agent = usingSsl ? https.globalAgent : http.globalAgent; - } if (usingSsl && this._ignoreSslError) { // we don't want to set NODE_TLS_REJECT_UNAUTHORIZED=0 since that will affect request for entire process // http.RequestOptions doesn't expose a way to modify RequestOptions.agent.options @@ -82582,35 +82577,43 @@ const coerce = (version, options) => { let match = null if (!options.rtl) { - match = version.match(re[t.COERCE]) + match = version.match(options.includePrerelease ? re[t.COERCEFULL] : re[t.COERCE]) } else { // Find the right-most coercible string that does not share // a terminus with a more left-ward coercible string. // Eg, '1.2.3.4' wants to coerce '2.3.4', not '3.4' or '4' + // With includePrerelease option set, '1.2.3.4-rc' wants to coerce '2.3.4-rc', not '2.3.4' // // Walk through the string checking with a /g regexp // Manually set the index so as to pick up overlapping matches. // Stop when we get a match that ends at the string end, since no // coercible string can be more right-ward without the same terminus. + const coerceRtlRegex = options.includePrerelease ? re[t.COERCERTLFULL] : re[t.COERCERTL] let next - while ((next = re[t.COERCERTL].exec(version)) && + while ((next = coerceRtlRegex.exec(version)) && (!match || match.index + match[0].length !== version.length) ) { if (!match || next.index + next[0].length !== match.index + match[0].length) { match = next } - re[t.COERCERTL].lastIndex = next.index + next[1].length + next[2].length + coerceRtlRegex.lastIndex = next.index + next[1].length + next[2].length } // leave it in a clean state - re[t.COERCERTL].lastIndex = -1 + coerceRtlRegex.lastIndex = -1 } if (match === null) { return null } - return parse(`${match[2]}.${match[3] || '0'}.${match[4] || '0'}`, options) + const major = match[2] + const minor = match[3] || '0' + const patch = match[4] || '0' + const prerelease = options.includePrerelease && match[5] ? `-${match[5]}` : '' + const build = options.includePrerelease && match[6] ? `+${match[6]}` : '' + + return parse(`${major}.${minor}.${patch}${prerelease}${build}`, options) } module.exports = coerce @@ -83302,12 +83305,17 @@ createToken('XRANGELOOSE', `^${src[t.GTLT]}\\s*${src[t.XRANGEPLAINLOOSE]}$`) // Coercion. // Extract anything that could conceivably be a part of a valid semver -createToken('COERCE', `${'(^|[^\\d])' + +createToken('COERCEPLAIN', `${'(^|[^\\d])' + '(\\d{1,'}${MAX_SAFE_COMPONENT_LENGTH}})` + `(?:\\.(\\d{1,${MAX_SAFE_COMPONENT_LENGTH}}))?` + - `(?:\\.(\\d{1,${MAX_SAFE_COMPONENT_LENGTH}}))?` + + `(?:\\.(\\d{1,${MAX_SAFE_COMPONENT_LENGTH}}))?`) +createToken('COERCE', `${src[t.COERCEPLAIN]}(?:$|[^\\d])`) +createToken('COERCEFULL', src[t.COERCEPLAIN] + + `(?:${src[t.PRERELEASE]})?` + + `(?:${src[t.BUILD]})?` + `(?:$|[^\\d])`) createToken('COERCERTL', src[t.COERCE], true) +createToken('COERCERTLFULL', src[t.COERCEFULL], true) // Tilde ranges. // Meaning is "reasonably at or greater than" @@ -85478,6 +85486,7 @@ const MockAgent = __nccwpck_require__(66771) const MockPool = __nccwpck_require__(26193) const mockErrors = __nccwpck_require__(50888) const ProxyAgent = __nccwpck_require__(97858) +const RetryHandler = __nccwpck_require__(82286) const { getGlobalDispatcher, setGlobalDispatcher } = __nccwpck_require__(21892) const DecoratorHandler = __nccwpck_require__(46930) const RedirectHandler = __nccwpck_require__(72860) @@ -85499,6 +85508,7 @@ module.exports.Pool = Pool module.exports.BalancedPool = BalancedPool module.exports.Agent = Agent module.exports.ProxyAgent = ProxyAgent +module.exports.RetryHandler = RetryHandler module.exports.DecoratorHandler = DecoratorHandler module.exports.RedirectHandler = RedirectHandler @@ -86399,6 +86409,7 @@ function request (opts, callback) { } module.exports = request +module.exports.RequestHandler = RequestHandler /***/ }), @@ -86781,6 +86792,8 @@ const kBody = Symbol('kBody') const kAbort = Symbol('abort') const kContentType = Symbol('kContentType') +const noop = () => {} + module.exports = class BodyReadable extends Readable { constructor ({ resume, @@ -86914,37 +86927,50 @@ module.exports = class BodyReadable extends Readable { return this[kBody] } - async dump (opts) { + dump (opts) { let limit = opts && Number.isFinite(opts.limit) ? opts.limit : 262144 const signal = opts && opts.signal - const abortFn = () => { - this.destroy() - } - let signalListenerCleanup + if (signal) { - if (typeof signal !== 'object' || !('aborted' in signal)) { - throw new InvalidArgumentError('signal must be an AbortSignal') - } - util.throwIfAborted(signal) - signalListenerCleanup = util.addAbortListener(signal, abortFn) - } - try { - for await (const chunk of this) { - util.throwIfAborted(signal) - limit -= Buffer.byteLength(chunk) - if (limit < 0) { - return + try { + if (typeof signal !== 'object' || !('aborted' in signal)) { + throw new InvalidArgumentError('signal must be an AbortSignal') } - } - } catch { - util.throwIfAborted(signal) - } finally { - if (typeof signalListenerCleanup === 'function') { - signalListenerCleanup() - } else if (signalListenerCleanup) { - signalListenerCleanup[Symbol.dispose]() + util.throwIfAborted(signal) + } catch (err) { + return Promise.reject(err) } } + + if (this.closed) { + return Promise.resolve(null) + } + + return new Promise((resolve, reject) => { + const signalListenerCleanup = signal + ? util.addAbortListener(signal, () => { + this.destroy() + }) + : noop + + this + .on('close', function () { + signalListenerCleanup() + if (signal && signal.aborted) { + reject(signal.reason || Object.assign(new Error('The operation was aborted'), { name: 'AbortError' })) + } else { + resolve(null) + } + }) + .on('error', noop) + .on('data', function (chunk) { + limit -= chunk.length + if (limit <= 0) { + this.destroy() + } + }) + .resume() + }) } } @@ -88324,13 +88350,13 @@ module.exports = { /***/ }), /***/ 29174: -/***/ ((module) => { +/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { "use strict"; module.exports = { - kConstruct: Symbol('constructable') + kConstruct: (__nccwpck_require__(72785).kConstruct) } @@ -89316,11 +89342,9 @@ class Parser { socket[kReset] = true } - let pause - try { - pause = request.onHeaders(statusCode, headers, this.resume, statusText) === false - } catch (err) { - util.destroy(socket, err) + const pause = request.onHeaders(statusCode, headers, this.resume, statusText) === false + + if (request.aborted) { return -1 } @@ -89367,13 +89391,8 @@ class Parser { this.bytesRead += buf.length - try { - if (request.onData(buf) === false) { - return constants.ERROR.PAUSED - } - } catch (err) { - util.destroy(socket, err) - return -1 + if (request.onData(buf) === false) { + return constants.ERROR.PAUSED } } @@ -89414,11 +89433,7 @@ class Parser { return -1 } - try { - request.onComplete(headers) - } catch (err) { - errorRequest(client, request, err) - } + request.onComplete(headers) client[kQueue][client[kRunningIdx]++] = null @@ -89582,7 +89597,7 @@ async function connect (client) { const idx = hostname.indexOf(']') assert(idx !== -1) - const ip = hostname.substr(1, idx - 1) + const ip = hostname.substring(1, idx) assert(net.isIP(ip)) hostname = ip @@ -90081,6 +90096,7 @@ function writeH2 (client, session, request) { return false } + /** @type {import('node:http2').ClientHttp2Stream} */ let stream const h2State = client[kHTTP2SessionState] @@ -90176,14 +90192,10 @@ function writeH2 (client, session, request) { const shouldEndStream = method === 'GET' || method === 'HEAD' if (expectContinue) { headers[HTTP2_HEADER_EXPECT] = '100-continue' - /** - * @type {import('node:http2').ClientHttp2Stream} - */ stream = session.request(headers, { endStream: shouldEndStream, signal }) stream.once('continue', writeBodyH2) } else { - /** @type {import('node:http2').ClientHttp2Stream} */ stream = session.request(headers, { endStream: shouldEndStream, signal @@ -90195,7 +90207,9 @@ function writeH2 (client, session, request) { ++h2State.openStreams stream.once('response', headers => { - if (request.onHeaders(Number(headers[HTTP2_HEADER_STATUS]), headers, stream.resume.bind(stream), '') === false) { + const { [HTTP2_HEADER_STATUS]: statusCode, ...realHeaders } = headers + + if (request.onHeaders(Number(statusCode), realHeaders, stream.resume.bind(stream), '') === false) { stream.pause() } }) @@ -90205,13 +90219,17 @@ function writeH2 (client, session, request) { }) stream.on('data', (chunk) => { - if (request.onData(chunk) === false) stream.pause() + if (request.onData(chunk) === false) { + stream.pause() + } }) stream.once('close', () => { h2State.openStreams -= 1 // TODO(HTTP/2): unref only if current streams count is 0 - if (h2State.openStreams === 0) session.unref() + if (h2State.openStreams === 0) { + session.unref() + } }) stream.once('error', function (err) { @@ -90371,7 +90389,11 @@ function writeStream ({ h2stream, body, client, request, socket, contentLength, } } const onAbort = function () { - onFinished(new RequestAbortedError()) + if (finished) { + return + } + const err = new RequestAbortedError() + queueMicrotask(() => onFinished(err)) } const onFinished = function (err) { if (finished) { @@ -91976,6 +91998,19 @@ class ResponseExceededMaxSizeError extends UndiciError { } } +class RequestRetryError extends UndiciError { + constructor (message, code, { headers, data }) { + super(message) + Error.captureStackTrace(this, RequestRetryError) + this.name = 'RequestRetryError' + this.message = message || 'Request retry error' + this.code = 'UND_ERR_REQ_RETRY' + this.statusCode = code + this.data = data + this.headers = headers + } +} + module.exports = { HTTPParserError, UndiciError, @@ -91995,7 +92030,8 @@ module.exports = { NotSupportedError, ResponseContentLengthMismatchError, BalancedPoolMissingUpstreamError, - ResponseExceededMaxSizeError + ResponseExceededMaxSizeError, + RequestRetryError } @@ -92237,9 +92273,9 @@ class Request { onBodySent (chunk) { if (this[kHandler].onBodySent) { try { - this[kHandler].onBodySent(chunk) + return this[kHandler].onBodySent(chunk) } catch (err) { - this.onError(err) + this.abort(err) } } } @@ -92251,9 +92287,9 @@ class Request { if (this[kHandler].onRequestSent) { try { - this[kHandler].onRequestSent() + return this[kHandler].onRequestSent() } catch (err) { - this.onError(err) + this.abort(err) } } } @@ -92278,14 +92314,23 @@ class Request { channels.headers.publish({ request: this, response: { statusCode, headers, statusText } }) } - return this[kHandler].onHeaders(statusCode, headers, resume, statusText) + try { + return this[kHandler].onHeaders(statusCode, headers, resume, statusText) + } catch (err) { + this.abort(err) + } } onData (chunk) { assert(!this.aborted) assert(!this.completed) - return this[kHandler].onData(chunk) + try { + return this[kHandler].onData(chunk) + } catch (err) { + this.abort(err) + return false + } } onUpgrade (statusCode, headers, socket) { @@ -92304,7 +92349,13 @@ class Request { if (channels.trailers.hasSubscribers) { channels.trailers.publish({ request: this, trailers }) } - return this[kHandler].onComplete(trailers) + + try { + return this[kHandler].onComplete(trailers) + } catch (err) { + // TODO (fix): This might be a bad idea? + this.onError(err) + } } onError (error) { @@ -92318,6 +92369,7 @@ class Request { return } this.aborted = true + return this[kHandler].onError(error) } @@ -92554,7 +92606,9 @@ module.exports = { kHTTP2BuildRequest: Symbol('http2 build request'), kHTTP1BuildRequest: Symbol('http1 build request'), kHTTP2CopyHeaders: Symbol('http2 copy headers'), - kHTTPConnVersion: Symbol('http connection version') + kHTTPConnVersion: Symbol('http connection version'), + kRetryHandlerDefaultRetry: Symbol('retry agent default retry'), + kConstruct: Symbol('constructable') } @@ -92691,13 +92745,13 @@ function getHostname (host) { const idx = host.indexOf(']') assert(idx !== -1) - return host.substr(1, idx - 1) + return host.substring(1, idx) } const idx = host.indexOf(':') if (idx === -1) return host - return host.substr(0, idx) + return host.substring(0, idx) } // IP addresses are not valid server names per RFC6066 @@ -92794,7 +92848,7 @@ function parseHeaders (headers, obj = {}) { if (!val) { if (Array.isArray(headers[i + 1])) { - obj[key] = headers[i + 1] + obj[key] = headers[i + 1].map(x => x.toString('utf8')) } else { obj[key] = headers[i + 1].toString('utf8') } @@ -92997,16 +93051,7 @@ function throwIfAborted (signal) { } } -let events function addAbortListener (signal, listener) { - if (typeof Symbol.dispose === 'symbol') { - if (!events) { - events = __nccwpck_require__(82361) - } - if (typeof events.addAbortListener === 'function' && 'aborted' in signal) { - return events.addAbortListener(signal, listener) - } - } if ('addEventListener' in signal) { signal.addEventListener('abort', listener, { once: true }) return () => signal.removeEventListener('abort', listener) @@ -93030,6 +93075,21 @@ function toUSVString (val) { return `${val}` } +// Parsed accordingly to RFC 9110 +// https://www.rfc-editor.org/rfc/rfc9110#field.content-range +function parseRangeHeader (range) { + if (range == null || range === '') return { start: 0, end: null, size: null } + + const m = range ? range.match(/^bytes (\d+)-(\d+)\/(\d+)?$/) : null + return m + ? { + start: parseInt(m[1]), + end: m[2] ? parseInt(m[2]) : null, + size: m[3] ? parseInt(m[3]) : null + } + : null +} + const kEnumerableProperty = Object.create(null) kEnumerableProperty.enumerable = true @@ -93063,9 +93123,11 @@ module.exports = { buildURL, throwIfAborted, addAbortListener, + parseRangeHeader, nodeMajor, nodeMinor, - nodeHasAutoSelectFamily: nodeMajor > 18 || (nodeMajor === 18 && nodeMinor >= 13) + nodeHasAutoSelectFamily: nodeMajor > 18 || (nodeMajor === 18 && nodeMinor >= 13), + safeHTTPMethods: ['GET', 'HEAD', 'OPTIONS', 'TRACE'] } @@ -94194,17 +94256,14 @@ function dataURLProcessor (dataURL) { * @param {boolean} excludeFragment */ function URLSerializer (url, excludeFragment = false) { - const href = url.href - if (!excludeFragment) { - return href + return url.href } - const hash = href.lastIndexOf('#') - if (hash === -1) { - return href - } - return href.slice(0, hash) + const href = url.href + const hashLength = url.hash.length + + return hashLength === 0 ? href : href.substring(0, href.length - hashLength) } // https://infra.spec.whatwg.org/#collect-a-sequence-of-code-points @@ -95388,7 +95447,7 @@ module.exports = { -const { kHeadersList } = __nccwpck_require__(72785) +const { kHeadersList, kConstruct } = __nccwpck_require__(72785) const { kGuard } = __nccwpck_require__(15861) const { kEnumerableProperty } = __nccwpck_require__(83983) const { @@ -95402,6 +95461,13 @@ const assert = __nccwpck_require__(39491) const kHeadersMap = Symbol('headers map') const kHeadersSortedMap = Symbol('headers map sorted') +/** + * @param {number} code + */ +function isHTTPWhiteSpaceCharCode (code) { + return code === 0x00a || code === 0x00d || code === 0x009 || code === 0x020 +} + /** * @see https://fetch.spec.whatwg.org/#concept-header-value-normalize * @param {string} potentialValue @@ -95410,12 +95476,12 @@ function headerValueNormalize (potentialValue) { // To normalize a byte sequence potentialValue, remove // any leading and trailing HTTP whitespace bytes from // potentialValue. + let i = 0; let j = potentialValue.length + + while (j > i && isHTTPWhiteSpaceCharCode(potentialValue.charCodeAt(j - 1))) --j + while (j > i && isHTTPWhiteSpaceCharCode(potentialValue.charCodeAt(i))) ++i - // Trimming the end with `.replace()` and a RegExp is typically subject to - // ReDoS. This is safer and faster. - let i = potentialValue.length - while (/[\r\n\t ]/.test(potentialValue.charAt(--i))); - return potentialValue.slice(0, i + 1).replace(/^[\r\n\t ]+/, '') + return i === 0 && j === potentialValue.length ? potentialValue : potentialValue.substring(i, j) } function fill (headers, object) { @@ -95424,7 +95490,8 @@ function fill (headers, object) { // 1. If object is a sequence, then for each header in object: // Note: webidl conversion to array has already been done. if (Array.isArray(object)) { - for (const header of object) { + for (let i = 0; i < object.length; ++i) { + const header = object[i] // 1. If header does not contain exactly two items, then throw a TypeError. if (header.length !== 2) { throw webidl.errors.exception({ @@ -95434,15 +95501,16 @@ function fill (headers, object) { } // 2. Append (header’s first item, header’s second item) to headers. - headers.append(header[0], header[1]) + appendHeader(headers, header[0], header[1]) } } else if (typeof object === 'object' && object !== null) { // Note: null should throw // 2. Otherwise, object is a record, then for each key → value in object, // append (key, value) to headers - for (const [key, value] of Object.entries(object)) { - headers.append(key, value) + const keys = Object.keys(object) + for (let i = 0; i < keys.length; ++i) { + appendHeader(headers, keys[i], object[keys[i]]) } } else { throw webidl.errors.conversionFailed({ @@ -95453,6 +95521,50 @@ function fill (headers, object) { } } +/** + * @see https://fetch.spec.whatwg.org/#concept-headers-append + */ +function appendHeader (headers, name, value) { + // 1. Normalize value. + value = headerValueNormalize(value) + + // 2. If name is not a header name or value is not a + // header value, then throw a TypeError. + if (!isValidHeaderName(name)) { + throw webidl.errors.invalidArgument({ + prefix: 'Headers.append', + value: name, + type: 'header name' + }) + } else if (!isValidHeaderValue(value)) { + throw webidl.errors.invalidArgument({ + prefix: 'Headers.append', + value, + type: 'header value' + }) + } + + // 3. If headers’s guard is "immutable", then throw a TypeError. + // 4. Otherwise, if headers’s guard is "request" and name is a + // forbidden header name, return. + // Note: undici does not implement forbidden header names + if (headers[kGuard] === 'immutable') { + throw new TypeError('immutable') + } else if (headers[kGuard] === 'request-no-cors') { + // 5. Otherwise, if headers’s guard is "request-no-cors": + // TODO + } + + // 6. Otherwise, if headers’s guard is "response" and name is a + // forbidden response-header name, return. + + // 7. Append (name, value) to headers’s header list. + return headers[kHeadersList].append(name, value) + + // 8. If headers’s guard is "request-no-cors", then remove + // privileged no-CORS request headers from headers +} + class HeadersList { /** @type {[string, string][]|null} */ cookies = null @@ -95461,7 +95573,7 @@ class HeadersList { if (init instanceof HeadersList) { this[kHeadersMap] = new Map(init[kHeadersMap]) this[kHeadersSortedMap] = init[kHeadersSortedMap] - this.cookies = init.cookies + this.cookies = init.cookies === null ? null : [...init.cookies] } else { this[kHeadersMap] = new Map(init) this[kHeadersSortedMap] = null @@ -95523,7 +95635,7 @@ class HeadersList { // the first such header to value and remove the // others. // 2. Otherwise, append header (name, value) to list. - return this[kHeadersMap].set(lowercaseName, { name, value }) + this[kHeadersMap].set(lowercaseName, { name, value }) } // https://fetch.spec.whatwg.org/#concept-header-list-delete @@ -95536,20 +95648,18 @@ class HeadersList { this.cookies = null } - return this[kHeadersMap].delete(name) + this[kHeadersMap].delete(name) } // https://fetch.spec.whatwg.org/#concept-header-list-get get (name) { - // 1. If list does not contain name, then return null. - if (!this.contains(name)) { - return null - } + const value = this[kHeadersMap].get(name.toLowerCase()) + // 1. If list does not contain name, then return null. // 2. Return the values of all headers in list whose name // is a byte-case-insensitive match for name, // separated from each other by 0x2C 0x20, in order. - return this[kHeadersMap].get(name.toLowerCase())?.value ?? null + return value === undefined ? null : value.value } * [Symbol.iterator] () { @@ -95575,6 +95685,9 @@ class HeadersList { // https://fetch.spec.whatwg.org/#headers-class class Headers { constructor (init = undefined) { + if (init === kConstruct) { + return + } this[kHeadersList] = new HeadersList() // The new Headers(init) constructor steps are: @@ -95598,43 +95711,7 @@ class Headers { name = webidl.converters.ByteString(name) value = webidl.converters.ByteString(value) - // 1. Normalize value. - value = headerValueNormalize(value) - - // 2. If name is not a header name or value is not a - // header value, then throw a TypeError. - if (!isValidHeaderName(name)) { - throw webidl.errors.invalidArgument({ - prefix: 'Headers.append', - value: name, - type: 'header name' - }) - } else if (!isValidHeaderValue(value)) { - throw webidl.errors.invalidArgument({ - prefix: 'Headers.append', - value, - type: 'header value' - }) - } - - // 3. If headers’s guard is "immutable", then throw a TypeError. - // 4. Otherwise, if headers’s guard is "request" and name is a - // forbidden header name, return. - // Note: undici does not implement forbidden header names - if (this[kGuard] === 'immutable') { - throw new TypeError('immutable') - } else if (this[kGuard] === 'request-no-cors') { - // 5. Otherwise, if headers’s guard is "request-no-cors": - // TODO - } - - // 6. Otherwise, if headers’s guard is "response" and name is a - // forbidden response-header name, return. - - // 7. Append (name, value) to headers’s header list. - // 8. If headers’s guard is "request-no-cors", then remove - // privileged no-CORS request headers from headers - return this[kHeadersList].append(name, value) + return appendHeader(this, name, value) } // https://fetch.spec.whatwg.org/#dom-headers-delete @@ -95679,7 +95756,7 @@ class Headers { // 7. Delete name from this’s header list. // 8. If this’s guard is "request-no-cors", then remove // privileged no-CORS request headers from this. - return this[kHeadersList].delete(name) + this[kHeadersList].delete(name) } // https://fetch.spec.whatwg.org/#dom-headers-get @@ -95772,7 +95849,7 @@ class Headers { // 7. Set (name, value) in this’s header list. // 8. If this’s guard is "request-no-cors", then remove // privileged no-CORS request headers from this - return this[kHeadersList].set(name, value) + this[kHeadersList].set(name, value) } // https://fetch.spec.whatwg.org/#dom-headers-getsetcookie @@ -95808,7 +95885,8 @@ class Headers { const cookies = this[kHeadersList].cookies // 3. For each name of names: - for (const [name, value] of names) { + for (let i = 0; i < names.length; ++i) { + const [name, value] = names[i] // 1. If name is `set-cookie`, then: if (name === 'set-cookie') { // 1. Let values be a list of all values of headers in list whose name @@ -95816,8 +95894,8 @@ class Headers { // 2. For each value of values: // 1. Append (name, value) to headers. - for (const value of cookies) { - headers.push([name, value]) + for (let j = 0; j < cookies.length; ++j) { + headers.push([name, cookies[j]]) } } else { // 2. Otherwise: @@ -95841,6 +95919,12 @@ class Headers { keys () { webidl.brandCheck(this, Headers) + if (this[kGuard] === 'immutable') { + const value = this[kHeadersSortedMap] + return makeIterator(() => value, 'Headers', + 'key') + } + return makeIterator( () => [...this[kHeadersSortedMap].values()], 'Headers', @@ -95851,6 +95935,12 @@ class Headers { values () { webidl.brandCheck(this, Headers) + if (this[kGuard] === 'immutable') { + const value = this[kHeadersSortedMap] + return makeIterator(() => value, 'Headers', + 'value') + } + return makeIterator( () => [...this[kHeadersSortedMap].values()], 'Headers', @@ -95861,6 +95951,12 @@ class Headers { entries () { webidl.brandCheck(this, Headers) + if (this[kGuard] === 'immutable') { + const value = this[kHeadersSortedMap] + return makeIterator(() => value, 'Headers', + 'key+value') + } + return makeIterator( () => [...this[kHeadersSortedMap].values()], 'Headers', @@ -96232,7 +96328,7 @@ function finalizeAndReportTiming (response, initiatorType = 'other') { } // 8. If response’s timing allow passed flag is not set, then: - if (!timingInfo.timingAllowPassed) { + if (!response.timingAllowPassed) { // 1. Set timingInfo to a the result of creating an opaque timing info for timingInfo. timingInfo = createOpaqueTimingInfo({ startTime: timingInfo.startTime @@ -97149,6 +97245,9 @@ function httpRedirectFetch (fetchParams, response) { // https://fetch.spec.whatwg.org/#cors-non-wildcard-request-header-name request.headersList.delete('authorization') + // https://fetch.spec.whatwg.org/#authentication-entries + request.headersList.delete('proxy-authorization', true) + // "Cookie" and "Host" are forbidden request-headers, which undici doesn't implement. request.headersList.delete('cookie') request.headersList.delete('host') @@ -97903,7 +98002,7 @@ async function httpNetworkFetch ( path: url.pathname + url.search, origin: url.origin, method: request.method, - body: fetchParams.controller.dispatcher.isMockActive ? request.body && request.body.source : body, + body: fetchParams.controller.dispatcher.isMockActive ? request.body && (request.body.source || request.body.stream) : body, headers: request.headersList.entries, maxRedirections: 0, upgrade: request.mode === 'websocket' ? 'websocket' : undefined @@ -97948,7 +98047,7 @@ async function httpNetworkFetch ( location = val } - headers.append(key, val) + headers[kHeadersList].append(key, val) } } else { const keys = Object.keys(headersList) @@ -97962,7 +98061,7 @@ async function httpNetworkFetch ( location = val } - headers.append(key, val) + headers[kHeadersList].append(key, val) } } @@ -98066,7 +98165,7 @@ async function httpNetworkFetch ( const key = headersList[n + 0].toString('latin1') const val = headersList[n + 1].toString('latin1') - headers.append(key, val) + headers[kHeadersList].append(key, val) } resolve({ @@ -98109,7 +98208,8 @@ const { isValidHTTPToken, sameOrigin, normalizeMethod, - makePolicyContainer + makePolicyContainer, + normalizeMethodRecord } = __nccwpck_require__(52538) const { forbiddenMethodsSet, @@ -98126,13 +98226,12 @@ const { kHeaders, kSignal, kState, kGuard, kRealm } = __nccwpck_require__(15861) const { webidl } = __nccwpck_require__(21744) const { getGlobalOrigin } = __nccwpck_require__(71246) const { URLSerializer } = __nccwpck_require__(685) -const { kHeadersList } = __nccwpck_require__(72785) +const { kHeadersList, kConstruct } = __nccwpck_require__(72785) const assert = __nccwpck_require__(39491) const { getMaxListeners, setMaxListeners, getEventListeners, defaultMaxListeners } = __nccwpck_require__(82361) let TransformStream = globalThis.TransformStream -const kInit = Symbol('init') const kAbortController = Symbol('abortController') const requestFinalizer = new FinalizationRegistry(({ signal, abort }) => { @@ -98143,7 +98242,7 @@ const requestFinalizer = new FinalizationRegistry(({ signal, abort }) => { class Request { // https://fetch.spec.whatwg.org/#dom-request constructor (input, init = {}) { - if (input === kInit) { + if (input === kConstruct) { return } @@ -98282,8 +98381,10 @@ class Request { urlList: [...request.urlList] }) + const initHasKey = Object.keys(init).length !== 0 + // 13. If init is not empty, then: - if (Object.keys(init).length > 0) { + if (initHasKey) { // 1. If request’s mode is "navigate", then set it to "same-origin". if (request.mode === 'navigate') { request.mode = 'same-origin' @@ -98398,7 +98499,7 @@ class Request { } // 23. If init["integrity"] exists, then set request’s integrity metadata to it. - if (init.integrity !== undefined && init.integrity != null) { + if (init.integrity != null) { request.integrity = String(init.integrity) } @@ -98414,16 +98515,16 @@ class Request { // 2. If method is not a method or method is a forbidden method, then // throw a TypeError. - if (!isValidHTTPToken(init.method)) { - throw TypeError(`'${init.method}' is not a valid HTTP method.`) + if (!isValidHTTPToken(method)) { + throw new TypeError(`'${method}' is not a valid HTTP method.`) } if (forbiddenMethodsSet.has(method.toUpperCase())) { - throw TypeError(`'${init.method}' HTTP method is unsupported.`) + throw new TypeError(`'${method}' HTTP method is unsupported.`) } // 3. Normalize method. - method = normalizeMethod(init.method) + method = normalizeMethodRecord[method] ?? normalizeMethod(method) // 4. Set request’s method to method. request.method = method @@ -98494,7 +98595,7 @@ class Request { // 30. Set this’s headers to a new Headers object with this’s relevant // Realm, whose header list is request’s header list and guard is // "request". - this[kHeaders] = new Headers() + this[kHeaders] = new Headers(kConstruct) this[kHeaders][kHeadersList] = request.headersList this[kHeaders][kGuard] = 'request' this[kHeaders][kRealm] = this[kRealm] @@ -98514,25 +98615,25 @@ class Request { } // 32. If init is not empty, then: - if (Object.keys(init).length !== 0) { + if (initHasKey) { + /** @type {HeadersList} */ + const headersList = this[kHeaders][kHeadersList] // 1. Let headers be a copy of this’s headers and its associated header // list. - let headers = new Headers(this[kHeaders]) - // 2. If init["headers"] exists, then set headers to init["headers"]. - if (init.headers !== undefined) { - headers = init.headers - } + const headers = init.headers !== undefined ? init.headers : new HeadersList(headersList) // 3. Empty this’s headers’s header list. - this[kHeaders][kHeadersList].clear() + headersList.clear() // 4. If headers is a Headers object, then for each header in its header // list, append header’s name/header’s value to this’s headers. - if (headers.constructor.name === 'Headers') { + if (headers instanceof HeadersList) { for (const [key, val] of headers) { - this[kHeaders].append(key, val) + headersList.append(key, val) } + // Note: Copy the `set-cookie` meta-data. + headersList.cookies = headers.cookies } else { // 5. Otherwise, fill this’s headers with headers. fillHeaders(this[kHeaders], headers) @@ -98821,10 +98922,10 @@ class Request { // 3. Let clonedRequestObject be the result of creating a Request object, // given clonedRequest, this’s headers’s guard, and this’s relevant Realm. - const clonedRequestObject = new Request(kInit) + const clonedRequestObject = new Request(kConstruct) clonedRequestObject[kState] = clonedRequest clonedRequestObject[kRealm] = this[kRealm] - clonedRequestObject[kHeaders] = new Headers() + clonedRequestObject[kHeaders] = new Headers(kConstruct) clonedRequestObject[kHeaders][kHeadersList] = clonedRequest.headersList clonedRequestObject[kHeaders][kGuard] = this[kHeaders][kGuard] clonedRequestObject[kHeaders][kRealm] = this[kHeaders][kRealm] @@ -99074,7 +99175,7 @@ const { webidl } = __nccwpck_require__(21744) const { FormData } = __nccwpck_require__(72015) const { getGlobalOrigin } = __nccwpck_require__(71246) const { URLSerializer } = __nccwpck_require__(685) -const { kHeadersList } = __nccwpck_require__(72785) +const { kHeadersList, kConstruct } = __nccwpck_require__(72785) const assert = __nccwpck_require__(39491) const { types } = __nccwpck_require__(73837) @@ -99195,7 +99296,7 @@ class Response { // 2. Set this’s headers to a new Headers object with this’s relevant // Realm, whose header list is this’s response’s header list and guard // is "response". - this[kHeaders] = new Headers() + this[kHeaders] = new Headers(kConstruct) this[kHeaders][kGuard] = 'response' this[kHeaders][kHeadersList] = this[kState].headersList this[kHeaders][kRealm] = this[kRealm] @@ -99565,11 +99666,7 @@ webidl.converters.XMLHttpRequestBodyInit = function (V) { return webidl.converters.Blob(V, { strict: false }) } - if ( - types.isAnyArrayBuffer(V) || - types.isTypedArray(V) || - types.isDataView(V) - ) { + if (types.isArrayBuffer(V) || types.isTypedArray(V) || types.isDataView(V)) { return webidl.converters.BufferSource(V) } @@ -99755,52 +99852,57 @@ function isValidReasonPhrase (statusText) { return true } -function isTokenChar (c) { - return !( - c >= 0x7f || - c <= 0x20 || - c === '(' || - c === ')' || - c === '<' || - c === '>' || - c === '@' || - c === ',' || - c === ';' || - c === ':' || - c === '\\' || - c === '"' || - c === '/' || - c === '[' || - c === ']' || - c === '?' || - c === '=' || - c === '{' || - c === '}' - ) +/** + * @see https://tools.ietf.org/html/rfc7230#section-3.2.6 + * @param {number} c + */ +function isTokenCharCode (c) { + switch (c) { + case 0x22: + case 0x28: + case 0x29: + case 0x2c: + case 0x2f: + case 0x3a: + case 0x3b: + case 0x3c: + case 0x3d: + case 0x3e: + case 0x3f: + case 0x40: + case 0x5b: + case 0x5c: + case 0x5d: + case 0x7b: + case 0x7d: + // DQUOTE and "(),/:;<=>?@[\]{}" + return false + default: + // VCHAR %x21-7E + return c >= 0x21 && c <= 0x7e + } } -// See RFC 7230, Section 3.2.6. -// https://github.com/chromium/chromium/blob/d7da0240cae77824d1eda25745c4022757499131/third_party/blink/renderer/platform/network/http_parsers.cc#L321 +/** + * @param {string} characters + */ function isValidHTTPToken (characters) { - if (!characters || typeof characters !== 'string') { + if (characters.length === 0) { return false } for (let i = 0; i < characters.length; ++i) { - const c = characters.charCodeAt(i) - if (c > 0x7f || !isTokenChar(c)) { + if (!isTokenCharCode(characters.charCodeAt(i))) { return false } } return true } -// https://fetch.spec.whatwg.org/#header-name -// https://github.com/chromium/chromium/blob/b3d37e6f94f87d59e44662d6078f6a12de845d17/net/http/http_util.cc#L342 +/** + * @see https://fetch.spec.whatwg.org/#header-name + * @param {string} potentialValue + */ function isValidHeaderName (potentialValue) { - if (potentialValue.length === 0) { - return false - } - return isValidHTTPToken(potentialValue) } @@ -100345,11 +100447,30 @@ function isCancelled (fetchParams) { fetchParams.controller.state === 'terminated' } -// https://fetch.spec.whatwg.org/#concept-method-normalize +const normalizeMethodRecord = { + delete: 'DELETE', + DELETE: 'DELETE', + get: 'GET', + GET: 'GET', + head: 'HEAD', + HEAD: 'HEAD', + options: 'OPTIONS', + OPTIONS: 'OPTIONS', + post: 'POST', + POST: 'POST', + put: 'PUT', + PUT: 'PUT' +} + +// Note: object prototypes should not be able to be referenced. e.g. `Object#hasOwnProperty`. +Object.setPrototypeOf(normalizeMethodRecord, null) + +/** + * @see https://fetch.spec.whatwg.org/#concept-method-normalize + * @param {string} method + */ function normalizeMethod (method) { - return /^(DELETE|GET|HEAD|OPTIONS|POST|PUT)$/i.test(method) - ? method.toUpperCase() - : method + return normalizeMethodRecord[method.toLowerCase()] ?? method } // https://infra.spec.whatwg.org/#serialize-a-javascript-value-to-a-json-string @@ -100694,7 +100815,8 @@ module.exports = { urlIsLocal, urlHasHttpsScheme, urlIsHttpHttpsScheme, - readAllBytes + readAllBytes, + normalizeMethodRecord } @@ -101133,12 +101255,10 @@ webidl.converters.ByteString = function (V) { // 2. If the value of any element of x is greater than // 255, then throw a TypeError. for (let index = 0; index < x.length; index++) { - const charCode = x.charCodeAt(index) - - if (charCode > 255) { + if (x.charCodeAt(index) > 255) { throw new TypeError( 'Cannot convert argument to a ByteString because the character at ' + - `index ${index} has a value of ${charCode} which is greater than 255.` + `index ${index} has a value of ${x.charCodeAt(index)} which is greater than 255.` ) } } @@ -102815,6 +102935,349 @@ function cleanRequestHeaders (headers, removeContent, unknownOrigin) { module.exports = RedirectHandler +/***/ }), + +/***/ 82286: +/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { + +const assert = __nccwpck_require__(39491) + +const { kRetryHandlerDefaultRetry } = __nccwpck_require__(72785) +const { RequestRetryError } = __nccwpck_require__(48045) +const { isDisturbed, parseHeaders, parseRangeHeader } = __nccwpck_require__(83983) + +function calculateRetryAfterHeader (retryAfter) { + const current = Date.now() + const diff = new Date(retryAfter).getTime() - current + + return diff +} + +class RetryHandler { + constructor (opts, handlers) { + const { retryOptions, ...dispatchOpts } = opts + const { + // Retry scoped + retry: retryFn, + maxRetries, + maxTimeout, + minTimeout, + timeoutFactor, + // Response scoped + methods, + errorCodes, + retryAfter, + statusCodes + } = retryOptions ?? {} + + this.dispatch = handlers.dispatch + this.handler = handlers.handler + this.opts = dispatchOpts + this.abort = null + this.aborted = false + this.retryOpts = { + retry: retryFn ?? RetryHandler[kRetryHandlerDefaultRetry], + retryAfter: retryAfter ?? true, + maxTimeout: maxTimeout ?? 30 * 1000, // 30s, + timeout: minTimeout ?? 500, // .5s + timeoutFactor: timeoutFactor ?? 2, + maxRetries: maxRetries ?? 5, + // What errors we should retry + methods: methods ?? ['GET', 'HEAD', 'OPTIONS', 'PUT', 'DELETE', 'TRACE'], + // Indicates which errors to retry + statusCodes: statusCodes ?? [500, 502, 503, 504, 429], + // List of errors to retry + errorCodes: errorCodes ?? [ + 'ECONNRESET', + 'ECONNREFUSED', + 'ENOTFOUND', + 'ENETDOWN', + 'ENETUNREACH', + 'EHOSTDOWN', + 'EHOSTUNREACH', + 'EPIPE' + ] + } + + this.retryCount = 0 + this.start = 0 + this.end = null + this.etag = null + this.resume = null + + // Handle possible onConnect duplication + this.handler.onConnect(reason => { + this.aborted = true + if (this.abort) { + this.abort(reason) + } else { + this.reason = reason + } + }) + } + + onRequestSent () { + if (this.handler.onRequestSent) { + this.handler.onRequestSent() + } + } + + onUpgrade (statusCode, headers, socket) { + if (this.handler.onUpgrade) { + this.handler.onUpgrade(statusCode, headers, socket) + } + } + + onConnect (abort) { + if (this.aborted) { + abort(this.reason) + } else { + this.abort = abort + } + } + + onBodySent (chunk) { + if (this.handler.onBodySent) return this.handler.onBodySent(chunk) + } + + static [kRetryHandlerDefaultRetry] (err, { state, opts }, cb) { + const { statusCode, code, headers } = err + const { method, retryOptions } = opts + const { + maxRetries, + timeout, + maxTimeout, + timeoutFactor, + statusCodes, + errorCodes, + methods + } = retryOptions + let { counter, currentTimeout } = state + + currentTimeout = + currentTimeout != null && currentTimeout > 0 ? currentTimeout : timeout + + // Any code that is not a Undici's originated and allowed to retry + if ( + code && + code !== 'UND_ERR_REQ_RETRY' && + code !== 'UND_ERR_SOCKET' && + !errorCodes.includes(code) + ) { + cb(err) + return + } + + // If a set of method are provided and the current method is not in the list + if (Array.isArray(methods) && !methods.includes(method)) { + cb(err) + return + } + + // If a set of status code are provided and the current status code is not in the list + if ( + statusCode != null && + Array.isArray(statusCodes) && + !statusCodes.includes(statusCode) + ) { + cb(err) + return + } + + // If we reached the max number of retries + if (counter > maxRetries) { + cb(err) + return + } + + let retryAfterHeader = headers != null && headers['retry-after'] + if (retryAfterHeader) { + retryAfterHeader = Number(retryAfterHeader) + retryAfterHeader = isNaN(retryAfterHeader) + ? calculateRetryAfterHeader(retryAfterHeader) + : retryAfterHeader * 1e3 // Retry-After is in seconds + } + + const retryTimeout = + retryAfterHeader > 0 + ? Math.min(retryAfterHeader, maxTimeout) + : Math.min(currentTimeout * timeoutFactor ** counter, maxTimeout) + + state.currentTimeout = retryTimeout + + setTimeout(() => cb(null), retryTimeout) + } + + onHeaders (statusCode, rawHeaders, resume, statusMessage) { + const headers = parseHeaders(rawHeaders) + + this.retryCount += 1 + + if (statusCode >= 300) { + this.abort( + new RequestRetryError('Request failed', statusCode, { + headers, + count: this.retryCount + }) + ) + return false + } + + // Checkpoint for resume from where we left it + if (this.resume != null) { + this.resume = null + + if (statusCode !== 206) { + return true + } + + const contentRange = parseRangeHeader(headers['content-range']) + // If no content range + if (!contentRange) { + this.abort( + new RequestRetryError('Content-Range mismatch', statusCode, { + headers, + count: this.retryCount + }) + ) + return false + } + + // Let's start with a weak etag check + if (this.etag != null && this.etag !== headers.etag) { + this.abort( + new RequestRetryError('ETag mismatch', statusCode, { + headers, + count: this.retryCount + }) + ) + return false + } + + const { start, size, end = size } = contentRange + + assert(this.start === start, 'content-range mismatch') + assert(this.end == null || this.end === end, 'content-range mismatch') + + this.resume = resume + return true + } + + if (this.end == null) { + if (statusCode === 206) { + // First time we receive 206 + const range = parseRangeHeader(headers['content-range']) + + if (range == null) { + return this.handler.onHeaders( + statusCode, + rawHeaders, + resume, + statusMessage + ) + } + + const { start, size, end = size } = range + + assert( + start != null && Number.isFinite(start) && this.start !== start, + 'content-range mismatch' + ) + assert(Number.isFinite(start)) + assert( + end != null && Number.isFinite(end) && this.end !== end, + 'invalid content-length' + ) + + this.start = start + this.end = end + } + + // We make our best to checkpoint the body for further range headers + if (this.end == null) { + const contentLength = headers['content-length'] + this.end = contentLength != null ? Number(contentLength) : null + } + + assert(Number.isFinite(this.start)) + assert( + this.end == null || Number.isFinite(this.end), + 'invalid content-length' + ) + + this.resume = resume + this.etag = headers.etag != null ? headers.etag : null + + return this.handler.onHeaders( + statusCode, + rawHeaders, + resume, + statusMessage + ) + } + + const err = new RequestRetryError('Request failed', statusCode, { + headers, + count: this.retryCount + }) + + this.abort(err) + + return false + } + + onData (chunk) { + this.start += chunk.length + + return this.handler.onData(chunk) + } + + onComplete (rawTrailers) { + this.retryCount = 0 + return this.handler.onComplete(rawTrailers) + } + + onError (err) { + if (this.aborted || isDisturbed(this.opts.body)) { + return this.handler.onError(err) + } + + this.retryOpts.retry( + err, + { + state: { counter: this.retryCount++, currentTimeout: this.retryAfter }, + opts: { retryOptions: this.retryOpts, ...this.opts } + }, + onRetry.bind(this) + ) + + function onRetry (err) { + if (err != null || this.aborted || isDisturbed(this.opts.body)) { + return this.handler.onError(err) + } + + if (this.start !== 0) { + this.opts = { + ...this.opts, + headers: { + ...this.opts.headers, + range: `bytes=${this.start}-${this.end ?? ''}` + } + } + } + + try { + this.dispatch(this.opts, this) + } catch (err) { + this.handler.onError(err) + } + } + } +} + +module.exports = RetryHandler + + /***/ }), /***/ 38861: @@ -104737,6 +105200,9 @@ class ProxyAgent extends DispatcherBase { this[kProxyTls] = opts.proxyTls this[kProxyHeaders] = opts.headers || {} + const resolvedUrl = new URL(opts.uri) + const { origin, port, host, username, password } = resolvedUrl + if (opts.auth && opts.token) { throw new InvalidArgumentError('opts.auth cannot be used in combination with opts.token') } else if (opts.auth) { @@ -104744,11 +105210,10 @@ class ProxyAgent extends DispatcherBase { this[kProxyHeaders]['proxy-authorization'] = `Basic ${opts.auth}` } else if (opts.token) { this[kProxyHeaders]['proxy-authorization'] = opts.token + } else if (username && password) { + this[kProxyHeaders]['proxy-authorization'] = `Basic ${Buffer.from(`${decodeURIComponent(username)}:${decodeURIComponent(password)}`).toString('base64')}` } - const resolvedUrl = new URL(opts.uri) - const { origin, port, host } = resolvedUrl - const connect = buildConnector({ ...opts.proxyTls }) this[kConnectEndpoint] = buildConnector({ ...opts.requestTls }) this[kClient] = clientFactory(resolvedUrl, { connect }) @@ -104772,7 +105237,7 @@ class ProxyAgent extends DispatcherBase { }) if (statusCode !== 200) { socket.on('error', () => {}).destroy() - callback(new RequestAbortedError('Proxy response !== 200 when HTTP Tunneling')) + callback(new RequestAbortedError(`Proxy response (${statusCode}) !== 200 when HTTP Tunneling`)) } if (opts.protocol !== 'https:') { callback(null, socket) @@ -123685,9 +124150,15 @@ class LibericaDistributions extends base_installer_1.JavaBase { downloadTool(javaRelease) { return __awaiter(this, void 0, void 0, function* () { core.info(`Downloading Java ${javaRelease.version} (${this.distribution}) from ${javaRelease.url} ...`); - const javaArchivePath = yield tc.downloadTool(javaRelease.url); + let javaArchivePath = yield tc.downloadTool(javaRelease.url); core.info(`Extracting Java archive...`); const extension = (0, util_1.getDownloadArchiveExtension)(); + if (process.platform === 'win32' && + (this.architecture === 'arm64' || this.architecture === 'aarch64')) { + const javaArchivePathRenamed = `${javaArchivePath}.zip`; + yield fs_1.default.renameSync(javaArchivePath, javaArchivePathRenamed); + javaArchivePath = javaArchivePathRenamed; + } const extractedJavaPath = yield (0, util_1.extractJdkFile)(javaArchivePath, extension); const archiveName = fs_1.default.readdirSync(extractedJavaPath)[0]; const archivePath = path_1.default.join(extractedJavaPath, archiveName); @@ -123967,7 +124438,18 @@ class MicrosoftDistributions extends base_installer_1.JavaBase { downloadTool(javaRelease) { return __awaiter(this, void 0, void 0, function* () { core.info(`Downloading Java ${javaRelease.version} (${this.distribution}) from ${javaRelease.url} ...`); - const javaArchivePath = yield tc.downloadTool(javaRelease.url); + let javaArchivePath = yield tc.downloadTool(javaRelease.url); + // Rename archive to add extension because after downloading + // archive does not contain extension type and it leads to some issues + // on Windows runners without PowerShell Core. + // + // For default PowerShell Windows it should contain extension type to unpack it. + if (process.platform === 'win32' && + (this.architecture === 'arm64' || this.architecture === 'aarch64')) { + const javaArchivePathRenamed = `${javaArchivePath}.zip`; + yield fs_1.default.renameSync(javaArchivePath, javaArchivePathRenamed); + javaArchivePath = javaArchivePathRenamed; + } core.info(`Extracting Java archive...`); const extension = (0, util_1.getDownloadArchiveExtension)(); const extractedJavaPath = yield (0, util_1.extractJdkFile)(javaArchivePath, extension); @@ -124635,9 +125117,15 @@ class ZuluDistribution extends base_installer_1.JavaBase { downloadTool(javaRelease) { return __awaiter(this, void 0, void 0, function* () { core.info(`Downloading Java ${javaRelease.version} (${this.distribution}) from ${javaRelease.url} ...`); - const javaArchivePath = yield tc.downloadTool(javaRelease.url); + let javaArchivePath = yield tc.downloadTool(javaRelease.url); core.info(`Extracting Java archive...`); const extension = (0, util_1.getDownloadArchiveExtension)(); + if (process.platform === 'win32' && + (this.architecture === 'arm64' || this.architecture === 'aarch64')) { + const javaArchivePathRenamed = `${javaArchivePath}.zip`; + yield fs_1.default.renameSync(javaArchivePath, javaArchivePathRenamed); + javaArchivePath = javaArchivePathRenamed; + } const extractedJavaPath = yield (0, util_1.extractJdkFile)(javaArchivePath, extension); const archiveName = fs_1.default.readdirSync(extractedJavaPath)[0]; const archivePath = path_1.default.join(extractedJavaPath, archiveName); @@ -124884,7 +125372,7 @@ function run() { if (!versions.length) { core.debug('java-version input is empty, looking for java-version-file input'); const content = fs_1.default.readFileSync(versionFile).toString().trim(); - const version = (0, util_1.getVersionFromFileContent)(content, distributionName); + const version = (0, util_1.getVersionFromFileContent)(content, distributionName, versionFile); core.debug(`Parsed version from file '${version}'`); if (!version) { throw new Error(`No supported version was found in file ${versionFile}`); @@ -125238,9 +125726,20 @@ function isCacheFeatureAvailable() { return false; } exports.isCacheFeatureAvailable = isCacheFeatureAvailable; -function getVersionFromFileContent(content, distributionName) { +function getVersionFromFileContent(content, distributionName, versionFile) { var _a, _b, _c, _d, _e; - const javaVersionRegExp = /(?(?<=(^|\s|-))(\d+\S*))(\s|$)/; + let javaVersionRegExp; + function getFileName(versionFile) { + return path_1.default.basename(versionFile); + } + const versionFileName = getFileName(versionFile); + if (versionFileName == '.tool-versions') { + javaVersionRegExp = + /^(java\s+)(?:\S*-)?v?(?(\d+)(\.\d+)?(\.\d+)?(\+\d+)?(-ea(\.\d+)?)?)$/m; + } + else { + javaVersionRegExp = /(?(?<=(^|\s|-))(\d+\S*))(\s|$)/; + } const fileContent = ((_b = (_a = content.match(javaVersionRegExp)) === null || _a === void 0 ? void 0 : _a.groups) === null || _b === void 0 ? void 0 : _b.version) ? (_d = (_c = content.match(javaVersionRegExp)) === null || _c === void 0 ? void 0 : _c.groups) === null || _d === void 0 ? void 0 : _d.version : ''; diff --git a/docs/advanced-usage.md b/docs/advanced-usage.md index ede356f93..c3cf42d01 100644 --- a/docs/advanced-usage.md +++ b/docs/advanced-usage.md @@ -525,14 +525,21 @@ steps: something_other ``` -## Java-version file -If the `java-version-file` input is specified, the action will try to extract the version from the file and install it. -Action is able to recognize all variants of the version description according to [jenv](https://github.com/jenv/jenv). +## Java version file +If the `java-version-file` input is specified, the action will extract the version from the file and install it. + +Supported files are .java-version and .tool-versions. +In .java-version file, only the version should be specified, e.g., 17.0.7. +In .tool-versions file, java version should be preceded by the java keyword, e.g., java 17.0.7. +.java-version recognizes all variants of the version description according to [jenv](https://github.com/jenv/jenv) and .tool-version recognizes all variants of the version description according to [asdf](https://github.com/asdf-vm/asdf). + +If both java-version and java-version-file inputs are provided, the java-version input will be used. + Valid entry options: ``` major versions: 8, 11, 16, 17, 21 more specific versions: 1.8.0.2, 17.0, 11.0, 11.0.4, 8.0.232, 8.0.282+8 -early access (EA) versions: 15-ea, 15.0.0-ea, 15.0.0-ea.2, 15.0.0+2-ea +early access (EA) versions: 15-ea, 15.0.0-ea versions with specified distribution: openjdk64-11.0.2 ``` If the file contains multiple versions, only the first one will be recognized. diff --git a/package-lock.json b/package-lock.json index b5383de7c..8274a1c89 100644 --- a/package-lock.json +++ b/package-lock.json @@ -9,32 +9,32 @@ "version": "4.0.0", "license": "MIT", "dependencies": { - "@actions/cache": "^3.0.4", + "@actions/cache": "^3.2.4", "@actions/core": "^1.10.0", "@actions/exec": "^1.0.4", "@actions/glob": "^0.4.0", - "@actions/http-client": "^2.2.0", + "@actions/http-client": "^2.2.1", "@actions/io": "^1.0.2", "@actions/tool-cache": "^2.0.1", - "semver": "^7.3.4", + "semver": "^7.6.0", "xmlbuilder2": "^2.4.0" }, "devDependencies": { - "@types/jest": "^29.5.9", - "@types/node": "^20.9.3", - "@types/semver": "^7.3.4", + "@types/jest": "^29.5.12", + "@types/node": "^20.11.24", + "@types/semver": "^7.5.8", "@typescript-eslint/eslint-plugin": "^5.54.0", "@typescript-eslint/parser": "^5.54.0", "@vercel/ncc": "^0.38.1", - "eslint": "^8.35.0", + "eslint": "^8.57.0", "eslint-config-prettier": "^8.6.0", - "eslint-plugin-jest": "^27.2.1", + "eslint-plugin-jest": "^27.9.0", "eslint-plugin-node": "^11.1.0", "jest": "^29.7.0", "jest-circus": "^29.7.0", "prettier": "^2.8.4", - "ts-jest": "^29.1.1", - "typescript": "^5.3.2" + "ts-jest": "^29.1.2", + "typescript": "^5.3.3" } }, "node_modules/@aashutoshrathi/word-wrap": { @@ -47,9 +47,9 @@ } }, "node_modules/@actions/cache": { - "version": "3.2.2", - "resolved": "https://registry.npmjs.org/@actions/cache/-/cache-3.2.2.tgz", - "integrity": "sha512-6D0Jq5JrLZRQ3VApeQwQkkV20ZZXjXsHNYXd9VjNUdi9E0h93wESpxfMJ2JWLCUCgHNLcfY0v3GjNM+2FdRMlg==", + "version": "3.2.4", + "resolved": "https://registry.npmjs.org/@actions/cache/-/cache-3.2.4.tgz", + "integrity": "sha512-RuHnwfcDagtX+37s0ZWy7clbOfnZ7AlDJQ7k/9rzt2W4Gnwde3fa/qjSjVuz4vLcLIpc7fUob27CMrqiWZytYA==", "dependencies": { "@actions/core": "^1.10.0", "@actions/exec": "^1.0.1", @@ -59,7 +59,7 @@ "@azure/abort-controller": "^1.1.0", "@azure/ms-rest-js": "^2.6.0", "@azure/storage-blob": "^12.13.0", - "semver": "^6.1.0", + "semver": "^6.3.1", "uuid": "^3.3.3" } }, @@ -115,9 +115,9 @@ } }, "node_modules/@actions/http-client": { - "version": "2.2.0", - "resolved": "https://registry.npmjs.org/@actions/http-client/-/http-client-2.2.0.tgz", - "integrity": "sha512-q+epW0trjVUUHboliPb4UF9g2msf+w61b32tAkFEwL/IwP0DQWgbCMM0Hbe3e3WXSKz5VcUXbzJQgy8Hkra/Lg==", + "version": "2.2.1", + "resolved": "https://registry.npmjs.org/@actions/http-client/-/http-client-2.2.1.tgz", + "integrity": "sha512-KhC/cZsq7f8I4LfZSJKgCvEwfkE8o1538VoBeoGzokVLLnbFDEAdFD3UhoMklxo2un9NJVBdANOresx7vTHlHw==", "dependencies": { "tunnel": "^0.0.6", "undici": "^5.25.4" @@ -1011,9 +1011,9 @@ } }, "node_modules/@eslint/eslintrc": { - "version": "2.1.3", - "resolved": "https://registry.npmjs.org/@eslint/eslintrc/-/eslintrc-2.1.3.tgz", - "integrity": "sha512-yZzuIG+jnVu6hNSzFEN07e8BxF3uAzYtQb6uDkaYZLo6oYZDCq454c5kB8zxnzfCYyP4MIuyBn10L0DqwujTmA==", + "version": "2.1.4", + "resolved": "https://registry.npmjs.org/@eslint/eslintrc/-/eslintrc-2.1.4.tgz", + "integrity": "sha512-269Z39MS6wVJtsoUl10L60WdkhJVdPG24Q4eZTH3nnF6lpvSShEK3wQjDX9JRWAUPvPh7COouPpU9IrqaZFvtQ==", "dev": true, "dependencies": { "ajv": "^6.12.4", @@ -1034,9 +1034,9 @@ } }, "node_modules/@eslint/js": { - "version": "8.54.0", - "resolved": "https://registry.npmjs.org/@eslint/js/-/js-8.54.0.tgz", - "integrity": "sha512-ut5V+D+fOoWPgGGNj83GGjnntO39xDy6DWxO0wb7Jp3DcMX0TfIqdzHF85VTQkerdyGmuuMD9AKAo5KiNlf/AQ==", + "version": "8.57.0", + "resolved": "https://registry.npmjs.org/@eslint/js/-/js-8.57.0.tgz", + "integrity": "sha512-Ys+3g2TaW7gADOJzPt83SJtCDhMjndcDMFVQ/Tj9iA1BfJzFKD9mAUXT3OenpuPHbI6P/myECxRJrofUsDx/5g==", "dev": true, "engines": { "node": "^12.22.0 || ^14.17.0 || >=16.0.0" @@ -1051,13 +1051,13 @@ } }, "node_modules/@humanwhocodes/config-array": { - "version": "0.11.13", - "resolved": "https://registry.npmjs.org/@humanwhocodes/config-array/-/config-array-0.11.13.tgz", - "integrity": "sha512-JSBDMiDKSzQVngfRjOdFXgFfklaXI4K9nLF49Auh21lmBWRLIK3+xTErTWD4KU54pb6coM6ESE7Awz/FNU3zgQ==", + "version": "0.11.14", + "resolved": "https://registry.npmjs.org/@humanwhocodes/config-array/-/config-array-0.11.14.tgz", + "integrity": "sha512-3T8LkOmg45BV5FICb15QQMsyUSWrQ8AygVfC7ZG32zOalnqrilm018ZVCw0eapXux8FtA33q8PSRSstjee3jSg==", "dev": true, "dependencies": { - "@humanwhocodes/object-schema": "^2.0.1", - "debug": "^4.1.1", + "@humanwhocodes/object-schema": "^2.0.2", + "debug": "^4.3.1", "minimatch": "^3.0.5" }, "engines": { @@ -1078,9 +1078,9 @@ } }, "node_modules/@humanwhocodes/object-schema": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/@humanwhocodes/object-schema/-/object-schema-2.0.1.tgz", - "integrity": "sha512-dvuCeX5fC9dXgJn9t+X5atfmgQAzUOWqS1254Gh0m6i8wKd10ebXkfNKiRK+1GWi/yTvvLDHpoxLr0xxxeslWw==", + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/@humanwhocodes/object-schema/-/object-schema-2.0.2.tgz", + "integrity": "sha512-6EwiSjwWYP7pTckG6I5eyFANjPhmPjUX9JRLUSfNPC7FX7zK9gyZAfUEaECL6ALTpGX5AjnBq3C9XmVWPitNpw==", "dev": true }, "node_modules/@istanbuljs/load-nyc-config": { @@ -1703,9 +1703,9 @@ } }, "node_modules/@types/jest": { - "version": "29.5.9", - "resolved": "https://registry.npmjs.org/@types/jest/-/jest-29.5.9.tgz", - "integrity": "sha512-zJeWhqBwVoPm83sP8h1/SVntwWTu5lZbKQGCvBjxQOyEWnKnsaomt2y7SlV4KfwlrHAHHAn00Sh4IAWaIsGOgQ==", + "version": "29.5.12", + "resolved": "https://registry.npmjs.org/@types/jest/-/jest-29.5.12.tgz", + "integrity": "sha512-eDC8bTvT/QhYdxJAulQikueigY5AsdBRH2yDKW3yveW7svY3+DzN84/2NUgkw10RTiJbWqZrTtoGVdYlvFJdLw==", "dev": true, "dependencies": { "expect": "^29.0.0", @@ -1719,9 +1719,9 @@ "dev": true }, "node_modules/@types/node": { - "version": "20.9.3", - "resolved": "https://registry.npmjs.org/@types/node/-/node-20.9.3.tgz", - "integrity": "sha512-nk5wXLAXGBKfrhLB0cyHGbSqopS+nz0BUgZkUQqSHSSgdee0kssp1IAqlQOu333bW+gMNs2QREx7iynm19Abxw==", + "version": "20.11.24", + "resolved": "https://registry.npmjs.org/@types/node/-/node-20.11.24.tgz", + "integrity": "sha512-Kza43ewS3xoLgCEpQrsT+xRo/EJej1y0kVYGiLFE1NEODXGzTfwiC6tXTLMQskn1X4/Rjlh0MQUvx9W+L9long==", "dependencies": { "undici-types": "~5.26.4" } @@ -1749,9 +1749,9 @@ } }, "node_modules/@types/semver": { - "version": "7.5.6", - "resolved": "https://registry.npmjs.org/@types/semver/-/semver-7.5.6.tgz", - "integrity": "sha512-dn1l8LaMea/IjDoHNd9J52uBbInB796CDffS6VdIxvqYCPSG0V0DzHp76GpaWnlhg88uYyPbXCDIowa86ybd5A==", + "version": "7.5.8", + "resolved": "https://registry.npmjs.org/@types/semver/-/semver-7.5.8.tgz", + "integrity": "sha512-I8EUhyrgfLrcTkzV3TSsGyl1tSuPrEDzr0yd5m90UgNxQkyDXULk3b6MlQqTCpZpNtWe1K0hzclnZkTcLBe2UQ==", "dev": true }, "node_modules/@types/stack-utils": { @@ -1998,9 +1998,9 @@ } }, "node_modules/acorn": { - "version": "8.11.2", - "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.11.2.tgz", - "integrity": "sha512-nc0Axzp/0FILLEVsm4fNwLCwMttvhEI263QtVPQcbpfZZ3ts0hLsZGOpE6czNlid7CJ9MlyH8reXkpsf3YUY4w==", + "version": "8.11.3", + "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.11.3.tgz", + "integrity": "sha512-Y9rRfJG5jcKOE0CLisYbojUjIrIEE7AGMzA/Sm4BslANhbS+cDMpgBdcPT91oJ7OuJ9hYJBx59RjbhxVnrF8Xg==", "dev": true, "bin": { "acorn": "bin/acorn" @@ -2659,16 +2659,16 @@ } }, "node_modules/eslint": { - "version": "8.54.0", - "resolved": "https://registry.npmjs.org/eslint/-/eslint-8.54.0.tgz", - "integrity": "sha512-NY0DfAkM8BIZDVl6PgSa1ttZbx3xHgJzSNJKYcQglem6CppHyMhRIQkBVSSMaSRnLhig3jsDbEzOjwCVt4AmmA==", + "version": "8.57.0", + "resolved": "https://registry.npmjs.org/eslint/-/eslint-8.57.0.tgz", + "integrity": "sha512-dZ6+mexnaTIbSBZWgou51U6OmzIhYM2VcNdtiTtI7qPNZm35Akpr0f6vtw3w1Kmn5PYo+tZVfh13WrhpS6oLqQ==", "dev": true, "dependencies": { "@eslint-community/eslint-utils": "^4.2.0", "@eslint-community/regexpp": "^4.6.1", - "@eslint/eslintrc": "^2.1.3", - "@eslint/js": "8.54.0", - "@humanwhocodes/config-array": "^0.11.13", + "@eslint/eslintrc": "^2.1.4", + "@eslint/js": "8.57.0", + "@humanwhocodes/config-array": "^0.11.14", "@humanwhocodes/module-importer": "^1.0.1", "@nodelib/fs.walk": "^1.2.8", "@ungap/structured-clone": "^1.2.0", @@ -2745,9 +2745,9 @@ } }, "node_modules/eslint-plugin-jest": { - "version": "27.6.0", - "resolved": "https://registry.npmjs.org/eslint-plugin-jest/-/eslint-plugin-jest-27.6.0.tgz", - "integrity": "sha512-MTlusnnDMChbElsszJvrwD1dN3x6nZl//s4JD23BxB6MgR66TZlL064su24xEIS3VACfAoHV1vgyMgPw8nkdng==", + "version": "27.9.0", + "resolved": "https://registry.npmjs.org/eslint-plugin-jest/-/eslint-plugin-jest-27.9.0.tgz", + "integrity": "sha512-QIT7FH7fNmd9n4se7FFKHbsLKGQiw885Ds6Y/sxKgCZ6natwCsXdgPOADnYVxN2QrRweF0FZWbJ6S7Rsn7llug==", "dev": true, "dependencies": { "@typescript-eslint/utils": "^5.10.0" @@ -2756,7 +2756,7 @@ "node": "^14.15.0 || ^16.10.0 || >=18.0.0" }, "peerDependencies": { - "@typescript-eslint/eslint-plugin": "^5.0.0 || ^6.0.0", + "@typescript-eslint/eslint-plugin": "^5.0.0 || ^6.0.0 || ^7.0.0", "eslint": "^7.0.0 || ^8.0.0", "jest": "*" }, @@ -3263,9 +3263,9 @@ } }, "node_modules/globals": { - "version": "13.23.0", - "resolved": "https://registry.npmjs.org/globals/-/globals-13.23.0.tgz", - "integrity": "sha512-XAmF0RjlrjY23MA51q3HltdlGxUpXPvg0GioKiD9X6HD28iMjo2dKC8Vqwm7lne4GNr78+RHTfliktR6ZH09wA==", + "version": "13.24.0", + "resolved": "https://registry.npmjs.org/globals/-/globals-13.24.0.tgz", + "integrity": "sha512-AhO5QUcj8llrbG09iWhPU2B204J1xnPeL8kQmVorSsy+Sjj1sk8gIyh6cUocGmH4L0UuhAJy+hJMRA4mgA4mFQ==", "dev": true, "dependencies": { "type-fest": "^0.20.2" @@ -4958,9 +4958,9 @@ "integrity": "sha512-0s+oAmw9zLl1V1cS9BtZN7JAd0cW5e0QH4W3LWEK6a4LaLEA2OTpGYWDY+6XasBLtz6wkm3u1xRw95mRuJ59WA==" }, "node_modules/semver": { - "version": "7.5.4", - "resolved": "https://registry.npmjs.org/semver/-/semver-7.5.4.tgz", - "integrity": "sha512-1bCSESV6Pv+i21Hvpxp3Dx+pSD8lIPt8uVjRrxAUt/nbswYc+tK6Y2btiULjd4+fnq15PX+nqQDC7Oft7WkwcA==", + "version": "7.6.0", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.6.0.tgz", + "integrity": "sha512-EnwXhrlwXMk9gKu5/flx5sv/an57AkRplG3hTK68W7FRDN+k+OWBj65M7719OkA82XLBxrcX0KSHj+X5COhOVg==", "dependencies": { "lru-cache": "^6.0.0" }, @@ -5215,9 +5215,9 @@ } }, "node_modules/ts-jest": { - "version": "29.1.1", - "resolved": "https://registry.npmjs.org/ts-jest/-/ts-jest-29.1.1.tgz", - "integrity": "sha512-D6xjnnbP17cC85nliwGiL+tpoKN0StpgE0TeOjXQTU6MVCfsB4v7aW05CgQ/1OywGb0x/oy9hHFnN+sczTiRaA==", + "version": "29.1.2", + "resolved": "https://registry.npmjs.org/ts-jest/-/ts-jest-29.1.2.tgz", + "integrity": "sha512-br6GJoH/WUX4pu7FbZXuWGKGNDuU7b8Uj77g/Sp7puZV6EXzuByl6JrECvm0MzVzSTkSHWTihsXt+5XYER5b+g==", "dev": true, "dependencies": { "bs-logger": "0.x", @@ -5233,7 +5233,7 @@ "ts-jest": "cli.js" }, "engines": { - "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + "node": "^16.10.0 || ^18.0.0 || >=20.0.0" }, "peerDependencies": { "@babel/core": ">=7.0.0-beta.0 <8", @@ -5325,9 +5325,9 @@ } }, "node_modules/typescript": { - "version": "5.3.2", - "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.3.2.tgz", - "integrity": "sha512-6l+RyNy7oAHDfxC4FzSJcz9vnjTKxrLpDG5M2Vu4SHRVNg6xzqZp6LYSR9zjqQTu8DU/f5xwxUdADOkbrIX2gQ==", + "version": "5.3.3", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.3.3.tgz", + "integrity": "sha512-pXWcraxM0uxAS+tN0AG/BF2TyqmHO014Z070UsJ+pFvYuRSq8KH8DmWpnbXe0pEPDHXZV3FcAbJkijJ5oNEnWw==", "dev": true, "bin": { "tsc": "bin/tsc", @@ -5338,9 +5338,9 @@ } }, "node_modules/undici": { - "version": "5.27.2", - "resolved": "https://registry.npmjs.org/undici/-/undici-5.27.2.tgz", - "integrity": "sha512-iS857PdOEy/y3wlM3yRp+6SNQQ6xU0mmZcwRSriqk+et/cwWAtwmIGf6WkoDN2EK/AMdCO/dfXzIwi+rFMrjjQ==", + "version": "5.28.3", + "resolved": "https://registry.npmjs.org/undici/-/undici-5.28.3.tgz", + "integrity": "sha512-3ItfzbrhDlINjaP0duwnNsKpDQk3acHI3gVJ1z4fmwMK31k5G9OVIAMLSIaP6w4FaGkaAkN6zaQO9LUvZ1t7VA==", "dependencies": { "@fastify/busboy": "^2.0.0" }, diff --git a/package.json b/package.json index 3f6eb92fd..d8c49485b 100644 --- a/package.json +++ b/package.json @@ -26,36 +26,35 @@ "author": "GitHub", "license": "MIT", "dependencies": { - "@actions/cache": "^3.0.4", + "@actions/cache": "^3.2.4", "@actions/core": "^1.10.0", "@actions/exec": "^1.0.4", "@actions/glob": "^0.4.0", - "@actions/http-client": "^2.2.0", + "@actions/http-client": "^2.2.1", "@actions/io": "^1.0.2", "@actions/tool-cache": "^2.0.1", - "semver": "^7.3.4", + "semver": "^7.6.0", "xmlbuilder2": "^2.4.0" }, "devDependencies": { - "@types/jest": "^29.5.9", - "@types/node": "^20.9.3", - "@types/semver": "^7.3.4", + "@types/jest": "^29.5.12", + "@types/node": "^20.11.24", + "@types/semver": "^7.5.8", "@typescript-eslint/eslint-plugin": "^5.54.0", "@typescript-eslint/parser": "^5.54.0", "@vercel/ncc": "^0.38.1", - "eslint": "^8.35.0", + "eslint": "^8.57.0", "eslint-config-prettier": "^8.6.0", - "eslint-plugin-jest": "^27.2.1", + "eslint-plugin-jest": "^27.9.0", "eslint-plugin-node": "^11.1.0", "jest": "^29.7.0", "jest-circus": "^29.7.0", "prettier": "^2.8.4", - "ts-jest": "^29.1.1", - "typescript": "^5.3.2" + "ts-jest": "^29.1.2", + "typescript": "^5.3.3" }, "bugs": { "url": "https://github.com/actions/setup-java/issues" }, "homepage": "https://github.com/actions/setup-java#readme" - } diff --git a/src/distributions/liberica/installer.ts b/src/distributions/liberica/installer.ts index 313f29eae..3ed9435ab 100644 --- a/src/distributions/liberica/installer.ts +++ b/src/distributions/liberica/installer.ts @@ -31,10 +31,18 @@ export class LibericaDistributions extends JavaBase { core.info( `Downloading Java ${javaRelease.version} (${this.distribution}) from ${javaRelease.url} ...` ); - const javaArchivePath = await tc.downloadTool(javaRelease.url); + let javaArchivePath = await tc.downloadTool(javaRelease.url); core.info(`Extracting Java archive...`); const extension = getDownloadArchiveExtension(); + if ( + process.platform === 'win32' && + (this.architecture === 'arm64' || this.architecture === 'aarch64') + ) { + const javaArchivePathRenamed = `${javaArchivePath}.zip`; + await fs.renameSync(javaArchivePath, javaArchivePathRenamed); + javaArchivePath = javaArchivePathRenamed; + } const extractedJavaPath = await extractJdkFile(javaArchivePath, extension); const archiveName = fs.readdirSync(extractedJavaPath)[0]; diff --git a/src/distributions/microsoft/installer.ts b/src/distributions/microsoft/installer.ts index 6feafabc0..d20e55da6 100644 --- a/src/distributions/microsoft/installer.ts +++ b/src/distributions/microsoft/installer.ts @@ -26,7 +26,20 @@ export class MicrosoftDistributions extends JavaBase { core.info( `Downloading Java ${javaRelease.version} (${this.distribution}) from ${javaRelease.url} ...` ); - const javaArchivePath = await tc.downloadTool(javaRelease.url); + let javaArchivePath = await tc.downloadTool(javaRelease.url); + // Rename archive to add extension because after downloading + // archive does not contain extension type and it leads to some issues + // on Windows runners without PowerShell Core. + // + // For default PowerShell Windows it should contain extension type to unpack it. + if ( + process.platform === 'win32' && + (this.architecture === 'arm64' || this.architecture === 'aarch64') + ) { + const javaArchivePathRenamed = `${javaArchivePath}.zip`; + await fs.renameSync(javaArchivePath, javaArchivePathRenamed); + javaArchivePath = javaArchivePathRenamed; + } core.info(`Extracting Java archive...`); const extension = getDownloadArchiveExtension(); diff --git a/src/distributions/microsoft/microsoft-openjdk-versions.json b/src/distributions/microsoft/microsoft-openjdk-versions.json index 9b7e798b1..4fd1e974f 100644 --- a/src/distributions/microsoft/microsoft-openjdk-versions.json +++ b/src/distributions/microsoft/microsoft-openjdk-versions.json @@ -1,4 +1,90 @@ [ + { + "version": "21.0.2", + "stable": true, + "release_url": "https://aka.ms/download-jdk", + "files": [ + { + "filename": "microsoft-jdk-21.0.2-macos-x64.tar.gz", + "arch": "x64", + "platform": "darwin", + "download_url": "https://aka.ms/download-jdk/microsoft-jdk-21.0.2-macos-x64.tar.gz" + }, + { + "filename": "microsoft-jdk-21.0.2-linux-x64.tar.gz", + "arch": "x64", + "platform": "linux", + "download_url": "https://aka.ms/download-jdk/microsoft-jdk-21.0.2-linux-x64.tar.gz" + }, + { + "filename": "microsoft-jdk-21.0.2-windows-x64.zip", + "arch": "x64", + "platform": "win32", + "download_url": "https://aka.ms/download-jdk/microsoft-jdk-21.0.2-windows-x64.zip" + }, + { + "filename": "microsoft-jdk-21.0.2-macos-aarch64.tar.gz", + "arch": "aarch64", + "platform": "darwin", + "download_url": "https://aka.ms/download-jdk/microsoft-jdk-21.0.2-macos-aarch64.tar.gz" + }, + { + "filename": "microsoft-jdk-21.0.2-linux-aarch64.tar.gz", + "arch": "aarch64", + "platform": "linux", + "download_url": "https://aka.ms/download-jdk/microsoft-jdk-21.0.2-linux-aarch64.tar.gz" + }, + { + "filename": "microsoft-jdk-21.0.2-windows-aarch64.zip", + "arch": "aarch64", + "platform": "win32", + "download_url": "https://aka.ms/download-jdk/microsoft-jdk-21.0.2-windows-aarch64.zip" + } + ] +}, + { + "version": "21.0.1", + "stable": true, + "release_url": "https://aka.ms/download-jdk", + "files": [ + { + "filename": "microsoft-jdk-21.0.1-macos-x64.tar.gz", + "arch": "x64", + "platform": "darwin", + "download_url": "https://aka.ms/download-jdk/microsoft-jdk-21.0.1-macos-x64.tar.gz" + }, + { + "filename": "microsoft-jdk-21.0.1-linux-x64.tar.gz", + "arch": "x64", + "platform": "linux", + "download_url": "https://aka.ms/download-jdk/microsoft-jdk-21.0.1-linux-x64.tar.gz" + }, + { + "filename": "microsoft-jdk-21.0.1-windows-x64.zip", + "arch": "x64", + "platform": "win32", + "download_url": "https://aka.ms/download-jdk/microsoft-jdk-21.0.1-windows-x64.zip" + }, + { + "filename": "microsoft-jdk-21.0.1-macos-aarch64.tar.gz", + "arch": "aarch64", + "platform": "darwin", + "download_url": "https://aka.ms/download-jdk/microsoft-jdk-21.0.1-macos-aarch64.tar.gz" + }, + { + "filename": "microsoft-jdk-21.0.1-linux-aarch64.tar.gz", + "arch": "aarch64", + "platform": "linux", + "download_url": "https://aka.ms/download-jdk/microsoft-jdk-21.0.1-linux-aarch64.tar.gz" + }, + { + "filename": "microsoft-jdk-21.0.1-windows-aarch64.zip", + "arch": "aarch64", + "platform": "win32", + "download_url": "https://aka.ms/download-jdk/microsoft-jdk-21.0.1-windows-aarch64.zip" + } + ] +}, { "version": "21.0.0", "stable": true, @@ -33,6 +119,184 @@ "arch": "aarch64", "platform": "linux", "download_url": "https://aka.ms/download-jdk/microsoft-jdk-21.0.0-linux-aarch64.tar.gz" + }, + { + "filename": "microsoft-jdk-21.0.0-windows-aarch64.zip", + "arch": "aarch64", + "platform": "win32", + "download_url": "https://aka.ms/download-jdk/microsoft-jdk-21.0.0-windows-aarch64.zip" + } + ] + }, + { + "version": "17.0.10", + "stable": true, + "release_url": "https://aka.ms/download-jdk", + "files": [ + { + "filename": "microsoft-jdk-17.0.10-macos-x64.tar.gz", + "arch": "x64", + "platform": "darwin", + "download_url": "https://aka.ms/download-jdk/microsoft-jdk-17.0.7-macos-x64.tar.gz" + }, + { + "filename": "microsoft-jdk-17.0.10-linux-x64.tar.gz", + "arch": "x64", + "platform": "linux", + "download_url": "https://aka.ms/download-jdk/microsoft-jdk-17.0.10-linux-x64.tar.gz" + }, + { + "filename": "microsoft-jdk-17.0.10-windows-x64.zip", + "arch": "x64", + "platform": "win32", + "download_url": "https://aka.ms/download-jdk/microsoft-jdk-17.0.10-windows-x64.zip" + }, + { + "filename": "microsoft-jdk-17.0.10-macos-aarch64.tar.gz", + "arch": "aarch64", + "platform": "darwin", + "download_url": "https://aka.ms/download-jdk/microsoft-jdk-17.0.10-macos-aarch64.tar.gz" + }, + { + "filename": "microsoft-jdk-17.0.10-linux-aarch64.tar.gz", + "arch": "aarch64", + "platform": "linux", + "download_url": "https://aka.ms/download-jdk/microsoft-jdk-17.0.10-linux-aarch64.tar.gz" + }, + { + "filename": "microsoft-jdk-17.0.10-windows-aarch64.zip", + "arch": "aarch64", + "platform": "win32", + "download_url": "https://aka.ms/download-jdk/microsoft-jdk-17.0.10-windows-aarch64.zip" + } + ] + }, + { + "version": "17.0.9", + "stable": true, + "release_url": "https://aka.ms/download-jdk", + "files": [ + { + "filename": "microsoft-jdk-17.0.9-macos-x64.tar.gz", + "arch": "x64", + "platform": "darwin", + "download_url": "https://aka.ms/download-jdk/microsoft-jdk-17.0.9-macos-x64.tar.gz" + }, + { + "filename": "microsoft-jdk-17.0.9-linux-x64.tar.gz", + "arch": "x64", + "platform": "linux", + "download_url": "https://aka.ms/download-jdk/microsoft-jdk-17.0.9-linux-x64.tar.gz" + }, + { + "filename": "microsoft-jdk-17.0.9-windows-x64.zip", + "arch": "x64", + "platform": "win32", + "download_url": "https://aka.ms/download-jdk/microsoft-jdk-17.0.9-windows-x64.zip" + }, + { + "filename": "microsoft-jdk-17.0.9-macos-aarch64.tar.gz", + "arch": "aarch64", + "platform": "darwin", + "download_url": "https://aka.ms/download-jdk/microsoft-jdk-17.0.9-macos-aarch64.tar.gz" + }, + { + "filename": "microsoft-jdk-17.0.9-linux-aarch64.tar.gz", + "arch": "aarch64", + "platform": "linux", + "download_url": "https://aka.ms/download-jdk/microsoft-jdk-17.0.9-linux-aarch64.tar.gz" + }, + { + "filename": "microsoft-jdk-17.0.9-windows-aarch64.zip", + "arch": "aarch64", + "platform": "win32", + "download_url": "https://aka.ms/download-jdk/microsoft-jdk-17.0.9-windows-aarch64.zip" + } + ] + }, + { + "version": "17.0.8", + "stable": true, + "release_url": "https://aka.ms/download-jdk", + "files": [ + { + "filename": "microsoft-jdk-17.0.8-macos-x64.tar.gz", + "arch": "x64", + "platform": "darwin", + "download_url": "https://aka.ms/download-jdk/microsoft-jdk-17.0.8-macos-x64.tar.gz" + }, + { + "filename": "microsoft-jdk-17.0.8-linux-x64.tar.gz", + "arch": "x64", + "platform": "linux", + "download_url": "https://aka.ms/download-jdk/microsoft-jdk-17.0.8-linux-x64.tar.gz" + }, + { + "filename": "microsoft-jdk-17.0.8-windows-x64.zip", + "arch": "x64", + "platform": "win32", + "download_url": "https://aka.ms/download-jdk/microsoft-jdk-17.0.8-windows-x64.zip" + }, + { + "filename": "microsoft-jdk-17.0.8-macos-aarch64.tar.gz", + "arch": "aarch64", + "platform": "darwin", + "download_url": "https://aka.ms/download-jdk/microsoft-jdk-17.0.8-macos-aarch64.tar.gz" + }, + { + "filename": "microsoft-jdk-17.0.8-linux-aarch64.tar.gz", + "arch": "aarch64", + "platform": "linux", + "download_url": "https://aka.ms/download-jdk/microsoft-jdk-17.0.8-linux-aarch64.tar.gz" + }, + { + "filename": "microsoft-jdk-17.0.8-windows-aarch64.zip", + "arch": "aarch64", + "platform": "win32", + "download_url": "https://aka.ms/download-jdk/microsoft-jdk-17.0.8-windows-aarch64.zip" + } + ] + }, + { + "version": "17.0.8.1", + "stable": true, + "release_url": "https://aka.ms/download-jdk", + "files": [ + { + "filename": "microsoft-jdk-17.0.8.1-macos-x64.tar.gz", + "arch": "x64", + "platform": "darwin", + "download_url": "https://aka.ms/download-jdk/microsoft-jdk-17.0.8.1-macos-x64.tar.gz" + }, + { + "filename": "microsoft-jdk-17.0.8.1-linux-x64.tar.gz", + "arch": "x64", + "platform": "linux", + "download_url": "https://aka.ms/download-jdk/microsoft-jdk-17.0.8.1-linux-x64.tar.gz" + }, + { + "filename": "microsoft-jdk-17.0.8.1-windows-x64.zip", + "arch": "x64", + "platform": "win32", + "download_url": "https://aka.ms/download-jdk/microsoft-jdk-17.0.8.1-windows-x64.zip" + }, + { + "filename": "microsoft-jdk-17.0.8.1-macos-aarch64.tar.gz", + "arch": "aarch64", + "platform": "darwin", + "download_url": "https://aka.ms/download-jdk/microsoft-jdk-17.0.8.1-macos-aarch64.tar.gz" + }, + { + "filename": "microsoft-jdk-17.0.8.1-linux-aarch64.tar.gz", + "arch": "aarch64", + "platform": "linux", + "download_url": "https://aka.ms/download-jdk/microsoft-jdk-17.0.8.1-linux-aarch64.tar.gz" + }, + { + "filename": "microsoft-jdk-17.0.8.1-windows-aarch64.zip", + "arch": "aarch64", + "platform": "win32", + "download_url": "https://aka.ms/download-jdk/microsoft-jdk-17.0.8.1-windows-aarch64.zip" } ] }, @@ -70,6 +334,12 @@ "arch": "aarch64", "platform": "linux", "download_url": "https://aka.ms/download-jdk/microsoft-jdk-17.0.7-linux-aarch64.tar.gz" + }, + { + "filename": "microsoft-jdk-17.0.7-windows-aarch64.zip", + "arch": "aarch64", + "platform": "win32", + "download_url": "https://aka.ms/download-jdk/microsoft-jdk-17.0.7-windows-aarch64.zip" } ] }, @@ -107,6 +377,12 @@ "arch": "aarch64", "platform": "linux", "download_url": "https://aka.ms/download-jdk/microsoft-jdk-17.0.6-linux-aarch64.tar.gz" + }, + { + "filename": "microsoft-jdk-17.0.6-windows-aarch64.zip", + "arch": "aarch64", + "platform": "win32", + "download_url": "https://aka.ms/download-jdk/microsoft-jdk-17.0.6-windows-aarch64.zip" } ] }, @@ -144,6 +420,12 @@ "arch": "aarch64", "platform": "linux", "download_url": "https://aka.ms/download-jdk/microsoft-jdk-17.0.5-linux-aarch64.tar.gz" + }, + { + "filename": "microsoft-jdk-17.0.5-windows-aarch64.zip", + "arch": "aarch64", + "platform": "win32", + "download_url": "https://aka.ms/download-jdk/microsoft-jdk-17.0.5-windows-aarch64.zip" } ] }, @@ -181,6 +463,12 @@ "arch": "aarch64", "platform": "linux", "download_url": "https://aka.ms/download-jdk/microsoft-jdk-17.0.4-linux-aarch64.tar.gz" + }, + { + "filename": "microsoft-jdk-17.0.4-windows-aarch64.zip", + "arch": "aarch64", + "platform": "win32", + "download_url": "https://aka.ms/download-jdk/microsoft-jdk-17.0.4-windows-aarch64.zip" } ] }, @@ -218,6 +506,12 @@ "arch": "aarch64", "platform": "linux", "download_url": "https://aka.ms/download-jdk/microsoft-jdk-17.0.3-linux-aarch64.tar.gz" + }, + { + "filename": "microsoft-jdk-17.0.3-windows-aarch64.zip", + "arch": "aarch64", + "platform": "win32", + "download_url": "https://aka.ms/download-jdk/microsoft-jdk-17.0.3-windows-aarch64.zip" } ] }, @@ -329,6 +623,12 @@ "arch": "aarch64", "platform": "linux", "download_url": "https://aka.ms/download-jdk/microsoft-jdk-11.0.19-linux-aarch64.tar.gz" + }, + { + "filename": "microsoft-jdk-11.0.19-windows-aarch64.zip", + "arch": "aarch64", + "platform": "win32", + "download_url": "https://aka.ms/download-jdk/microsoft-jdk-11.0.19-windows-aarch64.zip" } ] }, @@ -366,6 +666,12 @@ "arch": "aarch64", "platform": "linux", "download_url": "https://aka.ms/download-jdk/microsoft-jdk-11.0.18-linux-aarch64.tar.gz" + }, + { + "filename": "microsoft-jdk-11.0.18-windows-aarch64.zip", + "arch": "aarch64", + "platform": "win32", + "download_url": "https://aka.ms/download-jdk/microsoft-jdk-11.0.18-windows-aarch64.zip" } ] }, @@ -403,6 +709,12 @@ "arch": "aarch64", "platform": "linux", "download_url": "https://aka.ms/download-jdk/microsoft-jdk-11.0.17-linux-aarch64.tar.gz" + }, + { + "filename": "microsoft-jdk-11.0.17-windows-aarch64.zip", + "arch": "aarch64", + "platform": "win32", + "download_url": "https://aka.ms/download-jdk/microsoft-jdk-11.0.17-windows-aarch64.zip" } ] }, @@ -440,6 +752,12 @@ "arch": "aarch64", "platform": "linux", "download_url": "https://aka.ms/download-jdk/microsoft-jdk-11.0.16-linux-aarch64.tar.gz" + }, + { + "filename": "microsoft-jdk-11.0.16-windows-aarch64.zip", + "arch": "aarch64", + "platform": "win32", + "download_url": "https://aka.ms/download-jdk/microsoft-jdk-11.0.16-windows-aarch64.zip" } ] }, @@ -477,6 +795,12 @@ "arch": "aarch64", "platform": "linux", "download_url": "https://aka.ms/download-jdk/microsoft-jdk-11.0.15-linux-aarch64.tar.gz" + }, + { + "filename": "microsoft-jdk-11.0.15-windows-aarch64.zip", + "arch": "aarch64", + "platform": "win32", + "download_url": "https://aka.ms/download-jdk/microsoft-jdk-11.0.15-windows-aarch64.zip" } ] }, diff --git a/src/distributions/zulu/installer.ts b/src/distributions/zulu/installer.ts index c996bb8e4..e406c6b6d 100644 --- a/src/distributions/zulu/installer.ts +++ b/src/distributions/zulu/installer.ts @@ -76,11 +76,18 @@ export class ZuluDistribution extends JavaBase { core.info( `Downloading Java ${javaRelease.version} (${this.distribution}) from ${javaRelease.url} ...` ); - const javaArchivePath = await tc.downloadTool(javaRelease.url); + let javaArchivePath = await tc.downloadTool(javaRelease.url); core.info(`Extracting Java archive...`); const extension = getDownloadArchiveExtension(); - + if ( + process.platform === 'win32' && + (this.architecture === 'arm64' || this.architecture === 'aarch64') + ) { + const javaArchivePathRenamed = `${javaArchivePath}.zip`; + await fs.renameSync(javaArchivePath, javaArchivePathRenamed); + javaArchivePath = javaArchivePathRenamed; + } const extractedJavaPath = await extractJdkFile(javaArchivePath, extension); const archiveName = fs.readdirSync(extractedJavaPath)[0]; diff --git a/src/setup-java.ts b/src/setup-java.ts index 35a315df6..73baf33a7 100644 --- a/src/setup-java.ts +++ b/src/setup-java.ts @@ -55,7 +55,11 @@ async function run() { ); const content = fs.readFileSync(versionFile).toString().trim(); - const version = getVersionFromFileContent(content, distributionName); + const version = getVersionFromFileContent( + content, + distributionName, + versionFile + ); core.debug(`Parsed version from file '${version}'`); if (!version) { diff --git a/src/util.ts b/src/util.ts index 94be23477..034fc83d4 100644 --- a/src/util.ts +++ b/src/util.ts @@ -115,9 +115,23 @@ export function isCacheFeatureAvailable(): boolean { export function getVersionFromFileContent( content: string, - distributionName: string + distributionName: string, + versionFile: string ): string | null { - const javaVersionRegExp = /(?(?<=(^|\s|-))(\d+\S*))(\s|$)/; + let javaVersionRegExp: RegExp; + + function getFileName(versionFile: string) { + return path.basename(versionFile); + } + + const versionFileName = getFileName(versionFile); + if (versionFileName == '.tool-versions') { + javaVersionRegExp = + /^(java\s+)(?:\S*-)?v?(?(\d+)(\.\d+)?(\.\d+)?(\+\d+)?(-ea(\.\d+)?)?)$/m; + } else { + javaVersionRegExp = /(?(?<=(^|\s|-))(\d+\S*))(\s|$)/; + } + const fileContent = content.match(javaVersionRegExp)?.groups?.version ? (content.match(javaVersionRegExp)?.groups?.version as string) : '';