Skip to content

Fix passing provision to tns run ios and passsing --teamId #3069

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 1 commit into from
Aug 17, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions lib/definitions/livesync.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,11 @@ interface ILiveSyncDeviceInfo {
* Whether to skip preparing the native platform.
*/
skipNativePrepare?: boolean;

/**
* Describes options specific for each platform, like provision for iOS, target sdk for Android, etc.
*/
platformSpecificOptions?: IPlatformOptions;
}

/**
Expand Down
21 changes: 8 additions & 13 deletions lib/definitions/platform.d.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
interface IPlatformService extends NodeJS.EventEmitter {
cleanPlatforms(platforms: string[], platformTemplate: string, projectData: IProjectData, config: IAddPlatformCoreOptions, framework?: string): Promise<void>;
cleanPlatforms(platforms: string[], platformTemplate: string, projectData: IProjectData, config: IPlatformOptions, framework?: string): Promise<void>;

addPlatforms(platforms: string[], platformTemplate: string, projectData: IProjectData, config: IAddPlatformCoreOptions, frameworkPath?: string): Promise<void>;
addPlatforms(platforms: string[], platformTemplate: string, projectData: IProjectData, config: IPlatformOptions, frameworkPath?: string): Promise<void>;

/**
* Gets list of all installed platforms (the ones for which <project dir>/platforms/<platform> exists).
Expand Down Expand Up @@ -32,7 +32,7 @@ interface IPlatformService extends NodeJS.EventEmitter {
*/
removePlatforms(platforms: string[], projectData: IProjectData): Promise<void>;

updatePlatforms(platforms: string[], platformTemplate: string, projectData: IProjectData, config: IAddPlatformCoreOptions): Promise<void>;
updatePlatforms(platforms: string[], platformTemplate: string, projectData: IProjectData, config: IPlatformOptions): Promise<void>;

/**
* Ensures that the specified platform and its dependencies are installed.
Expand All @@ -47,7 +47,7 @@ interface IPlatformService extends NodeJS.EventEmitter {
* @param {Array} filesToSync Files about to be synced to device.
* @returns {boolean} true indicates that the platform was prepared.
*/
preparePlatform(platform: string, appFilesUpdaterOptions: IAppFilesUpdaterOptions, platformTemplate: string, projectData: IProjectData, config: IAddPlatformCoreOptions, filesToSync?: Array<String>, nativePrepare?: INativePrepare): Promise<boolean>;
preparePlatform(platform: string, appFilesUpdaterOptions: IAppFilesUpdaterOptions, platformTemplate: string, projectData: IProjectData, config: IPlatformOptions, filesToSync?: Array<String>, nativePrepare?: INativePrepare): Promise<boolean>;

/**
* Determines whether a build is necessary. A build is necessary when one of the following is true:
Expand Down Expand Up @@ -113,7 +113,7 @@ interface IPlatformService extends NodeJS.EventEmitter {
* @param {IAddPlatformCoreOptions} config Options required for project preparation/creation.
* @returns {void}
*/
deployPlatform(platform: string, appFilesUpdaterOptions: IAppFilesUpdaterOptions, deployOptions: IDeployPlatformOptions, projectData: IProjectData, config: IAddPlatformCoreOptions): Promise<void>;
deployPlatform(platform: string, appFilesUpdaterOptions: IAppFilesUpdaterOptions, deployOptions: IDeployPlatformOptions, projectData: IProjectData, config: IPlatformOptions): Promise<void>;

/**
* Runs the application on specified platform. Assumes that the application is already build and installed. Fails if this is not true.
Expand All @@ -124,7 +124,7 @@ interface IPlatformService extends NodeJS.EventEmitter {
*/
startApplication(platform: string, runOptions: IRunPlatformOptions, projectId: string): Promise<void>;

