var titaniumPrepHook = this.cli.createHook('build.android.titaniumprep', this, function (exe, args, opts, done) {
			this.logger.info(__('Encrypting JavaScript files: %s', (exe + ' "' + args.slice(1).join('" "') + '"').cyan));
			appc.subprocess.run(exe, args, opts, function (code, out, err) {

				if (code) {
					return done({
						code: code,
						msg: err.trim()
					});
				}

				fs.existsSync(this.buildGenAssetJavaFile) && fs.unlinkSync(this.buildGenAssetJavaFile);

				// write the encrypted JS bytes to the generated Java file
				fs.writeFileSync(
					this.buildGenAssetJavaFile,
					ejs.render(fs.readFileSync(this.assetCryptImplTemplateFile).toString(), {
						appid: this.manifest.moduleid,
						encryptedAssets: out
					})
				);

				fs.writeFileSync(
					path.join(this.buildGenJavaDir, 'CommonJsSourceProvider.java'),
					ejs.render(fs.readFileSync(this.commonJsSourceTemplateFile).toString(), { moduleid: this.manifest.moduleid })
				);

				done();
			}.bind(this));
		}.bind(this)),
Esempio n. 2
0
			function powershell(next) {
				if (!results.os.version) return next();

				appc.subprocess.getRealName(path.resolve(__dirname, '..', 'bin', 'test_permissions.ps1'), function (err, psScript) {
					if (err) {
						return next(err);
					}

					appc.subprocess.run(options.powershell || 'powershell', [
						'-ExecutionPolicy', 'Bypass', '-NoLogo', '-NonInteractive', '-NoProfile', '-File', psScript
					], function (code, out, err) {
						if (!code && /success/i.test(out.trim().split('\n').shift())) {
							results.powershell.enabled = true;
						} else {
							results.powershell.enabled = false;
							results.issues.push({
								id: 'WINDOWS_POWERSHELL_SCRIPTS_DISABLED',
								type: 'error',
								message: __('Executing PowerShell scripts is disabled.') + '\n' +
									__('In order to build Windows Hybrid apps for the Windows Store (winstore), you must change the execution policy to allow PowerShell scripts.') + '\n' +
									__('To enable PowerShell scripts, search __PowerShell__ in the __Start__ menu, right click the icon, select __Run as administrator__, then run:') + '\n' +
									'    __Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser__'
							});
						}
						next();
					});
				});
			}
Esempio n. 3
0
			'devices': function (next) {
				if (selectedWindowsPhoneSDK && selectedWindowsPhoneSDK.xapDeployCmd) {
					appc.subprocess.run(selectedWindowsPhoneSDK.xapDeployCmd, '/EnumerateDevices', function (code, out, err) {
						var devices = null;

						if (err) {
							results.issues.push({
								id: 'WINDOWS_PHONE_ENUMERATE_DEVICES_FAILED',
								type: 'error',
								message: __('Failed to enumerate Windows Phone devices.') + '\n' +
									__('Ensure that the Windows Phone SDK is properly installed.')
							});
						} else {
							var deviceRegExp = /^ ([0-9]*)\t\t(.*)$/;
							devices = {};
							out.trim().split(/\r\n|\n/).forEach(function (line) {
								var m = line.match(deviceRegExp);
								if (m) {
									devices[m[1]] = m[2];
								}
							});
						}

						next(null, devices);
					});
				} else {
					next();
				}
			}
Esempio n. 4
0
		async.each(searchPaths, function (keyPath, next) {
			appc.subprocess.run('reg', ['query', keyPath], function (code, out, err) {
				var keyRegExp = /.+\\(v\d+\.\d)$/;
				if (!code) {
					out.trim().split(/\r\n|\n/).forEach(function (key) {
						key = key.trim();
						var m = key.match(keyRegExp),
							version = m[1].replace(/^v/, '');
						if (m) {
							results.windowsphone || (results.windowsphone = {});
							results.windowsphone[version] = {
								version: version,
								registryKey: keyPath + '\\' + m[1],
								supported: !options.supportedWindowsPhoneSDKVersions || appc.version.satisfies(version, options.supportedWindowsPhoneSDKVersions, false), // no maybes
								path: null,
								deployCmd: null,
								xapSignTool: null,
								selected: false
							};
						}
					});
				}
				next();
			});
		}, function () {
Esempio n. 5
0
		visualstudio.detect(options, function (err, results) {
			if (err) {
				emitter.emit('error', err);
				return callback(err);
			}

			var vsInfo = results.selectedVisualStudio,
				pvk = certPath + '.pvk',
				cer = certPath + '.cer',
				expirationDate = moment().add(2, 'years').format('L'),
				args = [];

			if (!vsInfo) {
				var ex = new Error(__('Unable to find a supported Visual Studio installation'));
				emitter.emit('error', ex);
				return callback(ex);
			}

			args = [
				'&&', options.makeCert || 'MakeCert',
				'-n', subjectName, '-r', '-h', '0', '-eku', '1.3.6.1.5.5.7.3.3,1.3.6.1.4.1.311.10.3.13',
				'-e', expirationDate, '-sv', pvk, cer
			];

			appc.subprocess.run(vsInfo.vcvarsall, args, function (code, out, err) {
				if (code) {
					var ex = new Error(__('Failed to create certificate (code %s)', code));
					emitter.emit('error', ex);
					return callback(ex);
				} else {
					emitter.emit('created', certPath + '.cer');
					callback(null, certPath + '.pvk', certPath + '.cer');
				}
			});
		});
						), function (err, psScript) {
							var installProcess,
								args = [ '-command', psScript + ' -Force' ];

							logger.info(__('Installing the app'));
							logger.debug(__('Running: %s', ('powershell.exe "' + args.join('" "') + '"').cyan));
							appc.subprocess.run('powershell.exe', args, function (code, out, err) {
								if (!code) {
									logger.debug(__('Finished deploying the application'));
									return next();
								}

								if (out.indexOf('Please rerun the script without the -Force parameter') == -1) {
									logger.error(__('There were errors deploying the application') + '\n');
									process.exit(1);
								}

								args = [ '-command', psScript ];
								logger.debug(__('Failed, trying again without -Force'));
								logger.debug(__('Running: %s', ('powershell.exe "' + args.join('" "') + '"').cyan));
								appc.subprocess.run('powershell.exe', args, function (code, out, err) {
									if (code) {
										logger.error(__('There were errors deploying the application') + '\n');
										process.exit(1);
									} else {
										logger.debug(__('Finished deploying the application'));
										next();
									}
								});
							});
						});
Esempio n. 7
0
		appc.subprocess.getRealName(path.resolve(__dirname, '..', 'bin', 'wp_emulator_enabledstate.ps1'), function (err, psScript) {
			if (err) {
				emitter.emit('error', err);
				return callback(err);
			}

			// next get hyper-v to think the emulator is not running
			appc.subprocess.run(options.powershell || 'powershell', [
				'-ExecutionPolicy', 'Bypass', '-NoLogo', '-NonInteractive', '-NoProfile',
				'-File',
				psScript,
				emuHandle.name
			], function (code, out, err) {
				try {
					if (!code) {
						var result = JSON.parse(out);
						if (result.success) {
							return callback(null, result.state);
						} else {
							return callback(result.message);
						}
					}
				} catch (e) {}
				callback(new Error('Failed to retrieve emulator status'));
			});
		});
Esempio n. 8
0
iOSModuleBuilder.prototype.verifyBuildArch = function verifyBuildArch(next) {
	const args = [ '-info', path.join(this.projectDir, 'build', 'lib' + this.moduleId + '.a') ];

	this.logger.info(__('Verifying universal library'));
	this.logger.debug(__('Running: %s', (this.xcodeEnv.executables.lipo + ' ' + args.join(' ')).cyan));

	appc.subprocess.run(this.xcodeEnv.executables.lipo, args, function (code, out, err) {
		if (code) {
			this.logger.error(__('Unable to determine the compiled module\'s architecture (code %s):', code));
			this.logger.error(err.trim() + '\n');
			process.exit(1);
		}

		const manifestArchs = this.manifest.architectures.split(' '),
			buildArchs    = out.substr(out.lastIndexOf(':') + 1).trim().split(' '),
			buildDiff     = manifestArchs.filter(function (i) { return buildArchs.indexOf(i) < 0; });

		if (buildArchs.length !== manifestArchs.length || buildDiff.length > 0) {
			this.logger.error(__('There is discrepancy between the architectures specified in module manifest and compiled binary.'));
			this.logger.error(__('Architectures in manifest: %s', manifestArchs.join(', ')));
			this.logger.error(__('Compiled binary architectures: %s', buildArchs.join(', ')));
			this.logger.error(__('Please update manifest to match module binary architectures.') + '\n');
			process.exit(1);
		}

		if (buildArchs.indexOf('arm64') === -1) {
			this.logger.warn(__('The module is missing 64-bit support.'));
		}

		next();
	}.bind(this));
};
Esempio n. 9
0
			androidDetect(this.config, function (err, results) {
				if (err) return callback(err);

				opts.logger && opts.logger.trace(__('Executing: %s', [results.sdk.executables.adb, '-s', deviceId, 'install', '-r', apkFile].join(' ').cyan));

				appc.subprocess.run(results.sdk.executables.adb, ['-s', deviceId, 'install', '-r', apkFile], function (code, out, err) {
					var m = out.match(/^Failure \[(.+)\]$/m);
					if ((code && err.indexOf('No space left on device') != -1) || (!code && m && m[1] == 'INSTALL_FAILED_INSUFFICIENT_STORAGE')) {
						callback(new Error(__('Not enough free space on device')));
					} else if (m && m[1] == 'INSTALL_PARSE_FAILED_INCONSISTENT_CERTIFICATES') {
						callback(__('The app is already installed, but signed with a different certificate') + '\n'
							+ __('You need to either manually uninstall the app or rebuild using the same certificate that was used to sign the installed app'));
					} else if (m) {
						callback(new Error(m[1]));
					} else if (code) {
						callback(new Error(out.trim() + '\n' + err.trim()));
					} else {
						// no obvious errors, now we need to check stdout
						m = out.match(/^Error: (.+)$/m);
						if (m) {
							callback(new Error(m[1]));
						} else {
							callback();
						}
					}
				});
			});
