Skip to content

Commit f99762c

Browse files
Fix passing provision to tns run ios and passsing --teamId (#3069)
Passing `--provision` to `tns run <ios>` is not respected. Fix this by including additional option in the deviceDescriptors. This allows us to pass different provisions for each device, however in CLI's commands we'll set one provision for all devices. Also fix passing `--teamId` option - during previous refactoring we've broken the code for it and it has not been respected. Remove the unused alias `teamIdentifier` and use `teamId` in all cases.
1 parent 445b463 commit f99762c

8 files changed

+47
-41
lines changed

lib/definitions/livesync.d.ts

+5
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,11 @@ interface ILiveSyncDeviceInfo {
9494
* Whether to skip preparing the native platform.
9595
*/
9696
skipNativePrepare?: boolean;
97+
98+
/**
99+
* Describes options specific for each platform, like provision for iOS, target sdk for Android, etc.
100+
*/
101+
platformSpecificOptions?: IPlatformOptions;
97102
}
98103

99104
/**

lib/definitions/platform.d.ts

+8-13
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
interface IPlatformService extends NodeJS.EventEmitter {
2-
cleanPlatforms(platforms: string[], platformTemplate: string, projectData: IProjectData, config: IAddPlatformCoreOptions, framework?: string): Promise<void>;
2+
cleanPlatforms(platforms: string[], platformTemplate: string, projectData: IProjectData, config: IPlatformOptions, framework?: string): Promise<void>;
33

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

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

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

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

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

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

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

130130
/**
@@ -213,17 +213,12 @@ interface IPlatformService extends NodeJS.EventEmitter {
213213
saveBuildInfoFile(platform: string, projectDir: string, buildInfoFileDirname: string): void
214214
}
215215

216-
interface IAddPlatformCoreOptions extends IPlatformSpecificData, ICreateProjectOptions { }
216+
interface IPlatformOptions extends IPlatformSpecificData, ICreateProjectOptions { }
217217

218218
/**
219219
* Platform specific data required for project preparation.
220220
*/
221-
interface IPlatformSpecificData {
222-
/**
223-
* UUID of the provisioning profile used in iOS project preparation.
224-
*/
225-
provision: any;
226-
221+
interface IPlatformSpecificData extends IProvision {
227222
/**
228223
* Target SDK for Android.
229224
*/

lib/definitions/project.d.ts

-4
Original file line numberDiff line numberDiff line change
@@ -155,10 +155,6 @@ interface IiOSBuildConfig extends IBuildForDevice, IDeviceIdentifier, IProvision
155155
* Code sign identity used for build. If not set iPhone Developer is used as a default when building for device.
156156
*/
157157
codeSignIdentity?: string;
158-
/**
159-
* Team identifier.
160-
*/
161-
teamIdentifier?: string;
162158
}
163159

164160
interface IPlatformProjectService extends NodeJS.EventEmitter {

lib/services/ios-project-service.ts

+11-6
Original file line numberDiff line numberDiff line change
@@ -396,8 +396,8 @@ export class IOSProjectService extends projectServiceBaseLib.PlatformProjectServ
396396
args.push(`PROVISIONING_PROFILE=${buildConfig.mobileProvisionIdentifier}`);
397397
}
398398

399-
if (buildConfig && buildConfig.teamIdentifier) {
400-
args.push(`DEVELOPMENT_TEAM=${buildConfig.teamIdentifier}`);
399+
if (buildConfig && buildConfig.teamId) {
400+
args.push(`DEVELOPMENT_TEAM=${buildConfig.teamId}`);
401401
}
402402

403403
// this.$logger.out("xcodebuild...");
@@ -470,12 +470,14 @@ export class IOSProjectService extends projectServiceBaseLib.PlatformProjectServ
470470
xcode.setManualSigningStyle(projectData.projectName);
471471
xcode.save();
472472
} else if (!buildConfig.provision && !(signing && signing.style === "Manual" && !buildConfig.teamId)) {
473-
if (buildConfig) {
474-
delete buildConfig.teamIdentifier;
475-
}
476-
477473
const teamId = await this.getDevelopmentTeam(projectData, buildConfig.teamId);
478474

475+
// Remove teamId from build config as we'll set the signing in Xcode project directly.
476+
// In case we do not remove it, we'll pass DEVELOPMENT_TEAM=<team id> to xcodebuild, which is unnecessary.
477+
if (buildConfig.teamId) {
478+
delete buildConfig.teamId;
479+
}
480+
479481
xcode.setAutomaticSigningStyle(projectData.projectName, teamId);
480482
xcode.save();
481483
this.$logger.trace("Set Automatic signing style and team.");
@@ -1328,6 +1330,9 @@ We will now place an empty obsolete compatability white screen LauncScreen.xib f
13281330
}
13291331
}
13301332
}
1333+
1334+
this.$logger.trace(`Selected teamId is '${teamId}'.`);
1335+
13311336
return teamId;
13321337
}
13331338

