contensis-cli 1.6.1-beta.9 → 1.7.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.
Files changed (138) hide show
  1. package/CHANGELOG.md +39 -0
  2. package/LICENSE +674 -0
  3. package/dist/index.js +58362 -11
  4. package/dist/index.js.map +4 -4
  5. package/dist/shell.js +58100 -52
  6. package/dist/shell.js.map +4 -4
  7. package/docs/copy_field_templates.md +112 -0
  8. package/esbuild.config.js +8 -13
  9. package/package.json +3 -3
  10. package/src/commands/create.ts +48 -0
  11. package/src/commands/dev.ts +6 -0
  12. package/src/commands/push.ts +38 -6
  13. package/src/commands/set.ts +70 -1
  14. package/src/localisation/en-GB.ts +12 -0
  15. package/src/mappers/DevRequests-to-RequestHanderCliArgs.ts +3 -0
  16. package/src/models/CliService.d.ts +5 -1
  17. package/src/services/ContensisCliService.ts +189 -7
  18. package/src/shell.ts +6 -1
  19. package/src/util/logger.ts +3 -4
  20. package/src/version.ts +1 -1
  21. package/dist/commands/connect.js +0 -44
  22. package/dist/commands/connect.js.map +0 -7
  23. package/dist/commands/copy.js +0 -78
  24. package/dist/commands/copy.js.map +0 -7
  25. package/dist/commands/create.js +0 -170
  26. package/dist/commands/create.js.map +0 -7
  27. package/dist/commands/dev.js +0 -81
  28. package/dist/commands/dev.js.map +0 -7
  29. package/dist/commands/diff.js +0 -57
  30. package/dist/commands/diff.js.map +0 -7
  31. package/dist/commands/execute.js +0 -103
  32. package/dist/commands/execute.js.map +0 -7
  33. package/dist/commands/get.js +0 -330
  34. package/dist/commands/get.js.map +0 -7
  35. package/dist/commands/globalOptions.js +0 -252
  36. package/dist/commands/globalOptions.js.map +0 -7
  37. package/dist/commands/import.js +0 -256
  38. package/dist/commands/import.js.map +0 -7
  39. package/dist/commands/index.js +0 -107
  40. package/dist/commands/index.js.map +0 -7
  41. package/dist/commands/list.js +0 -195
  42. package/dist/commands/list.js.map +0 -7
  43. package/dist/commands/login.js +0 -55
  44. package/dist/commands/login.js.map +0 -7
  45. package/dist/commands/push.js +0 -234
  46. package/dist/commands/push.js.map +0 -7
  47. package/dist/commands/remove.js +0 -193
  48. package/dist/commands/remove.js.map +0 -7
  49. package/dist/commands/set.js +0 -180
  50. package/dist/commands/set.js.map +0 -7
  51. package/dist/commands/update.js +0 -70
  52. package/dist/commands/update.js.map +0 -7
  53. package/dist/factories/RequestHandlerFactory.js +0 -230
  54. package/dist/factories/RequestHandlerFactory.js.map +0 -7
  55. package/dist/localisation/en-GB.js +0 -559
  56. package/dist/localisation/en-GB.js.map +0 -7
  57. package/dist/mappers/ContensisCliService-to-RequestHanderSiteConfigYaml.js +0 -56
  58. package/dist/mappers/ContensisCliService-to-RequestHanderSiteConfigYaml.js.map +0 -7
  59. package/dist/mappers/DevInit-to-CIWorkflow.js +0 -409
  60. package/dist/mappers/DevInit-to-CIWorkflow.js.map +0 -7
  61. package/dist/mappers/DevInit-to-RolePermissions.js +0 -56
  62. package/dist/mappers/DevInit-to-RolePermissions.js.map +0 -7
  63. package/dist/mappers/DevRequests-to-RequestHanderCliArgs.js +0 -168
  64. package/dist/mappers/DevRequests-to-RequestHanderCliArgs.js.map +0 -7
  65. package/dist/mappers/MixedFileData.js +0 -83
  66. package/dist/mappers/MixedFileData.js.map +0 -7
  67. package/dist/models/AppError.d.js +0 -2
  68. package/dist/models/AppError.d.js.map +0 -7
  69. package/dist/models/Cache.d.js +0 -2
  70. package/dist/models/Cache.d.js.map +0 -7
  71. package/dist/models/CliService.d.js +0 -17
  72. package/dist/models/CliService.d.js.map +0 -7
  73. package/dist/models/DevService.d.js +0 -17
  74. package/dist/models/DevService.d.js.map +0 -7
  75. package/dist/models/JsModules.d.js +0 -2
  76. package/dist/models/JsModules.d.js.map +0 -7
  77. package/dist/providers/CredentialProvider.js +0 -126
  78. package/dist/providers/CredentialProvider.js.map +0 -7
  79. package/dist/providers/GitHubCliModuleProvider.js +0 -115
  80. package/dist/providers/GitHubCliModuleProvider.js.map +0 -7
  81. package/dist/providers/HttpProvider.js +0 -73
  82. package/dist/providers/HttpProvider.js.map +0 -7
  83. package/dist/providers/ManifestProvider.js +0 -50
  84. package/dist/providers/ManifestProvider.js.map +0 -7
  85. package/dist/providers/SessionCacheProvider.js +0 -132
  86. package/dist/providers/SessionCacheProvider.js.map +0 -7
  87. package/dist/providers/file-provider.js +0 -177
  88. package/dist/providers/file-provider.js.map +0 -7
  89. package/dist/services/ContensisAuthService.js +0 -88
  90. package/dist/services/ContensisAuthService.js.map +0 -7
  91. package/dist/services/ContensisCliService.js +0 -2661
  92. package/dist/services/ContensisCliService.js.map +0 -7
  93. package/dist/services/ContensisDevService.js +0 -435
  94. package/dist/services/ContensisDevService.js.map +0 -7
  95. package/dist/services/ContensisRoleService.js +0 -112
  96. package/dist/services/ContensisRoleService.js.map +0 -7
  97. package/dist/util/api-ids.js +0 -110
  98. package/dist/util/api-ids.js.map +0 -7
  99. package/dist/util/assert.js +0 -62
  100. package/dist/util/assert.js.map +0 -7
  101. package/dist/util/console.printer.js +0 -461
  102. package/dist/util/console.printer.js.map +0 -7
  103. package/dist/util/csv.formatter.js +0 -118
  104. package/dist/util/csv.formatter.js.map +0 -7
  105. package/dist/util/debug.js +0 -29
  106. package/dist/util/debug.js.map +0 -7
  107. package/dist/util/diff.js +0 -118
  108. package/dist/util/diff.js.map +0 -7
  109. package/dist/util/dotenv.js +0 -56
  110. package/dist/util/dotenv.js.map +0 -7
  111. package/dist/util/error.js +0 -36
  112. package/dist/util/error.js.map +0 -7
  113. package/dist/util/fetch.js +0 -69
  114. package/dist/util/fetch.js.map +0 -7
  115. package/dist/util/find.js +0 -39
  116. package/dist/util/find.js.map +0 -7
  117. package/dist/util/git.js +0 -145
  118. package/dist/util/git.js.map +0 -7
  119. package/dist/util/gitignore.js +0 -61
  120. package/dist/util/gitignore.js.map +0 -7
  121. package/dist/util/html.formatter.js +0 -70
  122. package/dist/util/html.formatter.js.map +0 -7
  123. package/dist/util/index.js +0 -68
  124. package/dist/util/index.js.map +0 -7
  125. package/dist/util/json.formatter.js +0 -66
  126. package/dist/util/json.formatter.js.map +0 -7
  127. package/dist/util/logger.js +0 -304
  128. package/dist/util/logger.js.map +0 -7
  129. package/dist/util/os.js +0 -49
  130. package/dist/util/os.js.map +0 -7
  131. package/dist/util/timers.js +0 -49
  132. package/dist/util/timers.js.map +0 -7
  133. package/dist/util/xml.formatter.js +0 -62
  134. package/dist/util/xml.formatter.js.map +0 -7
  135. package/dist/util/yaml.js +0 -44
  136. package/dist/util/yaml.js.map +0 -7
  137. package/dist/version.js +0 -29
  138. package/dist/version.js.map +0 -7
