@commercetools-frontend/application-cli 1.0.2 → 1.1.1
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/package.json
CHANGED
|
@@ -1,15 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@commercetools-frontend/application-cli",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.1.1",
|
|
4
4
|
"description": "Internal CLI to manage Merchant Center application deployments across various environments.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"commercetools",
|
|
7
7
|
"cli",
|
|
8
8
|
"custom-application"
|
|
9
9
|
],
|
|
10
|
-
"publishConfig": {
|
|
11
|
-
"access": "public"
|
|
12
|
-
},
|
|
13
10
|
"license": "MIT",
|
|
14
11
|
"type": "module",
|
|
15
12
|
"bin": "./src/bin/cli.js",
|
|
@@ -20,23 +17,21 @@
|
|
|
20
17
|
"README.md"
|
|
21
18
|
],
|
|
22
19
|
"dependencies": {
|
|
23
|
-
"@commercetools-frontend/application-config": "21.
|
|
24
|
-
"@manypkg/find-root": "
|
|
25
|
-
"
|
|
26
|
-
"cosmiconfig": "8.0.0",
|
|
20
|
+
"@commercetools-frontend/application-config": "21.23.8",
|
|
21
|
+
"@manypkg/find-root": "2.1.0",
|
|
22
|
+
"cosmiconfig": "8.1.0",
|
|
27
23
|
"dotenv": "16.0.3",
|
|
28
24
|
"execa": "6.1.0",
|
|
29
25
|
"listr": "0.14.3",
|
|
30
26
|
"listr-verbose-renderer": "0.6.0",
|
|
31
|
-
"lodash.lowerfirst": "4.3.1",
|
|
32
27
|
"mri": "1.2.0",
|
|
33
|
-
"node-fetch": "2.6.
|
|
34
|
-
"prettier": "2.8.0",
|
|
35
|
-
"prompts": "2.4.2",
|
|
36
|
-
"rcfile": "1.0.3"
|
|
28
|
+
"node-fetch": "2.6.9"
|
|
37
29
|
},
|
|
38
30
|
"engines": {
|
|
39
31
|
"node": ">=14",
|
|
40
32
|
"npm": ">=6"
|
|
33
|
+
},
|
|
34
|
+
"publishConfig": {
|
|
35
|
+
"access": "public"
|
|
41
36
|
}
|
|
42
37
|
}
|
package/src/bin/cli.js
CHANGED
|
@@ -18,7 +18,9 @@ const cwd = process.cwd();
|
|
|
18
18
|
'application-index-upload-script-out-file': 'upload-index.sh',
|
|
19
19
|
'application-assets-upload-script-out-file': 'upload-assets.sh',
|
|
20
20
|
'application-index-out-file': 'application.html',
|
|
21
|
+
'skip-menu': false,
|
|
21
22
|
},
|
|
23
|
+
boolean: ['skip-menu'],
|
|
22
24
|
});
|
|
23
25
|
const cliCommands = cliFlags._;
|
|
24
26
|
|
|
@@ -46,6 +48,7 @@ Options:
|
|
|
46
48
|
--application-index-upload-script-out-file <path> (optional) The name of the the application index upload script file. Defaults to upload-index.sh.
|
|
47
49
|
--application-assets-upload-script-out-file <path> (optional) The name of the the assets upload script file. Defaults to upload-assets.sh.
|
|
48
50
|
--ci-assets-root-path <path> (optional) A replacement value for the scripts root path only used on CI (e.g. '--ci-assets-root-path=/root/') used in generated scripts.
|
|
51
|
+
--skip-menu (optional) If provided, it will skip uploading the 'menu.json'.
|
|
49
52
|
|
|
50
53
|
Command:
|
|
51
54
|
compile-menu Compile the menu links of an application into a 'menu.json'. This is only required for internal applications
|
|
@@ -84,6 +84,7 @@ async function compileApplicationAssets({ cliFlags, bucketRegion, paths }) {
|
|
|
84
84
|
applicationName: cliFlags['application-name'],
|
|
85
85
|
}),
|
|
86
86
|
assetsPath: paths.assetsPath,
|
|
87
|
+
skipMenu: cliFlags['skip-menu'],
|
|
87
88
|
});
|
|
88
89
|
const parsedApplicationAssetsUploadScriptFile = path.parse(
|
|
89
90
|
cliFlags['application-assets-upload-script-out-file']
|
|
@@ -224,12 +225,13 @@ async function command(cliFlags, cwd) {
|
|
|
224
225
|
assetsPath = applicationDirectory;
|
|
225
226
|
}
|
|
226
227
|
|
|
228
|
+
const monorepoRoot = findRootSync(cwd);
|
|
227
229
|
const paths = {
|
|
228
230
|
publicAssetsPath: resolveInApplication('public', cwd),
|
|
229
231
|
deploymentsPath: resolveInApplication('deployments', cwd),
|
|
230
232
|
dotenvPath:
|
|
231
233
|
cliFlags['dotenv-folder'] &&
|
|
232
|
-
path.join(
|
|
234
|
+
path.join(monorepoRoot.rootDir, cliFlags['dotenv-folder']),
|
|
233
235
|
assetsPath,
|
|
234
236
|
};
|
|
235
237
|
|
|
@@ -84,10 +84,10 @@ const mapApplicationMenuConfigToGraqhQLMenuJson = (config) => {
|
|
|
84
84
|
|
|
85
85
|
async function command(cliFlags, cwd) {
|
|
86
86
|
const applicationDirectory = getApplicationDirectory(cwd);
|
|
87
|
-
|
|
87
|
+
const monorepoRoot = findRootSync(cwd);
|
|
88
88
|
const dotenvPath =
|
|
89
89
|
cliFlags['dotenv-folder'] &&
|
|
90
|
-
path.join(
|
|
90
|
+
path.join(monorepoRoot.rootDir, cliFlags['dotenv-folder']);
|
|
91
91
|
|
|
92
92
|
const processEnv = {
|
|
93
93
|
...loadDotenvFiles({
|
|
@@ -1,4 +1,8 @@
|
|
|
1
|
-
function createApplicationAssetsUploadScript({
|
|
1
|
+
function createApplicationAssetsUploadScript({
|
|
2
|
+
bucketUrl,
|
|
3
|
+
assetsPath,
|
|
4
|
+
skipMenu,
|
|
5
|
+
}) {
|
|
2
6
|
const uploadScriptContent = `#!/usr/bin/env bash
|
|
3
7
|
|
|
4
8
|
set -e
|
|
@@ -13,6 +17,7 @@ set -e
|
|
|
13
17
|
# 5. The '-n' will skip uploading existing files and prevents them to
|
|
14
18
|
# be overwritten
|
|
15
19
|
echo "Uploading static assets to bucket ${bucketUrl}"
|
|
20
|
+
|
|
16
21
|
gsutil -m \\
|
|
17
22
|
-h "Cache-Control: public, max-age=31536000, no-transform" \\
|
|
18
23
|
cp -z js,css \\
|
|
@@ -20,31 +25,35 @@ gsutil -m \\
|
|
|
20
25
|
${assetsPath}/public/{*.css,*.js,*.js.map,*.png,*.html,robots.txt} \\
|
|
21
26
|
"${bucketUrl}"
|
|
22
27
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
# 'cache-control:
|
|
28
|
-
#
|
|
29
|
-
#
|
|
30
|
-
#
|
|
31
|
-
#
|
|
32
|
-
#
|
|
33
|
-
#
|
|
34
|
-
#
|
|
35
|
-
#
|
|
36
|
-
#
|
|
37
|
-
#
|
|
38
|
-
#
|
|
39
|
-
#
|
|
40
|
-
#
|
|
41
|
-
# *
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
28
|
+
if ${skipMenu}; then
|
|
29
|
+
echo "Skipping menu.json upload"
|
|
30
|
+
else
|
|
31
|
+
echo "Uploading menu.json to bucket ${bucketUrl}"
|
|
32
|
+
# NOTE: somehow the 'cache-control:private' doesn't work.
|
|
33
|
+
# I mean, the file is uploaded with the correct metadata but when I fetch
|
|
34
|
+
# the file the response contains the header
|
|
35
|
+
# 'cache-control: public, max-age=31536000, no-transform', even though the
|
|
36
|
+
# documentation clearly states that by marking the header as 'private' will
|
|
37
|
+
# disable the cache (for publicly readable objects).
|
|
38
|
+
# https://cloud.google.com/storage/docs/gsutil/addlhelp/WorkingWithObjectMetadata#cache-control
|
|
39
|
+
# However, I found out that, by requesting the file with any RANDOM
|
|
40
|
+
# query parameter, will instruct the storage to return a 'fresh' object
|
|
41
|
+
# (without any cache control).
|
|
42
|
+
# Unofficial source: https://stackoverflow.com/a/49052895
|
|
43
|
+
# This seems to be the 'easiest' option to 'disable' the cache for public
|
|
44
|
+
# objects. Other alternative approaces are:
|
|
45
|
+
# * make the object private with some simple ACL (private objects are not cached)
|
|
46
|
+
# * suffix the file name with e.g. the git SHA, so we have different files
|
|
47
|
+
# for each upload ('index.html.template-\${CIRCLE_SHA1}'). The server knows
|
|
48
|
+
# the git SHA on runtime and can get the correct file when it starts.
|
|
49
|
+
# * find out why the 'private' cache control does not work
|
|
50
|
+
gsutil \\
|
|
51
|
+
-h "Content-Type: application/json" \\
|
|
52
|
+
-h "Cache-Control: private, max-age=0, no-transform" \\
|
|
53
|
+
cp -z json \\
|
|
54
|
+
${assetsPath}/menu.json \\
|
|
55
|
+
${bucketUrl}
|
|
56
|
+
fi
|
|
48
57
|
`;
|
|
49
58
|
|
|
50
59
|
return uploadScriptContent;
|