diff --git a/platforms/android/scripts/check_license_headers.rb b/platforms/android/scripts/check_license_headers.rb index 93b52778..12f59f30 100755 --- a/platforms/android/scripts/check_license_headers.rb +++ b/platforms/android/scripts/check_license_headers.rb @@ -4,7 +4,10 @@ files = [] Find.find('.') do |path| - next if path.include?('build/generated') + if File.directory?(path) && ['.gradle', 'build'].include?(File.basename(path)) + Find.prune + end + next unless File.file?(path) && path.end_with?('.kt') lines = File.readlines(path) diff --git a/platforms/react-native/modules/@shopify/checkout-kit-react-native/ios/AcceleratedCheckoutButtons.swift b/platforms/react-native/modules/@shopify/checkout-kit-react-native/ios/AcceleratedCheckoutButtons.swift index 31f03ccc..49336c74 100644 --- a/platforms/react-native/modules/@shopify/checkout-kit-react-native/ios/AcceleratedCheckoutButtons.swift +++ b/platforms/react-native/modules/@shopify/checkout-kit-react-native/ios/AcceleratedCheckoutButtons.swift @@ -160,8 +160,8 @@ class RCTAcceleratedCheckoutButtonsView: UIView { hostingController?.view.frame = bounds } - // Deprecated in iOS 17 — superseded by registerForTraitChanges in setupView(). - // Remove this override when dropping iOS 16 support. + /// Deprecated in iOS 17 — superseded by registerForTraitChanges in setupView(). + /// Remove this override when dropping iOS 16 support. override func traitCollectionDidChange(_ previousTraitCollection: UITraitCollection?) { super.traitCollectionDidChange(previousTraitCollection) if #unavailable(iOS 17.0) { diff --git a/platforms/react-native/modules/@shopify/checkout-kit-react-native/ios/ShopifyCheckoutKit.swift b/platforms/react-native/modules/@shopify/checkout-kit-react-native/ios/ShopifyCheckoutKit.swift index 58a6f43c..950f7104 100644 --- a/platforms/react-native/modules/@shopify/checkout-kit-react-native/ios/ShopifyCheckoutKit.swift +++ b/platforms/react-native/modules/@shopify/checkout-kit-react-native/ios/ShopifyCheckoutKit.swift @@ -65,34 +65,34 @@ class RCTShopifyCheckoutKit: RCTEventEmitter { hasListeners = false } - // TODO: re-enable when iOS CheckoutDelegate (or equivalent) lands upstream — + // TODO: re-enable when iOS CheckoutDelegate (or equivalent) lands upstream - // parallels Android's DefaultCheckoutListener.onCheckoutCanceled / onCheckoutFailed. // Until then, the JS "error" and "close" events stay declared in supportedEvents() // but native never emits them. /* - func shouldRecoverFromError(error: CheckoutError) -> Bool { - return error.isRecoverable - } + func shouldRecoverFromError(error: CheckoutError) -> Bool { + return error.isRecoverable + } - func checkoutDidFail(error: CheckoutError) { - guard hasListeners else { return } + func checkoutDidFail(error: CheckoutError) { + guard hasListeners else { return } - sendEvent(withName: "error", body: ShopifyEventSerialization.serialize(checkoutError: error)) - } + sendEvent(withName: "error", body: ShopifyEventSerialization.serialize(checkoutError: error)) + } - func checkoutDidCancel() { - DispatchQueue.main.async { - if self.hasListeners { - self.sendEvent(withName: "close", body: nil) - } + func checkoutDidCancel() { + DispatchQueue.main.async { + if self.hasListeners { + self.sendEvent(withName: "close", body: nil) + } - self.checkoutSheet?.dismiss(animated: true) - } - } + self.checkoutSheet?.dismiss(animated: true) + } + } - func checkoutDidEmitWebPixelEvent(event _: PixelEvent) {} - */ + func checkoutDidEmitWebPixelEvent(event _: PixelEvent) {} + */ @objc override func constantsToExport() -> [AnyHashable: Any]! { return [ @@ -150,7 +150,7 @@ class RCTShopifyCheckoutKit: RCTEventEmitter { } } - @objc func preload(_ checkoutURL: String) { + @objc func preload(_: String) { // Public native preload support is not exposed by the local iOS SDK. } diff --git a/platforms/react-native/sample/src/screens/SettingsScreen.tsx b/platforms/react-native/sample/src/screens/SettingsScreen.tsx index 29f9b6d4..f25ff376 100644 --- a/platforms/react-native/sample/src/screens/SettingsScreen.tsx +++ b/platforms/react-native/sample/src/screens/SettingsScreen.tsx @@ -441,7 +441,7 @@ function BuyerIdentityDetails({ if (authenticated) { return ( - + Changing Buyer Identity will log you out. @@ -538,6 +538,9 @@ function createStyles(colors: Colors) { fontSize: 12, color: '#007AFF', }, + warningText: { + color: '#f5a623', + }, }); } diff --git a/platforms/react-native/scripts/lint_swift b/platforms/react-native/scripts/lint_swift index d909a495..6490ab24 100755 --- a/platforms/react-native/scripts/lint_swift +++ b/platforms/react-native/scripts/lint_swift @@ -2,6 +2,9 @@ DIR=modules/@shopify/checkout-kit-react-native MODE="${1:-check}" +SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" +REPO_ROOT="$(git -C "$SCRIPT_DIR" rev-parse --show-toplevel)" +SWIFT_TOOLS_DIR="$REPO_ROOT/platforms/swift" # Validate the mode if [[ "$MODE" != "check" && "$MODE" != "fix" ]]; then @@ -16,20 +19,33 @@ fi print_install_instructions() { echo "🔧 FIX:" echo " Shopify employee? Run 'dev up'" - echo " Not a Shopify employee? Install via homebrew:" - echo " - SwiftLint: 'brew install swiftlint' / https://github.com/realm/SwiftLint" - echo " - SwiftFormat: 'brew install swiftformat' / https://github.com/nicklockwood/SwiftFormat" + echo " Not a Shopify employee? Install Mint and run 'mint bootstrap' from platforms/swift" + echo " Homebrew also works: 'brew install swiftlint swiftformat'" } -# Check for SwiftLint -if ! which swiftlint >/dev/null; then +resolve_tool() { + local command_name=$1 + + if which "$command_name" >/dev/null; then + which "$command_name" + return 0 + fi + + if command -v mint >/dev/null; then + (cd "$SWIFT_TOOLS_DIR" && mint which "$command_name") + return $? + fi + + return 1 +} + +if ! SWIFTLINT="$(resolve_tool swiftlint)"; then echo "⚠️ WARN: SwiftLint not installed" print_install_instructions exit 1 fi -# Check for SwiftFormat -if ! which swiftformat >/dev/null; then +if ! SWIFTFORMAT="$(resolve_tool swiftformat)"; then echo "⚠️ WARN: SwiftFormat not installed" print_install_instructions exit 1 @@ -38,11 +54,11 @@ fi # Run SwiftLint if [[ "$MODE" == "check" ]]; then echo "🔄 Running SwiftLint in check mode..." - swiftlint lint --strict $DIR --config .swiftlint.yml + "$SWIFTLINT" lint --strict $DIR --config .swiftlint.yml LINT_STATUS=$? else echo "🔄 Running SwiftLint in fix mode..." - swiftlint lint --fix $DIR --config .swiftlint.yml + "$SWIFTLINT" lint --fix $DIR --config .swiftlint.yml LINT_STATUS=$? fi echo "SwiftLint exit status: $LINT_STATUS" @@ -50,11 +66,11 @@ echo "SwiftLint exit status: $LINT_STATUS" # Run SwiftFormat if [[ "$MODE" == "check" ]]; then echo "🔄 Running SwiftFormat in check mode..." - swiftformat $DIR --lint --config .swiftformat + "$SWIFTFORMAT" $DIR --lint --config .swiftformat FORMAT_STATUS=$? else echo "🔄 Running SwiftFormat in fix mode..." - swiftformat $DIR --config .swiftformat + "$SWIFTFORMAT" $DIR --config .swiftformat FORMAT_STATUS=$? fi echo "SwiftFormat exit status: $FORMAT_STATUS" diff --git a/platforms/swift/Scripts/lint b/platforms/swift/Scripts/lint index f1874607..41e38bc5 100755 --- a/platforms/swift/Scripts/lint +++ b/platforms/swift/Scripts/lint @@ -169,6 +169,7 @@ if [[ "$MODE" == "check" && "$SKIP_POD" == "false" ]]; then # platforms/swift/ and protocol/languages/swift/. Run lint from the # repo root. REPO_ROOT="$(git -C "$(dirname "$0")" rev-parse --show-toplevel)" + export BUNDLE_GEMFILE="${BUNDLE_GEMFILE:-$REPO_ROOT/platforms/swift/Gemfile}" POD_LOG="" if [[ "$VERBOSE" == "true" ]]; then (cd "$REPO_ROOT" && bundle exec pod lib lint ShopifyCheckoutKit.podspec --allow-warnings) @@ -188,7 +189,7 @@ if [[ "$MODE" == "check" && "$SKIP_POD" == "false" ]]; then echo "❌ CocoaPods lint exit status: $POD_STATUS" echo "❌ CocoaPods detected issues that need to be fixed." - echo "🔧 Run 'bundle exec pod lib lint ShopifyCheckoutKit.podspec --allow-warnings --verbose' from the repo root for details" + echo "🔧 Run 'BUNDLE_GEMFILE=platforms/swift/Gemfile bundle exec pod lib lint ShopifyCheckoutKit.podspec --allow-warnings --verbose' from the repo root for details" exit 1 fi