Skip to content

Commit f22ee30

Browse files
Adds enterprise support
Allows sign-here to use a flag into it execution to enable enterprise support
1 parent f8f1317 commit f22ee30

18 files changed

+226
-107
lines changed

.bazelrc

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
common --enable_bzlmod
2+
13
build --incompatible_disallow_empty_glob
24
build --apple_platform_type=macos
35
build --incompatible_strict_action_env
@@ -8,4 +10,4 @@ build --crosstool_top=@local_config_apple_cc//:toolchain
810
build --host_crosstool_top=@local_config_apple_cc//:toolchain
911
test --test_output=errors
1012
test --test_summary=detailed
11-
common --enable_bzlmod
13+
test:record_snapshots --spawn_strategy=local

MODULE.bazel.lock

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

Makefile

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
.PHONY: record_snapshots
2+
record_snapshots:
3+
bazel test //Tests/... \
4+
--config=record_snapshots \
5+
--test_env=BUILD_WORKSPACE_DIRECTORY=$$(pwd) \
6+
--test_env=SNAPSHOT_DIRECTORY="$$(pwd)/Tests/SignHereLibraryTests" \
7+
--test_env=RERECORD_SNAPSHOTS=TRUE

Sources/SignHereLibrary/Commands/CreateProvisioningProfileCommand.swift

+12-10
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,7 @@ internal struct CreateProvisioningProfileCommand: ParsableCommand {
126126
case certificateSigningRequestSubject = "certificateSigningRequestSubject"
127127
case profileName = "profileName"
128128
case autoRegenerate = "autoRegenerate"
129+
case enterprise = "enterprise"
129130
}
130131

