Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/development_codepush-devml.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ jobs:
steps:
- uses: actions/checkout@v4

- name: Set up Node.js version
- name: Setup Node.js using .nvmrc
uses: actions/setup-node@v3
with:
node-version: "18.x"
node-version-file: "custom/.nvmrc"

- name: npm install, build, and test
working-directory: ./api
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/production_codepush-prodml.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ jobs:
steps:
- uses: actions/checkout@v4

- name: Set up Node.js version
- name: Setup Node.js using .nvmrc
uses: actions/setup-node@v3
with:
node-version: "18.x"
node-version-file: "custom/.nvmrc"

- name: npm install, build, and test
working-directory: ./api
Expand Down
1 change: 1 addition & 0 deletions custom/.nvmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
22.13.1
60 changes: 36 additions & 24 deletions api/FRIENDLY_DOCS.md → custom/guildes/API_FRIENDLY_DOCS.md
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,9 @@ OAuth Apps are **essential** for your CodePush server deployment because:

Without at least one OAuth provider configured, your CodePush server would have no way to authenticate users, making it impossible to use the system for deploying updates.

### Setting Up a GitHub OAuth App
### Setting Up a GitHub OAuth App (Recommended)

GitHub OAuth is the recommended authentication method for CodePush Server. To set up:

1. Go to https://github.com/settings/developers
2. Click "New OAuth App"
Expand All @@ -115,7 +117,9 @@ Without at least one OAuth provider configured, your CodePush server would have
5. Generate a new Client Secret
6. Save both values for your CodePush server configuration

### Setting Up a Microsoft OAuth App
### Setting Up a Microsoft OAuth App (Optional)

Microsoft OAuth is optional and only needed if you want to support Microsoft account authentication:

1. Register an app at https://portal.azure.com → Azure Active Directory → App registrations → New registration
2. Name your application (e.g., "CodePush Server")
Expand All @@ -137,15 +141,15 @@ Without at least one OAuth provider configured, your CodePush server would have
Add to your `.env` file:

```
# GitHub OAuth
# GitHub OAuth (Required)
GITHUB_CLIENT_ID=your_github_client_id
GITHUB_CLIENT_SECRET=your_github_client_secret

# Microsoft OAuth
MICROSOFT_CLIENT_ID=your_microsoft_client_id
MICROSOFT_CLIENT_SECRET=your_microsoft_client_secret
# Microsoft OAuth (Optional)
# MICROSOFT_CLIENT_ID=your_microsoft_client_id
# MICROSOFT_CLIENT_SECRET=your_microsoft_client_secret
# Only needed for single tenant work account setup
MICROSOFT_TENANT_ID=your_tenant_id
# MICROSOFT_TENANT_ID=your_tenant_id
```

#### For Azure Deployment:
Expand Down Expand Up @@ -191,18 +195,16 @@ az deployment group create \
--parameters project_suffix=<suffix> \
az_location=eastus \
github_client_id=<github-client-id> \
github_client_secret=<github-client-secret> \
microsoft_client_id=<microsoft-client-id> \
microsoft_client_secret=<microsoft-client-secret>
github_client_secret=<github-client-secret>
```

Notes:

- Choose a unique suffix (letters only, max 15 chars)
- OAuth parameters are optional but recommended for authentication
- **Important**: At least one OAuth provider (GitHub or Microsoft) must be configured for the system to work properly
- If using Microsoft single tenant work accounts, you'll need to add the `MICROSOFT_TENANT_ID` parameter after deployment
- GitHub OAuth parameters are required for authentication
- Microsoft OAuth parameters (`microsoft_client_id`, `microsoft_client_secret`) are now optional and can be omitted if you're only using GitHub authentication
- Your server URL will be: https://codepush-{suffix}.azurewebsites.net
- First-time users will need to register with the CLI using `code-push-standalone register https://codepush-{suffix}.azurewebsites.net` before accessing the web interface

### Step 5: Manual Deployment to Azure Web App

Expand Down Expand Up @@ -268,9 +270,18 @@ If you want to monitor release activity via the CLI:
### Common Issues:

1. **Deployment Fails**: Check that your project suffix meets naming requirements (letters only, max 15 chars)
2. **Authentication Issues**: Verify OAuth callback URLs match your server URL exactly
3. **Storage Errors**: Ensure Azurite is running for local development, or check storage account access keys
4. **Node.js Version**: Make sure you're using Node.js 18 LTS as specified

2. **GitHub Authentication Issues**:

- **Redirect URI Mismatch**: If you see an error about redirect_uri not being associated with the application, ensure your GitHub OAuth app's callback URL exactly matches what your server is using (including protocol, domain, and path)
- **Account Not Found Error**: If you see "Account not found. Have you registered with the CLI?" after GitHub authentication, you need to first register using the CLI with `code-push-standalone register <server-url>` before accessing the web interface
- **Authentication Failed**: Double-check your GitHub OAuth credentials are correctly set in environment variables

3. **Microsoft Authentication Issues**: Verify that the redirect URIs and account types in your Microsoft application registration match your server configuration

4. **Storage Errors**: Ensure Azurite is running for local development, or check storage account access keys

5. **Node.js Version**: Make sure you're using Node.js 18 LTS as specified

For more detailed troubleshooting, check the logs in your Azure Web App or local development environment.

