@messagevisor/catalog 0.1.0 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/assets/index-DrsX4U8c.css +1 -0
- package/dist/assets/index-OXIn4K-M.js +73 -0
- package/dist/index.html +2 -2
- package/lib/node/index.js +210 -100
- package/lib/node/index.js.map +1 -1
- package/package.json +2 -2
- package/src/components/details/FieldGrid.tsx +1 -1
- package/src/components/details/GroupSegmentTree.tsx +2 -1
- package/src/components/details/UsageLinks.tsx +3 -2
- package/src/components/history/HistoryTimeline.tsx +4 -3
- package/src/components/layout/PageHeader.tsx +13 -3
- package/src/components/lists/EntityList.tsx +2 -1
- package/src/components/ui/EntityKey.tsx +20 -0
- package/src/node/index.spec.ts +222 -0
- package/src/node/index.ts +241 -97
- package/src/pages/EntityDetailPage.tsx +14 -5
- package/dist/assets/index-CfGbXx4X.css +0 -1
- package/dist/assets/index-r8ugP5JL.js +0 -73
package/dist/index.html
CHANGED
|
@@ -5,8 +5,8 @@
|
|
|
5
5
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
6
6
|
<link rel="icon" type="image/png" href="/favicon.png" />
|
|
7
7
|
<title>Messagevisor Catalog</title>
|
|
8
|
-
<script type="module" crossorigin src="/assets/index-
|
|
9
|
-
<link rel="stylesheet" crossorigin href="/assets/index-
|
|
8
|
+
<script type="module" crossorigin src="/assets/index-OXIn4K-M.js"></script>
|
|
9
|
+
<link rel="stylesheet" crossorigin href="/assets/index-DrsX4U8c.css">
|
|
10
10
|
</head>
|
|
11
11
|
<body>
|
|
12
12
|
<div id="root"></div>
|
package/lib/node/index.js
CHANGED
|
@@ -226,26 +226,22 @@ function getTargetMessageKeys(target, messageKeys) {
|
|
|
226
226
|
})
|
|
227
227
|
.sort();
|
|
228
228
|
}
|
|
229
|
-
function
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
entity.key === key &&
|
|
234
|
-
(typeof set === "undefined" || entity.set === set);
|
|
235
|
-
});
|
|
236
|
-
});
|
|
237
|
-
if (!entry) {
|
|
238
|
-
return undefined;
|
|
239
|
-
}
|
|
229
|
+
function getHistoryEntityKey(type, key, set) {
|
|
230
|
+
return "".concat(set || "", "\u001F").concat(type, "\u001F").concat(key);
|
|
231
|
+
}
|
|
232
|
+
function toLastModified(entry) {
|
|
240
233
|
return {
|
|
241
234
|
commit: entry.commit,
|
|
242
235
|
author: entry.author,
|
|
243
236
|
timestamp: entry.timestamp,
|
|
244
237
|
};
|
|
245
238
|
}
|
|
246
|
-
function
|
|
239
|
+
function getLastModified(historyIndex, type, key, set) {
|
|
240
|
+
return historyIndex.lastModifiedByEntity[getHistoryEntityKey(type, key, set)];
|
|
241
|
+
}
|
|
242
|
+
function getEntitySummary(entity, type, key, historyIndex, set, extra) {
|
|
247
243
|
if (extra === void 0) { extra = {}; }
|
|
248
|
-
return __assign(__assign({ key: key, description: entity.description, archived: entity.archived, deprecated: entity.deprecated }, extra), { lastModified: getLastModified(
|
|
244
|
+
return __assign(__assign({ key: key, description: entity.description, archived: entity.archived, deprecated: entity.deprecated }, extra), { lastModified: getLastModified(historyIndex, type, key, set), href: "entities/".concat(type, "/").concat(encodeKey(key), ".json") });
|
|
249
245
|
}
|
|
250
246
|
function getPathValue(value, segments) {
|
|
251
247
|
var current = value;
|
|
@@ -431,6 +427,153 @@ function runGit(rootDirectoryPath, args) {
|
|
|
431
427
|
stdio: ["ignore", "pipe", "ignore"],
|
|
432
428
|
});
|
|
433
429
|
}
|
|
430
|
+
function getCatalogHistoryPathPatterns(rootDirectoryPath, projectConfig) {
|
|
431
|
+
return projectConfig.sets
|
|
432
|
+
? [path.relative(rootDirectoryPath, projectConfig.setsDirectoryPath)]
|
|
433
|
+
: [
|
|
434
|
+
path.relative(rootDirectoryPath, projectConfig.localesDirectoryPath),
|
|
435
|
+
path.relative(rootDirectoryPath, projectConfig.messagesDirectoryPath),
|
|
436
|
+
path.relative(rootDirectoryPath, projectConfig.attributesDirectoryPath),
|
|
437
|
+
path.relative(rootDirectoryPath, projectConfig.segmentsDirectoryPath),
|
|
438
|
+
path.relative(rootDirectoryPath, projectConfig.targetsDirectoryPath),
|
|
439
|
+
path.relative(rootDirectoryPath, projectConfig.testsDirectoryPath),
|
|
440
|
+
];
|
|
441
|
+
}
|
|
442
|
+
function createEmptyHistoryIndex() {
|
|
443
|
+
return {
|
|
444
|
+
entries: [],
|
|
445
|
+
bySet: {},
|
|
446
|
+
byEntity: {},
|
|
447
|
+
lastModifiedByEntity: {},
|
|
448
|
+
};
|
|
449
|
+
}
|
|
450
|
+
function addHistoryIndexEntry(target, key, entry) {
|
|
451
|
+
if (!target[key]) {
|
|
452
|
+
target[key] = [];
|
|
453
|
+
}
|
|
454
|
+
target[key].push(entry);
|
|
455
|
+
}
|
|
456
|
+
function buildCatalogHistoryIndex(entries) {
|
|
457
|
+
var index = createEmptyHistoryIndex();
|
|
458
|
+
index.entries = entries;
|
|
459
|
+
for (var _i = 0, entries_1 = entries; _i < entries_1.length; _i++) {
|
|
460
|
+
var entry = entries_1[_i];
|
|
461
|
+
var seenSets = new Set();
|
|
462
|
+
for (var _a = 0, _b = entry.entities; _a < _b.length; _a++) {
|
|
463
|
+
var entity = _b[_a];
|
|
464
|
+
if (entity.type === "test") {
|
|
465
|
+
continue;
|
|
466
|
+
}
|
|
467
|
+
var entityKey = getHistoryEntityKey(entity.type, entity.key, entity.set);
|
|
468
|
+
addHistoryIndexEntry(index.byEntity, entityKey, entry);
|
|
469
|
+
if (!index.lastModifiedByEntity[entityKey]) {
|
|
470
|
+
index.lastModifiedByEntity[entityKey] = toLastModified(entry);
|
|
471
|
+
}
|
|
472
|
+
if (entity.set && !seenSets.has(entity.set)) {
|
|
473
|
+
seenSets.add(entity.set);
|
|
474
|
+
addHistoryIndexEntry(index.bySet, entity.set, entry);
|
|
475
|
+
}
|
|
476
|
+
}
|
|
477
|
+
}
|
|
478
|
+
return index;
|
|
479
|
+
}
|
|
480
|
+
function appendHistoryEntry(history, current) {
|
|
481
|
+
if (!current || current.entities.length === 0) {
|
|
482
|
+
return;
|
|
483
|
+
}
|
|
484
|
+
history.push({
|
|
485
|
+
commit: current.commit,
|
|
486
|
+
author: current.author,
|
|
487
|
+
timestamp: current.timestamp,
|
|
488
|
+
entities: current.entities,
|
|
489
|
+
});
|
|
490
|
+
}
|
|
491
|
+
function addHistoryEntity(current, entity) {
|
|
492
|
+
if (entity.type === "test") {
|
|
493
|
+
return;
|
|
494
|
+
}
|
|
495
|
+
var entityKey = getHistoryEntityKey(entity.type, entity.key, entity.set);
|
|
496
|
+
if (current.seenEntityKeys.has(entityKey)) {
|
|
497
|
+
return;
|
|
498
|
+
}
|
|
499
|
+
current.seenEntityKeys.add(entityKey);
|
|
500
|
+
current.entities.push(entity);
|
|
501
|
+
}
|
|
502
|
+
function streamCatalogGitHistory(rootDirectoryPath, projectConfig) {
|
|
503
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
504
|
+
var pathPatterns, args;
|
|
505
|
+
return __generator(this, function (_a) {
|
|
506
|
+
pathPatterns = getCatalogHistoryPathPatterns(rootDirectoryPath, projectConfig);
|
|
507
|
+
args = __spreadArray([
|
|
508
|
+
"-C",
|
|
509
|
+
rootDirectoryPath,
|
|
510
|
+
"log",
|
|
511
|
+
"--name-only",
|
|
512
|
+
"--pretty=format:%x1e%h%x1f%an%x1f%aI",
|
|
513
|
+
"--relative",
|
|
514
|
+
"--no-merges",
|
|
515
|
+
"--"
|
|
516
|
+
], pathPatterns, true);
|
|
517
|
+
return [2 /*return*/, new Promise(function (resolve, reject) {
|
|
518
|
+
var current;
|
|
519
|
+
var buffer = "";
|
|
520
|
+
var history = [];
|
|
521
|
+
var git = childProcess.spawn("git", args, {
|
|
522
|
+
stdio: ["ignore", "pipe", "ignore"],
|
|
523
|
+
});
|
|
524
|
+
function processLine(line) {
|
|
525
|
+
if (!line) {
|
|
526
|
+
return;
|
|
527
|
+
}
|
|
528
|
+
if (line.startsWith("\x1e")) {
|
|
529
|
+
appendHistoryEntry(history, current);
|
|
530
|
+
var _a = line.slice(1).split("\x1f"), commit = _a[0], author = _a[1], timestamp = _a[2];
|
|
531
|
+
current =
|
|
532
|
+
commit && author && timestamp
|
|
533
|
+
? {
|
|
534
|
+
commit: commit,
|
|
535
|
+
author: author,
|
|
536
|
+
timestamp: timestamp,
|
|
537
|
+
entities: [],
|
|
538
|
+
seenEntityKeys: new Set(),
|
|
539
|
+
}
|
|
540
|
+
: undefined;
|
|
541
|
+
return;
|
|
542
|
+
}
|
|
543
|
+
if (!current) {
|
|
544
|
+
return;
|
|
545
|
+
}
|
|
546
|
+
var entity = getEntityInfoFromRelativePath(rootDirectoryPath, projectConfig, line);
|
|
547
|
+
if (entity) {
|
|
548
|
+
addHistoryEntity(current, entity);
|
|
549
|
+
}
|
|
550
|
+
}
|
|
551
|
+
git.stdout.setEncoding("utf8");
|
|
552
|
+
git.stdout.on("data", function (chunk) {
|
|
553
|
+
buffer += chunk;
|
|
554
|
+
var lines = buffer.split(/\r?\n/);
|
|
555
|
+
buffer = lines.pop() || "";
|
|
556
|
+
for (var _i = 0, lines_1 = lines; _i < lines_1.length; _i++) {
|
|
557
|
+
var line = lines_1[_i];
|
|
558
|
+
processLine(line);
|
|
559
|
+
}
|
|
560
|
+
});
|
|
561
|
+
git.on("error", reject);
|
|
562
|
+
git.on("close", function (code) {
|
|
563
|
+
if (buffer) {
|
|
564
|
+
processLine(buffer);
|
|
565
|
+
}
|
|
566
|
+
appendHistoryEntry(history, current);
|
|
567
|
+
if (code === 0) {
|
|
568
|
+
resolve(history);
|
|
569
|
+
return;
|
|
570
|
+
}
|
|
571
|
+
reject(new Error("git log exited with code ".concat(code)));
|
|
572
|
+
});
|
|
573
|
+
})];
|
|
574
|
+
});
|
|
575
|
+
});
|
|
576
|
+
}
|
|
434
577
|
function isExecutableFile(filePath) {
|
|
435
578
|
try {
|
|
436
579
|
var stat = fs.statSync(filePath);
|
|
@@ -496,49 +639,23 @@ function detectDevEditors() {
|
|
|
496
639
|
}
|
|
497
640
|
return editors;
|
|
498
641
|
}
|
|
499
|
-
function
|
|
500
|
-
|
|
501
|
-
var
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
"--name-only",
|
|
514
|
-
"--pretty=format:%h|%an|%aI",
|
|
515
|
-
"--relative",
|
|
516
|
-
"--no-merges",
|
|
517
|
-
"--"
|
|
518
|
-
], pathPatterns, true));
|
|
519
|
-
var blocks = raw.split("\n\n");
|
|
520
|
-
var history_1 = [];
|
|
521
|
-
for (var _i = 0, blocks_1 = blocks; _i < blocks_1.length; _i++) {
|
|
522
|
-
var block = blocks_1[_i];
|
|
523
|
-
if (!block.trim()) {
|
|
524
|
-
continue;
|
|
525
|
-
}
|
|
526
|
-
var lines = block.split("\n").filter(Boolean);
|
|
527
|
-
var _a = lines[0].split("|"), commit = _a[0], author = _a[1], timestamp = _a[2];
|
|
528
|
-
var entities = lines
|
|
529
|
-
.slice(1)
|
|
530
|
-
.map(function (line) { return getEntityInfoFromRelativePath(rootDirectoryPath, projectConfig, line); })
|
|
531
|
-
.filter(Boolean);
|
|
532
|
-
var filteredEntities = entities.filter(function (entity) { return entity.type !== "test"; });
|
|
533
|
-
if (filteredEntities.length > 0) {
|
|
534
|
-
history_1.push({ commit: commit, author: author, timestamp: timestamp, entities: filteredEntities });
|
|
642
|
+
function getGitHistoryIndex(rootDirectoryPath, projectConfig) {
|
|
643
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
644
|
+
var _a, _error_1;
|
|
645
|
+
return __generator(this, function (_b) {
|
|
646
|
+
switch (_b.label) {
|
|
647
|
+
case 0:
|
|
648
|
+
_b.trys.push([0, 2, , 3]);
|
|
649
|
+
_a = buildCatalogHistoryIndex;
|
|
650
|
+
return [4 /*yield*/, streamCatalogGitHistory(rootDirectoryPath, projectConfig)];
|
|
651
|
+
case 1: return [2 /*return*/, _a.apply(void 0, [_b.sent()])];
|
|
652
|
+
case 2:
|
|
653
|
+
_error_1 = _b.sent();
|
|
654
|
+
return [2 /*return*/, createEmptyHistoryIndex()];
|
|
655
|
+
case 3: return [2 /*return*/];
|
|
535
656
|
}
|
|
536
|
-
}
|
|
537
|
-
|
|
538
|
-
}
|
|
539
|
-
catch (_error) {
|
|
540
|
-
return [];
|
|
541
|
-
}
|
|
657
|
+
});
|
|
658
|
+
});
|
|
542
659
|
}
|
|
543
660
|
function getCurrentBranch(rootDirectoryPath) {
|
|
544
661
|
try {
|
|
@@ -646,17 +763,8 @@ function writeHistoryPages(directoryPath, history) {
|
|
|
646
763
|
});
|
|
647
764
|
});
|
|
648
765
|
}
|
|
649
|
-
function
|
|
650
|
-
return
|
|
651
|
-
return entry.entities.some(function (entity) {
|
|
652
|
-
return entity.type === type &&
|
|
653
|
-
entity.key === key &&
|
|
654
|
-
(typeof set === "undefined" || entity.set === set);
|
|
655
|
-
});
|
|
656
|
-
});
|
|
657
|
-
}
|
|
658
|
-
function filterHistoryForSet(history, set) {
|
|
659
|
-
return history.filter(function (entry) { return entry.entities.some(function (entity) { return entity.set === set; }); });
|
|
766
|
+
function getHistoryForEntity(historyIndex, type, key, set) {
|
|
767
|
+
return historyIndex.byEntity[getHistoryEntityKey(type, key, set)] || [];
|
|
660
768
|
}
|
|
661
769
|
function getSourceFileInfo(repositoryRootDirectoryPath, rootDirectoryPath, projectConfig, type, key) {
|
|
662
770
|
var directoryByType = {
|
|
@@ -825,7 +933,7 @@ function buildSetCatalog(context, set, projectConfig, datasource, outputRelative
|
|
|
825
933
|
}
|
|
826
934
|
}
|
|
827
935
|
}
|
|
828
|
-
history = set ?
|
|
936
|
+
history = set ? context.historyIndex.bySet[set] || [] : context.historyIndex.entries;
|
|
829
937
|
localeDirections = getLocaleDirections(locales);
|
|
830
938
|
duplicateResult = context.duplicateResultsBySet[getDuplicateSetKey(set)] || {
|
|
831
939
|
set: set || null,
|
|
@@ -900,9 +1008,9 @@ function buildSetCatalog(context, set, projectConfig, datasource, outputRelative
|
|
|
900
1008
|
targetKey,
|
|
901
1009
|
context.runtime.resolveFormats(localeKey, locales, targets[targetKey]),
|
|
902
1010
|
]; })),
|
|
903
|
-
lastModified: getLastModified(context.
|
|
1011
|
+
lastModified: getLastModified(context.historyIndex, "locale", localeKey, set || undefined),
|
|
904
1012
|
};
|
|
905
|
-
index.entities.locale.push(getEntitySummary(locale, "locale", localeKey, context.
|
|
1013
|
+
index.entities.locale.push(getEntitySummary(locale, "locale", localeKey, context.historyIndex, set || undefined, {
|
|
906
1014
|
targets: sortStrings(Array.from(localeTargets[localeKey] || [])),
|
|
907
1015
|
}));
|
|
908
1016
|
return [4 /*yield*/, writeJson(path.join(outputDirectoryPath, "entities", "locale", "".concat(encodeKey(localeKey), ".json")), detail)];
|
|
@@ -911,7 +1019,7 @@ function buildSetCatalog(context, set, projectConfig, datasource, outputRelative
|
|
|
911
1019
|
return [4 /*yield*/, writeJson(path.join(outputDirectoryPath, "duplicates", "locales", "".concat(encodeKey(localeKey), ".json")), toLocaleDuplicatesFile(localeKey, duplicatesByLocale))];
|
|
912
1020
|
case 2:
|
|
913
1021
|
_16.sent();
|
|
914
|
-
return [4 /*yield*/, writeHistoryPages(path.join(outputDirectoryPath, "history", "locale", encodeKey(localeKey)),
|
|
1022
|
+
return [4 /*yield*/, writeHistoryPages(path.join(outputDirectoryPath, "history", "locale", encodeKey(localeKey)), getHistoryForEntity(context.historyIndex, "locale", localeKey, set || undefined))];
|
|
915
1023
|
case 3:
|
|
916
1024
|
_16.sent();
|
|
917
1025
|
return [2 /*return*/];
|
|
@@ -965,7 +1073,7 @@ function buildSetCatalog(context, set, projectConfig, datasource, outputRelative
|
|
|
965
1073
|
return resolveTranslationRow(override.translations, localeKey, locales);
|
|
966
1074
|
}),
|
|
967
1075
|
}); }),
|
|
968
|
-
lastModified: getLastModified(context.
|
|
1076
|
+
lastModified: getLastModified(context.historyIndex, "message", messageKey, set || undefined),
|
|
969
1077
|
};
|
|
970
1078
|
directLocales = localeKeys.filter(function (lk) { return message.translations && typeof message.translations[lk] === "string"; });
|
|
971
1079
|
overrideLocalesSet = new Set();
|
|
@@ -992,11 +1100,11 @@ function buildSetCatalog(context, set, projectConfig, datasource, outputRelative
|
|
|
992
1100
|
}
|
|
993
1101
|
}
|
|
994
1102
|
}
|
|
995
|
-
index.entities.message.push(getEntitySummary(message, "message", messageKey, context.
|
|
1103
|
+
index.entities.message.push(getEntitySummary(message, "message", messageKey, context.historyIndex, set || undefined, __assign(__assign({ targets: sortStrings(messageTargets[messageKey] || []) }, (directLocales.length > 0 ? { locales: sortStrings(directLocales) } : {})), (overrideLocalesList.length > 0 ? { overrideLocales: overrideLocalesList } : {}))));
|
|
996
1104
|
return [4 /*yield*/, writeJson(path.join(outputDirectoryPath, "entities", "message", "".concat(encodeKey(messageKey), ".json")), detail)];
|
|
997
1105
|
case 1:
|
|
998
1106
|
_22.sent();
|
|
999
|
-
return [4 /*yield*/, writeHistoryPages(path.join(outputDirectoryPath, "history", "message", encodeKey(messageKey)),
|
|
1107
|
+
return [4 /*yield*/, writeHistoryPages(path.join(outputDirectoryPath, "history", "message", encodeKey(messageKey)), getHistoryForEntity(context.historyIndex, "message", messageKey, set || undefined))];
|
|
1000
1108
|
case 2:
|
|
1001
1109
|
_22.sent();
|
|
1002
1110
|
return [2 /*return*/];
|
|
@@ -1051,15 +1159,15 @@ function buildSetCatalog(context, set, projectConfig, datasource, outputRelative
|
|
|
1051
1159
|
segments: sortStrings(Array.from(attributesUsedInSegments[attributeKey] || [])),
|
|
1052
1160
|
messages: sortStrings(Array.from(attributesUsedInMessages[attributeKey] || [])),
|
|
1053
1161
|
},
|
|
1054
|
-
lastModified: getLastModified(context.
|
|
1162
|
+
lastModified: getLastModified(context.historyIndex, "attribute", attributeKey, set || undefined),
|
|
1055
1163
|
};
|
|
1056
|
-
index.entities.attribute.push(getEntitySummary(attribute, "attribute", attributeKey, context.
|
|
1164
|
+
index.entities.attribute.push(getEntitySummary(attribute, "attribute", attributeKey, context.historyIndex, set || undefined, {
|
|
1057
1165
|
targets: sortStrings(Array.from(attributeTargets[attributeKey] || [])),
|
|
1058
1166
|
}));
|
|
1059
1167
|
return [4 /*yield*/, writeJson(path.join(outputDirectoryPath, "entities", "attribute", "".concat(encodeKey(attributeKey), ".json")), detail)];
|
|
1060
1168
|
case 19:
|
|
1061
1169
|
_15.sent();
|
|
1062
|
-
return [4 /*yield*/, writeHistoryPages(path.join(outputDirectoryPath, "history", "attribute", encodeKey(attributeKey)),
|
|
1170
|
+
return [4 /*yield*/, writeHistoryPages(path.join(outputDirectoryPath, "history", "attribute", encodeKey(attributeKey)), getHistoryForEntity(context.historyIndex, "attribute", attributeKey, set || undefined))];
|
|
1063
1171
|
case 20:
|
|
1064
1172
|
_15.sent();
|
|
1065
1173
|
_15.label = 21;
|
|
@@ -1086,15 +1194,15 @@ function buildSetCatalog(context, set, projectConfig, datasource, outputRelative
|
|
|
1086
1194
|
attributes: sortStrings(Array.from(usedAttributes)),
|
|
1087
1195
|
messages: sortStrings(Array.from(segmentsUsedInMessages[segmentKey] || [])),
|
|
1088
1196
|
},
|
|
1089
|
-
lastModified: getLastModified(context.
|
|
1197
|
+
lastModified: getLastModified(context.historyIndex, "segment", segmentKey, set || undefined),
|
|
1090
1198
|
};
|
|
1091
|
-
index.entities.segment.push(getEntitySummary(segment, "segment", segmentKey, context.
|
|
1199
|
+
index.entities.segment.push(getEntitySummary(segment, "segment", segmentKey, context.historyIndex, set || undefined, {
|
|
1092
1200
|
targets: sortStrings(Array.from(segmentTargets[segmentKey] || [])),
|
|
1093
1201
|
}));
|
|
1094
1202
|
return [4 /*yield*/, writeJson(path.join(outputDirectoryPath, "entities", "segment", "".concat(encodeKey(segmentKey), ".json")), detail)];
|
|
1095
1203
|
case 24:
|
|
1096
1204
|
_15.sent();
|
|
1097
|
-
return [4 /*yield*/, writeHistoryPages(path.join(outputDirectoryPath, "history", "segment", encodeKey(segmentKey)),
|
|
1205
|
+
return [4 /*yield*/, writeHistoryPages(path.join(outputDirectoryPath, "history", "segment", encodeKey(segmentKey)), getHistoryForEntity(context.historyIndex, "segment", segmentKey, set || undefined))];
|
|
1098
1206
|
case 25:
|
|
1099
1207
|
_15.sent();
|
|
1100
1208
|
_15.label = 26;
|
|
@@ -1127,15 +1235,15 @@ function buildSetCatalog(context, set, projectConfig, datasource, outputRelative
|
|
|
1127
1235
|
formatsByLocale: formatsByLocale,
|
|
1128
1236
|
formatRowsByLocale: formatRowsByLocale,
|
|
1129
1237
|
messages: targetMessages[targetKey],
|
|
1130
|
-
lastModified: getLastModified(context.
|
|
1238
|
+
lastModified: getLastModified(context.historyIndex, "target", targetKey, set || undefined),
|
|
1131
1239
|
};
|
|
1132
|
-
index.entities.target.push(getEntitySummary(target, "target", targetKey, context.
|
|
1240
|
+
index.entities.target.push(getEntitySummary(target, "target", targetKey, context.historyIndex, set || undefined, {
|
|
1133
1241
|
messageCount: targetMessages[targetKey].length,
|
|
1134
1242
|
}));
|
|
1135
1243
|
return [4 /*yield*/, writeJson(path.join(outputDirectoryPath, "entities", "target", "".concat(encodeKey(targetKey), ".json")), detail)];
|
|
1136
1244
|
case 29:
|
|
1137
1245
|
_15.sent();
|
|
1138
|
-
return [4 /*yield*/, writeHistoryPages(path.join(outputDirectoryPath, "history", "target", encodeKey(targetKey)),
|
|
1246
|
+
return [4 /*yield*/, writeHistoryPages(path.join(outputDirectoryPath, "history", "target", encodeKey(targetKey)), getHistoryForEntity(context.historyIndex, "target", targetKey, set || undefined))];
|
|
1139
1247
|
case 30:
|
|
1140
1248
|
_15.sent();
|
|
1141
1249
|
_15.label = 31;
|
|
@@ -1181,7 +1289,7 @@ function copyCatalogAssets(outputDirectoryPath) {
|
|
|
1181
1289
|
}
|
|
1182
1290
|
function exportCatalog(runtime_1, rootDirectoryPath_1, projectConfig_1, datasource_1) {
|
|
1183
1291
|
return __awaiter(this, arguments, void 0, function (runtime, rootDirectoryPath, projectConfig, datasource, options) {
|
|
1184
|
-
var outputDirectoryPath, dataDirectoryPath, devEditors,
|
|
1292
|
+
var outputDirectoryPath, dataDirectoryPath, devEditors, historyIndex, duplicateTranslations, duplicateResultsBySet, context, executions, setIndexes, _i, executions_1, execution, outputRelativeDirectory, _a, _b, manifest;
|
|
1185
1293
|
if (options === void 0) { options = {}; }
|
|
1186
1294
|
return __generator(this, function (_c) {
|
|
1187
1295
|
switch (_c.label) {
|
|
@@ -1203,9 +1311,11 @@ function exportCatalog(runtime_1, rootDirectoryPath_1, projectConfig_1, datasour
|
|
|
1203
1311
|
_c.label = 4;
|
|
1204
1312
|
case 4:
|
|
1205
1313
|
devEditors = options.dev ? options.devEditors || detectDevEditors() : [];
|
|
1206
|
-
|
|
1207
|
-
return [4 /*yield*/, runtime.findDuplicateTranslations(projectConfig, datasource)];
|
|
1314
|
+
return [4 /*yield*/, getGitHistoryIndex(rootDirectoryPath, projectConfig)];
|
|
1208
1315
|
case 5:
|
|
1316
|
+
historyIndex = _c.sent();
|
|
1317
|
+
return [4 /*yield*/, runtime.findDuplicateTranslations(projectConfig, datasource)];
|
|
1318
|
+
case 6:
|
|
1209
1319
|
duplicateTranslations = _c.sent();
|
|
1210
1320
|
duplicateResultsBySet = Object.fromEntries(duplicateTranslations.results.map(function (result) { return [getDuplicateSetKey(result.set), result]; }));
|
|
1211
1321
|
context = {
|
|
@@ -1213,34 +1323,34 @@ function exportCatalog(runtime_1, rootDirectoryPath_1, projectConfig_1, datasour
|
|
|
1213
1323
|
repositoryRootDirectoryPath: getRepositoryRootDirectoryPath(rootDirectoryPath),
|
|
1214
1324
|
outputDirectoryPath: outputDirectoryPath,
|
|
1215
1325
|
dataDirectoryPath: dataDirectoryPath,
|
|
1216
|
-
|
|
1326
|
+
historyIndex: historyIndex,
|
|
1217
1327
|
runtime: runtime,
|
|
1218
1328
|
devEditors: devEditors,
|
|
1219
1329
|
duplicateResultsBySet: duplicateResultsBySet,
|
|
1220
1330
|
};
|
|
1221
1331
|
return [4 /*yield*/, runtime.getProjectSetExecutions(projectConfig, datasource)];
|
|
1222
|
-
case
|
|
1332
|
+
case 7:
|
|
1223
1333
|
executions = _c.sent();
|
|
1224
1334
|
setIndexes = {};
|
|
1225
|
-
return [4 /*yield*/, writeHistoryPages(path.join(dataDirectoryPath, "project", "history"),
|
|
1226
|
-
case
|
|
1335
|
+
return [4 /*yield*/, writeHistoryPages(path.join(dataDirectoryPath, "project", "history"), historyIndex.entries)];
|
|
1336
|
+
case 8:
|
|
1227
1337
|
_c.sent();
|
|
1228
1338
|
_i = 0, executions_1 = executions;
|
|
1229
|
-
_c.label =
|
|
1230
|
-
case
|
|
1231
|
-
if (!(_i < executions_1.length)) return [3 /*break*/,
|
|
1339
|
+
_c.label = 9;
|
|
1340
|
+
case 9:
|
|
1341
|
+
if (!(_i < executions_1.length)) return [3 /*break*/, 12];
|
|
1232
1342
|
execution = executions_1[_i];
|
|
1233
1343
|
outputRelativeDirectory = projectConfig.sets ? path.join("sets", execution.set) : "root";
|
|
1234
1344
|
_a = setIndexes;
|
|
1235
1345
|
_b = execution.set || "root";
|
|
1236
1346
|
return [4 /*yield*/, buildSetCatalog(context, execution.set, execution.projectConfig, execution.datasource, outputRelativeDirectory)];
|
|
1237
|
-
case 9:
|
|
1238
|
-
_a[_b] = _c.sent();
|
|
1239
|
-
_c.label = 10;
|
|
1240
1347
|
case 10:
|
|
1241
|
-
|
|
1242
|
-
|
|
1348
|
+
_a[_b] = _c.sent();
|
|
1349
|
+
_c.label = 11;
|
|
1243
1350
|
case 11:
|
|
1351
|
+
_i++;
|
|
1352
|
+
return [3 /*break*/, 9];
|
|
1353
|
+
case 12:
|
|
1244
1354
|
manifest = {
|
|
1245
1355
|
schemaVersion: exports.CATALOG_SCHEMA_VERSION,
|
|
1246
1356
|
generatedAt: new Date().toISOString(),
|
|
@@ -1262,7 +1372,7 @@ function exportCatalog(runtime_1, rootDirectoryPath_1, projectConfig_1, datasour
|
|
|
1262
1372
|
counts: Object.fromEntries(Object.keys(setIndexes).map(function (key) { return [key, setIndexes[key].counts]; })),
|
|
1263
1373
|
};
|
|
1264
1374
|
return [4 /*yield*/, writeJson(path.join(dataDirectoryPath, "manifest.json"), manifest)];
|
|
1265
|
-
case
|
|
1375
|
+
case 13:
|
|
1266
1376
|
_c.sent();
|
|
1267
1377
|
console.log("Catalog exported to ".concat(outputDirectoryPath));
|
|
1268
1378
|
return [2 /*return*/, {
|
|
@@ -1333,8 +1443,8 @@ function createProjectWatcher(rootDirectoryPath, ignoredDirectoryPaths, onChange
|
|
|
1333
1443
|
catch (_a) {
|
|
1334
1444
|
return;
|
|
1335
1445
|
}
|
|
1336
|
-
for (var _i = 0,
|
|
1337
|
-
var entry =
|
|
1446
|
+
for (var _i = 0, entries_2 = entries; _i < entries_2.length; _i++) {
|
|
1447
|
+
var entry = entries_2[_i];
|
|
1338
1448
|
var entryPath = path.join(directoryPath, entry.name);
|
|
1339
1449
|
if (shouldIgnore(entryPath)) {
|
|
1340
1450
|
continue;
|