@@ -3,7 +3,8 @@ const hx = require('hbuilderx');
33let config = require ( './config.js' ) ;
44const {
55 createOutputChannel,
6- getPluginConfig
6+ getPluginConfig,
7+ get_ios_device_type
78} = require ( './core.js' ) ;
89
910const {
@@ -53,16 +54,20 @@ function loadEnvConfig(envJsPath) {
5354 * @param {Object } envjs - env.js配置对象
5455 * @returns {Promise<String> } 启动器路径
5556 */
56- async function getLauncherPath ( testPlatform , isUniappX , isVapor , envjs ) {
57+ async function getLauncherPath ( testPlatform , isUniappX , isVapor , envjs , test_device_type = "" ) {
58+ // console.error("[test_device_type] = ", test_device_type);
59+ const isIOSRealDevice = testPlatform === PLATFORM . IOS && test_device_type === "真机" ;
60+
5761 const launcherConfig = {
5862 [ PLATFORM . ANDROID ] : {
5963 uniappX : isVapor ? config . UNIAPP_X_VAPOR_LAUNCHER_ANDROID : config . UNIAPP_X_LAUNCHER_ANDROID ,
6064 normal : config . LAUNCHER_ANDROID
6165 } ,
62- // ios真机、模拟器,所需的文件不一样。由于uni-app测试框架不支持ios真机。这里暂不区分。
6366 [ PLATFORM . IOS ] : {
64- uniappX : isVapor ? config . UNIAPP_X_VAPOR_LAUNCHER_IOS : config . UNIAPP_X_LAUNCHER_IOS ,
65- normal : config . LAUNCHER_IOS
67+ uniappX : isIOSRealDevice
68+ ? ( isVapor ? config . UNIAPP_X_VAPOR_LAUNCHER_IOS_IPA : config . UNIAPP_X_LAUNCHER_IOS_IPA )
69+ : ( isVapor ? config . UNIAPP_X_VAPOR_LAUNCHER_IOS : config . UNIAPP_X_LAUNCHER_IOS ) ,
70+ normal : isIOSRealDevice ? config . LAUNCHER_IOS_IPA : config . LAUNCHER_IOS
6671 }
6772 } ;
6873
@@ -127,13 +132,13 @@ function getPlatformConfigNode(envjs, isUniappX) {
127132function updateVersionInfo ( envjs , isUniappX , isVapor ) {
128133 if ( ! envjs [ 'app-plus' ] ) {
129134 envjs [ 'app-plus' ] = { } ;
130- } ;
131- let versionTxtFile = config . LAUNCHER_VERSION_TXT ;
132- if ( isUniappX ) {
133- versionTxtFile = config . UNIAPP_X_LAUNCHER_VERSION_TXT ;
134- } ;
135- if ( isVapor ) {
136- versionTxtFile = config . UNIAPP_X_VAPOR_LAUNCHER_VERSION_TXT ;
135+ } ;
136+ let versionTxtFile = config . LAUNCHER_VERSION_TXT ;
137+ if ( isUniappX ) {
138+ versionTxtFile = config . UNIAPP_X_LAUNCHER_VERSION_TXT ;
139+ } ;
140+ if ( isVapor ) {
141+ versionTxtFile = config . UNIAPP_X_VAPOR_LAUNCHER_VERSION_TXT ;
137142 } ;
138143 if ( isUniappX ) {
139144 const oldVersionTxtFile = envjs [ 'app-plus' ] ?. [ 'uni-app-x' ] ?. version ;
@@ -221,7 +226,8 @@ async function handleWeixinPlatform(envjs, envJsPath, logger) {
221226 return false ;
222227 }
223228 return true ;
224- }
229+ } ;
230+
225231
226232/**
227233 * @description 修改测试配置文件env.js, ios和android测试需要在env.js指定设备ID
@@ -235,17 +241,22 @@ async function handleWeixinPlatform(envjs, envJsPath, logger) {
235241 * @returns {Promise<Boolean> } - 修改成功返回true,失败返回false
236242 */
237243async function editEnvjsFile ( envJsPath = "" , testPlatform = "" , deviceId = "" , uniProjectAttributeData = { } , terminalId ) {
238- const {
239- is_uniapp_x : isUniappX ,
240- is_uniapp_x_vapor : isVapor
241- } = uniProjectAttributeData ;
242- console . error ( "isVapor = " , isVapor ) ;
244+ const {
245+ is_uniapp_x : isUniappX ,
246+ is_uniapp_x_vapor : isVapor
247+ } = uniProjectAttributeData ;
248+ console . error ( "isVapor = " , isVapor ) ;
243249
244250 const logger = createLogger ( terminalId ) ;
245-
246251 if ( terminalId ) {
247252 await logger ( `[uniapp.test] 修改测试配置文件: ${ envJsPath } ` ) ;
248- }
253+ } ;
254+
255+ // 设备类型 模拟器、真机。目前只有ios平台需要
256+ let test_device_type = "" ;
257+ if ( testPlatform == "ios" ) {
258+ test_device_type = await get_ios_device_type ( deviceId ) ;
259+ } ;
249260
250261 let envJsFileData = loadEnvConfig ( envJsPath ) ;
251262 if ( ! envJsFileData ) {
@@ -263,7 +274,7 @@ async function editEnvjsFile(envJsPath = "", testPlatform = "", deviceId = "", u
263274 return await handleWeixinPlatform ( envJsFileData , envJsPath , logger ) ;
264275 } ;
265276
266- const launcherPath = await getLauncherPath ( testPlatform , isUniappX , isVapor , envJsFileData ) ;
277+ const launcherPath = await getLauncherPath ( testPlatform , isUniappX , isVapor , envJsFileData , test_device_type ) ;
267278 console . log ( "[env.js]launcherPath = " , launcherPath )
268279 const isCustomRuntime = envJsFileData [ "is-custom-runtime" ] ;
269280
@@ -288,4 +299,7 @@ async function editEnvjsFile(envJsPath = "", testPlatform = "", deviceId = "", u
288299 return true ;
289300} ;
290301
291- module . exports = editEnvjsFile ;
302+ module . exports = {
303+ editEnvjsFile,
304+ loadEnvConfig
305+ } ;
0 commit comments