glotfile 0.6.1 → 0.6.2
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/server/cli.js
CHANGED
|
@@ -187,7 +187,7 @@ function validate(raw) {
|
|
|
187
187
|
if (config.scan !== void 0) {
|
|
188
188
|
const scan = config.scan;
|
|
189
189
|
if (!isObject(scan)) fail("config.scan must be an object");
|
|
190
|
-
for (const f of ["include", "exclude", "accessors", "patterns"]) {
|
|
190
|
+
for (const f of ["include", "exclude", "accessors", "patterns", "keep"]) {
|
|
191
191
|
const v = scan[f];
|
|
192
192
|
if (v !== void 0 && (!Array.isArray(v) || !v.every((x) => typeof x === "string"))) {
|
|
193
193
|
fail(`config.scan.${f} must be an array of strings`);
|
|
@@ -3225,13 +3225,15 @@ function computeUsedKeys(state, cache2) {
|
|
|
3225
3225
|
if (p.prefix) prefixes.push(p.prefix);
|
|
3226
3226
|
}
|
|
3227
3227
|
}
|
|
3228
|
-
|
|
3228
|
+
const keep = (state.config.scan?.keep ?? []).map(globToRegExp);
|
|
3229
|
+
return Object.keys(state.keys).filter((key) => exact.has(key) || prefixes.some((p) => key.startsWith(p)) || keep.some((re) => re.test(key))).sort();
|
|
3229
3230
|
}
|
|
3230
3231
|
var init_scan = __esm({
|
|
3231
3232
|
"src/server/scan.ts"() {
|
|
3232
3233
|
"use strict";
|
|
3233
3234
|
init_atomic_write();
|
|
3234
3235
|
init_glotfile_dir();
|
|
3236
|
+
init_glob();
|
|
3235
3237
|
}
|
|
3236
3238
|
});
|
|
3237
3239
|
|
package/dist/server/server.js
CHANGED
|
@@ -186,7 +186,7 @@ function validate(raw) {
|
|
|
186
186
|
if (config.scan !== void 0) {
|
|
187
187
|
const scan = config.scan;
|
|
188
188
|
if (!isObject(scan)) fail("config.scan must be an object");
|
|
189
|
-
for (const f of ["include", "exclude", "accessors", "patterns"]) {
|
|
189
|
+
for (const f of ["include", "exclude", "accessors", "patterns", "keep"]) {
|
|
190
190
|
const v = scan[f];
|
|
191
191
|
if (v !== void 0 && (!Array.isArray(v) || !v.every((x) => typeof x === "string"))) {
|
|
192
192
|
fail(`config.scan.${f} must be an array of strings`);
|
|
@@ -817,6 +817,12 @@ function ensureGlotfileDir(projectRoot) {
|
|
|
817
817
|
return dir;
|
|
818
818
|
}
|
|
819
819
|
|
|
820
|
+
// src/server/glob.ts
|
|
821
|
+
function globToRegExp(glob) {
|
|
822
|
+
const escaped = glob.replace(/[.+^${}()|[\]\\]/g, "\\$&").replace(/\*/g, ".*");
|
|
823
|
+
return new RegExp(`^${escaped}$`);
|
|
824
|
+
}
|
|
825
|
+
|
|
820
826
|
// src/server/scan.ts
|
|
821
827
|
function loadUsageCache(projectRoot) {
|
|
822
828
|
const path = resolve2(projectRoot, ".glotfile", "usage.json");
|
|
@@ -854,7 +860,8 @@ function computeUsedKeys(state, cache2) {
|
|
|
854
860
|
if (p.prefix) prefixes.push(p.prefix);
|
|
855
861
|
}
|
|
856
862
|
}
|
|
857
|
-
|
|
863
|
+
const keep = (state.config.scan?.keep ?? []).map(globToRegExp);
|
|
864
|
+
return Object.keys(state.keys).filter((key) => exact.has(key) || prefixes.some((p) => key.startsWith(p)) || keep.some((re) => re.test(key))).sort();
|
|
858
865
|
}
|
|
859
866
|
|
|
860
867
|
// src/server/scanner.ts
|
|
@@ -1139,7 +1146,7 @@ var MAX_CONTEXT_LENGTH = 500;
|
|
|
1139
1146
|
var SNIPPET_WINDOW = 15;
|
|
1140
1147
|
var MAX_SNIPPETS = 3;
|
|
1141
1148
|
var EXCLUDED_DIRS = ["node_modules/", "vendor/", "dist/", ".git/", ".glotfile/"];
|
|
1142
|
-
function
|
|
1149
|
+
function globToRegExp2(glob) {
|
|
1143
1150
|
const escaped = glob.replace(/[.+^${}()|[\]\\]/g, "\\$&").replace(/\*/g, ".*");
|
|
1144
1151
|
return new RegExp(`^${escaped}$`);
|
|
1145
1152
|
}
|
|
@@ -1182,7 +1189,7 @@ function buildUsageIndex(cache2) {
|
|
|
1182
1189
|
}
|
|
1183
1190
|
function selectContextTargets(state, opts, cache2, lastRunAt) {
|
|
1184
1191
|
const cutoff = opts.all ? void 0 : opts.since ?? lastRunAt;
|
|
1185
|
-
const keyRe = opts.keyGlob ?
|
|
1192
|
+
const keyRe = opts.keyGlob ? globToRegExp2(opts.keyGlob) : null;
|
|
1186
1193
|
const keySet = opts.keys ? new Set(opts.keys) : null;
|
|
1187
1194
|
const usageIndex = buildUsageIndex(cache2);
|
|
1188
1195
|
let candidates = [];
|
|
@@ -1678,12 +1685,6 @@ function runChecks(state, opts = {}) {
|
|
|
1678
1685
|
return { issues: visible, spellPending };
|
|
1679
1686
|
}
|
|
1680
1687
|
|
|
1681
|
-
// src/server/glob.ts
|
|
1682
|
-
function globToRegExp2(glob) {
|
|
1683
|
-
const escaped = glob.replace(/[.+^${}()|[\]\\]/g, "\\$&").replace(/\*/g, ".*");
|
|
1684
|
-
return new RegExp(`^${escaped}$`);
|
|
1685
|
-
}
|
|
1686
|
-
|
|
1687
1688
|
// src/server/lint/spelling.ts
|
|
1688
1689
|
var spellingRule = {
|
|
1689
1690
|
id: "spelling",
|
|
@@ -1933,7 +1934,7 @@ async function runLint(state, options = {}) {
|
|
|
1933
1934
|
spellers,
|
|
1934
1935
|
allowWords
|
|
1935
1936
|
};
|
|
1936
|
-
const ignoreRes = (config.ignore ?? []).map(
|
|
1937
|
+
const ignoreRes = (config.ignore ?? []).map(globToRegExp);
|
|
1937
1938
|
const localeFilter = options.locales ? new Set(options.locales) : null;
|
|
1938
1939
|
const findings = [];
|
|
1939
1940
|
let suppressed = 0;
|
|
@@ -3461,7 +3462,7 @@ import { readFileSync as readFileSync7, existsSync as existsSync7 } from "fs";
|
|
|
3461
3462
|
import { resolve as resolve5, extname as extname2 } from "path";
|
|
3462
3463
|
function selectRequests(state, opts) {
|
|
3463
3464
|
const targets = (opts.locales ?? state.config.locales).filter((l) => l !== state.config.sourceLocale);
|
|
3464
|
-
const keyRe = opts.keyGlob ?
|
|
3465
|
+
const keyRe = opts.keyGlob ? globToRegExp(opts.keyGlob) : null;
|
|
3465
3466
|
const keySet = opts.keys ? new Set(opts.keys) : null;
|
|
3466
3467
|
const reqs = [];
|
|
3467
3468
|
let id = 0;
|