Skip to content

use device-model and device-os fields for ios #2418

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 10, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 16 additions & 35 deletions maestro-cli/src/main/java/maestro/cli/cloud/CloudInteractor.kt
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,8 @@ class CloudInteractor(
val project = requireNotNull(projectId)
val appId = response.appId
val uploadUrl = uploadUrl(project, appId, response.uploadId, client.domain)
val deviceMessage = if (response.deviceConfiguration != null) printDeviceInfo(response.deviceConfiguration) else ""
val deviceMessage =
if (response.deviceConfiguration != null) printDeviceInfo(response.deviceConfiguration) else ""
return printMaestroCloudResponse(
async,
authToken,
Expand All @@ -143,10 +144,10 @@ class CloudInteractor(
}

private fun getAppFile(
appFile: File?,
appBinaryId: String?,
tmpDir: Path,
flowFile: File
appFile: File?,
appBinaryId: String?,
tmpDir: Path,
flowFile: File
): File? {
when {
appBinaryId != null -> return null
Expand Down Expand Up @@ -220,41 +221,21 @@ class CloudInteractor(
}
}

private fun printDeviceInfo(deviceInfo: DeviceInfo, iOSVersion: String?, androidApiLevel: Int?): String {

val platform = Platform.fromString(deviceInfo.platform)

val line1 = "Maestro Cloud device specs:\n* ${deviceInfo.displayInfo} - ${deviceInfo.deviceLocale}"
val line2 =
"To change OS version use this option: ${if (platform == Platform.IOS) "--ios-version=<version>" else "--android-api-level=<version>"}"
val line3 = "To change device locale use this option: --device-locale=<device_locale>"

val version = when (platform) {
Platform.ANDROID -> "${androidApiLevel ?: 30}" // todo change with constant from DeviceConfigAndroid
Platform.IOS -> "${iOSVersion ?: 15}" // todo change with constant from DeviceConfigIos
else -> return ""
}

val line4 = "To create a similar device locally, run: `maestro start-device --platform=${
platform.toString().lowercase()
} --os-version=$version --device-locale=${deviceInfo.deviceLocale}`"
return "$line1\n\n$line2\n\n$line3\n\n$line4".box()
}

private fun printDeviceInfo(deviceConfiguration: DeviceConfiguration): String {
val platform = Platform.fromString(deviceConfiguration.platform)

val line1 = "Robin device specs:\n* ${deviceConfiguration.displayInfo} - ${deviceConfiguration.deviceLocale}"
val line2 =
"To change OS version use this option: ${if (platform == Platform.IOS) "--ios-version=<version>" else "--android-api-level=<version>"}"
val line3 = "To change device locale use this option: --device-locale=<device_locale>"

val version = deviceConfiguration.osVersion
val lines = listOf(
"Maestro cloud device specs:\n* ${deviceConfiguration.displayInfo} - ${deviceConfiguration.deviceLocale}",
"To change OS version use this option: ${if (platform == Platform.IOS) "--device-os=<version>" else "--android-api-level=<version>"}",
"To change devices use this option: --device-model=<device_model>",
"To change device locale use this option: --device-locale=<device_locale>",
"To create a similar device locally, run: `maestro start-device --platform=${
platform.toString().lowercase()
} --os-version=$version --device-locale=${deviceConfiguration.deviceLocale}`"
)

val line4 = "To create a similar device locally, run: `maestro start-device --platform=${
platform.toString().lowercase()
} --os-version=$version --device-locale=${deviceConfiguration.deviceLocale}`"
return "$line1\n\n$line2\n\n$line3\n\n$line4".box()
return lines.joinToString("\n\n").box()
}


Expand Down
6 changes: 3 additions & 3 deletions maestro-cli/src/main/java/maestro/cli/command/CloudCommand.kt
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ class CloudCommand : Callable<Int> {
)
private var output: File? = null

@Option(order = 17, names = ["--ios-version"], description = ["iOS version to run your flow against"])
@Option(order = 17, names = ["--ios-version"], description = ["iOS version to run your flow against. Please use --device-os instead"])
private var iOSVersion: String? = null

@Option(order = 18, names = ["--app-binary-id", "--appBinaryId"], description = ["The ID of the app binary previously uploaded to Maestro Cloud"])
Expand All @@ -153,10 +153,10 @@ class CloudCommand : Callable<Int> {
@Option(order = 19, names = ["--device-locale"], description = ["Locale that will be set to a device, ISO-639-1 code and uppercase ISO-3166-1 code i.e. \"de_DE\" for Germany"])
private var deviceLocale: String? = null

@Option(order = 20, names = ["--device-model"], description = ["Device model to run your flow against [closed beta]"])
@Option(order = 20, names = ["--device-model"], description = ["Device model to run your flow against. Supported values include iPhone-11, etc. Only supported for iOS at the moment."])
private var deviceModel: String? = null

@Option(order = 21, names = ["--device-os"], description = ["OS version to run your flow against [closed beta]"])
@Option(order = 21, names = ["--device-os"], description = ["OS version to run your flow against. Supported values include iOS-16-4, iOS-17-5, iOS-18-2, etc. Only supported for iOS at the moment."])
private var deviceOs: String? = null

@Option(hidden = true, names = ["--fail-on-cancellation"], description = ["Fail the command if the upload is marked as cancelled"])
Expand Down
Loading