@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/cli.js
CHANGED
|
@@ -1032,7 +1032,26 @@ function byCodeUnit(a, b) {
|
|
|
1032
1032
|
}
|
|
1033
1033
|
//#endregion
|
|
1034
1034
|
//#region src/validate.ts
|
|
1035
|
-
|
|
1035
|
+
let remembered = /* @__PURE__ */ new Map();
|
|
1036
|
+
let reading;
|
|
1037
|
+
function read(message) {
|
|
1038
|
+
if (!reading) return parse(message, parseIcu);
|
|
1039
|
+
let tree = reading.get(message);
|
|
1040
|
+
if (!tree) {
|
|
1041
|
+
tree = remembered.get(message) ?? parse(message, parseIcu);
|
|
1042
|
+
reading.set(message, tree);
|
|
1043
|
+
}
|
|
1044
|
+
return tree;
|
|
1045
|
+
}
|
|
1046
|
+
function gatePass(run) {
|
|
1047
|
+
reading = /* @__PURE__ */ new Map();
|
|
1048
|
+
try {
|
|
1049
|
+
return run();
|
|
1050
|
+
} finally {
|
|
1051
|
+
remembered = reading;
|
|
1052
|
+
reading = void 0;
|
|
1053
|
+
}
|
|
1054
|
+
}
|
|
1036
1055
|
const PLURAL_CATEGORIES = /* @__PURE__ */ new Set([
|
|
1037
1056
|
"zero",
|
|
1038
1057
|
"one",
|
|
@@ -2383,6 +2402,9 @@ function gatePasses(result) {
|
|
|
2383
2402
|
return result.missing.length === 0 && result.unknown.length === 0 && result.collisions.length === 0 && !result.broken.some((entry) => entry.severity === "error");
|
|
2384
2403
|
}
|
|
2385
2404
|
function check(cfg, catalogs, registry, fingerprints = {}) {
|
|
2405
|
+
return gatePass(() => checkPass(cfg, catalogs, registry, fingerprints));
|
|
2406
|
+
}
|
|
2407
|
+
function checkPass(cfg, catalogs, registry, fingerprints) {
|
|
2386
2408
|
const extracted = registry.messages();
|
|
2387
2409
|
const flat = {};
|
|
2388
2410
|
for (const locale of cfg.locales) flat[locale] = flatten(catalogs[locale] ?? {});
|
|
@@ -2876,14 +2898,20 @@ function suggestedPattern(rel) {
|
|
|
2876
2898
|
const slash = rel.indexOf("/");
|
|
2877
2899
|
return slash < 0 ? rel : `${rel.slice(0, slash)}/**/*.${SOURCE_EXTENSIONS}`;
|
|
2878
2900
|
}
|
|
2879
|
-
function
|
|
2880
|
-
if (cfg.include.length === 0) return () => void 0;
|
|
2901
|
+
function outsidePath(cfg) {
|
|
2881
2902
|
const included = picomatch(cfg.include);
|
|
2882
2903
|
const excluded = picomatch(cfg.exclude);
|
|
2883
|
-
return (
|
|
2904
|
+
return (id) => {
|
|
2884
2905
|
const rel = relativeId(cfg, id);
|
|
2885
|
-
|
|
2886
|
-
|
|
2906
|
+
return rel.startsWith("..") || included(rel) || excluded(rel) ? void 0 : rel;
|
|
2907
|
+
};
|
|
2908
|
+
}
|
|
2909
|
+
function createOutsideCheck(cfg) {
|
|
2910
|
+
if (cfg.include.length === 0) return () => void 0;
|
|
2911
|
+
const outside = outsidePath(cfg);
|
|
2912
|
+
return (code, id) => {
|
|
2913
|
+
const rel = outside(id);
|
|
2914
|
+
if (rel === void 0 || !TAGGED_HINT.test(code)) return void 0;
|
|
2887
2915
|
if (analyzeFile(code, id).tagged.length === 0) return void 0;
|
|
2888
2916
|
return {
|
|
2889
2917
|
file: id,
|
|
@@ -2894,6 +2922,7 @@ function createOutsideCheck(cfg) {
|
|
|
2894
2922
|
async function filesOutsideInclude(cfg) {
|
|
2895
2923
|
if (cfg.include.length === 0) return [];
|
|
2896
2924
|
const check = createOutsideCheck(cfg);
|
|
2925
|
+
const outside = outsidePath(cfg);
|
|
2897
2926
|
const files = await glob([`**/*.${SOURCE_EXTENSIONS}`], {
|
|
2898
2927
|
cwd: cfg.root,
|
|
2899
2928
|
ignore: [...NOT_SOURCE, ...cfg.exclude],
|
|
@@ -2901,14 +2930,15 @@ async function filesOutsideInclude(cfg) {
|
|
|
2901
2930
|
});
|
|
2902
2931
|
const found = [];
|
|
2903
2932
|
for (const file of files.sort()) {
|
|
2933
|
+
if (outside(file) === void 0) continue;
|
|
2904
2934
|
let code;
|
|
2905
2935
|
try {
|
|
2906
2936
|
code = readFileSync(file, "utf8");
|
|
2907
2937
|
} catch {
|
|
2908
2938
|
continue;
|
|
2909
2939
|
}
|
|
2910
|
-
const
|
|
2911
|
-
if (
|
|
2940
|
+
const entry = check(code, file);
|
|
2941
|
+
if (entry) found.push(entry);
|
|
2912
2942
|
}
|
|
2913
2943
|
return found;
|
|
2914
2944
|
}
|