@commercetools-frontend/application-cli 0.0.0-FEC-212-react19-20250122084835
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +120 -0
- package/bin/cli.js +9 -0
- package/cli/dist/commercetools-frontend-application-cli-cli.cjs.d.ts +2 -0
- package/cli/dist/commercetools-frontend-application-cli-cli.cjs.dev.js +1390 -0
- package/cli/dist/commercetools-frontend-application-cli-cli.cjs.js +7 -0
- package/cli/dist/commercetools-frontend-application-cli-cli.cjs.prod.js +1390 -0
- package/cli/dist/commercetools-frontend-application-cli-cli.esm.js +1354 -0
- package/cli/package.json +4 -0
- package/dist/commercetools-frontend-application-cli.cjs.d.ts +2 -0
- package/dist/commercetools-frontend-application-cli.cjs.dev.js +18 -0
- package/dist/commercetools-frontend-application-cli.cjs.js +7 -0
- package/dist/commercetools-frontend-application-cli.cjs.prod.js +18 -0
- package/dist/commercetools-frontend-application-cli.esm.js +6 -0
- package/dist/declarations/src/cli.d.ts +2 -0
- package/dist/declarations/src/constants.d.ts +32 -0
- package/dist/declarations/src/index.d.ts +3 -0
- package/dist/declarations/src/storage-buckets-config.d.ts +13 -0
- package/dist/declarations/src/types.d.ts +145 -0
- package/dist/storage-buckets-config-30069ab7.cjs.dev.js +163 -0
- package/dist/storage-buckets-config-6c4043df.cjs.prod.js +163 -0
- package/dist/storage-buckets-config-fa564d15.esm.js +149 -0
- package/package.json +63 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2021 commercetools GmbH
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
# @commercetools-frontend/application-cli
|
|
2
|
+
|
|
3
|
+
> 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.
|
|
4
|
+
|
|
5
|
+
This CLI provides useful commands to work with Custom Applications that need to be deployed in a multi cloud environment.
|
|
6
|
+
|
|
7
|
+
## Installation
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
$ npm install --save @commercetools-frontend/application-cli
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## Usage
|
|
14
|
+
|
|
15
|
+
> Please make sure you have Node.js v14 or higher installed as this package uses native ES modules.
|
|
16
|
+
|
|
17
|
+
### Command: `compile-deployments`
|
|
18
|
+
|
|
19
|
+
This command compiles the deployments for each of the given cloud environments.
|
|
20
|
+
|
|
21
|
+
```bash
|
|
22
|
+
pnpm application-cli compile-deployments \
|
|
23
|
+
--build-revision=<git_sha>
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
The environments to compile the deployments for must be specified in a `storage-buckets` [cosmiconfig](https://github.com/davidtheclark/cosmiconfig) file for example `storage-buckets.config.cjs` with the bucket region mapping to multiple environments. For example:
|
|
27
|
+
|
|
28
|
+
```js
|
|
29
|
+
/**
|
|
30
|
+
* @type {import('@commercetools-frontend/application-cli').TStorageBucketsConfig}
|
|
31
|
+
*/
|
|
32
|
+
module.exports = {
|
|
33
|
+
'merchant-center-north-america': {
|
|
34
|
+
cloudEnvironment: 'ctp_production_gcp_us-central1_v1',
|
|
35
|
+
bucketEnvironment: 'ctp-gcp-production-us',
|
|
36
|
+
},
|
|
37
|
+
};
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
The above configuration would compile for one environment in `gcp-production-us` with its respective region. Yielding a `/deployments` folder for the application with the following structure:
|
|
41
|
+
|
|
42
|
+
```txt
|
|
43
|
+
- gs
|
|
44
|
+
- gcp-production-us
|
|
45
|
+
- application.html
|
|
46
|
+
- upload-index.sh
|
|
47
|
+
- upload-assets-merchant-center-north-america.sh
|
|
48
|
+
- upload-assets-merchant-center-asia.sh
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
1. The `gs` folder signals that these files will be uploaded to Google Storage which is the default storage provider
|
|
52
|
+
2. 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 `gcloud storage`.
|
|
53
|
+
3. The `public` folder contains shared static assets for all environments.
|
|
54
|
+
4. The `application.html` references the static assets from its respective environment's bucket
|
|
55
|
+
|
|
56
|
+
Depending on the environment you are deploying to, you need to:
|
|
57
|
+
|
|
58
|
+
- Upload the static assets using the `upload-assets-*.sh` scripts to all respective buckets.
|
|
59
|
+
- Upload the `application.html` using the `upload-index.sh` script. This is effectively the actual deployment of the application.
|
|
60
|
+
|
|
61
|
+
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.
|
|
62
|
+
|
|
63
|
+
The configuration also using a `defineBucketConfig` helper function to opt into defaults for bucket region and their environments:
|
|
64
|
+
|
|
65
|
+
```js
|
|
66
|
+
const {
|
|
67
|
+
defineStorageBucketsConfig,
|
|
68
|
+
} = require('@commercetools-frontend/application-cli');
|
|
69
|
+
|
|
70
|
+
module.exports = defineStorageBucketsConfig();
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
Given the configuration above upload scripts and `application.html` files would be generated for all default bucket regions and cloud environments. These can then be picked up by the CircleCI Orb for upload.
|
|
74
|
+
|
|
75
|
+
If you need to disable certain bucket regions or cloud environments, you can use the `options` parameter of `defineBucketConfig`:
|
|
76
|
+
|
|
77
|
+
You can disable existing bucket regions or environments:
|
|
78
|
+
|
|
79
|
+
```js
|
|
80
|
+
module.exports = defineStorageBucketsConfig({
|
|
81
|
+
options: {
|
|
82
|
+
disabledBucketRegions: ['merchant-center-north-america']
|
|
83
|
+
disabledEnvironments: ['vw_production_aws_eu-central-1_v1']
|
|
84
|
+
},
|
|
85
|
+
});
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
### Command: `compile-menu`
|
|
89
|
+
|
|
90
|
+
This command compiles the menu configuration [defined in the application config](https://docs.commercetools.com/custom-applications/api-reference/application-config#mainmenulink) into a `menu.json` file.
|
|
91
|
+
|
|
92
|
+
> This is mostly useful for internal Merchant Center applications.
|
|
93
|
+
|
|
94
|
+
```bash
|
|
95
|
+
pnpm application-cli compile-menu
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
### Command: `validate-menu`
|
|
99
|
+
|
|
100
|
+
This command validates the `menu.json` file generated by `compile-menu` command.
|
|
101
|
+
|
|
102
|
+
> This is mostly useful for internal Merchant Center applications.
|
|
103
|
+
|
|
104
|
+
```bash
|
|
105
|
+
pnpm application-cli validate-menu \
|
|
106
|
+
--input-file=<filepath> \
|
|
107
|
+
--navigation=top #option to switch between navbar (side) and appbar schema (top)
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
### Command: `create-version`
|
|
111
|
+
|
|
112
|
+
This command outputs a JSON string containing a list of deployed versions.
|
|
113
|
+
|
|
114
|
+
> This is mostly useful for internal Merchant Center applications.
|
|
115
|
+
|
|
116
|
+
```bash
|
|
117
|
+
pnpm application-cli create-version \
|
|
118
|
+
--version-url=https://cdn/version.json
|
|
119
|
+
--build-revision=<git_sha>
|
|
120
|
+
```
|
package/bin/cli.js
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
export * from "../../dist/declarations/src/cli.js";
|
|
2
|
+
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiY29tbWVyY2V0b29scy1mcm9udGVuZC1hcHBsaWNhdGlvbi1jbGktY2xpLmNqcy5kLnRzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vZGlzdC9kZWNsYXJhdGlvbnMvc3JjL2NsaS5kLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBIn0=
|