Skip to content

Commit 92e4426

Browse files
Merge pull request #4224 from NativeScript/vladimirov/merge-511-release
chore: merge release-patch (5.1.1) branch in release
2 parents ac077f0 + eb7b294 commit 92e4426

12 files changed

+271
-22
lines changed

.travis.yml

+8
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ branches:
22
only:
33
- master
44
- release
5+
- release-patch
56
env:
67
global:
78
- DATE=$(date +%Y-%m-%d)
@@ -58,3 +59,10 @@ deploy:
5859
branch: release
5960
api_key:
6061
secure: "FM9QLOkFq6JpHlfHkT1i2Ht1ZlttZLq7K3kQNLabw7Z5+BPMcy/f3LRJkAkYMezrKLKRkq1uXmhY0BapoTnR9AVEO/t4g6dtbZ1TZ3xBH/HHnFofTFubOrc7+61DJzKduYtnQ/sn3EEOkN8jrXSY9uas4qZh7PSm1hcfjPI8gdI="
62+
- provider: npm
63+
skip_cleanup: true
64+
65+
on:
66+
branch: release-patch
67+
api_key:
68+
secure: "FM9QLOkFq6JpHlfHkT1i2Ht1ZlttZLq7K3kQNLabw7Z5+BPMcy/f3LRJkAkYMezrKLKRkq1uXmhY0BapoTnR9AVEO/t4g6dtbZ1TZ3xBH/HHnFofTFubOrc7+61DJzKduYtnQ/sn3EEOkN8jrXSY9uas4qZh7PSm1hcfjPI8gdI="

.travis/add-publishConfig.js

+18-5
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,33 @@
22

33
const fsModule = require("fs");
44
const path = "./package.json";
5-
const fileOptions = {encoding: "utf-8"};
5+
const fileOptions = { encoding: "utf-8" };
66
const content = fsModule.readFileSync(path, fileOptions);
77

88
const packageDef = JSON.parse(content);
99
if (!packageDef.publishConfig) {
10-
packageDef.publishConfig = {};
10+
packageDef.publishConfig = {};
1111
}
1212

1313
const branch = process.argv[2];
1414
if (!branch) {
15-
console.log("Please pass the branch name as an argument!");
16-
process.exit(1);
15+
console.log("Please pass the branch name as an argument!");
16+
process.exit(1);
17+
}
18+
19+
switch (branch) {
20+
case "release":
21+
packageDef.publishConfig.tag = "rc";
22+
break;
23+
case "release-patch":
24+
packageDef.publishConfig.tag = "patch";
25+
break;
26+
case "master":
27+
packageDef.publishConfig.tag = "next";
28+
break;
29+
default:
30+
throw new Error(`Unable to publish as the branch ${branch} does not have corresponding tag. Supported branches are master (next tag), release (rc tag) and release-patch (patch tag)`);
1731
}
18-
packageDef.publishConfig.tag = branch === "release" ? "rc" : "next";
1932

2033
const newContent = JSON.stringify(packageDef, null, " ");
2134
fsModule.writeFileSync(path, newContent, fileOptions);

lib/definitions/platform.d.ts

+15
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,14 @@ interface IPlatformService extends IBuildPlatformAction, NodeJS.EventEmitter {
8383
*/
8484
shouldInstall(device: Mobile.IDevice, projectData: IProjectData, release: IRelease, outputPath?: string): Promise<boolean>;
8585

86+
/**
87+
*
88+
* @param {Mobile.IDevice} device The device where the application should be installed.
89+
* @param {IProjectData} projectData DTO with information about the project.
90+
* @param {string} @optional outputPath Directory containing build information and artifacts.
91+
*/
92+
validateInstall(device: Mobile.IDevice, projectData: IProjectData, release: IRelease, outputPath?: string): Promise<void>;
93+
8694
/**
8795
* Determines whether the project should undergo the prepare process.
8896
* @param {IShouldPrepareInfo} shouldPrepareInfo Options needed to decide whether to prepare.
@@ -307,6 +315,13 @@ interface INodeModulesDependenciesBuilder {
307315
interface IBuildInfo {
308316
prepareTime: string;
309317
buildTime: string;
318+
/**
319+
* Currently it is used only for iOS.
320+
* As `xcrun` command does not throw an error when IPHONEOS_DEPLOYMENT_TARGET is provided in `xcconfig` file and
321+
* the simulator's version does not match IPHONEOS_DEPLOYMENT_TARGET's value, we need to save it to buildInfo file
322+
* in order check it on livesync and throw an error to the user.
323+
*/
324+
deploymentTarget?: string;
310325
}
311326

312327
interface IPlatformDataComposition {

lib/definitions/project.d.ts

+6
Original file line numberDiff line numberDiff line change
@@ -449,6 +449,12 @@ interface IPlatformProjectService extends NodeJS.EventEmitter, IPlatformProjectS
449449
* Traverse through the production dependencies and find plugins that need build/rebuild
450450
*/
451451
checkIfPluginsNeedBuild(projectData: IProjectData): Promise<Array<any>>;
452+
453+
/**
454+
* Get the deployment target's version
455+
* Currently implemented only for iOS -> returns the value of IPHONEOS_DEPLOYMENT_TARGET property from xcconfig file
456+
*/
457+
getDeploymentTarget(projectData: IProjectData): any;
452458
}
453459

