contensis-cli 1.0.0-beta.52 → 1.0.0-beta.54
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/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/package.json +1 -1
- package/src/util/console.printer.ts +6 -6
- package/src/version.ts +1 -1
|
@@ -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;
|
|
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 migrateStatusAndCount = migrateResult.entriesToMigrate[currentProject][contentTypeId];
|
|
191
|
+
const existingCount = ((_d = (_c = migrateResult.existing) == null ? void 0 : _c[currentProject]) == null ? void 0 : _d[contentTypeId]) || 0;
|
|
192
|
+
const existingPercent = (existingCount / count * 100).toFixed(0);
|
|
193
|
+
const noChangeOrTotalEntriesCount = typeof migrateStatusAndCount !== "number" ? (migrateStatusAndCount == null ? void 0 : migrateStatusAndCount["no change"]) || 0 : migrateStatusAndCount;
|
|
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 ((_e = migrateResult.errors) == null ? void 0 : _e.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';\nimport { BlockVersion, MigrateModelsResult, MigrateStatus } from 'migratortron';\nimport ContensisCli from '~/services/ContensisCliService';\nimport { Logger } from './logger';\n\nconst formatDate = (date: Date | string, format = 'DD/MM/YYYY HH:mm') =>\n dayjs(date).format(format);\n\nexport const printBlockVersion = (\n { log, messages }: ContensisCli,\n block: BlockVersion,\n printOptions = {\n showSource: true,\n showStatus: true,\n showStaticPaths: true,\n showImage: true,\n }\n) => {\n console.log(\n ` ${log.standardText(`v${block.version.versionNo}`)} ${block.id}`\n );\n console.log(\n ` state: ${messages.blocks.runningStatus(\n block.status.broken ? 'broken' : block.status.running.global\n )}`\n );\n console.log(\n ` released: ${log.infoText(\n block.version.released\n ? `[${formatDate(block.version.released)}] ${block.version.releasedBy}`\n : 'no'\n )}`\n );\n if (block.version.madeLive)\n console.log(\n ` live: ${log.infoText(\n `[${formatDate(block.version.madeLive)}] ${block.version.madeLiveBy}`\n )}`\n );\n if (printOptions.showStatus) {\n console.log(` status:`);\n console.log(` deployment: ${log.infoText(block.status.deployment)}`);\n console.log(` workflow: ${log.infoText(block.status.workflow)}`);\n console.log(\n ` running status: ${messages.blocks.runningStatus(\n block.status.running.global\n )}`\n );\n console.log(` datacentres:`);\n console.log(\n ` hq: ${messages.blocks.runningStatus(\n block.status.running.dataCenters.hq\n )}`\n );\n console.log(\n ` london: ${messages.blocks.runningStatus(\n block.status.running.dataCenters.london\n )}`\n );\n console.log(\n ` manchester: ${messages.blocks.runningStatus(\n block.status.running.dataCenters.manchester\n )}`\n );\n }\n if (printOptions.showSource) {\n console.log(` source:`);\n console.log(` commit: ${log.helpText(block.source.commit.id)}`);\n console.log(\n ` message: ${log.infoText(\n block.source.commit.message\n ?.replaceAll('\\n', '\\\\n')\n .replaceAll('\\\\n\\\\n', '\\\\n')\n .replaceAll('\\\\n', '; ')\n )}`\n );\n console.log(\n ` committed: ${log.infoText(\n `[${formatDate(block.source.commit.dateTime)}] ${\n block.source.commit.authorEmail\n }`\n )}`\n );\n console.log(\n ` pushed: ${log.infoText(\n `[${formatDate(block.version.pushed)}] ${block.version.pushedBy}`\n )}`\n );\n console.log(` ${log.infoText(block.source.commit.commitUrl)}`);\n }\n if (printOptions.showImage) {\n console.log(` image:`);\n console.log(` uri: ${log.infoText(block.image.uri)}`);\n console.log(` tag: ${log.helpText(block.image.tag)}`);\n }\n if (printOptions.showStaticPaths) {\n if (block.staticPaths?.length) {\n console.log(` static paths:`);\n for (const path of block.staticPaths) console.log(` - ${path}`);\n }\n }\n if (block.stagingUrl)\n console.log(` staging url: ${log.infoText(block.stagingUrl)}`);\n console.log('');\n};\n\nexport const printMigrateResult = (\n { log, messages, contensis, currentProject }: ContensisCli,\n migrateResult: any,\n {\n action = 'import',\n showDiff = false,\n showAllEntries = false,\n showChangedEntries = false,\n }: {\n action?: 'import' | 'delete';\n showDiff?: boolean;\n showAllEntries?: boolean;\n showChangedEntries?: boolean;\n } = {}\n) => {\n if (Object.keys(migrateResult.entriesToMigrate.entryIds).length)\n console.log(``);\n\n for (const [contentTypeId, entryRes] of Object.entries(\n migrateResult.entriesToMigrate.entryIds\n ) as [string, any]) {\n for (const [originalId, entryStatus] of Object.entries(entryRes) as [\n string,\n any\n ][]) {\n // console.log(`${log.helpText(contentTypeId)} ${entryStatus.entryTitle}`);\n if (\n showAllEntries ||\n (showChangedEntries &&\n (\n Object.entries(\n Object.entries(entryStatus[currentProject])[0]\n )[1][1] as any\n ).status !== 'no change')\n ) {\n console.log(\n log.infoText(\n `${originalId} ${Object.entries(entryStatus || {})\n .filter(x => x[0] !== 'entryTitle')\n .map(([projectId, projectStatus]) => {\n const [targetGuid, { status }] = (Object.entries(\n projectStatus || {}\n )?.[0] as [string, { status: MigrateStatus }]) || [\n '',\n { x: { status: undefined } },\n ];\n return `${messages.migrate.status(status)(`${status}`)}${\n targetGuid !== originalId ? `-> ${targetGuid}` : ''\n }`;\n })}`\n ) + ` ${log.helpText(contentTypeId)} ${entryStatus.entryTitle}`\n );\n\n for (const [projectId, projectStatus] of Object.entries(\n entryStatus\n ).filter(([key]) => key !== 'entryTitle') as [string, any][]) {\n const [targetGuid, { error, diff, status }] = Object.entries(\n projectStatus\n )[0] as [string, any];\n if (error) log.error(error);\n if (diff && showDiff) {\n console.log(\n ` ${log.highlightText(`diff:`)} ${log.infoText(\n highlightDiffText(diff)\n )}\\n`\n );\n }\n }\n }\n }\n }\n console.log(``);\n if (\n contensis?.isPreview &&\n migrateResult.entriesToMigrate?.[currentProject]?.totalCount > 0 &&\n !migrateResult.errors\n ) {\n log.help(messages.entries.commitTip());\n }\n\n if (action === 'import') {\n for (const [projectId, contentTypeCounts] of Object.entries(\n migrateResult.entries || {}\n ) as [string, any][]) {\n log.help(\n `import from project ${log.highlightText(projectId)} to ${log.boldText(\n log.warningText(currentProject)\n )}`\n );\n for (const [contentTypeId, count] of Object.entries(\n contentTypeCounts\n ) as [string, number][]) {\n const migrateStatusAndCount =\n migrateResult.entriesToMigrate[currentProject][contentTypeId];\n const existingCount =\n migrateResult.existing?.[currentProject]?.[contentTypeId] || 0;\n const existingPercent = ((existingCount / count) * 100).toFixed(0);\n const noChangeOrTotalEntriesCount =\n typeof migrateStatusAndCount !== 'number'\n ? migrateStatusAndCount?.['no change'] || 0\n : migrateStatusAndCount;\n\n const isTotalCountRow = contentTypeId === 'totalCount';\n\n const changedPercentage = (\n (noChangeOrTotalEntriesCount / count) *\n 100\n ).toFixed(0);\n\n const existingColor =\n existingPercent === '0' ? log.warningText : log.infoText;\n const changedColor = isTotalCountRow\n ? log.helpText\n : changedPercentage === '100'\n ? log.successText\n : log.warningText;\n\n console.log(\n ` - ${\n isTotalCountRow\n ? log.highlightText(`${contentTypeId}: ${count}`)\n : `${contentTypeId}: ${log.helpText(count)}`\n }${\n changedPercentage === '100'\n ? ''\n : existingColor(\n ` [existing: ${\n isTotalCountRow ? existingCount : `${existingPercent}%`\n }]`\n )\n }${\n existingPercent === '0'\n ? ''\n : changedColor(\n ` ${\n isTotalCountRow\n ? `[to change: ${noChangeOrTotalEntriesCount}]`\n : changedPercentage === '100'\n ? 'up to date'\n : `[needs update: ${100 - Number(changedPercentage)}%]`\n }`\n )\n }`\n );\n }\n }\n if (migrateResult.errors?.length) {\n console.log(\n ` - ${log.errorText(`errors: ${migrateResult.errors.length}`)}\\n`\n );\n for (const error of migrateResult.errors)\n log.error(error.message || error);\n }\n }\n};\n\nconst highlightDiffText = (str: string) => {\n const addedRegex = new RegExp(/<<\\+>>(.*?)<<\\/\\+>>/, 'g');\n const removedRegex = new RegExp(/<<->>(.*?)<<\\/->>/, 'g');\n return str\n .replace(addedRegex, match => {\n return Logger.successText(\n match.replace(/<<\\+>>/g, '<+>').replace(/<<\\/\\+>>/g, '</+>')\n );\n })\n .replace(removedRegex, match => {\n return Logger.errorText(\n match.replace(/<<->>/g, '<->').replace(/<<\\/->>/g, '</->')\n );\n });\n};\n\nexport const printModelMigrationAnalysis = (\n { log, messages }: ContensisCli,\n result: any = {}\n) => {\n for (const [contentTypeId, model] of Object.entries(result) as [\n string,\n any\n ][]) {\n let mainOutput = log.standardText(` - ${contentTypeId}`);\n let extraOutput = '';\n let errorOutput = '';\n let diffOutput = '';\n for (const [key, details] of Object.entries(model) as [string, any][]) {\n if (key === 'dependencies') {\n extraOutput += log.infoText(\n ` references: [${details?.join(', ')}]\\n`\n );\n }\n if (key === 'dependencyOf') {\n extraOutput += log.infoText(\n ` required by: [${details?.join(', ')}]\\n`\n );\n }\n if (key === 'projects') {\n for (const [projectId, projectDetails] of Object.entries(details) as [\n string,\n any\n ][]) {\n mainOutput += log.infoText(\n ` [${messages.migrate.status(projectDetails.status)(\n `${projectId}: ${projectDetails.status}`\n )}] v${projectDetails.versionNo}`\n );\n if (projectDetails.diff)\n diffOutput += ` ${log.highlightText(`diff:`)} ${log.infoText(\n highlightDiffText(projectDetails.diff)\n )}\\n`;\n if (projectDetails.error)\n errorOutput += ` ${log.highlightText(\n `error::`\n )} ${log.errorText(projectDetails.error)}`;\n }\n }\n }\n console.log(mainOutput);\n if (extraOutput) {\n const search = '\\n';\n const replace = '';\n console.log(\n extraOutput.replace(\n new RegExp(search + '([^' + search + ']*)$'),\n replace + '$1'\n )\n );\n }\n if (diffOutput) console.log(diffOutput);\n if (errorOutput) console.log(errorOutput);\n }\n};\n\ntype MigrateResultSummary = MigrateModelsResult['']['contentTypes'];\ntype MigrateResultStatus = keyof MigrateResultSummary;\n\nexport const printModelMigrationResult = (\n { log, messages }: ContensisCli,\n result: MigrateResultSummary\n) => {\n for (const [status, ids] of Object.entries(result) as [\n MigrateResultStatus,\n string[]\n ][]) {\n if (ids?.length) {\n if (status === 'errors') {\n const errors: [string, MappedError][] = ids as any;\n log.raw(\n ` - ${status}: [ ${messages.migrate.models.result(status)(\n ids.map(id => id[0]).join(', ')\n )} ]\\n`\n );\n for (const [contentTypeId, error] of errors)\n log.error(\n `${log.highlightText(contentTypeId)}: ${error.message}`,\n error\n );\n } else\n log.raw(\n ` - ${status}: [ ${messages.migrate.models.result(status)(\n ids.join(', ')\n )} ]`\n );\n }\n }\n};\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAAkB;AAGlB,oBAAuB;AAEvB,MAAM,aAAa,CAAC,MAAqB,SAAS,2BAChD,aAAAA,SAAM,IAAI,EAAE,OAAO,MAAM;AAEpB,MAAM,oBAAoB,CAC/B,EAAE,KAAK,SAAS,GAChB,OACA,eAAe;AAAA,EACb,YAAY;AAAA,EACZ,YAAY;AAAA,EACZ,iBAAiB;AAAA,EACjB,WAAW;AACb,MACG;AAjBL;AAkBE,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AAa,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';\nimport { Parser } from 'json2csv';\nimport cleaner from 'deep-cleaner';\n\nconst flattenObject = (obj: any) => flatten(cleaner(obj, ['workflow']));\n\nexport const csvFormatter = <T>(entries: T | T[]) => {\n // Flatten the passed in object\n const flatEntries = [];\n if (Array.isArray(entries))\n for (const entry of entries) {\n flatEntries.push(flattenObject(entry));\n }\n else flatEntries.push(flattenObject(entries));\n\n // Parse the flattened object to csv\n const json2csvParser = new Parser();\n const csv = json2csvParser.parse(flatEntries);\n\n return csv;\n};\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';\nimport { Logger } from './logger';\nimport { LogMessages as enGB } from '../localisation/en-GB.js';\n\nexport 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: string) => {\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 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\nexport const url = (alias: string, project: string) => {\n const projectAndAlias =\n project && project.toLowerCase() !== 'website'\n ? `${project.toLowerCase()}-${alias}`\n : alias;\n return {\n api: `https://api-${alias}.cloud.contensis.com`,\n cms: `https://cms-${alias}.cloud.contensis.com`,\n liveWeb: `https://live-${projectAndAlias}.cloud.contensis.com`,\n previewWeb: `https://preview-${projectAndAlias}.cloud.contensis.com`,\n iisWeb: `https://iis-live-${projectAndAlias}.cloud.contensis.com`,\n iisPreviewWeb: `https://iis-preview-${projectAndAlias}.cloud.contensis.com`,\n };\n};\n\nexport const Logging = async (language = 'en-GB') => {\n const defaultMessages = enGB;\n // const { LogMessages: defaultMessages } = await import(\n // `../localisation/en-GB.js`\n // );\n let localisedMessages = defaultMessages;\n\n if (language === 'en-GB') {\n // Using a variable import e.g. `import(`../localisation/${language}.js`);`\n // does not play well with packaged executables\n // So we have to hard code the import for each language individually\n }\n return {\n messages: mergeWith(\n localisedMessages,\n defaultMessages,\n (v, s) => v || s\n ) as typeof defaultMessages,\n Log: Logger,\n };\n};\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,uBAAsB;AACtB,oBAAuB;AACvB,mBAAo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
|
+
}
|
|
@@ -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);\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAO,MAAM,gBAAgB,CAAI,QAAW,KAAK,UAAU,KAAK,MAAM,CAAC;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|