Expand Down Expand Up @@ -347,9 +358,7 @@ az deployment group create \
--parameters project_suffix="<your-suffix>" \
az_location="eastus" \
github_client_id="<github-client-id>" \
github_client_secret="<github-client-secret>" \
microsoft_client_id="<microsoft-client-id>" \
microsoft_client_secret="<microsoft-client-secret>"
github_client_secret="<github-client-secret>"

# 5. Build the application for deployment
npm run build
Expand All @@ -370,14 +379,17 @@ az webapp deployment source config-zip \
# Install the CodePush CLI
npm install -g code-push-cli

# Login to your CodePush server
code-push login --serverUrl https://codepush-<your-suffix>.azurewebsites.net
# First-time users must register (creates your account)
code-push-standalone register https://codepush-<your-suffix>.azurewebsites.net

# For subsequent logins
code-push-standalone login --serverUrl https://codepush-<your-suffix>.azurewebsites.net

# Register your app
code-push app add <app-name> <platform>
code-push-standalone app add <app-name> <platform>

# Deploy an update
code-push release-react <app-name> <platform> --development
code-push-standalone release-react <app-name> <platform> --development
```

Remember to replace placeholder values (`<your-suffix>`, `<subscription-id>`, etc.) with your actual values. Also, make sure you have set up at least one OAuth provider (GitHub or Microsoft) before deployment.
Remember to replace placeholder values (`<your-suffix>`, `<subscription-id>`, etc.) with your actual values. Also, make sure you have set up GitHub OAuth authentication before deployment.
237 changes: 237 additions & 0 deletions custom/guildes/CLI_GUIDE_DOCS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,237 @@
# CodePush CLI Guide

This guide explains how to use the local CodePush CLI with your self-hosted CodePush servers.

## Installation

To install and use the local CodePush CLI:

```bash
# Clone the CodePush Service repository
git clone <repository-url>

# Navigate to the project directory
cd ml-code-push-server

# Install dependencies
npm install

# Build the CLI
npm run build

# Install CLI globally
npm install -g
```

After installation, the CLI will be available as `code-push-standalone`.

## Configuration

Before using the CLI, you need to log in to your CodePush server:

```bash
# For development environment
code-push-standalone login https://codepush-devml.azurewebsites.net

# For production environment
code-push-standalone login https://codepush-prodml.azurewebsites.net
```

This will open a browser for authentication.

## Common Commands

### Account Management

```bash
# Register new account (if needed)
code-push-standalone register https://codepush-devml.azurewebsites.net

# Check current logged in account
code-push-standalone whoami

# Logout
code-push-standalone logout
```

### App Management

```bash
# List all apps
code-push-standalone app ls

# Add a new app (create separate apps for iOS and Android)
code-push-standalone app add MyApp-iOS
code-push-standalone app add MyApp-Android

# Rename an app
code-push-standalone app rename CurrentName NewName

# Remove an app
code-push-standalone 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-standalone deployment ls MyApp-iOS

# Add a deployment
code-push-standalone deployment add MyApp-iOS QA

# Rename a deployment
code-push-standalone deployment rename MyApp-iOS QA Beta

# Remove a deployment
code-push-standalone deployment rm MyApp-iOS QA
```

### Releasing Updates

#### Standard Release

```bash
# Release an update
code-push-standalone 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-standalone 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

Full command example:

```bash
# Comprehensive React Native release example with common options
code-push-standalone release-react MyAwesomeApp-iOS ios \
--deploymentName Production \
--description "Fixed login issues and improved performance" \
--mandatory true \
--targetBinaryVersion "~1.2.3" \
--development false \
--sourcemapOutput ./sourcemaps \
--rollout 25 \
--entryFile index.ios.js \
--plistFile ./ios/MyAwesomeApp/Info.plist \
--gradleFile ./android/app/build.gradle
```

This example:

- Releases to the "Production" deployment
- Includes descriptive release notes
- Makes the update mandatory for all users
- Targets app binary version 1.2.x (compatibility with semver range)
- Disables development mode for a minified production bundle
- Generates sourcemaps for debugging
- Rolls out to 25% of users initially
- Specifies custom entry file and build configuration files

### Managing Releases

```bash
# View release history
code-push-standalone deployment history MyApp-iOS Staging

# Promote a release from Staging to Production
code-push-standalone promote MyApp-iOS Staging Production

# Rollback a deployment to a previous release
code-push-standalone rollback MyApp-iOS Production
```

## Debugging

```bash
# View debug logs for a running app
code-push-standalone debug android
code-push-standalone debug ios
```

## Working with Collaborators

```bash
# List collaborators
code-push-standalone collaborator ls MyApp-iOS

# Add a collaborator
code-push-standalone collaborator add MyApp-iOS user@example.com

# Remove a collaborator
code-push-standalone 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-standalone 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-standalone app add MyAwesomeApp-iOS
code-push-standalone app add MyAwesomeApp-Android
```

2. Deploy an update to staging:

```bash
code-push-standalone release-react MyAwesomeApp-iOS ios --deploymentName Staging
```

3. Test the update in the staging environment

4. Promote to production when ready:
```bash
code-push-standalone promote MyAwesomeApp-iOS Staging Production
```

## Troubleshooting

- **Server errors**: Make sure your server URL is correct and server is running
- **Authentication issues**: Check your authentication 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).
Loading