454460
interface IValidatePlatformOutput {

lib/services/android-project-service.ts

+2
Original file line numberDiff line numberDiff line change
@@ -665,6 +665,8 @@ export class AndroidProjectService extends projectServiceBaseLib.PlatformProject
665665
// Nothing android specific to check yet.
666666
}
667667

668+
public getDeploymentTarget(projectData: IProjectData): semver.SemVer { return; }
669+
668670
private copy(projectRoot: string, frameworkDir: string, files: string, cpArg: string): void {
669671
const paths = files.split(' ').map(p => path.join(frameworkDir, p));
670672
shell.cp(cpArg, paths, projectRoot);

lib/services/ios-project-service.ts

+36-13
Original file line numberDiff line numberDiff line change
@@ -384,12 +384,6 @@ export class IOSProjectService extends projectServiceBaseLib.PlatformProjectServ
384384
}
385385

386386
private async buildForDevice(projectRoot: string, args: string[], buildConfig: IBuildConfig, projectData: IProjectData): Promise<void> {
387-
const defaultArchitectures = [
388-
'ARCHS=armv7 arm64',
389-
'VALID_ARCHS=armv7 arm64'
390-
];
391-
392-
// build only for device specific architecture
393387
if (!buildConfig.release && !buildConfig.architectures) {
394388
await this.$devicesService.initialize({
395389
platform: this.$devicePlatformsConstants.iOS.toLowerCase(), deviceId: buildConfig.device,
@@ -402,18 +396,15 @@ export class IOSProjectService extends projectServiceBaseLib.PlatformProjectServ
402396
.uniq()
403397
.value();
404398
if (devicesArchitectures.length > 0) {
405-
const architectures = [
406-
`ARCHS=${devicesArchitectures.join(" ")}`,
407-
`VALID_ARCHS=${devicesArchitectures.join(" ")}`
408-
];
399+
const architectures = this.getBuildArchitectures(projectData, buildConfig, devicesArchitectures);
409400
if (devicesArchitectures.length > 1) {
410401
architectures.push('ONLY_ACTIVE_ARCH=NO');
411402
}
412403
buildConfig.architectures = architectures;
413404
}
414405
}
415406

416-
args = args.concat((buildConfig && buildConfig.architectures) || defaultArchitectures);
407+
args = args.concat((buildConfig && buildConfig.architectures) || this.getBuildArchitectures(projectData, buildConfig, ["armv7", "arm64"]));
417408

418409
args = args.concat([
419410
"-sdk", "iphoneos",
@@ -457,6 +448,28 @@ export class IOSProjectService extends projectServiceBaseLib.PlatformProjectServ
457448
return commandResult;
458449
}
459450

451+
private getBuildArchitectures(projectData: IProjectData, buildConfig: IBuildConfig, architectures: string[]): string[] {
452+
let result: string[] = [];
453+
454+
const frameworkVersion = this.getFrameworkVersion(projectData);
455+
if (semver.valid(frameworkVersion) && semver.lt(semver.coerce(frameworkVersion), "5.1.0")) {
456+
const target = this.getDeploymentTarget(projectData);
457+
if (target && target.major >= 11) {
458+
// We need to strip 32bit architectures as of deployment target >= 11 it is not allowed to have such
459+
architectures = _.filter(architectures, arch => {
460+
const is64BitArchitecture = arch === "x86_64" || arch === "arm64";
461+
if (!is64BitArchitecture) {
462+
this.$logger.warn(`The architecture ${arch} will be stripped as it is not supported for deployment target ${target.version}.`);
463+
}
464+
return is64BitArchitecture;
465+
});
466+
}
467+
result = [`ARCHS=${architectures.join(" ")}`, `VALID_ARCHS=${architectures.join(" ")}`];
468+
}
469+
470+
return result;
471+
}
472+
460473
private async setupSigningFromTeam(projectRoot: string, projectData: IProjectData, teamId: string) {
461474
const xcode = this.$pbxprojDomXcode.Xcode.open(this.getPbxProjPath(projectData));
462475
const signing = xcode.getSigning(projectData.projectName);
@@ -555,13 +568,14 @@ export class IOSProjectService extends projectServiceBaseLib.PlatformProjectServ
555568
}
556569

557570
private async buildForSimulator(projectRoot: string, args: string[], projectData: IProjectData, buildConfig?: IBuildConfig): Promise<void> {
571+
const architectures = this.getBuildArchitectures(projectData, buildConfig, ["i386", "x86_64"]);
572+
558573
args = args
574+
.concat(architectures)
559575
.concat([
560576
"build",
561577
"-configuration", buildConfig.release ? "Release" : "Debug",
562578
"-sdk", "iphonesimulator",
563-
"ARCHS=i386 x86_64",
564-
"VALID_ARCHS=i386 x86_64",
565579
"ONLY_ACTIVE_ARCH=NO",
566580
"CONFIGURATION_BUILD_DIR=" + path.join(projectRoot, "build", "emulator"),
567581
"CODE_SIGN_IDENTITY=",
@@ -1031,6 +1045,15 @@ We will now place an empty obsolete compatability white screen LauncScreen.xib f
10311045
return [];
10321046
}
10331047

1048+
public getDeploymentTarget(projectData: IProjectData): semver.SemVer {
1049+
const target = this.$xCConfigService.readPropertyValue(this.getBuildXCConfigFilePath(projectData), "IPHONEOS_DEPLOYMENT_TARGET");
1050+
if (!target) {
1051+
return null;
1052+
}
1053+
1054+
return semver.coerce(target);
1055+
}
1056+
10341057
private getAllLibsForPluginWithFileExtension(pluginData: IPluginData, fileExtension: string): string[] {
10351058
const filterCallback = (fileName: string, pluginPlatformsFolderPath: string) => path.extname(fileName) === fileExtension;
10361059
return this.getAllNativeLibrariesForPlugin(pluginData, IOSProjectService.IOS_PLATFORM_NAME, filterCallback);

lib/services/livesync/livesync-service.ts

+1
Original file line numberDiff line numberDiff line change
@@ -475,6 +475,7 @@ export class LiveSyncService extends EventEmitter implements IDebugLiveSyncServi
475475
});
476476
}
477477

478+
await this.$platformService.validateInstall(options.device, options.projectData, options, options.deviceBuildInfoDescriptor.outputPath);
478479
const shouldInstall = await this.$platformService.shouldInstall(options.device, options.projectData, options, options.deviceBuildInfoDescriptor.outputPath);
479480
if (shouldInstall) {
480481
await this.$platformService.installApplication(options.device, { release: false }, options.projectData, pathToBuildItem, options.deviceBuildInfoDescriptor.outputPath);

lib/services/platform-service.ts

+21-2
Original file line numberDiff line numberDiff line change
@@ -436,13 +436,20 @@ export class PlatformService extends EventEmitter implements IPlatformService {
436436

437437
public saveBuildInfoFile(platform: string, projectDir: string, buildInfoFileDirname: string): void {
438438
const buildInfoFile = path.join(buildInfoFileDirname, buildInfoFileName);
439+
const projectData = this.$projectDataService.getProjectData(projectDir);
440+
const platformData = this.$platformsData.getPlatformData(platform, projectData);
439441

440-
const prepareInfo = this.$projectChangesService.getPrepareInfo(platform, this.$projectDataService.getProjectData(projectDir));
441-
const buildInfo = {
442+
const prepareInfo = this.$projectChangesService.getPrepareInfo(platform, projectData);
443+
const buildInfo: IBuildInfo = {
442444
prepareTime: prepareInfo.changesRequireBuildTime,
443445
buildTime: new Date().toString()
444446
};
445447

448+
const deploymentTarget = platformData.platformProjectService.getDeploymentTarget(projectData);
449+
if (deploymentTarget) {
450+
buildInfo.deploymentTarget = deploymentTarget.version;
451+
}
452+
446453
this.$fs.writeJson(buildInfoFile, buildInfo);
447454
}
448455

@@ -455,9 +462,21 @@ export class PlatformService extends EventEmitter implements IPlatformService {
455462
const platformData = this.$platformsData.getPlatformData(platform, projectData);
456463
const deviceBuildInfo: IBuildInfo = await this.getDeviceBuildInfo(device, projectData);
457464
const localBuildInfo = this.getBuildInfo(platform, platformData, { buildForDevice: !device.isEmulator, release: release.release }, outputPath);
465+
458466
return !localBuildInfo || !deviceBuildInfo || deviceBuildInfo.buildTime !== localBuildInfo.buildTime;
459467
}
460468

469+
public async validateInstall(device: Mobile.IDevice, projectData: IProjectData, release: IRelease, outputPath?: string): Promise<void> {
470+
const platform = device.deviceInfo.platform;
471+
const platformData = this.$platformsData.getPlatformData(platform, projectData);
472+
const localBuildInfo = this.getBuildInfo(device.deviceInfo.platform, platformData, { buildForDevice: !device.isEmulator, release: release.release }, outputPath);
473+
if (localBuildInfo.deploymentTarget) {
474+
if (semver.lt(semver.coerce(device.deviceInfo.version), semver.coerce(localBuildInfo.deploymentTarget))) {
475+
this.$errors.fail(`Unable to install on device with version ${device.deviceInfo.version} as deployment target is ${localBuildInfo.deploymentTarget}`);
476+
}
477+
}
478+
}
479+
461480
public async installApplication(device: Mobile.IDevice, buildConfig: IBuildConfig, projectData: IProjectData, packageFile?: string, outputFilePath?: string): Promise<void> {
462481
this.$logger.out(`Installing on device ${device.deviceInfo.identifier}...`);
463482

npm-shrinkwrap.json

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "nativescript",
33
"preferGlobal": true,
4-
"version": "5.1.0",
4+
"version": "5.1.1",
55
"author": "Telerik <[email protected]>",
66
"description": "Command-line interface for building NativeScript projects",
77
"bin": {

0 commit comments

Comments
 (0)