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.
compile-deployments
Command: 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
- The
upload-index.sh
andupload-assets-<bucket>.sh
scripts are generated pre-configured bash scripts for uploading theapplication.html
and static assets to the respective storage bucket usinggsutil
. - The
public
folder contains shared static assets for all environments. - 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 theupload-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.
compile-menu
Command: 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
create-version
Command: 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>