131132
@Option(help: "The key identifier of the private key (https://developer.apple.com/documentation/appstoreconnectapi/generating_tokens_for_api_requests)")
@@ -189,6 +190,9 @@ internal struct CreateProvisioningProfileCommand: ParsableCommand {
189190
@Flag(help: "Defines if the profile should be regenerated in case it already exists (optional)")
190191
internal var autoRegenerate = false
191192

193+
@Flag(help: "Controls if the enterprise API should be used.")
194+
internal var enterprise: Bool = false
195+
192196
private let files: Files
193197
private let log: Log
194198
private let shell: Shell
@@ -206,10 +210,7 @@ internal struct CreateProvisioningProfileCommand: ParsableCommand {
206210
shell = shellImp
207211
uuid = UUIDImp()
208212
iTunesConnectService = iTunesConnectServiceImp(
209-
network: NetworkImp(),
210-
files: filesImp,
211-
shell: shellImp,
212-
clock: clockImp
213+
enterprise: false
213214
)
214215
}
215216

@@ -236,7 +237,8 @@ internal struct CreateProvisioningProfileCommand: ParsableCommand {
236237
bundleIdentifierName: String?,
237238
platform: String,
238239
profileName: String?,
239-
autoRegenerate: Bool
240+
autoRegenerate: Bool,
241+
enterprise: Bool
240242
) {
241243
self.files = files
242244
self.log = log
@@ -261,24 +263,23 @@ internal struct CreateProvisioningProfileCommand: ParsableCommand {
261263
self.platform = platform
262264
self.profileName = profileName
263265
self.autoRegenerate = autoRegenerate
266+
self.enterprise = enterprise
264267
}
265268

266269
internal init(from decoder: Decoder) throws {
267270
let filesImp: Files = FilesImp()
268271
let clockImp: Clock = ClockImp()
269272
let shellImp: Shell = ShellImp()
270273
let container: KeyedDecodingContainer<CodingKeys> = try decoder.container(keyedBy: CodingKeys.self)
274+
let enterprise: Bool = try container.decode(Bool.self, forKey: .enterprise)
271275
self.init(
272276
files: filesImp,
273277
log: LogImp(),
274278
jsonWebTokenService: JSONWebTokenServiceImp(clock: clockImp),
275279
shell: shellImp,
276280
uuid: UUIDImp(),
277281
iTunesConnectService: iTunesConnectServiceImp(
278-
network: NetworkImp(),
279-
files: filesImp,
280-
shell: shellImp,
281-
clock: clockImp
282+
enterprise: enterprise
282283
),
283284
keyIdentifier: try container.decode(String.self, forKey: .keyIdentifier),
284285
issuerID: try container.decode(String.self, forKey: .issuerID),
@@ -296,7 +297,8 @@ internal struct CreateProvisioningProfileCommand: ParsableCommand {
296297
bundleIdentifierName: try container.decodeIfPresent(String.self, forKey: .bundleIdentifierName),
297298
platform: try container.decode(String.self, forKey: .platform),
298299
profileName: try container.decodeIfPresent(String.self, forKey: .profileName),
299-
autoRegenerate: try container.decode(Bool.self, forKey: .autoRegenerate)
300+
autoRegenerate: try container.decode(Bool.self, forKey: .autoRegenerate),
301+
enterprise: enterprise
300302
)
301303
}
302304

Sources/SignHereLibrary/Commands/DeleteProvisioningProfileCommand.swift

+12-10
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ internal struct DeleteProvisioningProfileCommand: ParsableCommand {
2424
case keyIdentifier = "keyIdentifier"
2525
case issuerID = "issuerID"
2626
case itunesConnectKeyPath = "itunesConnectKeyPath"
27+
case enterprise = "enterprise"
2728
}
2829

2930
@Option(help: "The iTunes Connect API ID of the provisioning profile to delete (https://developer.apple.com/documentation/appstoreconnectapi/profile)")
@@ -38,6 +39,9 @@ internal struct DeleteProvisioningProfileCommand: ParsableCommand {
3839
@Option(help: "The path to the private key (https://developer.apple.com/documentation/appstoreconnectapi/generating_tokens_for_api_requests)")
3940
internal var itunesConnectKeyPath: String
4041

42+
@Flag(help: "Controls if the enterprise API should be used.")
43+
internal var enterprise: Bool = false
44+
4145
private let files: Files
4246
private let jsonWebTokenService: JSONWebTokenService
4347
private let iTunesConnectService: iTunesConnectService
@@ -47,10 +51,7 @@ internal struct DeleteProvisioningProfileCommand: ParsableCommand {
4751
files = filesImp
4852
jsonWebTokenService = JSONWebTokenServiceImp(clock: ClockImp())
4953
iTunesConnectService = iTunesConnectServiceImp(
50-
network: NetworkImp(),
51-
files: filesImp,
52-
shell: ShellImp(),
53-
clock: ClockImp()
54+
enterprise: false
5455
)
5556
}
5657

@@ -61,7 +62,8 @@ internal struct DeleteProvisioningProfileCommand: ParsableCommand {
6162
provisioningProfileId: String,
6263
keyIdentifier: String,
6364
issuerID: String,
64-
itunesConnectKeyPath: String
65+
itunesConnectKeyPath: String,
66+
enterprise: Bool
6567
) {
6668
self.files = files
6769
self.jsonWebTokenService = jsonWebTokenService
@@ -70,24 +72,24 @@ internal struct DeleteProvisioningProfileCommand: ParsableCommand {
7072
self.keyIdentifier = keyIdentifier
7173
self.issuerID = issuerID
7274
self.itunesConnectKeyPath = itunesConnectKeyPath
75+
self.enterprise = enterprise
7376
}
7477

7578
internal init(from decoder: Decoder) throws {
7679
let filesImp: Files = FilesImp()
7780
let container: KeyedDecodingContainer<CodingKeys> = try decoder.container(keyedBy: CodingKeys.self)
81+
let enterprise: Bool = try container.decode(Bool.self, forKey: .enterprise)
7882
self.init(
7983
files: filesImp,
8084
jsonWebTokenService: JSONWebTokenServiceImp(clock: ClockImp()),
8185
iTunesConnectService: iTunesConnectServiceImp(
82-
network: NetworkImp(),
83-
files: filesImp,
84-
shell: ShellImp(),
85-
clock: ClockImp()
86+
enterprise: enterprise
8687
),
8788
provisioningProfileId: try container.decode(String.self, forKey: .provisioningProfileId),
8889
keyIdentifier: try container.decode(String.self, forKey: .keyIdentifier),
8990
issuerID: try container.decode(String.self, forKey: .issuerID),
90-
itunesConnectKeyPath: try container.decode(String.self, forKey: .itunesConnectKeyPath)
91+
itunesConnectKeyPath: try container.decode(String.self, forKey: .itunesConnectKeyPath),
92+
enterprise: enterprise
9193
)
9294
}
9395

0 commit comments

Comments
 (0)