react-push-cli
v1.0.3
Published
CLI tool for building and publishing React Native bundles to ReactPush
Maintainers
Readme
ReactPush CLI
Command-line tool for building and publishing React Native and Flutter bundles to ReactPush.
Supported Frameworks
| Framework | Build Tool | Platforms | |-----------|-----------|-----------| | React Native | Metro Bundler | iOS, Android | | Flutter | Flutter CLI | iOS, Android, Web |
Installation
npm install
npm link # Makes the CLI available globally as 'react-push'Or use directly with npx:
npx react-push-cli <command>Configuration
You can configure the CLI to avoid entering API key and URL every time. The CLI supports multiple ways to provide configuration:
Option 1: Configuration File (Recommended)
Initialize configuration once per project:
react-push init --api-key YOUR_APP_API_KEYOr with a custom API URL:
react-push init --api-key YOUR_APP_API_KEY --api-url https://api.example.comThis creates a .reactpushrc file in your project root. After initialization, you can use publish without specifying API key/URL:
react-push publish --version 1.0.1 --bundle-url https://cdn.example.com/bundles/1.0.1/bundle.jsOption 2: API Key File
Store your API key in a file and reference it:
# Create a file with your API key
echo "YOUR_API_KEY" > .api-key
# Use it with --api-key-file
react-push publish --api-key-file .api-key --version 1.0.1 ...Option 3: Environment Variables
Create a .env file in your project root:
REACTPUSH_API_KEY=YOUR_API_KEY
REACTPUSH_API_URL=https://api.example.comThe CLI will automatically read from .env if no other source is provided.
Option 4: Command Line Options
You can still provide API key and URL directly via command line (overrides config):
react-push publish --api-key YOUR_KEY --api-url https://api.example.com --version 1.0.1 ...Default API URL
If no API URL is provided, the CLI defaults to http://localhost:5000. You can override this in:
- Configuration file (via
init) - Command line (
--api-url) - Environment variable (
REACTPUSH_API_URL)
React Native Usage
Publish Update (React Native)
Build and publish a React Native bundle update:
react-push publish \
--framework react-native \
--version 1.0.1 \
--platform ios \
--bundle-url https://cdn.example.com/bundles/1.0.1/bundle.js \
--assets-url https://cdn.example.com/bundles/1.0.1/assets \
--label "v1.0.1" \
--description "Bug fixes and performance improvements" \
--mandatoryReact Native Options:
--framework: Set toreact-native(default)--version(required): Version number (e.g., 1.0.1)--api-key: Your app's API key (optional if configured viainitor config file)--api-key-file: Path to file containing API key (optional)--api-url: ReactPush API URL (optional, defaults to http://localhost:5000)--platform: Platform (ios or android). If not specified, builds for both platforms.--project-root: React Native project root directory, default: current directory--entry-file: Entry file path, default: index.js--bundle-url: Public URL for the bundle (if already uploaded). Use--bundle-url-iosand--bundle-url-androidfor both platforms.--bundle-url-ios: Public URL for iOS bundle--bundle-url-android: Public URL for Android bundle--assets-url: Public URL for assets (if already uploaded). Use--assets-url-iosand--assets-url-androidfor both platforms.--assets-url-ios: Public URL for iOS assets--assets-url-android: Public URL for Android assets--label: Release label, default: v{version}--description: Release description--mandatory: Mark update as mandatory--dev: Build in development mode--minify: Minify the bundle (default: true)--sourcemap-output: Output path for source map
Build Only (React Native)
Build a bundle without publishing:
react-push build \
--framework react-native \
--platform ios \
--bundle-output ./build/bundle.js \
--assets-dest ./build/assetsFlutter Usage
Publish Update (Flutter)
Build and publish a Flutter bundle update:
react-push publish \
--framework flutter \
--version 1.0.1 \
--platform ios \
--app-id YOUR_APP_ID \
--label "v1.0.1" \
--description "Bug fixes and performance improvements" \
--mandatoryFlutter Options:
--framework: Set toflutter--version(required): Version number (e.g., 1.0.1)--api-key: Your app's API key (optional if configured viainitor config file)--api-key-file: Path to file containing API key (optional)--api-url: ReactPush API URL (optional, defaults to http://localhost:5000)--app-id: App ID (required for zip upload)--platform: Platform (ios, android, or web). If not specified, builds for iOS and Android.--project-root: Flutter project root directory, default: current directory--label: Release label, default: v{version}--description: Release description--mandatory: Mark update as mandatory--flutter-build-mode: Build mode: release, profile, or debug (default: release)--flutter-target: Flutter target file (default: lib/main.dart)--flutter-flavor: Flutter flavor for the build--dart-define: Dart compile-time defines (can be used multiple times)
Build Only (Flutter)
Build a Flutter bundle without publishing:
react-push build \
--framework flutter \
--platform ios \
--bundle-output ./build/bundle.js \
--assets-dest ./build/assetsFlutter Web Build
For Flutter web apps, use --platform web:
react-push publish \
--framework flutter \
--platform web \
--version 1.0.1 \
--app-id YOUR_APP_IDExamples
Example 1: React Native - Using configuration file (recommended)
# First time: Initialize config
react-push init --api-key abc123xyz --api-url https://api.reactpush.com
# Then publish without API key/URL
react-push publish \
--framework react-native \
--version 1.0.2 \
--platform android \
--bundle-url https://cdn.example.com/bundles/1.0.2/bundle.js \
--assets-url https://cdn.example.com/bundles/1.0.2/assets \
--label "v1.0.2" \
--description "New features and improvements"Example 2: React Native - Build bundle first, then publish
# Step 1: Build the bundle
react-push build --framework react-native --platform ios --bundle-output ./build/bundle.js
# Step 2: Upload bundle.js and assets to your CDN
# (manual step or use your CDN's CLI)
# Step 3: Publish with URLs (using config file)
react-push publish \
--framework react-native \
--version 1.0.3 \
--bundle-url https://cdn.example.com/bundles/1.0.3/bundle.js \
--assets-url https://cdn.example.com/bundles/1.0.3/assetsExample 3: React Native - Build and publish in one command
react-push publish \
--framework react-native \
--version 1.0.4 \
--platform ios \
--bundle-output ./build/bundle-1.0.4.js \
--assets-dest ./build/assets-1.0.4 \
--bundle-url https://cdn.example.com/bundles/1.0.4/bundle.js \
--assets-url https://cdn.example.com/bundles/1.0.4/assetsExample 4: React Native - Build for both platforms
# Build bundles for both iOS and Android
react-push build --framework react-native
# This creates:
# - ./build/bundle-ios.js
# - ./build/bundle-android.js
# - ./build/assets-ios/
# - ./build/assets-android/Example 5: React Native - Publish for both platforms
# Publish updates for both platforms
react-push publish \
--framework react-native \
--version 1.0.7 \
--bundle-url-ios https://cdn.example.com/bundles/1.0.7/ios/bundle.js \
--bundle-url-android https://cdn.example.com/bundles/1.0.7/android/bundle.js \
--assets-url-ios https://cdn.example.com/bundles/1.0.7/ios/assets \
--assets-url-android https://cdn.example.com/bundles/1.0.7/android/assetsExample 6: Flutter - Build and publish for iOS
react-push publish \
--framework flutter \
--version 1.0.1 \
--platform ios \
--app-id YOUR_APP_ID \
--flutter-build-mode release \
--label "v1.0.1" \
--description "Initial Flutter release"Example 7: Flutter - Build for both platforms
react-push build --framework flutter
# This creates:
# - ./build/bundle-ios.js
# - ./build/bundle-android.js
# - ./build/assets-ios/
# - ./build/assets-android/Example 8: Flutter - Publish with flavor and dart defines
react-push publish \
--framework flutter \
--version 1.0.2 \
--platform android \
--app-id YOUR_APP_ID \
--flutter-flavor production \
--dart-define "API_URL=https://api.prod.example.com" \
--dart-define "DEBUG=false"Example 9: Flutter Web - Build and publish
react-push publish \
--framework flutter \
--platform web \
--version 1.0.1 \
--app-id YOUR_APP_ID \
--label "v1.0.1 Web"Example 10: Package assets for upload
# Package assets into a zip file
react-push package \
--assets-path ./build/assets-ios-1.0.8 \
--output ./build/assets-1.0.8.zip
# Upload the zip to your CDN, extract it, then publish
react-push publish \
--version 1.0.8 \
--bundle-url https://cdn.example.com/bundles/1.0.8/bundle.js \
--assets-url https://cdn.example.com/bundles/1.0.8/assetsCommands
init
Initialize configuration file for the project. Saves API key and URL so you don't need to enter them every time.
react-push init --api-key YOUR_API_KEY
react-push init --api-key-file .api-key --api-url https://api.example.compublish
Build and publish a React Native or Flutter bundle update to ReactPush API.
build
Build a React Native or Flutter bundle without publishing. Useful for testing or manual upload workflows.
package
Package assets into a zip file for easier upload to CDN or file server.
Notes
React Native
- The CLI uses Metro bundler to build React Native bundles
- Assets are collected from common directories:
assets/,src/assets/,images/,src/images/, and platform-specific directories - You need to upload bundles and assets to a publicly accessible URL (CDN or file server) before publishing
- The API key should be your app's API key (not the tenant API key)
- All bundle and asset URLs must be publicly accessible
- The
packagecommand creates a zip file of assets that you can upload to your CDN and extract
Flutter
- The CLI uses Flutter CLI to build bundles
- For mobile platforms (iOS/Android), the CLI builds Flutter asset bundles
- For web platform, the CLI builds the Flutter web output and packages
main.dart.js - Flutter assets are collected from common directories:
assets/,images/,fonts/,lib/assets/ - Requires Flutter SDK to be installed and available in PATH
Troubleshooting
React Native Issues
Error: react-native CLI not found
- Make sure you have
react-nativeinstalled in your project - Run
npm install react-nativein your project directory
Error: Bundle URL is required
- You need to provide
--bundle-urlwith a publicly accessible URL - Upload your bundle to a CDN or file server first
Flutter Issues
Error: Flutter CLI not found
- Make sure Flutter is installed and available in your PATH
- Run
flutter --versionto verify installation - Visit https://flutter.dev/docs/get-started/install for installation instructions
Error: Flutter build failed
- Run
flutter doctorto check for any issues - Ensure all Flutter dependencies are installed
- Try running
flutter cleanbefore building
General Issues
Error: API request failed
- Check that your API key is correct
- Verify the API URL is accessible
- Ensure the bundle and asset URLs are publicly accessible