lib/services/livesync/livesync-command-helper.ts

+2
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@ export class LiveSyncCommandHelper implements ILiveSyncCommandHelper {
4040
.map(d => {
4141
const info: ILiveSyncDeviceInfo = {
4242
identifier: d.deviceInfo.identifier,
43+
platformSpecificOptions: this.$options,
44+
4345
buildAction: async (): Promise<string> => {
4446
const buildConfig: IBuildConfig = {
4547
buildForDevice: !d.isEmulator,

lib/services/livesync/livesync-service.ts

+7-4
Original file line numberDiff line numberDiff line change
@@ -165,11 +165,12 @@ export class LiveSyncService extends EventEmitter implements ILiveSyncService {
165165
const appInstalledOnDeviceResult: IAppInstalledOnDeviceResult = { appInstalled: false };
166166
if (options.preparedPlatforms.indexOf(platform) === -1) {
167167
options.preparedPlatforms.push(platform);
168-
// TODO: Pass provision and sdk as a fifth argument here
168+
169+
const platformSpecificOptions = options.deviceBuildInfoDescriptor.platformSpecificOptions || <IPlatformOptions>{};
169170
await this.$platformService.preparePlatform(platform, {
170171
bundle: false,
171172
release: false,
172-
}, null, options.projectData, <any>{}, options.modifiedFiles, nativePrepare);
173+
}, null, options.projectData, platformSpecificOptions, options.modifiedFiles, nativePrepare);
173174
}
174175

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

181-
// TODO: Pass provision and sdk as a fifth argument here
182-
const shouldBuild = await this.$platformService.shouldBuild(platform, options.projectData, <any>{ buildForDevice: !options.device.isEmulator, clean: options.liveSyncData && options.liveSyncData.clean }, options.deviceBuildInfoDescriptor.outputPath);
182+
const shouldBuild = await this.$platformService.shouldBuild(platform,
183+
options.projectData,
184+
<any>{ buildForDevice: !options.device.isEmulator, clean: options.liveSyncData && options.liveSyncData.clean },
185+
options.deviceBuildInfoDescriptor.outputPath);
183186
let pathToBuildItem = null;
184187
let action = LiveSyncTrackActionNames.LIVESYNC_OPERATION;
185188
if (shouldBuild) {

lib/services/platform-service.ts

+13-13
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ export class PlatformService extends EventEmitter implements IPlatformService {
4343
super();
4444
}
4545

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

@@ -57,7 +57,7 @@ export class PlatformService extends EventEmitter implements IPlatformService {
5757
}
5858
}
5959

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

@@ -84,7 +84,7 @@ export class PlatformService extends EventEmitter implements IPlatformService {
8484
return version;
8585
}
8686

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

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

160160
}
161161

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

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

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

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

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

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

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

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

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

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

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

842842
}
843843

844-
private async updatePlatformCore(platformData: IPlatformData, updateOptions: IUpdatePlatformOptions, projectData: IProjectData, config: IAddPlatformCoreOptions): Promise<void> {
844+
private async updatePlatformCore(platformData: IPlatformData, updateOptions: IUpdatePlatformOptions, projectData: IProjectData, config: IPlatformOptions): Promise<void> {
845845
let packageName = platformData.normalizedPlatformName.toLowerCase();
846846
await this.removePlatforms([packageName], projectData);
847847
packageName = updateOptions.newVersion ? `${packageName}@${updateOptions.newVersion}` : packageName;

test/platform-service.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ class DestinationFolderVerifier {
147147

148148
describe('Platform Service Tests', () => {
149149
let platformService: IPlatformService, testInjector: IInjector;
150-
const config: IAddPlatformCoreOptions = {
150+
const config: IPlatformOptions = {
151151
ignoreScripts: false,
152152
provision: null,
153153
sdk: null,

0 commit comments

Comments
 (0)