Skip to content

Commit f9ea810

Browse files
authored
Add secrets to JetpackStatsWidgets (#24565)
* Add secrets to JetpackStatsWidgets * Delete copied code * Add secrets to WordpressShareExtension and WordPressDraftActionExtension * Add secrets to JetpackShareExtension and JetpackDraftActionExtension * Add secrets to JetpackNotificationServiceExtension and WordPressNotificationServiceExtension * Add secrets to JetpackIntents
1 parent 4a7f4f5 commit f9ea810

File tree

6 files changed

+289
-4
lines changed

6 files changed

+289
-4
lines changed

Scripts/BuildPhases/GenerateCredentials.sh

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -60,18 +60,20 @@ EXAMPLE_SECRETS_FILE="${SRCROOT}/Credentials/Secrets-example.swift"
6060
ensure_is_in_input_files_list $EXAMPLE_SECRETS_FILE
6161

6262
# The Secrets file destination
63-
SECRETS_DESTINATION_FILE="${BUILD_DIR}/Secrets/Secrets.swift"
64-
mkdir -p $(dirname "$SECRETS_DESTINATION_FILE")
63+
SECRETS_DESTINATION_FILE="${SCRIPT_OUTPUT_FILE_0}"
64+
mkdir -p "$(dirname "$SECRETS_DESTINATION_FILE")"
6565

66+
WORDPRESS_TARGETS=("WordPress" "WordPressShareExtension" "WordPressDraftActionExtension" "WordPressNotificationServiceExtension")
6667
# If the WordPress Production Secrets are available for WordPress, use them
67-
if [ -f "$WORDPRESS_SECRETS_FILE" ] && [ "${TARGET_NAME}" == "WordPress" ]; then
68+
if [ -f "$WORDPRESS_SECRETS_FILE" ] && [[ " ${WORDPRESS_TARGETS[*]} " == *" $TARGET_NAME "* ]]; then
6869
echo "Applying Production Secrets"
6970
cp -v "$WORDPRESS_SECRETS_FILE" "${SECRETS_DESTINATION_FILE}"
7071
exit 0
7172
fi
7273

74+
JETPACK_TARGETS=("Jetpack" "JetpackStatsWidgets" "JetpackShareExtension" "JetpackDraftActionExtension" "JetpackNotificationServiceExtension" "JetpackIntents")
7375
# If the Jetpack Secrets are available and if we're building Jetpack use them
74-
if [ -f "$JETPACK_SECRETS_FILE" ] && [ "${TARGET_NAME}" == "Jetpack" ]; then
76+
if [ -f "$JETPACK_SECRETS_FILE" ] && [[ " ${JETPACK_TARGETS[*]} " == *" $TARGET_NAME "* ]]; then
7577
echo "Applying Jetpack Secrets"
7678
cp -v "$JETPACK_SECRETS_FILE" "${SECRETS_DESTINATION_FILE}"
7779
exit 0

Sources/JetpackStatsWidgets/Sources/StatsWidgets.swift

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,13 @@
11
import SwiftUI
22
import WidgetKit
3+
import BuildSettingsKit
34

45
@main
56
struct JetpackStatsWidgets: WidgetBundle {
7+
init() {
8+
BuildSettings.configure(secrets: ApiCredentials.toSecrets())
9+
}
10+
611
var body: some Widget {
712
HomeWidgetToday()
813
HomeWidgetThisWeek()

WordPress/JetpackIntents/IntentHandler.swift

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,16 @@
11
import Intents
2+
import BuildSettingsKit
23

34
class IntentHandler: INExtension, SelectSiteIntentHandling {
45

56
let sitesDataProvider = SitesDataProvider()
67

8+
override init() {
9+
super.init()
10+
11+
BuildSettings.configure(secrets: ApiCredentials.toSecrets())
12+
}
13+
714
// MARK: - INIntentHandlerProviding
815

916
override func handler(for intent: INIntent) -> Any {

0 commit comments

Comments
 (0)