@commercetools-frontend/application-cli 2.4.0 → 3.0.0

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.
@@ -14,11 +14,11 @@ import _mapInstanceProperty from '@babel/runtime-corejs3/core-js-stable/instance
14
14
  import _Object$entries from '@babel/runtime-corejs3/core-js-stable/object/entries';
15
15
  import _Set from '@babel/runtime-corejs3/core-js-stable/set';
16
16
  import _flatMapInstanceProperty from '@babel/runtime-corejs3/core-js-stable/instance/flat-map';
17
- import { s as storageProviders, l as loadStorageBucketsConfig, c as clusterContexts } from '../../dist/storage-buckets-config-2fc2b441.esm.js';
17
+ import { s as storageProviders, l as loadStorageBucketsConfig, c as clusterContexts, a as loadConfig } from '../../dist/storage-buckets-config-6e04b3d3.esm.js';
18
18
  import fs from 'node:fs';
19
19
  import path$1 from 'node:path';
20
20
  import { Listr } from 'listr2';
21
- import execa from 'execa';
21
+ import execa, { command as command$5 } from 'execa';
22
22
  import { findRootSync } from '@manypkg/find-root';
23
23
  import path from 'path';
24
24
  import _possibleConstructorReturn from '@babel/runtime-corejs3/helpers/esm/possibleConstructorReturn';
@@ -37,9 +37,17 @@ import _JSON$stringify from '@babel/runtime-corejs3/core-js-stable/json/stringif
37
37
  import { processConfig } from '@commercetools-frontend/application-config';
38
38
  import { getSupportedLocales } from '@commercetools-frontend/l10n';
39
39
  import _sliceInstanceProperty from '@babel/runtime-corejs3/core-js-stable/instance/slice';
40
+ import _startsWithInstanceProperty from '@babel/runtime-corejs3/core-js-stable/instance/starts-with';
41
+ import _trimInstanceProperty from '@babel/runtime-corejs3/core-js-stable/instance/trim';
42
+ import _someInstanceProperty from '@babel/runtime-corejs3/core-js-stable/instance/some';
43
+ import _everyInstanceProperty from '@babel/runtime-corejs3/core-js-stable/instance/every';
44
+ import _includesInstanceProperty from '@babel/runtime-corejs3/core-js-stable/instance/includes';
45
+ import micromatch from 'micromatch';
46
+ import snakeCase from 'lodash/snakeCase';
40
47
  import { Validator } from 'jsonschema';
41
48
  import 'cosmiconfig';
42
49
  import 'ts-deepmerge';
50
+ import 'lodash';
43
51
 
