-
-
Notifications
You must be signed in to change notification settings - Fork 75
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
cd59a62
commit bb153f4
Showing
5 changed files
with
71 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
import { doctor } from 'appium-android-driver'; | ||
|
||
export const optionalBundletoolCheck = doctor.optionalBundletoolCheck; | ||
export const optionalFfmpegCheck = doctor.optionalFfmpegCheck; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
import { doctor as doctorCommon } from 'appium-android-driver'; | ||
import { exec } from 'teen_process'; | ||
import { fs, system, doctor } from '@appium/support'; | ||
import path from 'node:path'; | ||
|
||
export const androidHomeCheck = doctorCommon.androidHomeCheck; | ||
export const javaHomeCheck = doctorCommon.javaHomeCheck; | ||
export const javaHomeValueCheck = doctorCommon.javaHomeValueCheck; | ||
export const androidSdkCheck = doctorCommon.androidSdkCheck; | ||
|
||
/** @satisfies {import('@appium/types').IDoctorCheck} */ | ||
export class JavaVersionCheck { | ||
MIN_JAVA_VERSION = 11; | ||
JAVA_VERSION_PATTERN = /^\s*java\.version\s*=\s*([\d.]+)/m; | ||
|
||
async diagnose() { | ||
const javaHome = process.env.JAVA_HOME; | ||
const fullJavaPath = path.join(javaHome ?? '', 'bin', `java${system.isWindows() ? '.exe' : ''}`); | ||
if (!javaHome || !await fs.exists(fullJavaPath)) { | ||
return doctor.nok(`Cannot retrieve Java version. Is Java installed and JAVA_HOME set to a proper path?`); | ||
} | ||
let javaVerMatch; | ||
try { | ||
const {stderr} = await exec(fullJavaPath, ['-XshowSettings:properties', '-version']); | ||
javaVerMatch = this.JAVA_VERSION_PATTERN.exec(stderr); | ||
} catch (e) { | ||
return doctor.nok(`Cannot retrieve Java version: ${e.stderr || e.message}`); | ||
} | ||
if (!javaVerMatch) { | ||
return doctor.nok(`The actual Java version cannot be retrieved`); | ||
} | ||
const majorVer = parseInt(javaVerMatch[1], 10); | ||
return majorVer < this.MIN_JAVA_VERSION | ||
? doctor.nok(`The active Java version ${javaVerMatch[1]} is older than the required one`) | ||
: doctor.ok(`The active Java version matches (${majorVer} >= ${this.MIN_JAVA_VERSION})`); | ||
} | ||
|
||
async fix() { | ||
return `Upgrade to Java ${this.MIN_JAVA_VERSION}+ or update ` + | ||
`the JAVA_HOME environment variable if it is already instsalled`; | ||
} | ||
|
||
hasAutofix() { | ||
return false; | ||
} | ||
|
||
isOptional() { | ||
return false; | ||
} | ||
} | ||
export const javaVersionCheck = new JavaVersionCheck(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters