/**
 * Generates new build number based on tiapp.version
 *
 * @param {Function} next - A function to call after new version number have been generated.
 */
function generateBuildVersion(next) {
	// Generates new build number based on tiapp.version
	var version = appc.version.format(this.tiapp.version, 3, 4, true);
	// If revision number is omitted, we generate it. Only available on development/test build.
	// Can be disabled when 'use-auto-versioning' set false in <windows> section.
	var disabled = this.tiapp.windows && this.tiapp.windows['use-auto-versioning'] === false;

	if (!disabled && !/^dist-/.test(this.target) && version.split('.').length <= 3) {
		var buildNumber = 0;
		if (this.buildManifest.buildNumber) {
			var number = parseInt(this.buildManifest.buildNumber, 10);
			if (isNaN(number)) {
				number = 0;
			}
			buildNumber = number;
		}
		buildNumber++;
		this.buildVersion = appc.version.format(version + '.' + buildNumber, 4, 4, true);
		this.buildNumber = buildNumber;
	} else {
		this.buildVersion = appc.version.format(version, 4, 4, true);
		this.buildNumber  = 0;
	}
	next();
}
Пример #2
0
/**
 * Returns a list of platforms and since versions the API supports
 * @params api {Object} API to evaluate
 * @params versions {Object} Possible platforms and versions the API supports (usually from the class)
 * @returns {Object} Object containing platforms and versions the API supports
 */
function processVersions (api, versions) {
	var defaultVersions = nodeappc.util.mixObj({}, versions),
		platform = null,
		key = null;
	if (assert(api, 'platforms')) {
		for (platform in defaultVersions) {
			if (!~api.platforms.indexOf(platform)) delete defaultVersions[platform];
		}
		for (platform in common.ADDON_VERSIONS) {
			if (~api.platforms.indexOf(platform)) defaultVersions[platform] = common.ADDON_VERSIONS[platform];
		}
	} else if (assert(api, 'exclude-platforms')) {
		api['exclude-platforms'].forEach(function (platform) {
			if (platform in defaultVersions) delete defaultVersions[platform];
		});
	}
	if (assert(api, 'since')) {
		if (typeof api.since == 'string') {
			for (key in defaultVersions) {
				if (nodeappc.version.gt(api.since, defaultVersions[key])) defaultVersions[key] = api.since;
			}
		} else {
			for (key in defaultVersions) {
				if (nodeappc.version.gt(api.since[key], defaultVersions[key])) defaultVersions[key] = api.since[key];
			}
		}
	}
	return defaultVersions;
}
Пример #3
0
		post: function (data) {
			var sdk = getSDK();
			if (sdk && appc.version.lt(sdk, '3.4.0')) {
				// the plan is to wrap the project-dir callback and add the check to see if
				// we're using the correct SDK so we can fork as soon as possible
				// note: this logic was fixed in 3.4.0

				var titaniumFile = path.join(cli.sdk.path, 'node_modules', 'titanium-sdk', 'lib', 'titanium.js');

				// In Titanium SDK 3.2.3, the validateCorrectSDK() function call was moved from the --project-dir
				// callback into the validate() function because we needed to make sure all command line arguments
				// were processed before forking the correct SDK. In Titanium CLI 3.3.0, the command line parser
				// was completely rewritten and now properly handles arguments, so the validateCorrectSDK() can
				// be moved back into the callback() where it belongs. This has been corrected in Titanium SDK
				// 3.4.0, but needs to be monkey patched in 3.2.3 and 3.3.x.
				if (appc.version.gte(sdk, '3.2.3') && fs.existsSync(titaniumFile)) {
					var pd = data.result[1].options['project-dir'],
						orig = pd.callback;

					pd.callback = function (projectDir) {
						if (orig) {
							projectDir = orig(projectDir);
						}
						var ti = require(titaniumFile);
						if (!ti.validateCorrectSDK(logger, config, cli, 'build')) {
							throw new cli.GracefulShutdown;
						}
					};
				}
			}
		}
