Skip to content

chore: merge release-patch (5.1.1) branch in release #4224

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 13 commits into from
Dec 12, 2018
Merged
8 changes: 8 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ branches:
only:
- master
- release
- release-patch
env:
global:
- DATE=$(date +%Y-%m-%d)
Expand Down Expand Up @@ -58,3 +59,10 @@ deploy:
branch: release
api_key:
secure: "FM9QLOkFq6JpHlfHkT1i2Ht1ZlttZLq7K3kQNLabw7Z5+BPMcy/f3LRJkAkYMezrKLKRkq1uXmhY0BapoTnR9AVEO/t4g6dtbZ1TZ3xBH/HHnFofTFubOrc7+61DJzKduYtnQ/sn3EEOkN8jrXSY9uas4qZh7PSm1hcfjPI8gdI="
- provider: npm
skip_cleanup: true
email: [email protected]
on:
branch: release-patch
api_key:
secure: "FM9QLOkFq6JpHlfHkT1i2Ht1ZlttZLq7K3kQNLabw7Z5+BPMcy/f3LRJkAkYMezrKLKRkq1uXmhY0BapoTnR9AVEO/t4g6dtbZ1TZ3xBH/HHnFofTFubOrc7+61DJzKduYtnQ/sn3EEOkN8jrXSY9uas4qZh7PSm1hcfjPI8gdI="
23 changes: 18 additions & 5 deletions .travis/add-publishConfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,33 @@

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

const packageDef = JSON.parse(content);
if (!packageDef.publishConfig) {
packageDef.publishConfig = {};
packageDef.publishConfig = {};
}

const branch = process.argv[2];
if (!branch) {
console.log("Please pass the branch name as an argument!");
process.exit(1);
console.log("Please pass the branch name as an argument!");
process.exit(1);
}

