mirror of
https://github.com/actions/setup-java.git
synced 2025-04-21 02:16:45 +00:00
Add and configure ESLint and update configuration for Prettier (#458)
* Add ESLint config and update Prettier * Update test files * Rebuild action * Update docs * Update licenses * Update tsconfig * Rebuild action * Update tsconfig.json * Fix console.time calls * Rebuild action * Rebuild action on Linux
This commit is contained in:
parent
ea15b3b99c
commit
0de5c66fc0
55 changed files with 4402 additions and 1317 deletions
|
@ -1,9 +1,17 @@
|
|||
import { JavaBase } from '../base-installer';
|
||||
import { JavaDownloadRelease, JavaInstallerOptions, JavaInstallerResults } from '../base-models';
|
||||
import {JavaBase} from '../base-installer';
|
||||
import {
|
||||
JavaDownloadRelease,
|
||||
JavaInstallerOptions,
|
||||
JavaInstallerResults
|
||||
} from '../base-models';
|
||||
import semver from 'semver';
|
||||
import { extractJdkFile, getDownloadArchiveExtension, isVersionSatisfies } from '../../util';
|
||||
import {
|
||||
extractJdkFile,
|
||||
getDownloadArchiveExtension,
|
||||
isVersionSatisfies
|
||||
} from '../../util';
|
||||
import * as core from '@actions/core';
|
||||
import { ArchitectureOptions, LibericaVersion, OsVersions } from './models';
|
||||
import {ArchitectureOptions, LibericaVersion, OsVersions} from './models';
|
||||
import * as tc from '@actions/tool-cache';
|
||||
import fs from 'fs';
|
||||
import path from 'path';
|
||||
|
@ -17,7 +25,9 @@ export class LibericaDistributions extends JavaBase {
|
|||
super('Liberica', installerOptions);
|
||||
}
|
||||
|
||||
protected async downloadTool(javaRelease: JavaDownloadRelease): Promise<JavaInstallerResults> {
|
||||
protected async downloadTool(
|
||||
javaRelease: JavaDownloadRelease
|
||||
): Promise<JavaInstallerResults> {
|
||||
core.info(
|
||||
`Downloading Java ${javaRelease.version} (${this.distribution}) from ${javaRelease.url} ...`
|
||||
);
|
||||
|
@ -37,10 +47,12 @@ export class LibericaDistributions extends JavaBase {
|
|||
this.architecture
|
||||
);
|
||||
|
||||
return { version: javaRelease.version, path: javaPath };
|
||||
return {version: javaRelease.version, path: javaPath};
|
||||
}
|
||||
|
||||
protected async findPackageForDownload(range: string): Promise<JavaDownloadRelease> {
|
||||
protected async findPackageForDownload(
|
||||
range: string
|
||||
): Promise<JavaDownloadRelease> {
|
||||
const availableVersionsRaw = await this.getAvailableVersions();
|
||||
|
||||
const availableVersions = availableVersionsRaw.map(item => ({
|
||||
|
@ -53,7 +65,9 @@ export class LibericaDistributions extends JavaBase {
|
|||
.sort((a, b) => -semver.compareBuild(a.version, b.version))[0];
|
||||
|
||||
if (!satisfiedVersion) {
|
||||
const availableOptions = availableVersions.map(item => item.version).join(', ');
|
||||
const availableOptions = availableVersions
|
||||
.map(item => item.version)
|
||||
.join(', ');
|
||||
const availableOptionsMessage = availableOptions
|
||||
? `\nAvailable versions: ${availableOptions}`
|
||||
: '';
|
||||
|
@ -67,21 +81,20 @@ export class LibericaDistributions extends JavaBase {
|
|||
|
||||
private async getAvailableVersions(): Promise<LibericaVersion[]> {
|
||||
if (core.isDebug()) {
|
||||
console.time('liberica-retrieve-available-versions');
|
||||
console.time('Retrieving available versions for Liberica took'); // eslint-disable-line no-console
|
||||
}
|
||||
const url = this.prepareAvailableVersionsUrl();
|
||||
|
||||
if (core.isDebug()) {
|
||||
core.debug(`Gathering available versions from '${url}'`);
|
||||
}
|
||||
core.debug(`Gathering available versions from '${url}'`);
|
||||
|
||||
const availableVersions = (await this.http.getJson<LibericaVersion[]>(url)).result ?? [];
|
||||
const availableVersions =
|
||||
(await this.http.getJson<LibericaVersion[]>(url)).result ?? [];
|
||||
|
||||
if (core.isDebug()) {
|
||||
core.startGroup('Print information about available versions');
|
||||
console.timeEnd('liberica-retrieve-available-versions');
|
||||
console.log(`Available versions: [${availableVersions.length}]`);
|
||||
console.log(availableVersions.map(item => item.version));
|
||||
console.timeEnd('Retrieving available versions for Liberica took'); // eslint-disable-line no-console
|
||||
core.debug(`Available versions: [${availableVersions.length}]`);
|
||||
core.debug(availableVersions.map(item => item.version).join(', '));
|
||||
core.endGroup();
|
||||
}
|
||||
|
||||
|
@ -95,7 +108,8 @@ export class LibericaDistributions extends JavaBase {
|
|||
...this.getArchitectureOptions(),
|
||||
'build-type': this.stable ? 'all' : 'ea',
|
||||
'installation-type': 'archive',
|
||||
fields: 'downloadUrl,version,featureVersion,interimVersion,updateVersion,buildVersion'
|
||||
fields:
|
||||
'downloadUrl,version,featureVersion,interimVersion,updateVersion,buildVersion'
|
||||
};
|
||||
|
||||
const searchParams = new URLSearchParams(urlOptions).toString();
|
||||
|
@ -115,15 +129,15 @@ export class LibericaDistributions extends JavaBase {
|
|||
const arch = this.distributionArchitecture();
|
||||
switch (arch) {
|
||||
case 'x86':
|
||||
return { bitness: '32', arch: 'x86' };
|
||||
return {bitness: '32', arch: 'x86'};
|
||||
case 'x64':
|
||||
return { bitness: '64', arch: 'x86' };
|
||||
return {bitness: '64', arch: 'x86'};
|
||||
case 'armv7':
|
||||
return { bitness: '32', arch: 'arm' };
|
||||
return {bitness: '32', arch: 'arm'};
|
||||
case 'aarch64':
|
||||
return { bitness: '64', arch: 'arm' };
|
||||
return {bitness: '64', arch: 'arm'};
|
||||
case 'ppc64le':
|
||||
return { bitness: '64', arch: 'ppc' };
|
||||
return {bitness: '64', arch: 'ppc'};
|
||||
default:
|
||||
throw new Error(
|
||||
`Architecture '${this.architecture}' is not supported. Supported architectures: ${supportedArchitectures}`
|
||||
|
@ -131,7 +145,9 @@ export class LibericaDistributions extends JavaBase {
|
|||
}
|
||||
}
|
||||
|
||||
private getPlatformOption(platform: NodeJS.Platform = process.platform): OsVersions {
|
||||
private getPlatformOption(
|
||||
platform: NodeJS.Platform = process.platform
|
||||
): OsVersions {
|
||||
switch (platform) {
|
||||
case 'darwin':
|
||||
return 'macos';
|
||||
|
@ -150,8 +166,11 @@ export class LibericaDistributions extends JavaBase {
|
|||
}
|
||||
|
||||
private convertVersionToSemver(version: LibericaVersion): string {
|
||||
let { buildVersion, featureVersion, interimVersion, updateVersion } = version;
|
||||
const mainVersion = [featureVersion, interimVersion, updateVersion].join('.');
|
||||
const {buildVersion, featureVersion, interimVersion, updateVersion} =
|
||||
version;
|
||||
const mainVersion = [featureVersion, interimVersion, updateVersion].join(
|
||||
'.'
|
||||
);
|
||||
if (buildVersion != 0) {
|
||||
return `${mainVersion}+${buildVersion}`;
|
||||
}
|
||||
|
@ -159,7 +178,7 @@ export class LibericaDistributions extends JavaBase {
|
|||
}
|
||||
|
||||
protected distributionArchitecture(): string {
|
||||
let arch = super.distributionArchitecture();
|
||||
const arch = super.distributionArchitecture();
|
||||
switch (arch) {
|
||||
case 'arm':
|
||||
return 'armv7';
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue