开源 企业版 高校版 私有云 模力方舟 AI 队友
代码拉取完成,页面将自动刷新
捐赠
捐赠前请先登录
扫描微信二维码支付
取消
支付完成
支付提示
将跳转至支付宝完成支付
确定
取消
1 Star 0 Fork 1

碳猫科技/react-native-code-push

加入 Gitee
与超过 1400万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
已有帐号? 立即登录
文件
master
分支 (3)
标签 (75)
master
brownfield-apps-dev
brownfield-apps-archive
v5.4.2
v5.4.1
v5.4.0
v5.3.5
v5.3.4
v5.3.3
v5.3.2
v5.3.1
v5.3.0
v5.2.2
v5.2.1
v5.2.0-beta
v5.1.3-beta
v5.1.2-beta
v5.1.1-beta
v5.1.0-beta
v5.0.0-beta
v4.1.0-beta
v4.0.0-beta
v3.0.1-beta
master
分支 (3)
标签 (75)
master
brownfield-apps-dev
brownfield-apps-archive
v5.4.2
v5.4.1
v5.4.0
v5.3.5
v5.3.4
v5.3.3
v5.3.2
v5.3.1
v5.3.0
v5.2.2
v5.2.1
v5.2.0-beta
v5.1.3-beta
v5.1.2-beta
v5.1.1-beta
v5.1.0-beta
v5.0.0-beta
v4.1.0-beta
v4.0.0-beta
v3.0.1-beta
克隆/下载
克隆/下载
提示
下载代码请复制以下命令到终端执行
为确保你提交的代码身份被 Gitee 正确识别,请执行以下命令完成配置
初次使用 SSH 协议进行代码克隆、推送等操作时,需按下述提示完成 SSH 配置
1 生成 RSA 密钥
2 获取 RSA 公钥内容,并配置到 SSH公钥
在 Gitee 上使用 SVN,请访问 使用指南
使用 HTTPS 协议时,命令行会出现如下账号密码验证步骤。基于安全考虑,Gitee 建议 配置并使用私人令牌 替代登录密码进行克隆、推送等操作
Username for 'https://gitee.com': userName
Password for 'https://userName@gitee.com': # 私人令牌
master
分支 (3)
标签 (75)
master
brownfield-apps-dev
brownfield-apps-archive
v5.4.2
v5.4.1
v5.4.0
v5.3.5
v5.3.4
v5.3.3
v5.3.2
v5.3.1
v5.3.0
v5.2.2
v5.2.1
v5.2.0-beta
v5.1.3-beta
v5.1.2-beta
v5.1.1-beta
v5.1.0-beta
v5.0.0-beta
v4.1.0-beta
v4.0.0-beta
v3.0.1-beta
platform.js 16.82 KB
一键复制 编辑 原始数据 按行查看 历史
scottbommarito 提交于 2016年06月16日 07:55 +08:00 . fixes to make npm load it automatically
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391
"use strict";
var Q = require("q");
var testUtil_1 = require("./testUtil");
//////////////////////////////////////////////////////////////////////////////////////////
// PLATFORMS
/**
* Android implementations of IPlatform.
*/
var Android = (function () {
function Android(emulatorManager) {
this.emulatorManager = emulatorManager;
}
/**
* Gets the platform name. (e.g. "android" for the Android platform).
*/
Android.prototype.getName = function () {
return "android";
};
/**
* The command line flag used to determine whether or not this platform should run.
* Runs when the flag is present, doesn't run otherwise.
*/
Android.prototype.getCommandLineFlagName = function () {
return "--android";
};
/**
* Gets the server url used for testing.
*/
Android.prototype.getServerUrl = function () {
if (!this.serverUrl)
this.serverUrl = testUtil_1.TestUtil.readMochaCommandLineOption(Android.ANDROID_SERVER_URL_OPTION_NAME, Android.DEFAULT_ANDROID_SERVER_URL);
return this.serverUrl;
};
/**
* Gets an IEmulatorManager that is used to control the emulator during the tests.
*/
Android.prototype.getEmulatorManager = function () {
return this.emulatorManager;
};
/**
* Gets the default deployment key.
*/
Android.prototype.getDefaultDeploymentKey = function () {
return "mock-android-deployment-key";
};
Android.ANDROID_SERVER_URL_OPTION_NAME = "--androidserver";
Android.DEFAULT_ANDROID_SERVER_URL = "http://10.0.2.2:3001";
return Android;
}());
exports.Android = Android;
/**
* IOS implementation of IPlatform.
*/
var IOS = (function () {
function IOS(emulatorManager) {
this.emulatorManager = emulatorManager;
}
/**
* Gets the platform name. (e.g. "android" for the Android platform).
*/
IOS.prototype.getName = function () {
return "ios";
};
/**
* The command line flag used to determine whether or not this platform should run.
* Runs when the flag is present, doesn't run otherwise.
*/
IOS.prototype.getCommandLineFlagName = function () {
return "--ios";
};
/**
* Gets the server url used for testing.
*/
IOS.prototype.getServerUrl = function () {
if (!this.serverUrl)
this.serverUrl = testUtil_1.TestUtil.readMochaCommandLineOption(IOS.IOS_SERVER_URL_OPTION_NAME, IOS.DEFAULT_IOS_SERVER_URL);
return this.serverUrl;
};
/**
* Gets an IEmulatorManager that is used to control the emulator during the tests.
*/
IOS.prototype.getEmulatorManager = function () {
return this.emulatorManager;
};
/**
* Gets the default deployment key.
*/
IOS.prototype.getDefaultDeploymentKey = function () {
return "mock-ios-deployment-key";
};
IOS.IOS_SERVER_URL_OPTION_NAME = "--iosserver";
IOS.DEFAULT_IOS_SERVER_URL = "http://127.0.0.1:3000";
return IOS;
}());
exports.IOS = IOS;
//////////////////////////////////////////////////////////////////////////////////////////
// EMULATOR MANAGERS
// bootEmulatorInternal constants
var emulatorMaxReadyAttempts = 5;
var emulatorReadyCheckDelayMs = 30 * 1000;
/**
* Helper function for EmulatorManager implementations to use to boot an emulator with a given platformName and check, start, and kill methods.
*/
function bootEmulatorInternal(platformName, restartEmulators, targetEmulator, checkEmulator, startEmulator, killEmulator) {
var deferred = Q.defer();
console.log("Setting up " + platformName + " emulator.");
function onEmulatorReady() {
console.log(platformName + " emulator is ready!");
deferred.resolve(undefined);
return deferred.promise;
}
// Called to check if the emulator for the platform is initialized.
function checkEmulatorReady() {
var checkDeferred = Q.defer();
console.log("Checking if " + platformName + " emulator is ready yet...");
// Dummy command that succeeds if emulator is ready and fails otherwise.
checkEmulator()
.then(function () {
checkDeferred.resolve(undefined);
}, function (error) {
console.log(platformName + " emulator is not ready yet!");
checkDeferred.reject(error);
});
return checkDeferred.promise;
}
var emulatorReadyAttempts = 0;
// Loops checks to see if the emulator is ready and eventually fails after surpassing emulatorMaxReadyAttempts.
function checkEmulatorReadyLooper() {
var looperDeferred = Q.defer();
emulatorReadyAttempts++;
if (emulatorReadyAttempts > emulatorMaxReadyAttempts) {
console.log(platformName + " emulator is not ready after " + emulatorMaxReadyAttempts + " attempts, abort.");
deferred.reject(platformName + " emulator failed to boot.");
looperDeferred.resolve(undefined);
}
setTimeout(function () {
checkEmulatorReady()
.then(function () {
looperDeferred.resolve(undefined);
onEmulatorReady();
}, function () {
return checkEmulatorReadyLooper().then(function () { looperDeferred.resolve(undefined); }, function () { looperDeferred.reject(undefined); });
});
}, emulatorReadyCheckDelayMs);
return looperDeferred.promise;
}
// Starts and loops the emulator.
function startEmulatorAndLoop() {
console.log("Booting " + platformName + " emulator named " + targetEmulator + ".");
startEmulator(targetEmulator).catch(function (error) { console.log(error); deferred.reject(error); });
return checkEmulatorReadyLooper();
}
var promise;
if (restartEmulators) {
console.log("Killing " + platformName + " emulator.");
promise = killEmulator().catch(function () { return null; }).then(startEmulatorAndLoop);
}
else {
promise = checkEmulatorReady().then(onEmulatorReady, startEmulatorAndLoop);
}
return deferred.promise;
}
var AndroidEmulatorManager = (function () {
function AndroidEmulatorManager() {
}
/**
* Returns the target emulator, which is specified through the command line.
*/
AndroidEmulatorManager.prototype.getTargetEmulator = function () {
if (this.targetEmulator)
return Q(this.targetEmulator);
else {
this.targetEmulator = testUtil_1.TestUtil.readMochaCommandLineOption(AndroidEmulatorManager.ANDROID_EMULATOR_OPTION_NAME, AndroidEmulatorManager.DEFAULT_ANDROID_EMULATOR);
console.log("Using Android emulator named " + this.targetEmulator);
return Q(this.targetEmulator);
}
};
/**
* Boots the target emulator.
*/
AndroidEmulatorManager.prototype.bootEmulator = function (restartEmulators) {
function checkAndroidEmulator() {
// A command that does nothing but only succeeds if the emulator is running.
// List all of the packages on the device.
return testUtil_1.TestUtil.getProcessOutput("adb shell pm list packages", { noLogCommand: true, noLogStdOut: true, noLogStdErr: true }).then(function () { return null; });
}
function startAndroidEmulator(androidEmulatorName) {
return testUtil_1.TestUtil.getProcessOutput("emulator @" + androidEmulatorName).then(function () { return null; });
}
function killAndroidEmulator() {
return testUtil_1.TestUtil.getProcessOutput("adb emu kill").then(function () { return null; });
}
return this.getTargetEmulator()
.then(function (targetEmulator) {
return bootEmulatorInternal("Android", restartEmulators, targetEmulator, checkAndroidEmulator, startAndroidEmulator, killAndroidEmulator);
});
};
/**
* Launches an already installed application by app id.
*/
AndroidEmulatorManager.prototype.launchInstalledApplication = function (appId) {
return testUtil_1.TestUtil.getProcessOutput("adb shell monkey -p " + appId + " -c android.intent.category.LAUNCHER 1").then(function () { return null; });
};
/**
* Ends a running application given its app id.
*/
AndroidEmulatorManager.prototype.endRunningApplication = function (appId) {
return testUtil_1.TestUtil.getProcessOutput("adb shell am force-stop " + appId).then(function () { return null; });
};
/**
* Restarts an already installed application by app id.
*/
AndroidEmulatorManager.prototype.restartApplication = function (appId) {
var _this = this;
return this.endRunningApplication(appId)
.then(function () {
// Wait for a second before restarting.
return Q.delay(1000);
})
.then(function () {
return _this.launchInstalledApplication(appId);
});
};
/**
* Navigates away from the current app, waits for a delay (defaults to 1 second), then navigates to the specified app.
*/
AndroidEmulatorManager.prototype.resumeApplication = function (appId, delayBeforeResumingMs) {
var _this = this;
if (delayBeforeResumingMs === void 0) { delayBeforeResumingMs = 1000; }
// Open a default Android app (for example, settings).
return this.launchInstalledApplication("com.android.settings")
.then(function () {
console.log("Waiting for " + delayBeforeResumingMs + "ms before resuming the test application.");
return Q.delay(delayBeforeResumingMs);
})
.then(function () {
// Reopen the app.
return _this.launchInstalledApplication(appId);
});
};
/**
* Prepares the emulator for a test.
*/
AndroidEmulatorManager.prototype.prepareEmulatorForTest = function (appId) {
return this.endRunningApplication(appId)
.then(function () { return testUtil_1.TestUtil.getProcessOutput("adb shell pm clear " + appId); }).then(function () { return null; });
};
/**
* Uninstalls the app from the emulator.
*/
AndroidEmulatorManager.prototype.uninstallApplication = function (appId) {
return testUtil_1.TestUtil.getProcessOutput("adb uninstall " + appId).then(function () { return null; });
};
AndroidEmulatorManager.ANDROID_EMULATOR_OPTION_NAME = "--androidemu";
AndroidEmulatorManager.DEFAULT_ANDROID_EMULATOR = "emulator";
return AndroidEmulatorManager;
}());
exports.AndroidEmulatorManager = AndroidEmulatorManager;
var IOSEmulatorManager = (function () {
function IOSEmulatorManager() {
}
/**
* Returns the target emulator, which is specified through the command line.
*/
IOSEmulatorManager.prototype.getTargetEmulator = function () {
var _this = this;
if (this.targetEmulator)
return Q(this.targetEmulator);
else {
var deferred = Q.defer();
var targetIOSEmulator = testUtil_1.TestUtil.readMochaCommandLineOption(IOSEmulatorManager.IOS_EMULATOR_OPTION_NAME);
if (!targetIOSEmulator) {
// If no iOS simulator is specified, get the most recent iOS simulator to run tests on.
testUtil_1.TestUtil.getProcessOutput("xcrun simctl list", { noLogCommand: true, noLogStdOut: true, noLogStdErr: true })
.then(function (listOfDevicesWithDevicePairs) {
var listOfDevices = listOfDevicesWithDevicePairs.slice(listOfDevicesWithDevicePairs.indexOf("-- iOS"), listOfDevicesWithDevicePairs.indexOf("-- tvOS"));
var phoneDevice = /iPhone (\S* )*(\(([0-9A-Z-]*)\))/g;
var match = listOfDevices.match(phoneDevice);
deferred.resolve(match[match.length - 1]);
}, function (error) {
deferred.reject(error);
});
}
else {
// Use the simulator specified on the command line.
deferred.resolve(targetIOSEmulator);
}
return deferred.promise
.then(function (targetEmulator) {
_this.targetEmulator = targetEmulator;
console.log("Using iOS simulator named " + _this.targetEmulator);
return _this.targetEmulator;
});
}
};
/**
* Boots the target emulator.
*/
IOSEmulatorManager.prototype.bootEmulator = function (restartEmulators) {
function checkIOSEmulator() {
// A command that does nothing but only succeeds if the emulator is running.
// Get the environment variable with the name "asdf" (return null, not an error, if not initialized).
return testUtil_1.TestUtil.getProcessOutput("xcrun simctl getenv booted asdf", { noLogCommand: true, noLogStdOut: true, noLogStdErr: true }).then(function () { return null; });
}
function startIOSEmulator(iOSEmulatorName) {
return testUtil_1.TestUtil.getProcessOutput("xcrun instruments -w \"" + iOSEmulatorName + "\"", { noLogStdErr: true })
.catch(function (error) { return undefined; /* Always fails because we do not specify a template, which is not necessary to just start the emulator */ }).then(function () { return null; });
}
function killIOSEmulator() {
return testUtil_1.TestUtil.getProcessOutput("killall Simulator").then(function () { return null; });
}
return this.getTargetEmulator()
.then(function (targetEmulator) {
return bootEmulatorInternal("iOS", restartEmulators, targetEmulator, checkIOSEmulator, startIOSEmulator, killIOSEmulator);
});
};
/**
* Launches an already installed application by app id.
*/
IOSEmulatorManager.prototype.launchInstalledApplication = function (appId) {
return testUtil_1.TestUtil.getProcessOutput("xcrun simctl launch booted " + appId, undefined).then(function () { return null; });
};
/**
* Ends a running application given its app id.
*/
IOSEmulatorManager.prototype.endRunningApplication = function (appId) {
return testUtil_1.TestUtil.getProcessOutput("xcrun simctl spawn booted launchctl list", { noLogCommand: true, noLogStdOut: true, noLogStdErr: true })
.then(function (processListOutput) {
// Find the app's process.
var regex = new RegExp("(\\S+" + appId + "\\S+)");
var execResult = regex.exec(processListOutput);
if (execResult) {
return execResult[0];
}
else {
return Q.reject("Could not get the running application label.");
}
})
.then(function (applicationLabel) {
// Kill the app if we found the process.
return testUtil_1.TestUtil.getProcessOutput("xcrun simctl spawn booted launchctl stop " + applicationLabel, undefined).then(function () { return null; });
}, function (error) {
// We couldn't find the app's process so it must not be running.
return Q.resolve(error);
});
};
/**
* Restarts an already installed application by app id.
*/
IOSEmulatorManager.prototype.restartApplication = function (appId) {
var _this = this;
return this.endRunningApplication(appId)
.then(function () {
// Wait for a second before restarting.
return Q.delay(1000);
})
.then(function () { return _this.launchInstalledApplication(appId); });
};
/**
* Navigates away from the current app, waits for a delay (defaults to 1 second), then navigates to the specified app.
*/
IOSEmulatorManager.prototype.resumeApplication = function (appId, delayBeforeResumingMs) {
var _this = this;
if (delayBeforeResumingMs === void 0) { delayBeforeResumingMs = 1000; }
// Open a default iOS app (for example, camera).
return this.launchInstalledApplication("com.apple.camera")
.then(function () {
console.log("Waiting for " + delayBeforeResumingMs + "ms before resuming the test application.");
return Q.delay(delayBeforeResumingMs);
})
.then(function () {
// Reopen the app.
return _this.launchInstalledApplication(appId);
});
};
/**
* Prepares the emulator for a test.
*/
IOSEmulatorManager.prototype.prepareEmulatorForTest = function (appId) {
return this.endRunningApplication(appId);
};
/**
* Uninstalls the app from the emulator.
*/
IOSEmulatorManager.prototype.uninstallApplication = function (appId) {
return testUtil_1.TestUtil.getProcessOutput("xcrun simctl uninstall booted " + appId).then(function () { return null; });
};
IOSEmulatorManager.IOS_EMULATOR_OPTION_NAME = "--iosemu";
return IOSEmulatorManager;
}());
exports.IOSEmulatorManager = IOSEmulatorManager;
Loading...
举报
举报成功
我们将于2个工作日内通过站内信反馈结果给你!
请认真填写举报原因,尽可能描述详细。
请选择举报类型
取消
发送
误判申诉

此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。

如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。

取消
提交

简介

取消

发行版

暂无发行版

贡献者

全部

近期动态

不能加载更多了
编辑仓库简介
简介内容
主页
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Objective-C
1
https://gitee.com/hackcat/react-native-code-push.git
git@gitee.com:hackcat/react-native-code-push.git
hackcat
react-native-code-push
react-native-code-push
master
点此查找更多帮助

搜索帮助

评论
仓库举报
回到顶部
登录提示
该操作需登录 Gitee 帐号,请先登录后再操作。
立即登录
没有帐号,去注册

AltStyle によって変換されたページ (->オリジナル) /