pickSigningTeam function
Future<SigningChoice>
pickSigningTeam(
- String projectDir,
- String udid, {
- String? requested,
- ProcessRunner run = boundedRun,
Picks the team to sign projectDir for phone udid: requested, the project's own team, the one remembered here, the only one, or the one already provisioned for this app; throws SigningUndecided otherwise.
Implementation
Future<SigningChoice> pickSigningTeam(String projectDir, String udid,
{String? requested, ProcessRunner run = boundedRun}) async {
final local = await localTeams(run: run);
final own = projectTeam(projectDir);
List<String> others(String team) => [
for (final t in local)
if (t != team) t
];
if (requested != null) return (team: requested, why: 'signingTeam asked for it', others: others(requested));
if (own != null && local.contains(own)) return (team: own, why: 'the project names it', others: others(own));
final remembered = rememberedTeam();
if (remembered != null && local.contains(remembered)) {
return (
team: remembered,
why:
'glint signed with it last time on this Mac${own == null ? '' : ' (the project names $own, which has no certificate here)'}',
others: others(remembered)
);
}
if (local.length == 1) {
return (team: local.single, why: 'it is the only team with a certificate on this Mac', others: const <String>[]);
}
final bundle = projectBundleId(projectDir);
final provisioned = bundle == null ? const <String>[] : await teamsWithProfile(udid, bundle, run: run);
if (provisioned.length == 1) {
return (
team: provisioned.single,
why: 'it already has a profile for $bundle on this phone',
others: others(provisioned.single)
);
}
throw SigningUndecided(local, own);
}