Пример #4
0
		platforms.sort(sortFn).concat(addons.sort(sortFn)).forEach(function (platform) {
			var abis = [];
			if (platform.abis) {
				Object.keys(platform.abis).forEach(function (type) {
					platform.abis[type].forEach(function (abi) {
						if (abis.indexOf(abi) === -1) {
							abis.push(abi);
						}
					});
				});
			}

			var info = {
				id:          platform.id,
				abis:        abis,
				skins:       platform.skins,
				name:        platform.name,
				type:        platform.type,
				path:        platform.path,
				revision:    platform.revision,
				androidJar:  platform.androidJar,
				aidl:        platform.aidl
			};

			if (platform.type == 'platform') {
				info['api-level'] = platform.apiLevel;
				info.sdk = platform.apiLevel;
				info.version = platform.version;
				info.supported = !~~platform.apiLevel || appc.version.satisfies(platform.apiLevel, androidPackageJson.vendorDependencies['android sdk'], true);
			} else if (platform.type == 'add-on' && platform.basedOn) {
				info.vendor = platform.vendor;
				info.description = platform.description;
				info.version = platform.basedOn.version || parseInt(String(platform.basedOn).replace(/^android-/, '')) || null;
				info['based-on'] = {
					'android-version': platform.basedOn.version,
					'api-level': platform.basedOn.apiLevel
				};
				info.supported = !~~platform.basedOn.apiLevel || appc.version.satisfies(platform.basedOn.apiLevel, androidPackageJson.vendorDependencies['android sdk'], true);
				info.libraries = {}; // not supported any more
			}

			results.targets[index++] = info;

			if (!info.supported) {
				results.issues.push({
					id: 'ANDROID_API_TOO_OLD',
					type: 'warning',
					message: __('Android API %s is too old and is no longer supported by Titanium SDK %s.', '__' + info.name + ' (' + info.id + ')__', manifestJson.version) + '\n' +
						__('The minimum supported Android API level by Titanium SDK %s is API level %s.', manifestJson.version, appc.version.parseMin(androidPackageJson.vendorDependencies['android sdk']))
				});
			} else if (info.supported == 'maybe') {
				results.issues.push({
					id: 'ANDROID_API_TOO_NEW',
					type: 'warning',
					message: __('Android API %s is too new and may or may not work with Titanium SDK %s.', '__' + info.name + ' (' + info.id + ')__', manifestJson.version) + '\n' +
						__('The maximum supported Android API level by Titanium SDK %s is API level %s.', manifestJson.version, appc.version.parseMax(androidPackageJson.vendorDependencies['android sdk']))
				});
			}
		});
Пример #5
0
	cli.on('cli:pre-validate', function (data) {
		var sdk = getSDK();

		// there was a bug in 3.2.0 where the --store-password was being forced to
		// --password when forking the correct SDK command with a SDK >= 3.2.0, so we
		// need to reverse it
		if (sdk && appc.version.gte(sdk, '3.2.0') && appc.version.lt(sdk, '4.0.0') && cli.argv.platform === 'android' && !cli.argv['store-password'] && cli.argv.password) {
			cli.argv['store-password'] = cli.argv.password;
		}
	});
Пример #6
0
				simSDKs.forEach(function (sdk) {
					if (type === 'iphone' || (type === 'ipad' && appc.version.gte(sdk, '3.0.0'))) {
						if (!_64bit || appc.version.gte(sdk, '7.0.0')) {
							if (!tall || appc.version.gte(sdk, '6.0.0')) {
								if ((!retina && type === 'ipad' || appc.version.lt(sdk, '7.0.0')) || (retina && appc.version.gte(sdk, '4.0.0'))) {
									versions[sdk] = 1;
								}
							}
						}
					}
				});
	function validate(value, callback) {
		if (!value && value !== 0) {
			return callback(new Error(__('Invalid device id')));
		}

		var devices = this.getTargetDevices(),
			dev = null;

		// xd: first emulator
		// de: first device
		if (((cli.argv.target === 'wp-emulator' && value === 'xd') ||
			 (cli.argv.target === 'wp-device' && value === 'de')) && devices[0]) {

			// if win-sdk is not specified, use wpsdk for device
			if (dev.wpsdk && !this.isWindowsSDKTargetSpecified()) {
				if (appc.version.satisfies(dev.wpsdk, this.packageJson.vendorDependencies['windows phone sdk'], false)) {
					cli.argv['win-sdk'] = dev.wpsdk;
				} else {
					this.logger.error(__('The connected device is running %s, which is unsupported by Titanium SDK %s', dev.wpsdk, this.cli.sdk.name));
					process.exit(10)
				}
			}
			return callback(null, devices[0].udid);
		}

		// validate device
		if (!devices.some(function (d) {
			// because we specify ignorecase below, we may get the name lowercased!
				if (d.udid == value || d.name.toLowerCase() === value.toLowerCase()) {
					dev = d;
					value = d.udid;
					return true;
				}
				return false;
			})) {
			return callback(new Error(__('Invalid device id "%s"', value)));
		}

		// if win-sdk is not specified, use wpsdk specified for device
		if (dev.wpsdk && !this.isWindowsSDKTargetSpecified()) {
			if (appc.version.satisfies(dev.wpsdk, this.packageJson.vendorDependencies['windows phone sdk'], false)) {
				cli.argv['win-sdk'] = dev.wpsdk;
			} else {
				this.logger.error(__('The connected device is running %s, which is unsupported by Titanium SDK %s', dev.wpsdk, this.cli.sdk.name));
				process.exit(10)
			}
		}

		// check the device
		if (cli.argv.target === 'wp-device') {
			this.windowslibOptions['wpsdk'] = this.getWindowsSDKTarget();
		}
		callback(null, value);
	}
Пример #8
0
					legacySims.forEach(function (sim) {
						if (sim.versions.indexOf(simVer) !== -1) {
							var i = 0,
								udid = appc.version.format(simVer, 4, 4).split('.').map(function (id) { return appc.string.lpad(id, i++ === 0 ? 8 : 4, '0'); }).join('-') + '-' + appc.string.lpad(sim.id, 12, '0');

							results.simulators[simVer] || (results.simulators[simVer] = []);

							if (!results.simulators[simVer].some(function (s) { return s.udid === udid; })) {
								var info = {
										'deviceType': sim.name,
										'udid': udid,
										'type': sim.type,
										'name': sim.name,
										'ios': simVer,
										'retina': sim.retina,
										'tall': sim.retina && sim.tall,
										'64bit': !!sim['64bit'],
										'resizable': false,
										'xcode': xc.version,
										'app': path.join(xc.path, 'Platforms', 'iPhoneSimulator.platform', 'Developer', 'Applications', 'iPhone Simulator.app'),
										'systemLog': appc.fs.resolvePath('~/Library/Logs/iOS Simulator/' + simVer + (sim['64bit'] ? '-64' : '') + '/system.log'),
										'logPaths': [
											appc.fs.resolvePath('~/Library/Application Support/iPhone Simulator/' + simVer + (sim['64bit'] ? '-64' : '') + '/Applications')
										],
										'logFile': null,
										'cmd': [
											iossim,
											'launch',
											'<app path>',
											'--verbose',
											'--xcode-dir', xc.path,
											'--sdk', appc.version.format(simVer, 2, 2),
											'--family', sim.type
										]
									};

								if (sim.retina) {
									info.cmd.push('--retina');
									if (sim.tall) {
										info.cmd.push('--tall');
									}
								}

								if (sim['64bit']) {
									info.cmd.push('--sim-64bit');
								}

								results.simulators[simVer].push(info);
							}

							// sort the simulators
							results.simulators[simVer].sort(simSort);
						}
					});
Пример #9
0
			}).sort(function (a, b) {
				var as = cli.env.sdks[a],
					av = as.manifest && as.manifest.version || as.name,
					bs = cli.env.sdks[b],
					bv = bs.manifest && bs.manifest.version || bs.name;
				try {
					if (appc.version.lt(av, bv)) {
						return -1;
					} else if (appc.version.eq(av, bv)) {
						return 0;
					}
				} catch (ex) {}
				return 1;
			}).reverse(),
Пример #10
0
		xcodes.forEach(function (dir) {
			var p = new appc.plist(path.join(path.dirname(dir), 'version.plist')),
				selected = dir == selectedXcodePath,
				supported = options.supportedVersions ? appc.version.satisfies(p.CFBundleShortVersionString, options.supportedVersions, true) : null,
				ver = p.CFBundleShortVersionString + ':' + p.ProductBuildVersion,
				f;

			if (!results.xcode[ver] || selected || dir <= results.xcode[ver].path) {
				results.xcode[ver] = {
					xcodeapp: dir.replace(/\/Contents\/Developer\/?$/, ''),
					path: dir,
					selected: selected,
					version: p.CFBundleShortVersionString,
					build: p.ProductBuildVersion,
					supported: supported,
					sdks: findIosSdks(path.join(dir, 'Platforms', 'iPhoneOS.platform', 'Developer', 'SDKs')),
					sims: findIosSdks(path.join(dir, 'Platforms', 'iPhoneSimulator.platform', 'Developer', 'SDKs')),
					executables: {
						xcodebuild: fs.existsSync(f = path.join(dir, 'usr', 'bin', 'xcodebuild')) ? f : null,
						clang:      fs.existsSync(f = path.join(dir, 'Toolchains', 'XcodeDefault.xctoolchain', 'usr', 'bin', 'clang')) ? f : null,
						clang_xx:   fs.existsSync(f = path.join(dir, 'Toolchains', 'XcodeDefault.xctoolchain', 'usr', 'bin', 'clang++')) ? f : null,
						libtool:    fs.existsSync(f = path.join(dir, 'Toolchains', 'XcodeDefault.xctoolchain', 'usr', 'bin', 'libtool')) ? f : null,
						lipo:       fs.existsSync(f = path.join(dir, 'Toolchains', 'XcodeDefault.xctoolchain', 'usr', 'bin', 'lipo')) ? f : null,
						otool:      fs.existsSync(f = path.join(dir, 'Toolchains', 'XcodeDefault.xctoolchain', 'usr', 'bin', 'otool')) ? f : null
					}
				};

				selected && (results.selectedXcode = results.xcode[ver]);

				if (supported === false) {
					results.issues.push({
						id: 'IOS_XCODE_TOO_OLD',
						type: 'warning',
						message: __('Xcode %s is too old and is no longer supported.', '__' + p.CFBundleShortVersionString + '__') + '\n' +
							__('The minimum supported Xcode version is Xcode %s.', appc.version.parseMin(options.supportedVersions)),
						xcodeVer: p.CFBundleShortVersionString,
						minSupportedVer: appc.version.parseMin(options.supportedVersions)
					});
				} else if (supported === 'maybe') {
					results.issues.push({
						id: 'IOS_XCODE_TOO_NEW',
						type: 'warning',
						message: __('Xcode %s may or may not work as expected.', '__' + p.CFBundleShortVersionString + '__') + '\n' +
							__('The maximum supported Xcode version is Xcode %s.', appc.version.parseMax(options.supportedVersions, true)),
						xcodeVer: p.CFBundleShortVersionString,
						maxSupportedVer: appc.version.parseMax(options.supportedVersions, true)
					});
				}
			}
		});
	cli.on('cli:post-validate', function (data) {
		var sdk = getSDK();

		if (sdk && appc.version.gte(sdk, '3.0.0') && appc.version.lt(sdk, '3.2.0') && data.command.platform && /^ios|iphone$/.test(data.command.platform.name)) {
			// in the iOS build for SDK 3.0.0 through 3.1.x, the valid deploy types
			// are always "development" and "test" regardless of the target. that's
			// a bug. if the target changes, so should the array of valid deploy
			// types.
			switch (cli.argv.target) {
				case 'dist-adhoc':
				case 'dist-appstore':
					data.command.platform.options['deploy-type'].values = ['production'];
			}
		}
	});
Пример #12
0
				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;
							}
						}
					}
				});
Пример #13
0
	ioslib.xcode.detect(function (err, env) {
		if (err) {
			return done(err);
		}

		if (env.selectedXcode === null) {
			return done(new Error(__('No selected Xcode')));
		}

		var cmd = [
			env.selectedXcode.executables.xcodebuild,
			'clean', 'build',
			'-configuration', 'Debug',
			'-sdk', 'iphoneos' + appc.version.format(env.selectedXcode.sdks[0], 2, 2),
			'VALID_ARCHS="armv7 armv7s"',
			'ARCHS="armv7 armv7s"',
			'IPHONEOS_DEPLOYMENT_TARGET=6.0',
			'PROVISIONING_PROFILE=' + provisioningProfileUUID,
			'DEPLOYMENT_POSTPROCESSING=YES',
			'CODE_SIGN_IDENTITY="' + certName + '"',
			'GCC_PREPROCESSOR_DEFINITIONS="' + defs.join(' ') + '"'
		].join(' ');

		exec(cmd, {
			cwd: path.join(__dirname, 'TestApp')
		}, function (code, out, err) {
			should(out).match(/BUILD SUCCEEDED/);
			var appPath = path.join(__dirname, 'TestApp', 'build', 'Debug-iphoneos', 'TestApp.app');
			should(fs.existsSync(appPath)).be.true;
			done(null, appPath);
		});
	});
Пример #14
0
/**
 * Validate version
 * @param {string} version possible version string
 * @return {string} error string if not a value version string
 */
function validateVersion(version) {
	try {
		nodeappc.version.lt('0.0.1', version);
	} catch (e) {
		return 'Invalid version: ' + version;
	}
}
Пример #15
0
		function findIosSims(dir, xcodeVer) {
			var vers = findSDKs(dir, /^iPhoneSimulator(.+)\.sdk$/),
				simRuntimesDir = '/Library/Developer/CoreSimulator/Profiles/Runtimes';

			// for Xcode >=6.2 <7.0, the simulators are in a global directory
			if (fs.existsSync(simRuntimesDir) && appc.version.gte(xcodeVer, '6.2')) {
				fs.readdirSync(simRuntimesDir).forEach(function (name) {
					var file = path.join(simRuntimesDir, name);
					if (!fs.existsSync(file) || !fs.statSync(file).isDirectory()) return;

					var m = name.match(/^iOS (.+)\.simruntime$/);
					if (m && (!options.minIosVersion || appc.version.gte(m[1], options.minIosVersion))) {
						var ver = m[1];
						file = path.join(file, 'Contents', 'Resources', 'RuntimeRoot', 'System', 'Library', 'CoreServices', 'SystemVersion.plist');
						if (fs.existsSync(file)) {
							var p = new appc.plist(file);
							if (p.ProductVersion) {
								ver = p.ProductVersion;
							}
						}
						if (vers.indexOf(ver) === -1) {
							vers.push(ver);
						}
					}
				});
			}

			return vers.sort().reverse();
		}
Пример #16
0
			return env.xcode[ver].sdks.some(function (sdk) {
				if (!iosVersion || appc.version.satisfies(sdk, iosVersion)) {
					xc = env.xcode[ver];
					iosVersion = sdk;
					return true;
				}
			});
Пример #17
0
		(isDir ? fs.readdirSync(dir) : [dir]).forEach(function (filename) {
			var file = isDir ? path.resolve(path.join(dir, filename)) : filename;
			if (fs.existsSync(file) && fs.statSync(file).isFile() && jsfile.test(filename) && (!isDir || !ignore.test(path.basename(file)))) {
				try {
					vm.runInThisContext('(function (exports, require, module, __filename, __dirname) { ' + fs.readFileSync(file).toString() + '\n});', file, 0, false);
					var mod = require(file);
					if (mod.id) {
						Array.isArray(this.hooks.ids[mod.id]) || (this.hooks.ids[mod.id] = []);
						this.hooks.ids[mod.id].push({
							file: file,
							version: mod.version || null
						});
						// don't load duplicate ids
						if (this.hooks.ids[mod.id].length > 1) {
							return;
						}
					}
					if (!this.version || !mod.version || semver.satisfies(appc.version.format(this.version, 0, 3, true), mod.version)) {
						mod.init && mod.init(this, log);
						this.hooks.loadedFilenames.push(file);
					} else {
						this.hooks.incompatibleFilenames.push(file);
					}
				} catch (ex) {
					log.error('error loading hook',file,'. '+ex);
					this.hooks.erroredFilenames.push(file);
					this.hooks.errors[file] = ex;
				}
			}
		}, this);
Пример #18
0
				appc.subprocess.run('cmd', [ '/C', selectedVisualStudio.vcvarsall + ' && MSBuild /version' ], function (code, out, err) {
					var msbuildInfo = null;

					if (code) {
						results.issues.push({
							id: 'WINDOWS_MSBUILD_ERROR',
							type: 'error',
							message: __('Failed to run MSBuild.') + '\n' +
								__('This is most likely due to Visual Studio cannot find a suitable .NET framework.') + '\n' +
								__('Please install the latest .NET framework.')
						});
					} else {
						var chunks = out.trim().split(/\r\n\r\n|\n\n/);
						chunks.shift(); // strip off the first chunk

						msbuildInfo = {
							version: chunks.shift().split(/\r\n|\n/).pop().trim()
						};

						if (!appc.version.satisfies(msbuildInfo.version, mobilewebPackageJson.vendorDependencies['msbuild'])) {
							results.issues.push({
								id: 'WINDOWS_MSBUILD_TOO_OLD',
								type: 'error',
								message: __('The MSBuild version %s is too old.', msbuildInfo.version) + '\n' +
									__("Titanium requires .NET MSBuild '%s'.", mobilewebPackageJson.vendorDependencies['msbuild']) + '\n' +
									__('Please install the latest .NET framework.')
							});
						}
					}

					next(null, msbuildInfo);
				});
Пример #19
0
	var sdks = Object.keys(env.sdks).filter(function (v) {
		try {
			return appc.version.gte(v, '3.0.0');
		} catch (e) {
			return false;
		}
	});
Пример #20
0
			Object.keys(iosInfo.xcode).forEach(function (ver) {
				if (appc.version.gte(iosInfo.xcode[ver].version, '6.0.0')) {
					delete iosInfo.xcode[ver];
				} else if (iosInfo.xcode[ver].supported) {
					validXcodes++;
				}
			});
Пример #21
0
								appc.subprocess.run('cmd', [ '/C', vcvarsall + ' && MSBuild /version' ], function (code, out, err) {
									if (code) {
										results.issues.push({
											id: 'WINDOWS_MSBUILD_ERROR',
											type: 'error',
											message: __('Failed to run MSBuild.') + '\n' +
												__('This is most likely due to Visual Studio cannot find a suitable .NET framework.') + '\n' +
												__('Please install the latest .NET framework.')
										});
									} else {
										var chunks = out.trim().split(/\r\n\r\n|\n\n/);
										chunks.shift(); // strip off the first chunk

										var ver = info.msbuildVersion = chunks.shift().split(/\r\n|\n/).pop().trim();

										if (options.supportedMSBuildVersions && !appc.version.satisfies(ver, options.supportedMSBuildVersions)) {
											results.issues.push({
												id: 'WINDOWS_MSBUILD_TOO_OLD',
												type: 'error',
												message: __('The MSBuild version %s is too old.', ver) + '\n' +
													__("Titanium requires .NET MSBuild '%s'.", options.supportedMSBuildVersions) + '\n' +
													__('Please install the latest .NET framework.')
											});
										}
									}

									next();
								});
Пример #22
0
						return function (cb) {
							var m = dir.match(/^(.+?\/Xcode.*\.app)\//),
								xcodeapp = m ? m[1] : path.join(dir, 'Applications', 'Xcode.app'),
								xcodebuild = path.join(dir, 'usr', 'bin', 'xcodebuild'),
								plistfile = path.join(path.dirname(dir), 'version.plist'),
								p, info, key;

							if (fs.existsSync(xcodebuild) && fs.existsSync(plistfile)) {
								p = new appc.plist(plistfile);
								info = {
									path: dir,
									xcodeapp: xcodeapp,
									xcodebuild: xcodebuild,
									selected: dir == selectedXcodePath,
									version: p.CFBundleShortVersionString,
									build: p.ProductBuildVersion,
									supported: appc.version.satisfies(p.CFBundleShortVersionString, iosPackageJson.vendorDependencies.xcode, true),
									sdks: null,
									sims: null
								};
								key = info.version + ':' + info.build;

								// if we already have this version of Xcode, ignore unless it's currently the selected version
								if (!xcodeInstalls[key] || info.selected || dir <= xcodeInstalls[key].path) {
									if (info.supported == false) {
										issues.push({
											id: 'IOS_XCODE_TOO_OLD',
											type: 'warning',
											message: __('Xcode %s is too old and is no longer supported by Titanium SDK %s.', '__' + info.version + '__', manifestJson.version) + '\n' +
												__('The minimumm supported Xcode version by Titanium SDK %s is Xcode %s.', manifestJson.version, appc.version.parseMin(iosPackageJson.vendorDependencies.xcode))
										});
									} else if (info.supported == 'maybe') {
										issues.push({
											id: 'IOS_XCODE_TOO_NEW',
											type: 'warning',
											message: __('Xcode %s is too new and may or may not work with Titanium SDK %s.', '__' + info.version + '__', manifestJson.version) + '\n' +
												__('The maximum supported Xcode version by Titanium SDK %s is Xcode %s.', manifestJson.version, appc.version.parseMax(iosPackageJson.vendorDependencies.xcode)) + '\n'
										});
									}

									xcodeInstalls[key] = info;
									info.sdks = findIosSdks(path.join(dir, 'Platforms', 'iPhoneOS.platform', 'Developer', 'SDKs'));
									info.sims = findIosSdks(path.join(dir, 'Platforms', 'iPhoneSimulator.platform', 'Developer', 'SDKs'));
								}
							}
							cb();
						};
Пример #23
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();
							}
						});
Пример #24
0
function validateVersion(version) {
	try {
		nodeappc.version.lt("0.0.1", version);
	}
	catch (e) {
		return "Invalid version: " + version;
	}
}
Пример #25
0
	checkForceRebuild: function (versionIosSdkPath, versionGuid, versionTiCoreHash, versionGitHash, libTiCoreHash) {
		if (this.cli.argv.force) {
			this.logger.debug(__('Forcing rebuild: %s flag was set', '--force'.cyan));
			return true;
		}
		
		if (!afs.exists(this.buildVersionFile)) {
			// if no .version file, rebuild!
			this.logger.debug(__('Forcing rebuild: %s does not exist', this.buildVersionFile.cyan));
			return true;
		}
		
		if (afs.exists(this.xcodeProjectConfigFile)) {
			// we have a previous build, see if the Titanium SDK changed
			var m = fs.readFileSync(this.xcodeProjectConfigFile).toString().match(/TI_VERSION\=([^\n]*)/);
			if (m && !appc.version.eq(m[1], this.titaniumSdkVersion)) {
				this.logger.debug(__("Forcing rebuild: last build was under Titanium SDK version %s and we're compiling for version %s", m[1].cyan, this.titaniumSdkVersion.cyan));
				return true;
			}
		}
		
		if (!afs.exists(this.xcodeAppDir)) {
			this.logger.debug(__('Forcing rebuild: %s does not exist', this.xcodeAppDir.cyan));
			return true;
		}
		
		// check that we have a libTiCore hash
		if (!versionTiCoreHash) {
			this.logger.debug(__('Forcing rebuild: incomplete version file %s', this.buildVersionFile.cyan));
			return true;
		}
		
		// check if the libTiCore hashes are different
		if (libTiCoreHash != versionTiCoreHash) {
			this.logger.debug(__('Forcing rebuild: libTiCore hash changed since last build'));
			this.logger.debug('  ' + __('Was: %s', versionTiCoreHash));
			this.logger.debug('  ' + __('Now: %s', libTiCoreHash));
			return true;
		}
		
		// check if the titanium sdk paths are different
		if (versionIosSdkPath != this.titaniumIosSdkPath) {
			this.logger.debug(__('Forcing rebuild: Titanium SDK path changed since last build'));
			this.logger.debug('  ' + __('Was: %s', versionIosSdkPath));
			this.logger.debug('  ' + __('Now: %s', this.titaniumIosSdkPath));
			return true;
		}
		
		// check the git hashes are different
		if (!versionGitHash || versionGitHash != ti.manifest.githash) {
			this.logger.debug(__('Forcing rebuild: githash changed since last build'));
			this.logger.debug('  ' + __('Was: %s', versionGitHash));
			this.logger.debug('  ' + __('Now: %s', this.lib.manifest.githash));
			return true;
		}
		
		return false;
	}
/**
 * Generates the native type wrappers and adds them to the Visual Studio project.
 *
 * @param {Function} next - A function to call after the native types have been generated.
 */