@@ -1,110 +0,0 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
- var api_ids_exports = {};
20
- __export(api_ids_exports, {
21
- isApiId: () => isApiId,
22
- sanitiseId: () => sanitiseId,
23
- sanitiseIds: () => sanitiseIds,
24
- toApiId: () => toApiId
25
- });
26
- module.exports = __toCommonJS(api_ids_exports);
27
- const sanitiseId = (id) => id.split(".").map((part) => toApiId(part, "camelCase", true)).join(".");
28
- const sanitiseIds = (arr) => arr.map(sanitiseId);
29
- function isApiId(id, mode) {
30
- if (!id) {
31
- return false;
32
- }
33
- const validChars = mode === "camelCase" ? /[^a-zA-Z0-9]/g : /[^a-z0-9-]/g;
34
- if (id !== id.replace(validChars, "")) {
35
- return false;
36
- }
37
- if (!id.substr(0, 1).replace(/[^a-z]/g, "")) {
38
- return false;
39
- }
40
- return true;
41
- }
42
- function toApiId(name, mode, isId) {
43
- if (!name) {
44
- return name;
45
- }
46
- const validChars = mode === "camelCase" ? /[^a-zA-Z0-9 ]/g : /[^a-zA-Z0-9 -]/g;
47
- let id = name.replace(validChars, "");
48
- id = id.replace(/-/g, " ");
49
- id = id.trim();
50
- const noStart = "0123456789 ".split("");
51
- id = id.split("").reduce(
52
- (prev, char) => prev || !noStart.includes(char) ? prev + char : prev,
53
- ""
54
- );
55
- return mode === "camelCase" ? toCamelCase(id, isId) : toSnakeCase(id);
56
- }
57
- function toSnakeCase(sentence) {
58
- sentence = (sentence || "").trim();
59
- if (!sentence) {
60
- return sentence;
61
- }
62
- sentence = sentence.toLowerCase();
63
- return sentence.split(" ").filter((w) => !!w).join("-");
64
- }
65
- function toCamelCase(sentence, isId) {
66
- sentence = (sentence || "").trim();
67
- if (!sentence) {
68
- return sentence;
69
- }
70
- if (sentence.length < 2) {
71
- return sentence.toLowerCase();
72
- }
73
- const words = sentence.split(" ");
74
- if (isId && words.length === 1) {
75
- return words[0].substr(0, 1).toLowerCase() + words[0].substr(1);
76
- }
77
- const result = words.filter((w) => !!w).map(
78
- (w, index) => index === 0 ? firstWordToCamelCase(w) : wordToCamelCase(w)
79
- ).join("");
80
- return result.split(".").map((w, index) => index === 0 ? w : wordToCamelCase(w)).join(".");
81
- }
82
- function firstWordToCamelCase(word) {
83
- return isUpperCase(word) ? word.toLowerCase() : lowerCaseInitialCapitalLettersExceptLast(word);
84
- }
85
- function wordToCamelCase(word) {
86
- return word.substr(0, 1).toUpperCase() + word.substr(1);
87
- }
88
- function lowerCaseInitialCapitalLettersExceptLast(value) {
89
- return value.split("").reduce((prev, char, index) => {
90
- if (index === 0) {
91
- char = char.toLowerCase();
92
- } else if (isUpperCase(char)) {
93
- if (index + 1 < value.length && isUpperCase(value.charAt(index + 1))) {
94
- char = char.toLowerCase();
95
- }
96
- }
97
- return prev + char;
98
- }, "");
99
- }
100
- function isUpperCase(value) {
101
- return value === value.toUpperCase();
102
- }
103
- // Annotate the CommonJS export names for ESM import in node:
104
- 0 && (module.exports = {
105
- isApiId,
106
- sanitiseId,
107
- sanitiseIds,
108
- toApiId
109
- });
110
- //# sourceMappingURL=api-ids.js.map
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../src/util/api-ids.ts"],
4
- "sourcesContent": ["export const sanitiseId = (id: string) =>\n id\n .split('.')\n .map(part => toApiId(part, 'camelCase', true))\n .join('.');\n\nexport const sanitiseIds = (arr: string[]) => arr.map(sanitiseId);\n\n// borrowed from packages\\contensis\\components\\app\\src\\utils.ts\n\nexport function isApiId(id: string, mode: 'camelCase' | 'snake-case'): boolean {\n if (!id) {\n return false;\n }\n const validChars = mode === 'camelCase' ? /[^a-zA-Z0-9]/g : /[^a-z0-9-]/g;\n if (id !== id.replace(validChars, '')) {\n return false;\n }\n if (!id.substr(0, 1).replace(/[^a-z]/g, '')) {\n return false;\n }\n return true;\n}\n\nexport function toApiId(\n name: string,\n mode: 'camelCase' | 'snake-case',\n isId: boolean\n) {\n if (!name) {\n return name;\n }\n const validChars =\n mode === 'camelCase' ? /[^a-zA-Z0-9 ]/g : /[^a-zA-Z0-9 -]/g;\n let id = name.replace(validChars, '');\n id = id.replace(/-/g, ' ');\n id = id.trim();\n\n const noStart = '0123456789 '.split('');\n id = id\n .split('')\n .reduce(\n (prev, char) => (prev || !noStart.includes(char) ? prev + char : prev),\n ''\n );\n return mode === 'camelCase' ? toCamelCase(id, isId) : toSnakeCase(id);\n}\n\nfunction toSnakeCase(sentence: string): string {\n sentence = (sentence || '').trim();\n if (!sentence) {\n return sentence;\n }\n sentence = sentence.toLowerCase();\n return sentence\n .split(' ')\n .filter(w => !!w)\n .join('-');\n}\n\nfunction toCamelCase(sentence: string, isId: boolean): string {\n sentence = (sentence || '').trim();\n if (!sentence) {\n return sentence;\n }\n if (sentence.length < 2) {\n return sentence.toLowerCase();\n }\n const words = sentence.split(' ');\n if (isId && words.length === 1) {\n return words[0].substr(0, 1).toLowerCase() + words[0].substr(1);\n }\n const result = words\n .filter(w => !!w)\n .map((w, index) =>\n index === 0 ? firstWordToCamelCase(w) : wordToCamelCase(w)\n )\n .join('');\n\n return result\n .split('.')\n .map((w, index) => (index === 0 ? w : wordToCamelCase(w)))\n .join('.');\n}\n\nfunction firstWordToCamelCase(word: string) {\n return isUpperCase(word)\n ? word.toLowerCase()\n : lowerCaseInitialCapitalLettersExceptLast(word);\n}\n\nfunction wordToCamelCase(word: string) {\n return word.substr(0, 1).toUpperCase() + word.substr(1);\n}\n\nfunction lowerCaseInitialCapitalLettersExceptLast(value: string): string {\n return value.split('').reduce((prev, char, index) => {\n if (index === 0) {\n char = char.toLowerCase();\n } else if (isUpperCase(char)) {\n if (index + 1 < value.length && isUpperCase(value.charAt(index + 1))) {\n char = char.toLowerCase();\n }\n }\n return prev + char;\n }, '');\n}\n\nfunction isUpperCase(value: string): boolean {\n return value === value.toUpperCase();\n}\n"],
5
- "mappings": "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",
6
- "names": []
7
- }
@@ -1,62 +0,0 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
- var assert_exports = {};
20
- __export(assert_exports, {
21
- isJson: () => isJson,
22
- isPassword: () => isPassword,
23
- isSharedSecret: () => isSharedSecret,
24
- isSysError: () => isSysError,
25
- isUuid: () => isUuid,
26
- tryParse: () => tryParse,
27
- tryStringify: () => tryStringify
28
- });
29
- module.exports = __toCommonJS(assert_exports);
30
- const isSharedSecret = (str = "") => str.length > 80 && str.split("-").length === 3 ? str : void 0;
31
- const isPassword = (str = "") => !isSharedSecret(str) ? str : void 0;
32
- const tryParse = (str) => {
33
- try {
34
- return typeof str === "object" ? str : JSON.parse(str);
35
- } catch (e) {
36
- return false;
37
- }
38
- };
39
- const isJson = (str) => typeof str === "object" || !!tryParse(str);
40
- const tryStringify = (obj) => {
41
- try {
42
- return typeof obj === "object" ? JSON.stringify(obj) : obj;
43
- } catch (e) {
44
- return obj;
45
- }
46
- };
47
- const isSysError = (error) => (error == null ? void 0 : error.message) !== void 0 && error.stack;
48
- const isUuid = (str) => {
49
- const regexExp = /^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/gi;
50
- return regexExp.test(str);
51
- };
52
- // Annotate the CommonJS export names for ESM import in node:
53
- 0 && (module.exports = {
54
- isJson,
55
- isPassword,
56
- isSharedSecret,
57
- isSysError,
58
- isUuid,
59
- tryParse,
60
- tryStringify
61
- });
62
- //# sourceMappingURL=assert.js.map
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../src/util/assert.ts"],
4
- "sourcesContent": ["export const isSharedSecret = (str = '') =>\n str.length > 80 && str.split('-').length === 3 ? str : undefined;\n\nexport const isPassword = (str = '') =>\n !isSharedSecret(str) ? str : undefined;\n\nexport const tryParse = (str: any) => {\n try {\n return typeof str === 'object' ? str : JSON.parse(str);\n } catch (e) {\n return false;\n }\n};\n\nexport const isJson = (str?: string) =>\n typeof str === 'object' || !!tryParse(str);\n\nexport const tryStringify = (obj: any) => {\n try {\n return typeof obj === 'object' ? JSON.stringify(obj) : obj;\n } catch (e) {\n return obj;\n }\n};\n\nexport const isSysError = (error: any): error is Error =>\n error?.message !== undefined && error.stack;\n\nexport const isUuid = (str: string) => {\n // Regular expression to check if string is a valid UUID\n const regexExp =\n /^[0-9a-fA-F]{8}\\b-[0-9a-fA-F]{4}\\b-[0-9a-fA-F]{4}\\b-[0-9a-fA-F]{4}\\b-[0-9a-fA-F]{12}$/gi;\n\n return regexExp.test(str);\n};\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAO,MAAM,iBAAiB,CAAC,MAAM,OACnC,IAAI,SAAS,MAAM,IAAI,MAAM,GAAG,EAAE,WAAW,IAAI,MAAM;AAElD,MAAM,aAAa,CAAC,MAAM,OAC/B,CAAC,eAAe,GAAG,IAAI,MAAM;AAExB,MAAM,WAAW,CAAC,QAAa;AACpC,MAAI;AACF,WAAO,OAAO,QAAQ,WAAW,MAAM,KAAK,MAAM,GAAG;AAAA,EACvD,SAAS,GAAG;AACV,WAAO;AAAA,EACT;AACF;AAEO,MAAM,SAAS,CAAC,QACrB,OAAO,QAAQ,YAAY,CAAC,CAAC,SAAS,GAAG;AAEpC,MAAM,eAAe,CAAC,QAAa;AACxC,MAAI;AACF,WAAO,OAAO,QAAQ,WAAW,KAAK,UAAU,GAAG,IAAI;AAAA,EACzD,SAAS,GAAG;AACV,WAAO;AAAA,EACT;AACF;AAEO,MAAM,aAAa,CAAC,WACzB,+BAAO,aAAY,UAAa,MAAM;AAEjC,MAAM,SAAS,CAAC,QAAgB;AAErC,QAAM,WACJ;AAEF,SAAO,SAAS,KAAK,GAAG;AAC1B;",
6
- "names": []
7
- }
@@ -1,461 +0,0 @@
1
- "use strict";
2
- var __create = Object.create;
3
- var __defProp = Object.defineProperty;
4
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
- var __getOwnPropNames = Object.getOwnPropertyNames;
6
- var __getProtoOf = Object.getPrototypeOf;
7
- var __hasOwnProp = Object.prototype.hasOwnProperty;
8
- var __export = (target, all) => {
9
- for (var name in all)
10
- __defProp(target, name, { get: all[name], enumerable: true });
11
- };
12
- var __copyProps = (to, from, except, desc) => {
13
- if (from && typeof from === "object" || typeof from === "function") {
14
- for (let key of __getOwnPropNames(from))
15
- if (!__hasOwnProp.call(to, key) && key !== except)
16
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
- }
18
- return to;
19
- };
20
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
- // If the importer is in node compatibility mode or this is not an ESM
22
- // file that has been converted to a CommonJS file using a Babel-
23
- // compatible transform (i.e. "__esModule" has not been set), then set
24
- // "default" to the CommonJS "module.exports" for node compatibility.
25
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
- mod
27
- ));
28
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
- var console_printer_exports = {};
30
- __export(console_printer_exports, {
31
- printBlockVersion: () => printBlockVersion,
32
- printEntriesMigrateResult: () => printEntriesMigrateResult,
33
- printModelMigrationAnalysis: () => printModelMigrationAnalysis,
34
- printModelMigrationResult: () => printModelMigrationResult,
35
- printNodeTreeOutput: () => printNodeTreeOutput,
36
- printNodesMigrateResult: () => printNodesMigrateResult,
37
- printWebhooksMigrateResult: () => printWebhooksMigrateResult
38
- });
39
- module.exports = __toCommonJS(console_printer_exports);
40
- var import_dayjs = __toESM(require("dayjs"));
41
- var import_error = require("./error");
42
- var import_logger = require("./logger");
43
- const formatDate = (date, format = "DD/MM/YYYY HH:mm") => (0, import_dayjs.default)(date).format(format);
44
- const printBlockVersion = ({ log, messages }, block, printOptions = {
45
- showSource: true,
46
- showStatus: true,
47
- showStaticPaths: true,
48
- showImage: true
49
- }) => {
50
- var _a, _b;
51
- console.log(
52
- ` ${log.standardText(`v${block.version.versionNo}`)} ${block.id}`
53
- );
54
- console.log(
55
- ` state: ${messages.blocks.runningStatus(
56
- block.status.broken ? "broken" : block.status.running.global
57
- )}`
58
- );
59
- console.log(
60
- ` released: ${log.infoText(
61
- block.version.released ? `[${formatDate(block.version.released)}] ${block.version.releasedBy}` : "no"
62
- )}`
63
- );
64
- if (block.version.madeLive)
65
- console.log(
66
- ` live: ${log.infoText(
67
- `[${formatDate(block.version.madeLive)}] ${block.version.madeLiveBy}`
68
- )}`
69
- );
70
- if (printOptions.showStatus) {
71
- console.log(` status:`);
72
- console.log(` deployment: ${log.infoText(block.status.deployment)}`);
73
- console.log(` workflow: ${log.infoText(block.status.workflow)}`);
74
- console.log(
75
- ` running status: ${messages.blocks.runningStatus(
76
- block.status.running.global
77
- )}`
78
- );
79
- console.log(` datacentres:`);
80
- console.log(
81
- ` hq: ${messages.blocks.runningStatus(
82
- block.status.running.dataCenters.hq
83
- )}`
84
- );
85
- console.log(
86
- ` london: ${messages.blocks.runningStatus(
87
- block.status.running.dataCenters.london
88
- )}`
89
- );
90
- console.log(
91
- ` manchester: ${messages.blocks.runningStatus(
92
- block.status.running.dataCenters.manchester
93
- )}`
94
- );
95
- }
96
- if (printOptions.showSource) {
97
- console.log(` source:`);
98
- console.log(` commit: ${log.helpText(block.source.commit.id)}`);
99
- console.log(
100
- ` message: ${log.infoText(
101
- (_a = block.source.commit.message) == null ? void 0 : _a.replaceAll("\n", "\\n").replaceAll("\\n\\n", "\\n").replaceAll("\\n", "; ")
102
- )}`
103
- );
104
- console.log(
105
- ` committed: ${log.infoText(
106
- `[${formatDate(block.source.commit.dateTime)}] ${block.source.commit.authorEmail}`
107
- )}`
108
- );
109
- console.log(
110
- ` pushed: ${log.infoText(
111
- `[${formatDate(block.version.pushed)}] ${block.version.pushedBy}`
112
- )}`
113
- );
114
- console.log(` ${log.infoText(block.source.commit.commitUrl)}`);
115
- }
116
- if (printOptions.showImage) {
117
- console.log(` image:`);
118
- console.log(` uri: ${log.infoText(block.image.uri)}`);
119
- console.log(` tag: ${log.helpText(block.image.tag)}`);
120
- }
121
- if (printOptions.showStaticPaths) {
122
- if ((_b = block.staticPaths) == null ? void 0 : _b.length) {
123
- console.log(` static paths:`);
124
- for (const path of block.staticPaths) console.log(` - ${path}`);
125
- }
126
- }
127
- if (block.stagingUrl)
128
- console.log(` staging url: ${log.infoText(block.stagingUrl)}`);
129
- console.log("");
130
- };
131
- const printEntriesMigrateResult = (service, migrateResult, {
132
- action = "import",
133
- showDiff = false,
134
- showAll = false,
135
- showChanged = false
136
- } = {}) => {
137
- var _a, _b, _c;
138
- console.log(``);
139
- const { log, messages, currentProject } = service;
140
- for (const [contentTypeId, entryRes] of Object.entries(
141
- migrateResult.entriesToMigrate.entryIds
142
- )) {
143
- for (const [originalId, entryStatus] of Object.entries(entryRes)) {
144
- const projectStatus = Object.entries(
145
- Object.entries(entryStatus[currentProject])[0]
146
- )[1][1];
147
- if (showAll || showChanged && projectStatus.status !== "no change" && projectStatus.status !== "ignore") {
148
- console.log(
149
- log.infoText(
150
- `${Object.entries(entryStatus || {}).filter((x) => x[0] !== "entryTitle").map(([projectId, projectStatus2]) => {
151
- var _a2;
152
- const [targetGuid, { status }] = ((_a2 = Object.entries(
153
- projectStatus2 || {}
154
- )) == null ? void 0 : _a2[0]) || [
155
- "",
156
- { x: { status: void 0 } }
157
- ];
158
- return `${messages.migrate.status(status)(
159
- `${status}`
160
- )} ${originalId}${targetGuid !== originalId ? ` -> ${targetGuid}
161
- ` : " "}`;
162
- })}`
163
- ) + `${log.helpText(contentTypeId)} ${entryStatus.entryTitle}`
164
- );
165
- for (const [projectId, projectStatus2] of Object.entries(
166
- entryStatus
167
- ).filter(([key]) => key !== "entryTitle")) {
168
- const [targetGuid, { error, diff, status }] = Object.entries(
169
- projectStatus2
170
- )[0];
171
- if (error) log.error(error);
172
- if (diff && showDiff) {
173
- console.log(
174
- ` ${log.infoText(`diff: ${highlightDiffText(diff)}`)}
175
- `
176
- );
177
- }
178
- }
179
- }
180
- }
181
- }
182
- if (showAll || showChanged) console.log(``);
183
- for (const [projectId, contentTypeCounts] of Object.entries(
184
- migrateResult.entries || {}
185
- )) {
186
- log.help(
187
- action === "update" ? `update entries in project ${log.boldText(
188
- log.warningText(currentProject)
189
- )}` : `${action}${action === "delete" ? ` from project ${log.warningText(currentProject)}` : `${projectId ? ` from project ${log.highlightText(projectId)}` : ""} to ${log.boldText(
190
- log.warningText(currentProject)
191
- )}`}`
192
- );
193
- for (const [contentTypeId, count] of Object.entries(contentTypeCounts)) {
194
- const isTotalCountRow = contentTypeId === "totalCount";
195
- const migrateStatusAndCount = migrateResult.entriesToMigrate[currentProject][contentTypeId];
196
- const existingCount = ((_b = (_a = migrateResult.existing) == null ? void 0 : _a[currentProject]) == null ? void 0 : _b[contentTypeId]) || 0;
197
- const existingPercent = (existingCount / count * 100).toFixed(0);
198
- const noChangeOrTotalEntriesCount = typeof migrateStatusAndCount !== "number" ? ((migrateStatusAndCount == null ? void 0 : migrateStatusAndCount["no change"]) || 0) + ((migrateStatusAndCount == null ? void 0 : migrateStatusAndCount["ignore"]) || 0) : migrateStatusAndCount;
199
- const changedPercentage = (noChangeOrTotalEntriesCount / count * 100).toFixed(0);
200
- const existingColor = existingPercent === "0" || action === "delete" ? log.warningText : log.infoText;
201
- const changedColor = isTotalCountRow ? log.helpText : changedPercentage === "100" ? log.successText : log.warningText;
202
- if (isTotalCountRow && "nodes" in migrateResult) {
203
- printNodesMigrateResult(service, migrateResult, {
204
- showAll,
205
- showDiff,
206
- showChanged,
207
- isEntriesMigration: true
208
- });
209
- }
210
- console.log(
211
- ` - ${isTotalCountRow ? log.highlightText(
212
- `${contentTypeId}: ${noChangeOrTotalEntriesCount}`
213
- ) : `${contentTypeId}: ${log.helpText(count)}`}${changedPercentage === "100" || isTotalCountRow ? "" : existingColor(` [existing: ${`${existingPercent}%`}]`)}${existingPercent === "0" || action === "import" && isTotalCountRow ? "" : changedColor(
214
- ` ${isTotalCountRow ? `[to ${action}: ${noChangeOrTotalEntriesCount}]` : changedPercentage === "100" ? "up to date" : `[needs update: ${100 - Number(changedPercentage)}%]`}`
215
- )}`
216
- );
217
- }
218
- }
219
- if ((_c = migrateResult.errors) == null ? void 0 : _c.length) {
220
- console.log(
221
- ` - ${log.errorText(`errors: ${migrateResult.errors.length}`)}
222
- `
223
- );
224
- }
225
- };
226
- const printNodesMigrateResult = ({ log, currentProject }, migrateResult, {
227
- action = "import",
228
- logLimit = 50,
229
- showDiff = false,
230
- showAll = false,
231
- showChanged = false,
232
- isEntriesMigration = false
233
- } = {}) => {
234
- var _a, _b, _c;
235
- if (!isEntriesMigration) log.raw(``);
236
- for (const [projectId, counts] of Object.entries(migrateResult.nodes || {})) {
237
- const importTitle = action === "delete" ? `Delete from project ${log.warningText(currentProject)}` : `Import ${projectId && projectId !== "null" ? `from project ${log.highlightText(projectId)} ` : ""}to ${log.boldText(log.warningText(currentProject))}`;
238
- if (!isEntriesMigration) log.help(importTitle);
239
- const migrateStatusAndCount = migrateResult.nodesToMigrate[currentProject];
240
- const existingCount = ((_b = (_a = migrateResult.nodes) == null ? void 0 : _a[projectId]) == null ? void 0 : _b.totalCount) || 0;
241
- const totalCount = Object.keys(migrateResult.nodesToMigrate.nodeIds).length;
242
- const existingPercent = counts.totalCount ? (existingCount / totalCount * 100).toFixed(0) : "0";
243
- const noChangeCount = (migrateStatusAndCount == null ? void 0 : migrateStatusAndCount["no change"]) || 0;
244
- const changedPercentage = counts.totalCount ? (noChangeCount / totalCount * 100).toFixed(0) : "0";
245
- const existingColor = existingPercent === "0" || action === "delete" ? log.warningText : log.infoText;
246
- const changedColor = changedPercentage === "100" ? log.successText : log.warningText;
247
- if (!isEntriesMigration || migrateStatusAndCount.totalCount > 0)
248
- console.log(
249
- ` - ${log.highlightText(
250
- `${isEntriesMigration ? " + nodes" : "totalCount"}: ${migrateStatusAndCount.totalCount}`
251
- )}${changedPercentage === "100" ? "" : existingColor(` [existing: ${`${existingPercent}%`}]`)}${existingPercent === "0" ? "" : changedColor(
252
- ` ${changedPercentage === "100" ? "up to date" : `[needs update: ${100 - Number(changedPercentage)}%]`}`
253
- )}`
254
- );
255
- }
256
- if ((_c = migrateResult.errors) == null ? void 0 : _c.length) {
257
- console.log(
258
- ` - ${log.errorText(`errors: ${migrateResult.errors.length}`)}
259
- `
260
- );
261
- log.limits(
262
- migrateResult.errors.map((error) => {
263
- return log.errorText((0, import_error.deconstructApiError)(error));
264
- }).join("\n"),
265
- logLimit
266
- );
267
- }
268
- };
269
- const printWebhooksMigrateResult = (service, migrateResult, {
270
- showDiff = false,
271
- showAll = false,
272
- showChanged = false
273
- } = {}) => {
274
- var _a;
275
- console.log(``);
276
- const { log, messages } = service;
277
- for (const [originalId, webhookStatus] of Object.entries(
278
- migrateResult.webhooksToMigrate.webhookIds
279
- )) {
280
- if (showAll || showChanged && webhookStatus.status !== "no change" && webhookStatus.status !== "ignore") {
281
- console.log(
282
- log.infoText(
283
- `${messages.migrate.status(webhookStatus.status)(`${webhookStatus.status}`)} ${originalId}${webhookStatus.id !== originalId ? ` -> ${webhookStatus.id}
284
- ` : " "}`
285
- ) + `${webhookStatus.name}`
286
- );
287
- if (webhookStatus.error) log.error(webhookStatus.error);
288
- if (webhookStatus.diff && showDiff) {
289
- console.log(
290
- ` ${log.infoText(`diff: ${highlightDiffText(webhookStatus.diff)}`)}
291
- `
292
- );
293
- }
294
- }
295
- }
296
- if ((_a = migrateResult.errors) == null ? void 0 : _a.length) {
297
- console.log(
298
- ` - ${log.errorText(`errors: ${migrateResult.errors.length}`)}
299
- `
300
- );
301
- }
302
- };
303
- const highlightDiffText = (str) => {
304
- const addedRegex = new RegExp(/<<\+>>(.*?)<<\/\+>>/, "g");
305
- const removedRegex = new RegExp(/<<->>(.*?)<<\/->>/, "g");
306
- return str.replace(addedRegex, (match) => {
307
- return import_logger.Logger.successText(
308
- match.replace(/<<\+>>/g, "<+>").replace(/<<\/\+>>/g, "</+>")
309
- );
310
- }).replace(removedRegex, (match) => {
311
- return import_logger.Logger.errorText(
312
- match.replace(/<<->>/g, "<->").replace(/<<\/->>/g, "</->")
313
- );
314
- });
315
- };
316
- const printModelMigrationAnalysis = ({ log, messages }, result = {}) => {
317
- for (const [contentTypeId, model] of Object.entries(result)) {
318
- let mainOutput = log.standardText(
319
- ` - ${contentTypeId}${model.contentTypeId ? ` ${log.helpText(model.contentTypeId)}` : ""}`
320
- );
321
- let extraOutput = "";
322
- let errorOutput = "";
323
- let diffOutput = "";
324
- for (const [key, details] of Object.entries(model)) {
325
- if (key === "dependencies") {
326
- extraOutput += log.infoText(
327
- ` references: [${details == null ? void 0 : details.join(", ")}]
328
- `
329
- );
330
- }
331
- if (key === "dependencyOf") {
332
- extraOutput += log.infoText(
333
- ` required by: [${details == null ? void 0 : details.join(", ")}]
334
- `
335
- );
336
- }
337
- if (key === "projects") {
338
- for (const [projectId, projectDetails] of Object.entries(details)) {
339
- mainOutput += log.infoText(
340
- ` [${messages.migrate.status(projectDetails.status)(
341
- `${projectId}: ${projectDetails.status}`
342
- )}]${projectDetails.versionNo ? ` v${projectDetails.versionNo}` : ""}`
343
- );
344
- if (projectDetails.diff)
345
- diffOutput += ` ${log.highlightText(`diff:`)} ${log.infoText(
346
- highlightDiffText(projectDetails.diff)
347
- )}`;
348
- if (projectDetails.error)
349
- errorOutput += ` ${log.highlightText(
350
- `error:`
351
- )} ${log.errorText(projectDetails.error)}`;
352
- }
353
- }
354
- }
355
- console.log(mainOutput);
356
- if (extraOutput) {
357
- const search = "\n";
358
- const replace = "";
359
- console.log(
360
- extraOutput.replace(
361
- new RegExp(search + "([^" + search + "]*)$"),
362
- replace + "$1"
363
- )
364
- );
365
- }
366
- if (diffOutput) console.log(diffOutput);
367
- if (errorOutput) console.log(errorOutput);
368
- }
369
- };
370
- const printModelMigrationResult = ({ log, messages }, result) => {
371
- for (const [status, ids] of Object.entries(result)) {
372
- if (ids == null ? void 0 : ids.length) {
373
- if (status === "errors") {
374
- const errors = ids;
375
- log.raw(
376
- ` - ${status}: [ ${messages.migrate.models.result(status)(
377
- ids.map((id) => id[0]).join(", ")
378
- )} ]
379
- `
380
- );
381
- for (const [contentTypeId, error] of errors)
382
- log.error(
383
- `${log.highlightText(contentTypeId)}: ${error.message}`,
384
- error
385
- );
386
- } else
387
- log.raw(
388
- ` - ${status}: [ ${messages.migrate.models.result(status)(
389
- ids.join(", ")
390
- )} ]`
391
- );
392
- }
393
- }
394
- };
395
- const printNodeTreeOutput = ({ log, messages }, root, logDetail = "errors", logLimit = 1e3) => {
396
- log.raw("");
397
- const statusColour = messages.migrate.status;
398
- if (root && "status" in root)
399
- log.info(
400
- `Migrate status: ${statusColour("no change")(
401
- "N"
402
- )} [no change]; ${statusColour("create")("C")} [create]; ${statusColour(
403
- "update"
404
- )("U")} [update]; ${statusColour("delete")("D")} [delete]; ${statusColour(
405
- "error"
406
- )("E")} [error];`
407
- );
408
- log.info(
409
- `Node properties: ${log.highlightText(
410
- "e"
411
- )} = has entry; ${log.highlightText("c")} = canonical; ${log.highlightText(
412
- "m"
413
- )} = include in menu`
414
- );
415
- log.line();
416
- const outputNode = (node, spaces, isRoot = false) => {
417
- var _a, _b;
418
- const errorOutput = "error" in node && node.error && (0, import_error.deconstructApiError)(node.error);
419
- const fullOutput = logDetail === "all";
420
- const changesOutput = logDetail === "changes" && "status" in node && node.status && ["create", "update"].includes(node.status);
421
- const diffOutput = (fullOutput || changesOutput || errorOutput) && "diff" in node && ((_a = node.diff) == null ? void 0 : _a.replaceAll("\n", ""));
422
- return `${"status" in node && node.status ? `${statusColour(node.status)(
423
- node.status.substring(0, 1).toUpperCase()
424
- )} ` : ""}${node.entry ? log.highlightText("e") : log.infoText("-")}${"isCanonical" in node && node.isCanonical ? log.highlightText("c") : log.infoText("-")}${node.includeInMenu ? log.highlightText("m") : log.infoText("-")}${spaces}${log["status" in node && node.status === "no change" ? "infoText" : "standardText"](
425
- "isCanonical" in node && node.isCanonical ? log.boldText(
426
- fullOutput || isRoot || !node.slug ? node.path : `/${node.slug}`
427
- ) : fullOutput || isRoot || !node.slug ? node.path : `/${node.slug}`
428
- )}${node.entry ? ` ${log.helpText(node.entry.sys.contentTypeId)}` : ""}${node.childCount ? ` +${node.childCount}` : ``} ${"displayName" in node ? log.infoText(node.displayName) : ""}${fullOutput || changesOutput && node.id !== node.originalId ? `~n ${log.infoText(`id:`)} ${!("originalId" in node) || node.id === node.originalId ? node.id : `${node.id} ${log.infoText(`<= ${node.originalId}`)}`}` : ""}${(fullOutput || changesOutput && node.parentId !== node.originalParentId) && node.parentId ? `~n ${log.infoText(
429
- `parentId: ${!("originalParentId" in node) || node.parentId === node.originalParentId ? node.parentId : `${node.parentId} <= ${node.originalParentId}`}`
430
- )}` : ""}${fullOutput && ((_b = node.entry) == null ? void 0 : _b.sys.id) ? `~n ${log.infoText(`entryId: ${node.entry.sys.id}`)}` : ""}${errorOutput ? `~n${(0, import_logger.addNewLines)(` ${log.errorText(errorOutput)}`, "~n")}` : ""}${diffOutput ? `~n${(0, import_logger.addNewLines)(
431
- ` ${log.infoText(`diff: ${highlightDiffText(diffOutput)}`)}`,
432
- "~n"
433
- )}` : ""}`;
434
- };
435
- const outputChildren = (node, depth = 2) => {
436
- let str = "";
437
- for (const child of (node == null ? void 0 : node.children) || []) {
438
- str += `${outputNode(child, Array(depth + 1).join(" "))}
439
- `;
440
- if ("children" in child) str += outputChildren(child, depth + 1);
441
- }
442
- return str;
443
- };
444
- const children = outputChildren(root);
445
- log.limits(
446
- `${outputNode(root || {}, " ", true)}${children ? `
447
- ${children}` : ""}`,
448
- logLimit
449
- );
450
- };
451
- // Annotate the CommonJS export names for ESM import in node:
452
- 0 && (module.exports = {
453
- printBlockVersion,
454
- printEntriesMigrateResult,
455
- printModelMigrationAnalysis,
456
- printModelMigrationResult,
457
- printNodeTreeOutput,
458
- printNodesMigrateResult,
459
- printWebhooksMigrateResult
460
- });
461
- //# sourceMappingURL=console.printer.js.map