@commercetools-frontend/application-cli 2.0.0 → 2.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/README.md +34 -29
- package/cli/dist/commercetools-frontend-application-cli-cli.cjs.dev.js +37 -41
- package/cli/dist/commercetools-frontend-application-cli-cli.cjs.prod.js +37 -41
- package/cli/dist/commercetools-frontend-application-cli-cli.esm.js +34 -40
- package/dist/commercetools-frontend-application-cli.cjs.dev.js +13 -0
- package/dist/commercetools-frontend-application-cli.cjs.prod.js +13 -0
- package/dist/commercetools-frontend-application-cli.esm.js +4 -1
- package/dist/declarations/src/constants.d.ts +34 -0
- package/dist/declarations/src/index.d.ts +2 -0
- package/dist/declarations/src/storage-buckets-config.d.ts +11 -0
- package/dist/declarations/src/types.d.ts +17 -16
- package/dist/storage-buckets-config-0b3808a3.cjs.prod.js +111 -0
- package/dist/storage-buckets-config-478b8585.cjs.dev.js +111 -0
- package/dist/storage-buckets-config-7845a091.esm.js +101 -0
- package/package.json +7 -6
package/README.md
CHANGED
|
@@ -30,28 +30,28 @@ The environments to compile the deployments for must be specified in a `storage-
|
|
|
30
30
|
* @type {import('@commercetools-frontend/application-cli').TStorageBucketsConfig}
|
|
31
31
|
*/
|
|
32
32
|
module.exports = {
|
|
33
|
-
'merchant-center-north-america':
|
|
34
|
-
|
|
33
|
+
'merchant-center-north-america': {
|
|
34
|
+
cloudEnvironment: 'ctp_production_gcp_us-central1_v1',
|
|
35
|
+
bucketEnvironment: 'ctp-gcp-production-us',
|
|
36
|
+
},
|
|
35
37
|
};
|
|
36
38
|
```
|
|
37
39
|
|
|
38
|
-
The above configuration would compile for
|
|
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:
|
|
39
41
|
|
|
40
42
|
```txt
|
|
41
|
-
-
|
|
42
|
-
- gcp-production-us
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
-
|
|
46
|
-
|
|
47
|
-
- upload-index.sh
|
|
48
|
-
- upload-assets-merchant-center-north-america.sh
|
|
49
|
-
- upload-assets-merchant-center-asia.sh
|
|
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
|
|
50
49
|
```
|
|
51
50
|
|
|
52
|
-
1. The `
|
|
53
|
-
2. The `
|
|
54
|
-
3. The `
|
|
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
55
|
|
|
56
56
|
Depending on the environment you are deploying to, you need to:
|
|
57
57
|
|
|
@@ -60,25 +60,30 @@ Depending on the environment you are deploying to, you need to:
|
|
|
60
60
|
|
|
61
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
62
|
|
|
63
|
-
The configuration also
|
|
63
|
+
The configuration also using a `defineBucketConfig` helper function to opt into defaults for bucket region and their environments:
|
|
64
64
|
|
|
65
65
|
```js
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
{
|
|
72
|
-
cloudEnvironment: 'ctp_production_aws_eu-central-1_v1',
|
|
73
|
-
bucketEnvironment: 'ctp-aws-production-fra',
|
|
74
|
-
},
|
|
75
|
-
],
|
|
76
|
-
};
|
|
66
|
+
const {
|
|
67
|
+
defineStorageBucketsConfig,
|
|
68
|
+
} = require('@commercetools-frontend/application-cli');
|
|
69
|
+
|
|
70
|
+
module.exports = defineStorageBucketsConfig();
|
|
77
71
|
```
|
|
78
72
|
|
|
79
|
-
Given the configuration above
|
|
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:
|
|
80
78
|
|
|
81
|
-
|
|
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
|
+
```
|
|
82
87
|
|
|
83
88
|
### Command: `compile-menu`
|
|
84
89
|
|
|
@@ -17,12 +17,13 @@ var _mapInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instan
|
|
|
17
17
|
var _Object$entries = require('@babel/runtime-corejs3/core-js-stable/object/entries');
|
|
18
18
|
var _Set = require('@babel/runtime-corejs3/core-js-stable/set');
|
|
19
19
|
var _flatInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/flat');
|
|
20
|
-
var fs = require('fs');
|
|
21
|
-
var path = require('path');
|
|
20
|
+
var fs = require('node:fs');
|
|
21
|
+
var path$1 = require('node:path');
|
|
22
22
|
var listr2 = require('listr2');
|
|
23
23
|
var execa = require('execa');
|
|
24
24
|
var cosmiconfig = require('cosmiconfig');
|
|
25
25
|
var findRoot = require('@manypkg/find-root');
|
|
26
|
+
var path = require('path');
|
|
26
27
|
var _possibleConstructorReturn = require('@babel/runtime-corejs3/helpers/possibleConstructorReturn');
|
|
27
28
|
var _get = require('@babel/runtime-corejs3/helpers/get');
|
|
28
29
|
var _getPrototypeOf = require('@babel/runtime-corejs3/helpers/getPrototypeOf');
|
|
@@ -30,13 +31,16 @@ var _inherits = require('@babel/runtime-corejs3/helpers/inherits');
|
|
|
30
31
|
var _classCallCheck = require('@babel/runtime-corejs3/helpers/classCallCheck');
|
|
31
32
|
var _createClass = require('@babel/runtime-corejs3/helpers/createClass');
|
|
32
33
|
var _Reflect$construct = require('@babel/runtime-corejs3/core-js-stable/reflect/construct');
|
|
34
|
+
var fs$1 = require('fs');
|
|
33
35
|
var dotenv = require('dotenv');
|
|
34
36
|
var _findInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/find');
|
|
35
37
|
var _JSON$stringify = require('@babel/runtime-corejs3/core-js-stable/json/stringify');
|
|
36
38
|
var applicationConfig = require('@commercetools-frontend/application-config');
|
|
37
39
|
var l10n = require('@commercetools-frontend/l10n');
|
|
40
|
+
var storageBucketsConfig = require('../../dist/storage-buckets-config-478b8585.cjs.dev.js');
|
|
38
41
|
var _sliceInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/slice');
|
|
39
42
|
var jsonschema = require('jsonschema');
|
|
43
|
+
require('ts-deepmerge');
|
|
40
44
|
|
|
41
45
|
function _interopDefault (e) { return e && e.__esModule ? e : { 'default': e }; }
|
|
42
46
|
|
|
@@ -53,9 +57,11 @@ var _Object$entries__default = /*#__PURE__*/_interopDefault(_Object$entries);
|
|
|
53
57
|
var _Set__default = /*#__PURE__*/_interopDefault(_Set);
|
|
54
58
|
var _flatInstanceProperty__default = /*#__PURE__*/_interopDefault(_flatInstanceProperty);
|
|
55
59
|
var fs__default = /*#__PURE__*/_interopDefault(fs);
|
|
56
|
-
var path__default = /*#__PURE__*/_interopDefault(path);
|
|
60
|
+
var path__default$1 = /*#__PURE__*/_interopDefault(path$1);
|
|
57
61
|
var execa__default = /*#__PURE__*/_interopDefault(execa);
|
|
62
|
+
var path__default = /*#__PURE__*/_interopDefault(path);
|
|
58
63
|
var _Reflect$construct__default = /*#__PURE__*/_interopDefault(_Reflect$construct);
|
|
64
|
+
var fs__default$1 = /*#__PURE__*/_interopDefault(fs$1);
|
|
59
65
|
var dotenv__default = /*#__PURE__*/_interopDefault(dotenv);
|
|
60
66
|
var _findInstanceProperty__default = /*#__PURE__*/_interopDefault(_findInstanceProperty);
|
|
61
67
|
var _JSON$stringify__default = /*#__PURE__*/_interopDefault(_JSON$stringify);
|
|
@@ -341,7 +347,7 @@ function loadDotenvFiles(_ref) {
|
|
|
341
347
|
}
|
|
342
348
|
|
|
343
349
|
// Check if the given path exists.
|
|
344
|
-
if (!fs__default["default"].existsSync(dotenvPath)) {
|
|
350
|
+
if (!fs__default$1["default"].existsSync(dotenvPath)) {
|
|
345
351
|
throw new Error(`The dotenv folder path does not exist: "${dotenvPath}".`);
|
|
346
352
|
}
|
|
347
353
|
|
|
@@ -369,14 +375,14 @@ function loadDotenvFiles(_ref) {
|
|
|
369
375
|
|
|
370
376
|
function ownKeys$2(e, r) { var t = _Object$keys__default["default"](e); if (_Object$getOwnPropertySymbols__default["default"]) { var o = _Object$getOwnPropertySymbols__default["default"](e); r && (o = _filterInstanceProperty__default["default"](o).call(o, function (r) { return _Object$getOwnPropertyDescriptor__default["default"](e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
371
377
|
function _objectSpread$2(e) { for (var r = 1; r < arguments.length; r++) { var _context4, _context5; var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? _forEachInstanceProperty__default["default"](_context4 = ownKeys$2(Object(t), !0)).call(_context4, function (r) { _defineProperty(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors__default["default"] ? _Object$defineProperties__default["default"](e, _Object$getOwnPropertyDescriptors__default["default"](t)) : _forEachInstanceProperty__default["default"](_context5 = ownKeys$2(Object(t))).call(_context5, function (r) { _Object$defineProperty__default["default"](e, r, _Object$getOwnPropertyDescriptor__default["default"](t, r)); }); } return e; }
|
|
372
|
-
const
|
|
378
|
+
const storageBucketConfigExplorer = cosmiconfig.cosmiconfig('storage-buckets', {
|
|
373
379
|
searchStrategy: 'project'
|
|
374
380
|
});
|
|
375
381
|
function writeUploadScriptFile(_ref) {
|
|
376
382
|
let fileName = _ref.fileName,
|
|
377
383
|
fileContent = _ref.fileContent,
|
|
378
384
|
filePath = _ref.filePath;
|
|
379
|
-
fs__default["default"].writeFileSync(path__default["default"].join(filePath, fileName), fileContent, {
|
|
385
|
+
fs__default["default"].writeFileSync(path__default$1["default"].join(filePath, fileName), fileContent, {
|
|
380
386
|
// Make the script executable
|
|
381
387
|
mode: 0o755,
|
|
382
388
|
encoding: 'utf8'
|
|
@@ -398,12 +404,12 @@ async function compileApplicationAssets(_ref2) {
|
|
|
398
404
|
assetsPath: paths.assetsPath,
|
|
399
405
|
skipMenu: cliFlags.skipMenu
|
|
400
406
|
});
|
|
401
|
-
const parsedApplicationAssetsUploadScriptFile = path__default["default"].parse(cliFlags.applicationAssetsUploadScriptOutFile);
|
|
407
|
+
const parsedApplicationAssetsUploadScriptFile = path__default$1["default"].parse(cliFlags.applicationAssetsUploadScriptOutFile);
|
|
402
408
|
const applicationAssetsUploadScriptFileName = `${parsedApplicationAssetsUploadScriptFile.name}-${bucketRegion}${parsedApplicationAssetsUploadScriptFile.ext}`;
|
|
403
409
|
writeUploadScriptFile({
|
|
404
410
|
fileName: applicationAssetsUploadScriptFileName,
|
|
405
411
|
fileContent: applicationAssetsUploadScriptContent,
|
|
406
|
-
filePath: path__default["default"].join(paths.deploymentsPath, storageProvider.getTag())
|
|
412
|
+
filePath: path__default$1["default"].join(paths.deploymentsPath, storageProvider.getTag())
|
|
407
413
|
});
|
|
408
414
|
}
|
|
409
415
|
async function compileEnvironmentApplicationIndexes(_ref3) {
|
|
@@ -414,7 +420,7 @@ async function compileEnvironmentApplicationIndexes(_ref3) {
|
|
|
414
420
|
bucketRegion = _ref3.bucketRegion,
|
|
415
421
|
cloudEnvironment = _ref3.cloudEnvironment,
|
|
416
422
|
bucketEnvironment = _ref3.bucketEnvironment;
|
|
417
|
-
const cloudEnvironmentDeploymentPath = path__default["default"].join(paths.deploymentsPath, storageProvider.getTag(), cloudEnvironment);
|
|
423
|
+
const cloudEnvironmentDeploymentPath = path__default$1["default"].join(paths.deploymentsPath, storageProvider.getTag(), cloudEnvironment);
|
|
418
424
|
// Ensure the folder exists
|
|
419
425
|
const createDeploymentsFolderResult = await execa__default["default"]('mkdir', ['-p', cloudEnvironmentDeploymentPath], {
|
|
420
426
|
encoding: 'utf8'
|
|
@@ -489,7 +495,7 @@ async function compileEnvironmentApplicationIndexes(_ref3) {
|
|
|
489
495
|
});
|
|
490
496
|
|
|
491
497
|
// Move the compiled `index.html` to the deployments folder of the related cloud environment.
|
|
492
|
-
const moveResult = await execa__default["default"]('mv', [path__default["default"].join(paths.publicAssetsPath, 'index.html'), path__default["default"].join(cloudEnvironmentDeploymentPath, cliFlags.applicationIndexOutFile)]);
|
|
498
|
+
const moveResult = await execa__default["default"]('mv', [path__default$1["default"].join(paths.publicAssetsPath, 'index.html'), path__default$1["default"].join(cloudEnvironmentDeploymentPath, cliFlags.applicationIndexOutFile)]);
|
|
493
499
|
if (moveResult.failed) {
|
|
494
500
|
throw new Error(moveResult.stderr);
|
|
495
501
|
}
|
|
@@ -499,9 +505,9 @@ async function command$3(cliFlags, cwd) {
|
|
|
499
505
|
let cloudEnvironmentsGroupedByBucketRegions;
|
|
500
506
|
try {
|
|
501
507
|
// This is the list of the supported cloud environments and their related bucket location.
|
|
502
|
-
cloudEnvironmentsGroupedByBucketRegions = await
|
|
508
|
+
cloudEnvironmentsGroupedByBucketRegions = await storageBucketConfigExplorer.search();
|
|
503
509
|
} catch (e) {
|
|
504
|
-
throw new Error('Failed
|
|
510
|
+
throw new Error('Failed to load a storage bucket configuration. Create a cosmiconfig for `storage-buckets` for example `storage-buckets.config.cjs`.');
|
|
505
511
|
}
|
|
506
512
|
if (!cloudEnvironmentsGroupedByBucketRegions) {
|
|
507
513
|
throw new Error('Failed loading a storage bucket configuration');
|
|
@@ -517,7 +523,7 @@ async function command$3(cliFlags, cwd) {
|
|
|
517
523
|
const paths = {
|
|
518
524
|
publicAssetsPath: resolveInApplication('public', cwd),
|
|
519
525
|
deploymentsPath: resolveInApplication('deployments', cwd),
|
|
520
|
-
dotenvPath: cliFlags.dotenvFolder && path__default["default"].join(monorepoRoot.rootDir, cliFlags.dotenvFolder),
|
|
526
|
+
dotenvPath: cliFlags.dotenvFolder && path__default$1["default"].join(monorepoRoot.rootDir, cliFlags.dotenvFolder),
|
|
521
527
|
assetsPath
|
|
522
528
|
};
|
|
523
529
|
const defaultStorageProviders = ['gs'];
|
|
@@ -541,7 +547,7 @@ async function command$3(cliFlags, cwd) {
|
|
|
541
547
|
cliFlags,
|
|
542
548
|
storageProvider,
|
|
543
549
|
uploadScriptsGenerator,
|
|
544
|
-
bucketRegion,
|
|
550
|
+
bucketRegion: bucketRegion,
|
|
545
551
|
paths
|
|
546
552
|
})
|
|
547
553
|
};
|
|
@@ -565,7 +571,7 @@ async function command$3(cliFlags, cwd) {
|
|
|
565
571
|
storageProvider,
|
|
566
572
|
uploadScriptsGenerator,
|
|
567
573
|
paths,
|
|
568
|
-
bucketRegion,
|
|
574
|
+
bucketRegion: bucketRegion,
|
|
569
575
|
cloudEnvironment,
|
|
570
576
|
bucketEnvironment
|
|
571
577
|
});
|
|
@@ -664,28 +670,17 @@ const mapApplicationMenuConfigToGraqhQLMenuJson = config => {
|
|
|
664
670
|
shouldRenderDivider: menuLinks.shouldRenderDivider ?? false
|
|
665
671
|
};
|
|
666
672
|
};
|
|
667
|
-
|
|
668
|
-
// During the migration to the Naming Convention Record for Cloud Environments
|
|
669
|
-
// we need to gracefully use the non-compliant and compliant environment names
|
|
670
|
-
// for staging to avoid a breaking release of the CLI.
|
|
671
|
-
const doesCloudEnvironmentExist = _ref => {
|
|
672
|
-
let dotenvPath = _ref.dotenvPath,
|
|
673
|
-
cloudEnvironment = _ref.cloudEnvironment;
|
|
674
|
-
return fs__default["default"].existsSync(path__default["default"].join(dotenvPath ?? '', cloudEnvironment));
|
|
675
|
-
};
|
|
676
673
|
async function command$2(cliFlags, cwd) {
|
|
677
674
|
const applicationDirectory = getApplicationDirectory(cwd);
|
|
678
675
|
const monorepoRoot = findRoot.findRootSync(cwd);
|
|
679
676
|
const dotenvPath = cliFlags.dotenvFolder && path__default["default"].join(monorepoRoot.rootDir, cliFlags.dotenvFolder);
|
|
677
|
+
|
|
678
|
+
// The env itself is not important for the menu. However, the application config
|
|
679
|
+
// uses environment placeholders and therefore we need to provide the variables for it.
|
|
680
|
+
const cloudEnvironment = storageBucketsConfig.clusterContexts['ctp_staging_gcp_europe-west1_v1'];
|
|
680
681
|
const processEnv = _objectSpread$1(_objectSpread$1({}, loadDotenvFiles({
|
|
681
682
|
dotenvPath,
|
|
682
|
-
|
|
683
|
-
// uses environment placeholders and therefore we need to provide the variables for it.
|
|
684
|
-
// TODO: Remove after all repositories migrated to NCR.
|
|
685
|
-
cloudEnvironment: doesCloudEnvironmentExist({
|
|
686
|
-
dotenvPath,
|
|
687
|
-
cloudEnvironment: '.env.ctp_staging_gcp_europe-west1_v1'
|
|
688
|
-
}) ? 'ctp_staging_gcp_europe-west1_v1' : 'ctp-gcp-staging'
|
|
683
|
+
cloudEnvironment
|
|
689
684
|
})), {}, {
|
|
690
685
|
// Again, make sure that the environment is "development", otherwise
|
|
691
686
|
// the menu config won't be available.
|
|
@@ -701,7 +696,7 @@ async function command$2(cliFlags, cwd) {
|
|
|
701
696
|
});
|
|
702
697
|
const applicationMenu = mapApplicationMenuConfigToGraqhQLMenuJson(applicationRuntimeConfig);
|
|
703
698
|
const formattedJson = _JSON$stringify__default["default"](applicationMenu, null, 2);
|
|
704
|
-
fs__default["default"].writeFileSync(path__default["default"].join(applicationDirectory, 'menu.json'), formattedJson, {
|
|
699
|
+
fs__default$1["default"].writeFileSync(path__default["default"].join(applicationDirectory, 'menu.json'), formattedJson, {
|
|
705
700
|
encoding: 'utf8'
|
|
706
701
|
});
|
|
707
702
|
}
|
|
@@ -734,7 +729,7 @@ async function command$1(cliFlags) {
|
|
|
734
729
|
// Logging to stdout which is from where it will be picked
|
|
735
730
|
// up by the caller (a bash script).
|
|
736
731
|
if (cliFlags.outFile) {
|
|
737
|
-
fs__default["default"].writeFileSync(cliFlags.outFile, formattedJson, {
|
|
732
|
+
fs__default$1["default"].writeFileSync(cliFlags.outFile, formattedJson, {
|
|
738
733
|
encoding: 'utf8'
|
|
739
734
|
});
|
|
740
735
|
} else {
|
|
@@ -855,14 +850,14 @@ async function command(cliFlags) {
|
|
|
855
850
|
const menuJsonPath = cliFlags.inputFile;
|
|
856
851
|
const isAppbarMenu = cliFlags.navigation === 'top';
|
|
857
852
|
if (!menuJsonPath) throw new Error(`--input-file cannot be empty. please provide the path of compiled menu.json`);
|
|
858
|
-
if (!fs__default["default"].existsSync(menuJsonPath)) throw new Error(`The menu.json file doesn't exist: ${menuJsonPath}`);
|
|
859
|
-
const menuJson = fs__default["default"].readFileSync(menuJsonPath, 'utf-8');
|
|
853
|
+
if (!fs__default$1["default"].existsSync(menuJsonPath)) throw new Error(`The menu.json file doesn't exist: ${menuJsonPath}`);
|
|
854
|
+
const menuJson = fs__default$1["default"].readFileSync(menuJsonPath, 'utf-8');
|
|
860
855
|
return validateMenu(JSON.parse(menuJson), isAppbarMenu ? appbarMenuSchema : navbarMenuSchema);
|
|
861
856
|
}
|
|
862
857
|
|
|
863
858
|
var pkgJson = {
|
|
864
859
|
name: "@commercetools-frontend/application-cli",
|
|
865
|
-
version: "2.
|
|
860
|
+
version: "2.1.1",
|
|
866
861
|
description: "Internal CLI to manage Merchant Center application deployments across various environments.",
|
|
867
862
|
keywords: [
|
|
868
863
|
"commercetools",
|
|
@@ -885,11 +880,11 @@ var pkgJson = {
|
|
|
885
880
|
},
|
|
886
881
|
dependencies: {
|
|
887
882
|
"@babel/core": "^7.22.11",
|
|
888
|
-
"@babel/runtime": "^7.21.0",
|
|
889
883
|
"@babel/runtime-corejs3": "^7.21.0",
|
|
890
|
-
"@
|
|
891
|
-
"@commercetools-frontend/
|
|
892
|
-
"@commercetools-frontend/
|
|
884
|
+
"@babel/runtime": "^7.21.0",
|
|
885
|
+
"@commercetools-frontend/application-config": "22.17.0",
|
|
886
|
+
"@commercetools-frontend/constants": "22.17.0",
|
|
887
|
+
"@commercetools-frontend/l10n": "22.17.0",
|
|
893
888
|
"@manypkg/find-root": "2.2.1",
|
|
894
889
|
cac: "^6.7.14",
|
|
895
890
|
cosmiconfig: "9.0.0",
|
|
@@ -897,7 +892,8 @@ var pkgJson = {
|
|
|
897
892
|
execa: "5.1.1",
|
|
898
893
|
jsonschema: "^1.4.1",
|
|
899
894
|
listr2: "8.0.1",
|
|
900
|
-
"node-fetch": "2.7.0"
|
|
895
|
+
"node-fetch": "2.7.0",
|
|
896
|
+
"ts-deepmerge": "7.0.0"
|
|
901
897
|
},
|
|
902
898
|
devDependencies: {
|
|
903
899
|
"@tsconfig/node20": "20.1.2",
|
|
@@ -17,12 +17,13 @@ var _mapInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instan
|
|
|
17
17
|
var _Object$entries = require('@babel/runtime-corejs3/core-js-stable/object/entries');
|
|
18
18
|
var _Set = require('@babel/runtime-corejs3/core-js-stable/set');
|
|
19
19
|
var _flatInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/flat');
|
|
20
|
-
var fs = require('fs');
|
|
21
|
-
var path = require('path');
|
|
20
|
+
var fs = require('node:fs');
|
|
21
|
+
var path$1 = require('node:path');
|
|
22
22
|
var listr2 = require('listr2');
|
|
23
23
|
var execa = require('execa');
|
|
24
24
|
var cosmiconfig = require('cosmiconfig');
|
|
25
25
|
var findRoot = require('@manypkg/find-root');
|
|
26
|
+
var path = require('path');
|
|
26
27
|
var _possibleConstructorReturn = require('@babel/runtime-corejs3/helpers/possibleConstructorReturn');
|
|
27
28
|
var _get = require('@babel/runtime-corejs3/helpers/get');
|
|
28
29
|
var _getPrototypeOf = require('@babel/runtime-corejs3/helpers/getPrototypeOf');
|
|
@@ -30,13 +31,16 @@ var _inherits = require('@babel/runtime-corejs3/helpers/inherits');
|
|
|
30
31
|
var _classCallCheck = require('@babel/runtime-corejs3/helpers/classCallCheck');
|
|
31
32
|
var _createClass = require('@babel/runtime-corejs3/helpers/createClass');
|
|
32
33
|
var _Reflect$construct = require('@babel/runtime-corejs3/core-js-stable/reflect/construct');
|
|
34
|
+
var fs$1 = require('fs');
|
|
33
35
|
var dotenv = require('dotenv');
|
|
34
36
|
var _findInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/find');
|
|
35
37
|
var _JSON$stringify = require('@babel/runtime-corejs3/core-js-stable/json/stringify');
|
|
36
38
|
var applicationConfig = require('@commercetools-frontend/application-config');
|
|
37
39
|
var l10n = require('@commercetools-frontend/l10n');
|
|
40
|
+
var storageBucketsConfig = require('../../dist/storage-buckets-config-0b3808a3.cjs.prod.js');
|
|
38
41
|
var _sliceInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/slice');
|
|
39
42
|
var jsonschema = require('jsonschema');
|
|
43
|
+
require('ts-deepmerge');
|
|
40
44
|
|
|
41
45
|
function _interopDefault (e) { return e && e.__esModule ? e : { 'default': e }; }
|
|
42
46
|
|
|
@@ -53,9 +57,11 @@ var _Object$entries__default = /*#__PURE__*/_interopDefault(_Object$entries);
|
|
|
53
57
|
var _Set__default = /*#__PURE__*/_interopDefault(_Set);
|
|
54
58
|
var _flatInstanceProperty__default = /*#__PURE__*/_interopDefault(_flatInstanceProperty);
|
|
55
59
|
var fs__default = /*#__PURE__*/_interopDefault(fs);
|
|
56
|
-
var path__default = /*#__PURE__*/_interopDefault(path);
|
|
60
|
+
var path__default$1 = /*#__PURE__*/_interopDefault(path$1);
|
|
57
61
|
var execa__default = /*#__PURE__*/_interopDefault(execa);
|
|
62
|
+
var path__default = /*#__PURE__*/_interopDefault(path);
|
|
58
63
|
var _Reflect$construct__default = /*#__PURE__*/_interopDefault(_Reflect$construct);
|
|
64
|
+
var fs__default$1 = /*#__PURE__*/_interopDefault(fs$1);
|
|
59
65
|
var dotenv__default = /*#__PURE__*/_interopDefault(dotenv);
|
|
60
66
|
var _findInstanceProperty__default = /*#__PURE__*/_interopDefault(_findInstanceProperty);
|
|
61
67
|
var _JSON$stringify__default = /*#__PURE__*/_interopDefault(_JSON$stringify);
|
|
@@ -341,7 +347,7 @@ function loadDotenvFiles(_ref) {
|
|
|
341
347
|
}
|
|
342
348
|
|
|
343
349
|
// Check if the given path exists.
|
|
344
|
-
if (!fs__default["default"].existsSync(dotenvPath)) {
|
|
350
|
+
if (!fs__default$1["default"].existsSync(dotenvPath)) {
|
|
345
351
|
throw new Error(`The dotenv folder path does not exist: "${dotenvPath}".`);
|
|
346
352
|
}
|
|
347
353
|
|
|
@@ -369,14 +375,14 @@ function loadDotenvFiles(_ref) {
|
|
|
369
375
|
|
|
370
376
|
function ownKeys$2(e, r) { var t = _Object$keys__default["default"](e); if (_Object$getOwnPropertySymbols__default["default"]) { var o = _Object$getOwnPropertySymbols__default["default"](e); r && (o = _filterInstanceProperty__default["default"](o).call(o, function (r) { return _Object$getOwnPropertyDescriptor__default["default"](e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
371
377
|
function _objectSpread$2(e) { for (var r = 1; r < arguments.length; r++) { var _context4, _context5; var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? _forEachInstanceProperty__default["default"](_context4 = ownKeys$2(Object(t), !0)).call(_context4, function (r) { _defineProperty(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors__default["default"] ? _Object$defineProperties__default["default"](e, _Object$getOwnPropertyDescriptors__default["default"](t)) : _forEachInstanceProperty__default["default"](_context5 = ownKeys$2(Object(t))).call(_context5, function (r) { _Object$defineProperty__default["default"](e, r, _Object$getOwnPropertyDescriptor__default["default"](t, r)); }); } return e; }
|
|
372
|
-
const
|
|
378
|
+
const storageBucketConfigExplorer = cosmiconfig.cosmiconfig('storage-buckets', {
|
|
373
379
|
searchStrategy: 'project'
|
|
374
380
|
});
|
|
375
381
|
function writeUploadScriptFile(_ref) {
|
|
376
382
|
let fileName = _ref.fileName,
|
|
377
383
|
fileContent = _ref.fileContent,
|
|
378
384
|
filePath = _ref.filePath;
|
|
379
|
-
fs__default["default"].writeFileSync(path__default["default"].join(filePath, fileName), fileContent, {
|
|
385
|
+
fs__default["default"].writeFileSync(path__default$1["default"].join(filePath, fileName), fileContent, {
|
|
380
386
|
// Make the script executable
|
|
381
387
|
mode: 0o755,
|
|
382
388
|
encoding: 'utf8'
|
|
@@ -398,12 +404,12 @@ async function compileApplicationAssets(_ref2) {
|
|
|
398
404
|
assetsPath: paths.assetsPath,
|
|
399
405
|
skipMenu: cliFlags.skipMenu
|
|
400
406
|
});
|
|
401
|
-
const parsedApplicationAssetsUploadScriptFile = path__default["default"].parse(cliFlags.applicationAssetsUploadScriptOutFile);
|
|
407
|
+
const parsedApplicationAssetsUploadScriptFile = path__default$1["default"].parse(cliFlags.applicationAssetsUploadScriptOutFile);
|
|
402
408
|
const applicationAssetsUploadScriptFileName = `${parsedApplicationAssetsUploadScriptFile.name}-${bucketRegion}${parsedApplicationAssetsUploadScriptFile.ext}`;
|
|
403
409
|
writeUploadScriptFile({
|
|
404
410
|
fileName: applicationAssetsUploadScriptFileName,
|
|
405
411
|
fileContent: applicationAssetsUploadScriptContent,
|
|
406
|
-
filePath: path__default["default"].join(paths.deploymentsPath, storageProvider.getTag())
|
|
412
|
+
filePath: path__default$1["default"].join(paths.deploymentsPath, storageProvider.getTag())
|
|
407
413
|
});
|
|
408
414
|
}
|
|
409
415
|
async function compileEnvironmentApplicationIndexes(_ref3) {
|
|
@@ -414,7 +420,7 @@ async function compileEnvironmentApplicationIndexes(_ref3) {
|
|
|
414
420
|
bucketRegion = _ref3.bucketRegion,
|
|
415
421
|
cloudEnvironment = _ref3.cloudEnvironment,
|
|
416
422
|
bucketEnvironment = _ref3.bucketEnvironment;
|
|
417
|
-
const cloudEnvironmentDeploymentPath = path__default["default"].join(paths.deploymentsPath, storageProvider.getTag(), cloudEnvironment);
|
|
423
|
+
const cloudEnvironmentDeploymentPath = path__default$1["default"].join(paths.deploymentsPath, storageProvider.getTag(), cloudEnvironment);
|
|
418
424
|
// Ensure the folder exists
|
|
419
425
|
const createDeploymentsFolderResult = await execa__default["default"]('mkdir', ['-p', cloudEnvironmentDeploymentPath], {
|
|
420
426
|
encoding: 'utf8'
|
|
@@ -489,7 +495,7 @@ async function compileEnvironmentApplicationIndexes(_ref3) {
|
|
|
489
495
|
});
|
|
490
496
|
|
|
491
497
|
// Move the compiled `index.html` to the deployments folder of the related cloud environment.
|
|
492
|
-
const moveResult = await execa__default["default"]('mv', [path__default["default"].join(paths.publicAssetsPath, 'index.html'), path__default["default"].join(cloudEnvironmentDeploymentPath, cliFlags.applicationIndexOutFile)]);
|
|
498
|
+
const moveResult = await execa__default["default"]('mv', [path__default$1["default"].join(paths.publicAssetsPath, 'index.html'), path__default$1["default"].join(cloudEnvironmentDeploymentPath, cliFlags.applicationIndexOutFile)]);
|
|
493
499
|
if (moveResult.failed) {
|
|
494
500
|
throw new Error(moveResult.stderr);
|
|
495
501
|
}
|
|
@@ -499,9 +505,9 @@ async function command$3(cliFlags, cwd) {
|
|
|
499
505
|
let cloudEnvironmentsGroupedByBucketRegions;
|
|
500
506
|
try {
|
|
501
507
|
// This is the list of the supported cloud environments and their related bucket location.
|
|
502
|
-
cloudEnvironmentsGroupedByBucketRegions = await
|
|
508
|
+
cloudEnvironmentsGroupedByBucketRegions = await storageBucketConfigExplorer.search();
|
|
503
509
|
} catch (e) {
|
|
504
|
-
throw new Error('Failed
|
|
510
|
+
throw new Error('Failed to load a storage bucket configuration. Create a cosmiconfig for `storage-buckets` for example `storage-buckets.config.cjs`.');
|
|
505
511
|
}
|
|
506
512
|
if (!cloudEnvironmentsGroupedByBucketRegions) {
|
|
507
513
|
throw new Error('Failed loading a storage bucket configuration');
|
|
@@ -517,7 +523,7 @@ async function command$3(cliFlags, cwd) {
|
|
|
517
523
|
const paths = {
|
|
518
524
|
publicAssetsPath: resolveInApplication('public', cwd),
|
|
519
525
|
deploymentsPath: resolveInApplication('deployments', cwd),
|
|
520
|
-
dotenvPath: cliFlags.dotenvFolder && path__default["default"].join(monorepoRoot.rootDir, cliFlags.dotenvFolder),
|
|
526
|
+
dotenvPath: cliFlags.dotenvFolder && path__default$1["default"].join(monorepoRoot.rootDir, cliFlags.dotenvFolder),
|
|
521
527
|
assetsPath
|
|
522
528
|
};
|
|
523
529
|
const defaultStorageProviders = ['gs'];
|
|
@@ -541,7 +547,7 @@ async function command$3(cliFlags, cwd) {
|
|
|
541
547
|
cliFlags,
|
|
542
548
|
storageProvider,
|
|
543
549
|
uploadScriptsGenerator,
|
|
544
|
-
bucketRegion,
|
|
550
|
+
bucketRegion: bucketRegion,
|
|
545
551
|
paths
|
|
546
552
|
})
|
|
547
553
|
};
|
|
@@ -565,7 +571,7 @@ async function command$3(cliFlags, cwd) {
|
|
|
565
571
|
storageProvider,
|
|
566
572
|
uploadScriptsGenerator,
|
|
567
573
|
paths,
|
|
568
|
-
bucketRegion,
|
|
574
|
+
bucketRegion: bucketRegion,
|
|
569
575
|
cloudEnvironment,
|
|
570
576
|
bucketEnvironment
|
|
571
577
|
});
|
|
@@ -664,28 +670,17 @@ const mapApplicationMenuConfigToGraqhQLMenuJson = config => {
|
|
|
664
670
|
shouldRenderDivider: menuLinks.shouldRenderDivider ?? false
|
|
665
671
|
};
|
|
666
672
|
};
|
|
667
|
-
|
|
668
|
-
// During the migration to the Naming Convention Record for Cloud Environments
|
|
669
|
-
// we need to gracefully use the non-compliant and compliant environment names
|
|
670
|
-
// for staging to avoid a breaking release of the CLI.
|
|
671
|
-
const doesCloudEnvironmentExist = _ref => {
|
|
672
|
-
let dotenvPath = _ref.dotenvPath,
|
|
673
|
-
cloudEnvironment = _ref.cloudEnvironment;
|
|
674
|
-
return fs__default["default"].existsSync(path__default["default"].join(dotenvPath ?? '', cloudEnvironment));
|
|
675
|
-
};
|
|
676
673
|
async function command$2(cliFlags, cwd) {
|
|
677
674
|
const applicationDirectory = getApplicationDirectory(cwd);
|
|
678
675
|
const monorepoRoot = findRoot.findRootSync(cwd);
|
|
679
676
|
const dotenvPath = cliFlags.dotenvFolder && path__default["default"].join(monorepoRoot.rootDir, cliFlags.dotenvFolder);
|
|
677
|
+
|
|
678
|
+
// The env itself is not important for the menu. However, the application config
|
|
679
|
+
// uses environment placeholders and therefore we need to provide the variables for it.
|
|
680
|
+
const cloudEnvironment = storageBucketsConfig.clusterContexts['ctp_staging_gcp_europe-west1_v1'];
|
|
680
681
|
const processEnv = _objectSpread$1(_objectSpread$1({}, loadDotenvFiles({
|
|
681
682
|
dotenvPath,
|
|
682
|
-
|
|
683
|
-
// uses environment placeholders and therefore we need to provide the variables for it.
|
|
684
|
-
// TODO: Remove after all repositories migrated to NCR.
|
|
685
|
-
cloudEnvironment: doesCloudEnvironmentExist({
|
|
686
|
-
dotenvPath,
|
|
687
|
-
cloudEnvironment: '.env.ctp_staging_gcp_europe-west1_v1'
|
|
688
|
-
}) ? 'ctp_staging_gcp_europe-west1_v1' : 'ctp-gcp-staging'
|
|
683
|
+
cloudEnvironment
|
|
689
684
|
})), {}, {
|
|
690
685
|
// Again, make sure that the environment is "development", otherwise
|
|
691
686
|
// the menu config won't be available.
|
|
@@ -701,7 +696,7 @@ async function command$2(cliFlags, cwd) {
|
|
|
701
696
|
});
|
|
702
697
|
const applicationMenu = mapApplicationMenuConfigToGraqhQLMenuJson(applicationRuntimeConfig);
|
|
703
698
|
const formattedJson = _JSON$stringify__default["default"](applicationMenu, null, 2);
|
|
704
|
-
fs__default["default"].writeFileSync(path__default["default"].join(applicationDirectory, 'menu.json'), formattedJson, {
|
|
699
|
+
fs__default$1["default"].writeFileSync(path__default["default"].join(applicationDirectory, 'menu.json'), formattedJson, {
|
|
705
700
|
encoding: 'utf8'
|
|
706
701
|
});
|
|
707
702
|
}
|
|
@@ -734,7 +729,7 @@ async function command$1(cliFlags) {
|
|
|
734
729
|
// Logging to stdout which is from where it will be picked
|
|
735
730
|
// up by the caller (a bash script).
|
|
736
731
|
if (cliFlags.outFile) {
|
|
737
|
-
fs__default["default"].writeFileSync(cliFlags.outFile, formattedJson, {
|
|
732
|
+
fs__default$1["default"].writeFileSync(cliFlags.outFile, formattedJson, {
|
|
738
733
|
encoding: 'utf8'
|
|
739
734
|
});
|
|
740
735
|
} else {
|
|
@@ -855,14 +850,14 @@ async function command(cliFlags) {
|
|
|
855
850
|
const menuJsonPath = cliFlags.inputFile;
|
|
856
851
|
const isAppbarMenu = cliFlags.navigation === 'top';
|
|
857
852
|
if (!menuJsonPath) throw new Error(`--input-file cannot be empty. please provide the path of compiled menu.json`);
|
|
858
|
-
if (!fs__default["default"].existsSync(menuJsonPath)) throw new Error(`The menu.json file doesn't exist: ${menuJsonPath}`);
|
|
859
|
-
const menuJson = fs__default["default"].readFileSync(menuJsonPath, 'utf-8');
|
|
853
|
+
if (!fs__default$1["default"].existsSync(menuJsonPath)) throw new Error(`The menu.json file doesn't exist: ${menuJsonPath}`);
|
|
854
|
+
const menuJson = fs__default$1["default"].readFileSync(menuJsonPath, 'utf-8');
|
|
860
855
|
return validateMenu(JSON.parse(menuJson), isAppbarMenu ? appbarMenuSchema : navbarMenuSchema);
|
|
861
856
|
}
|
|
862
857
|
|
|
863
858
|
var pkgJson = {
|
|
864
859
|
name: "@commercetools-frontend/application-cli",
|
|
865
|
-
version: "2.
|
|
860
|
+
version: "2.1.1",
|
|
866
861
|
description: "Internal CLI to manage Merchant Center application deployments across various environments.",
|
|
867
862
|
keywords: [
|
|
868
863
|
"commercetools",
|
|
@@ -885,11 +880,11 @@ var pkgJson = {
|
|
|
885
880
|
},
|
|
886
881
|
dependencies: {
|
|
887
882
|
"@babel/core": "^7.22.11",
|
|
888
|
-
"@babel/runtime": "^7.21.0",
|
|
889
883
|
"@babel/runtime-corejs3": "^7.21.0",
|
|
890
|
-
"@
|
|
891
|
-
"@commercetools-frontend/
|
|
892
|
-
"@commercetools-frontend/
|
|
884
|
+
"@babel/runtime": "^7.21.0",
|
|
885
|
+
"@commercetools-frontend/application-config": "22.17.0",
|
|
886
|
+
"@commercetools-frontend/constants": "22.17.0",
|
|
887
|
+
"@commercetools-frontend/l10n": "22.17.0",
|
|
893
888
|
"@manypkg/find-root": "2.2.1",
|
|
894
889
|
cac: "^6.7.14",
|
|
895
890
|
cosmiconfig: "9.0.0",
|
|
@@ -897,7 +892,8 @@ var pkgJson = {
|
|
|
897
892
|
execa: "5.1.1",
|
|
898
893
|
jsonschema: "^1.4.1",
|
|
899
894
|
listr2: "8.0.1",
|
|
900
|
-
"node-fetch": "2.7.0"
|
|
895
|
+
"node-fetch": "2.7.0",
|
|
896
|
+
"ts-deepmerge": "7.0.0"
|
|
901
897
|
},
|
|
902
898
|
devDependencies: {
|
|
903
899
|
"@tsconfig/node20": "20.1.2",
|