cleanDestinationApp(platform: string, appFilesUpdaterOptions: IAppFilesUpdaterOptions, platformTemplate: string, projectData: IProjectData, config: IAddPlatformCoreOptions): Promise<void>;
cleanDestinationApp(platform: string, appFilesUpdaterOptions: IAppFilesUpdaterOptions, platformTemplate: string, projectData: IProjectData, config: IPlatformOptions): Promise<void>;
validatePlatformInstalled(platform: string, projectData: IProjectData): void;

/**
Expand Down Expand Up @@ -213,17 +213,12 @@ interface IPlatformService extends NodeJS.EventEmitter {
saveBuildInfoFile(platform: string, projectDir: string, buildInfoFileDirname: string): void
}

interface IAddPlatformCoreOptions extends IPlatformSpecificData, ICreateProjectOptions { }
interface IPlatformOptions extends IPlatformSpecificData, ICreateProjectOptions { }

/**
* Platform specific data required for project preparation.
*/
interface IPlatformSpecificData {
/**
* UUID of the provisioning profile used in iOS project preparation.
*/
provision: any;

interface IPlatformSpecificData extends IProvision {
/**
* Target SDK for Android.
*/
Expand Down
4 changes: 0 additions & 4 deletions lib/definitions/project.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -155,10 +155,6 @@ interface IiOSBuildConfig extends IBuildForDevice, IDeviceIdentifier, IProvision
* Code sign identity used for build. If not set iPhone Developer is used as a default when building for device.
*/
codeSignIdentity?: string;
/**
* Team identifier.
*/
teamIdentifier?: string;
}

interface IPlatformProjectService extends NodeJS.EventEmitter {
Expand Down
17 changes: 11 additions & 6 deletions lib/services/ios-project-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -396,8 +396,8 @@ export class IOSProjectService extends projectServiceBaseLib.PlatformProjectServ
args.push(`PROVISIONING_PROFILE=${buildConfig.mobileProvisionIdentifier}`);
}

if (buildConfig && buildConfig.teamIdentifier) {
args.push(`DEVELOPMENT_TEAM=${buildConfig.teamIdentifier}`);
if (buildConfig && buildConfig.teamId) {
args.push(`DEVELOPMENT_TEAM=${buildConfig.teamId}`);
}

// this.$logger.out("xcodebuild...");
Expand Down Expand Up @@ -470,12 +470,14 @@ export class IOSProjectService extends projectServiceBaseLib.PlatformProjectServ
xcode.setManualSigningStyle(projectData.projectName);
xcode.save();
} else if (!buildConfig.provision && !(signing && signing.style === "Manual" && !buildConfig.teamId)) {
if (buildConfig) {
delete buildConfig.teamIdentifier;
}

const teamId = await this.getDevelopmentTeam(projectData, buildConfig.teamId);

// Remove teamId from build config as we'll set the signing in Xcode project directly.
// In case we do not remove it, we'll pass DEVELOPMENT_TEAM=<team id> to xcodebuild, which is unnecessary.
if (buildConfig.teamId) {
delete buildConfig.teamId;
}

xcode.setAutomaticSigningStyle(projectData.projectName, teamId);
xcode.save();
this.$logger.trace("Set Automatic signing style and team.");
Expand Down Expand Up @@ -1328,6 +1330,9 @@ We will now place an empty obsolete compatability white screen LauncScreen.xib f
}
}
}

this.$logger.trace(`Selected teamId is '${teamId}'.`);

return teamId;
}

