diff --git a/dev.yml b/dev.yml index 9381dfa0..a738ce19 100644 --- a/dev.yml +++ b/dev.yml @@ -7,6 +7,8 @@ up: - mint - xcbeautify - jq + - swiftlint + - sccache - ruby - custom: name: Install bundle packages @@ -50,6 +52,24 @@ up: ([ -f "./platforms/swift/Samples/MobileBuyIntegration/MobileBuyIntegration/MobileBuyIntegration.entitlements" ] || exit 1;) meet: cd platforms/swift && ./Scripts/setup_entitlements + - node: + version: v22.14.0 + package_manager: pnpm@10.33.1 + packages: + - platforms/react-native + - custom: + name: Install NPM dependencies (React Native) + met?: ls -l platforms/react-native | grep node_modules + meet: cd platforms/react-native && pnpm install + - custom: + name: Install gems (React Native sample) + met?: (cd platforms/react-native/sample/ios && bundle check) + meet: cd platforms/react-native/sample/ios && bundle install + - custom: + name: Install pods (React Native sample) + met?: (cd platforms/react-native/sample/ios && bundle exec pod check --ignore-dev-pods) + meet: cd platforms/react-native && pnpm run pod-install + open: "GitHub": "https://github.com/Shopify/checkout-kit" "Issues": "https://github.com/Shopify/checkout-kit/issues" @@ -60,6 +80,9 @@ check: android-detekt: cd platforms/android && ./gradlew detekt android-lint: cd platforms/android && ./gradlew lintRelease swift-lint: cd platforms/swift && ./Scripts/lint + react-native-lint-swift: cd platforms/react-native && ./scripts/lint_swift + react-native-lint-module: cd platforms/react-native && pnpm module lint + react-native-lint-sample: cd platforms/react-native && pnpm sample lint commands: # Repo-wide @@ -187,3 +210,56 @@ commands: `dev swift test ` - Run only the specified test class. syntax: "[test_class_name]" run: cd platforms/swift && ./Scripts/xcode_run test ShopifyCheckoutKit-Package "$1" + + # React Native + react-native: + desc: "React Native Checkout Kit commands" + aliases: [rn] + subcommands: + server: + desc: Start Metro development server + aliases: [s] + run: cd platforms/react-native && pnpm sample start --reset-cache + ios: + desc: Run the iOS sample app in the simulator + run: cd platforms/react-native && pnpm sample ios + android: + desc: Run the Android sample app in the emulator + run: cd platforms/react-native && pnpm sample android + clean: + desc: Remove generated directories and stop sccache + run: | + cd platforms/react-native + pnpm module clean + pnpm sample clean + pnpm clean + if command -v sccache >/dev/null 2>&1; then + sccache --stop-server 2>/dev/null || true + fi + echo "Cleaned root, module and sample workspaces" + build: + desc: Build the @shopify/checkout-kit-react-native module + run: cd platforms/react-native && pnpm module build + lint: + desc: Run all React Native lint checks (Swift, module, sample) + aliases: [style] + run: | + set -e + cd platforms/react-native + ./scripts/lint_swift + pnpm module lint + pnpm sample lint + subcommands: + swift: + desc: Lint Swift code via SwiftLint + run: cd platforms/react-native && ./scripts/lint_swift + module: + desc: Lint the @shopify/checkout-sheet-kit module + run: cd platforms/react-native && pnpm module lint + sample: + desc: Lint the sample app + run: cd platforms/react-native && pnpm sample lint + format: + desc: Auto-fix Swift lint and format issues + aliases: [fix] + run: cd platforms/react-native && ./scripts/lint_swift fix diff --git a/platforms/react-native/CONTRIBUTING.md b/platforms/react-native/CONTRIBUTING.md index f1b16ed3..612b9ce6 100644 --- a/platforms/react-native/CONTRIBUTING.md +++ b/platforms/react-native/CONTRIBUTING.md @@ -1,7 +1,7 @@ # Contributing We welcome code contributions, feature requests, and reporting of issues. Please -see [guidelines and instructions](.github/CONTRIBUTING.md). +see [guidelines and instructions](../../.github/CONTRIBUTING.md). --- @@ -16,7 +16,10 @@ specific to each workspace. ## Getting started -If you've cloned the repo and want to run the sample app, you will first need to: +If you've cloned the repo and want to run the sample app, Shopify employees can +run `dev up` and `dev react-native ` from the repo root (`dev rn` is +an alias). The underlying `pnpm` commands below are run from +`platforms/react-native`: 1. Install the NPM dependencies @@ -130,8 +133,8 @@ pnpm sample test:android ## Running the sample app -To run the sample app in this repo, first clone the repo and run the following -commands at the root of the project directory. +To run the sample app in this repo with `pnpm`, first run the following commands +from `platforms/react-native`. ### Install NPM dependencies diff --git a/platforms/react-native/dev.yml b/platforms/react-native/dev.yml deleted file mode 100644 index b87a78b4..00000000 --- a/platforms/react-native/dev.yml +++ /dev/null @@ -1,83 +0,0 @@ -name: checkout-kit-react-native - -dev.edition: 2024 - -type: node - -up: - - packages: - - swiftlint - - sccache - - ruby - - xcode: - version: '26.2' - runtimes: - ios: - - version: 23C54 # 26.2 - architecture_variant: arm64 - # Node / pnpm versions are mirrored from package.json (engines.node, - # packageManager). dev validates engines.node matches the version below on - # every `dev up`, so drift is caught automatically. If you bump one, bump - # both. - - node: - version: v22.14.0 - package_manager: pnpm@10.33.1 - - custom: - name: Remove stale Yarn artifacts - met?: test ! -d .yarn - meet: | - rm -rf .yarn - - custom: - name: Install NPM dependencies - met?: ls -l | grep node_modules - meet: | - pnpm install - - custom: - name: Install gems - met?: (cd sample/ios && bundle check) - meet: | - (cd sample/ios && bundle install) - - custom: - name: Install pods - met?: (cd sample/ios && bundle exec pod check --ignore-dev-pods) - meet: | - pnpm run pod-install - - custom: - name: Build node module - met?: (cd modules/@shopify/checkout-kit-react-native && ls -l | grep lib) - meet: | - pnpm module build - -check: - lint_swift: ./scripts/lint_swift - lint_module: pnpm module lint - lint_sample: pnpm sample lint - -commands: - server: - desc: 'Start development server' - run: pnpm sample start --reset-cache - - ios: - desc: 'Run iOS simulator' - run: pnpm sample ios - - android: - desc: 'Run Android emulator' - run: pnpm sample android - - clean: - desc: 'rm -rf all generated directories' - run: | - pnpm module clean - pnpm sample clean - pnpm clean - if command -v sccache >/dev/null 2>&1; then - sccache --stop-server 2>/dev/null || true - fi - echo "✅ Cleaned root, module and sample workspaces" - - fix: - desc: Fix linting - run: | - ./scripts/lint_swift fix diff --git a/platforms/react-native/scripts/lint_swift b/platforms/react-native/scripts/lint_swift index c737b6e3..d909a495 100755 --- a/platforms/react-native/scripts/lint_swift +++ b/platforms/react-native/scripts/lint_swift @@ -64,7 +64,7 @@ print_linting_error() { local tool_name=$1 echo "❌ $tool_name detected issues that need to be fixed." echo "🔧 How to fix:" - echo " Shopify employee? Run 'dev fix' or 'dev check' to see detailed output" + echo " Shopify employee? Run 'dev react-native format' or 'dev react-native lint' to see detailed output" echo " Not a Shopify employee? Run './scripts/lint_swift fix' to auto-fix issues" if [[ "$tool_name" == "SwiftLint" ]]; then echo " Then fix any remaining non-autofixable issues manually"