Esempio n. 10
0
	async.each(win10SearchPaths, function (keyPath, next) {
		appc.subprocess.run('reg', ['query', keyPath], function (code, out, err) {
			if (!code) {
				var version = '10.0';
				// get only the values we are interested in
				out.trim().split(/\r\n|\n/).forEach(function (line) {
					var parts = line.trim().split('   ').map(function (p) { return p.trim(); });
					if (parts.length == 3) {
						if (parts[0] == 'InstallationFolder') {
							results.windowsphone || (results.windowsphone = {});
							results.windowsphone[version] = {
								version: version,
								registryKey: keyPath,
								supported: !options.supportedWindowsPhoneSDKVersions || appc.version.satisfies(version, options.supportedWindowsPhoneSDKVersions, false), // no maybes
								path: parts[2],
								deployCmd: null,
								xapSignTool: null,
								selected: false
							};

							var deployCmd = path.join(parts[2], 'bin', 'x86', 'WinAppDeployCmd.exe'),
								signTool = path.join(parts[2], 'bin', 'x86', 'signtool.exe');
							if (fs.existsSync(deployCmd)) {
								results.windowsphone[version].deployCmd = deployCmd;
							}
							if (fs.existsSync(signTool)) {
								results.windowsphone[version].xapSignTool = signTool;
							}
						}
					}
				});
			}
			next();
		});
	}, function () {
Esempio n. 11
0
						appc.subprocess.getRealName(path.resolve(__dirname, '..', 'bin', 'wp_emulator_status.ps1'), function (err, script) {
							if (err) {
								emitter.emit('error', err);
								return callback(err);
							}

							appc.subprocess.run(options.powershell || 'powershell', [
								'-ExecutionPolicy', 'Bypass', '-NoLogo', '-NonInteractive', '-NoProfile',
								'-File',
								script
							], function (code, out, err) {
								if (code) {
									var err = new Error(__('Failed to detect running emulators'));
									emitter.emit('error', err);
									return callback(err);
								}

								var re = new RegExp('^' + emu.name + '\\..*(\\d+)(?:\\s+\\d+)$', 'i'),
									match = out.trim().split(/\r\n|\n/).map(function (line) {
										line = line.trim();
										return line && line.match(re);
									}).filter(function (m) { return !!m; }).shift(),
									running = match && ~~match[1] === 2 || false;

								emitter.emit('running', running);
								callback(null, running);
							});
						});
Esempio n. 12
0
iOSModuleBuilder.prototype.verifyBuildArch = function (next) {
	var outputFile = path.join(this.projectDir, 'build', 'lib' + this.manifest.moduleid + '.a'),
		lipoArgs = ['-info', outputFile];

	appc.subprocess.run(this.xcodeEnv.executables.lipo, lipoArgs, function (code, out, err) {
		var buildArchs = out.substr(out.lastIndexOf(':') + 1).trim().split(' '),
			manifestArchs = this.manifest.architectures.split(' '),
			buildDiff = manifestArchs.filter(function (i) { return buildArchs.indexOf(i) < 0; });

		if (buildArchs.length != manifestArchs.length || buildDiff.length > 0) {
			this.logger.error(__('There is discrepancy between the architectures specified in module manifest and compiled binary.'));
			this.logger.error(__('Architectures in manifest: %s', manifestArchs));
			this.logger.error(__('Compiled binary architectures: %s', buildArchs));
			this.logger.error(__('Please update manifest to match module binary architectures.'));

			process.exit(1);
		}

		if (buildArchs.indexOf('arm64') < 0) {
			this.logger.warn(__('The module is missing 64-bit support.'));
		}

		next();
	}.bind(this));
};
Esempio n. 13
0
			appc.subprocess.run(options.powershell || 'powershell', ['-ExecutionPolicy', 'Bypass', '-NoLogo', '-NoProfile', '-File', psScript, '-Force'], function (code, out, err) {
				if (!code) {
					emitter.emit('installed');
					return callback();
				}

				// I'm seeing "Please run this script without the -Force parameter" for Win 8.1 store apps.
				// This originally was "Please rerun the script without the -Force parameter" (for Win 8 hybrid apps?)
				// It's a hack to check for the common substring. Hopefully use of the exact error codes works better first
				// Error codes 9 and 14 mean rerun without -Force
				if ((code && (code == 9 || code == 14)) ||
					out.indexOf('script without the -Force parameter') !== -1) {
					appc.subprocess.run(options.powershell || 'powershell', ['-ExecutionPolicy', 'Bypass', '-NoLogo', '-NoProfile', '-File', psScript], function (code, out, err) {
						if (err) {
							emitter.emit('error', err);
							callback(err);
						} else {
							emitter.emit('installed');
							callback();
						}
					});
					return;
				}

				// must have been some other issue, error out
				var ex = new Error(__('Failed to install app: %s', out));
				emitter.emit('error', ex);
				callback(ex);
			});
Esempio n. 14
0
	return magik(options, callback, function (emitter, options, callback) {
		var scripts = [],
			packageScript = 'Add-AppDevPackage.ps1';

		// find the Add-AppDevPackage.ps1
		(function walk(dir) {
			fs.readdirSync(dir).forEach(function (name) {
				var file = path.join(dir, name);
				if (fs.statSync(file).isDirectory()) {
					walk(file);
				} else if (name === packageScript && (!options.buildConfiguration || path.basename(dir).indexOf('_' + options.buildConfiguration) !== -1)) {
					scripts.push(file);
				}
			});
		}(projectDir));

		if (!scripts.length) {
			var err = new Error(__('Unable to find built application. Please rebuild the project.'));
			emitter.emit('error', err);
			return callback(err);
		}

		// let's grab the first match
		appc.subprocess.getRealName(scripts[0], function (err, psScript) {
			if (err) {
				emitter.emit('error', err);
				return callback(err);
			}

			appc.subprocess.run(options.powershell || 'powershell', ['-ExecutionPolicy', 'Bypass', '-NoLogo', '-NoProfile', '-File', psScript, '-Force'], function (code, out, err) {
				if (!code) {
					emitter.emit('installed');
					return callback();
				}

				// I'm seeing "Please run this script without the -Force parameter" for Win 8.1 store apps.
				// This originally was "Please rerun the script without the -Force parameter" (for Win 8 hybrid apps?)
				// It's a hack to check for the common substring. Hopefully use of the exact error codes works better first
				// Error codes 9 and 14 mean rerun without -Force
				if ((code && (code == 9 || code == 14)) ||
					out.indexOf('script without the -Force parameter') !== -1) {
					appc.subprocess.run(options.powershell || 'powershell', ['-ExecutionPolicy', 'Bypass', '-NoLogo', '-NoProfile', '-File', psScript], function (code, out, err) {
						if (err) {
							emitter.emit('error', err);
							callback(err);
						} else {
							emitter.emit('installed');
							callback();
						}
					});
					return;
				}

				// must have been some other issue, error out
				var ex = new Error(__('Failed to install app: %s', out));
				emitter.emit('error', ex);
				callback(ex);
			});
		});
	});
Esempio n. 15
0
			async.each(Object.keys(results.windows), function (ver, next) {
				appc.subprocess.run('reg', ['query', results.windows[ver].registryKey, '/v', '*'], function (code, out, err) {
					if (code) {
						// bad key? either way, remove this version
						delete results.windows[ver];
					} else {
						// get only the values we are interested in
						out.trim().split(/\r\n|\n/).forEach(function (line) {
							var parts = line.trim().split('   ').map(function (p) { return p.trim(); });
							if (parts.length == 3) {
								if (parts[0] == 'InstallationFolder') {
									results.windows[ver].path = parts[2];

									function addIfExists(key, exe) {
										for (var i = 0; i < architectures.length; i++) {
											var arch = architectures[i],
												tool = path.join(parts[2], 'bin', arch, exe);
											if (fs.existsSync(tool)) {
												!results.windows[ver][key] && (results.windows[ver][key] = {});
												results.windows[ver][key][arch] = tool;
											}
										}
									}

									addIfExists('signTool', 'SignTool.exe');
									addIfExists('makeCert', 'MakeCert.exe');
									addIfExists('pvk2pfx', 'pvk2pfx.exe');
								}
							}
						});
					}
					next();
				});
			}, function () {
Esempio n. 16
0
			async.each(Object.keys(results.windowsphone), function (ver, next) {
				appc.subprocess.run('reg', ['query', results.windowsphone[ver].registryKey + '\\Install Path', '/v', '*'], function (code, out, err) {
					if (code) {
						// bad key? either way, remove this version
						delete results.windowsphone[ver];
					} else {
						// get only the values we are interested in
						out.trim().split(/\r\n|\n/).forEach(function (line) {
							var parts = line.trim().split('   ').map(function (p) { return p.trim(); });
							if (parts.length == 3) {
								if (parts[0] == 'Install Path') {
									results.windowsphone[ver].path = parts[2];

									var deployCmd = path.join(parts[2], 'Tools', 'XAP Deployment', 'XapDeployCmd.exe');
									// check the old WP8 location
									if (fs.existsSync(deployCmd)) {
										results.windowsphone[ver].deployCmd = deployCmd;
									// check the new WP8.1 location
									} else if (fs.existsSync(deployCmd = path.join(parts[2], 'Tools', 'AppDeploy', 'AppDeployCmd.exe'))) {
										results.windowsphone[ver].deployCmd = deployCmd;
									}

									var xapSignTool = path.join(parts[2], 'Tools', 'XapSignTool', 'XapSignTool.exe');
									if (fs.existsSync(xapSignTool)) {
										results.windowsphone[ver].xapSignTool = xapSignTool;
									}
								}
							}
						});
					}
					next();
				});
			}, function () {
Esempio n. 17
0
						appc.subprocess.run('reg', ['query', configKey, '/v', '*'], function (code, out, err) {
							if (!code) {
								var ver = possibleVersions[configKey].version,
									info = vsInfo[ver] = {
										version: ver,
										registryKey: configKey,
										supported: appc.version.satisfies(ver, mobilewebPackageJson.vendorDependencies['visual studio'], true),
										vcvarsall: null,
										wpsdk: null,
										selected: false
									};

								// get only the values we are interested in
								out.trim().split(/\r\n|\n/).forEach(function (line) {
									var parts = line.trim().split('   ').map(function (p) { return p.trim(); });
									if (parts.length == 3) {
										if (parts[0] == 'CLR Version') {
											info.clrVersion = parts[2];
										} else if (parts[0] == 'ShellFolder') {
											info.path = parts[2];
										}
									}
								});

								// verify that this Visual Studio actually exists
								if (info.path && fs.existsSync(info.path) && fs.existsSync(path.join(info.path, 'Common7', 'IDE', 'devenv.exe'))) {
									// get the vcvarsall script
									var vcvarsall = path.join(info.path, 'VC', 'vcvarsall.bat');
									if (fs.existsSync(vcvarsall)) {
										info.vcvarsall = vcvarsall;
									}

									// detect all Windows Phone SDKs
									var wpsdkDir = path.join(info.path, 'VC', 'WPSDK');
									fs.existsSync(wpsdkDir) && fs.readdirSync(wpsdkDir).forEach(function (ver) {
										var vcvarsphone = path.join(wpsdkDir, ver, 'vcvarsphoneall.bat');
										if (fs.existsSync(vcvarsphone) && /^wp\d+$/i.test(ver)) {
											// we found a windows phone sdk!
											var name = (parseInt(ver.replace(/^wp/i, '')) / 10).toFixed(1);
											info.wpsdk || (info.wpsdk = {});
											info.wpsdk[name] = {
												vcvarsphone: vcvarsphone
											};
										}
									});
								}
							}

							if (info.vcvarsall) {
								appc.subprocess.getRealName(info.vcvarsall, function (err, file) {
									if (!err) {
										info.vcvarsall = file
									}
									next();
								});
							} else {
								next();
							}
						});
Esempio n. 18
0
				function getVersion(exe) {
					appc.subprocess.run(exe, '--version', function (code, out, err) {
						next(null, {
							vboxmanage: exe,
							version: code ? null : out.trim()
						});
					});
				}
Esempio n. 19
0
					tasks.push(function (next) {
						appc.subprocess.run(env.executables.security, ['find-certificate', '-c', 'iOS Distribution:', '-a', '-p', keychain], function (code, out, err) {
							if (!code) {
								parseCerts(out, dest.distribution, 'iOS Distribution:');
							}
							next();
						});
					});
Esempio n. 20
0
	android.detect(this.config, null, function (results) {
		if (results.sdk && results.sdk.executables.adb) {
			appc.subprocess.run(results.sdk.executables.adb, 'kill-server', function (code, out, err) {
				callback(code);
			});
		} else {
			callback(new Error(__('Android SDK not found')));
		}
	});
Esempio n. 21
0
		android.detect(this.config, null, function (results) {
			if (results.sdk && results.sdk.executables.adb) {
				appc.subprocess.run(results.sdk.executables.adb, ['-s', deviceId, 'pull', src, dest], function (code, out, err) {
					callback(code);
				});
			} else {
				callback(new Error(__('Android SDK not found')));
			}
		});
Esempio n. 22
0
		async.eachSeries(simHandlesToWipe, function (simHandle, next) {
			if (simHandle && simHandle.simctl) {
				appc.subprocess.run(simHandle.simctl, ['erase', simHandle.udid], function () {
					next();
				});
			} else {
				next();
			}
		}, function () {
Esempio n. 23
0
				// try finding the 'genymotion' executable
				function (cb) {
					appc.subprocess.findExecutable([config.get('genymotion.executables.genymotion'), 'genymotion' + exe], function (err, result) {
						if (err) {
							cb(err);
						} else {
							findGenymotion(path.resolve(result, '..', '..'), config, cb);
						}
					});
				}
Esempio n. 24
0
		detect(options, function (err, results) {
			if (err) {
				emitter.emit('error', err);
				return callback(err);
			}

			var vsInfo = results.selectedVisualStudio;

			if (!vsInfo || !vsInfo.vcvarsall) {
				var e = new Error(__('Unable to find a supported Visual Studio installation'));
				emitter.emit('error', e);
				return callback(e);
			}

			// it's possible that this function could be called multiple times for the same
			// project such as when wptool.exe needs to be built and the master detect() is
			// running each module's detection code in parallel. so, we need to detect this
			// and create a queue of events to process after the build completes.
			if (runningBuilds[options.project]) {
				runningBuilds[options.project].push({
					emitter: emitter,
					callback: callback
				});
				return;
			}

			runningBuilds[options.project] = [ {
				emitter: emitter,
				callback: callback
			} ];

			appc.subprocess.run(vsInfo.vcvarsall.replace(/\ /g, '^ '), [
				'&&', 'MSBuild', '/t:rebuild', '/p:configuration=' + (options.buildConfiguration || 'Release'), options.project
			], function (code, out, err) {
				var queue = runningBuilds[options.project];
				delete runningBuilds[options.project];

				var result = {
					code: code,
					out: out,
					err: err
				};

				queue.forEach(function (p) {
					if (code) {
						var err = new Error(__('Failed to build project %s (code %s)', options.project, code));
						err.extendedError = result;
						p.emitter.emit('error', err);
						p.callback(err);
					} else {
						p.emitter.emit('success', result);
						p.callback(null, result);
					}
				});
			});
		});
Esempio n. 25
0
			proc.list(options, function (err, processes) {
				if (err) {
					emitter.emit('error', err);
					return callback(err);
				}

				appc.subprocess.getRealName(path.resolve(__dirname, '..', 'bin', 'wp_stop_emulator.ps1'), function (err, psScript) {
					if (err) {
						emitter.emit('error', err);
						return callback(err);
					}

					var xdeRegExp = /^xde\.exe$/i,
						name = emuHandle.name.toLowerCase();

					async.eachSeries(processes, function (p, next) {
						if (!xdeRegExp.test(p.name) || p.title.toLowerCase() !== name) {
							return next();
						}
						// first kill the emulator
						process.kill(p.pid, 'SIGKILL'); // FIXME If we get ESRCH, can we assume the process died on it's own?

						setTimeout(function () {
							// next get hyper-v to think the emulator is not running
							appc.subprocess.run(options.powershell || 'powershell', [
								'-ExecutionPolicy', 'Bypass', '-NoLogo', '-NonInteractive', '-NoProfile',
								'-File',
								psScript,
								'"' + emuHandle.name + '"'
							], function (code, out, err) {
								try {
									if (!code) {
										var r = JSON.parse(out);
										if (r.success) {
											return next();
										}
									}
								} catch (e) {
									return next(e);
								}
								next(new Error('Failed to stop emulator.\r\nstdout: ' + out + '\r\nstderr: ' + err));
							});
						}, 1000);
					}, function (err) {
						if (err) {
							emitter.emit('error', err);
							return callback(err);
						}

						emuHandle.running = false;
						emitter.emit('stopped');
						callback();
					});
				});
			});
Esempio n. 26
0
			function osInfo(next) {
				appc.subprocess.run('wmic', ['os', 'get', 'Caption,Version'], function (code, out, err) {
					if (code) return next(code);

					var s = out.split('\n')[1].split(/ {2,}/);
					s.length > 0 && (results.os.name = s[0].trim());
					s.length > 1 && (results.os.version = s[1].trim());

					next();
				});
			},
Esempio n. 27
0
iOSModuleBuilder.prototype.createUniversalBinary = function createUniversalBinary(next) {
	const findLib = function (dest) {
		let lib = path.join(this.projectDir, 'build', 'Release-' + dest, 'lib' + this.moduleId + '.a');
		if (!fs.existsSync(lib)) {
			// unfortunately the initial module project template incorrectly
			// used the camel-cased module id
			lib = path.join(this.projectDir, 'build', 'Release-' + dest, 'lib' + this.moduleIdAsIdentifier + '.a');
			if (!fs.existsSync(lib)) {
                // try old path
                lib = path.join(this.projectDir, 'build', 'TIRelease', dest, 'lib' + this.moduleId + '.a');
                if (!fs.existsSync(lib)) {
				return new Error(__('Unable to find the built %s library', 'Release-' + dest));
			}
		}
        }
		return lib;
	}.bind(this);

	// Create a universal build by merging the all builds to a single binary
	const args = [];

	let lib = findLib('iphoneos');
	if (lib instanceof Error) {
		return next(lib);
	}
	args.push(lib);

	lib = findLib('iphonesimulator');
	if (lib instanceof Error) {
		return next(lib);
	}
	args.push(lib);

	args.push(
		'-create',
		'-output',
		path.join(this.projectDir, 'build', 'lib' + this.moduleId + '.a')
	);

	this.logger.info(__('Creating universal library'));
	this.logger.debug(__('Running: %s', (this.xcodeEnv.executables.lipo + ' ' + args.join(' ')).cyan));

	appc.subprocess.run(this.xcodeEnv.executables.lipo, args, function (code, out, err) {
		if (code) {
			this.logger.error(__('Failed to generate universal binary (code %s):', code));
			this.logger.error(err.trim() + '\n');
			process.exit(1);
		}

		next();
	}.bind(this));
};
Esempio n. 28
0
		visualstudio.detect(options, function (err, results) {
			if (err) {
				emitter.emit('error', err);
				return callback(err);
			}

			var vsInfo = results.selectedVisualStudio;

			if (!vsInfo) {
				var ex = new Error(__('Unable to find a supported Visual Studio installation'));
				emitter.emit('error', ex);
				return callback(ex);
			}
			// TODO Use generate method instead? There are very slight difference between the script and generate function
			appc.subprocess.getRealName(path.resolve(__dirname, '..', 'bin', 'winstore_create_cert.ps1'), function (err, psScript) {
				if (err) {
					emitter.emit('error', err);
					return callback(err);
				}

				// first lets create the cert
				appc.subprocess.run(vsInfo.vcvarsall.replace(/\ /g, '^ '), [
					'&&',
					options.powershell || 'powershell',
					'-ExecutionPolicy', 'Bypass', '-NoLogo', '-NonInteractive', '-NoProfile',
					'-File', psScript,
					appid,
					moment().add(2, 'years').format('L'),
					'"' + certPath + '"'
				], function (code, out, err) {
					if (code) {
						var ex = new Error(__('Failed to create certificate (code %s)', code));
						emitter.emit('error', ex);
						return callback(ex);
					}

					generatePFX(certPath + '.pvk', certPath + '.cer', certPath + '.pfx', options, function(err, pfxFile) {
						if (err) {
							emitter.emit('error', err);
							callback(err);
						} else {
							// Once generated, remove the private key and cert
							fs.existsSync(certPath + '.pvk') && fs.unlinkSync(certPath + '.pvk');
							fs.existsSync(certPath + '.cer') && fs.unlinkSync(certPath + '.cer');

							emitter.emit('created', pfxFile);
							callback(null, pfxFile);
						}
					});
				});
			});
		});
Esempio n. 29
0
	var javaHook = this.cli.createHook('build.android.java', this, function (exe, args, opts, done) {
		this.logger.info(__('Generate v8 bindings: %s', (exe + ' "' + args.join('" "') + '"').cyan));
			appc.subprocess.run(exe, args, opts, function (code, out, err) {
				if (code) {
					this.logger.error(__('Failed to compile Java source files:'));
					this.logger.error();
					err.trim().split('\n').forEach(this.logger.error);
					this.logger.log();
					process.exit(1);
				}
				done();
			}.bind(this));
		});
Esempio n. 30
0
					tasks.push(function (next) {
						// if we already found it, then skip the remaining keychains
						if (results.certs.wwdr) return next();

						appc.subprocess.run(env.executables.security, ['find-certificate', '-c', 'Apple Worldwide Developer Relations Certification Authority', '-a', '-p', keychain], function (code, out, err) {
							if (!code) {
								var tmp = [];
								parseCerts(out, tmp);
								results.certs.wwdr = tmp.length && tmp[0].invalid === false;
							}
							next();
						});
					});