Expand Down
2 changes: 2 additions & 0 deletions lib/services/livesync/livesync-command-helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ export class LiveSyncCommandHelper implements ILiveSyncCommandHelper {
.map(d => {
const info: ILiveSyncDeviceInfo = {
identifier: d.deviceInfo.identifier,
platformSpecificOptions: this.$options,

buildAction: async (): Promise<string> => {
const buildConfig: IBuildConfig = {
buildForDevice: !d.isEmulator,
Expand Down
11 changes: 7 additions & 4 deletions lib/services/livesync/livesync-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -165,11 +165,12 @@ export class LiveSyncService extends EventEmitter implements ILiveSyncService {
const appInstalledOnDeviceResult: IAppInstalledOnDeviceResult = { appInstalled: false };
if (options.preparedPlatforms.indexOf(platform) === -1) {
options.preparedPlatforms.push(platform);
// TODO: Pass provision and sdk as a fifth argument here

const platformSpecificOptions = options.deviceBuildInfoDescriptor.platformSpecificOptions || <IPlatformOptions>{};
await this.$platformService.preparePlatform(platform, {
bundle: false,
release: false,
}, null, options.projectData, <any>{}, options.modifiedFiles, nativePrepare);
}, null, options.projectData, platformSpecificOptions, options.modifiedFiles, nativePrepare);
}

const buildResult = await this.installedCachedAppPackage(platform, options);
Expand All @@ -178,8 +179,10 @@ export class LiveSyncService extends EventEmitter implements ILiveSyncService {
return appInstalledOnDeviceResult;
}

// TODO: Pass provision and sdk as a fifth argument here
const shouldBuild = await this.$platformService.shouldBuild(platform, options.projectData, <any>{ buildForDevice: !options.device.isEmulator, clean: options.liveSyncData && options.liveSyncData.clean }, options.deviceBuildInfoDescriptor.outputPath);
const shouldBuild = await this.$platformService.shouldBuild(platform,
options.projectData,
<any>{ buildForDevice: !options.device.isEmulator, clean: options.liveSyncData && options.liveSyncData.clean },
options.deviceBuildInfoDescriptor.outputPath);
let pathToBuildItem = null;
let action = LiveSyncTrackActionNames.LIVESYNC_OPERATION;
if (shouldBuild) {
Expand Down
26 changes: 13 additions & 13 deletions lib/services/platform-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ export class PlatformService extends EventEmitter implements IPlatformService {
super();
}

public async cleanPlatforms(platforms: string[], platformTemplate: string, projectData: IProjectData, config: IAddPlatformCoreOptions, framworkPath?: string): Promise<void> {
public async cleanPlatforms(platforms: string[], platformTemplate: string, projectData: IProjectData, config: IPlatformOptions, framworkPath?: string): Promise<void> {
for (let platform of platforms) {
let version: string = this.getCurrentPlatformVersion(platform, projectData);

Expand All @@ -57,7 +57,7 @@ export class PlatformService extends EventEmitter implements IPlatformService {
}
}

public async addPlatforms(platforms: string[], platformTemplate: string, projectData: IProjectData, config: IAddPlatformCoreOptions, frameworkPath?: string): Promise<void> {
public async addPlatforms(platforms: string[], platformTemplate: string, projectData: IProjectData, config: IPlatformOptions, frameworkPath?: string): Promise<void> {
const platformsDir = projectData.platformsDir;
this.$fs.ensureDirectoryExists(platformsDir);

Expand All @@ -84,7 +84,7 @@ export class PlatformService extends EventEmitter implements IPlatformService {
return version;
}

private async addPlatform(platformParam: string, platformTemplate: string, projectData: IProjectData, config: IAddPlatformCoreOptions, frameworkPath?: string, nativePrepare?: INativePrepare): Promise<void> {
private async addPlatform(platformParam: string, platformTemplate: string, projectData: IProjectData, config: IPlatformOptions, frameworkPath?: string, nativePrepare?: INativePrepare): Promise<void> {
let data = platformParam.split("@"),
platform = data[0].toLowerCase(),
version = data[1];
Expand Down Expand Up @@ -137,7 +137,7 @@ export class PlatformService extends EventEmitter implements IPlatformService {
this.$logger.out("Project successfully created.");
}

private async addPlatformCore(platformData: IPlatformData, frameworkDir: string, platformTemplate: string, projectData: IProjectData, config: IAddPlatformCoreOptions, nativePrepare?: INativePrepare): Promise<string> {
private async addPlatformCore(platformData: IPlatformData, frameworkDir: string, platformTemplate: string, projectData: IProjectData, config: IPlatformOptions, nativePrepare?: INativePrepare): Promise<string> {
const coreModuleData = this.$fs.readJson(path.join(frameworkDir, "..", "package.json"));
const installedVersion = coreModuleData.version;
const customTemplateOptions = await this.getPathToPlatformTemplate(platformTemplate, platformData.frameworkPackageName, projectData.projectDir);
Expand All @@ -159,7 +159,7 @@ export class PlatformService extends EventEmitter implements IPlatformService {

}

private async addPlatformCoreNative(platformData: IPlatformData, frameworkDir: string, installedVersion: string, projectData: IProjectData, config: IAddPlatformCoreOptions): Promise<void> {
private async addPlatformCoreNative(platformData: IPlatformData, frameworkDir: string, installedVersion: string, projectData: IProjectData, config: IPlatformOptions): Promise<void> {
await platformData.platformProjectService.createProject(path.resolve(frameworkDir), installedVersion, projectData, config);
platformData.platformProjectService.ensureConfigurationFileInAppResources(projectData);
await platformData.platformProjectService.interpolateData(projectData, config);
Expand Down Expand Up @@ -213,7 +213,7 @@ export class PlatformService extends EventEmitter implements IPlatformService {
public getPreparedPlatforms(projectData: IProjectData): string[] {
return _.filter(this.$platformsData.platformsNames, p => { return this.isPlatformPrepared(p, projectData); });
}
public async preparePlatform(platform: string, appFilesUpdaterOptions: IAppFilesUpdaterOptions, platformTemplate: string, projectData: IProjectData, config: IAddPlatformCoreOptions, filesToSync?: Array<String>, nativePrepare?: INativePrepare): Promise<boolean> {
public async preparePlatform(platform: string, appFilesUpdaterOptions: IAppFilesUpdaterOptions, platformTemplate: string, projectData: IProjectData, config: IPlatformOptions, filesToSync?: Array<String>, nativePrepare?: INativePrepare): Promise<boolean> {
const platformData = this.$platformsData.getPlatformData(platform, projectData);
const changesInfo = await this.initialPrepare(platform, platformData, appFilesUpdaterOptions, platformTemplate, projectData, config, nativePrepare);
const requiresNativePrepare = (!nativePrepare || !nativePrepare.skipNativePrepare) && changesInfo.nativePlatformStatus === constants.NativePlatformStatus.requiresPrepare;
Expand Down Expand Up @@ -265,7 +265,7 @@ export class PlatformService extends EventEmitter implements IPlatformService {
}
}

private async initialPrepare(platform: string, platformData: IPlatformData, appFilesUpdaterOptions: IAppFilesUpdaterOptions, platformTemplate: string, projectData: IProjectData, config: IAddPlatformCoreOptions, nativePrepare?: INativePrepare): Promise<IProjectChangesInfo> {
private async initialPrepare(platform: string, platformData: IPlatformData, appFilesUpdaterOptions: IAppFilesUpdaterOptions, platformTemplate: string, projectData: IProjectData, config: IPlatformOptions, nativePrepare?: INativePrepare): Promise<IProjectChangesInfo> {
this.validatePlatform(platform, projectData);

await this.trackProjectType(projectData);
Expand Down Expand Up @@ -532,7 +532,7 @@ export class PlatformService extends EventEmitter implements IPlatformService {
this.$logger.out(`Successfully installed on device with identifier '${device.deviceInfo.identifier}'.`);
}

public async deployPlatform(platform: string, appFilesUpdaterOptions: IAppFilesUpdaterOptions, deployOptions: IDeployPlatformOptions, projectData: IProjectData, config: IAddPlatformCoreOptions): Promise<void> {
public async deployPlatform(platform: string, appFilesUpdaterOptions: IAppFilesUpdaterOptions, deployOptions: IDeployPlatformOptions, projectData: IProjectData, config: IPlatformOptions): Promise<void> {
await this.preparePlatform(platform, appFilesUpdaterOptions, deployOptions.platformTemplate, projectData, config);
let options: Mobile.IDevicesServicesInitializationOptions = {
platform: platform, deviceId: deployOptions.device, emulator: deployOptions.emulator
Expand Down Expand Up @@ -623,7 +623,7 @@ export class PlatformService extends EventEmitter implements IPlatformService {
return null;
}

public async cleanDestinationApp(platform: string, appFilesUpdaterOptions: IAppFilesUpdaterOptions, platformTemplate: string, projectData: IProjectData, config: IAddPlatformCoreOptions): Promise<void> {
public async cleanDestinationApp(platform: string, appFilesUpdaterOptions: IAppFilesUpdaterOptions, platformTemplate: string, projectData: IProjectData, config: IPlatformOptions): Promise<void> {
await this.ensurePlatformInstalled(platform, platformTemplate, projectData, config);

const appSourceDirectoryPath = path.join(projectData.projectDir, constants.APP_FOLDER_NAME);
Expand Down Expand Up @@ -679,7 +679,7 @@ export class PlatformService extends EventEmitter implements IPlatformService {
}
}

public async updatePlatforms(platforms: string[], platformTemplate: string, projectData: IProjectData, config: IAddPlatformCoreOptions): Promise<void> {
public async updatePlatforms(platforms: string[], platformTemplate: string, projectData: IProjectData, config: IPlatformOptions): Promise<void> {
for (let platformParam of platforms) {
let data = platformParam.split("@"),
platform = data[0],
Expand Down Expand Up @@ -736,7 +736,7 @@ export class PlatformService extends EventEmitter implements IPlatformService {
}
}

public async ensurePlatformInstalled(platform: string, platformTemplate: string, projectData: IProjectData, config: IAddPlatformCoreOptions, nativePrepare?: INativePrepare): Promise<void> {
public async ensurePlatformInstalled(platform: string, platformTemplate: string, projectData: IProjectData, config: IPlatformOptions, nativePrepare?: INativePrepare): Promise<void> {
let requiresNativePlatformAdd = false;

if (!this.isPlatformInstalled(platform, projectData)) {
Expand Down Expand Up @@ -808,7 +808,7 @@ export class PlatformService extends EventEmitter implements IPlatformService {
return this.getLatestApplicationPackage(outputPath || platformData.emulatorBuildOutputPath || platformData.deviceBuildOutputPath, platformData.getValidPackageNames({ isForDevice: false, isReleaseBuild: buildConfig.release }));
}

private async updatePlatform(platform: string, version: string, platformTemplate: string, projectData: IProjectData, config: IAddPlatformCoreOptions): Promise<void> {
private async updatePlatform(platform: string, version: string, platformTemplate: string, projectData: IProjectData, config: IPlatformOptions): Promise<void> {
let platformData = this.$platformsData.getPlatformData(platform, projectData);

let data = this.$projectDataService.getNSValue(projectData.projectDir, platformData.frameworkPackageName);
Expand Down Expand Up @@ -841,7 +841,7 @@ export class PlatformService extends EventEmitter implements IPlatformService {

}

private async updatePlatformCore(platformData: IPlatformData, updateOptions: IUpdatePlatformOptions, projectData: IProjectData, config: IAddPlatformCoreOptions): Promise<void> {
private async updatePlatformCore(platformData: IPlatformData, updateOptions: IUpdatePlatformOptions, projectData: IProjectData, config: IPlatformOptions): Promise<void> {
let packageName = platformData.normalizedPlatformName.toLowerCase();
await this.removePlatforms([packageName], projectData);
packageName = updateOptions.newVersion ? `${packageName}@${updateOptions.newVersion}` : packageName;
Expand Down
2 changes: 1 addition & 1 deletion test/platform-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ class DestinationFolderVerifier {

describe('Platform Service Tests', () => {
let platformService: IPlatformService, testInjector: IInjector;
const config: IAddPlatformCoreOptions = {
const config: IPlatformOptions = {
ignoreScripts: false,
provision: null,
sdk: null,
Expand Down