From f19ac42523ec725b71e2b568178af2b1a7380145 Mon Sep 17 00:00:00 2001 From: Van Allen Diongzon Date: Tue, 22 Apr 2025 17:09:59 +0800 Subject: [PATCH 1/3] [Adjustment][Van] Add entra-id, cli, and test guildelines, Change node version --- .../workflows/development_codepush-devml.yml | 2 +- .../workflows/production_codepush-prodml.yml | 2 +- CodePush-CLI-Guide.md | 194 ++++++++++++ CodePush-Testing-Guide.md | 294 ++++++++++++++++++ api/Entra_ID_CodePush_Setup.md | 101 ++++++ 5 files changed, 591 insertions(+), 2 deletions(-) create mode 100644 CodePush-CLI-Guide.md create mode 100644 CodePush-Testing-Guide.md create mode 100644 api/Entra_ID_CodePush_Setup.md diff --git a/.github/workflows/development_codepush-devml.yml b/.github/workflows/development_codepush-devml.yml index 35ebc7de2..f0226b2dd 100644 --- a/.github/workflows/development_codepush-devml.yml +++ b/.github/workflows/development_codepush-devml.yml @@ -21,7 +21,7 @@ jobs: - name: Set up Node.js version uses: actions/setup-node@v3 with: - node-version: "18.x" + node-version: "22.13.1" - name: npm install, build, and test working-directory: ./api diff --git a/.github/workflows/production_codepush-prodml.yml b/.github/workflows/production_codepush-prodml.yml index 0069a48d2..fcfcc1dcf 100644 --- a/.github/workflows/production_codepush-prodml.yml +++ b/.github/workflows/production_codepush-prodml.yml @@ -21,7 +21,7 @@ jobs: - name: Set up Node.js version uses: actions/setup-node@v3 with: - node-version: "18.x" + node-version: "22.13.1" - name: npm install, build, and test working-directory: ./api diff --git a/CodePush-CLI-Guide.md b/CodePush-CLI-Guide.md new file mode 100644 index 000000000..fdd917e5d --- /dev/null +++ b/CodePush-CLI-Guide.md @@ -0,0 +1,194 @@ +# CodePush CLI Guide + +This guide explains how to use the CodePush CLI with your Azure-hosted CodePush servers. + +## Installation + +To install the CodePush CLI: + +```bash +npm install -g code-push-cli +``` + +## Configuration + +Before using the CLI, you need to log in to your CodePush server: + +```bash +# For development environment +code-push login --serverUrl https://codepush-devml.azurewebsites.net + +# For production environment +code-push login --serverUrl https://codepush-prodml.azurewebsites.net +``` + +This will open a browser for authentication through Microsoft Entra ID. + +## Common Commands + +### Account Management + +```bash +# Register new account (if needed) +code-push register --serverUrl https://codepush-devml.azurewebsites.net + +# Check current logged in account +code-push whoami + +# Logout +code-push logout +``` + +### App Management + +```bash +# List all apps +code-push app ls + +# Add a new app (create separate apps for iOS and Android) +code-push app add MyApp-iOS +code-push app add MyApp-Android + +# Rename an app +code-push app rename CurrentName NewName + +# Remove an app +code-push app rm AppName +``` + +### Deployment Management + +Every app automatically gets "Staging" and "Production" deployments, but you can add more: + +```bash +# List deployments for an app +code-push deployment ls MyApp-iOS + +# Add a deployment +code-push deployment add MyApp-iOS QA + +# Rename a deployment +code-push deployment rename MyApp-iOS QA Beta + +# Remove a deployment +code-push deployment rm MyApp-iOS QA +``` + +### Releasing Updates + +#### Standard Release + +```bash +# Release an update +code-push release MyApp-iOS ./updates 1.0.0 +``` + +Parameters: + +- **App name**: Name of your app +- **Update contents**: Path to the update files or folder +- **Target binary version**: App store version this is for (can be a semver range) + +Optional flags: + +- `--deploymentName` or `-d`: Target deployment (defaults to Staging) +- `--description` or `-des`: Release notes +- `--mandatory` or `-m`: Force users to update +- `--rollout` or `-r`: Percentage of users to deploy to (e.g., "25%") +- `--disabled`: Prevent the update from being downloaded + +#### React Native Release + +```bash +# Release a React Native update +code-push release-react MyApp-iOS ios +``` + +Parameters: + +- **App name**: Name of your app +- **Platform**: "ios" or "android" + +Common options: + +- `--deploymentName` or `-d`: Target deployment (defaults to Staging) +- `--description` or `-des`: Release notes +- `--mandatory` or `-m`: Force users to update +- `--targetBinaryVersion` or `-t`: App store version this is for +- `--development` or `--dev`: Generate an unminified bundle with warnings + +### Managing Releases + +```bash +# View release history +code-push deployment history MyApp-iOS Staging + +# Promote a release from Staging to Production +code-push promote MyApp-iOS Staging Production + +# Rollback a deployment to a previous release +code-push rollback MyApp-iOS Production +``` + +## Debugging + +```bash +# View debug logs for a running app +code-push debug android +code-push debug ios +``` + +## Working with Collaborators + +```bash +# List collaborators +code-push collaborator ls MyApp-iOS + +# Add a collaborator +code-push collaborator add MyApp-iOS user@example.com + +# Remove a collaborator +code-push collaborator rm MyApp-iOS user@example.com +``` + +## Additional Security with Code Signing + +If using code signing: + +```bash +# Release with a private key for signing +code-push release-react MyApp-iOS ios --privateKeyPath private.pem +``` + +## Example Workflow + +A typical workflow with CodePush might look like: + +1. Create your apps for each platform: + + ```bash + code-push app add MyAwesomeApp-iOS + code-push app add MyAwesomeApp-Android + ``` + +2. Deploy an update to staging: + + ```bash + code-push release-react MyAwesomeApp-iOS ios --deploymentName Staging + ``` + +3. Test the update in the staging environment + +4. Promote to production when ready: + ```bash + code-push promote MyAwesomeApp-iOS Staging Production + ``` + +## Troubleshooting + +- **Server errors**: Make sure your server URL is correct and server is running +- **Authentication issues**: Check your Entra ID configuration +- **Deployment errors**: Verify app name and deployment name +- **Release issues**: Check target binary version compatibility + +For more information, refer to the [CLI documentation](../cli/README.md). diff --git a/CodePush-Testing-Guide.md b/CodePush-Testing-Guide.md new file mode 100644 index 000000000..9bf1e9f2c --- /dev/null +++ b/CodePush-Testing-Guide.md @@ -0,0 +1,294 @@ +# Testing Your CodePush Server and CLI Setup + +This guide provides practical steps to test your CodePush server and CLI setup to ensure everything is working correctly. It follows a progressive testing approach, starting from basic connectivity and advancing to complete end-to-end testing with a React Native app. + +## Prerequisites + +- Your CodePush server is running (either locally or on Azure) +- You have the CodePush CLI installed: `npm install -g code-push-cli` +- Microsoft Entra ID applications are configured for authentication + +## 1. Basic Connectivity Tests + +### 1.1. Server Availability + +First, let's verify your server is accessible: + +```bash +# For production environment +curl https://codepush-prodml.azurewebsites.net/ + +# For development environment +curl https://codepush-devml.azurewebsites.net/ +``` + +You should see a response indicating the server is running. If not, check that your server is deployed correctly. + +### 1.2. CLI Authentication + +Test authentication with the CLI: + +```bash +# For production +code-push login --serverUrl https://codepush-prodml.azurewebsites.net + +# For development +code-push login --serverUrl https://codepush-devml.azurewebsites.net +``` + +This should open a browser for authentication with Microsoft Entra ID. After authenticating, you'll be asked to paste the access token into the CLI. + +### 1.3. Verify Authentication + +Check that you're properly authenticated: + +```bash +code-push whoami +``` + +This should display your email address and indicate which authentication provider you used. + +## 2. App Management Tests + +### 2.1. Create Test Apps + +Create test applications for each platform: + +```bash +# Create a test iOS app +code-push app add TestApp-iOS ios + +# Create a test Android app +code-push app add TestApp-Android android +``` + +### 2.2. List Apps + +Verify your apps were created: + +```bash +code-push app ls +``` + +You should see the apps you just created, along with their deployment keys. + +### 2.3. Inspect Deployments + +Check the deployments for one of your apps: + +```bash +code-push deployment ls TestApp-iOS +``` + +You should see "Staging" and "Production" deployments automatically created for your app. + +### 2.4. Create a Custom Deployment + +Test creating a custom deployment: + +```bash +code-push deployment add TestApp-iOS Development +``` + +Then verify it was created: + +```bash +code-push deployment ls TestApp-iOS +``` + +## 3. Release Management Tests + +### 3.1. Create a Dummy Release Package + +Create a simple file to use as a test update: + +```bash +mkdir -p TestRelease +echo '{"version": "1.0.0", "test": true}' > TestRelease/app.json +``` + +### 3.2. Release an Update + +Release this package to your test app: + +```bash +code-push release TestApp-iOS ./TestRelease 1.0.0 --description "Test release" +``` + +### 3.3. View Release History + +Check that your release is in the deployment history: + +```bash +code-push deployment history TestApp-iOS Staging +``` + +You should see your test release in the list. + +### 3.4. Promote an Update + +Test the promotion workflow: + +```bash +code-push promote TestApp-iOS Staging Production --description "Promoted test release" +``` + +### 3.5. Verify the Promotion + +Verify that the release exists in both deployments: + +```bash +code-push deployment history TestApp-iOS Production +``` + +### 3.6. Rollback Test + +Test the rollback functionality (assuming you have multiple releases): + +```bash +# Release a second update +echo '{"version": "1.0.1", "test": true}' > TestRelease/app.json +code-push release TestApp-iOS ./TestRelease 1.0.0 --description "Second test release" + +# Rollback to the previous release +code-push rollback TestApp-iOS Staging +``` + +Verify the rollback worked: + +```bash +code-push deployment history TestApp-iOS Staging +``` + +## 4. Full End-to-End Testing with a React Native App + +For complete testing, you'll need a React Native app with the CodePush SDK integrated. + +### 4.1. Create a Simple React Native App + +```bash +npx react-native init CodePushTestApp +cd CodePushTestApp +``` + +### 4.2. Add the CodePush SDK + +```bash +npm install react-native-code-push --save +``` + +### 4.3. Configure the SDK to Use Your Server + +#### For iOS (in `ios/CodePushTestApp/Info.plist`): + +Add within the `` tags: + +```xml +CodePushServerURL +https://codepush-prodml.azurewebsites.net +``` + +#### For Android (in `android/app/src/main/res/values/strings.xml`): + +Add: + +```xml +https://codepush-prodml.azurewebsites.net +``` + +### 4.4. Update Your App Code + +Modify `App.js` to integrate CodePush: + +```javascript +import React from "react"; +import { View, Text, Button, Alert } from "react-native"; +import codePush from "react-native-code-push"; + +const codePushOptions = { + checkFrequency: codePush.CheckFrequency.ON_APP_START, + installMode: codePush.InstallMode.IMMEDIATE, +}; + +function App() { + const checkForUpdates = () => { + codePush.sync( + { + updateDialog: true, + installMode: codePush.InstallMode.IMMEDIATE, + }, + (status) => { + switch (status) { + case codePush.SyncStatus.CHECKING_FOR_UPDATE: + Alert.alert("Checking for updates"); + break; + case codePush.SyncStatus.DOWNLOADING_PACKAGE: + Alert.alert("Downloading package"); + break; + case codePush.SyncStatus.INSTALLING_UPDATE: + Alert.alert("Installing update"); + break; + case codePush.SyncStatus.UP_TO_DATE: + Alert.alert("App is up to date"); + break; + case codePush.SyncStatus.UPDATE_INSTALLED: + Alert.alert("Update installed"); + break; + case codePush.SyncStatus.UNKNOWN_ERROR: + Alert.alert("An unknown error occurred"); + break; + } + } + ); + }; + + return ( + + CodePush Test App - Version 1 +