@verbaly/compiler 0.73.0 → 0.74.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/cli.js +38 -8
- package/dist/cli.js.map +1 -1
- package/dist/index.js +38 -8
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -1083,7 +1083,26 @@ function pruneCatalogs(cfg, catalogs, registry) {
|
|
|
1083
1083
|
}
|
|
1084
1084
|
//#endregion
|
|
1085
1085
|
//#region src/validate.ts
|
|
1086
|
-
|
|
1086
|
+
let remembered = /* @__PURE__ */ new Map();
|
|
1087
|
+
let reading;
|
|
1088
|
+
function read(message) {
|
|
1089
|
+
if (!reading) return parse(message, parseIcu);
|
|
1090
|
+
let tree = reading.get(message);
|
|
1091
|
+
if (!tree) {
|
|
1092
|
+
tree = remembered.get(message) ?? parse(message, parseIcu);
|
|
1093
|
+
reading.set(message, tree);
|
|
1094
|
+
}
|
|
1095
|
+
return tree;
|
|
1096
|
+
}
|
|
1097
|
+
function gatePass(run) {
|
|
1098
|
+
reading = /* @__PURE__ */ new Map();
|
|
1099
|
+
try {
|
|
1100
|
+
return run();
|
|
1101
|
+
} finally {
|
|
1102
|
+
remembered = reading;
|
|
1103
|
+
reading = void 0;
|
|
1104
|
+
}
|
|
1105
|
+
}
|
|
1087
1106
|
const PLURAL_CATEGORIES = /* @__PURE__ */ new Set([
|
|
1088
1107
|
"zero",
|
|
1089
1108
|
"one",
|
|
@@ -2316,6 +2335,9 @@ function warningCount(result) {
|
|
|
2316
2335
|
return result.broken.filter((entry) => entry.severity === "warning").length + result.extra.length + result.divergent.length + result.outdated.length;
|
|
2317
2336
|
}
|
|
2318
2337
|
function check(cfg, catalogs, registry, fingerprints = {}) {
|
|
2338
|
+
return gatePass(() => checkPass(cfg, catalogs, registry, fingerprints));
|
|
2339
|
+
}
|
|
2340
|
+
function checkPass(cfg, catalogs, registry, fingerprints) {
|
|
2319
2341
|
const extracted = registry.messages();
|
|
2320
2342
|
const flat = {};
|
|
2321
2343
|
for (const locale of cfg.locales) flat[locale] = flatten(catalogs[locale] ?? {});
|
|
@@ -2605,14 +2627,20 @@ function suggestedPattern(rel) {
|
|
|
2605
2627
|
const slash = rel.indexOf("/");
|
|
2606
2628
|
return slash < 0 ? rel : `${rel.slice(0, slash)}/**/*.${SOURCE_EXTENSIONS}`;
|
|
2607
2629
|
}
|
|
2608
|
-
function
|
|
2609
|
-
if (cfg.include.length === 0) return () => void 0;
|
|
2630
|
+
function outsidePath(cfg) {
|
|
2610
2631
|
const included = picomatch(cfg.include);
|
|
2611
2632
|
const excluded = picomatch(cfg.exclude);
|
|
2612
|
-
return (
|
|
2633
|
+
return (id) => {
|
|
2613
2634
|
const rel = relativeId(cfg, id);
|
|
2614
|
-
|
|
2615
|
-
|
|
2635
|
+
return rel.startsWith("..") || included(rel) || excluded(rel) ? void 0 : rel;
|
|
2636
|
+
};
|
|
2637
|
+
}
|
|
2638
|
+
function createOutsideCheck(cfg) {
|
|
2639
|
+
if (cfg.include.length === 0) return () => void 0;
|
|
2640
|
+
const outside = outsidePath(cfg);
|
|
2641
|
+
return (code, id) => {
|
|
2642
|
+
const rel = outside(id);
|
|
2643
|
+
if (rel === void 0 || !TAGGED_HINT.test(code)) return void 0;
|
|
2616
2644
|
if (analyzeFile(code, id).tagged.length === 0) return void 0;
|
|
2617
2645
|
return {
|
|
2618
2646
|
file: id,
|
|
@@ -2629,6 +2657,7 @@ async function reportOutsideInclude(cfg) {
|
|
|
2629
2657
|
async function filesOutsideInclude(cfg) {
|
|
2630
2658
|
if (cfg.include.length === 0) return [];
|
|
2631
2659
|
const check = createOutsideCheck(cfg);
|
|
2660
|
+
const outside = outsidePath(cfg);
|
|
2632
2661
|
const files = await glob([`**/*.${SOURCE_EXTENSIONS}`], {
|
|
2633
2662
|
cwd: cfg.root,
|
|
2634
2663
|
ignore: [...NOT_SOURCE, ...cfg.exclude],
|
|
@@ -2636,14 +2665,15 @@ async function filesOutsideInclude(cfg) {
|
|
|
2636
2665
|
});
|
|
2637
2666
|
const found = [];
|
|
2638
2667
|
for (const file of files.sort()) {
|
|
2668
|
+
if (outside(file) === void 0) continue;
|
|
2639
2669
|
let code;
|
|
2640
2670
|
try {
|
|
2641
2671
|
code = readFileSync(file, "utf8");
|
|
2642
2672
|
} catch {
|
|
2643
2673
|
continue;
|
|
2644
2674
|
}
|
|
2645
|
-
const
|
|
2646
|
-
if (
|
|
2675
|
+
const entry = check(code, file);
|
|
2676
|
+
if (entry) found.push(entry);
|
|
2647
2677
|
}
|
|
2648
2678
|
return found;
|
|
2649
2679
|
}
|