@commercetools-frontend/application-cli 2.4.0 → 2.5.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.
- package/cli/dist/commercetools-frontend-application-cli-cli.cjs.dev.js +192 -8
- package/cli/dist/commercetools-frontend-application-cli-cli.cjs.prod.js +192 -8
- package/cli/dist/commercetools-frontend-application-cli-cli.esm.js +186 -9
- package/dist/commercetools-frontend-application-cli.cjs.dev.js +3 -1
- package/dist/commercetools-frontend-application-cli.cjs.prod.js +3 -1
- package/dist/commercetools-frontend-application-cli.esm.js +3 -1
- package/dist/declarations/src/constants.d.ts +2 -0
- package/dist/declarations/src/storage-buckets-config.d.ts +2 -1
- package/dist/declarations/src/types.d.ts +17 -0
- package/dist/{storage-buckets-config-91932b24.cjs.dev.js → storage-buckets-config-0a380c12.cjs.prod.js} +26 -1
- package/dist/{storage-buckets-config-2fc2b441.esm.js → storage-buckets-config-896b4064.esm.js} +24 -2
- package/dist/{storage-buckets-config-b6d36938.cjs.prod.js → storage-buckets-config-cf50df38.cjs.dev.js} +26 -1
- package/package.json +5 -1
|
@@ -18,7 +18,7 @@ var _mapInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instan
|
|
|
18
18
|
var _Object$entries = require('@babel/runtime-corejs3/core-js-stable/object/entries');
|
|
19
19
|
var _Set = require('@babel/runtime-corejs3/core-js-stable/set');
|
|
20
20
|
var _flatMapInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/flat-map');
|
|
21
|
-
var storageBucketsConfig = require('../../dist/storage-buckets-config-
|
|
21
|
+
var storageBucketsConfig = require('../../dist/storage-buckets-config-cf50df38.cjs.dev.js');
|
|
22
22
|
var fs = require('node:fs');
|
|
23
23
|
var path$1 = require('node:path');
|
|
24
24
|
var listr2 = require('listr2');
|
|
@@ -41,9 +41,17 @@ var _JSON$stringify = require('@babel/runtime-corejs3/core-js-stable/json/string
|
|
|
41
41
|
var applicationConfig = require('@commercetools-frontend/application-config');
|
|
42
42
|
var l10n = require('@commercetools-frontend/l10n');
|
|
43
43
|
var _sliceInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/slice');
|
|
44
|
+
var _startsWithInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/starts-with');
|
|
45
|
+
var _trimInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/trim');
|
|
46
|
+
var _someInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/some');
|
|
47
|
+
var _everyInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/every');
|
|
48
|
+
var _includesInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/includes');
|
|
49
|
+
var micromatch = require('micromatch');
|
|
50
|
+
var snakeCase = require('lodash/snakeCase');
|
|
44
51
|
var jsonschema = require('jsonschema');
|
|
45
52
|
require('cosmiconfig');
|
|
46
53
|
require('ts-deepmerge');
|
|
54
|
+
require('lodash');
|
|
47
55
|
|
|
48
56
|
function _interopDefault (e) { return e && e.__esModule ? e : { 'default': e }; }
|
|
49
57
|
|
|
@@ -70,6 +78,13 @@ var fs__default$1 = /*#__PURE__*/_interopDefault(fs$1);
|
|
|
70
78
|
var _findInstanceProperty__default = /*#__PURE__*/_interopDefault(_findInstanceProperty);
|
|
71
79
|
var _JSON$stringify__default = /*#__PURE__*/_interopDefault(_JSON$stringify);
|
|
72
80
|
var _sliceInstanceProperty__default = /*#__PURE__*/_interopDefault(_sliceInstanceProperty);
|
|
81
|
+
var _startsWithInstanceProperty__default = /*#__PURE__*/_interopDefault(_startsWithInstanceProperty);
|
|
82
|
+
var _trimInstanceProperty__default = /*#__PURE__*/_interopDefault(_trimInstanceProperty);
|
|
83
|
+
var _someInstanceProperty__default = /*#__PURE__*/_interopDefault(_someInstanceProperty);
|
|
84
|
+
var _everyInstanceProperty__default = /*#__PURE__*/_interopDefault(_everyInstanceProperty);
|
|
85
|
+
var _includesInstanceProperty__default = /*#__PURE__*/_interopDefault(_includesInstanceProperty);
|
|
86
|
+
var micromatch__default = /*#__PURE__*/_interopDefault(micromatch);
|
|
87
|
+
var snakeCase__default = /*#__PURE__*/_interopDefault(snakeCase);
|
|
73
88
|
|
|
74
89
|
function getApplicationDirectory(cwd) {
|
|
75
90
|
return fs__default["default"].realpathSync(cwd);
|
|
@@ -611,7 +626,7 @@ async function compileEnvironmentApplicationIndexes(_ref3) {
|
|
|
611
626
|
throw new Error(moveResult.stderr);
|
|
612
627
|
}
|
|
613
628
|
}
|
|
614
|
-
async function command$
|
|
629
|
+
async function command$4(cliFlags, cwd) {
|
|
615
630
|
var _context3;
|
|
616
631
|
const storageBucketConfig = await storageBucketsConfig.loadStorageBucketsConfig();
|
|
617
632
|
const applicationDirectory = getApplicationDirectory(cwd);
|
|
@@ -784,7 +799,7 @@ const mapApplicationMenuConfigToGraqhQLMenuJson = config => {
|
|
|
784
799
|
shouldRenderDivider: (_menuLinks$shouldRend = menuLinks.shouldRenderDivider) !== null && _menuLinks$shouldRend !== void 0 ? _menuLinks$shouldRend : false
|
|
785
800
|
};
|
|
786
801
|
};
|
|
787
|
-
async function command$
|
|
802
|
+
async function command$3(cliFlags, cwd) {
|
|
788
803
|
const applicationDirectory = getApplicationDirectory(cwd);
|
|
789
804
|
const monorepoRoot = findRoot.findRootSync(cwd);
|
|
790
805
|
const dotenvPath = cliFlags.dotenvFolder && path__default["default"].join(monorepoRoot.rootDir, cliFlags.dotenvFolder);
|
|
@@ -815,7 +830,7 @@ async function command$2(cliFlags, cwd) {
|
|
|
815
830
|
});
|
|
816
831
|
}
|
|
817
832
|
|
|
818
|
-
async function command$
|
|
833
|
+
async function command$2(cliFlags) {
|
|
819
834
|
const numberOfRollbacks = cliFlags.rollbacks - 1;
|
|
820
835
|
let nextRollbacks;
|
|
821
836
|
try {
|
|
@@ -851,6 +866,158 @@ async function command$1(cliFlags) {
|
|
|
851
866
|
}
|
|
852
867
|
}
|
|
853
868
|
|
|
869
|
+
/**
|
|
870
|
+
* This is heavily inspired by https://circleci.com/developer/orbs/orb/circleci/path-filtering.
|
|
871
|
+
*
|
|
872
|
+
* It detects changed files between `HEAD` and a base revision.
|
|
873
|
+
* To match them against configured RegEx tr
|
|
874
|
+
* All matched triggers will be written as a dotenv file.
|
|
875
|
+
* The dotenv file is read in a CircleCI step and be evaluated.
|
|
876
|
+
*/
|
|
877
|
+
const git = {
|
|
878
|
+
// https://git-scm.com/docs/git-merge-base
|
|
879
|
+
base: (baseBranch, headRevision) => {
|
|
880
|
+
var _context;
|
|
881
|
+
return _concatInstanceProperty__default["default"](_context = "git merge-base ".concat(baseBranch, " ")).call(_context, headRevision);
|
|
882
|
+
},
|
|
883
|
+
// https://git-scm.com/docs/git-diff
|
|
884
|
+
changedFiles: (mergeRevision, headRevision) => {
|
|
885
|
+
var _context2;
|
|
886
|
+
return _concatInstanceProperty__default["default"](_context2 = "git diff --name-only ".concat(mergeRevision, " ")).call(_context2, headRevision);
|
|
887
|
+
},
|
|
888
|
+
commitMessage: headRevision => "git log --format=oneline -n 1 ".concat(headRevision)
|
|
889
|
+
};
|
|
890
|
+
const helpers = {
|
|
891
|
+
async writeOutDotEnvFile(cliFlags, cwd, matchingTriggers) {
|
|
892
|
+
var _context3;
|
|
893
|
+
// If desired read the env file and write out the matching triggers.
|
|
894
|
+
if (!cliFlags.outEnvFile) {
|
|
895
|
+
return;
|
|
896
|
+
}
|
|
897
|
+
const filePath = path__default$1["default"].join(fs__default["default"].realpathSync(cwd), cliFlags.outEnvFile);
|
|
898
|
+
const fileContents = _mapInstanceProperty__default["default"](_context3 = _Object$entries__default["default"](matchingTriggers)).call(_context3, _ref => {
|
|
899
|
+
var _context5;
|
|
900
|
+
let _ref2 = _slicedToArray(_ref, 2),
|
|
901
|
+
triggerName = _ref2[0],
|
|
902
|
+
triggerValue = _ref2[1];
|
|
903
|
+
const triggerNameForEnvFile = "".concat(snakeCase__default["default"](triggerName).toUpperCase());
|
|
904
|
+
|
|
905
|
+
// General pipeline optimization hints are not transformed
|
|
906
|
+
if (_startsWithInstanceProperty__default["default"](triggerName).call(triggerName, 'allowPipelineOptimizations')) {
|
|
907
|
+
var _context4;
|
|
908
|
+
return _concatInstanceProperty__default["default"](_context4 = "".concat(triggerNameForEnvFile, "=")).call(_context4, triggerValue);
|
|
909
|
+
}
|
|
910
|
+
return _concatInstanceProperty__default["default"](_context5 = "DID_".concat(triggerNameForEnvFile, "_CHANGE=")).call(_context5, triggerValue);
|
|
911
|
+
}).join('\n');
|
|
912
|
+
await fs__default["default"].promises.writeFile(filePath, fileContents);
|
|
913
|
+
if (!cliFlags.silent) {
|
|
914
|
+
console.log("\uD83D\uDCDD Wrote out file to '".concat(filePath, "' with contents:"));
|
|
915
|
+
console.log(fileContents);
|
|
916
|
+
}
|
|
917
|
+
},
|
|
918
|
+
async getChangedFiles(cliFlags) {
|
|
919
|
+
var _context6, _context7;
|
|
920
|
+
const baseCmdResult = await execa.command(git.base(cliFlags.baseBranch, cliFlags.headRevision));
|
|
921
|
+
const mergeRevision = baseCmdResult.stdout;
|
|
922
|
+
const changedFilesCmdResult = await execa.command(git.changedFiles(mergeRevision, cliFlags.headRevision));
|
|
923
|
+
const changedFiles = _filterInstanceProperty__default["default"](_context6 = _mapInstanceProperty__default["default"](_context7 = changedFilesCmdResult.stdout.split('\n')).call(_context7, filePath => _trimInstanceProperty__default["default"](filePath).call(filePath))).call(_context6, filePath => filePath.length > 0);
|
|
924
|
+
return changedFiles;
|
|
925
|
+
},
|
|
926
|
+
async matchTriggersAgainstChangedFiles(cliFlags, config, changedFiles) {
|
|
927
|
+
const matchedTriggers = {};
|
|
928
|
+
|
|
929
|
+
// Evaluate each trigger against each file.
|
|
930
|
+
_forEachInstanceProperty__default["default"](config).call(config, async trigger => {
|
|
931
|
+
var _trigger$exclude;
|
|
932
|
+
const hasTriggerBeenInitialized = typeof matchedTriggers[trigger.name] === 'number';
|
|
933
|
+
|
|
934
|
+
// Given the trigger with this name was never evaluated it has to be defaulted to 0.
|
|
935
|
+
// As without any matches we should indicate nothing changed.
|
|
936
|
+
if (!hasTriggerBeenInitialized) {
|
|
937
|
+
matchedTriggers[trigger.name] = 0;
|
|
938
|
+
}
|
|
939
|
+
// Given the trigger was already evaluated to be positive we can skip this evaluation.
|
|
940
|
+
if (matchedTriggers[trigger.name] === 1) {
|
|
941
|
+
return matchedTriggers;
|
|
942
|
+
}
|
|
943
|
+
|
|
944
|
+
// In any other case we evaluate this trigger.
|
|
945
|
+
const anyFileChangedForTrigger = _someInstanceProperty__default["default"](micromatch__default["default"]).call(micromatch__default["default"], changedFiles, trigger.include, {
|
|
946
|
+
ignore: trigger.ignore
|
|
947
|
+
});
|
|
948
|
+
if (!cliFlags.silent && anyFileChangedForTrigger) {
|
|
949
|
+
console.log("\u2139\uFE0F Files for trigger ".concat(trigger.name, " changed."));
|
|
950
|
+
}
|
|
951
|
+
let onlyExcludedFilesChangedForTrigger = false;
|
|
952
|
+
if (((_trigger$exclude = trigger.exclude) === null || _trigger$exclude === void 0 ? void 0 : _trigger$exclude.length) > 0) {
|
|
953
|
+
// NOTE: `micromatch.every` evaluates if every file matches
|
|
954
|
+
// every pattern.
|
|
955
|
+
// We need to evaluate if every file matches some pattern.
|
|
956
|
+
onlyExcludedFilesChangedForTrigger = _everyInstanceProperty__default["default"](changedFiles).call(changedFiles, changedFile => {
|
|
957
|
+
return micromatch__default["default"].isMatch(changedFile, trigger.exclude, {
|
|
958
|
+
ignore: trigger.ignore
|
|
959
|
+
});
|
|
960
|
+
});
|
|
961
|
+
}
|
|
962
|
+
if (!cliFlags.silent && onlyExcludedFilesChangedForTrigger) {
|
|
963
|
+
console.log("\u2139\uFE0F Only excluded files for trigger ".concat(trigger.name, " changed."));
|
|
964
|
+
}
|
|
965
|
+
if (onlyExcludedFilesChangedForTrigger) {
|
|
966
|
+
matchedTriggers[trigger.name] = 0;
|
|
967
|
+
} else {
|
|
968
|
+
matchedTriggers[trigger.name] = Number(anyFileChangedForTrigger);
|
|
969
|
+
}
|
|
970
|
+
return matchedTriggers;
|
|
971
|
+
});
|
|
972
|
+
return matchedTriggers;
|
|
973
|
+
}
|
|
974
|
+
};
|
|
975
|
+
async function command$1(cliFlags, config, cwd) {
|
|
976
|
+
const enablePipelineOptimizations = process.env.ENABLE_PIPELINE_OPTIMIZATIONS === '1';
|
|
977
|
+
const isDevelopmentBranch = cliFlags.branch !== cliFlags.baseBranch;
|
|
978
|
+
const triggersContainingSharedFiles = _filterInstanceProperty__default["default"](config).call(config, trigger => trigger.containsSharedFiles);
|
|
979
|
+
if (!cliFlags.silent) {
|
|
980
|
+
var _context8;
|
|
981
|
+
console.log("\u2139\uFE0F Pipeline optimizations are ".concat(enablePipelineOptimizations ? 'enabled' : 'disabled', "."));
|
|
982
|
+
console.log("\u2139\uFE0F Changes have been commited to the ".concat(isDevelopmentBranch ? 'a development' : 'the main', " branch."));
|
|
983
|
+
console.log(_concatInstanceProperty__default["default"](_context8 = "\uD83D\uDEA7 Comparing '".concat(cliFlags.baseBranch, "' against '")).call(_context8, cliFlags.headRevision, "' to determine changed files."));
|
|
984
|
+
}
|
|
985
|
+
|
|
986
|
+
// Collect and parse changed files from git comparing base and head revision.
|
|
987
|
+
const changedFiles = await helpers.getChangedFiles(cliFlags);
|
|
988
|
+
if (!cliFlags.silent) {
|
|
989
|
+
if (changedFiles.length === 0) {
|
|
990
|
+
console.log("\u2139\uFE0F No changes found.");
|
|
991
|
+
} else {
|
|
992
|
+
console.log("\u2139\uFE0F ".concat(changedFiles.length, " changes found."));
|
|
993
|
+
}
|
|
994
|
+
}
|
|
995
|
+
|
|
996
|
+
// Read the trigger file to match the changed files against.
|
|
997
|
+
const matchedTriggers = await helpers.matchTriggersAgainstChangedFiles(cliFlags, config, changedFiles);
|
|
998
|
+
const commitMessageCmdResult = await execa.command(git.commitMessage(cliFlags.headRevision));
|
|
999
|
+
const commitMessage = commitMessageCmdResult.stdout;
|
|
1000
|
+
const hasCommitMessageTrigger = commitMessage && _includesInstanceProperty__default["default"](commitMessage).call(commitMessage, '[ci all]');
|
|
1001
|
+
const doesSharedTriggerMatch = _someInstanceProperty__default["default"](triggersContainingSharedFiles).call(triggersContainingSharedFiles, triggerContainingSharedFiles => matchedTriggers[triggerContainingSharedFiles.name] === 1);
|
|
1002
|
+
if (!cliFlags.silent) {
|
|
1003
|
+
console.log("\u2139\uFE0F The git commit message ".concat(hasCommitMessageTrigger ? 'does' : 'does not', " contain a [ci all] trigger."));
|
|
1004
|
+
}
|
|
1005
|
+
const doesPackageFolderTriggerMatch = matchedTriggers[cliFlags.triggerName] === 1;
|
|
1006
|
+
if (enablePipelineOptimizations && isDevelopmentBranch && !hasCommitMessageTrigger && !doesSharedTriggerMatch && !doesPackageFolderTriggerMatch) {
|
|
1007
|
+
if (!cliFlags.silent) {
|
|
1008
|
+
console.log("\u2139\uFE0F No relevant changes found for ".concat(cliFlags.triggerName, "."));
|
|
1009
|
+
}
|
|
1010
|
+
matchedTriggers['allowPipelineOptimizationsForTrigger'] = 1;
|
|
1011
|
+
} else {
|
|
1012
|
+
if (!cliFlags.silent) {
|
|
1013
|
+
console.log("\u2139\uFE0F Relevant changes found for ".concat(cliFlags.triggerName, "."));
|
|
1014
|
+
}
|
|
1015
|
+
matchedTriggers['allowPipelineOptimizationsForTrigger'] = 0;
|
|
1016
|
+
}
|
|
1017
|
+
await helpers.writeOutDotEnvFile(cliFlags, cwd, matchedTriggers);
|
|
1018
|
+
return matchedTriggers;
|
|
1019
|
+
}
|
|
1020
|
+
|
|
854
1021
|
function ownKeys(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; }
|
|
855
1022
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var _context, _context2; var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? _forEachInstanceProperty__default["default"](_context = ownKeys(Object(t), !0)).call(_context, function (r) { _defineProperty(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors__default["default"] ? _Object$defineProperties__default["default"](e, _Object$getOwnPropertyDescriptors__default["default"](t)) : _forEachInstanceProperty__default["default"](_context2 = ownKeys(Object(t))).call(_context2, function (r) { _Object$defineProperty__default["default"](e, r, _Object$getOwnPropertyDescriptor__default["default"](t, r)); }); } return e; }
|
|
856
1023
|
const baseMenuProperties = {
|
|
@@ -971,7 +1138,7 @@ async function command(cliFlags) {
|
|
|
971
1138
|
|
|
972
1139
|
var pkgJson = {
|
|
973
1140
|
name: "@commercetools-frontend/application-cli",
|
|
974
|
-
version: "2.
|
|
1141
|
+
version: "2.5.0",
|
|
975
1142
|
description: "Internal CLI to manage Merchant Center application deployments across various environments.",
|
|
976
1143
|
keywords: [
|
|
977
1144
|
"commercetools",
|
|
@@ -1006,11 +1173,15 @@ var pkgJson = {
|
|
|
1006
1173
|
execa: "5.1.1",
|
|
1007
1174
|
jsonschema: "^1.4.1",
|
|
1008
1175
|
listr2: "8.2.0",
|
|
1176
|
+
lodash: "4.17.21",
|
|
1177
|
+
micromatch: "4.0.5",
|
|
1009
1178
|
"node-fetch": "2.7.0",
|
|
1010
1179
|
"ts-deepmerge": "7.0.0"
|
|
1011
1180
|
},
|
|
1012
1181
|
devDependencies: {
|
|
1013
1182
|
"@tsconfig/node20": "20.1.4",
|
|
1183
|
+
"@types/lodash": "^4.14.198",
|
|
1184
|
+
"@types/micromatch": "4.0.6",
|
|
1014
1185
|
"@types/node": "20.12.7",
|
|
1015
1186
|
typescript: "5.2.2"
|
|
1016
1187
|
},
|
|
@@ -1052,11 +1223,11 @@ const run = async () => {
|
|
|
1052
1223
|
}).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`.', {
|
|
1053
1224
|
default: false
|
|
1054
1225
|
}).action(async options => {
|
|
1055
|
-
await command$
|
|
1226
|
+
await command$4(options, cwd);
|
|
1056
1227
|
});
|
|
1057
1228
|
const usageCompileMenu = 'Compile the menu links of an application into a `menu.json`. This is only required for internal applications';
|
|
1058
1229
|
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 => {
|
|
1059
|
-
await command$
|
|
1230
|
+
await command$3(options, cwd);
|
|
1060
1231
|
});
|
|
1061
1232
|
const usageValidateMenu = 'Validate compiled `menu.json` file';
|
|
1062
1233
|
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 => {
|
|
@@ -1066,7 +1237,20 @@ const run = async () => {
|
|
|
1066
1237
|
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', {
|
|
1067
1238
|
default: 15
|
|
1068
1239
|
}).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 => {
|
|
1069
|
-
await command$
|
|
1240
|
+
await command$2(options);
|
|
1241
|
+
});
|
|
1242
|
+
|
|
1243
|
+
// Command: Evaluate change triggers
|
|
1244
|
+
const usageEvaluateChangeTriggers = 'Evaluates changed files against a base and evaluates them against defined triggers.';
|
|
1245
|
+
cli.command('evaluate-change-triggers', usageEvaluateChangeTriggers).usage("evaluate-change-triggers \n\n ".concat(usageEvaluateChangeTriggers)).option('--branch <string>', 'The branch of the pull request', {
|
|
1246
|
+
default: process.env.CIRCLE_BRANCH
|
|
1247
|
+
}).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', {
|
|
1248
|
+
default: process.env.CIRCLE_SHA1
|
|
1249
|
+
}).option('--trigger-name <string>', 'The trigger to evaluate for.').option('--silent', '(optional) Disable logging', {
|
|
1250
|
+
default: false
|
|
1251
|
+
}).option('--out-env-file [string]', '(optional) A file path where the matched triggers are written as a dotenv file.').action(async options => {
|
|
1252
|
+
const config = await storageBucketsConfig.loadConfig('circleci-change-triggers', []);
|
|
1253
|
+
await command$1(options, config, cwd);
|
|
1070
1254
|
});
|
|
1071
1255
|
cli.help();
|
|
1072
1256
|
cli.version(pkgJson.version);
|
|
@@ -18,7 +18,7 @@ var _mapInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instan
|
|
|
18
18
|
var _Object$entries = require('@babel/runtime-corejs3/core-js-stable/object/entries');
|
|
19
19
|
var _Set = require('@babel/runtime-corejs3/core-js-stable/set');
|
|
20
20
|
var _flatMapInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/flat-map');
|
|
21
|
-
var storageBucketsConfig = require('../../dist/storage-buckets-config-
|
|
21
|
+
var storageBucketsConfig = require('../../dist/storage-buckets-config-0a380c12.cjs.prod.js');
|
|
22
22
|
var fs = require('node:fs');
|
|
23
23
|
var path$1 = require('node:path');
|
|
24
24
|
var listr2 = require('listr2');
|
|
@@ -41,9 +41,17 @@ var _JSON$stringify = require('@babel/runtime-corejs3/core-js-stable/json/string
|
|
|
41
41
|
var applicationConfig = require('@commercetools-frontend/application-config');
|
|
42
42
|
var l10n = require('@commercetools-frontend/l10n');
|
|
43
43
|
var _sliceInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/slice');
|
|
44
|
+
var _startsWithInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/starts-with');
|
|
45
|
+
var _trimInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/trim');
|
|
46
|
+
var _someInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/some');
|
|
47
|
+
var _everyInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/every');
|
|
48
|
+
var _includesInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/includes');
|
|
49
|
+
var micromatch = require('micromatch');
|
|
50
|
+
var snakeCase = require('lodash/snakeCase');
|
|
44
51
|
var jsonschema = require('jsonschema');
|
|
45
52
|
require('cosmiconfig');
|
|
46
53
|
require('ts-deepmerge');
|
|
54
|
+
require('lodash');
|
|
47
55
|
|
|
48
56
|
function _interopDefault (e) { return e && e.__esModule ? e : { 'default': e }; }
|
|
49
57
|
|
|
@@ -70,6 +78,13 @@ var fs__default$1 = /*#__PURE__*/_interopDefault(fs$1);
|
|
|
70
78
|
var _findInstanceProperty__default = /*#__PURE__*/_interopDefault(_findInstanceProperty);
|
|
71
79
|
var _JSON$stringify__default = /*#__PURE__*/_interopDefault(_JSON$stringify);
|
|
72
80
|
var _sliceInstanceProperty__default = /*#__PURE__*/_interopDefault(_sliceInstanceProperty);
|
|
81
|
+
var _startsWithInstanceProperty__default = /*#__PURE__*/_interopDefault(_startsWithInstanceProperty);
|
|
82
|
+
var _trimInstanceProperty__default = /*#__PURE__*/_interopDefault(_trimInstanceProperty);
|
|
83
|
+
var _someInstanceProperty__default = /*#__PURE__*/_interopDefault(_someInstanceProperty);
|
|
84
|
+
var _everyInstanceProperty__default = /*#__PURE__*/_interopDefault(_everyInstanceProperty);
|
|
85
|
+
var _includesInstanceProperty__default = /*#__PURE__*/_interopDefault(_includesInstanceProperty);
|
|
86
|
+
var micromatch__default = /*#__PURE__*/_interopDefault(micromatch);
|
|
87
|
+
var snakeCase__default = /*#__PURE__*/_interopDefault(snakeCase);
|
|
73
88
|
|
|
74
89
|
function getApplicationDirectory(cwd) {
|
|
75
90
|
return fs__default["default"].realpathSync(cwd);
|
|
@@ -611,7 +626,7 @@ async function compileEnvironmentApplicationIndexes(_ref3) {
|
|
|
611
626
|
throw new Error(moveResult.stderr);
|
|
612
627
|
}
|
|
613
628
|
}
|
|
614
|
-
async function command$
|
|
629
|
+
async function command$4(cliFlags, cwd) {
|
|
615
630
|
var _context3;
|
|
616
631
|
const storageBucketConfig = await storageBucketsConfig.loadStorageBucketsConfig();
|
|
617
632
|
const applicationDirectory = getApplicationDirectory(cwd);
|
|
@@ -784,7 +799,7 @@ const mapApplicationMenuConfigToGraqhQLMenuJson = config => {
|
|
|
784
799
|
shouldRenderDivider: (_menuLinks$shouldRend = menuLinks.shouldRenderDivider) !== null && _menuLinks$shouldRend !== void 0 ? _menuLinks$shouldRend : false
|
|
785
800
|
};
|
|
786
801
|
};
|
|
787
|
-
async function command$
|
|
802
|
+
async function command$3(cliFlags, cwd) {
|
|
788
803
|
const applicationDirectory = getApplicationDirectory(cwd);
|
|
789
804
|
const monorepoRoot = findRoot.findRootSync(cwd);
|
|
790
805
|
const dotenvPath = cliFlags.dotenvFolder && path__default["default"].join(monorepoRoot.rootDir, cliFlags.dotenvFolder);
|
|
@@ -815,7 +830,7 @@ async function command$2(cliFlags, cwd) {
|
|
|
815
830
|
});
|
|
816
831
|
}
|
|
817
832
|
|
|
818
|
-
async function command$
|
|
833
|
+
async function command$2(cliFlags) {
|
|
819
834
|
const numberOfRollbacks = cliFlags.rollbacks - 1;
|
|
820
835
|
let nextRollbacks;
|
|
821
836
|
try {
|
|
@@ -851,6 +866,158 @@ async function command$1(cliFlags) {
|
|
|
851
866
|
}
|
|
852
867
|
}
|
|
853
868
|
|
|
869
|
+
/**
|
|
870
|
+
* This is heavily inspired by https://circleci.com/developer/orbs/orb/circleci/path-filtering.
|
|
871
|
+
*
|
|
872
|
+
* It detects changed files between `HEAD` and a base revision.
|
|
873
|
+
* To match them against configured RegEx tr
|
|
874
|
+
* All matched triggers will be written as a dotenv file.
|
|
875
|
+
* The dotenv file is read in a CircleCI step and be evaluated.
|
|
876
|
+
*/
|
|
877
|
+
const git = {
|
|
878
|
+
// https://git-scm.com/docs/git-merge-base
|
|
879
|
+
base: (baseBranch, headRevision) => {
|
|
880
|
+
var _context;
|
|
881
|
+
return _concatInstanceProperty__default["default"](_context = "git merge-base ".concat(baseBranch, " ")).call(_context, headRevision);
|
|
882
|
+
},
|
|
883
|
+
// https://git-scm.com/docs/git-diff
|
|
884
|
+
changedFiles: (mergeRevision, headRevision) => {
|
|
885
|
+
var _context2;
|
|
886
|
+
return _concatInstanceProperty__default["default"](_context2 = "git diff --name-only ".concat(mergeRevision, " ")).call(_context2, headRevision);
|
|
887
|
+
},
|
|
888
|
+
commitMessage: headRevision => "git log --format=oneline -n 1 ".concat(headRevision)
|
|
889
|
+
};
|
|
890
|
+
const helpers = {
|
|
891
|
+
async writeOutDotEnvFile(cliFlags, cwd, matchingTriggers) {
|
|
892
|
+
var _context3;
|
|
893
|
+
// If desired read the env file and write out the matching triggers.
|
|
894
|
+
if (!cliFlags.outEnvFile) {
|
|
895
|
+
return;
|
|
896
|
+
}
|
|
897
|
+
const filePath = path__default$1["default"].join(fs__default["default"].realpathSync(cwd), cliFlags.outEnvFile);
|
|
898
|
+
const fileContents = _mapInstanceProperty__default["default"](_context3 = _Object$entries__default["default"](matchingTriggers)).call(_context3, _ref => {
|
|
899
|
+
var _context5;
|
|
900
|
+
let _ref2 = _slicedToArray(_ref, 2),
|
|
901
|
+
triggerName = _ref2[0],
|
|
902
|
+
triggerValue = _ref2[1];
|
|
903
|
+
const triggerNameForEnvFile = "".concat(snakeCase__default["default"](triggerName).toUpperCase());
|
|
904
|
+
|
|
905
|
+
// General pipeline optimization hints are not transformed
|
|
906
|
+
if (_startsWithInstanceProperty__default["default"](triggerName).call(triggerName, 'allowPipelineOptimizations')) {
|
|
907
|
+
var _context4;
|
|
908
|
+
return _concatInstanceProperty__default["default"](_context4 = "".concat(triggerNameForEnvFile, "=")).call(_context4, triggerValue);
|
|
909
|
+
}
|
|
910
|
+
return _concatInstanceProperty__default["default"](_context5 = "DID_".concat(triggerNameForEnvFile, "_CHANGE=")).call(_context5, triggerValue);
|
|
911
|
+
}).join('\n');
|
|
912
|
+
await fs__default["default"].promises.writeFile(filePath, fileContents);
|
|
913
|
+
if (!cliFlags.silent) {
|
|
914
|
+
console.log("\uD83D\uDCDD Wrote out file to '".concat(filePath, "' with contents:"));
|
|
915
|
+
console.log(fileContents);
|
|
916
|
+
}
|
|
917
|
+
},
|
|
918
|
+
async getChangedFiles(cliFlags) {
|
|
919
|
+
var _context6, _context7;
|
|
920
|
+
const baseCmdResult = await execa.command(git.base(cliFlags.baseBranch, cliFlags.headRevision));
|
|
921
|
+
const mergeRevision = baseCmdResult.stdout;
|
|
922
|
+
const changedFilesCmdResult = await execa.command(git.changedFiles(mergeRevision, cliFlags.headRevision));
|
|
923
|
+
const changedFiles = _filterInstanceProperty__default["default"](_context6 = _mapInstanceProperty__default["default"](_context7 = changedFilesCmdResult.stdout.split('\n')).call(_context7, filePath => _trimInstanceProperty__default["default"](filePath).call(filePath))).call(_context6, filePath => filePath.length > 0);
|
|
924
|
+
return changedFiles;
|
|
925
|
+
},
|
|
926
|
+
async matchTriggersAgainstChangedFiles(cliFlags, config, changedFiles) {
|
|
927
|
+
const matchedTriggers = {};
|
|
928
|
+
|
|
929
|
+
// Evaluate each trigger against each file.
|
|
930
|
+
_forEachInstanceProperty__default["default"](config).call(config, async trigger => {
|
|
931
|
+
var _trigger$exclude;
|
|
932
|
+
const hasTriggerBeenInitialized = typeof matchedTriggers[trigger.name] === 'number';
|
|
933
|
+
|
|
934
|
+
// Given the trigger with this name was never evaluated it has to be defaulted to 0.
|
|
935
|
+
// As without any matches we should indicate nothing changed.
|
|
936
|
+
if (!hasTriggerBeenInitialized) {
|
|
937
|
+
matchedTriggers[trigger.name] = 0;
|
|
938
|
+
}
|
|
939
|
+
// Given the trigger was already evaluated to be positive we can skip this evaluation.
|
|
940
|
+
if (matchedTriggers[trigger.name] === 1) {
|
|
941
|
+
return matchedTriggers;
|
|
942
|
+
}
|
|
943
|
+
|
|
944
|
+
// In any other case we evaluate this trigger.
|
|
945
|
+
const anyFileChangedForTrigger = _someInstanceProperty__default["default"](micromatch__default["default"]).call(micromatch__default["default"], changedFiles, trigger.include, {
|
|
946
|
+
ignore: trigger.ignore
|
|
947
|
+
});
|
|
948
|
+
if (!cliFlags.silent && anyFileChangedForTrigger) {
|
|
949
|
+
console.log("\u2139\uFE0F Files for trigger ".concat(trigger.name, " changed."));
|
|
950
|
+
}
|
|
951
|
+
let onlyExcludedFilesChangedForTrigger = false;
|
|
952
|
+
if (((_trigger$exclude = trigger.exclude) === null || _trigger$exclude === void 0 ? void 0 : _trigger$exclude.length) > 0) {
|
|
953
|
+
// NOTE: `micromatch.every` evaluates if every file matches
|
|
954
|
+
// every pattern.
|
|
955
|
+
// We need to evaluate if every file matches some pattern.
|
|
956
|
+
onlyExcludedFilesChangedForTrigger = _everyInstanceProperty__default["default"](changedFiles).call(changedFiles, changedFile => {
|
|
957
|
+
return micromatch__default["default"].isMatch(changedFile, trigger.exclude, {
|
|
958
|
+
ignore: trigger.ignore
|
|
959
|
+
});
|
|
960
|
+
});
|
|
961
|
+
}
|
|
962
|
+
if (!cliFlags.silent && onlyExcludedFilesChangedForTrigger) {
|
|
963
|
+
console.log("\u2139\uFE0F Only excluded files for trigger ".concat(trigger.name, " changed."));
|
|
964
|
+
}
|
|
965
|
+
if (onlyExcludedFilesChangedForTrigger) {
|
|
966
|
+
matchedTriggers[trigger.name] = 0;
|
|
967
|
+
} else {
|
|
968
|
+
matchedTriggers[trigger.name] = Number(anyFileChangedForTrigger);
|
|
969
|
+
}
|
|
970
|
+
return matchedTriggers;
|
|
971
|
+
});
|
|
972
|
+
return matchedTriggers;
|
|
973
|
+
}
|
|
974
|
+
};
|
|
975
|
+
async function command$1(cliFlags, config, cwd) {
|
|
976
|
+
const enablePipelineOptimizations = process.env.ENABLE_PIPELINE_OPTIMIZATIONS === '1';
|
|
977
|
+
const isDevelopmentBranch = cliFlags.branch !== cliFlags.baseBranch;
|
|
978
|
+
const triggersContainingSharedFiles = _filterInstanceProperty__default["default"](config).call(config, trigger => trigger.containsSharedFiles);
|
|
979
|
+
if (!cliFlags.silent) {
|
|
980
|
+
var _context8;
|
|
981
|
+
console.log("\u2139\uFE0F Pipeline optimizations are ".concat(enablePipelineOptimizations ? 'enabled' : 'disabled', "."));
|
|
982
|
+
console.log("\u2139\uFE0F Changes have been commited to the ".concat(isDevelopmentBranch ? 'a development' : 'the main', " branch."));
|
|
983
|
+
console.log(_concatInstanceProperty__default["default"](_context8 = "\uD83D\uDEA7 Comparing '".concat(cliFlags.baseBranch, "' against '")).call(_context8, cliFlags.headRevision, "' to determine changed files."));
|
|
984
|
+
}
|
|
985
|
+
|
|
986
|
+
// Collect and parse changed files from git comparing base and head revision.
|
|
987
|
+
const changedFiles = await helpers.getChangedFiles(cliFlags);
|
|
988
|
+
if (!cliFlags.silent) {
|
|
989
|
+
if (changedFiles.length === 0) {
|
|
990
|
+
console.log("\u2139\uFE0F No changes found.");
|
|
991
|
+
} else {
|
|
992
|
+
console.log("\u2139\uFE0F ".concat(changedFiles.length, " changes found."));
|
|
993
|
+
}
|
|
994
|
+
}
|
|
995
|
+
|
|
996
|
+
// Read the trigger file to match the changed files against.
|
|
997
|
+
const matchedTriggers = await helpers.matchTriggersAgainstChangedFiles(cliFlags, config, changedFiles);
|
|
998
|
+
const commitMessageCmdResult = await execa.command(git.commitMessage(cliFlags.headRevision));
|
|
999
|
+
const commitMessage = commitMessageCmdResult.stdout;
|
|
1000
|
+
const hasCommitMessageTrigger = commitMessage && _includesInstanceProperty__default["default"](commitMessage).call(commitMessage, '[ci all]');
|
|
1001
|
+
const doesSharedTriggerMatch = _someInstanceProperty__default["default"](triggersContainingSharedFiles).call(triggersContainingSharedFiles, triggerContainingSharedFiles => matchedTriggers[triggerContainingSharedFiles.name] === 1);
|
|
1002
|
+
if (!cliFlags.silent) {
|
|
1003
|
+
console.log("\u2139\uFE0F The git commit message ".concat(hasCommitMessageTrigger ? 'does' : 'does not', " contain a [ci all] trigger."));
|
|
1004
|
+
}
|
|
1005
|
+
const doesPackageFolderTriggerMatch = matchedTriggers[cliFlags.triggerName] === 1;
|
|
1006
|
+
if (enablePipelineOptimizations && isDevelopmentBranch && !hasCommitMessageTrigger && !doesSharedTriggerMatch && !doesPackageFolderTriggerMatch) {
|
|
1007
|
+
if (!cliFlags.silent) {
|
|
1008
|
+
console.log("\u2139\uFE0F No relevant changes found for ".concat(cliFlags.triggerName, "."));
|
|
1009
|
+
}
|
|
1010
|
+
matchedTriggers['allowPipelineOptimizationsForTrigger'] = 1;
|
|
1011
|
+
} else {
|
|
1012
|
+
if (!cliFlags.silent) {
|
|
1013
|
+
console.log("\u2139\uFE0F Relevant changes found for ".concat(cliFlags.triggerName, "."));
|
|
1014
|
+
}
|
|
1015
|
+
matchedTriggers['allowPipelineOptimizationsForTrigger'] = 0;
|
|
1016
|
+
}
|
|
1017
|
+
await helpers.writeOutDotEnvFile(cliFlags, cwd, matchedTriggers);
|
|
1018
|
+
return matchedTriggers;
|
|
1019
|
+
}
|
|
1020
|
+
|
|
854
1021
|
function ownKeys(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; }
|
|
855
1022
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var _context, _context2; var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? _forEachInstanceProperty__default["default"](_context = ownKeys(Object(t), !0)).call(_context, function (r) { _defineProperty(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors__default["default"] ? _Object$defineProperties__default["default"](e, _Object$getOwnPropertyDescriptors__default["default"](t)) : _forEachInstanceProperty__default["default"](_context2 = ownKeys(Object(t))).call(_context2, function (r) { _Object$defineProperty__default["default"](e, r, _Object$getOwnPropertyDescriptor__default["default"](t, r)); }); } return e; }
|
|
856
1023
|
const baseMenuProperties = {
|
|
@@ -971,7 +1138,7 @@ async function command(cliFlags) {
|
|
|
971
1138
|
|
|
972
1139
|
var pkgJson = {
|
|
973
1140
|
name: "@commercetools-frontend/application-cli",
|
|
974
|
-
version: "2.
|
|
1141
|
+
version: "2.5.0",
|
|
975
1142
|
description: "Internal CLI to manage Merchant Center application deployments across various environments.",
|
|
976
1143
|
keywords: [
|
|
977
1144
|
"commercetools",
|
|
@@ -1006,11 +1173,15 @@ var pkgJson = {
|
|
|
1006
1173
|
execa: "5.1.1",
|
|
1007
1174
|
jsonschema: "^1.4.1",
|
|
1008
1175
|
listr2: "8.2.0",
|
|
1176
|
+
lodash: "4.17.21",
|
|
1177
|
+
micromatch: "4.0.5",
|
|
1009
1178
|
"node-fetch": "2.7.0",
|
|
1010
1179
|
"ts-deepmerge": "7.0.0"
|
|
1011
1180
|
},
|
|
1012
1181
|
devDependencies: {
|
|
1013
1182
|
"@tsconfig/node20": "20.1.4",
|
|
1183
|
+
"@types/lodash": "^4.14.198",
|
|
1184
|
+
"@types/micromatch": "4.0.6",
|
|
1014
1185
|
"@types/node": "20.12.7",
|
|
1015
1186
|
typescript: "5.2.2"
|
|
1016
1187
|
},
|
|
@@ -1052,11 +1223,11 @@ const run = async () => {
|
|
|
1052
1223
|
}).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`.', {
|
|
1053
1224
|
default: false
|
|
1054
1225
|
}).action(async options => {
|
|
1055
|
-
await command$
|
|
1226
|
+
await command$4(options, cwd);
|
|
1056
1227
|
});
|
|
1057
1228
|
const usageCompileMenu = 'Compile the menu links of an application into a `menu.json`. This is only required for internal applications';
|
|
1058
1229
|
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 => {
|
|
1059
|
-
await command$
|
|
1230
|
+
await command$3(options, cwd);
|
|
1060
1231
|
});
|
|
1061
1232
|
const usageValidateMenu = 'Validate compiled `menu.json` file';
|
|
1062
1233
|
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 => {
|
|
@@ -1066,7 +1237,20 @@ const run = async () => {
|
|
|
1066
1237
|
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', {
|
|
1067
1238
|
default: 15
|
|
1068
1239
|
}).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 => {
|
|
1069
|
-
await command$
|
|
1240
|
+
await command$2(options);
|
|
1241
|
+
});
|
|
1242
|
+
|
|
1243
|
+
// Command: Evaluate change triggers
|
|
1244
|
+
const usageEvaluateChangeTriggers = 'Evaluates changed files against a base and evaluates them against defined triggers.';
|
|
1245
|
+
cli.command('evaluate-change-triggers', usageEvaluateChangeTriggers).usage("evaluate-change-triggers \n\n ".concat(usageEvaluateChangeTriggers)).option('--branch <string>', 'The branch of the pull request', {
|
|
1246
|
+
default: process.env.CIRCLE_BRANCH
|
|
1247
|
+
}).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', {
|
|
1248
|
+
default: process.env.CIRCLE_SHA1
|
|
1249
|
+
}).option('--trigger-name <string>', 'The trigger to evaluate for.').option('--silent', '(optional) Disable logging', {
|
|
1250
|
+
default: false
|
|
1251
|
+
}).option('--out-env-file [string]', '(optional) A file path where the matched triggers are written as a dotenv file.').action(async options => {
|
|
1252
|
+
const config = await storageBucketsConfig.loadConfig('circleci-change-triggers', []);
|
|
1253
|
+
await command$1(options, config, cwd);
|
|
1070
1254
|
});
|
|
1071
1255
|
cli.help();
|
|
1072
1256
|
cli.version(pkgJson.version);
|
|
@@ -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-
|
|
17
|
+
import { s as storageProviders, l as loadStorageBucketsConfig, c as clusterContexts, a as loadConfig } from '../../dist/storage-buckets-config-896b4064.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);
|
|
@@ -581,7 +589,7 @@ async function compileEnvironmentApplicationIndexes(_ref3) {
|
|
|
581
589
|
throw new Error(moveResult.stderr);
|
|
582
590
|
}
|
|
583
591
|
}
|
|
584
|
-
async function command$
|
|
592
|
+
async function command$4(cliFlags, cwd) {
|
|
585
593
|
var _context3;
|
|
586
594
|
const storageBucketConfig = await loadStorageBucketsConfig();
|
|
587
595
|
const applicationDirectory = getApplicationDirectory(cwd);
|
|
@@ -754,7 +762,7 @@ const mapApplicationMenuConfigToGraqhQLMenuJson = config => {
|
|
|
754
762
|
shouldRenderDivider: (_menuLinks$shouldRend = menuLinks.shouldRenderDivider) !== null && _menuLinks$shouldRend !== void 0 ? _menuLinks$shouldRend : false
|
|
755
763
|
};
|
|
756
764
|
};
|
|
757
|
-
async function command$
|
|
765
|
+
async function command$3(cliFlags, cwd) {
|
|
758
766
|
const applicationDirectory = getApplicationDirectory(cwd);
|
|
759
767
|
const monorepoRoot = findRootSync(cwd);
|
|
760
768
|
const dotenvPath = cliFlags.dotenvFolder && path.join(monorepoRoot.rootDir, cliFlags.dotenvFolder);
|
|
@@ -785,7 +793,7 @@ async function command$2(cliFlags, cwd) {
|
|
|
785
793
|
});
|
|
786
794
|
}
|
|
787
795
|
|
|
788
|
-
async function command$
|
|
796
|
+
async function command$2(cliFlags) {
|
|
789
797
|
const numberOfRollbacks = cliFlags.rollbacks - 1;
|
|
790
798
|
let nextRollbacks;
|
|
791
799
|
try {
|
|
@@ -821,6 +829,158 @@ async function command$1(cliFlags) {
|
|
|
821
829
|
}
|
|
822
830
|
}
|
|
823
831
|
|
|
832
|
+
/**
|
|
833
|
+
* This is heavily inspired by https://circleci.com/developer/orbs/orb/circleci/path-filtering.
|
|
834
|
+
*
|
|
835
|
+
* It detects changed files between `HEAD` and a base revision.
|
|
836
|
+
* To match them against configured RegEx tr
|
|
837
|
+
* All matched triggers will be written as a dotenv file.
|
|
838
|
+
* The dotenv file is read in a CircleCI step and be evaluated.
|
|
839
|
+
*/
|
|
840
|
+
const git = {
|
|
841
|
+
// https://git-scm.com/docs/git-merge-base
|
|
842
|
+
base: (baseBranch, headRevision) => {
|
|
843
|
+
var _context;
|
|
844
|
+
return _concatInstanceProperty(_context = "git merge-base ".concat(baseBranch, " ")).call(_context, headRevision);
|
|
845
|
+
},
|
|
846
|
+
// https://git-scm.com/docs/git-diff
|
|
847
|
+
changedFiles: (mergeRevision, headRevision) => {
|
|
848
|
+
var _context2;
|
|
849
|
+
return _concatInstanceProperty(_context2 = "git diff --name-only ".concat(mergeRevision, " ")).call(_context2, headRevision);
|
|
850
|
+
},
|
|
851
|
+
commitMessage: headRevision => "git log --format=oneline -n 1 ".concat(headRevision)
|
|
852
|
+
};
|
|
853
|
+
const helpers = {
|
|
854
|
+
async writeOutDotEnvFile(cliFlags, cwd, matchingTriggers) {
|
|
855
|
+
var _context3;
|
|
856
|
+
// If desired read the env file and write out the matching triggers.
|
|
857
|
+
if (!cliFlags.outEnvFile) {
|
|
858
|
+
return;
|
|
859
|
+
}
|
|
860
|
+
const filePath = path$1.join(fs.realpathSync(cwd), cliFlags.outEnvFile);
|
|
861
|
+
const fileContents = _mapInstanceProperty(_context3 = _Object$entries(matchingTriggers)).call(_context3, _ref => {
|
|
862
|
+
var _context5;
|
|
863
|
+
let _ref2 = _slicedToArray(_ref, 2),
|
|
864
|
+
triggerName = _ref2[0],
|
|
865
|
+
triggerValue = _ref2[1];
|
|
866
|
+
const triggerNameForEnvFile = "".concat(snakeCase(triggerName).toUpperCase());
|
|
867
|
+
|
|
868
|
+
// General pipeline optimization hints are not transformed
|
|
869
|
+
if (_startsWithInstanceProperty(triggerName).call(triggerName, 'allowPipelineOptimizations')) {
|
|
870
|
+
var _context4;
|
|
871
|
+
return _concatInstanceProperty(_context4 = "".concat(triggerNameForEnvFile, "=")).call(_context4, triggerValue);
|
|
872
|
+
}
|
|
873
|
+
return _concatInstanceProperty(_context5 = "DID_".concat(triggerNameForEnvFile, "_CHANGE=")).call(_context5, triggerValue);
|
|
874
|
+
}).join('\n');
|
|
875
|
+
await fs.promises.writeFile(filePath, fileContents);
|
|
876
|
+
if (!cliFlags.silent) {
|
|
877
|
+
console.log("\uD83D\uDCDD Wrote out file to '".concat(filePath, "' with contents:"));
|
|
878
|
+
console.log(fileContents);
|
|
879
|
+
}
|
|
880
|
+
},
|
|
881
|
+
async getChangedFiles(cliFlags) {
|
|
882
|
+
var _context6, _context7;
|
|
883
|
+
const baseCmdResult = await command$5(git.base(cliFlags.baseBranch, cliFlags.headRevision));
|
|
884
|
+
const mergeRevision = baseCmdResult.stdout;
|
|
885
|
+
const changedFilesCmdResult = await command$5(git.changedFiles(mergeRevision, cliFlags.headRevision));
|
|
886
|
+
const changedFiles = _filterInstanceProperty(_context6 = _mapInstanceProperty(_context7 = changedFilesCmdResult.stdout.split('\n')).call(_context7, filePath => _trimInstanceProperty(filePath).call(filePath))).call(_context6, filePath => filePath.length > 0);
|
|
887
|
+
return changedFiles;
|
|
888
|
+
},
|
|
889
|
+
async matchTriggersAgainstChangedFiles(cliFlags, config, changedFiles) {
|
|
890
|
+
const matchedTriggers = {};
|
|
891
|
+
|
|
892
|
+
// Evaluate each trigger against each file.
|
|
893
|
+
_forEachInstanceProperty(config).call(config, async trigger => {
|
|
894
|
+
var _trigger$exclude;
|
|
895
|
+
const hasTriggerBeenInitialized = typeof matchedTriggers[trigger.name] === 'number';
|
|
896
|
+
|
|
897
|
+
// Given the trigger with this name was never evaluated it has to be defaulted to 0.
|
|
898
|
+
// As without any matches we should indicate nothing changed.
|
|
899
|
+
if (!hasTriggerBeenInitialized) {
|
|
900
|
+
matchedTriggers[trigger.name] = 0;
|
|
901
|
+
}
|
|
902
|
+
// Given the trigger was already evaluated to be positive we can skip this evaluation.
|
|
903
|
+
if (matchedTriggers[trigger.name] === 1) {
|
|
904
|
+
return matchedTriggers;
|
|
905
|
+
}
|
|
906
|
+
|
|
907
|
+
// In any other case we evaluate this trigger.
|
|
908
|
+
const anyFileChangedForTrigger = _someInstanceProperty(micromatch).call(micromatch, changedFiles, trigger.include, {
|
|
909
|
+
ignore: trigger.ignore
|
|
910
|
+
});
|
|
911
|
+
if (!cliFlags.silent && anyFileChangedForTrigger) {
|
|
912
|
+
console.log("\u2139\uFE0F Files for trigger ".concat(trigger.name, " changed."));
|
|
913
|
+
}
|
|
914
|
+
let onlyExcludedFilesChangedForTrigger = false;
|
|
915
|
+
if (((_trigger$exclude = trigger.exclude) === null || _trigger$exclude === void 0 ? void 0 : _trigger$exclude.length) > 0) {
|
|
916
|
+
// NOTE: `micromatch.every` evaluates if every file matches
|
|
917
|
+
// every pattern.
|
|
918
|
+
// We need to evaluate if every file matches some pattern.
|
|
919
|
+
onlyExcludedFilesChangedForTrigger = _everyInstanceProperty(changedFiles).call(changedFiles, changedFile => {
|
|
920
|
+
return micromatch.isMatch(changedFile, trigger.exclude, {
|
|
921
|
+
ignore: trigger.ignore
|
|
922
|
+
});
|
|
923
|
+
});
|
|
924
|
+
}
|
|
925
|
+
if (!cliFlags.silent && onlyExcludedFilesChangedForTrigger) {
|
|
926
|
+
console.log("\u2139\uFE0F Only excluded files for trigger ".concat(trigger.name, " changed."));
|
|
927
|
+
}
|
|
928
|
+
if (onlyExcludedFilesChangedForTrigger) {
|
|
929
|
+
matchedTriggers[trigger.name] = 0;
|
|
930
|
+
} else {
|
|
931
|
+
matchedTriggers[trigger.name] = Number(anyFileChangedForTrigger);
|
|
932
|
+
}
|
|
933
|
+
return matchedTriggers;
|
|
934
|
+
});
|
|
935
|
+
return matchedTriggers;
|
|
936
|
+
}
|
|
937
|
+
};
|
|
938
|
+
async function command$1(cliFlags, config, cwd) {
|
|
939
|
+
const enablePipelineOptimizations = process.env.ENABLE_PIPELINE_OPTIMIZATIONS === '1';
|
|
940
|
+
const isDevelopmentBranch = cliFlags.branch !== cliFlags.baseBranch;
|
|
941
|
+
const triggersContainingSharedFiles = _filterInstanceProperty(config).call(config, trigger => trigger.containsSharedFiles);
|
|
942
|
+
if (!cliFlags.silent) {
|
|
943
|
+
var _context8;
|
|
944
|
+
console.log("\u2139\uFE0F Pipeline optimizations are ".concat(enablePipelineOptimizations ? 'enabled' : 'disabled', "."));
|
|
945
|
+
console.log("\u2139\uFE0F Changes have been commited to the ".concat(isDevelopmentBranch ? 'a development' : 'the main', " branch."));
|
|
946
|
+
console.log(_concatInstanceProperty(_context8 = "\uD83D\uDEA7 Comparing '".concat(cliFlags.baseBranch, "' against '")).call(_context8, cliFlags.headRevision, "' to determine changed files."));
|
|
947
|
+
}
|
|
948
|
+
|
|
949
|
+
// Collect and parse changed files from git comparing base and head revision.
|
|
950
|
+
const changedFiles = await helpers.getChangedFiles(cliFlags);
|
|
951
|
+
if (!cliFlags.silent) {
|
|
952
|
+
if (changedFiles.length === 0) {
|
|
953
|
+
console.log("\u2139\uFE0F No changes found.");
|
|
954
|
+
} else {
|
|
955
|
+
console.log("\u2139\uFE0F ".concat(changedFiles.length, " changes found."));
|
|
956
|
+
}
|
|
957
|
+
}
|
|
958
|
+
|
|
959
|
+
// Read the trigger file to match the changed files against.
|
|
960
|
+
const matchedTriggers = await helpers.matchTriggersAgainstChangedFiles(cliFlags, config, changedFiles);
|
|
961
|
+
const commitMessageCmdResult = await command$5(git.commitMessage(cliFlags.headRevision));
|
|
962
|
+
const commitMessage = commitMessageCmdResult.stdout;
|
|
963
|
+
const hasCommitMessageTrigger = commitMessage && _includesInstanceProperty(commitMessage).call(commitMessage, '[ci all]');
|
|
964
|
+
const doesSharedTriggerMatch = _someInstanceProperty(triggersContainingSharedFiles).call(triggersContainingSharedFiles, triggerContainingSharedFiles => matchedTriggers[triggerContainingSharedFiles.name] === 1);
|
|
965
|
+
if (!cliFlags.silent) {
|
|
966
|
+
console.log("\u2139\uFE0F The git commit message ".concat(hasCommitMessageTrigger ? 'does' : 'does not', " contain a [ci all] trigger."));
|
|
967
|
+
}
|
|
968
|
+
const doesPackageFolderTriggerMatch = matchedTriggers[cliFlags.triggerName] === 1;
|
|
969
|
+
if (enablePipelineOptimizations && isDevelopmentBranch && !hasCommitMessageTrigger && !doesSharedTriggerMatch && !doesPackageFolderTriggerMatch) {
|
|
970
|
+
if (!cliFlags.silent) {
|
|
971
|
+
console.log("\u2139\uFE0F No relevant changes found for ".concat(cliFlags.triggerName, "."));
|
|
972
|
+
}
|
|
973
|
+
matchedTriggers['allowPipelineOptimizationsForTrigger'] = 1;
|
|
974
|
+
} else {
|
|
975
|
+
if (!cliFlags.silent) {
|
|
976
|
+
console.log("\u2139\uFE0F Relevant changes found for ".concat(cliFlags.triggerName, "."));
|
|
977
|
+
}
|
|
978
|
+
matchedTriggers['allowPipelineOptimizationsForTrigger'] = 0;
|
|
979
|
+
}
|
|
980
|
+
await helpers.writeOutDotEnvFile(cliFlags, cwd, matchedTriggers);
|
|
981
|
+
return matchedTriggers;
|
|
982
|
+
}
|
|
983
|
+
|
|
824
984
|
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
985
|
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
986
|
const baseMenuProperties = {
|
|
@@ -941,7 +1101,7 @@ async function command(cliFlags) {
|
|
|
941
1101
|
|
|
942
1102
|
var pkgJson = {
|
|
943
1103
|
name: "@commercetools-frontend/application-cli",
|
|
944
|
-
version: "2.
|
|
1104
|
+
version: "2.5.0",
|
|
945
1105
|
description: "Internal CLI to manage Merchant Center application deployments across various environments.",
|
|
946
1106
|
keywords: [
|
|
947
1107
|
"commercetools",
|
|
@@ -976,11 +1136,15 @@ var pkgJson = {
|
|
|
976
1136
|
execa: "5.1.1",
|
|
977
1137
|
jsonschema: "^1.4.1",
|
|
978
1138
|
listr2: "8.2.0",
|
|
1139
|
+
lodash: "4.17.21",
|
|
1140
|
+
micromatch: "4.0.5",
|
|
979
1141
|
"node-fetch": "2.7.0",
|
|
980
1142
|
"ts-deepmerge": "7.0.0"
|
|
981
1143
|
},
|
|
982
1144
|
devDependencies: {
|
|
983
1145
|
"@tsconfig/node20": "20.1.4",
|
|
1146
|
+
"@types/lodash": "^4.14.198",
|
|
1147
|
+
"@types/micromatch": "4.0.6",
|
|
984
1148
|
"@types/node": "20.12.7",
|
|
985
1149
|
typescript: "5.2.2"
|
|
986
1150
|
},
|
|
@@ -1022,11 +1186,11 @@ const run = async () => {
|
|
|
1022
1186
|
}).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
1187
|
default: false
|
|
1024
1188
|
}).action(async options => {
|
|
1025
|
-
await command$
|
|
1189
|
+
await command$4(options, cwd);
|
|
1026
1190
|
});
|
|
1027
1191
|
const usageCompileMenu = 'Compile the menu links of an application into a `menu.json`. This is only required for internal applications';
|
|
1028
1192
|
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$
|
|
1193
|
+
await command$3(options, cwd);
|
|
1030
1194
|
});
|
|
1031
1195
|
const usageValidateMenu = 'Validate compiled `menu.json` file';
|
|
1032
1196
|
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 +1200,20 @@ const run = async () => {
|
|
|
1036
1200
|
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
1201
|
default: 15
|
|
1038
1202
|
}).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$
|
|
1203
|
+
await command$2(options);
|
|
1204
|
+
});
|
|
1205
|
+
|
|
1206
|
+
// Command: Evaluate change triggers
|
|
1207
|
+
const usageEvaluateChangeTriggers = 'Evaluates changed files against a base and evaluates them against defined triggers.';
|
|
1208
|
+
cli.command('evaluate-change-triggers', usageEvaluateChangeTriggers).usage("evaluate-change-triggers \n\n ".concat(usageEvaluateChangeTriggers)).option('--branch <string>', 'The branch of the pull request', {
|
|
1209
|
+
default: process.env.CIRCLE_BRANCH
|
|
1210
|
+
}).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', {
|
|
1211
|
+
default: process.env.CIRCLE_SHA1
|
|
1212
|
+
}).option('--trigger-name <string>', 'The trigger to evaluate for.').option('--silent', '(optional) Disable logging', {
|
|
1213
|
+
default: false
|
|
1214
|
+
}).option('--out-env-file [string]', '(optional) A file path where the matched triggers are written as a dotenv file.').action(async options => {
|
|
1215
|
+
const config = await loadConfig('circleci-change-triggers', []);
|
|
1216
|
+
await command$1(options, config, cwd);
|
|
1040
1217
|
});
|
|
1041
1218
|
cli.help();
|
|
1042
1219
|
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-
|
|
5
|
+
var storageBucketsConfig = require('./storage-buckets-config-cf50df38.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-
|
|
5
|
+
var storageBucketsConfig = require('./storage-buckets-config-0a380c12.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,
|
|
1
|
+
export { b as bucketEnvironments, e as bucketRegions, c as clusterContexts, d as defineStorageBucketsConfig, s as storageProviders } from './storage-buckets-config-896b4064.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-eastus': "ctp-azure-production-eastus";
|
|
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
|
-
|
|
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-eastus': 'ctp-azure-production-eastus',
|
|
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-eastus']
|
|
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;
|
package/dist/{storage-buckets-config-2fc2b441.esm.js → storage-buckets-config-896b4064.esm.js}
RENAMED
|
@@ -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-eastus': 'ctp-azure-production-eastus',
|
|
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-eastus']
|
|
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 {
|
|
188
|
+
export { loadConfig as a, bucketEnvironments as b, clusterContexts as c, defineStorageBucketsConfig as d, bucketRegions as e, loadStorageBucketsConfig as l, storageProviders as s };
|
|
@@ -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-eastus': 'ctp-azure-production-eastus',
|
|
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-eastus']
|
|
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;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@commercetools-frontend/application-cli",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.5.0",
|
|
4
4
|
"description": "Internal CLI to manage Merchant Center application deployments across various environments.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"commercetools",
|
|
@@ -32,11 +32,15 @@
|
|
|
32
32
|
"execa": "5.1.1",
|
|
33
33
|
"jsonschema": "^1.4.1",
|
|
34
34
|
"listr2": "8.2.0",
|
|
35
|
+
"lodash": "4.17.21",
|
|
36
|
+
"micromatch": "4.0.5",
|
|
35
37
|
"node-fetch": "2.7.0",
|
|
36
38
|
"ts-deepmerge": "7.0.0"
|
|
37
39
|
},
|
|
38
40
|
"devDependencies": {
|
|
39
41
|
"@tsconfig/node20": "20.1.4",
|
|
42
|
+
"@types/lodash": "^4.14.198",
|
|
43
|
+
"@types/micromatch": "4.0.6",
|
|
40
44
|
"@types/node": "20.12.7",
|
|
41
45
|
"typescript": "5.2.2"
|
|
42
46
|
},
|