@commercetools-frontend/application-cli

Internal CLI to manage Merchant Center application deployments across various environments.

Usage no npm install needed!

<script type="module">
  import commercetoolsFrontendApplicationCli from 'https://cdn.skypack.dev/@commercetools-frontend/application-cli';
</script>

README

@commercetools-frontend/application-cli

This is a CLI used internally for Merchant Center applications. We do not provide any guarantees or support for the functionality. For normal Custom Applications development, the @commercetools-frontend/mc-scripts package should be good enough.

This CLI provides useful commands to work with Custom Applications that need to be deployed in a multi cloud environment.

Installation

$ npm install --save @commercetools-frontend/application-cli

Usage

Please make sure you have Node.js v14 or higher installed as this package uses native ES modules.

Command: compile-deployments

This command compiles the deployments for each of the given cloud environments.

yarn application-cli compile-deployments \
  --build-revision=<git_sha>

The environments to compile the deployments for must be specified in a google-storage-buckets cosmiconfig file for example google-storage-buckets.config.cjs with the bucket region mapping to multiple environments. For example:

module.exports = {
  'merchant-center-north-america': ['gcp-production-us'],
  'merchant-center-asia': ['gcp-production-au'],
};

The above configuration would compile for two environments in gcp-production-us and gcp-production-au each for their respective region. Yielding a /deployments folder for the application with the following structure:

- public
- gcp-production-us
   - application.html
   - upload-index.sh
- gcp-production-au
   - application.html
   - upload-index.sh
- upload-assets-merchant-center-north-america.sh
- upload-assets-merchant-center-asia.sh
  1. The upload-index.sh and upload-assets-<bucket>.sh scripts are generated pre-configured bash scripts for uploading the application.html and static assets to the respective storage bucket using gsutil.
  2. The public folder contains shared static assets for all environments.
  3. The application.html references the static assets from its respective environment's bucket

Depending on the environment you are deploying to, you need to:

  • Upload the static assets using the upload-assets-*.sh scripts to all respective buckets.
  • Upload the application.html using the upload-index.sh script. This is effectively the actual deployment of the application.

Additionally, when specifying the --dotenv-folder option, you can specify a dotenv file for each environment (for example .env.gcp-production-eu) and a single .env.production dotenv file. These files are then loaded when compiling the application for the respective environment.

Command: compile-menu

This command compiles the menu configuration defined in the application config into a menu.json file.

This is mostly useful for internal Merchant Center applications.

yarn application-cli compile-menu

Command: create-version

This command outputs a JSON string containing a list of deployed versions.

This is mostly useful for internal Merchant Center applications.

yarn application-cli create-version \
  --version-url=https://cdn/version.json
  --build-revision=<git_sha>