diff --git a/README.md b/README.md index 468cc03..41aaa49 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,28 @@ Appcircle CLI is a unified tool for accessing the Appcircle platform features from the command line. -# Installation +## Table of Contents + +- [Table of Contents](#table-of-contents) +- [Installation Instructions](#installation-instructions) +- [Usage Guidelines](#usage-guidelines) + - [Command List](#core-commands) +- [Environment Variables](#environment-variables) +- [Interactive Mode](#interactive-mode) +- [Logging Requests](#logging-requests) +- [Guides and Tutorials](#guides-and-tutorials) + - [Configuring Your Appcircle CLI Environment](#configuring-your-appcircle-cli-environment) + - [Trusting Your Self-Hosted Appcircle Certificate](#trusting-your-self-hosted-appcircle-certificate) + - [Connecting Your Appcircle Account via CLI](#connecting-your-appcircle-account-via-cli) + - [Starting a New Build via the Appcircle CLI](#starting-a-new-build-via-the-appcircle-cli) + - [Distributing an App via the Appcircle CLI](#distributing-an-app-via-the-appcircle-cli) +- [How to Contribute](#how-to-contribute) +- [Publishing Guidelines](#publishing-guidelines) +- [Jenkins Pipeline](#jenkins-pipeline) +- [Docker Image](#docker-image) +- [Migration Guides](#migration-guides) + +## Installation Instructions To install Appcircle CLI globally, simply launch: @@ -18,9 +39,13 @@ alternatively, you can install Appcircle CLI locally: npm install @appcircle/cli ``` -# Usage & Commands +## Usage Guidelines -Simply launch the command on your Terminal/Command Line +To get started : + +1. Follow the [installation instructions](#installation-instructions) + +2. Simply launch the command on your Terminal/Command Line ``` appcircle @@ -28,40 +53,58 @@ appcircle > If you have installed it locally, you should run `npx appcircle` +3. Set any needed [environment variables](#how-to-configure-your-appcircle-cli-environment). + +4. If you are using a self-signed SSL certificate on a self-hosted Appcircle server, [trust the SSL certificate](#trusting-your-self-hosted-appcircle-certificate) of the server to ensure secure communication between the CLI and the server. + +5. [Authenticate](https://docs.appcircle.io/appcircle-api/api-authentication) into your Appcircle account. + + + Below is the list of commands currently supported by Appcircle CLI: -| Command | Description | -| --------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------- | -| `appcircle (-i, --interactive)` | AppCircle GUI | -| `appcircle help [commandName]` | Display help for command | -| `appcircle config [argument] [options]` | View and edit Appcircle CLI properties | -| `appcircle login [--pat]` | Get an access token for the session | -| `appcircle organization [action] [options]` | Manage organization users, roles, and details | -| `appcircle listBuildProfiles` | Get the list of build profiles | -| `appcircle listDistributionProfiles` | Get the list of distribution profiles | -| `appcircle listBuildProfileWorkflows [--profileId]` | Get the list of workflows for the profile | -| `appcircle listBuildProfileConfigurations [--profileId]` | Get the list of configurations for the profile | -| `appcircle listBuildProfileBuildsOfCommit [--profileId]` | Get the list of commits of branch | -| `appcircle listBuildProfileBuildsOfCommit [--profileId]` | Get the list of builds of a commit | -| `appcircle build [--profileId] [--branch] [--workflow]` | Start a new build | -| `appcircle download [--path] [--commitId] [--buildId]` | Download the artifact under the selected path | -| `appcircle upload [--app] [--message] [--profileId]` | Upload your app binary to selected distribution profile | -| `appcircle createDistributionProfile [--name]` | Create a distribution profile | -| `appcircle listEnvironmentVariableGroups` | Get list of environment variable groups | -| `appcircle createEnvironmentVariableGroup [--name]` | Create an environment variable group | -| `appcircle listEnvironmentVariables [--variableGroupId]` | Get list of environment variables | -| `appcircle createEnvironmentVariable [--type] [-isSecret, --isSecret] [--variableGroupId] [--key] [--value] [--filePath]` | Create a file or text environment variable | -| `appcircle listEnterpriseProfiles` | List Enterprise profiles | -| `appcircle listEnterpriseAppVersions [--entProfileId] [--publishType]` | List Enterprise app versions | -| `appcircle publishEnterpriseAppVersion [--entProfileId] [--entVersionId] [--entVersionId] [--summary] [--releaseNotes] [--publishType]` | Publish Enterprise app version | -| `appcircle publishEnterpriseAppVersion [--entProfileId] [--entVersionId]` | Unpublish Enterprise app version | -| `appcircle removeEnterpriseAppVersion [--entProfileId] [--entVersionId]` | Remove Enterprise app version | -| `appcircle notifyEnterpriseAppVersion [--entProfileId] [--entVersionId] [--subject] [--message]` | Notify Enterprise app version | -| `appcircle uploadEnterpriseApp [--app] ` | Upload Enterprise app version without a profile | -| `appcircle uploadEnterpriseAppVersion [--entProfileId] [--app] ` | Upload enterprise app version for a profile | -| `appcircle getEnterpriseDownloadLink [--entProfileId] [--entVersionId]` | Get enterprise app download link | - -## Logging requests +### Core Commands + +Run `appcircle [commandName] --help` to view a list of commands/subcommands in your terminal. + +- [appcircle config](/docs/config/index.md) +- [appcircle login](/docs/login/index.md) +- [appcircle build](/docs/build/index.md) +- [appcircle distribution](/docs/distribution/index.md) +- [appcircle publish](/docs/publish/index.md) +- [appcircle enterprise-app-store](/docs/enterprise-app-store/index.md) +- [appcircle organization](/docs/organization/index.md) + +The commands follow this pattern: + +```shell +appcircle ... [options] +``` + +- Run `appcircle (-i, --interactive)` to proceed with the Appcircle GUI + + +## Environment Variables +- `AC_ACCESS_TOKEN`: An authentication token for API requests. Setting this avoids being + prompted to authenticate and overrides any previously stored credentials. + Can be set in the config with `appcircle config set AUTH_HOSTNAME xxxxxx` + +- `API_HOSTNAME`: Specifies the host where the API endpoint is located. [See also](#how-to-configure-your-appcircle-cli-environment) for more details. + +- `AUTH_HOSTNAME`: Specifies the host where your IAM (identity access management) server endpoint is located. [See also](#how-to-configure-your-appcircle-cli-environment) for more details. + +## Interactive Mode + +Appcircle CLI incorporates a GUI that allows users to interactively access its features. To view all features in interactive mode, execute the following command: + +``` +appcircle -i +``` + +### Demo +![Demo](https://cdn.appcircle.io/docs/assets/appcircle_gui_demo.gif) + +## Logging Requests If you want to log the requests as `curl` commands you can start appcircle CLI by setting the `CURL_LOGGING` environment variable. @@ -71,7 +114,9 @@ Example: CURL_LOGGING= appcircle ``` -## How to Configure your Appcircle CLI environment? +## Guides and Tutorials + +### Configuring Your Appcircle CLI Environment - Using the Appcircle CLI, add your custom configuration for self-hosted Appcircle @@ -79,11 +124,11 @@ CURL_LOGGING= appcircle appcircle config set API_HOSTNAME https://api.your.appcircle.io appcircle config set AUTH_HOSTNAME https://auth.your.appcircle.io -- Change current configuration enviroment using `appcircle config current default` +- Change current configuration enviroment using `appcircle config current self_env` - Set all these settings via interactive mode `appcircle -i` - Print help of config command `appcircle config -h` -## How to Trust your Self-Hosted Appcircle Certificate? +### Trusting Your Self-Hosted Appcircle Certificate - After you configure the Appcircle CLI, you can run the the command below to trust SSL certificate. @@ -93,29 +138,29 @@ CURL_LOGGING= appcircle - For detailed usage, please refer to the [Trusting SSL Certificate](https://docs.appcircle.io/self-hosted-appcircle/configure-server/appcircle-cli#trusting-the-ssl-certificate-recommended) documentation. -## How to Connect your Appcircle Account within CLI? +### Connecting Your Appcircle Account via CLI -- [Generate a personal access token from the Appcircle dashboard](/appcircle-api/api-authentication) +- [Generate a personal access token from the Appcircle dashboard](https://docs.appcircle.io/appcircle-api/api-authentication#generatingmanaging-the-personal-api-tokens) - Using the Appcircle CLI, create a full access API token using the following command with the personal access token specified as "pat": `appcircle login --pat="YOUR PERSONAL ACCESS TOKEN"`. > Your token will be stored internally. You should always revoke your access token if you do not plan to use it in the future. -## How to start a new build via the Appcircle CLI? +### Starting a New Build via the Appcircle CLI - Add a build profile and [connect a repository](https://docs.appcircle.io/build/adding-a-build-profile#connect-your-repository) -- Get the build profile ID using `appcircle listBuildProfiles` -- Get the workflows of that build profile `appcircle listBuildProfileWorkflows --profileId="YOUR PROFILE ID"` -- Start a new build using `appcircle build --profileId="YOUR PROFILE ID" --branch="YOUR BRANCH" --workflow="YOUR WORKFLOW ID"` +- Get the build profile ID using `appcircle build profile list` +- Get the workflows of that build profile `appcircle build profile workflows --profileId="YOUR PROFILE ID"` +- Start a new build using `appcircle build start --profileId="YOUR PROFILE ID" --branch="YOUR BRANCH" --workflow="YOUR WORKFLOW ID"` -## How to distribute an app via the Appcircle CLI? +### Distributing an App via the Appcircle CLI - Create a distribution profile and [share with the testers](https://docs.appcircle.io/distribute/create-or-select-a-distribution-profile) - Enable [auto sending](https://docs.appcircle.io/distribute/create-or-select-a-distribution-profile#auto-send-your-build-to-the-testers) of the build to the testers -- Get the distribution profile ID using `appcircle listDistributionProfiles` +- Get the distribution profile ID using `appcircle distribution profile list` - Upload your app binary to the selected distribution profile using `appcircle upload --app="YOUR APP PATH" --profileId="YOUR PROFILE ID" --message="YOUR RELEASE NOTES"` -# Contribution +## How to Contribute - Clone this repository - Install dependencies by using `yarn` command @@ -123,7 +168,7 @@ CURL_LOGGING= appcircle - Make your changes - Submit a PR -# Publishing +## Publishing Guidelines - After changes, run the command `yarn run postversion`. It will push a new tag to the repository. - Jenkins will take care of the rest. @@ -140,7 +185,7 @@ CURL_LOGGING= appcircle - If the tag is `v*-alpha*`, the app will be published to the alpha channel. -# Docker Image +## Docker Image - Docker image is for building and publishing the application anywhere. @@ -157,3 +202,7 @@ docker run --rm --env NPM_AUTH_TOKEN=abcd ac-cli npm publish --tag beta docker image build -t ac-cli --build-arg NPM_AUTH_TOKEN=abcd . docker run --rm --env NPM_AUTH_TOKEN=abcd ac-cli npm publish ``` + +## Migration Guides + +- [1.x to 2.x](docs/migration-guides/1.x-to-2.x.md) \ No newline at end of file diff --git a/docs/build/active-list.md b/docs/build/active-list.md new file mode 100644 index 0000000..4ed5e6a --- /dev/null +++ b/docs/build/active-list.md @@ -0,0 +1,13 @@ +# `appcircle build active-list` + +Get a list of active builds in the queue. + +```plaintext +appcircle build active-list [options] +``` + +## Options inherited from parent commands + +```plaintext + --help Show help for command +``` diff --git a/docs/build/download.md b/docs/build/download.md new file mode 100644 index 0000000..ea8b290 --- /dev/null +++ b/docs/build/download.md @@ -0,0 +1,22 @@ +# `appcircle build download` + +Download your artifact to the given directory on your machine. + +```plaintext +appcircle build download [options] +``` + +## Options + +```plaintext + --path [OPTIONAL] The path for artifacts to be downloaded. Defaults to the current directory + + --commitId Commit ID of your build + + --buildId Build ID +``` +## Options inherited from parent commands + +```plaintext + --help Show help for command +``` diff --git a/docs/build/index.md b/docs/build/index.md new file mode 100644 index 0000000..eefbf54 --- /dev/null +++ b/docs/build/index.md @@ -0,0 +1,24 @@ +# `appcircle build` + +Manage build actions. + +```plaintext +appcircle build [command] [options] +``` + +## Options inherited from parent commands + +```plaintext + --help Show help for command +``` + +## Subcommands + +- [`start`](start.md) +- [`active-list`](active-list.md) +- [`list`](list.md) +- [`view`](view.md) +- [`download`](download.md) +- [`profile`](profile/index.md) +- [`variable`](variable/index.md) + diff --git a/docs/build/list.md b/docs/build/list.md new file mode 100644 index 0000000..99e964d --- /dev/null +++ b/docs/build/list.md @@ -0,0 +1,18 @@ +# `appcircle build list` + +Get list of builds of a commit. + +```plaintext +appcircle build list [options] +``` + +## Options + +```plaintext + --commitId Commit ID +``` +## Options inherited from parent commands + +```plaintext + --help Show help for command +``` diff --git a/docs/build/profile/branch/commits.md b/docs/build/profile/branch/commits.md new file mode 100644 index 0000000..733c369 --- /dev/null +++ b/docs/build/profile/branch/commits.md @@ -0,0 +1,19 @@ +# `appcircle build profile branch commits` + +Get list of commits of a branch + +```plaintext +appcircle build profile branch commits [options] +``` + +## Options + +```plaintext + --branchId Branch ID +``` + +## Options inherited from parent commands + +```plaintext + --help Show help for command +``` diff --git a/docs/build/profile/branch/index.md b/docs/build/profile/branch/index.md new file mode 100644 index 0000000..f129d82 --- /dev/null +++ b/docs/build/profile/branch/index.md @@ -0,0 +1,19 @@ +# `appcircle build profile branch` + +Manage branches of a build profile. + +```plaintext +appcircle build profile branch [command] [options] +``` + +## Options inherited from parent commands + +```plaintext + --help Show help for command +``` + +## Subcommands + +- [`list`](list.md) +- [`commits`](commits.md) + diff --git a/docs/build/profile/branch/list.md b/docs/build/profile/branch/list.md new file mode 100644 index 0000000..c0fd0ab --- /dev/null +++ b/docs/build/profile/branch/list.md @@ -0,0 +1,19 @@ +# `appcircle build profile branch list` + +Get list of branches of a build profile + +```plaintext +appcircle build profile branch list [options] +``` + +## Options + +```plaintext + --profileId Build profile ID +``` + +## Options inherited from parent commands + +```plaintext + --help Show help for command +``` diff --git a/docs/build/profile/configurations.md b/docs/build/profile/configurations.md new file mode 100644 index 0000000..1b3ad79 --- /dev/null +++ b/docs/build/profile/configurations.md @@ -0,0 +1,19 @@ +# `appcircle build profile configurations` + +Get list of configurations of a build profile + +```plaintext +appcircle build profile configurations [options] +``` + +## Options + +```plaintext + --profileId Build profile ID +``` + +## Options inherited from parent commands + +```plaintext + --help Show help for command +``` diff --git a/docs/build/profile/index.md b/docs/build/profile/index.md new file mode 100644 index 0000000..55f8d19 --- /dev/null +++ b/docs/build/profile/index.md @@ -0,0 +1,21 @@ +# `appcircle build profile` + +Manage build profile actions. + +```plaintext +appcircle build profile [command] [options] +``` + +## Options inherited from parent commands + +```plaintext + --help Show help for command +``` + +## Subcommands + +- [`list`](list.md) +- [`branch`](branch/index.md) +- [`workflows`](workflows.md) +- [`configurations`](configurations.md) + diff --git a/docs/build/profile/list.md b/docs/build/profile/list.md new file mode 100644 index 0000000..fd80f58 --- /dev/null +++ b/docs/build/profile/list.md @@ -0,0 +1,13 @@ +# `appcircle build profile list` + +Get list of build profiles. + +```plaintext +appcircle build profile list +``` + +## Options inherited from parent commands + +```plaintext + --help Show help for command +``` diff --git a/docs/build/profile/workflows.md b/docs/build/profile/workflows.md new file mode 100644 index 0000000..ad8207a --- /dev/null +++ b/docs/build/profile/workflows.md @@ -0,0 +1,19 @@ +# `appcircle build profile workflows` + +Get list of workflows of a build profile + +```plaintext +appcircle build profile workflows [options] +``` + +## Options + +```plaintext + --profileId Build profile ID +``` + +## Options inherited from parent commands + +```plaintext + --help Show help for command +``` diff --git a/docs/build/start.md b/docs/build/start.md new file mode 100644 index 0000000..0bde7ae --- /dev/null +++ b/docs/build/start.md @@ -0,0 +1,24 @@ +# `appcircle build start` + +Start a new build. + +```plaintext +appcircle build start [options] +``` + +## Options + +```plaintext + --profileId Build profile ID + --branchId Branch ID + --commitId Commit ID [Optional] + --configurationId Configuration ID [Optional] + --workflowId Workflow ID + --branch Branch Name instead of 'branch ID' + --workflow Workflow Name instead of 'workflow ID' +``` +## Options inherited from parent commands + +```plaintext + --help Show help for command +``` diff --git a/docs/build/variable/create.md b/docs/build/variable/create.md new file mode 100644 index 0000000..d470eeb --- /dev/null +++ b/docs/build/variable/create.md @@ -0,0 +1,31 @@ +# `appcircle build variable create` + +Create a file or text environment variable. + +```plaintext +appcircle build variable create [options] +``` +## Examples + +```plaintext +$ appcircle build variable create --variableGroupId "Variable Group ID" --type "text" --key "Key Name" --value "Key Value" --isSecret true + +$ appcircle build variable create --variableGroupId "Variable Group ID" --type "file" --key "Key Name" --filePath "File Path" +``` + +## Options + +```plaintext + --variableGroupId Variable Group ID + --type Type [file, text] + --isSecret Secret + --key Key Name + --value Key Value + --filePath File Path +``` + +## Options inherited from parent commands + +```plaintext + --help Show help for command +``` diff --git a/docs/build/variable/group/create.md b/docs/build/variable/group/create.md new file mode 100644 index 0000000..096cf1a --- /dev/null +++ b/docs/build/variable/group/create.md @@ -0,0 +1,24 @@ +# `appcircle build variable group create` + +Create an environment variable group + +```plaintext +appcircle build variable group create [options] +``` +## Examples + +```plaintext +$ appcircle build variable group create --name "variable group" +``` + +## Options + +```plaintext + --name Variable group name +``` + +## Options inherited from parent commands + +```plaintext + --help Show help for command +``` diff --git a/docs/build/variable/group/index.md b/docs/build/variable/group/index.md new file mode 100644 index 0000000..599bfa0 --- /dev/null +++ b/docs/build/variable/group/index.md @@ -0,0 +1,19 @@ +# `appcircle build variable group` + +View and create environment variable groups. + +```plaintext +appcircle build variable group [command] [options] +``` + +## Options inherited from parent commands + +```plaintext + --help Show help for command +``` + +## Subcommands + +- [`list`](list.md) +- [`create`](create.md) + diff --git a/docs/build/variable/group/list.md b/docs/build/variable/group/list.md new file mode 100644 index 0000000..410ea6e --- /dev/null +++ b/docs/build/variable/group/list.md @@ -0,0 +1,13 @@ +# `appcircle build variable group list` + +List environment variable groups. + +```plaintext +appcircle build variable group list +``` + +## Options inherited from parent commands + +```plaintext + --help Show help for command +``` diff --git a/docs/build/variable/index.md b/docs/build/variable/index.md new file mode 100644 index 0000000..51786b5 --- /dev/null +++ b/docs/build/variable/index.md @@ -0,0 +1,20 @@ +# `appcircle build variable` + +View and set environment variables for builds. + +```plaintext +appcircle build variable [command] [options] +``` + +## Options inherited from parent commands + +```plaintext + --help Show help for command +``` + +## Subcommands + +- [`group`](group/index.md) +- [`create`](create.md) +- [`view`](view.md) + diff --git a/docs/build/variable/view.md b/docs/build/variable/view.md new file mode 100644 index 0000000..aa309c2 --- /dev/null +++ b/docs/build/variable/view.md @@ -0,0 +1,19 @@ +# `appcircle build variable view` + +Get list of environment variables + +```plaintext +appcircle build variable view [options] +``` + +## Options + +```plaintext + --variableGroupId Variable Groups ID +``` + +## Options inherited from parent commands + +```plaintext + --help Show help for command +``` diff --git a/docs/build/view.md b/docs/build/view.md new file mode 100644 index 0000000..695e489 --- /dev/null +++ b/docs/build/view.md @@ -0,0 +1,19 @@ +# `appcircle build view` + +View comprehensive details of a build, including its status, duration, and other relevant information. + +```plaintext +appcircle build view [options] +``` + +## Options + +```plaintext + --commitId Commit ID of your build + --buildId Build ID +``` +## Options inherited from parent commands + +```plaintext + --help Show help for command +``` diff --git a/docs/config/add.md b/docs/config/add.md new file mode 100644 index 0000000..fe3bfe0 --- /dev/null +++ b/docs/config/add.md @@ -0,0 +1,20 @@ +# `appcircle config add` + +Add a new Appcircle CLI configuration environment. + +```plaintext +appcircle config add +``` + +## Arguments + +| Argument | Description | +| --------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------- | +| `value` | New configuration environment name + + +## Options inherited from parent commands + +```plaintext + --help Show help for command +``` diff --git a/docs/config/current.md b/docs/config/current.md new file mode 100644 index 0000000..2bf0cb6 --- /dev/null +++ b/docs/config/current.md @@ -0,0 +1,26 @@ +# `appcircle config current` + +Set the currently active configuration environment in the Appcircle CLI. + +```plaintext +appcircle config current +``` +## Examples + +```plaintext +$ appcircle config current default +$ appcircle config current development +$ appcircle config current production +``` + +## Arguments + +| Argument | Description | +| --------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------- | +| `value` | Current configuration environment name | + +## Options inherited from parent commands + +```plaintext + --help Show help for command +``` diff --git a/docs/config/get.md b/docs/config/get.md new file mode 100644 index 0000000..a4ae51c --- /dev/null +++ b/docs/config/get.md @@ -0,0 +1,26 @@ +# `appcircle config get` + +Print the value of the currently active configuration property in the Appcircle CLI. + +```plaintext +appcircle config get +``` +## Examples + +```plaintext +$ appcircle config get API_HOSTNAME +$ appcircle config get AUTH_HOSTNAME +$ appcircle config get AC_ACCESS_TOKEN +``` + +## Arguments + +| Argument | Description | +| --------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------- | +| `key` | Config key [API_HOSTNAME, AUTH_HOSTNAME, AC_ACCESS_TOKEN] + +## Options inherited from parent commands + +```plaintext + --help Show help for command +``` diff --git a/docs/config/index.md b/docs/config/index.md new file mode 100644 index 0000000..7602919 --- /dev/null +++ b/docs/config/index.md @@ -0,0 +1,24 @@ +# `appcircle config` + +View and set Appcircle CLI properties + +```plaintext +appcircle config [command] [options] +``` + +## Options inherited from parent commands + +```plaintext + --help Show help for command +``` + +## Subcommands + +- [`list`](list.md) +- [`get`](get.md) +- [`set`](set.md) +- [`current`](current.md) +- [`add`](add.md) +- [`reset`](reset.md) +- [`trust`](trust.md) + diff --git a/docs/config/list.md b/docs/config/list.md new file mode 100644 index 0000000..ad372f5 --- /dev/null +++ b/docs/config/list.md @@ -0,0 +1,13 @@ +# `appcircle config list` + +List all configuration properties in the Appcircle CLI. + +```plaintext +appcircle config list +``` + +## Options inherited from parent commands + +```plaintext + --help Show help for command +``` diff --git a/docs/config/reset.md b/docs/config/reset.md new file mode 100644 index 0000000..6532fca --- /dev/null +++ b/docs/config/reset.md @@ -0,0 +1,13 @@ +# `appcircle config reset` + +Reset a Appcircle CLI configuration to default. + +```plaintext +appcircle config reset +``` + +## Options inherited from parent commands + +```plaintext + --help Show help for command +``` diff --git a/docs/config/set.md b/docs/config/set.md new file mode 100644 index 0000000..6e11116 --- /dev/null +++ b/docs/config/set.md @@ -0,0 +1,25 @@ +# `appcircle config set` + +Set a Appcircle CLI currently active configuration property. + +```plaintext +appcircle config set +``` +## Examples + +```plaintext +$ appcircle config set AUTH_HOSTNAME https://auth.example.com +``` + +## Arguments + +| Argument | Description | +| --------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------- | +| `key` | Config key [API_HOSTNAME, AUTH_HOSTNAME, AC_ACCESS_TOKEN] | +`value` | Config value + +## Options inherited from parent commands + +```plaintext + --help Show help for command +``` diff --git a/docs/config/trust.md b/docs/config/trust.md new file mode 100644 index 0000000..c9dec5f --- /dev/null +++ b/docs/config/trust.md @@ -0,0 +1,13 @@ +# `appcircle config trust` + +Trust the SSL certificate of your self-hosted Appcircle server. By default, the system retrieves the server host from the `API_HOST` property of the current environment. + +```plaintext +appcircle config trust +``` + +## Options inherited from parent commands + +```plaintext + --help Show help for command +``` diff --git a/docs/distribution/index.md b/docs/distribution/index.md new file mode 100644 index 0000000..4294986 --- /dev/null +++ b/docs/distribution/index.md @@ -0,0 +1,18 @@ +# `appcircle distribution` + +Testing distribution management + +```plaintext +appcircle distribution [command] [options] +``` + +## Options inherited from parent commands + +```plaintext + --help Show help for command +``` + +## Subcommands + +- [`upload`](upload.md) +- [`profile`](profile/index.md) diff --git a/docs/distribution/profile/create.md b/docs/distribution/profile/create.md new file mode 100644 index 0000000..bee320a --- /dev/null +++ b/docs/distribution/profile/create.md @@ -0,0 +1,18 @@ +# `appcircle distribution profile create` + +Create a distribution profile. + +```plaintext +appcircle distribution profile create [options] +``` + +## Options + +```plaintext + --name Profile name +``` +## Options inherited from parent commands + +```plaintext + --help Show help for command +``` diff --git a/docs/distribution/profile/index.md b/docs/distribution/profile/index.md new file mode 100644 index 0000000..18d091c --- /dev/null +++ b/docs/distribution/profile/index.md @@ -0,0 +1,18 @@ +# `appcircle distribution profile` + +Distribution profile actions + +```plaintext +appcircle distribution profile [command] [options] +``` + +## Options inherited from parent commands + +```plaintext + --help Show help for command +``` + +## Subcommands + +- [`list`](list.md) +- [`create`](create.md) diff --git a/docs/distribution/profile/list.md b/docs/distribution/profile/list.md new file mode 100644 index 0000000..b1a9937 --- /dev/null +++ b/docs/distribution/profile/list.md @@ -0,0 +1,13 @@ +# `appcircle distribution profile list` + +Get list of distribution profiles. + +```plaintext +appcircle distribution profile list +``` + +## Options inherited from parent commands + +```plaintext + --help Show help for command +``` diff --git a/docs/distribution/upload.md b/docs/distribution/upload.md new file mode 100644 index 0000000..faadc5c --- /dev/null +++ b/docs/distribution/upload.md @@ -0,0 +1,20 @@ +# `appcircle distribution upload` + +Upload your mobile app to selected distribution profile. + +```plaintext +appcircle distribution upload [options] +``` + +## Options + +```plaintext + --distProfileId Distribution profile ID + --message Release notes + --app App path +``` +## Options inherited from parent commands + +```plaintext + --help Show help for command +``` diff --git a/docs/enterprise-app-store/index.md b/docs/enterprise-app-store/index.md new file mode 100644 index 0000000..47cf3dd --- /dev/null +++ b/docs/enterprise-app-store/index.md @@ -0,0 +1,19 @@ +# `appcircle enterprise-app-store` + +Manage enterprise app store actions. + +```plaintext +appcircle enterprise-app-store [command] [options] +``` + +## Options inherited from parent commands + +```plaintext + --help Show help for command +``` + +## Subcommands + +- [`profie`](profile/index.md) +- [`version`](version/index.md) + diff --git a/docs/enterprise-app-store/profile/index.md b/docs/enterprise-app-store/profile/index.md new file mode 100644 index 0000000..7ba14d2 --- /dev/null +++ b/docs/enterprise-app-store/profile/index.md @@ -0,0 +1,18 @@ +# `appcircle enterprise-app-store profile` + +Enterprise app profile actions + +```plaintext +appcircle enterprise-app-store profile [command] [options] +``` + +## Options inherited from parent commands + +```plaintext + --help Show help for command +``` + +## Subcommands + +- [`list`](list.md) + diff --git a/docs/enterprise-app-store/profile/list.md b/docs/enterprise-app-store/profile/list.md new file mode 100644 index 0000000..bc2ee24 --- /dev/null +++ b/docs/enterprise-app-store/profile/list.md @@ -0,0 +1,13 @@ +# `appcircle enterprise-app-store profile list` + +Get list of enterprise profiles. + +```plaintext +appcircle enterprise-app-store profile list [options] +``` + +## Options inherited from parent commands + +```plaintext + --help Show help for command +``` diff --git a/docs/enterprise-app-store/version/download-link.md b/docs/enterprise-app-store/version/download-link.md new file mode 100644 index 0000000..1de906c --- /dev/null +++ b/docs/enterprise-app-store/version/download-link.md @@ -0,0 +1,21 @@ +# `appcircle enterprise-app-store version download-link` + +Get enterprise app download link. + +```plaintext +appcircle enterprise-app-store version download-link [options] +``` + +## Options + +```plaintext + --entProfileId Enterprise profile ID + + --entVersionId App version ID +``` + +## Options inherited from parent commands + +```plaintext + --help Show help for command +``` diff --git a/docs/enterprise-app-store/version/index.md b/docs/enterprise-app-store/version/index.md new file mode 100644 index 0000000..ced0083 --- /dev/null +++ b/docs/enterprise-app-store/version/index.md @@ -0,0 +1,25 @@ +# `appcircle enterprise-app-store version` + +Enterprise app version actions. + +```plaintext +appcircle enterprise-app-store version [command] [options] +``` + +## Options inherited from parent commands + +```plaintext + --help Show help for command +``` + +## Subcommands + +- [`list`](list.md) +- [`publish`](publish.md) +- [`unpublish`](unpublish.md) +- [`remove`](remove.md) +- [`notify`](notify.md) +- [`upload-for-profile`](upload-for-profile.md) +- [`upload-without-profile`](upload-without-profile.md) +- [`download-link`](download-link.md) + diff --git a/docs/enterprise-app-store/version/list.md b/docs/enterprise-app-store/version/list.md new file mode 100644 index 0000000..f85287d --- /dev/null +++ b/docs/enterprise-app-store/version/list.md @@ -0,0 +1,21 @@ +# `appcircle enterprise-app-store version list` + +Get list of enterprise app versions. + +```plaintext +appcircle enterprise-app-store version list [options] +``` + +## Options + +```plaintext + --entProfileId Enterprise Profile ID + + --publishType Publish Type Empty,0=All,1=Beta,2=Live (default: "0") +``` + +## Options inherited from parent commands + +```plaintext + --help Show help for command +``` diff --git a/docs/enterprise-app-store/version/notify.md b/docs/enterprise-app-store/version/notify.md new file mode 100644 index 0000000..08da352 --- /dev/null +++ b/docs/enterprise-app-store/version/notify.md @@ -0,0 +1,25 @@ +# `appcircle enterprise-app-store version notify` + +Notify enterprise app version to users. + +```plaintext +appcircle enterprise-app-store version notify [options] +``` + +## Options + +```plaintext + --entProfileId Enterprise profile ID + + --entVersionId App version ID + + --subject Subject + + --message Message +``` + +## Options inherited from parent commands + +```plaintext + --help Show help for command +``` diff --git a/docs/enterprise-app-store/version/publish.md b/docs/enterprise-app-store/version/publish.md new file mode 100644 index 0000000..820dc9e --- /dev/null +++ b/docs/enterprise-app-store/version/publish.md @@ -0,0 +1,27 @@ +# `appcircle enterprise-app-store version publish` + +Publish enterprise app version. + +```plaintext +appcircle enterprise-app-store version publish [options] +``` + +## Options + +```plaintext + --entProfileId Enterprise Profile ID + + --entVersionId App Version ID + + --summary Summary + + --releaseNotes Release Notes + + --publishType Publish Type 0=None,1=Beta,2=Live +``` + +## Options inherited from parent commands + +```plaintext + --help Show help for command +``` diff --git a/docs/enterprise-app-store/version/remove.md b/docs/enterprise-app-store/version/remove.md new file mode 100644 index 0000000..11475bc --- /dev/null +++ b/docs/enterprise-app-store/version/remove.md @@ -0,0 +1,21 @@ +# `appcircle enterprise-app-store version remove` + +Remove enterprise app version. + +```plaintext +appcircle enterprise-app-store version remove [options] +``` + +## Options + +```plaintext + --entProfileId Enterprise profile ID + + --entVersionId App version ID +``` + +## Options inherited from parent commands + +```plaintext + --help Show help for command +``` diff --git a/docs/enterprise-app-store/version/unpublish.md b/docs/enterprise-app-store/version/unpublish.md new file mode 100644 index 0000000..34ca173 --- /dev/null +++ b/docs/enterprise-app-store/version/unpublish.md @@ -0,0 +1,21 @@ +# `appcircle enterprise-app-store version unpublish` + +Unpublish enterprise app version. + +```plaintext +appcircle enterprise-app-store version unpublish [options] +``` + +## Options + +```plaintext + --entProfileId Enterprise profile ID + + --entVersionId App version ID +``` + +## Options inherited from parent commands + +```plaintext + --help Show help for command +``` diff --git a/docs/enterprise-app-store/version/upload-for-profie.md b/docs/enterprise-app-store/version/upload-for-profie.md new file mode 100644 index 0000000..824f357 --- /dev/null +++ b/docs/enterprise-app-store/version/upload-for-profie.md @@ -0,0 +1,21 @@ +# `appcircle enterprise-app-store version upload-for-profile` + +Upload enterprise app version for a profile. + +```plaintext +appcircle enterprise-app-store version upload-for-profile [options] +``` + +## Options + +```plaintext + --entProfileId Enterprise profile ID + + --app App path +``` + +## Options inherited from parent commands + +```plaintext + --help Show help for command +``` diff --git a/docs/enterprise-app-store/version/upload-without-profile.md b/docs/enterprise-app-store/version/upload-without-profile.md new file mode 100644 index 0000000..c8317bf --- /dev/null +++ b/docs/enterprise-app-store/version/upload-without-profile.md @@ -0,0 +1,19 @@ +# `appcircle enterprise-app-store version upload-without-profile` + +Upload enterprise app version without a profile. + +```plaintext +appcircle enterprise-app-store version upload-without-profile [options] +``` + +## Options + +```plaintext + --app App path +``` + +## Options inherited from parent commands + +```plaintext + --help Show help for command +``` diff --git a/docs/login/index.md b/docs/login/index.md new file mode 100644 index 0000000..5077ace --- /dev/null +++ b/docs/login/index.md @@ -0,0 +1,19 @@ +# `appcircle login` + +Log in to obtain your access token. + +```plaintext +appcircle login [options] +``` + +## Options + +```plaintext + --pat Personal Access Token +``` + +## Options inherited from parent commands + +```plaintext + --help Show help for command +``` diff --git a/docs/migration-guides/1.x-to-2.x.md b/docs/migration-guides/1.x-to-2.x.md new file mode 100644 index 0000000..be51c0a --- /dev/null +++ b/docs/migration-guides/1.x-to-2.x.md @@ -0,0 +1,482 @@ +# Appcircle CLI Migration Guide from Version 1.x to 2.x + +## Introduction +This guide provides instructions for migrating Appcircle CLI commands from version 1.x to version 2.x. It outlines the changes in the command structure and provides examples for updating your commands accordingly. + + +## Update Command Syntax +- Modify the syntax of commands according to the changes in version 2.x. Use the following format: + - Old command syntax: + ```bash + appcircle oldCommand [options] [arguments] + ``` + - New command syntax: + ```bash + appcircle ... [options] [arguments] + ``` + +## Command Migration Guide + This guide outlines the changes required to migrate your existing Appcircle CLI commands from version 1.x to version 2.x. Below, you'll find a list of all commands along with the corresponding changes needed for each. + + - [appcircle publish profile version markAsRC](#appcircle-publish-profile-version-markasrc) + - [appcircle publish profile version unmarkAsRC](#appcircle-publish-profile-version-unmarkasrc) + - [appcircle listBuildProfiles](#appcircle-listbuildprofiles) + - [appcircle listBuildProfileBranches](#appcircle-listbuildprofilebranches) + - [appcircle listBuildProfileWorkflows](#appcircle-listbuildprofileworkflows) + - [appcircle listBuildProfileCommits](#appcircle-listbuildprofilecommits) + - [appcircle listBuildProfileBuildsOfCommit](#appcircle-listbuildprofilebuildsofcommit) + - [appcircle listDistributionProfiles](#appcircle-listdistributionprofiles) + - [appcircle build](#appcircle-build) + - [appcircle download](#appcircle-download) + - [appcircle upload](#appcircle-upload) + - [appcircle createDistributionProfile](#appcircle-createdistributionprofile) + - [appcircle listEnvironmentVariableGroups](#appcircle-listenvironmentvariablegroups) + - [appcircle createEnvironmentVariableGroup](#appcircle-createenvironmentvariablegroup) + - [appcircle listEnvironmentVariables](#appcircle-listenvironmentvariables) + - [appcircle createEnvironmentVariable](#appcircle-createenvironmentvariable) + - [appcircle listEnterpriseProfiles](#appcircle-listenterpriseprofiles) + - [appcircle listEnterpriseAppVersions](#appcircle-listenterpriseappversions) + - [appcircle publishEnterpriseAppVersion](#appcircle-publishenterpriseappversion) + - [appcircle unpublishEnterpriseAppVersion](#appcircle-unpublishenterpriseappversion) + - [appcircle removeEnterpriseAppVersion](#appcircle-removeenterpriseappversion) + - [appcircle notifyEnterpriseAppVersion](#appcircle-notifyenterpriseappversion) + - [appcircle uploadEnterpriseAppVersion](#appcircle-uploadenterpriseappversion) + - [appcircle uploadEnterpriseApp](#appcircle-uploadenterpriseapp) + - [appcircle getEnterpriseDownloadLink](#appcircle-getenterprisedownloadlink) + +--- + + +### ```appcircle publish profile version markAsRC``` + +- [See also](/docs/publish/profile/version/mark-as-rc.md) + +**Old Command:** +```sh +$ appcircle publish profile version markAsRC [options] [arguments] +``` +**New Command:** + +```sh +$ appcircle publish profile version mark-as-rc [options] [arguments] +``` + + +--- + + +### ```appcircle publish profile version unmarkAsRC``` + +- [See also](/docs/publish/profile/version/unmark-as-rc.md) + +**Old Command:** +```sh +$ appcircle publish profile version unmarkAsRC [options] [arguments] +``` +**New Command:** + +```sh +$ appcircle publish profile version unmark-as-rc [options] [arguments] +``` + +--- + + +### ```appcircle listBuildProfiles``` + +- [See also](/docs/build/profile/list.md) + +**Old Command:** +```sh +$ appcircle listBuildProfiles [options] [arguments] +``` +**New Command:** + +```sh +$ appcircle build profile list [options] [arguments] +``` + + +--- + + +### ```appcircle listBuildProfileBranches``` + +- [See also](/docs/build/profile/branch/list.md) + +**Old Command:** +```sh +$ appcircle listBuildProfileBranches [options] [arguments] +``` +**New Command:** + +```sh +$ appcircle build profile branch list [options] [arguments] +``` + + +--- + +### ```appcircle listBuildProfileWorkflows``` + +- [See also](/docs/build/profile/workflows.md) + +**Old Command:** +```sh +$ appcircle listBuildProfileWorkflows [options] [arguments] +``` +**New Command:** + +```sh +$ appcircle build profile workflows [options] [arguments] +``` + + +--- + +### ```appcircle listBuildProfileConfigurations``` + +- [See also](/docs/build/profile/configurations.md) + +**Old Command:** +```sh +$ appcircle listBuildProfileConfigurations [options] [arguments] +``` +**New Command:** + +```sh +$ appcircle build profile configurations [options] [arguments] +``` + + +--- + +### ```appcircle listBuildProfileCommits``` + +- [See also](/docs/build/profile/branch/commits.md) + +**Old Command:** +```sh +$ appcircle listBuildProfileCommits [options] [arguments] +``` +**New Command:** + +```sh +$ appcircle build profile branch commits [options] [arguments] +``` + + +--- + +### ```appcircle listBuildProfileBuildsOfCommit``` + +- [See also](/docs/build/list.md) + +**Old Command:** +```sh +$ appcircle listBuildProfileBuildsOfCommit [options] [arguments] +``` +**New Command:** + +```sh +$ appcircle build list [options] [arguments] +``` + + +--- + +### ```appcircle listDistributionProfiles``` + +- [See also](/docs/distribution/profile/list.md) + +**Old Command:** +```sh +$ appcircle listDistributionProfiles [options] [arguments] +``` +**New Command:** + +```sh +$ appcircle distribution profile list [options] [arguments] +``` + + +--- + +### ```appcircle build``` + +- [See also](/docs/build/start.md) + +**Old Command:** +```sh +$ appcircle build [options] [arguments] +``` +**New Command:** + +```sh +$ appcircle build start [options] [arguments] +``` + + +--- + +### ```appcircle download``` + +- [See also](/docs/build/download.md) + +**Old Command:** +```sh +$ appcircle download [options] [arguments] +``` +**New Command:** + +```sh +$ appcircle build download [options] [arguments] +``` + + +--- + +### ```appcircle upload``` + +- [See also](/docs/distribution/upload.md) + +**Old Command:** +```sh +$ appcircle upload [options] [arguments] +``` +**New Command:** + +```sh +$ appcircle distribution upload [options] [arguments] +``` + + +--- + +### ```appcircle createDistributionProfile``` + +- [See also](/docs/distribution/profile/create.md) + +**Old Command:** +```sh +$ appcircle createDistributionProfile [options] [arguments] +``` +**New Command:** + +```sh +$ appcircle distribution profile create [options] [arguments] +``` + + +--- + +### ```appcircle listEnvironmentVariableGroups``` + +- [See also](/docs/build/variable/group/list.md) + +**Old Command:** +```sh +$ appcircle listEnvironmentVariableGroups [options] [arguments] +``` +**New Command:** + +```sh +$ appcircle build variable group list [options] [arguments] +``` + + +--- + +### ```appcircle createEnvironmentVariableGroup``` + +- [See also](/docs/build/variable/group/create.md) + +**Old Command:** +```sh +$ appcircle createEnvironmentVariableGroup [options] [arguments] +``` +**New Command:** + +```sh +$ appcircle build variable group create [options] [arguments] +``` + + +--- + +### ```appcircle listEnvironmentVariables``` + +- [See also](/docs/build/variable/view.md) + +**Old Command:** +```sh +$ appcircle listEnvironmentVariables [options] [arguments] +``` +**New Command:** + +```sh +$ appcircle build variable view [options] [arguments] +``` + + +--- + +### ```appcircle createEnvironmentVariable``` + +- [See also](/docs/build/variable/create.md) + +**Old Command:** +```sh +$ appcircle createEnvironmentVariable [options] [arguments] +``` +**New Command:** + +```sh +$ appcircle build variable create [options] [arguments] +``` + +--- + +### ```appcircle listEnterpriseProfiles``` + +- [See also](/docs/enterprise-app-store/profile/list.md) + +**Old Command:** +```sh +$ appcircle listEnterpriseProfiles [options] [arguments] +``` +**New Command:** + +```sh +$ appcircle enterprise-app-store profile list [options] [arguments] +``` + +--- + +### ```appcircle listEnterpriseAppVersions``` + +- [See also](/docs/enterprise-app-store/version/list.md) + +**Old Command:** +```sh +$ appcircle listEnterpriseAppVersions [options] [arguments] +``` +**New Command:** + +```sh +$ appcircle enterprise-app-store version list [options] [arguments] +``` + +--- + +### ```appcircle publishEnterpriseAppVersion``` + +- [See also](/docs/enterprise-app-store/version/publish.md) + +**Old Command:** +```sh +$ appcircle publishEnterpriseAppVersion [options] [arguments] +``` +**New Command:** + +```sh +$ appcircle enterprise-app-store version publish [options] [arguments] +``` + +--- + +### ```appcircle unpublishEnterpriseAppVersion``` + +- [See also](/docs/enterprise-app-store/version/unpublish.md) + +**Old Command:** +```sh +$ appcircle unpublishEnterpriseAppVersion [options] [arguments] +``` +**New Command:** + +```sh +$ appcircle enterprise-app-store version unpublish [options] [arguments] +``` + +--- + +### ```appcircle removeEnterpriseAppVersion``` + +- [See also](/docs/enterprise-app-store/version/remove.md) + +**Old Command:** +```sh +$ appcircle removeEnterpriseAppVersion [options] [arguments] +``` +**New Command:** + +```sh +$ appcircle enterprise-app-store version remove [options] [arguments] +``` + +--- + +### ```appcircle notifyEnterpriseAppVersion``` + +- [See also](/docs/enterprise-app-store/version/notify.md) + +**Old Command:** +```sh +$ appcircle notifyEnterpriseAppVersion [options] [arguments] +``` +**New Command:** + +```sh +$ appcircle enterprise-app-store version notify [options] [arguments] +``` + +--- + +### ```appcircle uploadEnterpriseAppVersion``` + +- [See also](/docs/enterprise-app-store/version/upload-for-profie.md) + +**Old Command:** +```sh +$ appcircle uploadEnterpriseAppVersion [options] [arguments] +``` +**New Command:** + +```sh +$ appcircle enterprise-app-store version upload-for-profile [options] [arguments] +``` + +--- + +### ```appcircle uploadEnterpriseApp``` + +- [See also](/docs/enterprise-app-store/version/upload-without-profile.md) + +**Old Command:** +```sh +$ appcircle uploadEnterpriseApp [options] [arguments] +``` +**New Command:** + +```sh +$ appcircle enterprise-app-store version upload-without-profile [options] [arguments] +``` + +--- + +### ```appcircle getEnterpriseDownloadLink``` + +- [See also](/docs/enterprise-app-store/version/download-link.md) + +**Old Command:** +```sh +$ appcircle getEnterpriseDownloadLink [options] [arguments] +``` +**New Command:** + +```sh +$ appcircle enterprise-app-store version download-link [options] [arguments] +``` + +--- \ No newline at end of file diff --git a/docs/organization/index.md b/docs/organization/index.md new file mode 100644 index 0000000..9cc3ff1 --- /dev/null +++ b/docs/organization/index.md @@ -0,0 +1,20 @@ +# `appcircle organization` + +Manage organization users, roles, and details. + +```plaintext +appcircle organization [command] [options] +``` + +## Options inherited from parent commands + +```plaintext + --help Show help for command +``` + +## Subcommands + +- [`view`](view.md) +- [`user`](user/index.md) +- [`role`](role/index.md) + diff --git a/docs/organization/role/add.md b/docs/organization/role/add.md new file mode 100644 index 0000000..6367177 --- /dev/null +++ b/docs/organization/role/add.md @@ -0,0 +1,22 @@ +# `appcircle organization role add` + +Add roles to the given userId within the organizationId. + +```plaintext +appcircle organization role add [options] +``` + +## Options + +```plaintext + --organizationId Organization ID [Optional] (default: "current") + + --userId User ID + + --role Roles +``` +## Options inherited from parent commands + +```plaintext + --help Show help for command +``` diff --git a/docs/organization/role/clear.md b/docs/organization/role/clear.md new file mode 100644 index 0000000..42f1e0e --- /dev/null +++ b/docs/organization/role/clear.md @@ -0,0 +1,20 @@ +# `appcircle organization role clear` + +Remove all roles from the given userId within the organizationId. + +```plaintext +appcircle organization role clear [options] +``` + +## Options + +```plaintext + --organizationId Organization ID [Optional] (default: "current") + + --userId User ID +``` +## Options inherited from parent commands + +```plaintext + --help Show help for command +``` diff --git a/docs/organization/role/index.md b/docs/organization/role/index.md new file mode 100644 index 0000000..4dfba88 --- /dev/null +++ b/docs/organization/role/index.md @@ -0,0 +1,21 @@ +# `appcircle organization role` + +Organization users roles management (view, add, remove, clear ). + +```plaintext +appcircle organization role [command] [options] +``` + +## Options inherited from parent commands + +```plaintext + --help Show help for command +``` + +## Subcommands + +- [`view`](view.md) +- [`add`](add.md) +- [`remove`](remove.md) +- [`clear`](clear.md) + diff --git a/docs/organization/role/remove.md b/docs/organization/role/remove.md new file mode 100644 index 0000000..f222521 --- /dev/null +++ b/docs/organization/role/remove.md @@ -0,0 +1,22 @@ +# `appcircle organization role remove` + +Remove given roles from the given userId within the organizationId. + +```plaintext +appcircle organization role add [options] +``` + +## Options + +```plaintext + --organizationId Organization ID [Optional] (default: "current") + + --userId User ID + + --role Roles +``` +## Options inherited from parent commands + +```plaintext + --help Show help for command +``` diff --git a/docs/organization/role/view.md b/docs/organization/role/view.md new file mode 100644 index 0000000..900c154 --- /dev/null +++ b/docs/organization/role/view.md @@ -0,0 +1,20 @@ +# `appcircle organization role view` + +View roles of the given userId within the organizationId. + +```plaintext +appcircle organization role view [options] +``` + +## Options + +```plaintext + --organizationId Organization ID [Optional] (default: "current") + + --userId User ID +``` +## Options inherited from parent commands + +```plaintext + --help Show help for command +``` diff --git a/docs/organization/user/index.md b/docs/organization/user/index.md new file mode 100644 index 0000000..51753a3 --- /dev/null +++ b/docs/organization/user/index.md @@ -0,0 +1,21 @@ +# `appcircle organization user` + +Organization users management (view, invite, re-invite, remove ). + +```plaintext +appcircle organization user [command] [options] +``` + +## Options inherited from parent commands + +```plaintext + --help Show help for command +``` + +## Subcommands + +- [`view`](view.md) +- [`invite`](invite.md) +- [`re-invide`](re-invite.md) +- [`remove`](remove.md) + diff --git a/docs/organization/user/invite.md b/docs/organization/user/invite.md new file mode 100644 index 0000000..878e09d --- /dev/null +++ b/docs/organization/user/invite.md @@ -0,0 +1,21 @@ +# `appcircle organization user invite` + +Invite user to organization. + +```plaintext +appcircle organization user invite [options] +``` + +## Options + +```plaintext + --organizationId Organization ID [Optional] (default: "current") + --email Email + --role Role + +``` +## Options inherited from parent commands + +```plaintext + --help Show help for command +``` diff --git a/docs/organization/user/re-invite.md b/docs/organization/user/re-invite.md new file mode 100644 index 0000000..516c5d9 --- /dev/null +++ b/docs/organization/user/re-invite.md @@ -0,0 +1,20 @@ +# `appcircle organization user re-invite` + +Re-invite user to organization. + +```plaintext +appcircle organization user re-invite [options] +``` + +## Options + +```plaintext + --organizationId Organization ID [Optional] (default: "current") + --email Email + +``` +## Options inherited from parent commands + +```plaintext + --help Show help for command +``` diff --git a/docs/organization/user/remove.md b/docs/organization/user/remove.md new file mode 100644 index 0000000..7ea3b91 --- /dev/null +++ b/docs/organization/user/remove.md @@ -0,0 +1,21 @@ +# `appcircle organization user remove` + +Remove user or inivation from organization. + +```plaintext +appcircle organization user remove [options] +``` + +## Options + +```plaintext + --organizationId Organization ID [Optional] (default: "current") + --userId User ID + --email Email (default: "") + +``` +## Options inherited from parent commands + +```plaintext + --help Show help for command +``` diff --git a/docs/organization/user/view.md b/docs/organization/user/view.md new file mode 100644 index 0000000..526b9e1 --- /dev/null +++ b/docs/organization/user/view.md @@ -0,0 +1,18 @@ +# `appcircle organization user view` + +View users of organization. + +```plaintext +appcircle organization user view [options] +``` + +## Options + +```plaintext + --organizationId Organization ID [Optional] (default: "current") +``` +## Options inherited from parent commands + +```plaintext + --help Show help for command +``` diff --git a/docs/organization/view.md b/docs/organization/view.md new file mode 100644 index 0000000..d13de9e --- /dev/null +++ b/docs/organization/view.md @@ -0,0 +1,18 @@ +# `appcircle organization view` + +View organization details. If "organizationId" not provided, will list all organizations. + +```plaintext +appcircle organization view [options] +``` + +## Options + +```plaintext + --organizationId Organization ID [Optional] (default: "all") +``` +## Options inherited from parent commands + +```plaintext + --help Show help for command +``` diff --git a/docs/publish/index.md b/docs/publish/index.md new file mode 100644 index 0000000..5913922 --- /dev/null +++ b/docs/publish/index.md @@ -0,0 +1,20 @@ +# `appcircle publish` + +Manage publish module actions. + +```plaintext +appcircle publish [command] [options] +``` + +## Options inherited from parent commands + +```plaintext + --help Show help for command +``` + +## Subcommands + +- [`start`](view.md) +- [`profile`](profile/index.md) +- [`variable`](variable/index.md) + diff --git a/docs/publish/profile/create.md b/docs/publish/profile/create.md new file mode 100644 index 0000000..ae9e866 --- /dev/null +++ b/docs/publish/profile/create.md @@ -0,0 +1,19 @@ +# `appcircle publish profile create` + +Create a distribution profile. + +```plaintext +appcircle publish profile create [options] +``` + +## Options + +```plaintext + --platform Platform (ios/android) + --name Profile name +``` +## Options inherited from parent commands + +```plaintext + --help Show help for command +``` diff --git a/docs/publish/profile/delete.md b/docs/publish/profile/delete.md new file mode 100644 index 0000000..ff67032 --- /dev/null +++ b/docs/publish/profile/delete.md @@ -0,0 +1,19 @@ +# `appcircle publish profile delete` + +Remove publish profile. + +```plaintext +appcircle publish profile delete [options] +``` + +## Options + +```plaintext + --platform Platform (ios/android) + --publishProfileId Publish Profile ID +``` +## Options inherited from parent commands + +```plaintext + --help Show help for command +``` diff --git a/docs/publish/profile/index.md b/docs/publish/profile/index.md new file mode 100644 index 0000000..f84550b --- /dev/null +++ b/docs/publish/profile/index.md @@ -0,0 +1,23 @@ +# `appcircle publish profile` + +Publish profile actions. + +```plaintext +appcircle publish profile [command] [options] +``` + +## Options inherited from parent commands + +```plaintext + --help Show help for command +``` + +## Subcommands + +- [`list`](list.md) +- [`create`](create.md) +- [`rename`](rename.md) +- [`delete`](delete.md) +- [`version`](version/index.md) +- [`settings`](settings/index.md) + diff --git a/docs/publish/profile/list.md b/docs/publish/profile/list.md new file mode 100644 index 0000000..596580c --- /dev/null +++ b/docs/publish/profile/list.md @@ -0,0 +1,19 @@ +# `appcircle publish profile list` + +Get list of publish profile by platform (iOS or Android). + +```plaintext +appcircle publish profile list [options] +``` + +## Options + +```plaintext + --platform Platform (ios/android) +``` + +## Options inherited from parent commands + +```plaintext + --help Show help for command +``` diff --git a/docs/publish/profile/rename.md b/docs/publish/profile/rename.md new file mode 100644 index 0000000..f6a5fa8 --- /dev/null +++ b/docs/publish/profile/rename.md @@ -0,0 +1,20 @@ +# `appcircle publish profile rename` + +Modify the name of the publish profile. + +```plaintext +appcircle publish profile rename [options] +``` + +## Options + +```plaintext + --platform Platform (ios/android) + --publishProfileId Publish Profile ID + --name New profile name +``` +## Options inherited from parent commands + +```plaintext + --help Show help for command +``` diff --git a/docs/publish/profile/settings/autopublish.md b/docs/publish/profile/settings/autopublish.md new file mode 100644 index 0000000..ebff61a --- /dev/null +++ b/docs/publish/profile/settings/autopublish.md @@ -0,0 +1,20 @@ +# `appcircle publish profile settings autopublish` + +Configure the automatic publishing setting for the publish profile. Enabling autopublish initiates a publish process upon receiving a new app version. + +```plaintext +appcircle publish profile settings autopublish [options] +``` + +## Options + +```plaintext + --platform Platform (ios/android) + --publishProfileId Publish Profile ID + --enable Enable Auto Publish +``` +## Options inherited from parent commands + +```plaintext + --help Show help for command +``` diff --git a/docs/publish/profile/settings/index.md b/docs/publish/profile/settings/index.md new file mode 100644 index 0000000..771d55e --- /dev/null +++ b/docs/publish/profile/settings/index.md @@ -0,0 +1,18 @@ +# `appcircle publish profile settings` + +Publish profile settings. + +```plaintext +appcircle publish profile settings [command] [options] +``` + +## Options inherited from parent commands + +```plaintext + --help Show help for command +``` + +## Subcommands + +- [`autopublish`](autopublish.md) + diff --git a/docs/publish/profile/version/delete.md b/docs/publish/profile/version/delete.md new file mode 100644 index 0000000..8388ad5 --- /dev/null +++ b/docs/publish/profile/version/delete.md @@ -0,0 +1,22 @@ +# `appcircle publish profile version delete` + +Remove app version from selected publish profile. + +```plaintext +appcircle publish profile version delete [options] +``` + +## Options + +```plaintext + --platform Platform (ios/android) + + --publishProfileId Publish profile ID + + --appVersionId App version +``` +## Options inherited from parent commands + +```plaintext + --help Show help for command +``` diff --git a/docs/publish/profile/version/download.md b/docs/publish/profile/version/download.md new file mode 100644 index 0000000..4852287 --- /dev/null +++ b/docs/publish/profile/version/download.md @@ -0,0 +1,24 @@ +# `appcircle publish profile version download` + +Download app version from selected publish profile. + +```plaintext +appcircle publish profile version download [options] +``` + +## Options + +```plaintext + --platform Platform (ios/android) + + --publishProfileId Publish profile ID + + --appVersionId App version + + --path [OPTIONAL] The path for artifacts to be downloaded: (Defaults to the current directory) +``` +## Options inherited from parent commands + +```plaintext + --help Show help for command +``` diff --git a/docs/publish/profile/version/index.md b/docs/publish/profile/version/index.md new file mode 100644 index 0000000..9462ad6 --- /dev/null +++ b/docs/publish/profile/version/index.md @@ -0,0 +1,22 @@ +# `appcircle publish profile version` + +App version actions. + +```plaintext +appcircle publish profile version [command] [options] +``` + +## Options inherited from parent commands + +```plaintext + --help Show help for command +``` + +## Subcommands + +- [`upload`](upload.md) +- [`download`](download.md) +- [`delete`](delete.md) +- [`mark-as-rc`](mark-as-rc.md) +- [`unmark-as-rc`](unmark-as-rc.md) + diff --git a/docs/publish/profile/version/mark-as-rc.md b/docs/publish/profile/version/mark-as-rc.md new file mode 100644 index 0000000..61b9415 --- /dev/null +++ b/docs/publish/profile/version/mark-as-rc.md @@ -0,0 +1,22 @@ +# `appcircle publish profile version mark-as-rc` + +Mark an app version as Release Candidate. + +```plaintext +appcircle publish profile version mark-as-rc [options] +``` + +## Options + +```plaintext + --platform Platform (ios/android) + + --publishProfileId Publish profile ID + + --appVersionId App version +``` +## Options inherited from parent commands + +```plaintext + --help Show help for command +``` diff --git a/docs/publish/profile/version/unmark-as-rc.md b/docs/publish/profile/version/unmark-as-rc.md new file mode 100644 index 0000000..f8aecae --- /dev/null +++ b/docs/publish/profile/version/unmark-as-rc.md @@ -0,0 +1,22 @@ +# `appcircle publish profile version unmark-as-rc` + +Unmark an app version as Release Candidate. + +```plaintext +appcircle publish profile version unmark-as-rc [options] +``` + +## Options + +```plaintext + --platform Platform (ios/android) + + --publishProfileId Publish profile ID + + --appVersionId App version +``` +## Options inherited from parent commands + +```plaintext + --help Show help for command +``` diff --git a/docs/publish/profile/version/upload.md b/docs/publish/profile/version/upload.md new file mode 100644 index 0000000..0f734ec --- /dev/null +++ b/docs/publish/profile/version/upload.md @@ -0,0 +1,20 @@ +# `appcircle publish profile version upload` + +Upload a new version to given publish profile. + +```plaintext +appcircle publish profile version upload [options] +``` + +## Options + +```plaintext + --platform Platform (ios/android) + --publishProfileId Publish profile ID + --app App path +``` +## Options inherited from parent commands + +```plaintext + --help Show help for command +``` diff --git a/docs/publish/start.md b/docs/publish/start.md new file mode 100644 index 0000000..5d7b61e --- /dev/null +++ b/docs/publish/start.md @@ -0,0 +1,20 @@ +# `appcircle publish start` + +Remove given roles from the given userId within the organizationId. + +```plaintext +appcircle publish start [options] +``` + +## Options + +```plaintext + --platform Platform (ios/android) + --publishProfileId Publish profile ID + --appVersionId App version +``` +## Options inherited from parent commands + +```plaintext + --help Show help for command +``` diff --git a/docs/publish/variable/group/index.md b/docs/publish/variable/group/index.md new file mode 100644 index 0000000..cbbae16 --- /dev/null +++ b/docs/publish/variable/group/index.md @@ -0,0 +1,19 @@ +# `appcircle publish profile variable group` + +Publish variable group actions. + +```plaintext +appcircle publish profile variable group [command] [options] +``` + +## Options inherited from parent commands + +```plaintext + --help Show help for command +``` + +## Subcommands + +- [`list`](list.md) +- [`view`](view.md) + diff --git a/docs/publish/variable/group/list.md b/docs/publish/variable/group/list.md new file mode 100644 index 0000000..960c29f --- /dev/null +++ b/docs/publish/variable/group/list.md @@ -0,0 +1,13 @@ +# `appcircle publish variable group list` + +Get list of publish variable groups. + +```plaintext +appcircle publish variable group list +``` + +## Options inherited from parent commands + +```plaintext + --help Show help for command +``` diff --git a/docs/publish/variable/group/view.md b/docs/publish/variable/group/view.md new file mode 100644 index 0000000..4fd0c4d --- /dev/null +++ b/docs/publish/variable/group/view.md @@ -0,0 +1,18 @@ +# `appcircle publish variable group view` + +View items of publish variable group. + +```plaintext +appcircle publish variable group view [options] +``` + +## Options + +```plaintext + --publishVariableGroupId Variable Group ID +``` +## Options inherited from parent commands + +```plaintext + --help Show help for command +``` diff --git a/docs/publish/variable/index.md b/docs/publish/variable/index.md new file mode 100644 index 0000000..94cc02d --- /dev/null +++ b/docs/publish/variable/index.md @@ -0,0 +1,18 @@ +# `appcircle publish profile variable` + +Manage publish variables. + +```plaintext +appcircle publish profile variable [command] [options] +``` + +## Options inherited from parent commands + +```plaintext + --help Show help for command +``` + +## Subcommands + +- [`group`](group/index.md) + diff --git a/package.json b/package.json index b1fee47..e20dbbe 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@appcircle/cli", - "version": "1.2.0", + "version": "2.0.0", "description": "CLI tool for running Appcircle services from the command line", "main": "bin/appcircle", "bin": { diff --git a/src/constant.ts b/src/constant.ts index ab49ab1..7d0b4a9 100644 --- a/src/constant.ts +++ b/src/constant.ts @@ -11,6 +11,10 @@ export const BuildStatus = { "99": "Unknown", }; +export const QueueItemStatus = { + "0": "Waiting", + "1": "Running", +}; export const AuthenticationTypes = { 1: "None", 2: "Individual Enrollment", @@ -49,3 +53,5 @@ export const PROGRAM_NAME = "appcircle"; export const UNKNOWN_PARAM_VALUE = '-' export const CURRENT_PARAM_VALUE = 'current' +export let globalVariables : {[key:string]: string} = {} + diff --git a/src/core/command-runner.ts b/src/core/command-runner.ts index cbf0312..918629a 100644 --- a/src/core/command-runner.ts +++ b/src/core/command-runner.ts @@ -54,6 +54,23 @@ import { getOrganizationUserinfo, assignRolesToUserInOrganitaion, getOrganizationUsersWithRoles, + createPublishProfile, + getPublishProfiles, + uploadAppVersion, + deleteAppVersion, + getAppVersionDownloadLink, + getPublishByAppVersion, + startExistingPublishFlow, + setAppVersionReleaseCandidateStatus, + switchPublishProfileAutoPublishSettings, + getPublishProfileDetailById, + getPublishVariableGroups, + getPublishVariableListByGroupId, + deletePublishProfile, + renamePublishProfile, + getAppVersions, + downloadAppVersion, + getActiveBuilds, } from '../services'; import { commandWriter, configWriter } from './writer'; import { trustAppcircleCertificate } from '../security/trust-url-certificate'; @@ -201,6 +218,371 @@ const handleOrganizationCommand = async (command: ProgramCommand, params: any) = } }; +const handlePublishCommand = async (command: ProgramCommand, params: any) => { + if(params.platform && !['ios','android'].includes(params.platform)){ + throw new ProgramError(`Invalid platform(${params.platform}). Supported platforms: ios, android`); + } + if (command.fullCommandName === `${PROGRAM_NAME}-publish-profile-create`) { + const profileRes = await createPublishProfile({ platform: params.platform, name: params.name }); + commandWriter(CommandTypes.PUBLISH, { + fullCommandName: command.fullCommandName, + data: profileRes, + }); + } else if (command.fullCommandName === `${PROGRAM_NAME}-publish-profile-list`) { + const profiles = await getPublishProfiles({ platform: params.platform }); + commandWriter(CommandTypes.PUBLISH, { + fullCommandName: command.fullCommandName, + data: profiles, + }); + } else if (command.fullCommandName === `${PROGRAM_NAME}-publish-profile-delete`) { + const response = await deletePublishProfile(params); + commandWriter(CommandTypes.PUBLISH, { + fullCommandName: command.fullCommandName, + data: response, + }); + } + else if (command.fullCommandName === `${PROGRAM_NAME}-publish-profile-rename`) { + const response = await renamePublishProfile(params); + commandWriter(CommandTypes.PUBLISH, { + fullCommandName: command.fullCommandName, + data: response, + }); + } + else if (command.fullCommandName === `${PROGRAM_NAME}-publish-profile-version-upload`) { + const spinner = createOra('Try to upload the app version').start(); + try { + const responseData = await uploadAppVersion(params); + commandWriter(CommandTypes.PUBLISH, responseData); + spinner.text = `App version uploaded successfully.\n\nTaskId: ${responseData.taskId}`; + spinner.succeed(); + } catch (e: any) { + spinner.fail('Upload failed'); + throw e; + } + } else if (command.fullCommandName === `${PROGRAM_NAME}-publish-profile-version-delete`) { + const spinner = createOra('Try to remove the app version').start(); + try { + const responseData = await deleteAppVersion(params); + commandWriter(CommandTypes.PUBLISH, responseData); + spinner.text = `App version removed successfully.\n\nTaskId: ${responseData.taskId}`; + spinner.succeed(); + } catch (e: any) { + spinner.fail('Remove failed'); + throw e; + } + } else if (command.fullCommandName === `${PROGRAM_NAME}-publish-start`) { + const spinner = createOra('Publish flow starting').start(); + const publish = await getPublishByAppVersion(params); + const firstStep = publish.steps[0]; + const startResponse = await startExistingPublishFlow({ ...params, publishId: firstStep.publishId }); + commandWriter(CommandTypes.PUBLISH, startResponse); + spinner.text = `Publish started successfully.`; + spinner.succeed(); + } else if (command.fullCommandName === `${PROGRAM_NAME}-publish-profile-version-download`) { + let spinner = createOra('Fetching app version download link').start(); + try { + let downloadPath = path.resolve((params.path || '').replace('~', `${os.homedir}`)); + const responseData = await getAppVersionDownloadLink(params); + const appVersions = await getAppVersions(params); + const appVersion = appVersions.find((appVersion: any) => appVersion.id === params.appVersionId); + if (!appVersion) { + spinner.fail(); + throw new Error('App version not found'); + } + spinner.text = `App version download link fetched successfully.`; + spinner.text = `Try to download the app version.`; + downloadPath = path.join(downloadPath, appVersion.fileName); + await downloadAppVersion({ url: responseData, path:downloadPath }); + spinner.text = `App version downloaded successfully.\n\nDownload Path: ${downloadPath}`; + spinner.succeed(); + } catch (e: any) { + spinner.fail('Process failed'); + throw e; + } + } else if (command.fullCommandName === `${PROGRAM_NAME}-publish-profile-version-mark-as-rc`) { + const response = await setAppVersionReleaseCandidateStatus({...params, releaseCandidate: true }); + commandWriter(CommandTypes.PUBLISH, { + fullCommandName: command.fullCommandName, + data: response, + }); + } else if (command.fullCommandName === `${PROGRAM_NAME}-publish-profile-version-unmark-as-rc`) { + const response = await setAppVersionReleaseCandidateStatus({...params, releaseCandidate: false }); + commandWriter(CommandTypes.PUBLISH, { + fullCommandName: command.fullCommandName, + data: response, + }); + } else if (command.fullCommandName === `${PROGRAM_NAME}-publish-profile-settings-autopublish`) { + const publishProfileDetails = await getPublishProfileDetailById(params); + const response = await switchPublishProfileAutoPublishSettings({ ...params, currentProfileSettings: publishProfileDetails.profileSettings }); + commandWriter(CommandTypes.PUBLISH, { + fullCommandName: command.fullCommandName, + data: response, + }); + } else if (command.fullCommandName === `${PROGRAM_NAME}-publish-variable-group-list`) { + const variableGroups = await getPublishVariableGroups(); + commandWriter(CommandTypes.PUBLISH, { + fullCommandName: command.fullCommandName, + data: variableGroups, + }); + } else if (command.fullCommandName === `${PROGRAM_NAME}-publish-variable-group-view`) { + const variables = await getPublishVariableListByGroupId(params); + commandWriter(CommandTypes.PUBLISH, { + fullCommandName: command.fullCommandName, + data: variables.variables, + }); + } else { + const beutufiyCommandName = command.fullCommandName.split('-').join(' '); + console.error(`"${beutufiyCommandName} ..." command not found \nRun "${beutufiyCommandName} --help" for more information`); + } +}; + +const handleBuildCommand = async (command: ProgramCommand, params:any) => { + if (command.fullCommandName === `${PROGRAM_NAME}-build-start`) { + //Check optional params if need one of them + if (!params.branchId && !params.branch) { + console.error('error: You must provide either branchId or branch parameter'); + process.exit(1); + } + if (!params.workflowId && !params.workflow) { + console.error('error: You must provide either workflowId or workflow parameter'); + process.exit(1); + } + const spinner = createOra(`Try to start a new build`).start(); + try { + const responseData = await startBuild(params); + commandWriter(CommandTypes.BUILD, { + fullCommandName: command.fullCommandName, + data: responseData, + }); + spinner.text = `Build added to queue successfully.\n\nTaskId: ${responseData.taskId}\nQueueItemId: ${responseData.queueItemId}`; + spinner.succeed(); + } catch (e) { + spinner.fail('Build failed'); + throw e; + } + }else if(command.fullCommandName === `${PROGRAM_NAME}-build-profile-list`){ + const responseData = await getBuildProfiles(params); + commandWriter(CommandTypes.BUILD, { + fullCommandName: command.fullCommandName, + data: responseData, + }); + }else if(command.fullCommandName === `${PROGRAM_NAME}-build-profile-branch-list`) { + const responseData = await getBranches(params); + commandWriter(CommandTypes.BUILD, { + fullCommandName: command.fullCommandName, + data: responseData, + }); + }else if(command.fullCommandName === `${PROGRAM_NAME}-build-profile-workflows`){ + const responseData = await getWorkflows(params); + commandWriter(CommandTypes.BUILD, { + fullCommandName: command.fullCommandName, + data: responseData, + }); + } else if(command.fullCommandName === `${PROGRAM_NAME}-build-profile-configurations`) { + const responseData = await getConfigurations(params); + commandWriter(CommandTypes.BUILD, { + fullCommandName: command.fullCommandName, + data: responseData, + }); + } else if(command.fullCommandName === `${PROGRAM_NAME}-build-profile-branch-commits`){ + const responseData = await getCommits(params); + commandWriter(CommandTypes.BUILD, { + fullCommandName: command.fullCommandName, + data: responseData, + }); + } else if(command.fullCommandName === `${PROGRAM_NAME}-build-list`){ + const responseData = await getBuildsOfCommit(params); + commandWriter(CommandTypes.BUILD, { + fullCommandName: command.fullCommandName, + data: responseData, + }); + } else if (command.fullCommandName === `${PROGRAM_NAME}-build-download`){ + const downloadPath = path.resolve((params.path || '').replace('~', `${os.homedir}`)); + const spinner = createOra(`Downloading file artifact.zip`).start(); + try { + const responseData = await downloadArtifact(params, downloadPath); + commandWriter(CommandTypes.BUILD, { + fullCommandName: command.fullCommandName, + data: responseData, + }); + spinner.text = `The file artifact.zip is downloaded successfully under path:\n${downloadPath}`; + spinner.succeed(); + } catch (e) { + spinner.text = 'The file could not be downloaded.'; + spinner.fail(); + } + } else if (command.fullCommandName === `${PROGRAM_NAME}-build-variable-group-list`){ + const responseData = await getEnvironmentVariableGroups(params); + commandWriter(CommandTypes.BUILD, { + fullCommandName: command.fullCommandName, + data: responseData, + }); + } else if(command.fullCommandName === `${PROGRAM_NAME}-build-variable-group-create`){ + const responseData = await createEnvironmentVariableGroup(params); + commandWriter(CommandTypes.BUILD, { + fullCommandName: command.fullCommandName, + data: { ...responseData, name: params.name }, + }); + } else if(command.fullCommandName === `${PROGRAM_NAME}-build-variable-view`){ + const responseData = await getEnvironmentVariables(params); + commandWriter(CommandTypes.BUILD, { + fullCommandName: command.fullCommandName, + data: responseData, + }); + } else if(command.fullCommandName === `${PROGRAM_NAME}-build-variable-create`){ + const responseData = await createEnvironmentVariable(params as any); + commandWriter(CommandTypes.BUILD, { + fullCommandName: command.fullCommandName, + data: { ...responseData, key: params.key }, + }); + } else if (command.fullCommandName === `${PROGRAM_NAME}-build-active-list`){ + const responseData = await getActiveBuilds(); + commandWriter(CommandTypes.BUILD, { + fullCommandName: command.fullCommandName, + data: responseData, + }); + } else if (command.fullCommandName === `${PROGRAM_NAME}-build-view`){ + const responseData = await getBuildsOfCommit(params); + const build = responseData?.builds?.find((build: any) => build.id === params.buildId); + commandWriter(CommandTypes.BUILD, { + fullCommandName: command.fullCommandName, + data: build, + }); + } + else { + const beutufiyCommandName = command.fullCommandName.split('-').join(' '); + console.error(`"${beutufiyCommandName} ..." command not found \nRun "${beutufiyCommandName} --help" for more information`); + } + +} + +const handleDistributionCommand = async (command: ProgramCommand, params: any) => { + if (command.fullCommandName === `${PROGRAM_NAME}-distribution-profile-list`) { + const responseData = await getDistributionProfiles(params); + commandWriter(CommandTypes.TESTING_DISTRIBUTION, { + fullCommandName: command.fullCommandName, + data: responseData, + }); + } else if (command.fullCommandName === `${PROGRAM_NAME}-distribution-profile-create`){ + const responseData = await createDistributionProfile(params); + commandWriter(CommandTypes.TESTING_DISTRIBUTION, { + fullCommandName: command.fullCommandName, + data: { ...responseData, name: params.name }, + }); + }else if (command.fullCommandName === `${PROGRAM_NAME}-distribution-upload`){ + const spinner = createOra('Try to upload the app').start(); + try { + const responseData = await uploadArtifact(params); + commandWriter(CommandTypes.TESTING_DISTRIBUTION, { + fullCommandName: command.fullCommandName, + data: responseData, + }); + spinner.text = `App uploaded successfully.\n\nTaskId: ${responseData.taskId}`; + spinner.succeed(); + } catch (e) { + spinner.fail('Upload failed'); + throw e; + } + } + else { + const beutufiyCommandName = command.fullCommandName.split('-').join(' '); + console.error(`"${beutufiyCommandName} ..." command not found \nRun "${beutufiyCommandName} --help" for more information`); + } +} + +const handleEnterpriseAppStoreCommand = async (command: ProgramCommand, params: any) => { + if (command.fullCommandName === `${PROGRAM_NAME}-enterprise-app-store-profile-list`){ + const responseData = await getEnterpriseProfiles(); + commandWriter(CommandTypes.ENTERPRISE_APP_STORE, { + fullCommandName: command.fullCommandName, + data: responseData, + }); + } else if(command.fullCommandName === `${PROGRAM_NAME}-enterprise-app-store-version-list`){ + const responseData = await getEnterpriseAppVersions(params); + commandWriter(CommandTypes.ENTERPRISE_APP_STORE, { + fullCommandName: command.fullCommandName, + data: responseData, + }); + } else if (command.fullCommandName === `${PROGRAM_NAME}-enterprise-app-store-version-publish`){ + const responseData = await publishEnterpriseAppVersion(params); + commandWriter(CommandTypes.ENTERPRISE_APP_STORE, { + fullCommandName: command.fullCommandName, + data: responseData, + }); + } else if (command.fullCommandName === `${PROGRAM_NAME}-enterprise-app-store-version-unpublish`){ + const responseData = await unpublishEnterpriseAppVersion(params); + commandWriter(CommandTypes.ENTERPRISE_APP_STORE, { + fullCommandName: command.fullCommandName, + data: responseData, + }); + } else if (command.fullCommandName === `${PROGRAM_NAME}-enterprise-app-store-version-remove`){ + const spinner = createOra('Try to delete the app version').start(); + try { + const responseData = await removeEnterpriseAppVersion(params); + commandWriter(CommandTypes.ENTERPRISE_APP_STORE, { + fullCommandName: command.fullCommandName, + data: responseData, + }); + spinner.text = `App version deleted successfully.\n\nTaskId: ${responseData.taskId}`; + spinner.succeed(); + } catch (e) { + spinner.fail('App version delete failed'); + throw e; + } + } else if (command.fullCommandName === `${PROGRAM_NAME}-enterprise-app-store-version-notify`){ + const spinner = createOra(`Notifying users with new version for ${params.entVersionId}`).start(); + try { + const responseData = await notifyEnterpriseAppVersion(params); + commandWriter(CommandTypes.ENTERPRISE_APP_STORE, { + fullCommandName: command.fullCommandName, + data: responseData, + }); + spinner.text = `Version notification sent successfully.\n\nTaskId: ${responseData.taskId}`; + spinner.succeed(); + } catch (e) { + spinner.fail('Notification failed'); + throw e; + } + } else if (command.fullCommandName === `${PROGRAM_NAME}-enterprise-app-store-version-upload-for-profile`){ + const spinner = createOra('Try to upload the app').start(); + try { + const responseData = await uploadEnterpriseAppVersion(params); + commandWriter(CommandTypes.ENTERPRISE_APP_STORE, { + fullCommandName: command.fullCommandName, + data: responseData, + }); + spinner.text = `App version uploaded successfully.\n\nTaskId: ${responseData.taskId}`; + spinner.succeed(); + } catch (e) { + spinner.fail('Upload failed'); + throw e; + } + } else if (command.fullCommandName === `${PROGRAM_NAME}-enterprise-app-store-version-upload-without-profile`){ + const spinner = createOra('Try to upload the app').start(); + try { + const responseData = await uploadEnterpriseApp(params); + commandWriter(CommandTypes.ENTERPRISE_APP_STORE, { + fullCommandName: command.fullCommandName, + data: responseData, + }); + spinner.text = `New profile created and app uploaded successfully.\n\nTaskId: ${responseData.taskId}`; + spinner.succeed(); + } catch (e) { + spinner.fail('Upload failed'); + throw e; + } + } else if (command.fullCommandName === `${PROGRAM_NAME}-enterprise-app-store-version-download-link`) { + const responseData = await getEnterpriseDownloadLink(params); + commandWriter(CommandTypes.ENTERPRISE_APP_STORE, { + fullCommandName: command.fullCommandName, + data: responseData, + }); + } + else { + const beutufiyCommandName = command.fullCommandName.split('-').join(' '); + console.error(`"${beutufiyCommandName} ..." command not found \nRun "${beutufiyCommandName} --help" for more information`); + } +} export const runCommand = async (command: ProgramCommand) => { const params = command.opts() as any; const commandName = command.name(); @@ -209,7 +591,7 @@ export const runCommand = async (command: ProgramCommand) => { //console.log('Full-Command-Name: ', command.fullCommandName, params); //In interactive mode, if any parameters have errors, we can't continue execution. - if(params.isError){ + if (params.isError) { process.exit(1); } @@ -222,6 +604,20 @@ export const runCommand = async (command: ProgramCommand) => { return handleOrganizationCommand(command, params); } + if (command.isGroupCommand(CommandTypes.PUBLISH)) { + return handlePublishCommand(command, params); + } + + if (command.isGroupCommand(CommandTypes.BUILD)) { + return handleBuildCommand(command, params); + } + + if (command.isGroupCommand(CommandTypes.TESTING_DISTRIBUTION)) { + return handleDistributionCommand(command, params); + } + if (command.isGroupCommand(CommandTypes.ENTERPRISE_APP_STORE)) { + return handleEnterpriseAppStoreCommand(command, params); + } switch (commandName) { case CommandTypes.LOGIN: { responseData = await getToken(params); @@ -229,194 +625,6 @@ export const runCommand = async (command: ProgramCommand) => { commandWriter(CommandTypes.LOGIN, responseData); break; } - case CommandTypes.LIST_BUILD_PROFILES: { - responseData = await getBuildProfiles(params); - commandWriter(CommandTypes.LIST_BUILD_PROFILES, responseData); - break; - } - case CommandTypes.LIST_BUILD_PROFILE_BRANCHES: { - responseData = await getBranches(params); - commandWriter(CommandTypes.LIST_BUILD_PROFILE_BRANCHES, responseData); - break; - } - case CommandTypes.LIST_BUILD_PROFILE_WORKFLOWS: { - responseData = await getWorkflows(params); - commandWriter(CommandTypes.LIST_BUILD_PROFILE_WORKFLOWS, responseData); - break; - } - case CommandTypes.LIST_BUILD_PROFILE_CONFIGURATIONS: { - responseData = await getConfigurations(params); - commandWriter(CommandTypes.LIST_BUILD_PROFILE_CONFIGURATIONS, responseData); - break; - } - - case CommandTypes.LIST_BUILD_PROFILE_COMMITS: { - responseData = await getCommits(params); - commandWriter(CommandTypes.LIST_BUILD_PROFILE_COMMITS, responseData); - break; - } - case CommandTypes.LIST_BUILD_PROFILE_BUILDS_OF_COMMIT: { - responseData = await getBuildsOfCommit(params); - commandWriter(CommandTypes.LIST_BUILD_PROFILE_BUILDS_OF_COMMIT, responseData); - break; - } - case CommandTypes.LIST_DISTRIBUTION_PROFILES: { - responseData = await getDistributionProfiles(params); - commandWriter(CommandTypes.LIST_DISTRIBUTION_PROFILES, responseData); - break; - } - case CommandTypes.BUILD: { - //Check optional params if need one of them - if (!params.branchId && !params.branch) { - console.error('error: You must provide either branchId or branch parameter'); - process.exit(1); - } - if (!params.workflowId && !params.workflow) { - console.error('error: You must provide either workflowId or workflow parameter'); - process.exit(1); - } - const spinner = createOra(`Try to start a new build`).start(); - try { - responseData = await startBuild(params); - commandWriter(CommandTypes.BUILD, responseData); - spinner.text = `Build added to queue successfully.\n\nTaskId: ${responseData.taskId}\nQueueItemId: ${responseData.queueItemId}`; - spinner.succeed(); - } catch (e) { - spinner.fail('Build failed'); - throw e; - } - break; - } - case CommandTypes.DOWNLOAD: { - const downloadPath = path.resolve((params.path || '').replace('~', `${os.homedir}`)); - const spinner = createOra(`Downloading file artifact.zip`).start(); - try { - responseData = await downloadArtifact(params, downloadPath); - commandWriter(CommandTypes.DOWNLOAD, responseData); - spinner.text = `The file artifact.zip is downloaded successfully under path:\n${downloadPath}`; - spinner.succeed(); - } catch (e) { - spinner.text = 'The file could not be downloaded.'; - spinner.fail(); - throw e; - } - break; - } - case CommandTypes.UPLOAD: { - const spinner = createOra('Try to upload the app').start(); - try { - responseData = await uploadArtifact(params); - commandWriter(CommandTypes.UPLOAD, responseData); - spinner.text = `App uploaded successfully.\n\nTaskId: ${responseData.taskId}`; - spinner.succeed(); - } catch (e) { - spinner.fail('Upload failed'); - throw e; - } - break; - } - case CommandTypes.CREATE_DISTRIBUTION_PROFILE: { - responseData = await createDistributionProfile(params); - commandWriter(CommandTypes.CREATE_DISTRIBUTION_PROFILE, { ...responseData, name: params.name }); - break; - } - case CommandTypes.LIST_ENVIRONMENT_VARIABLE_GROUPS: { - responseData = await getEnvironmentVariableGroups(params); - commandWriter(CommandTypes.LIST_ENVIRONMENT_VARIABLE_GROUPS, responseData); - break; - } - case CommandTypes.CREATE_ENVIRONMENT_VARIABLE_GROUP: { - responseData = await createEnvironmentVariableGroup(params); - commandWriter(CommandTypes.CREATE_ENVIRONMENT_VARIABLE_GROUP, { ...responseData, name: params.name }); - break; - } - case CommandTypes.LIST_ENVIRONMENT_VARIABLES: { - responseData = await getEnvironmentVariables(params); - commandWriter(CommandTypes.LIST_ENVIRONMENT_VARIABLES, responseData); - break; - } - case CommandTypes.CREATE_ENVIRONMENT_VARIABLE: { - responseData = await createEnvironmentVariable(params as any); - commandWriter(CommandTypes.CREATE_ENVIRONMENT_VARIABLE, { ...responseData, key: params.key }); - break; - } - case CommandTypes.LIST_ENTERPRISE_PROFILES: { - responseData = await getEnterpriseProfiles(); - commandWriter(CommandTypes.LIST_ENTERPRISE_PROFILES, responseData); - break; - } - case CommandTypes.LIST_ENTERPRISE_APP_VERSIONS: { - responseData = await getEnterpriseAppVersions(params); - commandWriter(CommandTypes.LIST_ENTERPRISE_APP_VERSIONS, responseData); - break; - } - case CommandTypes.PUBLISH_ENTERPRISE_APP_VERSION: { - responseData = await publishEnterpriseAppVersion(params); - commandWriter(CommandTypes.PUBLISH_ENTERPRISE_APP_VERSION, responseData); - break; - } - case CommandTypes.UNPUBLISH_ENTERPRISE_APP_VERSION: { - responseData = await unpublishEnterpriseAppVersion(params); - commandWriter(CommandTypes.UNPUBLISH_ENTERPRISE_APP_VERSION, responseData); - break; - } - case CommandTypes.REMOVE_ENTERPRISE_APP_VERSION: { - const spinner = createOra('Try to delete the app version').start(); - try { - responseData = await removeEnterpriseAppVersion(params); - commandWriter(CommandTypes.REMOVE_ENTERPRISE_APP_VERSION, responseData); - spinner.text = `App version deleted successfully.\n\nTaskId: ${responseData.taskId}`; - spinner.succeed(); - } catch (e) { - spinner.fail('App version delete failed'); - throw e; - } - break; - } - case CommandTypes.NOTIFY_ENTERPRISE_APP_VERSION: { - const spinner = createOra(`Notifying users with new version for ${params.entVersionId}`).start(); - try { - responseData = await notifyEnterpriseAppVersion(params); - commandWriter(CommandTypes.NOTIFY_ENTERPRISE_APP_VERSION, responseData); - spinner.text = `Version notification sent successfully.\n\nTaskId: ${responseData.taskId}`; - spinner.succeed(); - } catch (e) { - spinner.fail('Notification failed'); - throw e; - } - break; - } - case CommandTypes.UPLOAD_ENTERPRISE_APP: { - const spinner = createOra('Try to upload the app').start(); - try { - responseData = await uploadEnterpriseApp(params); - commandWriter(CommandTypes.UPLOAD_ENTERPRISE_APP, responseData); - spinner.text = `New profile created and app uploaded successfully.\n\nTaskId: ${responseData.taskId}`; - spinner.succeed(); - } catch (e) { - spinner.fail('Upload failed'); - throw e; - } - break; - } - case CommandTypes.UPLOAD_ENTERPRISE_APP_VERSION: { - const spinner = createOra('Try to upload the app').start(); - try { - responseData = await uploadEnterpriseAppVersion(params); - commandWriter(CommandTypes.UPLOAD_ENTERPRISE_APP_VERSION, responseData); - spinner.text = `App version uploaded successfully.\n\nTaskId: ${responseData.taskId}`; - spinner.succeed(); - } catch (e) { - spinner.fail('Upload failed'); - throw e; - } - break; - } - case CommandTypes.GET_ENTERPRISE_DOWNLOAD_LINK: { - responseData = await getEnterpriseDownloadLink(params); - commandWriter(CommandTypes.GET_ENTERPRISE_DOWNLOAD_LINK, responseData); - break; - } default: { const beutufiyCommandName = command.fullCommandName.split('-').join(' '); console.error(`"${beutufiyCommandName} ..." command not found \nRun "${beutufiyCommandName} --help" for more information`); diff --git a/src/core/commands.ts b/src/core/commands.ts index cbef18b..d957fee 100644 --- a/src/core/commands.ts +++ b/src/core/commands.ts @@ -13,30 +13,10 @@ export enum CommandTypes { CONFIG = 'config', LOGIN = 'login', ORGANIZATION = 'organization', - LIST_BUILD_PROFILES = 'listBuildProfiles', - LIST_BUILD_PROFILE_BRANCHES = 'listBuildProfileBranches', - LIST_BUILD_PROFILE_WORKFLOWS = 'listBuildProfileWorkflows', - LIST_BUILD_PROFILE_CONFIGURATIONS = 'listBuildProfileConfigurations', - LIST_BUILD_PROFILE_COMMITS = 'listBuildProfileCommits', - LIST_BUILD_PROFILE_BUILDS_OF_COMMIT = 'listBuildProfileBuildsOfCommit', - LIST_DISTRIBUTION_PROFILES = 'listDistributionProfiles', + PUBLISH = 'publish', BUILD = 'build', - DOWNLOAD = 'download', - UPLOAD = 'upload', - CREATE_DISTRIBUTION_PROFILE = 'createDistributionProfile', - LIST_ENVIRONMENT_VARIABLE_GROUPS = 'listEnvironmentVariableGroups', - CREATE_ENVIRONMENT_VARIABLE_GROUP = 'createEnvironmentVariableGroup', - LIST_ENVIRONMENT_VARIABLES = 'listEnvironmentVariables', - CREATE_ENVIRONMENT_VARIABLE = 'createEnvironmentVariable', - LIST_ENTERPRISE_PROFILES = 'listEnterpriseProfiles', - LIST_ENTERPRISE_APP_VERSIONS = 'listEnterpriseAppVersions', - PUBLISH_ENTERPRISE_APP_VERSION = 'publishEnterpriseAppVersion', - UNPUBLISH_ENTERPRISE_APP_VERSION = 'unpublishEnterpriseAppVersion', - REMOVE_ENTERPRISE_APP_VERSION = 'removeEnterpriseAppVersion', - NOTIFY_ENTERPRISE_APP_VERSION = 'notifyEnterpriseAppVersion', - UPLOAD_ENTERPRISE_APP = 'uploadEnterpriseApp', - UPLOAD_ENTERPRISE_APP_VERSION = 'uploadEnterpriseAppVersion', - GET_ENTERPRISE_DOWNLOAD_LINK = 'getEnterpriseDownloadLink', + TESTING_DISTRIBUTION= 'distribution', + ENTERPRISE_APP_STORE= 'enterprise-app-store', } export type ParamType = { @@ -48,6 +28,7 @@ export type ParamType = { required?: boolean; params?: any[]; requriedForInteractiveMode?: boolean; + skipForInteractiveMode?: boolean; paramType?: string; defaultValue?: any; from?: 'user' | 'default'; @@ -63,25 +44,36 @@ export type CommandType = { params: ParamType[]; }; +const platformParam = { + name: 'platform', + description: 'Platform (ios/android)', + type: CommandParameterTypes.SELECT, + params: [{ name: 'ios' , message: 'iOS' }, { name: 'android', message: 'Android' }], + defaultValue: 'ios', + valueType: 'string', + required: true, +}; + export const Commands: CommandType[] = [ { command: CommandTypes.CONFIG, - description: 'Config (View and set Appcircle CLI properties)', + description: 'Config', + longDescription: 'View and set Appcircle CLI properties.', params: [], subCommands: [ { command: 'list', - description: 'List Appcircle CLI properties for all configurations', + description: 'List Appcircle CLI properties for all configurations.', params: [], }, { command: 'get', - description: 'Get Print the value of a Appcircle CLI currently active configuration property', + description: 'Get Print the value of a Appcircle CLI currently active configuration property.', params: [], arguments: [ { name: 'key', - description: 'Config key [API_HOSTNAME, AUTH_HOSTMANE, AC_ACCESS_TOKEN]', + description: 'Config key [API_HOSTNAME, AUTH_HOSTNAME, AC_ACCESS_TOKEN]', type: CommandParameterTypes.SELECT, params: Object.keys(DefaultEnvironmentVariables), }, @@ -89,12 +81,12 @@ export const Commands: CommandType[] = [ }, { command: 'set', - description: 'Set a Appcircle CLI currently active configuration property', + description: 'Set a Appcircle CLI currently active configuration property.', params: [], arguments: [ { name: 'key', - description: 'Config key [API_HOSTNAME, AUTH_HOSTMANE, AC_ACCESS_TOKEN]', + description: 'Config key [API_HOSTNAME, AUTH_HOSTNAME, AC_ACCESS_TOKEN]', type: CommandParameterTypes.SELECT, params: Object.keys(DefaultEnvironmentVariables), }, @@ -120,7 +112,7 @@ export const Commands: CommandType[] = [ }, { command: 'add', - description: 'Add a new Appcircle CLI configuration environment', + description: 'Add a new Appcircle CLI configuration environment.', params: [], arguments: [ { @@ -132,12 +124,12 @@ export const Commands: CommandType[] = [ }, { command: 'reset', - description: 'Reset a Appcircle CLI configuration to default', + description: 'Reset a Appcircle CLI configuration to default.', params: [], }, { command: 'trust', - description: 'Trust the SSL certificate of the self-hosted Appcircle server', + description: 'Trust the SSL certificate of the self-hosted Appcircle server.', params: [], }, ], @@ -156,740 +148,1157 @@ export const Commands: CommandType[] = [ ], }, { - command: CommandTypes.ORGANIZATION, - description: 'Organization management', - longDescription: 'Manage organization users, roles, and details.', + command: CommandTypes.BUILD, + description: 'Build', + longDescription: 'Manage build actions.', subCommands: [ + { + command: 'start', + description: 'Start a new build.', + params: [ + { + name: 'profileId', + description: 'Build profile ID', + type: CommandParameterTypes.SELECT, + valueType: 'uuid', + }, + { + name: 'branchId', + description: 'Branch ID', + type: CommandParameterTypes.SELECT, + valueType: 'uuid', + required: false, + params: [], + }, + { + name: 'commitId', + description: 'Commit ID [Optional]', + type: CommandParameterTypes.SELECT, + valueType: 'uuid', + required: false, + params: [], + }, + { + name: 'configurationId', + description: 'Configuration ID [Optional]', + type: CommandParameterTypes.SELECT, + valueType: 'uuid', + required: false, + params: [], + }, + { + name: 'workflowId', + description: 'Workflow ID', + type: CommandParameterTypes.SELECT, + valueType: 'uuid', + required: false, + params: [], + }, + { + name: 'branch', + description: "Branch Name instead of 'branch ID'", + type: CommandParameterTypes.STRING, + valueType: 'string', + required: false, + requriedForInteractiveMode: false, + skipForInteractiveMode:true, + params: [], + }, + { + name: 'workflow', + description: "Workflow Name instead of 'workflow ID'", + type: CommandParameterTypes.STRING, + valueType: 'string', + required: false, + requriedForInteractiveMode: false, + skipForInteractiveMode:true, + params: [], + }, + ], + }, + { + command: 'active-list', + description: 'Get a list of active builds in the queue.', + params: [], + }, + { + command: "list", + description: 'Get list of builds of a commit.', + params: [ + { + name: 'profileId', + description: 'Build profile ID', + type: CommandParameterTypes.SELECT, + requriedForInteractiveMode: true, + valueType: 'uuid', + }, + { + name: 'branchId', + description: 'Branch ID', + type: CommandParameterTypes.SELECT, + requriedForInteractiveMode: true, + valueType: 'uuid', + }, + { + name: 'commitId', + description: 'Commit ID', + type: CommandParameterTypes.SELECT, + valueType: 'uuid', + }, + ], + }, { command: 'view', - description: 'View organizations details', - longDescription: 'View organization details. If "organizationId" not provided, will list all organizations.', - params: [{ - name: 'organizationId', - description: 'Organization ID [Optional]', - type: CommandParameterTypes.SELECT, - defaultValue: 'all', - valueType: 'uuid', - required: false, - }], + description: 'View details of a build.', + longDescription: 'View comprehensive details of a build, including its status, duration, and other relevant information.', + params: [ + { + name: 'profileId', + description: 'Build profile ID', + type: CommandParameterTypes.SELECT, + requriedForInteractiveMode: true, + valueType: 'uuid', + }, + { + name: 'branchId', + description: 'Branch ID', + type: CommandParameterTypes.SELECT, + valueType: 'string', + requriedForInteractiveMode: true, + params: [], + }, + { + name: 'commitId', + description: 'Commit ID of your build', + type: CommandParameterTypes.SELECT, + valueType: 'uuid', + }, + { + name: 'buildId', + description: 'Build ID', + type: CommandParameterTypes.SELECT, + valueType: 'uuid', + }, + ] }, { - command: 'user', - description: 'User management', - longDescription: 'Organization users management (view, invite, re-invite, remove ).', - subCommands: [ + command: 'download', + description: 'Download your artifact to the given directory on your machine.', + params: [ { - command: 'view', - description: 'View users of organization', - params: [ { - name: 'organizationId', - description: 'Organization ID [Optional]', - type: CommandParameterTypes.SELECT, - defaultValue: 'current', - valueType: 'uuid', - required: false, - }], + name: 'path', + description: '[OPTIONAL] The path for artifacts to be downloaded:', + longDescription:'[OPTIONAL] The path for artifacts to be downloaded: (Defaults to the current directory)', + type: CommandParameterTypes.STRING, + valueType: 'string', + required: false, }, { - command: 'invite', - description: 'Invite user to organization', - params: [{ - name: 'organizationId', - description: 'Organization ID [Optional]', - type: CommandParameterTypes.SELECT, - defaultValue: 'current', - valueType: 'uuid', - required: false, - },{ - name: 'email', - description: 'Email', - type: CommandParameterTypes.STRING, - defaultValue: '', - valueType: 'string', - required: true, - },{ - name: 'role', - description: 'Role', - type: CommandParameterTypes.MULTIPLE_SELECT, - valueType: 'string', - required: false, - }], + name: 'profileId', + description: 'Build profile ID', + type: CommandParameterTypes.SELECT, + requriedForInteractiveMode: true, + valueType: 'uuid', }, { - command: 're-invite', - description: 'Re-invite user to organization', - params: [ - { - name: 'organizationId', - description: 'Organization ID [Optional]', - type: CommandParameterTypes.SELECT, - defaultValue: CURRENT_PARAM_VALUE, - valueType: 'uuid', - required: false, - },{ - name: 'email', - description: 'Email', - type: CommandParameterTypes.SELECT, - defaultValue: '', - valueType: 'string', - required: true, - } - ], + name: 'branchId', + description: 'Branch ID', + type: CommandParameterTypes.SELECT, + valueType: 'string', + requriedForInteractiveMode: true, + params: [], }, { - command: 'remove', - description: 'Remove user or inivation from organization', - params: [{ - name: 'organizationId', - description: 'Organization ID [Optional]', - type: CommandParameterTypes.SELECT, - defaultValue: CURRENT_PARAM_VALUE, - valueType: 'uuid', - required: false, - },{ - name: 'userId', - description: 'User ID', - type: CommandParameterTypes.SELECT, - valueType: 'uuid', - required: false, - },{ - name: 'email', - description: 'Email', - type: CommandParameterTypes.SELECT, - defaultValue: '', - valueType: 'string', - required: false, - }], + name: 'commitId', + description: 'Commit ID of your build', + type: CommandParameterTypes.SELECT, + valueType: 'uuid', + }, + { + name: 'buildId', + description: 'Build ID', + type: CommandParameterTypes.SELECT, + valueType: 'uuid', }, ], - params: [], }, { - command: 'role', - description: 'Roles management', - longDescription: 'Organization users roles management (view, add, remove, clear ).', + command:'profile', + description: 'Build profile actions.', subCommands: [ { - command: 'view', - description: 'View roles of the given userId within the organizationId.', - params: [ + command: 'list', + description: 'Build profile list', + longDescription: 'Get list of build profiles.', + params: [], + }, + { + command: 'branch', + description: 'Build profile branch actions', + subCommands: [ { - name: 'organizationId', - description: 'Organization ID [Optional]', - type: CommandParameterTypes.SELECT, - defaultValue: CURRENT_PARAM_VALUE, - valueType: 'uuid', - required: false, + command: 'list', + description: 'Get list of branches of a build profile', + params: [ + { + name: 'profileId', + description: 'Build profile ID', + type: CommandParameterTypes.SELECT, + valueType: 'uuid', + }, + ], }, { - name: 'userId', - description: 'User ID', - type: CommandParameterTypes.SELECT, - valueType: 'uuid', - required: true, + command: 'commits', + description: 'Get list of commits of a branch', + params: [ + { + name: 'profileId', + description: 'Build profile ID', + type: CommandParameterTypes.SELECT, + requriedForInteractiveMode: true, + valueType: 'uuid', + }, + { + name: 'branchId', + description: 'Branch ID', + type: CommandParameterTypes.SELECT, + valueType: 'uuid', + }, + ], }, ], + params: [] }, { - command: 'add', - description: 'Add roles to the given userId within the organizationId.', + command: 'workflows', + description: 'Get list of workflows of a build profile', params: [ { - name: 'organizationId', - description: 'Organization ID [Optional]', + name: 'profileId', + description: 'Build profile ID', type: CommandParameterTypes.SELECT, - defaultValue: CURRENT_PARAM_VALUE, valueType: 'uuid', - required: false, }, + ], + }, + { + command: 'configurations', + description: 'Get list of configurations of a build profile', + params: [ { - name: 'userId', - description: 'User ID', + name: 'profileId', + description: 'Build profile ID', type: CommandParameterTypes.SELECT, valueType: 'uuid', - required: true, }, + ], + }, + ], + params: [] + }, + { + command: 'variable', + description: 'Environment variable actions', + subCommands: [ + { + command: 'group', + description: 'Group Actions', + longDescription: 'Environment variable group actions', + params: [], + subCommands:[ { - name: 'role', - description: 'Roles', - type: CommandParameterTypes.MULTIPLE_SELECT, - valueType: 'string', - required: true, + command: "list", + description: 'List groups', + params: [], }, - ], + { + command: "create", + description: 'Create an environment variable group', + params: [ + { + name: 'name', + description: 'Variable group name', + type: CommandParameterTypes.STRING, + valueType: 'string', + }, + ], + } + ] }, { - command: 'remove', - description: 'Remove given roles from the given userId within the organizationId.', + command: 'create', + description: 'Create a file or text environment variable', params: [ { - name: 'organizationId', - description: 'Organization ID [Optional]', + name: 'variableGroupId', + description: 'Variable group ID', type: CommandParameterTypes.SELECT, - defaultValue: CURRENT_PARAM_VALUE, valueType: 'uuid', - required: false, }, { - name: 'userId', - description: 'User ID', + name: 'type', + description: 'Type', type: CommandParameterTypes.SELECT, - valueType: 'uuid', - required: true, + valueType: 'string', + params: [ + { + name: 'file', + description: 'File', + }, + { + name: 'text', + description: 'Text', + }, + ], }, { - name: 'role', - description: 'Roles', - type: CommandParameterTypes.MULTIPLE_SELECT, - from: 'user', + name: 'isSecret', + description: 'Secret', + type: CommandParameterTypes.BOOLEAN, + valueType: 'boolean', + required: false, + }, + { + name: 'key', + description: 'Key Name', + type: CommandParameterTypes.STRING, valueType: 'string', - required: true, + }, + { + name: 'value', + description: `Key Value`, + type: CommandParameterTypes.STRING, + valueType: 'string', + required: false, + paramType: 'text', + }, + { + name: 'filePath', + description: `File Path`, + type: CommandParameterTypes.STRING, + valueType: 'string', + required: false, + paramType: 'file', }, ], }, { - command: 'clear', - description: 'Remove all roles from the given userId within the organizationId.', + command: "view", + description: 'Get list of environment variables', params: [ { - name: 'organizationId', - description: 'Organization ID [Optional]', + name: 'variableGroupId', + description: 'Variable Groups ID', type: CommandParameterTypes.SELECT, - defaultValue: CURRENT_PARAM_VALUE, valueType: 'uuid', - required: false, }, - { - name: 'userId', - description: 'User ID', - type: CommandParameterTypes.SELECT, - valueType: 'uuid', - required: true, - } ], } ], - params: [], - }, + params: [] + } ], - params: [], + params: [] }, { - command: CommandTypes.LIST_BUILD_PROFILES, - description: 'Get list of build profiles', + command: CommandTypes.TESTING_DISTRIBUTION, + description: 'Testing Distribution', + longDescription: 'Testing Distribution management', params: [], - }, - { - command: CommandTypes.LIST_BUILD_PROFILE_BRANCHES, - description: 'Get list of branches of a build profile', - params: [ + subCommands: [ { - name: 'profileId', - description: 'Build profile ID', - type: CommandParameterTypes.SELECT, - valueType: 'uuid', - }, - ], - }, - { - command: CommandTypes.LIST_BUILD_PROFILE_WORKFLOWS, - description: 'Get list of workflows of a build profile', - params: [ - { - name: 'profileId', - description: 'Build profile ID', - type: CommandParameterTypes.SELECT, - valueType: 'uuid', - }, - ], - }, - { - command: CommandTypes.LIST_BUILD_PROFILE_CONFIGURATIONS, - description: 'Get list of configurations of a build profile', - params: [ - { - name: 'profileId', - description: 'Build profile ID', - type: CommandParameterTypes.SELECT, - valueType: 'uuid', - }, - ], - }, - { - command: CommandTypes.LIST_BUILD_PROFILE_COMMITS, - description: 'Get list of commits of a branch', - params: [ - { - name: 'profileId', - description: 'Build profile ID', - type: CommandParameterTypes.SELECT, - requriedForInteractiveMode: true, - valueType: 'uuid', - }, - { - name: 'branchId', - description: 'Branch ID', - type: CommandParameterTypes.SELECT, - valueType: 'uuid', - }, - ], - }, - { - command: CommandTypes.LIST_BUILD_PROFILE_BUILDS_OF_COMMIT, - description: 'Get list of builds of a commit', - params: [ - { - name: 'profileId', - description: 'Build profile ID', - type: CommandParameterTypes.SELECT, - requriedForInteractiveMode: true, - valueType: 'uuid', - }, - { - name: 'branchId', - description: 'Branch ID', - type: CommandParameterTypes.SELECT, - requriedForInteractiveMode: true, - valueType: 'uuid', - }, - { - name: 'commitId', - description: 'Commit ID', - type: CommandParameterTypes.SELECT, - valueType: 'uuid', - }, - ], - }, - { - command: CommandTypes.LIST_DISTRIBUTION_PROFILES, - description: 'Get list of distribution profiles', - params: [], - }, - { - command: CommandTypes.BUILD, - description: 'Start a new build', - params: [ - { - name: 'profileId', - description: 'Build profile ID', - type: CommandParameterTypes.SELECT, - valueType: 'uuid', - }, - { - name: 'branchId', - description: 'Branch ID', - type: CommandParameterTypes.SELECT, - valueType: 'uuid', - required: false, - params: [], - }, - { - name: 'commitId', - description: 'Commit ID [Optional]', - type: CommandParameterTypes.SELECT, - valueType: 'uuid', - required: false, - params: [], - }, - { - name: 'configurationId', - description: 'Configuration ID [Optional]', - type: CommandParameterTypes.SELECT, - valueType: 'uuid', - required: false, - params: [], - }, - { - name: 'workflowId', - description: 'Workflow ID', - type: CommandParameterTypes.SELECT, - valueType: 'uuid', - required: false, - params: [], - }, - { - name: 'branch', - description: "Branch Name instead of 'branch ID'", - type: CommandParameterTypes.STRING, - valueType: 'string', - required: false, - params: [], - }, - { - name: 'workflow', - description: "Workflow Name instead of 'workflow ID'", - type: CommandParameterTypes.STRING, - valueType: 'string', - required: false, - params: [], - }, - ], - }, - { - command: CommandTypes.DOWNLOAD, - description: 'Download your artifact to the given directory on your machine', - params: [ - { - name: 'path', - description: '[OPTIONAL] The path for artifacts to be downloaded:', - longDescription:'[OPTIONAL] The path for artifacts to be downloaded: (Defaults to the current directory)', - type: CommandParameterTypes.STRING, - valueType: 'string', - required: false, - }, - { - name: 'profileId', - description: 'Build profile ID', - type: CommandParameterTypes.SELECT, - requriedForInteractiveMode: true, - valueType: 'uuid', - }, - { - name: 'branchId', - description: 'Branch ID', - type: CommandParameterTypes.SELECT, - valueType: 'string', - requriedForInteractiveMode: true, - params: [], - }, - { - name: 'commitId', - description: 'Commit ID of your build', - type: CommandParameterTypes.SELECT, - valueType: 'uuid', - }, - { - name: 'buildId', - description: 'Build ID', - type: CommandParameterTypes.SELECT, - valueType: 'uuid', - }, - ], - }, - { - command: CommandTypes.UPLOAD, - description: 'Upload your mobile app to selected distribution profile', - params: [ - { - name: 'distProfileId', - description: 'Distribution profile ID', - type: CommandParameterTypes.SELECT, - valueType: 'uuid', - }, - { - name: 'message', - description: 'Release notes', - type: CommandParameterTypes.STRING, - valueType: 'string', - }, - { - name: 'app', - description: 'App path', - type: CommandParameterTypes.STRING, - valueType: 'path', - }, - ], - }, - { - command: CommandTypes.CREATE_DISTRIBUTION_PROFILE, - description: 'Create a distribution profile', - params: [ - { - name: 'name', - description: 'Profile name', - type: CommandParameterTypes.STRING, - valueType: 'string', - }, - ], - }, - { - command: CommandTypes.LIST_ENVIRONMENT_VARIABLE_GROUPS, - description: 'Get list of environment variable groups', - params: [], - }, - { - command: CommandTypes.CREATE_ENVIRONMENT_VARIABLE_GROUP, - description: 'Create an environment variable group', - params: [ - { - name: 'name', - description: 'Variable group name', - type: CommandParameterTypes.STRING, - valueType: 'string', - }, - ], - }, - { - command: CommandTypes.LIST_ENVIRONMENT_VARIABLES, - description: 'Get list of environment variables', - params: [ - { - name: 'variableGroupId', - description: 'Variable Groups ID', - type: CommandParameterTypes.SELECT, - valueType: 'uuid', - }, - ], - }, - { - command: CommandTypes.CREATE_ENVIRONMENT_VARIABLE, - description: 'Create a file or text environment variable', - params: [ - { - name: 'variableGroupId', - description: 'Variable group ID', - type: CommandParameterTypes.SELECT, - valueType: 'uuid', - }, - { - name: 'type', - description: 'Type', - type: CommandParameterTypes.SELECT, - valueType: 'string', + command: 'upload', + description: 'Upload your mobile app to selected distribution profile', params: [ { - name: 'file', - description: 'File', + name: 'distProfileId', + description: 'Distribution profile ID', + type: CommandParameterTypes.SELECT, + valueType: 'uuid', + }, + { + name: 'message', + description: 'Release notes', + type: CommandParameterTypes.STRING, + valueType: 'string', }, { - name: 'text', - description: 'Text', + name: 'app', + description: 'App path', + type: CommandParameterTypes.STRING, + valueType: 'path', }, ], }, { - name: 'isSecret', - description: 'Secret', - type: CommandParameterTypes.BOOLEAN, - valueType: 'boolean', - required: false, - }, - { - name: 'key', - description: 'Key Name', - type: CommandParameterTypes.STRING, - valueType: 'string', - }, - { - name: 'value', - description: `Key Value`, - type: CommandParameterTypes.STRING, - valueType: 'string', - required: false, - paramType: 'text', - }, - { - name: 'filePath', - description: `File Path`, - type: CommandParameterTypes.STRING, - valueType: 'string', - required: false, - paramType: 'file', - }, - ], - }, - { - command: CommandTypes.LIST_ENTERPRISE_PROFILES, - description: 'Get list of enterprise profiles', - params: [], - }, - { - command: CommandTypes.LIST_ENTERPRISE_APP_VERSIONS, - description: 'Get list of enterprise app versions', - params: [ - { - name: 'entProfileId', - description: 'Enterprise Profile ID', - type: CommandParameterTypes.SELECT, - valueType: 'uuid', - }, - { - name: 'publishType', - description: 'Publish Type Empty,0=All,1=Beta,2=Live', - type: CommandParameterTypes.SELECT, - defaultValue: '0', - params: [ - { - name: '0', - message: 'All', - }, + command:'profile', + description: 'Distribution profile actions', + subCommands: [ { - name: '1', - message: 'Beta', + command: 'list', + description: 'Get list of distribution profiles', + params: [], }, { - name: '2', - message: 'Live', + command: 'create', + description: 'Create a distribution profile', + params: [ + { + name: 'name', + description: 'Profile name', + type: CommandParameterTypes.STRING, + valueType: 'string', + }, + ], }, ], - required: false, - valueType: 'number', - }, - ], + params: [] + } + ] }, { - command: CommandTypes.PUBLISH_ENTERPRISE_APP_VERSION, - description: 'Publish enterprise app version', - params: [ - { - name: 'entProfileId', - description: 'Enterprise Profile ID', - type: CommandParameterTypes.SELECT, - valueType: 'uuid', - }, - { - name: 'entVersionId', - description: 'App Version ID', - type: CommandParameterTypes.SELECT, - valueType: 'uuid', - }, - { - name: 'summary', - description: 'Summary', - type: CommandParameterTypes.STRING, - valueType: 'string', - }, + command: CommandTypes.PUBLISH, + description: 'Publish', + longDescription: 'Manage publish module actions.', + subCommands: [ { - name: 'releaseNotes', - description: 'Release Notes', - type: CommandParameterTypes.STRING, - valueType: 'string', + command: 'start', + description: 'Start a publish', + longDescription: 'Starts a publish', + params: [ + platformParam, + { + name: 'publishProfileId', + description: 'Publish Profile ID', + type: CommandParameterTypes.SELECT, + valueType: 'uuid', + required: true + }, + { + name: 'appVersionId', + description: 'App version', + type: CommandParameterTypes.SELECT, + valueType: 'uuid', + required: true + } + ], }, { - name: 'publishType', - description: 'Publish Type 0=None,1=Beta,2=Live', - type: CommandParameterTypes.SELECT, - defaultValue: '0', - params: [ + command: 'profile', + description: 'Publish profile actions', + longDescription: 'Publish profile actions', + params: [], + subCommands: [ + { + command: 'list', + description: 'Publish profile list', + longDescription: 'Get list of publish profile', + params: [platformParam], + }, + { + command: 'create', + description: 'Create a publish profile', + longDescription: 'Create a new publish profile', + params: [platformParam, + { + name: 'name', + description: 'Profile name', + type: CommandParameterTypes.STRING, + defaultValue: undefined, + valueType: 'string', + required: true, + } + ], + }, { - name: '0', - message: 'None', + command: 'rename', + description: 'Raname publish profile', + longDescription: 'Rename publish profile', + params: [platformParam, + { + name: 'publishProfileId', + description: 'Publish Profile ID', + type: CommandParameterTypes.SELECT, + valueType: 'uuid', + required: true + }, + { + name: 'name', + description: 'New profile name', + type: CommandParameterTypes.STRING, + defaultValue: undefined, + valueType: 'string', + required: true, + } + ], }, { - name: '1', - message: 'Beta', + command: 'delete', + description: 'Remove publish profile', + longDescription: 'Remove publish profile', + params: [platformParam, + { + name: 'publishProfileId', + description: 'Publish Profile ID', + type: CommandParameterTypes.SELECT, + valueType: 'uuid', + required: true + } + ], }, { - name: '2', - message: 'Live', + command: 'version', + description: 'App version actions', + longDescription: 'App version actions', + params: [], + subCommands: [ + { + command: 'upload', + description: 'Upload a new app version', + longDescription: 'Upload a new version to given publish profile', + params: [ + platformParam, + { + name: 'publishProfileId', + description: 'Publish Profile ID', + type: CommandParameterTypes.SELECT, + valueType: 'uuid', + required: true + }, + { + name: 'app', + description: 'App path', + type: CommandParameterTypes.STRING, + valueType: 'path', + required: true + } + ], + }, + { + command: 'download', + description: 'Download app version', + longDescription: 'Download app version from selected publish profile', + params: [ + platformParam, + { + name: 'publishProfileId', + description: 'Publish Profile ID', + type: CommandParameterTypes.SELECT, + valueType: 'uuid', + required: true + }, + { + name: 'appVersionId', + description: 'App version', + type: CommandParameterTypes.SELECT, + valueType: 'uuid', + required: true + }, + { + name: 'path', + description: '[OPTIONAL] The path for artifacts to be downloaded:', + longDescription:'[OPTIONAL] The path for artifacts to be downloaded: (Defaults to the current directory)', + type: CommandParameterTypes.STRING, + valueType: 'path', + required: false + } + ], + }, + { + command: 'delete', + description: 'Remove app version', + longDescription: 'Remove app version from selected publish profile', + params: [ + platformParam, + { + name: 'publishProfileId', + description: 'Publish Profile ID', + type: CommandParameterTypes.SELECT, + valueType: 'uuid', + required: true + }, + { + name: 'appVersionId', + description: 'App version', + type: CommandParameterTypes.SELECT, + valueType: 'uuid', + required: true + } + ], + }, + { + command: 'mark-as-rc', + description: 'Mark as Release Candidate', + longDescription: 'Mark an app version as Release Candidate', + params: [ + platformParam, + { + name: 'publishProfileId', + description: 'Publish Profile ID', + type: CommandParameterTypes.SELECT, + valueType: 'uuid', + required: true + }, + { + name: 'appVersionId', + description: 'App version', + type: CommandParameterTypes.SELECT, + valueType: 'uuid', + required: true + } + ], + }, + { + command: 'unmark-as-rc', + description: 'Unmark as Release Candidate', + longDescription: 'Unmark an app version as Release Candidate', + params: [ + platformParam, + { + name: 'publishProfileId', + description: 'Publish Profile ID', + type: CommandParameterTypes.SELECT, + valueType: 'uuid', + required: true + }, + { + name: 'appVersionId', + description: 'App version', + type: CommandParameterTypes.SELECT, + valueType: 'uuid', + required: true + } + ], + }, + ] }, - ], - valueType: 'number', - }, - ], - }, - { - command: CommandTypes.UNPUBLISH_ENTERPRISE_APP_VERSION, - description: 'Unpublish enterprise app version', - params: [ - { - name: 'entProfileId', - description: 'Enterprise Profile ID', - type: CommandParameterTypes.SELECT, - valueType: 'uuid', - }, - { - name: 'entVersionId', - description: 'App Version ID', - type: CommandParameterTypes.SELECT, - valueType: 'uuid', - }, - ], - }, - { - command: CommandTypes.REMOVE_ENTERPRISE_APP_VERSION, - description: 'Remove enterprise app version', - params: [ - { - name: 'entProfileId', - description: 'Enterprise Profile ID', - type: CommandParameterTypes.SELECT, - valueType: 'uuid', + { + command: 'settings', + description: 'Publish profile settings', + longDescription: 'Publish profile settings', + params: [], + subCommands: [ + { + command: 'autopublish', + description: 'Set Publish Profile as Auto Publish', + longDescription: 'Start a publish process when a new version is received.', + params: [ + platformParam, + { + name: 'publishProfileId', + description: 'Publish Profile ID', + type: CommandParameterTypes.SELECT, + valueType: 'uuid', + required: true + }, + { + name: 'enable', + description: 'Enable Auto Publish', + type: CommandParameterTypes.BOOLEAN, + valueType: 'boolean', + required: true + } + ], + }, + ] + } + ] }, { - name: 'entVersionId', - description: 'App Version ID', - type: CommandParameterTypes.SELECT, - valueType: 'uuid', - }, + command: 'variable', + description: 'Publish Variables', + longDescription: 'Publish Variables', + params: [], + subCommands: [ + { + command: 'group', + description: 'Group Actions', + longDescription: 'Publish variable group actions', + params: [], + subCommands:[ + { + command: "list", + description: 'List groups', + longDescription: 'Publish variable group actions', + params: [], + }, + // { + // command: "create", + // description: 'Create new group', + // longDescription: 'Create a new publish variable group', + // params: [{ + // name: 'name', + // description: 'Group name', + // type: CommandParameterTypes.STRING, + // defaultValue: undefined, + // valueType: 'string', + // required: true, + // }], + // }, + { + command: "view", + description: 'View items of group', + longDescription: 'View items of publish variable group', + params: [ + { + name: 'publishVariableGroupId', + description: 'Variable Group ID', + type: CommandParameterTypes.SELECT, + valueType: 'uuid', + required: true + } + ], + } + ] + } + ] + } ], + params: [], }, { - command: CommandTypes.NOTIFY_ENTERPRISE_APP_VERSION, - description: 'Notify enterprise app version', - params: [ - { - name: 'entProfileId', - description: 'Enterprise Profile ID', - type: CommandParameterTypes.SELECT, - valueType: 'uuid', - }, - { - name: 'entVersionId', - description: 'App Version ID', - type: CommandParameterTypes.SELECT, - valueType: 'uuid', - }, + command: CommandTypes.ENTERPRISE_APP_STORE, + description: 'Enterprise App Store', + params: [], + subCommands: [ { - name: 'subject', - description: 'Subject', - type: CommandParameterTypes.STRING, - valueType: 'string', + command: 'profile', + description: 'Enterprise profile actions', + subCommands: [ + { + command: 'list', + description: 'Get list of enterprise profiles', + params: [], + } + ], + params: [] }, { - name: 'message', - description: 'Message', - type: CommandParameterTypes.STRING, - valueType: 'string', - }, - ], - }, - { - command: CommandTypes.UPLOAD_ENTERPRISE_APP_VERSION, - description: 'Upload enterprise app version for a profile', - params: [ - { - name: 'entProfileId', - description: 'Enterprise Profile Id', - type: CommandParameterTypes.SELECT, - valueType: 'uuid', - }, - { - name: 'app', - description: 'App path', - type: CommandParameterTypes.STRING, - valueType: 'string', - }, - ], + command: 'version', + description: 'Enterprise app version actions', + subCommands: [ + { + command: 'list', + description: 'Get list of enterprise app versions', + params: [ + { + name: 'entProfileId', + description: 'Enterprise Profile ID', + type: CommandParameterTypes.SELECT, + valueType: 'uuid', + }, + { + name: 'publishType', + description: 'Publish Type Empty,0=All,1=Beta,2=Live', + type: CommandParameterTypes.SELECT, + defaultValue: '0', + params: [ + { + name: '0', + message: 'All', + }, + { + name: '1', + message: 'Beta', + }, + { + name: '2', + message: 'Live', + }, + ], + required: false, + valueType: 'number', + }, + ], + }, + { + command: 'publish', + description: 'Publish enterprise app version', + params: [ + { + name: 'entProfileId', + description: 'Enterprise Profile ID', + type: CommandParameterTypes.SELECT, + valueType: 'uuid', + }, + { + name: 'entVersionId', + description: 'App Version ID', + type: CommandParameterTypes.SELECT, + valueType: 'uuid', + }, + { + name: 'summary', + description: 'Summary', + type: CommandParameterTypes.STRING, + valueType: 'string', + }, + { + name: 'releaseNotes', + description: 'Release Notes', + type: CommandParameterTypes.STRING, + valueType: 'string', + }, + { + name: 'publishType', + description: 'Publish Type 0=None,1=Beta,2=Live', + type: CommandParameterTypes.SELECT, + defaultValue: '0', + params: [ + { + name: '0', + message: 'None', + }, + { + name: '1', + message: 'Beta', + }, + { + name: '2', + message: 'Live', + }, + ], + valueType: 'number', + }, + ], + }, + { + command: 'unpublish', + description: 'Unpublish enterprise app version', + params: [ + { + name: 'entProfileId', + description: 'Enterprise Profile ID', + type: CommandParameterTypes.SELECT, + valueType: 'uuid', + }, + { + name: 'entVersionId', + description: 'App Version ID', + type: CommandParameterTypes.SELECT, + valueType: 'uuid', + }, + ], + }, + { + command: 'remove', + description: 'Remove enterprise app version', + params: [ + { + name: 'entProfileId', + description: 'Enterprise Profile ID', + type: CommandParameterTypes.SELECT, + valueType: 'uuid', + }, + { + name: 'entVersionId', + description: 'App Version ID', + type: CommandParameterTypes.SELECT, + valueType: 'uuid', + }, + ], + }, + { + command: 'notify', + description: 'Notify enterprise app version', + params: [ + { + name: 'entProfileId', + description: 'Enterprise Profile ID', + type: CommandParameterTypes.SELECT, + valueType: 'uuid', + }, + { + name: 'entVersionId', + description: 'App Version ID', + type: CommandParameterTypes.SELECT, + valueType: 'uuid', + }, + { + name: 'subject', + description: 'Subject', + type: CommandParameterTypes.STRING, + valueType: 'string', + }, + { + name: 'message', + description: 'Message', + type: CommandParameterTypes.STRING, + valueType: 'string', + }, + ], + }, + { + command: 'upload-for-profile', + description: 'Upload enterprise app version for a profile', + params: [ + { + name: 'entProfileId', + description: 'Enterprise Profile Id', + type: CommandParameterTypes.SELECT, + valueType: 'uuid', + }, + { + name: 'app', + description: 'App path', + type: CommandParameterTypes.STRING, + valueType: 'string', + }, + ], + }, + { + command: 'upload-without-profile', + description: 'Upload enterprise app version without a profile', + params: [ + { + name: 'app', + description: 'App path', + type: CommandParameterTypes.STRING, + valueType: 'string', + }, + ], + }, + { + command: 'download-link', + description: 'Get enterprise app download link', + params: [ + { + name: 'entProfileId', + description: 'Enterprise Profile Id', + type: CommandParameterTypes.SELECT, + valueType: 'uuid', + }, + { + name: 'entVersionId', + description: 'App Version ID', + type: CommandParameterTypes.SELECT, + valueType: 'uuid', + }, + ], + } + ], + params: [] + } + ] }, { - command: CommandTypes.UPLOAD_ENTERPRISE_APP, - description: 'Upload enterprise app version without a profile', - params: [ + command: CommandTypes.ORGANIZATION, + description: 'Organization management', + longDescription: 'Manage organization users, roles, and details.', + subCommands: [ { - name: 'app', - description: 'App path', - type: CommandParameterTypes.STRING, - valueType: 'string', + command: 'view', + description: 'View organizations details', + longDescription: 'View organization details. If "organizationId" not provided, will list all organizations.', + params: [{ + name: 'organizationId', + description: 'Organization ID [Optional]', + type: CommandParameterTypes.SELECT, + defaultValue: 'all', + valueType: 'uuid', + required: false, + }], }, - ], - }, - { - command: CommandTypes.GET_ENTERPRISE_DOWNLOAD_LINK, - description: 'Get enterprise app download link', - params: [ { - name: 'entProfileId', - description: 'Enterprise Profile Id', - type: CommandParameterTypes.SELECT, - valueType: 'uuid', + command: 'user', + description: 'User management', + longDescription: 'Organization users management (view, invite, re-invite, remove ).', + subCommands: [ + { + command: 'view', + description: 'View users of organization', + params: [ { + name: 'organizationId', + description: 'Organization ID [Optional]', + type: CommandParameterTypes.SELECT, + defaultValue: 'current', + valueType: 'uuid', + required: false, + }], + }, + { + command: 'invite', + description: 'Invite user to organization', + params: [{ + name: 'organizationId', + description: 'Organization ID [Optional]', + type: CommandParameterTypes.SELECT, + defaultValue: 'current', + valueType: 'uuid', + required: false, + },{ + name: 'email', + description: 'Email', + type: CommandParameterTypes.STRING, + defaultValue: '', + valueType: 'string', + required: true, + },{ + name: 'role', + description: 'Role', + type: CommandParameterTypes.MULTIPLE_SELECT, + valueType: 'string', + required: false, + }], + }, + { + command: 're-invite', + description: 'Re-invite user to organization', + params: [ + { + name: 'organizationId', + description: 'Organization ID [Optional]', + type: CommandParameterTypes.SELECT, + defaultValue: CURRENT_PARAM_VALUE, + valueType: 'uuid', + required: false, + },{ + name: 'email', + description: 'Email', + type: CommandParameterTypes.SELECT, + defaultValue: '', + valueType: 'string', + required: true, + } + ], + }, + { + command: 'remove', + description: 'Remove user or inivation from organization', + params: [{ + name: 'organizationId', + description: 'Organization ID [Optional]', + type: CommandParameterTypes.SELECT, + defaultValue: CURRENT_PARAM_VALUE, + valueType: 'uuid', + required: false, + },{ + name: 'userId', + description: 'User ID', + type: CommandParameterTypes.SELECT, + valueType: 'uuid', + required: false, + },{ + name: 'email', + description: 'Email', + type: CommandParameterTypes.SELECT, + defaultValue: '', + valueType: 'string', + required: false, + }], + }, + ], + params: [], }, { - name: 'entVersionId', - description: 'App Version ID', - type: CommandParameterTypes.SELECT, - valueType: 'uuid', + command: 'role', + description: 'Roles management', + longDescription: 'Organization users roles management (view, add, remove, clear ).', + subCommands: [ + { + command: 'view', + description: 'View roles of the given userId within the organizationId.', + params: [ + { + name: 'organizationId', + description: 'Organization ID [Optional]', + type: CommandParameterTypes.SELECT, + defaultValue: CURRENT_PARAM_VALUE, + valueType: 'uuid', + required: false, + }, + { + name: 'userId', + description: 'User ID', + type: CommandParameterTypes.SELECT, + valueType: 'uuid', + required: true, + }, + ], + }, + { + command: 'add', + description: 'Add roles to the given userId within the organizationId.', + params: [ + { + name: 'organizationId', + description: 'Organization ID [Optional]', + type: CommandParameterTypes.SELECT, + defaultValue: CURRENT_PARAM_VALUE, + valueType: 'uuid', + required: false, + }, + { + name: 'userId', + description: 'User ID', + type: CommandParameterTypes.SELECT, + valueType: 'uuid', + required: true, + }, + { + name: 'role', + description: 'Roles', + type: CommandParameterTypes.MULTIPLE_SELECT, + valueType: 'string', + required: true, + }, + ], + }, + { + command: 'remove', + description: 'Remove given roles from the given userId within the organizationId.', + params: [ + { + name: 'organizationId', + description: 'Organization ID [Optional]', + type: CommandParameterTypes.SELECT, + defaultValue: CURRENT_PARAM_VALUE, + valueType: 'uuid', + required: false, + }, + { + name: 'userId', + description: 'User ID', + type: CommandParameterTypes.SELECT, + valueType: 'uuid', + required: true, + }, + { + name: 'role', + description: 'Roles', + type: CommandParameterTypes.MULTIPLE_SELECT, + from: 'user', + valueType: 'string', + required: true, + }, + ], + }, + { + command: 'clear', + description: 'Remove all roles from the given userId within the organizationId.', + params: [ + { + name: 'organizationId', + description: 'Organization ID [Optional]', + type: CommandParameterTypes.SELECT, + defaultValue: CURRENT_PARAM_VALUE, + valueType: 'uuid', + required: false, + }, + { + name: 'userId', + description: 'User ID', + type: CommandParameterTypes.SELECT, + valueType: 'uuid', + required: true, + } + ], + } + ], + params: [], }, ], - }, + params: [], + } ]; diff --git a/src/core/interactive-runner.ts b/src/core/interactive-runner.ts index 35dd840..26e5175 100644 --- a/src/core/interactive-runner.ts +++ b/src/core/interactive-runner.ts @@ -6,7 +6,7 @@ import moment from 'moment'; import { prompt, Select, AutoComplete, BooleanPrompt, MultiSelect } from 'enquirer'; import { runCommand } from './command-runner'; import { Commands, CommandParameterTypes, CommandTypes, CommandType } from './commands'; -import { APPCIRCLE_COLOR, UNKNOWN_PARAM_VALUE } from '../constant'; +import { APPCIRCLE_COLOR, OperatingSystems, UNKNOWN_PARAM_VALUE } from '../constant'; import { createOra } from '../utils/orahelper'; import { getBranches, @@ -25,6 +25,9 @@ import { getOrganizationInvitations, getOrganizationUsers, getOrganizationUserinfo, + getPublishProfiles, + getAppVersions, + getPublishVariableGroups, } from '../services'; import { DefaultEnvironmentVariables, getConfigStore } from '../config'; import { ProgramCommand, createCommandActionCallback } from '../program'; @@ -307,7 +310,41 @@ const handleInteractiveParamsOrArguments = async ( param.params = userList.map((user: any) => ({ name: user.id, message: user._message || ` ${user.id} (${user.email})` })); spinner.text = 'Users fetched'; spinner.succeed(); - } else if (param.name === 'email' && param.type === CommandParameterTypes.SELECT) { + }else if(param.name === 'publishProfileId' && param.type === CommandParameterTypes.SELECT){ + const spinner = ora('Publish Profiles Fetching').start(); + const selectedPlatform = params["platform"]; + const publishProfiles = await getPublishProfiles({ platform: selectedPlatform }); + param.params = publishProfiles.map((profile:any) => ({name:profile.id, message: ` ${profile.id} (${profile.name}) - ${(OperatingSystems as any)[profile.platformType]}`})); + spinner.text = 'Publish Profiles Fetched'; + spinner.succeed(); + }else if(param.name === 'appVersionId' && param.type === CommandParameterTypes.SELECT){ + const spinner = ora('App Versions Fetching').start(); + const selectedPlatform = params["platform"]; + const selectedPublishProfileId = params["publishProfileId"]; + const appVersions = await getAppVersions({ platform: selectedPlatform, publishProfileId: selectedPublishProfileId }); + if (!appVersions || appVersions.length === 0) { + spinner.text = 'No app versions available'; + spinner.fail(); + return { isError: true }; + }else { + param.params = appVersions.map((appVersion:any) => ({name:appVersion.id, message: ` ${appVersion.id} - ${appVersion.name}(${appVersion.version}) ${appVersion.releaseCandidate ? '(Release Candidate)' : ''}`})); + spinner.text = 'App Versions Fetched'; + spinner.succeed(); + } + }else if(param.name === 'publishVariableGroupId' && param.type === CommandParameterTypes.SELECT){ + const spinner = ora('Publish Variable Groups Fetching').start(); + const groups = await getPublishVariableGroups(); + if (!groups || groups.length === 0) { + spinner.text = 'No groups available'; + spinner.fail(); + return { isError: true }; + }else { + param.params = groups.map((group:any) => ({name:group.id, message: ` ${group.id} (${group.name})`})); + spinner.text = 'Publish Variable Groups Fetched'; + spinner.succeed(); + } + } + else if (param.name === 'email' && param.type === CommandParameterTypes.SELECT) { const spinner = ora('Invitations fetching').start(); const invitationsList = await getOrganizationInvitations({ organizationId: params.organizationId || params.currentOrganizationId || '' }); if (param.required !== false && (!invitationsList || invitationsList.length === 0)) { @@ -321,14 +358,14 @@ const handleInteractiveParamsOrArguments = async ( param.params = invitationsList.map((invitation: any) => ({ name: invitation.userEmail, message: invitation._message || invitation.userEmail })); spinner.text = 'Invitations fetched'; spinner.succeed(); - } else if (param.name === 'value' && params.isSecret) { + }else if (param.name === 'value' && params.isSecret) { param.type = CommandParameterTypes.PASSWORD; } // If has paramType and type match to selected type if (!param.paramType || param.paramType === params.type) { // Prompt for parameter - if ([CommandParameterTypes.STRING, CommandParameterTypes.PASSWORD].includes(param.type)) { + if ([CommandParameterTypes.STRING, CommandParameterTypes.PASSWORD].includes(param.type) && !param.skipForInteractiveMode) { const stringPrompt = await prompt([ { type: param.type, @@ -365,6 +402,7 @@ const handleInteractiveParamsOrArguments = async ( ], }); (params as any)[param.name] = await selectPrompt.run(); + } else if (param.type === CommandParameterTypes.MULTIPLE_SELECT && param.params) { const selectPrompt = new AutoComplete({ name: param.name, @@ -387,7 +425,6 @@ const handleInteractiveParamsOrArguments = async ( const handleCommandParamsAndArguments = async (selectedCommand: CommandType, parentCommand: any): Promise => { const params = (await handleInteractiveParamsOrArguments(selectedCommand.params || [])) || {}; const args = (await handleInteractiveParamsOrArguments(selectedCommand.arguments || [])) || {}; - return createCommandActionCallback({ parent: parentCommand || null, name: () => selectedCommand.command, @@ -398,7 +435,6 @@ const handleCommandParamsAndArguments = async (selectedCommand: CommandType, par const handleSelectedCommand = async (command: CommandType, __parentCommand?: any): Promise => { const preparedCommand = await handleCommandParamsAndArguments(command, __parentCommand); - if (command.subCommands?.length) { const commandSelect = new AutoComplete({ name: 'action', diff --git a/src/core/writer.ts b/src/core/writer.ts index 455e538..e9e6d93 100644 --- a/src/core/writer.ts +++ b/src/core/writer.ts @@ -1,6 +1,6 @@ import chalk from 'chalk'; import { CommandTypes } from './commands'; -import { AuthenticationTypes, OperatingSystems, PlatformTypes, PublishTypes, BuildStatus, PROGRAM_NAME } from '../constant'; +import { AuthenticationTypes, OperatingSystems, PlatformTypes, PublishTypes, BuildStatus, PROGRAM_NAME, QueueItemStatus } from '../constant'; import moment from 'moment'; import { getConsoleOutputType } from '../config'; @@ -14,212 +14,250 @@ const writersMap: { [key in CommandTypes]: (data: any) => void } = { ) ); }, - [CommandTypes.LIST_BUILD_PROFILES]: (data: any) => { - if (data.length === 0) { - console.info('No build profiles available.'); - return; - } - console.table( - data.map((buildProfile: any) => ({ - 'Profile Id': buildProfile.id, - 'Profile Name': buildProfile.name, - Pinned: buildProfile.pinned, - 'Target OS': (OperatingSystems as any)[buildProfile.os], - 'Target Platform': (PlatformTypes as any)[buildProfile.buildPlatformType], - Repository: buildProfile.repositoryName ? buildProfile.repositoryName : 'No repository connected', - 'Last Build': buildProfile.lastBuildDate ? moment(buildProfile.lastBuildDate).calendar() : 'No previous builds', - 'Auto Distribute': buildProfile.autoDistributeCount === 0 ? 'Disabled' : `Enabled in ${buildProfile.autoDistributeCount} branch(es)`, - 'Auto Build': buildProfile.autoBuildCount === 0 ? 'Disabled' : 'Enabled', - })) - ); - }, - [CommandTypes.LIST_BUILD_PROFILE_BRANCHES]: (data: any) => { - console.table( - data.branches.map((branch: any) => ({ - 'Branch Id': branch.id, - 'Branch Name': branch.name, - 'Last Build': branch.lastBuildDate ? moment(branch.lastBuildDate).calendar() : 'No previous builds', - //@ts-ignore - 'Build Status': BuildStatus[String(branch.buildStatus)] || 'No previous builds', - })) - ); - }, - [CommandTypes.LIST_BUILD_PROFILE_WORKFLOWS]: (data: any) => { - console.table( - data.map((workflow: any) => ({ - 'Workflow Id': workflow.id, - 'Workflow Name': workflow.configurationName, - 'Last Used': workflow.lastUsedTime ? moment(workflow.lastUsedTime).calendar() : 'No previous builds', - })) - ); - }, - [CommandTypes.LIST_BUILD_PROFILE_CONFIGURATIONS]: (data: any) => { - console.table( - data.map((configuration: any) => ({ - 'Configuration Id': configuration.item1.id, - 'Configuration Name': configuration.item1.configurationName, - 'Update Date': configuration.item1.updateDate ? moment(configuration.item1.updateDate).calendar() : 'No updated before', - })) - ); - }, - [CommandTypes.LIST_BUILD_PROFILE_COMMITS]: (data: any) => { - if (data.length === 0) { - console.info('No commits available.'); - return; - } - console.table( - data.map((commit: any) => ({ - 'Commit Id': commit.id, - Hash: commit.hash, - Date: commit.commitDate ? moment(commit.commitDate).calendar() : 'Could not find date', - Author: commit.author || '', - Message: commit.message || '', - })) - ); - }, - [CommandTypes.LIST_BUILD_PROFILE_BUILDS_OF_COMMIT]: (data: any) => { - if (data.builds.length === 0) { - console.info('No builds available.'); - return; - } - console.table( - data.builds?.map((build: any) => ({ - 'Build Id': build.id, - Hash: build.hash, - - 'Has Warning': !!build.hasWarning, - Status: build.status, - 'Start Date': build.startDate ? moment(build.startDate).calendar() : 'Could not find date', - 'End Date': build.endDate ? moment(build.endDate).calendar() : 'Could not find date', - })) - ); - }, - [CommandTypes.LIST_DISTRIBUTION_PROFILES]: (data: any) => { - if (data.length === 0) { - console.info('No distribution profiles available.'); - return; - } - console.table( - data.map((distributionProfile: any) => ({ - 'Profile Id': distributionProfile.id, - 'Profile Name': distributionProfile.name, - Pinned: distributionProfile.pinned, - 'iOS Version': distributionProfile.iOSVersion ? distributionProfile.iOSVersion : 'No versions available', - 'Android Version': distributionProfile.androidVersion ? distributionProfile.androidVersion : 'No versions available', - 'Last Updated': moment(distributionProfile.updateDate).fromNow(), - 'Last Shared': distributionProfile.lastAppVersionSharedDate ? moment(distributionProfile.lastAppVersionSharedDate).fromNow() : 'Not Shared', - Authentication: (AuthenticationTypes as any)[distributionProfile.settings.authenticationType], - 'Auto Send': distributionProfile.testingGroupIds ? 'Enabled' : 'Disabled', - })) - ); - }, - [CommandTypes.BUILD]: (data: any) => {}, - [CommandTypes.DOWNLOAD]: (data: any) => {}, - [CommandTypes.UPLOAD]: (data: any) => {}, - [CommandTypes.CREATE_DISTRIBUTION_PROFILE]: (data: any) => { - console.info(`\n${data.name} distribution profile created successfully!`); - }, - [CommandTypes.LIST_ENVIRONMENT_VARIABLE_GROUPS]: (data: any) => { - console.table(data.map((x: any) => ({ 'Variable Groups ID': x.id, 'Variable Groups Name': x.name }))); - }, - [CommandTypes.CREATE_ENVIRONMENT_VARIABLE_GROUP]: (data: any) => { - console.info(`\n${data.name} environment variable group created successfully!`); - }, - [CommandTypes.LIST_ENVIRONMENT_VARIABLES]: (data: any) => { - console.table( - data.map((environmentVariable: any) => ({ - 'Key Name': environmentVariable.key, - 'Key Value': environmentVariable.isSecret ? '********' : environmentVariable.value, - })) - ); - }, - [CommandTypes.CREATE_ENVIRONMENT_VARIABLE]: (data: any) => { - console.info(`\n${data.key} environment variable created successfully!`); - }, - [CommandTypes.LIST_ENTERPRISE_PROFILES]: (data: any) => { - if (data.length === 0) { - console.info('No build profiles available.'); - return; + [CommandTypes.TESTING_DISTRIBUTION]: (data: any) => { + if(data.fullCommandName === `${PROGRAM_NAME}-distribution-profile-list`){ + if (data?.data?.length === 0) { + console.info('No distribution profiles available.'); + return; + } + console.table( + data?.data?.map((distributionProfile: any) => ({ + 'Profile Id': distributionProfile.id, + 'Profile Name': distributionProfile.name, + Pinned: distributionProfile.pinned, + 'iOS Version': distributionProfile.iOSVersion ? distributionProfile.iOSVersion : 'No versions available', + 'Android Version': distributionProfile.androidVersion ? distributionProfile.androidVersion : 'No versions available', + 'Last Updated': moment(distributionProfile.updateDate).fromNow(), + 'Last Shared': distributionProfile.lastAppVersionSharedDate ? moment(distributionProfile.lastAppVersionSharedDate).fromNow() : 'Not Shared', + Authentication: (AuthenticationTypes as any)[distributionProfile.settings.authenticationType], + 'Auto Send': distributionProfile.testingGroupIds ? 'Enabled' : 'Disabled', + })) + ); + } else if(data.fullCommandName === `${PROGRAM_NAME}-distribution-profile-create`){ + console.info(`\n${data.data.name} distribution profile created successfully!`); } - console.table( - data.map((buildProfile: any) => ({ - 'Profile Id': buildProfile.id, - 'Profile Name': buildProfile.name, - Version: buildProfile.version, - Downloads: buildProfile.totalDownloadCount, - 'Latest Publish': buildProfile.latestPublishDate ? moment(buildProfile.latestPublishDate).calendar() : '-', - 'Last Received': buildProfile.lastBinaryReceivedDate ? moment(buildProfile.lastBinaryReceivedDate).calendar() : '-', - })) - ); }, - [CommandTypes.LIST_ENTERPRISE_APP_VERSIONS]: (data: any) => { - if (data.length === 0) { - console.info('No app versions available.'); - return; + [CommandTypes.BUILD]: (data: any) => { + if(data.fullCommandName === `${PROGRAM_NAME}-build-profile-list`){ + if (data?.data?.length === 0) { + console.info('No build profiles available.'); + return; + } + console.table( + data?.data?.map((buildProfile: any) => ({ + 'Profile Id': buildProfile.id, + 'Profile Name': buildProfile.name, + Pinned: buildProfile.pinned, + 'Target OS': (OperatingSystems as any)[buildProfile.os], + 'Target Platform': (PlatformTypes as any)[buildProfile.buildPlatformType], + Repository: buildProfile.repositoryName ? buildProfile.repositoryName : 'No repository connected', + 'Last Build': buildProfile.lastBuildDate ? moment(buildProfile.lastBuildDate).calendar() : 'No previous builds', + 'Auto Distribute': buildProfile.autoDistributeCount === 0 ? 'Disabled' : `Enabled in ${buildProfile.autoDistributeCount} branch(es)`, + 'Auto Build': buildProfile.autoBuildCount === 0 ? 'Disabled' : 'Enabled', + })) + ); + } else if(data.fullCommandName === `${PROGRAM_NAME}-build-profile-branch-list`) { + console.table( + data?.data?.branches.map((branch: any) => ({ + 'Branch Id': branch.id, + 'Branch Name': branch.name, + 'Last Build': branch.lastBuildDate ? moment(branch.lastBuildDate).calendar() : 'No previous builds', + //@ts-ignore + 'Build Status': BuildStatus[String(branch.buildStatus)] || 'No previous builds', + })) + ); + } else if(data.fullCommandName === `${PROGRAM_NAME}-build-profile-workflows`) { + console.table( + data?.data?.map((workflow: any) => ({ + 'Workflow Id': workflow.id, + 'Workflow Name': workflow.workflowName, + 'Last Used': workflow.lastUsedTime ? moment(workflow.lastUsedTime).calendar() : 'No previous builds', + })) + ); + } else if(data.fullCommandName === `${PROGRAM_NAME}-build-profile-configurations`){ + console.table( + data?.data?.map((configuration: any) => ({ + 'Configuration Id': configuration.item1.id, + 'Configuration Name': configuration.item1.configurationName, + 'Update Date': configuration.item1.updateDate ? moment(configuration.item1.updateDate).calendar() : 'No updated before', + })) + ); + } else if (data.fullCommandName === `${PROGRAM_NAME}-build-profile-branch-commits`){ + if (data?.data?.length === 0) { + console.info('No commits available.'); + return; + } + console.table( + data?.data?.map((commit: any) => ({ + 'Commit Id': commit.id, + Hash: commit.hash, + Date: commit.commitDate ? moment(commit.commitDate).calendar() : 'Could not find date', + Author: commit.author || '', + Message: commit.message || '', + })) + ); + } else if (data.fullCommandName === `${PROGRAM_NAME}-build-list`){ + if (data?.data?.builds?.length === 0) { + console.info('No builds available.'); + return; + } + console.table( + data?.data?.builds?.map((build: any) => ({ + 'Build Id': build.id, + Hash: build.hash, + 'Has Warning': !!build.hasWarning, + Status: build.status, + 'Start Date': build.startDate ? moment(build.startDate).calendar() : 'Could not find date', + 'End Date': build.endDate ? moment(build.endDate).calendar() : 'Could not find date', + })) + ); + } else if(data.fullCommandName === `${PROGRAM_NAME}-build-variable-group-list`){ + console.table(data?.data?.map((x: any) => ({ 'Variable Groups ID': x.id, 'Variable Groups Name': x.name }))); + } else if(data.fullCommandName === `${PROGRAM_NAME}-build-variable-group-create`){ + console.info(`\n${data?.data?.name} environment variable group created successfully!`); + } else if(data.fullCommandName === `${PROGRAM_NAME}-build-variable-view`){ + console.table( + data?.data?.map((environmentVariable: any) => ({ + 'Key Name': environmentVariable.key, + 'Key Value': environmentVariable.isSecret ? '********' : environmentVariable.value, + })) + ); + } else if(data.fullCommandName === `${PROGRAM_NAME}-build-variable-create`){ + console.info(`\n${data?.data?.key} environment variable created successfully!`); + } else if (data.fullCommandName === `${PROGRAM_NAME}-build-active-list` ) { + if(data?.data?.data?.length === 0) { + console.info('No active builds available.'); + return; + } + console.table( + data?.data?.data?.map((build: any) => ({ + 'Build Id': build.id, + 'Commit Id': build.commitId, + 'Commit Hash': build.commitHash || '-', + 'Profile Name': build.profileName || '-', + 'Branch Name': build.branchName || '-', + 'Status': build.queueItemStatus !== null || build.queueItemStatus !== undefined ? (QueueItemStatus as any )[String(build.queueItemStatus)] : '-', + })) + ); } - console.table( - data.map((buildProfile: any) => ({ - 'Version Name': buildProfile.name, - Summary: buildProfile.summary, - Version: buildProfile.version, - 'Version Code': buildProfile.versionCode, - 'Publish Type': (PublishTypes as any)[buildProfile.publishType], - 'Latest Publish': buildProfile.publishDate ? moment(buildProfile.publishDate).calendar() : '-', - 'Target Platform': (OperatingSystems as any)[buildProfile.platformType], - Downloads: buildProfile.downloadCount, - Created: buildProfile.createDate ? moment(buildProfile.createDate).calendar() : '-', - Updated: buildProfile.updateDate ? moment(buildProfile.updateDate).calendar() : '-', - })) - ); - }, - [CommandTypes.PUBLISH_ENTERPRISE_APP_VERSION]: (data: any) => { - console.table( - [data].map((buildProfile: any) => ({ - 'Profile Name': buildProfile.name, - Summary: buildProfile.summary, - Version: buildProfile.version, - 'Version Code': buildProfile.versionCode, - 'Publish Type': (PublishTypes as any)[buildProfile.publishType], - 'Latest Publish': buildProfile.publishDate ? moment(buildProfile.publishDate).calendar() : '-', - 'Target Platform': (OperatingSystems as any)[buildProfile.platformType], - Downloads: buildProfile.downloadCount, - Created: buildProfile.createDate ? moment(buildProfile.createDate).calendar() : '-', - Updated: buildProfile.updateDate ? moment(buildProfile.updateDate).calendar() : '-', - })) - ); - }, - [CommandTypes.UNPUBLISH_ENTERPRISE_APP_VERSION]: (data: any) => { - if (data.length === 0) { - console.info('No app versions available.'); - return; + else if (data.fullCommandName === `${PROGRAM_NAME}-build-view` ) { + const build = data?.data; + if(!build){ + console.info('No builds available.'); + return; + } + const parsedDuration = moment.duration(build.duration); + const minutes = parsedDuration.minutes() !== 0 ? `${parsedDuration.minutes()} minutes ` : ''; + const seconds = parsedDuration.seconds() !== 0 ? `${parsedDuration.seconds()} seconds ` : ''; + const hours = parsedDuration.hours() !== 0 ? `${parsedDuration.hours()} hours ` : ''; + console.table( + { + 'Build Id': build.id, + 'Commit Id': build.commitId, + 'Hash': build.hash || '-', + 'Has Warning': !!build.hasWarning, + 'Status': build.status !== null || build.status !== undefined ? (BuildStatus as any)[String(build.status)] : '-', + 'Duration': build.duration ? `${hours}${minutes}${seconds}` : '-', + 'Is Distributable': build.isDistributable || '-', + 'Start Date': build.startDate ? moment(build.startDate).calendar() : 'Could not find date', + 'End Date': build.endDate ? moment(build.endDate).calendar() : 'Could not find date', + } + ); } - console.table( - [data].map((buildProfile: any) => ({ - 'Profile Name': buildProfile.name, - Summary: buildProfile.summary, - Version: buildProfile.version, - 'Version Code': buildProfile.versionCode, - 'Publish Type': (PublishTypes as any)[buildProfile.publishType], - 'Latest Publish': buildProfile.publishDate ? moment(buildProfile.publishDate).calendar() : '-', - 'Target Platform': (OperatingSystems as any)[buildProfile.platformType], - Downloads: buildProfile.downloadCount, - Created: buildProfile.createDate ? moment(buildProfile.createDate).calendar() : '-', - Updated: buildProfile.updateDate ? moment(buildProfile.updateDate).calendar() : '-', - })) - ); }, - [CommandTypes.REMOVE_ENTERPRISE_APP_VERSION]: (data: any) => {}, - [CommandTypes.NOTIFY_ENTERPRISE_APP_VERSION]: (data: any) => { - if (data.length === 0) { - console.info('No app versions available.'); - return; + [CommandTypes.ENTERPRISE_APP_STORE]: (data: any) => { + if(data.fullCommandName === `${PROGRAM_NAME}-enterprise-app-store-profile-list`) { + if (data?.data?.length === 0) { + console.info('No build profiles available.'); + return; + } + console.table( + data?.data?.map((buildProfile: any) => ({ + 'Profile Id': buildProfile.id, + 'Profile Name': buildProfile.name, + Version: buildProfile.version, + Downloads: buildProfile.totalDownloadCount, + 'Latest Publish': buildProfile.latestPublishDate ? moment(buildProfile.latestPublishDate).calendar() : '-', + 'Last Received': buildProfile.lastBinaryReceivedDate ? moment(buildProfile.lastBinaryReceivedDate).calendar() : '-', + })) + ); + } else if (data.fullCommandName === `${PROGRAM_NAME}-enterprise-app-store-version-list`){ + if (data?.data?.length === 0) { + console.info('No app versions available.'); + return; + } + console.table( + data?.data?.map((buildProfile: any) => ({ + 'Version Name': buildProfile.name, + Summary: buildProfile.summary, + Version: buildProfile.version, + 'Version Code': buildProfile.versionCode, + 'Publish Type': (PublishTypes as any)[buildProfile.publishType], + 'Latest Publish': buildProfile.publishDate ? moment(buildProfile.publishDate).calendar() : '-', + 'Target Platform': (OperatingSystems as any)[buildProfile.platformType], + Downloads: buildProfile.downloadCount, + Created: buildProfile.createDate ? moment(buildProfile.createDate).calendar() : '-', + Updated: buildProfile.updateDate ? moment(buildProfile.updateDate).calendar() : '-', + })) + ); + } else if (data.fullCommandName === `${PROGRAM_NAME}-enterprise-app-store-version-publish`){ + console.table( + [data?.data]?.map((buildProfile: any) => ({ + 'Profile Name': buildProfile.name, + Summary: buildProfile.summary, + Version: buildProfile.version, + 'Version Code': buildProfile.versionCode, + 'Publish Type': (PublishTypes as any)[buildProfile.publishType], + 'Latest Publish': buildProfile.publishDate ? moment(buildProfile.publishDate).calendar() : '-', + 'Target Platform': (OperatingSystems as any)[buildProfile.platformType], + Downloads: buildProfile.downloadCount, + Created: buildProfile.createDate ? moment(buildProfile.createDate).calendar() : '-', + Updated: buildProfile.updateDate ? moment(buildProfile.updateDate).calendar() : '-', + })) + ); + } else if (data.fullCommandName === `${PROGRAM_NAME}-enterprise-app-store-version-unpublish`){ + console.table( + [data?.data]?.map((buildProfile: any) => ({ + 'Profile Name': buildProfile.name, + Summary: buildProfile.summary, + Version: buildProfile.version, + 'Version Code': buildProfile.versionCode, + 'Publish Type': (PublishTypes as any)[buildProfile.publishType], + 'Latest Publish': buildProfile.publishDate ? moment(buildProfile.publishDate).calendar() : '-', + 'Target Platform': (OperatingSystems as any)[buildProfile.platformType], + Downloads: buildProfile.downloadCount, + Created: buildProfile.createDate ? moment(buildProfile.createDate).calendar() : '-', + Updated: buildProfile.updateDate ? moment(buildProfile.updateDate).calendar() : '-', + })) + ); + } else if (data.fullCommandName === `${PROGRAM_NAME}-enterprise-app-store-version-unpublish`) { + if (data?.data?.length === 0) { + console.info('No app versions available.'); + return; + } + console.table( + [data?.data]?.map((buildProfile: any) => ({ + 'Profile Name': buildProfile.name, + Summary: buildProfile.summary, + Version: buildProfile.version, + 'Version Code': buildProfile.versionCode, + 'Publish Type': (PublishTypes as any)[buildProfile.publishType], + 'Latest Publish': buildProfile.publishDate ? moment(buildProfile.publishDate).calendar() : '-', + 'Target Platform': (OperatingSystems as any)[buildProfile.platformType], + Downloads: buildProfile.downloadCount, + Created: buildProfile.createDate ? moment(buildProfile.createDate).calendar() : '-', + Updated: buildProfile.updateDate ? moment(buildProfile.updateDate).calendar() : '-', + })) + ); + } else if (data.fullCommandName === `${PROGRAM_NAME}-enterprise-app-store-version-notify`){ + if (data?.data?.length === 0) { + console.info('No app versions available.'); + return; + } + } else if (data.fullCommandName === `${PROGRAM_NAME}-enterprise-app-store-version-download-link`) { + console.log(`Download Link: ${data?.data}`); } }, - [CommandTypes.UPLOAD_ENTERPRISE_APP]: (data: any) => {}, - [CommandTypes.UPLOAD_ENTERPRISE_APP_VERSION]: (data: any) => {}, - [CommandTypes.GET_ENTERPRISE_DOWNLOAD_LINK]: (data: any) => { - console.log(`Download Link: ${data}`); - }, [CommandTypes.ORGANIZATION]: (data: any) => { if (data.fullCommandName === `${PROGRAM_NAME}-organization-view`) { let isAll = Array.isArray(data.data); @@ -287,7 +325,80 @@ const writersMap: { [key in CommandTypes]: (data: any) => void } = { } else { console.log(data.data); } - }, + }, + [CommandTypes.PUBLISH]: (data: any) => { + if(data.fullCommandName === `${PROGRAM_NAME}-publish-profile-create`){ + console.table( + [{ 'Id:': data.data.id, + 'Name:': data.data.name, + 'Created:': data.data.createDate ? moment(data.data.createDate).calendar() : '-', + }] + ) + }else if(data.fullCommandName === `${PROGRAM_NAME}-publish-profile-rename`){ + console.table( + [{ 'Id:': data.data.id, + 'Name:': data.data.name, + 'Created:': data.data.createDate ? moment(data.data.createDate).calendar() : '-', + 'Updated:': data.data.updateDate ? moment(data.data.updateDate).calendar() : '-', + }] + ) + } + else if(data.fullCommandName === `${PROGRAM_NAME}-publish-profile-list`){ + data.data.length > 0 ? + console.table( + data.data.map((publishProfile: any) => ({ + 'Id': publishProfile.id, + 'Name': publishProfile.name, + 'Last Version': publishProfile.lastUploadVersion, + 'Last Version Code': publishProfile.lastUploadVersionCode, + 'Version Code': publishProfile.version, + 'App Unique Id': publishProfile.appUniqueId , + 'Latest Publish': publishProfile.latestPublishDate ? moment(publishProfile.publishDate).calendar() : '-', + 'Platform': (OperatingSystems as any)[publishProfile.platformType], + Created: publishProfile.createDate ? moment(publishProfile.createDate).calendar() : '-', + Updated: publishProfile.updateDate ? moment(publishProfile.updateDate).calendar() : '-', + })) + ) : console.log(' No publish profile found'); + }else if(data.fullCommandName === `${PROGRAM_NAME}-publish-variable-group-list`){ + data.data.length > 0 ? console.table( + data.data.map((group: any) => ({ + 'Group Id': group.id, + 'Group Name': group.name, + Created: group.createDate ? moment(group.createDate).calendar() : '-', + Updated: group.updateDate ? moment(group.updateDate).calendar() : '-', + })) + ) : console.log(' No publish variable group found'); + }else if(data.fullCommandName === `${PROGRAM_NAME}-publish-variable-group-view`){ + data.data.length > 0 ? console.table( + data.data.map((variable: any) => ({ + 'Key Name': variable.key, + 'Key Value': variable.isSecret ? '********' : variable.value, + })) + ) : console.log(' No publish variable found'); + }else if(data.fullCommandName ===`${PROGRAM_NAME}-publish-profile-settings-autopublish`){ + console.table( + [{ 'Id:': data.data.id, + 'Name:': data.data.name, + 'Created:': data.data.createDate ? moment(data.data.createDate).calendar() : '-', + 'Updated:': data.data.updateDate ? moment(data.data.updateDate).calendar() : '-', + 'Auto Publish': data.data.profileSettings.whenNewVersionRecieved ? 'Yes' : 'No', + }] + ) + }else if(data.fullCommandName ===`${PROGRAM_NAME}-publish-profile-version-mark-as-rc` || data.fullCommandName ===`${PROGRAM_NAME}-publish-profile-version-unmark-as-rc`){ + console.table( + [{ 'Id:': data.data.id, + 'Name:': data.data.name, + 'Unique Name': data.data.uniqueName, + 'Created:': data.data.createDate ? moment(data.data.createDate).calendar() : '-', + 'Updated:': data.data.updateDate ? moment(data.data.updateDate).calendar() : '-', + 'Release Candidate': data.data.releaseCandidate ? 'Yes' : 'No', + }] + ) + } + else { + console.log(data.data) + } + } }; export const commandWriter = (command: CommandTypes, data: any) => { diff --git a/src/main.ts b/src/main.ts index 831f559..dfa3cd4 100644 --- a/src/main.ts +++ b/src/main.ts @@ -7,9 +7,10 @@ import { getConsoleOutputType, setConsoleOutputType } from './config'; import { error } from 'console'; import { ProgramError } from './core/ProgramError'; import { PROGRAM_NAME } from './constant'; +import chalk from 'chalk'; const collectErrorMessageFromData = (data: any) => { - return data ? '\n↳ ' + Object.keys(data).map(key => data[key]).join('\n↳ '): ''; + return data ? '\n↳ ' + Object.keys(data).filter(k => k !== 'stackTrace').map(key => ' -' +key +': ' + data[key]).join('\n↳ '): ''; } const handleError = (error: any) => { @@ -22,12 +23,12 @@ const handleError = (error: any) => { } else { if (axios.isAxiosError(error)) { const data = error.response?.data as any; - console.error(`\n${error.message} ${error.response?.statusText}${collectErrorMessageFromData(data)}`); + console.error(`\n${chalk.red('✖')} ${error.message} ${chalk.red(error.response?.statusText)}${collectErrorMessageFromData(data)}`); if(error.response?.status === 401) { - console.error(`Run "${PROGRAM_NAME} login --help" command for more information.`); + console.error(`Run ${chalk.cyan(`"${PROGRAM_NAME} login --help"`)} command for more information.`); } } else if (error instanceof ProgramError) { - console.error(error.message); + console.error(chalk.red('✖'), error.message); } else { console.error(error); } diff --git a/src/services/index.ts b/src/services/index.ts index b21e9f1..28820e6 100644 --- a/src/services/index.ts +++ b/src/services/index.ts @@ -77,6 +77,13 @@ export async function getBuildsOfCommit(options: OptionsType<{ commitId: string return commits.data; } +export async function getActiveBuilds() { + const builds = await appcircleApi.get(`/build/v1/queue/my-dashboard?page=1&size=1000`, { + headers: getHeaders(), + }); + return builds.data; +} + export async function startBuild( options: OptionsType<{ profileId: string; branch?: string; workflow?: string; branchId?: string; workflowId?: string; commitId?: string }> ) { @@ -92,8 +99,8 @@ export async function startBuild( } if (!workflowId && options.workflow) { const workflowsRes = await getWorkflows({ profileId: options.profileId || '' }); - const workflowIndex = workflowsRes.workflows.findIndex((element: { [key: string]: any }) => element.workflowName === options.workflow); - workflowId = workflowsRes.workflows[workflowIndex].id; + const workflowIndex = workflowsRes.findIndex((element: { [key: string]: any }) => element.workflowName === options.workflow); + workflowId = workflowsRes[workflowIndex].id; } if (!commitId) { const allCommitsByBranchId = await getCommits({ branchId }); @@ -208,7 +215,7 @@ async function createFileEnvironmentVariable(options: OptionsType<{ key: string; console.log('options.filePath): ', options.filePath); form.append('Key', options.key); form.append('Value', path.basename(options.filePath)); - form.append('IsSecret', options.isSecret || 'false'); + form.append('IsSecret', 'false'); form.append('Binary', file); const uploadResponse = await appcircleApi.post(`build/v1/variable-groups/${options.variableGroupId}/variables/files`, form, { @@ -395,3 +402,4 @@ export const getUserInfo = async () => { }; export * from './organization'; +export * from './publish'; diff --git a/src/services/organization.ts b/src/services/organization.ts index 3ed86ab..62ca53c 100644 --- a/src/services/organization.ts +++ b/src/services/organization.ts @@ -8,7 +8,10 @@ const prepareRoles = async (roles: string[]) => { //Create roles map by groupId const willAssingRolesMap: Record = {}; - roles.forEach(r => { + roles.filter(r => r).forEach(r => { + if(!rolesMap[r]){ + throw new ProgramError(`Invalid role "${r}" \n↳ Assignable roles: ${Object.keys(rolesMap).join(', ')}`); + } willAssingRolesMap[rolesMap[r].groupId] = willAssingRolesMap[rolesMap[r].groupId] ||[]; willAssingRolesMap[rolesMap[r].groupId].push(rolesMap[r]); }); diff --git a/src/services/publish.ts b/src/services/publish.ts new file mode 100644 index 0000000..e699534 --- /dev/null +++ b/src/services/publish.ts @@ -0,0 +1,170 @@ + +import fs from 'fs'; +import FormData from 'form-data'; +import { ProgramError } from '../core/ProgramError'; +import { OptionsType, appcircleApi, getHeaders } from './api'; +import axios from 'axios'; + +export async function createPublishProfile(options: OptionsType<{ platform: string, name: string }>) { + const response = await appcircleApi.post( + `publish/v2/profiles/${options.platform}`, + { name: options.name }, + { headers: getHeaders() } + ); + return response.data; + } + +export async function deletePublishProfile(options: OptionsType<{ platform: string, publishProfileId: string }>) { + const response = await appcircleApi.delete( + `publish/v2/profiles/${options.platform}/${options.publishProfileId}`, + { headers: getHeaders() } + ); + return response.data; + } + export async function renamePublishProfile(options: OptionsType<{ platform: string, publishProfileId: string, name: string }>) { + const response = await appcircleApi.patch( + `publish/v2/profiles/${options.platform}/${options.publishProfileId}`, + { name : options.name}, + { headers: getHeaders() } + ); + return response.data; + } + + export async function getPublishProfiles(options: OptionsType<{ platform: string }>) { + const response = await appcircleApi.get( + `publish/v2/profiles/${options.platform}`, + { headers: getHeaders() } + ); + return response.data; + } + + export async function startExistingPublishFlow(options: OptionsType<{ publishProfileId: string, platform:string, publishId: string }>) { + const startResponse = await appcircleApi.post(`publish/v2/profiles/${options.platform}/${options.publishProfileId}/publish/${options.publishId}?action=restart`,"{}", + { + headers: getHeaders() + } + ); + return startResponse.data; + } + + export async function getPublishVariableGroups() { + + const response = await appcircleApi.get(`publish/v2/variable-groups`, + { + headers: getHeaders() + } + ); + + return response.data; + } + export async function getPublishVariableListByGroupId(options: OptionsType<{ publishVariableGroupId: string }>) { + + const response = await appcircleApi.get(`publish/v2/variable-groups/${options.publishVariableGroupId}`, + { + headers: getHeaders() + } + ); + + return response.data; + } + export async function setAppVersionReleaseCandidateStatus(options: OptionsType<{ publishProfileId: string, platform:string, appVersionId: string, releaseCandidate: boolean }>) { + + const response = await appcircleApi.patch(`publish/v2/profiles/${options.platform}/${options.publishProfileId}/app-versions/${options.appVersionId}?action=releaseCandidate`,{ + ReleaseCandidate: options.releaseCandidate + }, + { + headers: getHeaders() + } + ); + + return response.data; + } + + export async function switchPublishProfileAutoPublishSettings(options: OptionsType<{ publishProfileId: string, platform:string, appVersionId: string, enable: boolean, currentProfileSettings: any }>) { + const response = await appcircleApi.patch(`publish/v2/profiles/${options.platform}/${options.publishProfileId}`,{ + profileSettings: {...options.currentProfileSettings , whenNewVersionRecieved: options.enable } + }, + { + headers: getHeaders() + } + ); + + return response.data; + } + + export async function uploadAppVersion(options: OptionsType<{ app: string; publishProfileId: string, platform:string }>) { + const data = new FormData(); + data.append('File', fs.createReadStream(options.app)); + + const uploadResponse = await appcircleApi.post(`publish/v2/profiles/${options.platform}/${options.publishProfileId}/app-versions`, data, { + maxContentLength: Infinity, + maxBodyLength: Infinity, + headers: { + ...getHeaders(), + ...data.getHeaders(), + 'Content-Type': 'multipart/form-data;boundary=' + data.getBoundary(), + }, + }); + return uploadResponse.data; + } + export async function getAppVersions(options: OptionsType<{ publishProfileId: string, platform:string }>) { + const appVersions = await appcircleApi.get(`publish/v2/profiles/${options.platform}/${options.publishProfileId}/app-versions`, { + headers: getHeaders(), + }); + return appVersions.data; + } + export async function getPublishByAppVersion(options: OptionsType<{ publishProfileId: string, platform:string,appVersionId: string }>) { + const publish = await appcircleApi.get(`publish/v2/profiles/${options.platform}/${options.publishProfileId}/app-versions/${options.appVersionId}/publish`, { + headers: getHeaders(), + }); + return publish.data; + } + export async function deleteAppVersion(options: OptionsType<{ publishProfileId: string, platform:string, appVersionId: string }>) { + const appVersions = await appcircleApi.delete(`publish/v2/profiles/${options.platform}/${options.publishProfileId}/app-versions/${options.appVersionId}`, { + headers: getHeaders(), + }); + return appVersions.data; + } + export async function getAppVersionDownloadLink(options: OptionsType<{ publishProfileId: string, platform:string, appVersionId: string }>) { + + const downloadResponse = await appcircleApi.get(`publish/v2/profiles/${options.platform}/${options.publishProfileId}/app-versions/${options.appVersionId}?action=download`, + { + headers: getHeaders() + } + ); + + return downloadResponse.data; + } + export async function getPublishProfileDetailById(options: OptionsType<{ publishProfileId: string, platform:string }>) { + const response = await appcircleApi.get(`publish/v2/profiles/${options.platform}/${options.publishProfileId}`, + { + headers: getHeaders() + } + ); + return response.data; + } + + export async function downloadAppVersion(options: OptionsType<{ url: string, path: string }>) { + + + const downloadResponse = await axios.get(options.url, { + responseType: 'stream', + }); + return new Promise((resolve, reject) => { + const writer = fs.createWriteStream(options.path); + downloadResponse.data.pipe(writer); + let error: any = null; + writer.on('error', (err) => { + error = err; + writer.close(); + reject(err); + }); + writer.on('close', () => { + if (!error) { + resolve(true); + } + //no need to call the reject here, as it will have been called in the + //'error' stream; + }); + }); + } \ No newline at end of file