Skip to content

Commit

Permalink
Adds enterprise support
Browse files Browse the repository at this point in the history
Allows sign-here to use a flag into it execution to enable enterprise support
  • Loading branch information
tinder-maxwellelliott committed Aug 20, 2024
1 parent f8f1317 commit f22ee30
Show file tree
Hide file tree
Showing 18 changed files with 226 additions and 107 deletions.
4 changes: 3 additions & 1 deletion .bazelrc
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
common --enable_bzlmod

build --incompatible_disallow_empty_glob
build --apple_platform_type=macos
build --incompatible_strict_action_env
Expand All @@ -8,4 +10,4 @@ build --crosstool_top=@local_config_apple_cc//:toolchain
build --host_crosstool_top=@local_config_apple_cc//:toolchain
test --test_output=errors
test --test_summary=detailed
common --enable_bzlmod
test:record_snapshots --spawn_strategy=local
8 changes: 4 additions & 4 deletions MODULE.bazel.lock

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

7 changes: 7 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
.PHONY: record_snapshots
record_snapshots:
bazel test //Tests/... \
--config=record_snapshots \
--test_env=BUILD_WORKSPACE_DIRECTORY=$$(pwd) \
--test_env=SNAPSHOT_DIRECTORY="$$(pwd)/Tests/SignHereLibraryTests" \
--test_env=RERECORD_SNAPSHOTS=TRUE
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ internal struct CreateProvisioningProfileCommand: ParsableCommand {
case certificateSigningRequestSubject = "certificateSigningRequestSubject"
case profileName = "profileName"
case autoRegenerate = "autoRegenerate"
case enterprise = "enterprise"
}

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

@Flag(help: "Controls if the enterprise API should be used.")
internal var enterprise: Bool = false

private let files: Files
private let log: Log
private let shell: Shell
Expand All @@ -206,10 +210,7 @@ internal struct CreateProvisioningProfileCommand: ParsableCommand {
shell = shellImp
uuid = UUIDImp()
iTunesConnectService = iTunesConnectServiceImp(
network: NetworkImp(),
files: filesImp,
shell: shellImp,
clock: clockImp
enterprise: false
)
}

Expand All @@ -236,7 +237,8 @@ internal struct CreateProvisioningProfileCommand: ParsableCommand {
bundleIdentifierName: String?,
platform: String,
profileName: String?,
autoRegenerate: Bool
autoRegenerate: Bool,
enterprise: Bool
) {
self.files = files
self.log = log
Expand All @@ -261,24 +263,23 @@ internal struct CreateProvisioningProfileCommand: ParsableCommand {
self.platform = platform
self.profileName = profileName
self.autoRegenerate = autoRegenerate
self.enterprise = enterprise
}

internal init(from decoder: Decoder) throws {
let filesImp: Files = FilesImp()
let clockImp: Clock = ClockImp()
let shellImp: Shell = ShellImp()
let container: KeyedDecodingContainer<CodingKeys> = try decoder.container(keyedBy: CodingKeys.self)
let enterprise: Bool = try container.decode(Bool.self, forKey: .enterprise)
self.init(
files: filesImp,
log: LogImp(),
jsonWebTokenService: JSONWebTokenServiceImp(clock: clockImp),
shell: shellImp,
uuid: UUIDImp(),
iTunesConnectService: iTunesConnectServiceImp(
network: NetworkImp(),
files: filesImp,
shell: shellImp,
clock: clockImp
enterprise: enterprise
),
keyIdentifier: try container.decode(String.self, forKey: .keyIdentifier),
issuerID: try container.decode(String.self, forKey: .issuerID),
Expand All @@ -296,7 +297,8 @@ internal struct CreateProvisioningProfileCommand: ParsableCommand {
bundleIdentifierName: try container.decodeIfPresent(String.self, forKey: .bundleIdentifierName),
platform: try container.decode(String.self, forKey: .platform),
profileName: try container.decodeIfPresent(String.self, forKey: .profileName),
autoRegenerate: try container.decode(Bool.self, forKey: .autoRegenerate)
autoRegenerate: try container.decode(Bool.self, forKey: .autoRegenerate),
enterprise: enterprise
)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ internal struct DeleteProvisioningProfileCommand: ParsableCommand {
case keyIdentifier = "keyIdentifier"
case issuerID = "issuerID"
case itunesConnectKeyPath = "itunesConnectKeyPath"
case enterprise = "enterprise"
}

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

@Flag(help: "Controls if the enterprise API should be used.")
internal var enterprise: Bool = false

private let files: Files
private let jsonWebTokenService: JSONWebTokenService
private let iTunesConnectService: iTunesConnectService
Expand All @@ -47,10 +51,7 @@ internal struct DeleteProvisioningProfileCommand: ParsableCommand {
files = filesImp
jsonWebTokenService = JSONWebTokenServiceImp(clock: ClockImp())
iTunesConnectService = iTunesConnectServiceImp(
network: NetworkImp(),
files: filesImp,
shell: ShellImp(),
clock: ClockImp()
enterprise: false
)
}

Expand All @@ -61,7 +62,8 @@ internal struct DeleteProvisioningProfileCommand: ParsableCommand {
provisioningProfileId: String,
keyIdentifier: String,
issuerID: String,
itunesConnectKeyPath: String
itunesConnectKeyPath: String,
enterprise: Bool
) {
self.files = files
self.jsonWebTokenService = jsonWebTokenService
Expand All @@ -70,24 +72,24 @@ internal struct DeleteProvisioningProfileCommand: ParsableCommand {
self.keyIdentifier = keyIdentifier
self.issuerID = issuerID
self.itunesConnectKeyPath = itunesConnectKeyPath
self.enterprise = enterprise
}

internal init(from decoder: Decoder) throws {
let filesImp: Files = FilesImp()
let container: KeyedDecodingContainer<CodingKeys> = try decoder.container(keyedBy: CodingKeys.self)
let enterprise: Bool = try container.decode(Bool.self, forKey: .enterprise)
self.init(
files: filesImp,
jsonWebTokenService: JSONWebTokenServiceImp(clock: ClockImp()),
iTunesConnectService: iTunesConnectServiceImp(
network: NetworkImp(),
files: filesImp,
shell: ShellImp(),
clock: ClockImp()
enterprise: enterprise
),
provisioningProfileId: try container.decode(String.self, forKey: .provisioningProfileId),
keyIdentifier: try container.decode(String.self, forKey: .keyIdentifier),
issuerID: try container.decode(String.self, forKey: .issuerID),
itunesConnectKeyPath: try container.decode(String.self, forKey: .itunesConnectKeyPath)
itunesConnectKeyPath: try container.decode(String.self, forKey: .itunesConnectKeyPath),
enterprise: enterprise
)
}

Expand Down
Loading

0 comments on commit f22ee30

Please sign in to comment.