function generateNativeTypes(next) {
	this.logger.info(__('Generating Native Types'));

	var defaultTargetPlatformVersion,
		defaultTargetPlatformMinVersion;

	if (this.wpsdk.startsWith('10.0') &&
		this.windowsInfo.windowsphone['10.0'] &&
		this.windowsInfo.windowsphone['10.0'].sdks &&
		this.windowsInfo.windowsphone['10.0'].sdks.length > 0) {
		
		var supportedSdkVersions = this.windowslibOptions.supportedWindows10SDKVersions.replace(/(\d+\.\d+\.\d+)\.\d+/g, '$1'),
			sdks = this.windowsInfo.windowsphone['10.0'].sdks;

		// TIMOB-24908: Visual studio 2015 cannout build with newer SDKs
		if (this.windowsInfo.selectedVisualStudio.version === '14.0') {
			supportedSdkVersions = '>=10.0.10240 <=10.0.14393';
		}

		// obtain highest compatible target version
		for (var i = sdks.length - 1; i >= 0; i--) {
			var sdk = sdks[i];
			if (appc.version.satisfies(sdk, supportedSdkVersions, false)) {
				defaultTargetPlatformVersion = sdk;
				break;
			}
		}
		// obtain lowest compatible target version
		for (var i = 0; i < sdks.length; i++) {
			var sdk = sdks[i];
			if (appc.version.satisfies(sdk, supportedSdkVersions, false)) {
				defaultTargetPlatformMinVersion = sdk;
				break;
			}
		}
	}
	this.targetPlatformSdkVersion = this.targetPlatformSdkVersion || this.tiapp.windows['TargetPlatformVersion'] || defaultTargetPlatformVersion || this.wpsdk;
	this.targetPlatformSdkMinVersion = this.targetPlatformSdkMinVersion || this.tiapp.windows['TargetPlatformMinVersion'] || defaultTargetPlatformMinVersion || this.targetPlatformSdkVersion;

	this.logger.debug(__('targetPlatformSdkVersion: %s', this.targetPlatformSdkVersion));
	this.logger.debug(__('targetPlatformSdkMinVersion: %s', this.targetPlatformSdkMinVersion));

	nativeModuleGenerator.generate(this, next);
};
Пример #27
0
					Object.keys(this.data.titanium).sort().reverse().forEach(function (ver) {
						var x = this.data.titanium[ver];
						logger.log(
							'  ' + ver.cyan + '\n' +
							'  ' + rpad('  ' + __('Install Location'))  + ' = ' + styleValue(x.path) + '\n' +
							'  ' + rpad('  ' + __('Platforms'))         + ' = ' + styleValue(x.platforms.join(', ')) + '\n' +
							'  ' + rpad('  ' + __('git Hash'))          + ' = ' + styleValue(x.githash || 'unknown') + '\n' +
							'  ' + rpad('  ' + __('git Timestamp'))     + ' = ' + styleValue(x.timestamp || 'unknown') + '\n' +
							'  ' + rpad('  ' + __('node-appc Version')) + ' = ' + styleValue(appc.version.lt(ver, '3.0.0') ? 'n/a' : x.nodeAppcVer || 'unknown')
						);
					}, this);
			function finish(version) {
				analyticsPayload.version = version;
				cli.addAnalyticsEvent('sdk.install', analyticsPayload);

				if (version) {
					var setDefault = (data.setDefault || cli.argv.default) && appc.version.gte(version, '3.0.0') && (cli.argv.default || newestInstalledSdk === null || appc.version.gt(version, newestInstalledSdk));
					if (setDefault) {
						logger.log(__('Setting Titanium SDK %s as the default.', version.cyan) + '\n');
						config.load();
						config.set('sdk.selected', version);
						config.save();
					}

					logger.log(__('Titanium SDK %s successfully installed!', version.cyan) + '\n');
				} else {
					logger.log(__('Successfully installed!') + '\n');
				}

				finished();
			}
Пример #29
0
		], function (err, data) {
			data = data.shift();

			var vers = Object.keys(cli.env.sdks).filter(function (v) {
					return appc.version.gte(v, '3.0.0');
				}).sort().reverse(),
				newestInstalledSdk = config.get('sdk.selected', config.get('app.sdk', 'latest')) == 'latest' ? (vers.length ? vers[0] : null) : config.get('sdk.selected', config.get('app.sdk')),
				setDefault = (data.setDefault || cli.argv.default) && appc.version.gte(data.version, '3.0.0') && (cli.argv.default || newestInstalledSdk === null || appc.version.gt(data.version, newestInstalledSdk)),
				analyticsPayload = {};

			data.version && (analyticsPayload.version = data.version);
			data.branch && (analyticsPayload.branch = data.branch);

			function finish(version) {
				analyticsPayload.version = version;
				cli.addAnalyticsEvent('sdk.install', analyticsPayload);

				if (version) {
					if (setDefault) {
						logger.log(__('Setting Titanium SDK %s as the default.', version.cyan) + '\n');
						config.load();
						config.set('sdk.selected', version);
						config.save();
					}

					logger.log(__('Titanium SDK %s successfully installed!', version.cyan) + '\n');
				} else {
					logger.log(__('Successfully installed!') + '\n');
				}

				finished();
			}

			if (data.file) {
				extractSDK(data.file, true, null, finish);
			} else if (data.url) {
				downloadSDK(data.url, function (filename) {
					extractSDK(filename, cli.argv['keep-files'], data.version, finish);
				});
			}
		});
Пример #30
0
			validate: function (value) {
				if (!cli.env.sdks[value]) {
					logger.error(__('Invalid Titanium SDK "%s"', value));
					return false;
				}
				if (appc.version.lt(value, '3.2.0')) {
					logger.log('');
					logger.warn(__('Titanium SDK ' + value + ' has been deprecated and will not work with future releases.'));
					logger.warn(__('Please use Titanium SDK 3.2 or newer.'));
				}
				return true;
			}