44
52
  function getApplicationDirectory(cwd) {
45
53
  return fs.realpathSync(cwd);
@@ -56,20 +64,8 @@ function isCI() {
56
64
 
57
65
  function ownKeys$4(e, r) { var t = _Object$keys(e); if (_Object$getOwnPropertySymbols) { var o = _Object$getOwnPropertySymbols(e); r && (o = _filterInstanceProperty(o).call(o, function (r) { return _Object$getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
58
66
  function _objectSpread$4(e) { for (var r = 1; r < arguments.length; r++) { var _context6, _context7; var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? _forEachInstanceProperty(_context6 = ownKeys$4(Object(t), !0)).call(_context6, function (r) { _defineProperty(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(e, _Object$getOwnPropertyDescriptors(t)) : _forEachInstanceProperty(_context7 = ownKeys$4(Object(t))).call(_context7, function (r) { _Object$defineProperty(e, r, _Object$getOwnPropertyDescriptor(t, r)); }); } return e; }
59
- function _callSuper(_this, derived, args) {
60
- function isNativeReflectConstruct() {
61
- if (typeof Reflect === "undefined" || !_Reflect$construct) return false;
62
- if (_Reflect$construct.sham) return false;
63
- if (typeof Proxy === "function") return true;
64
- try {
65
- return !Boolean.prototype.valueOf.call(_Reflect$construct(Boolean, [], function () {}));
66
- } catch (e) {
67
- return false;
68
- }
69
- }
70
- derived = _getPrototypeOf(derived);
71
- return _possibleConstructorReturn(_this, isNativeReflectConstruct() ? _Reflect$construct(derived, args || [], _getPrototypeOf(_this).constructor) : derived.apply(_this, args));
72
- }
67
+ function _callSuper(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? _Reflect$construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); }
68
+ function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(_Reflect$construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function () { return !!t; })(); }
73
69
  var _bucketRegion$1 = /*#__PURE__*/_classPrivateFieldLooseKey("bucketRegion");
74
70
  var _bucketEnvironment$1 = /*#__PURE__*/_classPrivateFieldLooseKey("bucketEnvironment");
75
71
  let StorageProvider = /*#__PURE__*/function () {
@@ -172,20 +168,20 @@ var _bucketRegion2$1 = /*#__PURE__*/_classPrivateFieldLooseKey("bucketRegion");
172
168
  var _bucketEnvironment2$1 = /*#__PURE__*/_classPrivateFieldLooseKey("bucketEnvironment");
173
169
  let GoogleStorageProvider = /*#__PURE__*/function (_StorageProvider2) {
174
170
  function GoogleStorageProvider(config) {
175
- var _this2;
171
+ var _this;
176
172
  _classCallCheck(this, GoogleStorageProvider);
177
- _this2 = _callSuper(this, GoogleStorageProvider, [config]);
178
- _Object$defineProperty(_this2, _bucketRegion2$1, {
173
+ _this = _callSuper(this, GoogleStorageProvider, [config]);
174
+ _Object$defineProperty(_this, _bucketRegion2$1, {
179
175
  writable: true,
180
176
  value: void 0
181
177
  });
182
- _Object$defineProperty(_this2, _bucketEnvironment2$1, {
178
+ _Object$defineProperty(_this, _bucketEnvironment2$1, {
183
179
  writable: true,
184
180
  value: void 0
185
181
  });
186
- _classPrivateFieldLooseBase(_this2, _bucketRegion2$1)[_bucketRegion2$1] = config.bucketRegion;
187
- _classPrivateFieldLooseBase(_this2, _bucketEnvironment2$1)[_bucketEnvironment2$1] = config.bucketEnvironment;
188
- return _this2;
182
+ _classPrivateFieldLooseBase(_this, _bucketRegion2$1)[_bucketRegion2$1] = config.bucketRegion;
183
+ _classPrivateFieldLooseBase(_this, _bucketEnvironment2$1)[_bucketEnvironment2$1] = config.bucketEnvironment;
184
+ return _this;
189
185
  }
190
186
  _inherits(GoogleStorageProvider, _StorageProvider2);
191
187
  return _createClass(GoogleStorageProvider, [{
@@ -244,20 +240,20 @@ var _bucketRegion3 = /*#__PURE__*/_classPrivateFieldLooseKey("bucketRegion");
244
240
  var _bucketEnvironment3 = /*#__PURE__*/_classPrivateFieldLooseKey("bucketEnvironment");
245
241
  let AwsStorageProvider = /*#__PURE__*/function (_StorageProvider3) {
246
242
  function AwsStorageProvider(config) {
247
- var _this3;
243
+ var _this2;
248
244
  _classCallCheck(this, AwsStorageProvider);
249
- _this3 = _callSuper(this, AwsStorageProvider, [config]);
250
- _Object$defineProperty(_this3, _bucketRegion3, {
245
+ _this2 = _callSuper(this, AwsStorageProvider, [config]);
246
+ _Object$defineProperty(_this2, _bucketRegion3, {
251
247
  writable: true,
252
248
  value: void 0
253
249
  });
254
- _Object$defineProperty(_this3, _bucketEnvironment3, {
250
+ _Object$defineProperty(_this2, _bucketEnvironment3, {
255
251
  writable: true,
256
252
  value: void 0
257
253
  });
258
- _classPrivateFieldLooseBase(_this3, _bucketRegion3)[_bucketRegion3] = config.bucketRegion;
259
- _classPrivateFieldLooseBase(_this3, _bucketEnvironment3)[_bucketEnvironment3] = config.bucketEnvironment;
260
- return _this3;
254
+ _classPrivateFieldLooseBase(_this2, _bucketRegion3)[_bucketRegion3] = config.bucketRegion;
255
+ _classPrivateFieldLooseBase(_this2, _bucketEnvironment3)[_bucketEnvironment3] = config.bucketEnvironment;
256
+ return _this2;
261
257
  }
262
258
  _inherits(AwsStorageProvider, _StorageProvider3);
263
259
  return _createClass(AwsStorageProvider, [{
@@ -581,7 +577,7 @@ async function compileEnvironmentApplicationIndexes(_ref3) {
581
577
  throw new Error(moveResult.stderr);
582
578
  }
583
579
  }
584
- async function command$3(cliFlags, cwd) {
580
+ async function command$4(cliFlags, cwd) {
585
581
  var _context3;
586
582
  const storageBucketConfig = await loadStorageBucketsConfig();
587
583
  const applicationDirectory = getApplicationDirectory(cwd);
@@ -754,7 +750,7 @@ const mapApplicationMenuConfigToGraqhQLMenuJson = config => {
754
750
  shouldRenderDivider: (_menuLinks$shouldRend = menuLinks.shouldRenderDivider) !== null && _menuLinks$shouldRend !== void 0 ? _menuLinks$shouldRend : false
755
751
  };
756
752
  };
757
- async function command$2(cliFlags, cwd) {
753
+ async function command$3(cliFlags, cwd) {
758
754
  const applicationDirectory = getApplicationDirectory(cwd);
759
755
  const monorepoRoot = findRootSync(cwd);
760
756
  const dotenvPath = cliFlags.dotenvFolder && path.join(monorepoRoot.rootDir, cliFlags.dotenvFolder);
@@ -785,7 +781,7 @@ async function command$2(cliFlags, cwd) {
785
781
  });
786
782
  }
787
783
 
788
- async function command$1(cliFlags) {
784
+ async function command$2(cliFlags) {
789
785
  const numberOfRollbacks = cliFlags.rollbacks - 1;
790
786
  let nextRollbacks;
791
787
  try {
@@ -821,6 +817,158 @@ async function command$1(cliFlags) {
821
817
  }
822
818
  }
823
819
 
820
+ /**
821
+ * This is heavily inspired by https://circleci.com/developer/orbs/orb/circleci/path-filtering.
822
+ *
823
+ * It detects changed files between `HEAD` and a base revision.
824
+ * To match them against configured RegEx tr
825
+ * All matched triggers will be written as a dotenv file.
826
+ * The dotenv file is read in a CircleCI step and be evaluated.
827
+ */
828
+ const git = {
829
+ // https://git-scm.com/docs/git-merge-base
830
+ base: (baseBranch, headRevision) => {
831
+ var _context;
832
+ return _concatInstanceProperty(_context = "git merge-base ".concat(baseBranch, " ")).call(_context, headRevision);
833
+ },
834
+ // https://git-scm.com/docs/git-diff
835
+ changedFiles: (mergeRevision, headRevision) => {
836
+ var _context2;
837
+ return _concatInstanceProperty(_context2 = "git diff --name-only ".concat(mergeRevision, " ")).call(_context2, headRevision);
838
+ },
839
+ commitMessage: headRevision => "git log --format=oneline -n 1 ".concat(headRevision)
840
+ };
841
+ const helpers = {
842
+ async writeOutDotEnvFile(cliFlags, cwd, matchingTriggers) {
843
+ var _context3;
844
+ // If desired read the env file and write out the matching triggers.
845
+ if (!cliFlags.outEnvFile) {
846
+ return;
847
+ }
848
+ const filePath = path$1.join(fs.realpathSync(cwd), cliFlags.outEnvFile);
849
+ const fileContents = _mapInstanceProperty(_context3 = _Object$entries(matchingTriggers)).call(_context3, _ref => {
850
+ var _context5;
851
+ let _ref2 = _slicedToArray(_ref, 2),
852
+ triggerName = _ref2[0],
853
+ triggerValue = _ref2[1];
854
+ const triggerNameForEnvFile = "".concat(snakeCase(triggerName).toUpperCase());
855
+
856
+ // General pipeline optimization hints are not transformed
857
+ if (_startsWithInstanceProperty(triggerName).call(triggerName, 'allowPipelineOptimizations')) {
858
+ var _context4;
859
+ return _concatInstanceProperty(_context4 = "".concat(triggerNameForEnvFile, "=")).call(_context4, triggerValue);
860
+ }
861
+ return _concatInstanceProperty(_context5 = "DID_".concat(triggerNameForEnvFile, "_CHANGE=")).call(_context5, triggerValue);
862
+ }).join('\n');
863
+ await fs.promises.writeFile(filePath, fileContents);
864
+ if (!cliFlags.silent) {
865
+ console.log("\uD83D\uDCDD Wrote out file to '".concat(filePath, "' with contents:"));
866
+ console.log(fileContents);
867
+ }
868
+ },
869
+ async getChangedFiles(cliFlags) {
870
+ var _context6, _context7;
871
+ const baseCmdResult = await command$5(git.base(cliFlags.baseBranch, cliFlags.headRevision));
872
+ const mergeRevision = baseCmdResult.stdout;
873
+ const changedFilesCmdResult = await command$5(git.changedFiles(mergeRevision, cliFlags.headRevision));
874
+ const changedFiles = _filterInstanceProperty(_context6 = _mapInstanceProperty(_context7 = changedFilesCmdResult.stdout.split('\n')).call(_context7, filePath => _trimInstanceProperty(filePath).call(filePath))).call(_context6, filePath => filePath.length > 0);
875
+ return changedFiles;
876
+ },
877
+ async matchTriggersAgainstChangedFiles(cliFlags, config, changedFiles) {
878
+ const matchedTriggers = {};
879
+
880
+ // Evaluate each trigger against each file.
881
+ _forEachInstanceProperty(config).call(config, async trigger => {
882
+ var _trigger$exclude;
883
+ const hasTriggerBeenInitialized = typeof matchedTriggers[trigger.name] === 'number';
884
+
885
+ // Given the trigger with this name was never evaluated it has to be defaulted to 0.
886
+ // As without any matches we should indicate nothing changed.
887
+ if (!hasTriggerBeenInitialized) {
888
+ matchedTriggers[trigger.name] = 0;
889
+ }
890
+ // Given the trigger was already evaluated to be positive we can skip this evaluation.
891
+ if (matchedTriggers[trigger.name] === 1) {
892
+ return matchedTriggers;
893
+ }
894
+
895
+ // In any other case we evaluate this trigger.
896
+ const anyFileChangedForTrigger = _someInstanceProperty(micromatch).call(micromatch, changedFiles, trigger.include, {
897
+ ignore: trigger.ignore
898
+ });
899
+ if (!cliFlags.silent && anyFileChangedForTrigger) {
900
+ console.log("\u2139\uFE0F Files for trigger ".concat(trigger.name, " changed."));
901
+ }
902
+ let onlyExcludedFilesChangedForTrigger = false;
903
+ if (((_trigger$exclude = trigger.exclude) === null || _trigger$exclude === void 0 ? void 0 : _trigger$exclude.length) > 0) {
904
+ // NOTE: `micromatch.every` evaluates if every file matches
905
+ // every pattern.
906
+ // We need to evaluate if every file matches some pattern.
907
+ onlyExcludedFilesChangedForTrigger = _everyInstanceProperty(changedFiles).call(changedFiles, changedFile => {
908
+ return micromatch.isMatch(changedFile, trigger.exclude, {
909
+ ignore: trigger.ignore
910
+ });
911
+ });
912
+ }
913
+ if (!cliFlags.silent && onlyExcludedFilesChangedForTrigger) {
914
+ console.log("\u2139\uFE0F Only excluded files for trigger ".concat(trigger.name, " changed."));
915
+ }
916
+ if (onlyExcludedFilesChangedForTrigger) {
917
+ matchedTriggers[trigger.name] = 0;
918
+ } else {
919
+ matchedTriggers[trigger.name] = Number(anyFileChangedForTrigger);
920
+ }
921
+ return matchedTriggers;
922
+ });
923
+ return matchedTriggers;
924
+ }
925
+ };
926
+ async function command$1(cliFlags, config, cwd) {
927
+ const enablePipelineOptimizations = process.env.ENABLE_PIPELINE_OPTIMIZATIONS === '1';
928
+ const isDevelopmentBranch = cliFlags.branch !== cliFlags.baseBranch;
929
+ const triggersContainingSharedFiles = _filterInstanceProperty(config).call(config, trigger => trigger.containsSharedFiles);
930
+ if (!cliFlags.silent) {
931
+ var _context8;
932
+ console.log("\u2139\uFE0F Pipeline optimizations are ".concat(enablePipelineOptimizations ? 'enabled' : 'disabled', "."));
933
+ console.log("\u2139\uFE0F Changes have been commited to the ".concat(isDevelopmentBranch ? 'a development' : 'the main', " branch."));
934
+ console.log(_concatInstanceProperty(_context8 = "\uD83D\uDEA7 Comparing '".concat(cliFlags.baseBranch, "' against '")).call(_context8, cliFlags.headRevision, "' to determine changed files."));
935
+ }
936
+
937
+ // Collect and parse changed files from git comparing base and head revision.
938
+ const changedFiles = await helpers.getChangedFiles(cliFlags);
939
+ if (!cliFlags.silent) {
940
+ if (changedFiles.length === 0) {
941
+ console.log("\u2139\uFE0F No changes found.");
942
+ } else {
943
+ console.log("\u2139\uFE0F ".concat(changedFiles.length, " changes found."));
944
+ }
945
+ }
946
+
947
+ // Read the trigger file to match the changed files against.
948
+ const matchedTriggers = await helpers.matchTriggersAgainstChangedFiles(cliFlags, config, changedFiles);
949
+ const commitMessageCmdResult = await command$5(git.commitMessage(cliFlags.headRevision));
950
+ const commitMessage = commitMessageCmdResult.stdout;
951
+ const hasCommitMessageTrigger = commitMessage && _includesInstanceProperty(commitMessage).call(commitMessage, '[ci all]');
952
+ const doesSharedTriggerMatch = _someInstanceProperty(triggersContainingSharedFiles).call(triggersContainingSharedFiles, triggerContainingSharedFiles => matchedTriggers[triggerContainingSharedFiles.name] === 1);
953
+ if (!cliFlags.silent) {
954
+ console.log("\u2139\uFE0F The git commit message ".concat(hasCommitMessageTrigger ? 'does' : 'does not', " contain a [ci all] trigger."));
955
+ }
956
+ const doesPackageFolderTriggerMatch = matchedTriggers[cliFlags.triggerName] === 1;
957
+ if (enablePipelineOptimizations && isDevelopmentBranch && !hasCommitMessageTrigger && !doesSharedTriggerMatch && !doesPackageFolderTriggerMatch) {
958
+ if (!cliFlags.silent) {
959
+ console.log("\u2139\uFE0F No relevant changes found for ".concat(cliFlags.triggerName, "."));
960
+ }
961
+ matchedTriggers['allowPipelineOptimizationsForTrigger'] = 1;
962
+ } else {
963
+ if (!cliFlags.silent) {
964
+ console.log("\u2139\uFE0F Relevant changes found for ".concat(cliFlags.triggerName, "."));
965
+ }
966
+ matchedTriggers['allowPipelineOptimizationsForTrigger'] = 0;
967
+ }
968
+ await helpers.writeOutDotEnvFile(cliFlags, cwd, matchedTriggers);
969
+ return matchedTriggers;
970
+ }
971
+
824
972
  function ownKeys(e, r) { var t = _Object$keys(e); if (_Object$getOwnPropertySymbols) { var o = _Object$getOwnPropertySymbols(e); r && (o = _filterInstanceProperty(o).call(o, function (r) { return _Object$getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
825
973
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var _context, _context2; var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? _forEachInstanceProperty(_context = ownKeys(Object(t), !0)).call(_context, function (r) { _defineProperty(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(e, _Object$getOwnPropertyDescriptors(t)) : _forEachInstanceProperty(_context2 = ownKeys(Object(t))).call(_context2, function (r) { _Object$defineProperty(e, r, _Object$getOwnPropertyDescriptor(t, r)); }); } return e; }
826
974
  const baseMenuProperties = {
@@ -941,7 +1089,7 @@ async function command(cliFlags) {
941
1089
 
942
1090
  var pkgJson = {
943
1091
  name: "@commercetools-frontend/application-cli",
944
- version: "2.4.0",
1092
+ version: "3.0.0",
945
1093
  description: "Internal CLI to manage Merchant Center application deployments across various environments.",
946
1094
  keywords: [
947
1095
  "commercetools",
@@ -953,6 +1101,7 @@ var pkgJson = {
953
1101
  module: "dist/commercetools-frontend-application-cli.esm.js",
954
1102
  bin: "bin/cli.js",
955
1103
  files: [
1104
+ "bin",
956
1105
  "cli",
957
1106
  "dist",
958
1107
  "package.json",
@@ -966,26 +1115,30 @@ var pkgJson = {
966
1115
  "@babel/core": "^7.22.11",
967
1116
  "@babel/runtime": "^7.21.0",
968
1117
  "@babel/runtime-corejs3": "^7.21.0",
969
- "@commercetools-frontend/application-config": "22.23.3",
970
- "@commercetools-frontend/constants": "22.23.3",
971
- "@commercetools-frontend/l10n": "22.23.3",
1118
+ "@commercetools-frontend/application-config": "22.27.0",
1119
+ "@commercetools-frontend/constants": "22.27.0",
1120
+ "@commercetools-frontend/l10n": "22.27.0",
972
1121
  "@manypkg/find-root": "2.2.1",
973
1122
  cac: "^6.7.14",
974
1123
  cosmiconfig: "9.0.0",
975
1124
  dotenv: "16.4.5",
976
1125
  execa: "5.1.1",
977
1126
  jsonschema: "^1.4.1",
978
- listr2: "8.2.0",
1127
+ listr2: "8.2.1",
1128
+ lodash: "4.17.21",
1129
+ micromatch: "4.0.7",
979
1130
  "node-fetch": "2.7.0",
980
1131
  "ts-deepmerge": "7.0.0"
981
1132
  },
982
1133
  devDependencies: {
983
1134
  "@tsconfig/node20": "20.1.4",
984
- "@types/node": "20.12.7",
1135
+ "@types/lodash": "^4.14.198",
1136
+ "@types/micromatch": "4.0.7",
1137
+ "@types/node": "20.12.12",
985
1138
  typescript: "5.2.2"
986
1139
  },
987
1140
  engines: {
988
- node: ">=18",
1141
+ node: ">=21",
989
1142
  npm: ">=6"
990
1143
  },
991
1144
  publishConfig: {
@@ -1022,11 +1175,11 @@ const run = async () => {
1022
1175
  }).option('--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.').option('--skip-menu', '(optional) If provided, it will skip uploading the `menu.json`.', {
1023
1176
  default: false
1024
1177
  }).action(async options => {
1025
- await command$3(options, cwd);
1178
+ await command$4(options, cwd);
1026
1179
  });
1027
1180
  const usageCompileMenu = 'Compile the menu links of an application into a `menu.json`. This is only required for internal applications';
1028
1181
  cli.command('compile-menu', usageCompileMenu).usage("compile-menu \n\n ".concat(usageCompileMenu)).option('--dotenv-folder [string]', '(optional) The path to a folder containing a dotenv file `.env.production` and a cloud-environment specific dotenv file (for example `.env.gcp-production-eu`). Those values are parsed and merged together to be used by the application config.').action(async options => {
1029
- await command$2(options, cwd);
1182
+ await command$3(options, cwd);
1030
1183
  });
1031
1184
  const usageValidateMenu = 'Validate compiled `menu.json` file';
1032
1185
  cli.command('validate-menu', usageValidateMenu).usage("validate-menu \n\n ".concat(usageValidateMenu)).option('--input-file <path>', '(required) The path to the `menu.json` file to be validated.').option('--navigation [string]', '(optional) Location of the menu navigation. Possible values are `top`.').action(async options => {
@@ -1036,7 +1189,20 @@ const run = async () => {
1036
1189
  cli.command('create-version', usageCreateVersion).usage("create-version \n\n ".concat(usageCreateVersion)).option('--version-url <url>', "(required) The path of an application's current `version.json` within the storage bucket.").option('--rollbacks [int]', '(optional) The number of max rollbacks to keep', {
1037
1190
  default: 15
1038
1191
  }).option('--out-file [path]', '(optional) The path to the file where to write the JSON. If not specified, the JSON is printed to stdout.').action(async options => {
1039
- await command$1(options);
1192
+ await command$2(options);
1193
+ });
1194
+
1195
+ // Command: Evaluate change triggers
1196
+ const usageEvaluateChangeTriggers = 'Evaluates changed files against a base and evaluates them against defined triggers.';
1197
+ cli.command('evaluate-change-triggers', usageEvaluateChangeTriggers).usage("evaluate-change-triggers \n\n ".concat(usageEvaluateChangeTriggers)).option('--branch <string>', 'The branch of the pull request', {
1198
+ default: process.env.CIRCLE_BRANCH
1199
+ }).option('--base-branch <string>', 'The base revision of the git commit compare against (e.g. "main")').option('--head-revision <string>', 'The revision of the git head to compare with', {
1200
+ default: process.env.CIRCLE_SHA1
1201
+ }).option('--trigger-name <string>', 'The trigger to evaluate for.').option('--silent', '(optional) Disable logging', {
1202
+ default: false
1203
+ }).option('--out-env-file [string]', '(optional) A file path where the matched triggers are written as a dotenv file.').action(async options => {
1204
+ const config = await loadConfig('circleci-change-triggers', []);
1205
+ await command$1(options, config, cwd);
1040
1206
  });
1041
1207
  cli.help();
1042
1208
  cli.version(pkgJson.version);
@@ -2,12 +2,14 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var storageBucketsConfig = require('./storage-buckets-config-91932b24.cjs.dev.js');
5
+ var storageBucketsConfig = require('./storage-buckets-config-89962880.cjs.dev.js');
6
6
  require('@babel/runtime-corejs3/core-js-stable/instance/for-each');
7
7
  require('@babel/runtime-corejs3/core-js-stable/object/keys');
8
8
  require('@babel/runtime-corejs3/core-js-stable/instance/filter');
9
+ require('@babel/runtime-corejs3/core-js-stable/instance/concat');
9
10
  require('cosmiconfig');
10
11
  require('ts-deepmerge');
12
+ require('lodash');
11
13
 
12
14
 
13
15
 
@@ -2,12 +2,14 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var storageBucketsConfig = require('./storage-buckets-config-b6d36938.cjs.prod.js');
5
+ var storageBucketsConfig = require('./storage-buckets-config-2f9a9168.cjs.prod.js');
6
6
  require('@babel/runtime-corejs3/core-js-stable/instance/for-each');
7
7
  require('@babel/runtime-corejs3/core-js-stable/object/keys');
8
8
  require('@babel/runtime-corejs3/core-js-stable/instance/filter');
9
+ require('@babel/runtime-corejs3/core-js-stable/instance/concat');
9
10
  require('cosmiconfig');
10
11
  require('ts-deepmerge');
12
+ require('lodash');
11
13
 
12
14
 
13
15
 
@@ -1,6 +1,8 @@
1
- export { b as bucketEnvironments, a as bucketRegions, c as clusterContexts, d as defineStorageBucketsConfig, s as storageProviders } from './storage-buckets-config-2fc2b441.esm.js';
1
+ export { b as bucketEnvironments, e as bucketRegions, c as clusterContexts, d as defineStorageBucketsConfig, s as storageProviders } from './storage-buckets-config-6e04b3d3.esm.js';
2
2
  import '@babel/runtime-corejs3/core-js-stable/instance/for-each';
3
3
  import '@babel/runtime-corejs3/core-js-stable/object/keys';
4
4
  import '@babel/runtime-corejs3/core-js-stable/instance/filter';
5
+ import '@babel/runtime-corejs3/core-js-stable/instance/concat';
5
6
  import 'cosmiconfig';
6
7
  import 'ts-deepmerge';
8
+ import 'lodash';
@@ -13,6 +13,7 @@ export declare const clusterContexts: {
13
13
  readonly 'ctp_production_gcp_australia-southeast1_v1': "ctp_production_gcp_australia-southeast1_v1";
14
14
  readonly 'ctp_production_aws_cn-northwest-1_v1': "ctp_production_aws_cn-northwest-1_v1";
15
15
  readonly ctp_staging_azure_northeurope_v1: "ctp_staging_azure_northeurope_v1";
16
+ readonly ctp_production_azure_eastus_v1: "ctp_production_azure_eastus_v1";
16
17
  };
17
18
  export declare const bucketEnvironments: {
18
19
  readonly 'ctp-gcp-staging': "ctp-gcp-staging";
@@ -20,6 +21,7 @@ export declare const bucketEnvironments: {
20
21
  readonly 'ctp-aws-staging-cn': "ctp-aws-staging-cn";
21
22
  readonly 'ctp-gcp-testing-performance-eu': "ctp-gcp-testing-performance-eu";
22
23
  readonly 'ctp-azure-staging': "ctp-azure-staging";
24
+ readonly 'ctp-azure-production-us': "ctp-azure-production-us";
23
25
  readonly 'ctp-aws-production-fra': "ctp-aws-production-fra";
24
26
  readonly 'ctp-gcp-production-eu': "ctp-gcp-production-eu";
25
27
  readonly 'ctp-vw-production-eu': "ctp-vw-production-eu";
@@ -9,4 +9,5 @@ type TDefineConfigArgs = {
9
9
  };
10
10
  declare function defineStorageBucketsConfig({ regions, options, }?: TDefineConfigArgs): TStorageBucketsConfig;
11
11
  declare function loadStorageBucketsConfig(): Promise<TStorageBucketsConfig>;
12
- export { defineStorageBucketsConfig, loadStorageBucketsConfig };
12
+ declare function loadConfig<TConfig>(moduleName: string, defaultConfig?: unknown): Promise<TConfig>;
13
+ export { defineStorageBucketsConfig, loadStorageBucketsConfig, loadConfig };
@@ -125,4 +125,21 @@ export type TValidateMenuFlags = {
125
125
  inputFile: string;
126
126
  navigation?: string;
127
127
  };
128
+ export type TEvaluateChangeTriggersCliFlags = {
129
+ branch: string;
130
+ baseBranch: string;
131
+ headRevision: string;
132
+ triggerName: string;
133
+ gitCommitMessage?: string;
134
+ outEnvFile?: string;
135
+ silent?: boolean;
136
+ };
137
+ type TChangeTrigger = {
138
+ name: string;
139
+ containsSharedFiles?: boolean;
140
+ include: string[];
141
+ exclude: string[];
142
+ ignore: string[];
143
+ };
144
+ export type TChangeTriggersConfig = TChangeTrigger[];
128
145
  export {};
@@ -3,14 +3,18 @@
3
3
  var _forEachInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/for-each');
4
4
  var _Object$keys = require('@babel/runtime-corejs3/core-js-stable/object/keys');
5
5
  var _filterInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/filter');
6
+ var _concatInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/concat');
6
7
  var cosmiconfig = require('cosmiconfig');
7
8
  var tsDeepmerge = require('ts-deepmerge');
9
+ var lodash = require('lodash');
8
10
 
9
11
  function _interopDefault (e) { return e && e.__esModule ? e : { 'default': e }; }
10
12
 
11
13
  var _forEachInstanceProperty__default = /*#__PURE__*/_interopDefault(_forEachInstanceProperty);
12
14
  var _Object$keys__default = /*#__PURE__*/_interopDefault(_Object$keys);
13
15
  var _filterInstanceProperty__default = /*#__PURE__*/_interopDefault(_filterInstanceProperty);
16
+ var _concatInstanceProperty__default = /*#__PURE__*/_interopDefault(_concatInstanceProperty);
17
+ var lodash__default = /*#__PURE__*/_interopDefault(lodash);
14
18
 
15
19
  const clusterContexts = {
16
20
  'ctp_staging_gcp_europe-west1_v1': 'ctp_staging_gcp_europe-west1_v1',
@@ -25,7 +29,8 @@ const clusterContexts = {
25
29
  'ctp_production_gcp_us-central1_v1': 'ctp_production_gcp_us-central1_v1',
26
30
  'ctp_production_gcp_australia-southeast1_v1': 'ctp_production_gcp_australia-southeast1_v1',
27
31
  'ctp_production_aws_cn-northwest-1_v1': 'ctp_production_aws_cn-northwest-1_v1',
28
- ctp_staging_azure_northeurope_v1: 'ctp_staging_azure_northeurope_v1'
32
+ ctp_staging_azure_northeurope_v1: 'ctp_staging_azure_northeurope_v1',
33
+ ctp_production_azure_eastus_v1: 'ctp_production_azure_eastus_v1'
29
34
  };
30
35
  const bucketEnvironments = {
31
36
  'ctp-gcp-staging': 'ctp-gcp-staging',
@@ -33,6 +38,7 @@ const bucketEnvironments = {
33
38
  'ctp-aws-staging-cn': 'ctp-aws-staging-cn',
34
39
  'ctp-gcp-testing-performance-eu': 'ctp-gcp-testing-performance-eu',
35
40
  'ctp-azure-staging': 'ctp-azure-staging',
41
+ 'ctp-azure-production-us': 'ctp-azure-production-us',
36
42
  'ctp-aws-production-fra': 'ctp-aws-production-fra',
37
43
  'ctp-gcp-production-eu': 'ctp-gcp-production-eu',
38
44
  'ctp-vw-production-eu': 'ctp-vw-production-eu',
@@ -115,6 +121,9 @@ const defaultConfig = {
115
121
  }, {
116
122
  cloudEnvironment: clusterContexts['ctp_production_gcp_us-central1_v1'],
117
123
  bucketEnvironment: bucketEnvironments['ctp-gcp-production-us']
124
+ }, {
125
+ cloudEnvironment: clusterContexts['ctp_production_azure_eastus_v1'],
126
+ bucketEnvironment: bucketEnvironments['ctp-azure-production-us']
118
127
  }],
119
128
  [bucketRegions.asia]: [{
120
129
  cloudEnvironment: clusterContexts['ctp_production_gcp_australia-southeast1_v1'],
@@ -170,10 +179,26 @@ async function loadStorageBucketsConfig() {
170
179
  }
171
180
  return (_explorerResult = explorerResult) === null || _explorerResult === void 0 ? void 0 : _explorerResult.config;
172
181
  }
182
+ async function loadConfig(moduleName, defaultConfig) {
183
+ const configExplorer = cosmiconfig.cosmiconfig(moduleName, {
184
+ searchStrategy: 'project'
185
+ });
186
+ try {
187
+ const cosmiconfigResult = await configExplorer.search();
188
+ const mergedConfig = lodash__default["default"].merge(defaultConfig, cosmiconfigResult === null || cosmiconfigResult === void 0 ? void 0 : cosmiconfigResult.config);
189
+ console.log("\u2139\uFE0F Merged and loaded cosmiconfig file for '".concat(moduleName, "'."));
190
+ return mergedConfig;
191
+ } catch (e) {
192
+ var _context, _context2;
193
+ console.warn(e);
194
+ throw new Error(_concatInstanceProperty__default["default"](_context = _concatInstanceProperty__default["default"](_context2 = "Failed loading a ".concat(moduleName, " configuration. Create a cosmiconfig for '")).call(_context2, moduleName, "' for example '")).call(_context, moduleName, ".config.cjs.'"));
195
+ }
196
+ }
173
197
 
174
198
  exports.bucketEnvironments = bucketEnvironments;
175
199
  exports.bucketRegions = bucketRegions;
176
200
  exports.clusterContexts = clusterContexts;
177
201
  exports.defineStorageBucketsConfig = defineStorageBucketsConfig;
202
+ exports.loadConfig = loadConfig;
178
203
  exports.loadStorageBucketsConfig = loadStorageBucketsConfig;
179
204
  exports.storageProviders = storageProviders;
@@ -1,8 +1,10 @@
1
1
  import _forEachInstanceProperty from '@babel/runtime-corejs3/core-js-stable/instance/for-each';
2
2
  import _Object$keys from '@babel/runtime-corejs3/core-js-stable/object/keys';
3
3
  import _filterInstanceProperty from '@babel/runtime-corejs3/core-js-stable/instance/filter';
4
+ import _concatInstanceProperty from '@babel/runtime-corejs3/core-js-stable/instance/concat';
4
5
  import { cosmiconfig } from 'cosmiconfig';
5
6
  import { merge } from 'ts-deepmerge';
7
+ import lodash from 'lodash';
6
8
 
7
9
  const clusterContexts = {
8
10
  'ctp_staging_gcp_europe-west1_v1': 'ctp_staging_gcp_europe-west1_v1',
@@ -17,7 +19,8 @@ const clusterContexts = {
17
19
  'ctp_production_gcp_us-central1_v1': 'ctp_production_gcp_us-central1_v1',
18
20
  'ctp_production_gcp_australia-southeast1_v1': 'ctp_production_gcp_australia-southeast1_v1',
19
21
  'ctp_production_aws_cn-northwest-1_v1': 'ctp_production_aws_cn-northwest-1_v1',
20
- ctp_staging_azure_northeurope_v1: 'ctp_staging_azure_northeurope_v1'
22
+ ctp_staging_azure_northeurope_v1: 'ctp_staging_azure_northeurope_v1',
23
+ ctp_production_azure_eastus_v1: 'ctp_production_azure_eastus_v1'
21
24
  };
22
25
  const bucketEnvironments = {
23
26
  'ctp-gcp-staging': 'ctp-gcp-staging',
@@ -25,6 +28,7 @@ const bucketEnvironments = {
25
28
  'ctp-aws-staging-cn': 'ctp-aws-staging-cn',
26
29
  'ctp-gcp-testing-performance-eu': 'ctp-gcp-testing-performance-eu',
27
30
  'ctp-azure-staging': 'ctp-azure-staging',
31
+ 'ctp-azure-production-us': 'ctp-azure-production-us',
28
32
  'ctp-aws-production-fra': 'ctp-aws-production-fra',
29
33
  'ctp-gcp-production-eu': 'ctp-gcp-production-eu',
30
34
  'ctp-vw-production-eu': 'ctp-vw-production-eu',
@@ -107,6 +111,9 @@ const defaultConfig = {
107
111
  }, {
108
112
  cloudEnvironment: clusterContexts['ctp_production_gcp_us-central1_v1'],
109
113
  bucketEnvironment: bucketEnvironments['ctp-gcp-production-us']
114
+ }, {
115
+ cloudEnvironment: clusterContexts['ctp_production_azure_eastus_v1'],
116
+ bucketEnvironment: bucketEnvironments['ctp-azure-production-us']
110
117
  }],
111
118
  [bucketRegions.asia]: [{
112
119
  cloudEnvironment: clusterContexts['ctp_production_gcp_australia-southeast1_v1'],
@@ -162,5 +169,20 @@ async function loadStorageBucketsConfig() {
162
169
  }
163
170
  return (_explorerResult = explorerResult) === null || _explorerResult === void 0 ? void 0 : _explorerResult.config;
164
171
  }
172
+ async function loadConfig(moduleName, defaultConfig) {
173
+ const configExplorer = cosmiconfig(moduleName, {
174
+ searchStrategy: 'project'
175
+ });
176
+ try {
177
+ const cosmiconfigResult = await configExplorer.search();
178
+ const mergedConfig = lodash.merge(defaultConfig, cosmiconfigResult === null || cosmiconfigResult === void 0 ? void 0 : cosmiconfigResult.config);
179
+ console.log("\u2139\uFE0F Merged and loaded cosmiconfig file for '".concat(moduleName, "'."));
180
+ return mergedConfig;
181
+ } catch (e) {
182
+ var _context, _context2;
183
+ console.warn(e);
184
+ throw new Error(_concatInstanceProperty(_context = _concatInstanceProperty(_context2 = "Failed loading a ".concat(moduleName, " configuration. Create a cosmiconfig for '")).call(_context2, moduleName, "' for example '")).call(_context, moduleName, ".config.cjs.'"));
185
+ }
186
+ }
165
187
 
166
- export { bucketRegions as a, bucketEnvironments as b, clusterContexts as c, defineStorageBucketsConfig as d, loadStorageBucketsConfig as l, storageProviders as s };
188
+ export { loadConfig as a, bucketEnvironments as b, clusterContexts as c, defineStorageBucketsConfig as d, bucketRegions as e, loadStorageBucketsConfig as l, storageProviders as s };