contensis-cli 1.0.0-beta.52 → 1.0.0-beta.53
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/.vscode/launch.json +15 -15
- package/README.md +1226 -1226
- package/dist/commands/connect.js +44 -0
- package/dist/commands/connect.js.map +7 -0
- package/dist/commands/create.js +75 -0
- package/dist/commands/create.js.map +7 -0
- package/dist/commands/diff.js +57 -0
- package/dist/commands/diff.js.map +7 -0
- package/dist/commands/get.js +170 -0
- package/dist/commands/get.js.map +7 -0
- package/dist/commands/globalOptions.js +144 -0
- package/dist/commands/globalOptions.js.map +7 -0
- package/dist/commands/import.js +121 -0
- package/dist/commands/import.js.map +7 -0
- package/dist/commands/index.js +89 -0
- package/dist/commands/index.js.map +7 -0
- package/dist/commands/list.js +99 -0
- package/dist/commands/list.js.map +7 -0
- package/dist/commands/login.js +56 -0
- package/dist/commands/login.js.map +7 -0
- package/dist/commands/push.js +137 -0
- package/dist/commands/push.js.map +7 -0
- package/dist/commands/release.js +47 -0
- package/dist/commands/release.js.map +7 -0
- package/dist/commands/remove.js +79 -0
- package/dist/commands/remove.js.map +7 -0
- package/dist/commands/set.js +96 -0
- package/dist/commands/set.js.map +7 -0
- package/dist/index.js +32 -0
- package/dist/index.js.map +7 -0
- package/dist/localisation/en-GB.js +253 -0
- package/dist/localisation/en-GB.js.map +7 -0
- package/dist/models/AppError.d.js +2 -0
- package/dist/models/AppError.d.js.map +7 -0
- package/dist/models/Cache.d.js +2 -0
- package/dist/models/Cache.d.js.map +7 -0
- package/dist/models/JsModules.d.js +2 -0
- package/dist/models/JsModules.d.js.map +7 -0
- package/dist/providers/CredentialProvider.js +116 -0
- package/dist/providers/CredentialProvider.js.map +7 -0
- package/dist/providers/SessionCacheProvider.js +111 -0
- package/dist/providers/SessionCacheProvider.js.map +7 -0
- package/dist/providers/file-provider.js +117 -0
- package/dist/providers/file-provider.js.map +7 -0
- package/dist/services/ContensisAuthService.js +75 -0
- package/dist/services/ContensisAuthService.js.map +7 -0
- package/dist/services/ContensisCliService.js +1374 -0
- package/dist/services/ContensisCliService.js.map +7 -0
- package/dist/shell.js +278 -0
- package/dist/shell.js.map +7 -0
- package/dist/util/console.printer.js +317 -0
- package/dist/util/console.printer.js.map +7 -0
- package/dist/util/csv.formatter.js +50 -0
- package/dist/util/csv.formatter.js.map +7 -0
- package/dist/util/index.js +97 -0
- package/dist/util/index.js.map +7 -0
- package/dist/util/json.formatter.js +29 -0
- package/dist/util/json.formatter.js.map +7 -0
- package/dist/util/logger.js +216 -0
- package/dist/util/logger.js.map +7 -0
- package/dist/util/xml.formatter.js +51 -0
- package/dist/util/xml.formatter.js.map +7 -0
- package/dist/version.js +29 -0
- package/dist/version.js.map +7 -0
- package/esbuild.config.js +49 -49
- package/headless-setup.sh +6 -6
- package/package.json +59 -59
- package/src/commands/connect.ts +24 -24
- package/src/commands/create.ts +70 -70
- package/src/commands/diff.ts +41 -41
- package/src/commands/get.ts +214 -214
- package/src/commands/globalOptions.ts +127 -127
- package/src/commands/import.ts +128 -128
- package/src/commands/index.ts +80 -80
- package/src/commands/list.ts +116 -116
- package/src/commands/login.ts +34 -34
- package/src/commands/push.ts +127 -127
- package/src/commands/release.ts +32 -32
- package/src/commands/remove.ts +85 -85
- package/src/commands/set.ts +96 -96
- package/src/index.ts +19 -19
- package/src/localisation/en-GB.ts +289 -289
- package/src/models/AppError.d.ts +40 -40
- package/src/models/Cache.d.ts +25 -25
- package/src/models/JsModules.d.ts +1 -1
- package/src/providers/CredentialProvider.ts +121 -121
- package/src/providers/SessionCacheProvider.ts +101 -101
- package/src/providers/file-provider.ts +76 -76
- package/src/services/ContensisAuthService.ts +70 -70
- package/src/services/ContensisCliService.ts +1745 -1745
- package/src/shell.ts +270 -270
- package/src/util/console.printer.ts +371 -371
- package/src/util/csv.formatter.ts +21 -21
- package/src/util/index.ts +73 -73
- package/src/util/json.formatter.ts +1 -1
- package/src/util/logger.ts +234 -234
- package/src/util/xml.formatter.ts +20 -20
- package/src/version.ts +1 -1
- package/tsconfig.json +22 -22
|
@@ -0,0 +1,317 @@
|
|
|
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
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
22
|
+
mod
|
|
23
|
+
));
|
|
24
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
25
|
+
var console_printer_exports = {};
|
|
26
|
+
__export(console_printer_exports, {
|
|
27
|
+
printBlockVersion: () => printBlockVersion,
|
|
28
|
+
printMigrateResult: () => printMigrateResult,
|
|
29
|
+
printModelMigrationAnalysis: () => printModelMigrationAnalysis,
|
|
30
|
+
printModelMigrationResult: () => printModelMigrationResult
|
|
31
|
+
});
|
|
32
|
+
module.exports = __toCommonJS(console_printer_exports);
|
|
33
|
+
var import_dayjs = __toESM(require("dayjs"));
|
|
34
|
+
var import_logger = require("./logger");
|
|
35
|
+
const formatDate = (date, format = "DD/MM/YYYY HH:mm") => (0, import_dayjs.default)(date).format(format);
|
|
36
|
+
const printBlockVersion = ({ log, messages }, block, printOptions = {
|
|
37
|
+
showSource: true,
|
|
38
|
+
showStatus: true,
|
|
39
|
+
showStaticPaths: true,
|
|
40
|
+
showImage: true
|
|
41
|
+
}) => {
|
|
42
|
+
var _a, _b;
|
|
43
|
+
console.log(
|
|
44
|
+
` ${log.standardText(`v${block.version.versionNo}`)} ${block.id}`
|
|
45
|
+
);
|
|
46
|
+
console.log(
|
|
47
|
+
` state: ${messages.blocks.runningStatus(
|
|
48
|
+
block.status.broken ? "broken" : block.status.running.global
|
|
49
|
+
)}`
|
|
50
|
+
);
|
|
51
|
+
console.log(
|
|
52
|
+
` released: ${log.infoText(
|
|
53
|
+
block.version.released ? `[${formatDate(block.version.released)}] ${block.version.releasedBy}` : "no"
|
|
54
|
+
)}`
|
|
55
|
+
);
|
|
56
|
+
if (block.version.madeLive)
|
|
57
|
+
console.log(
|
|
58
|
+
` live: ${log.infoText(
|
|
59
|
+
`[${formatDate(block.version.madeLive)}] ${block.version.madeLiveBy}`
|
|
60
|
+
)}`
|
|
61
|
+
);
|
|
62
|
+
if (printOptions.showStatus) {
|
|
63
|
+
console.log(` status:`);
|
|
64
|
+
console.log(` deployment: ${log.infoText(block.status.deployment)}`);
|
|
65
|
+
console.log(` workflow: ${log.infoText(block.status.workflow)}`);
|
|
66
|
+
console.log(
|
|
67
|
+
` running status: ${messages.blocks.runningStatus(
|
|
68
|
+
block.status.running.global
|
|
69
|
+
)}`
|
|
70
|
+
);
|
|
71
|
+
console.log(` datacentres:`);
|
|
72
|
+
console.log(
|
|
73
|
+
` hq: ${messages.blocks.runningStatus(
|
|
74
|
+
block.status.running.dataCenters.hq
|
|
75
|
+
)}`
|
|
76
|
+
);
|
|
77
|
+
console.log(
|
|
78
|
+
` london: ${messages.blocks.runningStatus(
|
|
79
|
+
block.status.running.dataCenters.london
|
|
80
|
+
)}`
|
|
81
|
+
);
|
|
82
|
+
console.log(
|
|
83
|
+
` manchester: ${messages.blocks.runningStatus(
|
|
84
|
+
block.status.running.dataCenters.manchester
|
|
85
|
+
)}`
|
|
86
|
+
);
|
|
87
|
+
}
|
|
88
|
+
if (printOptions.showSource) {
|
|
89
|
+
console.log(` source:`);
|
|
90
|
+
console.log(` commit: ${log.helpText(block.source.commit.id)}`);
|
|
91
|
+
console.log(
|
|
92
|
+
` message: ${log.infoText(
|
|
93
|
+
(_a = block.source.commit.message) == null ? void 0 : _a.replaceAll("\n", "\\n").replaceAll("\\n\\n", "\\n").replaceAll("\\n", "; ")
|
|
94
|
+
)}`
|
|
95
|
+
);
|
|
96
|
+
console.log(
|
|
97
|
+
` committed: ${log.infoText(
|
|
98
|
+
`[${formatDate(block.source.commit.dateTime)}] ${block.source.commit.authorEmail}`
|
|
99
|
+
)}`
|
|
100
|
+
);
|
|
101
|
+
console.log(
|
|
102
|
+
` pushed: ${log.infoText(
|
|
103
|
+
`[${formatDate(block.version.pushed)}] ${block.version.pushedBy}`
|
|
104
|
+
)}`
|
|
105
|
+
);
|
|
106
|
+
console.log(` ${log.infoText(block.source.commit.commitUrl)}`);
|
|
107
|
+
}
|
|
108
|
+
if (printOptions.showImage) {
|
|
109
|
+
console.log(` image:`);
|
|
110
|
+
console.log(` uri: ${log.infoText(block.image.uri)}`);
|
|
111
|
+
console.log(` tag: ${log.helpText(block.image.tag)}`);
|
|
112
|
+
}
|
|
113
|
+
if (printOptions.showStaticPaths) {
|
|
114
|
+
if ((_b = block.staticPaths) == null ? void 0 : _b.length) {
|
|
115
|
+
console.log(` static paths:`);
|
|
116
|
+
for (const path of block.staticPaths)
|
|
117
|
+
console.log(` - ${path}`);
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
if (block.stagingUrl)
|
|
121
|
+
console.log(` staging url: ${log.infoText(block.stagingUrl)}`);
|
|
122
|
+
console.log("");
|
|
123
|
+
};
|
|
124
|
+
const printMigrateResult = ({ log, messages, contensis, currentProject }, migrateResult, {
|
|
125
|
+
action = "import",
|
|
126
|
+
showDiff = false,
|
|
127
|
+
showAllEntries = false,
|
|
128
|
+
showChangedEntries = false
|
|
129
|
+
} = {}) => {
|
|
130
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
131
|
+
if (Object.keys(migrateResult.entriesToMigrate.entryIds).length)
|
|
132
|
+
console.log(``);
|
|
133
|
+
for (const [contentTypeId, entryRes] of Object.entries(
|
|
134
|
+
migrateResult.entriesToMigrate.entryIds
|
|
135
|
+
)) {
|
|
136
|
+
for (const [originalId, entryStatus] of Object.entries(entryRes)) {
|
|
137
|
+
if (showAllEntries || showChangedEntries && Object.entries(
|
|
138
|
+
Object.entries(entryStatus[currentProject])[0]
|
|
139
|
+
)[1][1].status !== "no change") {
|
|
140
|
+
console.log(
|
|
141
|
+
log.infoText(
|
|
142
|
+
`${originalId} ${Object.entries(entryStatus || {}).filter((x) => x[0] !== "entryTitle").map(([projectId, projectStatus]) => {
|
|
143
|
+
var _a2;
|
|
144
|
+
const [targetGuid, { status }] = ((_a2 = Object.entries(
|
|
145
|
+
projectStatus || {}
|
|
146
|
+
)) == null ? void 0 : _a2[0]) || [
|
|
147
|
+
"",
|
|
148
|
+
{ x: { status: void 0 } }
|
|
149
|
+
];
|
|
150
|
+
return `${messages.migrate.status(status)(`${status}`)}${targetGuid !== originalId ? `-> ${targetGuid}` : ""}`;
|
|
151
|
+
})}`
|
|
152
|
+
) + ` ${log.helpText(contentTypeId)} ${entryStatus.entryTitle}`
|
|
153
|
+
);
|
|
154
|
+
for (const [projectId, projectStatus] of Object.entries(
|
|
155
|
+
entryStatus
|
|
156
|
+
).filter(([key]) => key !== "entryTitle")) {
|
|
157
|
+
const [targetGuid, { error, diff, status }] = Object.entries(
|
|
158
|
+
projectStatus
|
|
159
|
+
)[0];
|
|
160
|
+
if (error)
|
|
161
|
+
log.error(error);
|
|
162
|
+
if (diff && showDiff) {
|
|
163
|
+
console.log(
|
|
164
|
+
` ${log.highlightText(`diff:`)} ${log.infoText(
|
|
165
|
+
highlightDiffText(diff)
|
|
166
|
+
)}
|
|
167
|
+
`
|
|
168
|
+
);
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
console.log(``);
|
|
175
|
+
if ((contensis == null ? void 0 : contensis.isPreview) && ((_b = (_a = migrateResult.entriesToMigrate) == null ? void 0 : _a[currentProject]) == null ? void 0 : _b.totalCount) > 0 && !migrateResult.errors) {
|
|
176
|
+
log.help(messages.entries.commitTip());
|
|
177
|
+
}
|
|
178
|
+
if (action === "import") {
|
|
179
|
+
for (const [projectId, contentTypeCounts] of Object.entries(
|
|
180
|
+
migrateResult.entries || {}
|
|
181
|
+
)) {
|
|
182
|
+
log.help(
|
|
183
|
+
`import from project ${log.highlightText(projectId)} to ${log.boldText(
|
|
184
|
+
log.warningText(currentProject)
|
|
185
|
+
)}`
|
|
186
|
+
);
|
|
187
|
+
for (const [contentTypeId, count] of Object.entries(
|
|
188
|
+
contentTypeCounts
|
|
189
|
+
)) {
|
|
190
|
+
const entriesToMigrate = (_d = (_c = migrateResult.entriesToMigrate) == null ? void 0 : _c[projectId]) == null ? void 0 : _d[contentTypeId];
|
|
191
|
+
const existingCount = ((_f = (_e = migrateResult.existing) == null ? void 0 : _e[projectId]) == null ? void 0 : _f[contentTypeId]) || 0;
|
|
192
|
+
const existingPercent = (existingCount / count * 100).toFixed(0);
|
|
193
|
+
const noChangeOrTotalEntriesCount = typeof entriesToMigrate !== "number" ? (entriesToMigrate == null ? void 0 : entriesToMigrate["no change"]) || 0 : entriesToMigrate;
|
|
194
|
+
const isTotalCountRow = contentTypeId === "totalCount";
|
|
195
|
+
const changedPercentage = (noChangeOrTotalEntriesCount / count * 100).toFixed(0);
|
|
196
|
+
const existingColor = existingPercent === "0" ? log.warningText : log.infoText;
|
|
197
|
+
const changedColor = isTotalCountRow ? log.helpText : changedPercentage === "100" ? log.successText : log.warningText;
|
|
198
|
+
console.log(
|
|
199
|
+
` - ${isTotalCountRow ? log.highlightText(`${contentTypeId}: ${count}`) : `${contentTypeId}: ${log.helpText(count)}`}${changedPercentage === "100" ? "" : existingColor(
|
|
200
|
+
` [existing: ${isTotalCountRow ? existingCount : `${existingPercent}%`}]`
|
|
201
|
+
)}${existingPercent === "0" ? "" : changedColor(
|
|
202
|
+
` ${isTotalCountRow ? `[to change: ${noChangeOrTotalEntriesCount}]` : changedPercentage === "100" ? "up to date" : `[needs update: ${100 - Number(changedPercentage)}%]`}`
|
|
203
|
+
)}`
|
|
204
|
+
);
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
if ((_g = migrateResult.errors) == null ? void 0 : _g.length) {
|
|
208
|
+
console.log(
|
|
209
|
+
` - ${log.errorText(`errors: ${migrateResult.errors.length}`)}
|
|
210
|
+
`
|
|
211
|
+
);
|
|
212
|
+
for (const error of migrateResult.errors)
|
|
213
|
+
log.error(error.message || error);
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
};
|
|
217
|
+
const highlightDiffText = (str) => {
|
|
218
|
+
const addedRegex = new RegExp(/<<\+>>(.*?)<<\/\+>>/, "g");
|
|
219
|
+
const removedRegex = new RegExp(/<<->>(.*?)<<\/->>/, "g");
|
|
220
|
+
return str.replace(addedRegex, (match) => {
|
|
221
|
+
return import_logger.Logger.successText(
|
|
222
|
+
match.replace(/<<\+>>/g, "<+>").replace(/<<\/\+>>/g, "</+>")
|
|
223
|
+
);
|
|
224
|
+
}).replace(removedRegex, (match) => {
|
|
225
|
+
return import_logger.Logger.errorText(
|
|
226
|
+
match.replace(/<<->>/g, "<->").replace(/<<\/->>/g, "</->")
|
|
227
|
+
);
|
|
228
|
+
});
|
|
229
|
+
};
|
|
230
|
+
const printModelMigrationAnalysis = ({ log, messages }, result = {}) => {
|
|
231
|
+
for (const [contentTypeId, model] of Object.entries(result)) {
|
|
232
|
+
let mainOutput = log.standardText(` - ${contentTypeId}`);
|
|
233
|
+
let extraOutput = "";
|
|
234
|
+
let errorOutput = "";
|
|
235
|
+
let diffOutput = "";
|
|
236
|
+
for (const [key, details] of Object.entries(model)) {
|
|
237
|
+
if (key === "dependencies") {
|
|
238
|
+
extraOutput += log.infoText(
|
|
239
|
+
` references: [${details == null ? void 0 : details.join(", ")}]
|
|
240
|
+
`
|
|
241
|
+
);
|
|
242
|
+
}
|
|
243
|
+
if (key === "dependencyOf") {
|
|
244
|
+
extraOutput += log.infoText(
|
|
245
|
+
` required by: [${details == null ? void 0 : details.join(", ")}]
|
|
246
|
+
`
|
|
247
|
+
);
|
|
248
|
+
}
|
|
249
|
+
if (key === "projects") {
|
|
250
|
+
for (const [projectId, projectDetails] of Object.entries(details)) {
|
|
251
|
+
mainOutput += log.infoText(
|
|
252
|
+
` [${messages.migrate.status(projectDetails.status)(
|
|
253
|
+
`${projectId}: ${projectDetails.status}`
|
|
254
|
+
)}] v${projectDetails.versionNo}`
|
|
255
|
+
);
|
|
256
|
+
if (projectDetails.diff)
|
|
257
|
+
diffOutput += ` ${log.highlightText(`diff:`)} ${log.infoText(
|
|
258
|
+
highlightDiffText(projectDetails.diff)
|
|
259
|
+
)}
|
|
260
|
+
`;
|
|
261
|
+
if (projectDetails.error)
|
|
262
|
+
errorOutput += ` ${log.highlightText(
|
|
263
|
+
`error::`
|
|
264
|
+
)} ${log.errorText(projectDetails.error)}`;
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
console.log(mainOutput);
|
|
269
|
+
if (extraOutput) {
|
|
270
|
+
const search = "\n";
|
|
271
|
+
const replace = "";
|
|
272
|
+
console.log(
|
|
273
|
+
extraOutput.replace(
|
|
274
|
+
new RegExp(search + "([^" + search + "]*)$"),
|
|
275
|
+
replace + "$1"
|
|
276
|
+
)
|
|
277
|
+
);
|
|
278
|
+
}
|
|
279
|
+
if (diffOutput)
|
|
280
|
+
console.log(diffOutput);
|
|
281
|
+
if (errorOutput)
|
|
282
|
+
console.log(errorOutput);
|
|
283
|
+
}
|
|
284
|
+
};
|
|
285
|
+
const printModelMigrationResult = ({ log, messages }, result) => {
|
|
286
|
+
for (const [status, ids] of Object.entries(result)) {
|
|
287
|
+
if (ids == null ? void 0 : ids.length) {
|
|
288
|
+
if (status === "errors") {
|
|
289
|
+
const errors = ids;
|
|
290
|
+
log.raw(
|
|
291
|
+
` - ${status}: [ ${messages.migrate.models.result(status)(
|
|
292
|
+
ids.map((id) => id[0]).join(", ")
|
|
293
|
+
)} ]
|
|
294
|
+
`
|
|
295
|
+
);
|
|
296
|
+
for (const [contentTypeId, error] of errors)
|
|
297
|
+
log.error(
|
|
298
|
+
`${log.highlightText(contentTypeId)}: ${error.message}`,
|
|
299
|
+
error
|
|
300
|
+
);
|
|
301
|
+
} else
|
|
302
|
+
log.raw(
|
|
303
|
+
` - ${status}: [ ${messages.migrate.models.result(status)(
|
|
304
|
+
ids.join(", ")
|
|
305
|
+
)} ]`
|
|
306
|
+
);
|
|
307
|
+
}
|
|
308
|
+
}
|
|
309
|
+
};
|
|
310
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
311
|
+
0 && (module.exports = {
|
|
312
|
+
printBlockVersion,
|
|
313
|
+
printMigrateResult,
|
|
314
|
+
printModelMigrationAnalysis,
|
|
315
|
+
printModelMigrationResult
|
|
316
|
+
});
|
|
317
|
+
//# sourceMappingURL=console.printer.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/util/console.printer.ts"],
|
|
4
|
+
"sourcesContent": ["import dayjs from 'dayjs';\r\nimport { BlockVersion, MigrateModelsResult, MigrateStatus } from 'migratortron';\r\nimport ContensisCli from '~/services/ContensisCliService';\r\nimport { Logger } from './logger';\r\n\r\nconst formatDate = (date: Date | string, format = 'DD/MM/YYYY HH:mm') =>\r\n dayjs(date).format(format);\r\n\r\nexport const printBlockVersion = (\r\n { log, messages }: ContensisCli,\r\n block: BlockVersion,\r\n printOptions = {\r\n showSource: true,\r\n showStatus: true,\r\n showStaticPaths: true,\r\n showImage: true,\r\n }\r\n) => {\r\n console.log(\r\n ` ${log.standardText(`v${block.version.versionNo}`)} ${block.id}`\r\n );\r\n console.log(\r\n ` state: ${messages.blocks.runningStatus(\r\n block.status.broken ? 'broken' : block.status.running.global\r\n )}`\r\n );\r\n console.log(\r\n ` released: ${log.infoText(\r\n block.version.released\r\n ? `[${formatDate(block.version.released)}] ${block.version.releasedBy}`\r\n : 'no'\r\n )}`\r\n );\r\n if (block.version.madeLive)\r\n console.log(\r\n ` live: ${log.infoText(\r\n `[${formatDate(block.version.madeLive)}] ${block.version.madeLiveBy}`\r\n )}`\r\n );\r\n if (printOptions.showStatus) {\r\n console.log(` status:`);\r\n console.log(` deployment: ${log.infoText(block.status.deployment)}`);\r\n console.log(` workflow: ${log.infoText(block.status.workflow)}`);\r\n console.log(\r\n ` running status: ${messages.blocks.runningStatus(\r\n block.status.running.global\r\n )}`\r\n );\r\n console.log(` datacentres:`);\r\n console.log(\r\n ` hq: ${messages.blocks.runningStatus(\r\n block.status.running.dataCenters.hq\r\n )}`\r\n );\r\n console.log(\r\n ` london: ${messages.blocks.runningStatus(\r\n block.status.running.dataCenters.london\r\n )}`\r\n );\r\n console.log(\r\n ` manchester: ${messages.blocks.runningStatus(\r\n block.status.running.dataCenters.manchester\r\n )}`\r\n );\r\n }\r\n if (printOptions.showSource) {\r\n console.log(` source:`);\r\n console.log(` commit: ${log.helpText(block.source.commit.id)}`);\r\n console.log(\r\n ` message: ${log.infoText(\r\n block.source.commit.message\r\n ?.replaceAll('\\n', '\\\\n')\r\n .replaceAll('\\\\n\\\\n', '\\\\n')\r\n .replaceAll('\\\\n', '; ')\r\n )}`\r\n );\r\n console.log(\r\n ` committed: ${log.infoText(\r\n `[${formatDate(block.source.commit.dateTime)}] ${\r\n block.source.commit.authorEmail\r\n }`\r\n )}`\r\n );\r\n console.log(\r\n ` pushed: ${log.infoText(\r\n `[${formatDate(block.version.pushed)}] ${block.version.pushedBy}`\r\n )}`\r\n );\r\n console.log(` ${log.infoText(block.source.commit.commitUrl)}`);\r\n }\r\n if (printOptions.showImage) {\r\n console.log(` image:`);\r\n console.log(` uri: ${log.infoText(block.image.uri)}`);\r\n console.log(` tag: ${log.helpText(block.image.tag)}`);\r\n }\r\n if (printOptions.showStaticPaths) {\r\n if (block.staticPaths?.length) {\r\n console.log(` static paths:`);\r\n for (const path of block.staticPaths) console.log(` - ${path}`);\r\n }\r\n }\r\n if (block.stagingUrl)\r\n console.log(` staging url: ${log.infoText(block.stagingUrl)}`);\r\n console.log('');\r\n};\r\n\r\nexport const printMigrateResult = (\r\n { log, messages, contensis, currentProject }: ContensisCli,\r\n migrateResult: any,\r\n {\r\n action = 'import',\r\n showDiff = false,\r\n showAllEntries = false,\r\n showChangedEntries = false,\r\n }: {\r\n action?: 'import' | 'delete';\r\n showDiff?: boolean;\r\n showAllEntries?: boolean;\r\n showChangedEntries?: boolean;\r\n } = {}\r\n) => {\r\n if (Object.keys(migrateResult.entriesToMigrate.entryIds).length)\r\n console.log(``);\r\n\r\n for (const [contentTypeId, entryRes] of Object.entries(\r\n migrateResult.entriesToMigrate.entryIds\r\n ) as [string, any]) {\r\n for (const [originalId, entryStatus] of Object.entries(entryRes) as [\r\n string,\r\n any\r\n ][]) {\r\n // console.log(`${log.helpText(contentTypeId)} ${entryStatus.entryTitle}`);\r\n if (\r\n showAllEntries ||\r\n (showChangedEntries &&\r\n (\r\n Object.entries(\r\n Object.entries(entryStatus[currentProject])[0]\r\n )[1][1] as any\r\n ).status !== 'no change')\r\n ) {\r\n console.log(\r\n log.infoText(\r\n `${originalId} ${Object.entries(entryStatus || {})\r\n .filter(x => x[0] !== 'entryTitle')\r\n .map(([projectId, projectStatus]) => {\r\n const [targetGuid, { status }] = (Object.entries(\r\n projectStatus || {}\r\n )?.[0] as [string, { status: MigrateStatus }]) || [\r\n '',\r\n { x: { status: undefined } },\r\n ];\r\n return `${messages.migrate.status(status)(`${status}`)}${\r\n targetGuid !== originalId ? `-> ${targetGuid}` : ''\r\n }`;\r\n })}`\r\n ) + ` ${log.helpText(contentTypeId)} ${entryStatus.entryTitle}`\r\n );\r\n\r\n for (const [projectId, projectStatus] of Object.entries(\r\n entryStatus\r\n ).filter(([key]) => key !== 'entryTitle') as [string, any][]) {\r\n const [targetGuid, { error, diff, status }] = Object.entries(\r\n projectStatus\r\n )[0] as [string, any];\r\n if (error) log.error(error);\r\n if (diff && showDiff) {\r\n console.log(\r\n ` ${log.highlightText(`diff:`)} ${log.infoText(\r\n highlightDiffText(diff)\r\n )}\\n`\r\n );\r\n }\r\n }\r\n }\r\n }\r\n }\r\n console.log(``);\r\n if (\r\n contensis?.isPreview &&\r\n migrateResult.entriesToMigrate?.[currentProject]?.totalCount > 0 &&\r\n !migrateResult.errors\r\n ) {\r\n log.help(messages.entries.commitTip());\r\n }\r\n\r\n if (action === 'import') {\r\n for (const [projectId, contentTypeCounts] of Object.entries(\r\n migrateResult.entries || {}\r\n ) as [string, any][]) {\r\n log.help(\r\n `import from project ${log.highlightText(projectId)} to ${log.boldText(\r\n log.warningText(currentProject)\r\n )}`\r\n );\r\n for (const [contentTypeId, count] of Object.entries(\r\n contentTypeCounts\r\n ) as [string, number][]) {\r\n const entriesToMigrate =\r\n migrateResult.entriesToMigrate?.[projectId]?.[contentTypeId];\r\n const existingCount =\r\n migrateResult.existing?.[projectId]?.[contentTypeId] || 0;\r\n const existingPercent = ((existingCount / count) * 100).toFixed(0);\r\n const noChangeOrTotalEntriesCount =\r\n typeof entriesToMigrate !== 'number'\r\n ? entriesToMigrate?.['no change'] || 0\r\n : entriesToMigrate;\r\n\r\n const isTotalCountRow = contentTypeId === 'totalCount';\r\n\r\n const changedPercentage = (\r\n (noChangeOrTotalEntriesCount / count) *\r\n 100\r\n ).toFixed(0);\r\n\r\n const existingColor =\r\n existingPercent === '0' ? log.warningText : log.infoText;\r\n const changedColor = isTotalCountRow\r\n ? log.helpText\r\n : changedPercentage === '100'\r\n ? log.successText\r\n : log.warningText;\r\n\r\n console.log(\r\n ` - ${\r\n isTotalCountRow\r\n ? log.highlightText(`${contentTypeId}: ${count}`)\r\n : `${contentTypeId}: ${log.helpText(count)}`\r\n }${\r\n changedPercentage === '100'\r\n ? ''\r\n : existingColor(\r\n ` [existing: ${\r\n isTotalCountRow ? existingCount : `${existingPercent}%`\r\n }]`\r\n )\r\n }${\r\n existingPercent === '0'\r\n ? ''\r\n : changedColor(\r\n ` ${\r\n isTotalCountRow\r\n ? `[to change: ${noChangeOrTotalEntriesCount}]`\r\n : changedPercentage === '100'\r\n ? 'up to date'\r\n : `[needs update: ${100 - Number(changedPercentage)}%]`\r\n }`\r\n )\r\n }`\r\n );\r\n }\r\n }\r\n if (migrateResult.errors?.length) {\r\n console.log(\r\n ` - ${log.errorText(`errors: ${migrateResult.errors.length}`)}\\n`\r\n );\r\n for (const error of migrateResult.errors)\r\n log.error(error.message || error);\r\n }\r\n }\r\n};\r\n\r\nconst highlightDiffText = (str: string) => {\r\n const addedRegex = new RegExp(/<<\\+>>(.*?)<<\\/\\+>>/, 'g');\r\n const removedRegex = new RegExp(/<<->>(.*?)<<\\/->>/, 'g');\r\n return str\r\n .replace(addedRegex, match => {\r\n return Logger.successText(\r\n match.replace(/<<\\+>>/g, '<+>').replace(/<<\\/\\+>>/g, '</+>')\r\n );\r\n })\r\n .replace(removedRegex, match => {\r\n return Logger.errorText(\r\n match.replace(/<<->>/g, '<->').replace(/<<\\/->>/g, '</->')\r\n );\r\n });\r\n};\r\n\r\nexport const printModelMigrationAnalysis = (\r\n { log, messages }: ContensisCli,\r\n result: any = {}\r\n) => {\r\n for (const [contentTypeId, model] of Object.entries(result) as [\r\n string,\r\n any\r\n ][]) {\r\n let mainOutput = log.standardText(` - ${contentTypeId}`);\r\n let extraOutput = '';\r\n let errorOutput = '';\r\n let diffOutput = '';\r\n for (const [key, details] of Object.entries(model) as [string, any][]) {\r\n if (key === 'dependencies') {\r\n extraOutput += log.infoText(\r\n ` references: [${details?.join(', ')}]\\n`\r\n );\r\n }\r\n if (key === 'dependencyOf') {\r\n extraOutput += log.infoText(\r\n ` required by: [${details?.join(', ')}]\\n`\r\n );\r\n }\r\n if (key === 'projects') {\r\n for (const [projectId, projectDetails] of Object.entries(details) as [\r\n string,\r\n any\r\n ][]) {\r\n mainOutput += log.infoText(\r\n ` [${messages.migrate.status(projectDetails.status)(\r\n `${projectId}: ${projectDetails.status}`\r\n )}] v${projectDetails.versionNo}`\r\n );\r\n if (projectDetails.diff)\r\n diffOutput += ` ${log.highlightText(`diff:`)} ${log.infoText(\r\n highlightDiffText(projectDetails.diff)\r\n )}\\n`;\r\n if (projectDetails.error)\r\n errorOutput += ` ${log.highlightText(\r\n `error::`\r\n )} ${log.errorText(projectDetails.error)}`;\r\n }\r\n }\r\n }\r\n console.log(mainOutput);\r\n if (extraOutput) {\r\n const search = '\\n';\r\n const replace = '';\r\n console.log(\r\n extraOutput.replace(\r\n new RegExp(search + '([^' + search + ']*)$'),\r\n replace + '$1'\r\n )\r\n );\r\n }\r\n if (diffOutput) console.log(diffOutput);\r\n if (errorOutput) console.log(errorOutput);\r\n }\r\n};\r\n\r\ntype MigrateResultSummary = MigrateModelsResult['']['contentTypes'];\r\ntype MigrateResultStatus = keyof MigrateResultSummary;\r\n\r\nexport const printModelMigrationResult = (\r\n { log, messages }: ContensisCli,\r\n result: MigrateResultSummary\r\n) => {\r\n for (const [status, ids] of Object.entries(result) as [\r\n MigrateResultStatus,\r\n string[]\r\n ][]) {\r\n if (ids?.length) {\r\n if (status === 'errors') {\r\n const errors: [string, MappedError][] = ids as any;\r\n log.raw(\r\n ` - ${status}: [ ${messages.migrate.models.result(status)(\r\n ids.map(id => id[0]).join(', ')\r\n )} ]\\n`\r\n );\r\n for (const [contentTypeId, error] of errors)\r\n log.error(\r\n `${log.highlightText(contentTypeId)}: ${error.message}`,\r\n error\r\n );\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MAAM,4BAA4B,CACvC,EAAE,KAAK,SAAS,GAChB,WACG;AACH,aAAW,CAAC,QAAQ,GAAG,KAAK,OAAO,QAAQ,MAAM,GAG5C;AACH,QAAI,2BAAK,QAAQ;AACf,UAAI,WAAW,UAAU;AACvB,cAAM,SAAkC;AACxC,YAAI;AAAA,UACF,OAAO,aAAa,SAAS,QAAQ,OAAO,OAAO,MAAM;AAAA,YACvD,IAAI,IAAI,QAAM,GAAG,EAAE,EAAE,KAAK,IAAI;AAAA,UAChC;AAAA;AAAA,QACF;AACA,mBAAW,CAAC,eAAe,KAAK,KAAK;AACnC,cAAI;AAAA,YACF,GAAG,IAAI,cAAc,aAAa,MAAM,MAAM;AAAA,YAC9C;AAAA,UACF;AAAA,MACJ;AACE,YAAI;AAAA,UACF,OAAO,aAAa,SAAS,QAAQ,OAAO,OAAO,MAAM;AAAA,YACvD,IAAI,KAAK,IAAI;AAAA,UACf;AAAA,QACF;AAAA,IACJ;AAAA,EACF;AACF;",
|
|
6
|
+
"names": ["dayjs", "_a"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
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
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
22
|
+
mod
|
|
23
|
+
));
|
|
24
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
25
|
+
var csv_formatter_exports = {};
|
|
26
|
+
__export(csv_formatter_exports, {
|
|
27
|
+
csvFormatter: () => csvFormatter
|
|
28
|
+
});
|
|
29
|
+
module.exports = __toCommonJS(csv_formatter_exports);
|
|
30
|
+
var import_flat = require("flat");
|
|
31
|
+
var import_json2csv = require("json2csv");
|
|
32
|
+
var import_deep_cleaner = __toESM(require("deep-cleaner"));
|
|
33
|
+
const flattenObject = (obj) => (0, import_flat.flatten)((0, import_deep_cleaner.default)(obj, ["workflow"]));
|
|
34
|
+
const csvFormatter = (entries) => {
|
|
35
|
+
const flatEntries = [];
|
|
36
|
+
if (Array.isArray(entries))
|
|
37
|
+
for (const entry of entries) {
|
|
38
|
+
flatEntries.push(flattenObject(entry));
|
|
39
|
+
}
|
|
40
|
+
else
|
|
41
|
+
flatEntries.push(flattenObject(entries));
|
|
42
|
+
const json2csvParser = new import_json2csv.Parser();
|
|
43
|
+
const csv = json2csvParser.parse(flatEntries);
|
|
44
|
+
return csv;
|
|
45
|
+
};
|
|
46
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
47
|
+
0 && (module.exports = {
|
|
48
|
+
csvFormatter
|
|
49
|
+
});
|
|
50
|
+
//# sourceMappingURL=csv.formatter.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/util/csv.formatter.ts"],
|
|
4
|
+
"sourcesContent": ["import { flatten } from 'flat';\r\nimport { Parser } from 'json2csv';\r\nimport cleaner from 'deep-cleaner';\r\n\r\nconst flattenObject = (obj: any) => flatten(cleaner(obj, ['workflow']));\r\n\r\nexport const csvFormatter = <T>(entries: T | T[]) => {\r\n // Flatten the passed in object\r\n const flatEntries = [];\r\n if (Array.isArray(entries))\r\n for (const entry of entries) {\r\n flatEntries.push(flattenObject(entry));\r\n }\r\n else flatEntries.push(flattenObject(entries));\r\n\r\n // Parse the flattened object to csv\r\n const json2csvParser = new Parser();\r\n const csv = json2csvParser.parse(flatEntries);\r\n\r\n return csv;\r\n};\r\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAAwB;AACxB,sBAAuB;AACvB,0BAAoB;AAEpB,MAAM,gBAAgB,CAAC,YAAa,yBAAQ,oBAAAA,SAAQ,KAAK,CAAC,UAAU,CAAC,CAAC;AAE/D,MAAM,eAAe,CAAI,YAAqB;AAEnD,QAAM,cAAc,CAAC;AACrB,MAAI,MAAM,QAAQ,OAAO;AACvB,eAAW,SAAS,SAAS;AAC3B,kBAAY,KAAK,cAAc,KAAK,CAAC;AAAA,IACvC;AAAA;AACG,gBAAY,KAAK,cAAc,OAAO,CAAC;AAG5C,QAAM,iBAAiB,IAAI,uBAAO;AAClC,QAAM,MAAM,eAAe,MAAM,WAAW;AAE5C,SAAO;AACT;",
|
|
6
|
+
"names": ["cleaner"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,97 @@
|
|
|
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
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
22
|
+
mod
|
|
23
|
+
));
|
|
24
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
25
|
+
var util_exports = {};
|
|
26
|
+
__export(util_exports, {
|
|
27
|
+
Logging: () => Logging,
|
|
28
|
+
isJson: () => isJson,
|
|
29
|
+
isPassword: () => isPassword,
|
|
30
|
+
isSharedSecret: () => isSharedSecret,
|
|
31
|
+
isUuid: () => isUuid,
|
|
32
|
+
tryParse: () => tryParse,
|
|
33
|
+
tryStringify: () => tryStringify,
|
|
34
|
+
url: () => url
|
|
35
|
+
});
|
|
36
|
+
module.exports = __toCommonJS(util_exports);
|
|
37
|
+
var import_mergeWith = __toESM(require("lodash/mergeWith"));
|
|
38
|
+
var import_logger = require("./logger");
|
|
39
|
+
var import_en_GB = require("../localisation/en-GB.js");
|
|
40
|
+
const isSharedSecret = (str = "") => str.length > 80 && str.split("-").length === 3 ? str : void 0;
|
|
41
|
+
const isPassword = (str = "") => !isSharedSecret(str) ? str : void 0;
|
|
42
|
+
const tryParse = (str) => {
|
|
43
|
+
try {
|
|
44
|
+
return typeof str === "object" ? str : JSON.parse(str);
|
|
45
|
+
} catch (e) {
|
|
46
|
+
return false;
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
const isJson = (str) => typeof str === "object" || !!tryParse(str);
|
|
50
|
+
const tryStringify = (obj) => {
|
|
51
|
+
try {
|
|
52
|
+
return typeof obj === "object" ? JSON.stringify(obj) : obj;
|
|
53
|
+
} catch (e) {
|
|
54
|
+
return obj;
|
|
55
|
+
}
|
|
56
|
+
};
|
|
57
|
+
const isUuid = (str) => {
|
|
58
|
+
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;
|
|
59
|
+
return regexExp.test(str);
|
|
60
|
+
};
|
|
61
|
+
const url = (alias, project) => {
|
|
62
|
+
const projectAndAlias = project && project.toLowerCase() !== "website" ? `${project.toLowerCase()}-${alias}` : alias;
|
|
63
|
+
return {
|
|
64
|
+
api: `https://api-${alias}.cloud.contensis.com`,
|
|
65
|
+
cms: `https://cms-${alias}.cloud.contensis.com`,
|
|
66
|
+
liveWeb: `https://live-${projectAndAlias}.cloud.contensis.com`,
|
|
67
|
+
previewWeb: `https://preview-${projectAndAlias}.cloud.contensis.com`,
|
|
68
|
+
iisWeb: `https://iis-live-${projectAndAlias}.cloud.contensis.com`,
|
|
69
|
+
iisPreviewWeb: `https://iis-preview-${projectAndAlias}.cloud.contensis.com`
|
|
70
|
+
};
|
|
71
|
+
};
|
|
72
|
+
const Logging = async (language = "en-GB") => {
|
|
73
|
+
const defaultMessages = import_en_GB.LogMessages;
|
|
74
|
+
let localisedMessages = defaultMessages;
|
|
75
|
+
if (language === "en-GB") {
|
|
76
|
+
}
|
|
77
|
+
return {
|
|
78
|
+
messages: (0, import_mergeWith.default)(
|
|
79
|
+
localisedMessages,
|
|
80
|
+
defaultMessages,
|
|
81
|
+
(v, s) => v || s
|
|
82
|
+
),
|
|
83
|
+
Log: import_logger.Logger
|
|
84
|
+
};
|
|
85
|
+
};
|
|
86
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
87
|
+
0 && (module.exports = {
|
|
88
|
+
Logging,
|
|
89
|
+
isJson,
|
|
90
|
+
isPassword,
|
|
91
|
+
isSharedSecret,
|
|
92
|
+
isUuid,
|
|
93
|
+
tryParse,
|
|
94
|
+
tryStringify,
|
|
95
|
+
url
|
|
96
|
+
});
|
|
97
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/util/index.ts"],
|
|
4
|
+
"sourcesContent": ["import mergeWith from 'lodash/mergeWith';\r\nimport { Logger } from './logger';\r\nimport { LogMessages as enGB } from '../localisation/en-GB.js';\r\n\r\nexport const isSharedSecret = (str = '') =>\r\n str.length > 80 && str.split('-').length === 3 ? str : undefined;\r\n\r\nexport const isPassword = (str = '') =>\r\n !isSharedSecret(str) ? str : undefined;\r\n\r\nexport const tryParse = (str: string) => {\r\n try {\r\n return typeof str === 'object' ? str : JSON.parse(str);\r\n } catch (e) {\r\n return false;\r\n }\r\n};\r\n\r\nexport const isJson = (str: string) =>\r\n typeof str === 'object' || !!tryParse(str);\r\n\r\nexport const tryStringify = (obj: any) => {\r\n try {\r\n return typeof obj === 'object' ? JSON.stringify(obj) : obj;\r\n } catch (e) {\r\n return obj;\r\n }\r\n};\r\n\r\nexport const isUuid = (str: string) => {\r\n // Regular expression to check if string is a valid UUID\r\n const regexExp =\r\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;\r\n\r\n return regexExp.test(str);\r\n};\r\n\r\nexport const url = (alias: string, project: string) => {\r\n const projectAndAlias =\r\n project && project.toLowerCase() !== 'website'\r\n ? `${project.toLowerCase()}-${alias}`\r\n : alias;\r\n return {\r\n api: `https://api-${alias}.cloud.contensis.com`,\r\n cms: `https://cms-${alias}.cloud.contensis.com`,\r\n liveWeb: `https://live-${projectAndAlias}.cloud.contensis.com`,\r\n previewWeb: `https://preview-${projectAndAlias}.cloud.contensis.com`,\r\n iisWeb: `https://iis-live-${projectAndAlias}.cloud.contensis.com`,\r\n iisPreviewWeb: `https://iis-preview-${projectAndAlias}.cloud.contensis.com`,\r\n };\r\n};\r\n\r\nexport const Logging = async (language = 'en-GB') => {\r\n const defaultMessages = enGB;\r\n // const { LogMessages: defaultMessages } = await import(\r\n // `../localisation/en-GB.js`\r\n // );\r\n let localisedMessages = defaultMessages;\r\n\r\n if (language === 'en-GB') {\r\n // Using a variable import e.g. `import(`../localisation/${language}.js`);`\r\n // does not play well with packaged executables\r\n // So we have to hard code the import for each language individually\r\n }\r\n return {\r\n messages: mergeWith(\r\n localisedMessages,\r\n defaultMessages,\r\n (v, s) => v || s\r\n ) as typeof defaultMessages,\r\n Log: Logger,\r\n };\r\n};\r\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,uBAAsB;AACtB,oBAAuB;AACvB,mBAAoC;AAE7B,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,QAAgB;AACvC,MAAI;AACF,WAAO,OAAO,QAAQ,WAAW,MAAM,KAAK,MAAM,GAAG;AAAA,EACvD,SAAS,GAAP;AACA,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,GAAP;AACA,WAAO;AAAA,EACT;AACF;AAEO,MAAM,SAAS,CAAC,QAAgB;AAErC,QAAM,WACJ;AAEF,SAAO,SAAS,KAAK,GAAG;AAC1B;AAEO,MAAM,MAAM,CAAC,OAAe,YAAoB;AACrD,QAAM,kBACJ,WAAW,QAAQ,YAAY,MAAM,YACjC,GAAG,QAAQ,YAAY,KAAK,UAC5B;AACN,SAAO;AAAA,IACL,KAAK,eAAe;AAAA,IACpB,KAAK,eAAe;AAAA,IACpB,SAAS,gBAAgB;AAAA,IACzB,YAAY,mBAAmB;AAAA,IAC/B,QAAQ,oBAAoB;AAAA,IAC5B,eAAe,uBAAuB;AAAA,EACxC;AACF;AAEO,MAAM,UAAU,OAAO,WAAW,YAAY;AACnD,QAAM,kBAAkB,aAAAA;AAIxB,MAAI,oBAAoB;AAExB,MAAI,aAAa,SAAS;AAAA,EAI1B;AACA,SAAO;AAAA,IACL,cAAU,iBAAAC;AAAA,MACR;AAAA,MACA;AAAA,MACA,CAAC,GAAG,MAAM,KAAK;AAAA,IACjB;AAAA,IACA,KAAK;AAAA,EACP;AACF;",
|
|
6
|
+
"names": ["enGB", "mergeWith"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
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 json_formatter_exports = {};
|
|
20
|
+
__export(json_formatter_exports, {
|
|
21
|
+
jsonFormatter: () => jsonFormatter
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(json_formatter_exports);
|
|
24
|
+
const jsonFormatter = (obj) => JSON.stringify(obj, null, 2);
|
|
25
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
26
|
+
0 && (module.exports = {
|
|
27
|
+
jsonFormatter
|
|
28
|
+
});
|
|
29
|
+
//# sourceMappingURL=json.formatter.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/util/json.formatter.ts"],
|
|
4
|
+
"sourcesContent": ["export const jsonFormatter = <T>(obj: T) => JSON.stringify(obj, null, 2);\r\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAO,MAAM,gBAAgB,CAAI,QAAW,KAAK,UAAU,KAAK,MAAM,CAAC;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|