switch (branch) {
case "release":
packageDef.publishConfig.tag = "rc";
break;
case "release-patch":
packageDef.publishConfig.tag = "patch";
break;
case "master":
packageDef.publishConfig.tag = "next";
break;
default:
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)`);
}
packageDef.publishConfig.tag = branch === "release" ? "rc" : "next";

const newContent = JSON.stringify(packageDef, null, " ");
fsModule.writeFileSync(path, newContent, fileOptions);
15 changes: 15 additions & 0 deletions lib/definitions/platform.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,14 @@ interface IPlatformService extends IBuildPlatformAction, NodeJS.EventEmitter {
*/
shouldInstall(device: Mobile.IDevice, projectData: IProjectData, release: IRelease, outputPath?: string): Promise<boolean>;

/**
*
* @param {Mobile.IDevice} device The device where the application should be installed.
* @param {IProjectData} projectData DTO with information about the project.
* @param {string} @optional outputPath Directory containing build information and artifacts.
*/
validateInstall(device: Mobile.IDevice, projectData: IProjectData, release: IRelease, outputPath?: string): Promise<void>;

/**
* Determines whether the project should undergo the prepare process.
* @param {IShouldPrepareInfo} shouldPrepareInfo Options needed to decide whether to prepare.
Expand Down Expand Up @@ -307,6 +315,13 @@ interface INodeModulesDependenciesBuilder {
interface IBuildInfo {
prepareTime: string;
buildTime: string;
/**
* Currently it is used only for iOS.
* As `xcrun` command does not throw an error when IPHONEOS_DEPLOYMENT_TARGET is provided in `xcconfig` file and
* the simulator's version does not match IPHONEOS_DEPLOYMENT_TARGET's value, we need to save it to buildInfo file
* in order check it on livesync and throw an error to the user.
*/
deploymentTarget?: string;
}

interface IPlatformDataComposition {
Expand Down
6 changes: 6 additions & 0 deletions lib/definitions/project.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -449,6 +449,12 @@ interface IPlatformProjectService extends NodeJS.EventEmitter, IPlatformProjectS
* Traverse through the production dependencies and find plugins that need build/rebuild
*/
checkIfPluginsNeedBuild(projectData: IProjectData): Promise<Array<any>>;

/**
* Get the deployment target's version
* Currently implemented only for iOS -> returns the value of IPHONEOS_DEPLOYMENT_TARGET property from xcconfig file
*/
getDeploymentTarget(projectData: IProjectData): any;
}

interface IValidatePlatformOutput {
Expand Down
2 changes: 2 additions & 0 deletions lib/services/android-project-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -665,6 +665,8 @@ export class AndroidProjectService extends projectServiceBaseLib.PlatformProject
// Nothing android specific to check yet.
}

public getDeploymentTarget(projectData: IProjectData): semver.SemVer { return; }

private copy(projectRoot: string, frameworkDir: string, files: string, cpArg: string): void {
const paths = files.split(' ').map(p => path.join(frameworkDir, p));
shell.cp(cpArg, paths, projectRoot);
Expand Down
49 changes: 36 additions & 13 deletions lib/services/ios-project-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -384,12 +384,6 @@ export class IOSProjectService extends projectServiceBaseLib.PlatformProjectServ
}

private async buildForDevice(projectRoot: string, args: string[], buildConfig: IBuildConfig, projectData: IProjectData): Promise<void> {
const defaultArchitectures = [
'ARCHS=armv7 arm64',
'VALID_ARCHS=armv7 arm64'
];

// build only for device specific architecture
if (!buildConfig.release && !buildConfig.architectures) {
await this.$devicesService.initialize({
platform: this.$devicePlatformsConstants.iOS.toLowerCase(), deviceId: buildConfig.device,
Expand All @@ -402,18 +396,15 @@ export class IOSProjectService extends projectServiceBaseLib.PlatformProjectServ
.uniq()
.value();
if (devicesArchitectures.length > 0) {
const architectures = [
`ARCHS=${devicesArchitectures.join(" ")}`,
`VALID_ARCHS=${devicesArchitectures.join(" ")}`
];
const architectures = this.getBuildArchitectures(projectData, buildConfig, devicesArchitectures);
if (devicesArchitectures.length > 1) {
architectures.push('ONLY_ACTIVE_ARCH=NO');
}
buildConfig.architectures = architectures;
}
}

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

args = args.concat([
"-sdk", "iphoneos",
Expand Down Expand Up @@ -457,6 +448,28 @@ export class IOSProjectService extends projectServiceBaseLib.PlatformProjectServ
return commandResult;
}

private getBuildArchitectures(projectData: IProjectData, buildConfig: IBuildConfig, architectures: string[]): string[] {
let result: string[] = [];

const frameworkVersion = this.getFrameworkVersion(projectData);
if (semver.valid(frameworkVersion) && semver.lt(semver.coerce(frameworkVersion), "5.1.0")) {
const target = this.getDeploymentTarget(projectData);
if (target && target.major >= 11) {
// We need to strip 32bit architectures as of deployment target >= 11 it is not allowed to have such
architectures = _.filter(architectures, arch => {
const is64BitArchitecture = arch === "x86_64" || arch === "arm64";
if (!is64BitArchitecture) {
this.$logger.warn(`The architecture ${arch} will be stripped as it is not supported for deployment target ${target.version}.`);
}
return is64BitArchitecture;
});
}
result = [`ARCHS=${architectures.join(" ")}`, `VALID_ARCHS=${architectures.join(" ")}`];
}

return result;
}

private async setupSigningFromTeam(projectRoot: string, projectData: IProjectData, teamId: string) {
const xcode = this.$pbxprojDomXcode.Xcode.open(this.getPbxProjPath(projectData));
const signing = xcode.getSigning(projectData.projectName);
Expand Down Expand Up @@ -555,13 +568,14 @@ export class IOSProjectService extends projectServiceBaseLib.PlatformProjectServ
}

private async buildForSimulator(projectRoot: string, args: string[], projectData: IProjectData, buildConfig?: IBuildConfig): Promise<void> {
const architectures = this.getBuildArchitectures(projectData, buildConfig, ["i386", "x86_64"]);

args = args
.concat(architectures)
.concat([
"build",
"-configuration", buildConfig.release ? "Release" : "Debug",
"-sdk", "iphonesimulator",
"ARCHS=i386 x86_64",
"VALID_ARCHS=i386 x86_64",
"ONLY_ACTIVE_ARCH=NO",
"CONFIGURATION_BUILD_DIR=" + path.join(projectRoot, "build", "emulator"),
"CODE_SIGN_IDENTITY=",
Expand Down Expand Up @@ -1031,6 +1045,15 @@ We will now place an empty obsolete compatability white screen LauncScreen.xib f
return [];
}

public getDeploymentTarget(projectData: IProjectData): semver.SemVer {
const target = this.$xCConfigService.readPropertyValue(this.getBuildXCConfigFilePath(projectData), "IPHONEOS_DEPLOYMENT_TARGET");
if (!target) {
return null;
}

return semver.coerce(target);
}

private getAllLibsForPluginWithFileExtension(pluginData: IPluginData, fileExtension: string): string[] {
const filterCallback = (fileName: string, pluginPlatformsFolderPath: string) => path.extname(fileName) === fileExtension;
return this.getAllNativeLibrariesForPlugin(pluginData, IOSProjectService.IOS_PLATFORM_NAME, filterCallback);
Expand Down
1 change: 1 addition & 0 deletions lib/services/livesync/livesync-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -475,6 +475,7 @@ export class LiveSyncService extends EventEmitter implements IDebugLiveSyncServi
});
}

await this.$platformService.validateInstall(options.device, options.projectData, options, options.deviceBuildInfoDescriptor.outputPath);
const shouldInstall = await this.$platformService.shouldInstall(options.device, options.projectData, options, options.deviceBuildInfoDescriptor.outputPath);
if (shouldInstall) {
await this.$platformService.installApplication(options.device, { release: false }, options.projectData, pathToBuildItem, options.deviceBuildInfoDescriptor.outputPath);
Expand Down
23 changes: 21 additions & 2 deletions lib/services/platform-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -436,13 +436,20 @@ export class PlatformService extends EventEmitter implements IPlatformService {

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

const prepareInfo = this.$projectChangesService.getPrepareInfo(platform, this.$projectDataService.getProjectData(projectDir));
const buildInfo = {
const prepareInfo = this.$projectChangesService.getPrepareInfo(platform, projectData);
const buildInfo: IBuildInfo = {
prepareTime: prepareInfo.changesRequireBuildTime,
buildTime: new Date().toString()
};

const deploymentTarget = platformData.platformProjectService.getDeploymentTarget(projectData);
if (deploymentTarget) {
buildInfo.deploymentTarget = deploymentTarget.version;
}

this.$fs.writeJson(buildInfoFile, buildInfo);
}

Expand All @@ -455,9 +462,21 @@ export class PlatformService extends EventEmitter implements IPlatformService {
const platformData = this.$platformsData.getPlatformData(platform, projectData);
const deviceBuildInfo: IBuildInfo = await this.getDeviceBuildInfo(device, projectData);
const localBuildInfo = this.getBuildInfo(platform, platformData, { buildForDevice: !device.isEmulator, release: release.release }, outputPath);

return !localBuildInfo || !deviceBuildInfo || deviceBuildInfo.buildTime !== localBuildInfo.buildTime;
}

public async validateInstall(device: Mobile.IDevice, projectData: IProjectData, release: IRelease, outputPath?: string): Promise<void> {
const platform = device.deviceInfo.platform;
const platformData = this.$platformsData.getPlatformData(platform, projectData);
const localBuildInfo = this.getBuildInfo(device.deviceInfo.platform, platformData, { buildForDevice: !device.isEmulator, release: release.release }, outputPath);
if (localBuildInfo.deploymentTarget) {
if (semver.lt(semver.coerce(device.deviceInfo.version), semver.coerce(localBuildInfo.deploymentTarget))) {
this.$errors.fail(`Unable to install on device with version ${device.deviceInfo.version} as deployment target is ${localBuildInfo.deploymentTarget}`);
}
}
}

public async installApplication(device: Mobile.IDevice, buildConfig: IBuildConfig, projectData: IProjectData, packageFile?: string, outputFilePath?: string): Promise<void> {
this.$logger.out(`Installing on device ${device.deviceInfo.identifier}...`);

Expand Down
2 changes: 1 addition & 1 deletion npm-shrinkwrap.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "nativescript",
"preferGlobal": true,
"version": "5.1.0",
"version": "5.1.1",
"author": "Telerik <[email protected]>",
"description": "Command-line interface for building NativeScript projects",
"bin": {
Expand Down
Loading