@hagicode/hagi18n 0.1.0-dev.1.1.45d0d2f
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/README.md +184 -0
- package/README_cn.md +178 -0
- package/dist/cli.d.ts +5 -0
- package/dist/cli.js +174 -0
- package/dist/cli.js.map +1 -0
- package/dist/config.d.ts +60 -0
- package/dist/config.js +341 -0
- package/dist/config.js.map +1 -0
- package/dist/index.d.ts +9 -0
- package/dist/index.js +12 -0
- package/dist/index.js.map +1 -0
- package/dist/locale-toolkit.d.ts +113 -0
- package/dist/locale-toolkit.js +679 -0
- package/dist/locale-toolkit.js.map +1 -0
- package/dist/version.d.ts +7 -0
- package/dist/version.js +23 -0
- package/dist/version.js.map +1 -0
- package/package.json +72 -0
package/dist/config.js
ADDED
|
@@ -0,0 +1,341 @@
|
|
|
1
|
+
import { access, readFile } from "node:fs/promises";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
import yaml from "js-yaml";
|
|
4
|
+
export const DEFAULT_BASE_LOCALE = "en-US";
|
|
5
|
+
export const DEFAULT_CONFIG_FILE_NAMES = ["hagi18n.yaml", "hagi18n.yml"];
|
|
6
|
+
export const DEFAULT_DOCTOR_EXCLUDED_DIRECTORIES = [
|
|
7
|
+
".git",
|
|
8
|
+
"coverage",
|
|
9
|
+
"dist",
|
|
10
|
+
"indexGenerator",
|
|
11
|
+
"node_modules",
|
|
12
|
+
"public"
|
|
13
|
+
];
|
|
14
|
+
export const DEFAULT_DOCTOR_TEXT_FILE_EXTENSIONS = [
|
|
15
|
+
".cjs",
|
|
16
|
+
".js",
|
|
17
|
+
".jsx",
|
|
18
|
+
".md",
|
|
19
|
+
".mjs",
|
|
20
|
+
".ts",
|
|
21
|
+
".tsx"
|
|
22
|
+
];
|
|
23
|
+
export const DEFAULT_DOCTOR_EXCLUDED_PATH_PREFIXES = ["src/generated/"];
|
|
24
|
+
export const DEFAULT_DOCTOR_SCAN_RULES = [
|
|
25
|
+
{
|
|
26
|
+
id: "legacy-locale-path",
|
|
27
|
+
message: "Legacy locale paths should use en-US instead of en.",
|
|
28
|
+
pattern: "(?:src\\/locales\\/en\\/|\\.\\.\\/\\.\\.\\/locales\\/en\\/)"
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
id: "legacy-language-change-call",
|
|
32
|
+
message: "Use en-US when switching the canonical UI language in code or tests.",
|
|
33
|
+
pattern: "\\b(?:i18n\\.)?changeLanguage\\(\\s*['\"]en['\"]\\s*\\)"
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
id: "legacy-ui-language-literal",
|
|
37
|
+
message: "Use en-US as the canonical UI language literal.",
|
|
38
|
+
pattern: "\\b(currentLanguage|confirmedLanguage|detectedLanguage|resolvedLanguage|language|lng)\\s*[:=]\\s*['\"]en['\"]"
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
id: "legacy-ui-language-union",
|
|
42
|
+
message: "Use en-US in UI-language unions and casts.",
|
|
43
|
+
pattern: "(?:as\\s+)?['\"]en['\"]\\s*\\|\\s*['\"]zh-CN['\"]"
|
|
44
|
+
}
|
|
45
|
+
];
|
|
46
|
+
export const DEFAULT_DOCTOR_ALLOWLIST = {
|
|
47
|
+
"legacy-ui-language-literal": [
|
|
48
|
+
"src/services/__tests__/frontendConfigBootstrap.generalSettings.test.ts",
|
|
49
|
+
"src/services/__tests__/frontendConfigBootstrap.projectScope.test.ts",
|
|
50
|
+
"src/store/__tests__/aiLanguageSlice.test.ts",
|
|
51
|
+
"src/store/listeners/__tests__/frontendConfigSyncListener.projectScope.test.ts",
|
|
52
|
+
"src/store/slices/__tests__/generalSettingsSlice.test.ts"
|
|
53
|
+
],
|
|
54
|
+
"legacy-language-change-call": [],
|
|
55
|
+
"legacy-locale-path": [],
|
|
56
|
+
"legacy-ui-language-union": []
|
|
57
|
+
};
|
|
58
|
+
function isPlainObject(value) {
|
|
59
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
60
|
+
}
|
|
61
|
+
function ensureString(value, fieldName, { allowEmpty = false } = {}) {
|
|
62
|
+
if (value === undefined) {
|
|
63
|
+
return undefined;
|
|
64
|
+
}
|
|
65
|
+
if (typeof value !== "string") {
|
|
66
|
+
throw new Error(`${fieldName} must be a string.`);
|
|
67
|
+
}
|
|
68
|
+
const trimmed = value.trim();
|
|
69
|
+
if (!allowEmpty && trimmed.length === 0) {
|
|
70
|
+
throw new Error(`${fieldName} must not be empty.`);
|
|
71
|
+
}
|
|
72
|
+
return trimmed;
|
|
73
|
+
}
|
|
74
|
+
function ensureStringArray(value, fieldName) {
|
|
75
|
+
if (value === undefined) {
|
|
76
|
+
return undefined;
|
|
77
|
+
}
|
|
78
|
+
if (!Array.isArray(value)) {
|
|
79
|
+
throw new Error(`${fieldName} must be an array of strings.`);
|
|
80
|
+
}
|
|
81
|
+
return value.map((entry, index) => {
|
|
82
|
+
const validated = ensureString(entry, `${fieldName}[${index}]`);
|
|
83
|
+
return validated ?? "";
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
function dedupeStrings(values) {
|
|
87
|
+
const output = [];
|
|
88
|
+
for (const value of values) {
|
|
89
|
+
const trimmed = value.trim();
|
|
90
|
+
if (!trimmed || output.includes(trimmed)) {
|
|
91
|
+
continue;
|
|
92
|
+
}
|
|
93
|
+
output.push(trimmed);
|
|
94
|
+
}
|
|
95
|
+
return output;
|
|
96
|
+
}
|
|
97
|
+
function normalizeAllowlist(value, fieldName) {
|
|
98
|
+
if (value === undefined) {
|
|
99
|
+
return undefined;
|
|
100
|
+
}
|
|
101
|
+
if (!isPlainObject(value)) {
|
|
102
|
+
throw new Error(`${fieldName} must be a mapping of rule ids to file paths.`);
|
|
103
|
+
}
|
|
104
|
+
const output = {};
|
|
105
|
+
for (const [ruleId, paths] of Object.entries(value)) {
|
|
106
|
+
output[ruleId] = dedupeStrings(ensureStringArray(paths, `${fieldName}.${ruleId}`) ?? []);
|
|
107
|
+
}
|
|
108
|
+
return output;
|
|
109
|
+
}
|
|
110
|
+
function normalizeScanRules(value, fieldName) {
|
|
111
|
+
if (value === undefined) {
|
|
112
|
+
return undefined;
|
|
113
|
+
}
|
|
114
|
+
if (!Array.isArray(value)) {
|
|
115
|
+
throw new Error(`${fieldName} must be an array of rule definitions.`);
|
|
116
|
+
}
|
|
117
|
+
return value.map((entry, index) => {
|
|
118
|
+
if (!isPlainObject(entry)) {
|
|
119
|
+
throw new Error(`${fieldName}[${index}] must be a mapping.`);
|
|
120
|
+
}
|
|
121
|
+
return {
|
|
122
|
+
id: ensureString(entry.id, `${fieldName}[${index}].id`) ?? "",
|
|
123
|
+
message: ensureString(entry.message, `${fieldName}[${index}].message`) ?? "",
|
|
124
|
+
pattern: ensureString(entry.pattern, `${fieldName}[${index}].pattern`) ?? "",
|
|
125
|
+
flags: ensureString(entry.flags, `${fieldName}[${index}].flags`, {
|
|
126
|
+
allowEmpty: true
|
|
127
|
+
})
|
|
128
|
+
};
|
|
129
|
+
});
|
|
130
|
+
}
|
|
131
|
+
function parseDoctorConfig(value) {
|
|
132
|
+
if (value === undefined) {
|
|
133
|
+
return undefined;
|
|
134
|
+
}
|
|
135
|
+
if (!isPlainObject(value)) {
|
|
136
|
+
throw new Error("doctor must be a mapping.");
|
|
137
|
+
}
|
|
138
|
+
return {
|
|
139
|
+
excludedDirectories: ensureStringArray(value.excludedDirectories, "doctor.excludedDirectories"),
|
|
140
|
+
textFileExtensions: ensureStringArray(value.textFileExtensions, "doctor.textFileExtensions"),
|
|
141
|
+
excludedPathPrefixes: ensureStringArray(value.excludedPathPrefixes, "doctor.excludedPathPrefixes"),
|
|
142
|
+
allowlist: normalizeAllowlist(value.allowlist, "doctor.allowlist"),
|
|
143
|
+
scanRules: normalizeScanRules(value.scanRules, "doctor.scanRules")
|
|
144
|
+
};
|
|
145
|
+
}
|
|
146
|
+
function parseConfigDocument(document, configPath) {
|
|
147
|
+
if (document === undefined) {
|
|
148
|
+
return {};
|
|
149
|
+
}
|
|
150
|
+
if (!isPlainObject(document)) {
|
|
151
|
+
throw new Error(`Top-level YAML document in ${configPath} must be a mapping object.`);
|
|
152
|
+
}
|
|
153
|
+
return {
|
|
154
|
+
localesRoot: ensureString(document.localesRoot, "localesRoot"),
|
|
155
|
+
repoRoot: ensureString(document.repoRoot, "repoRoot"),
|
|
156
|
+
baseLocale: ensureString(document.baseLocale, "baseLocale"),
|
|
157
|
+
targetLocales: ensureStringArray(document.targetLocales, "targetLocales"),
|
|
158
|
+
doctor: parseDoctorConfig(document.doctor)
|
|
159
|
+
};
|
|
160
|
+
}
|
|
161
|
+
export async function findHagi18nConfigPath(options = {}) {
|
|
162
|
+
const cwd = path.resolve(options.cwd ?? process.cwd());
|
|
163
|
+
const explicitConfigPath = options.configPath?.trim();
|
|
164
|
+
if (explicitConfigPath) {
|
|
165
|
+
return path.resolve(cwd, explicitConfigPath);
|
|
166
|
+
}
|
|
167
|
+
for (const fileName of DEFAULT_CONFIG_FILE_NAMES) {
|
|
168
|
+
const candidate = path.join(cwd, fileName);
|
|
169
|
+
try {
|
|
170
|
+
await access(candidate);
|
|
171
|
+
return candidate;
|
|
172
|
+
}
|
|
173
|
+
catch {
|
|
174
|
+
continue;
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
return null;
|
|
178
|
+
}
|
|
179
|
+
export async function loadHagi18nConfig(options = {}) {
|
|
180
|
+
const cwd = path.resolve(options.cwd ?? process.cwd());
|
|
181
|
+
const configPath = await findHagi18nConfigPath({ ...options, cwd });
|
|
182
|
+
if (!configPath) {
|
|
183
|
+
return {
|
|
184
|
+
cwd,
|
|
185
|
+
configPath: null,
|
|
186
|
+
config: null
|
|
187
|
+
};
|
|
188
|
+
}
|
|
189
|
+
let raw;
|
|
190
|
+
try {
|
|
191
|
+
raw = await readFile(configPath, "utf8");
|
|
192
|
+
}
|
|
193
|
+
catch (error) {
|
|
194
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
195
|
+
throw new Error(`Failed to read ${configPath}: ${message}`);
|
|
196
|
+
}
|
|
197
|
+
let parsed;
|
|
198
|
+
try {
|
|
199
|
+
parsed = yaml.load(raw);
|
|
200
|
+
}
|
|
201
|
+
catch (error) {
|
|
202
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
203
|
+
throw new Error(`Failed to parse ${configPath}: ${message}`);
|
|
204
|
+
}
|
|
205
|
+
return {
|
|
206
|
+
cwd,
|
|
207
|
+
configPath,
|
|
208
|
+
config: parseConfigDocument(parsed, configPath)
|
|
209
|
+
};
|
|
210
|
+
}
|
|
211
|
+
function compileScanRules(rules) {
|
|
212
|
+
return rules.map((rule) => ({
|
|
213
|
+
...rule,
|
|
214
|
+
regex: new RegExp(rule.pattern, rule.flags ?? "u")
|
|
215
|
+
}));
|
|
216
|
+
}
|
|
217
|
+
function resolveStringPath(value, baseDirectory) {
|
|
218
|
+
if (value === undefined) {
|
|
219
|
+
return undefined;
|
|
220
|
+
}
|
|
221
|
+
return path.isAbsolute(value) ? value : path.resolve(baseDirectory, value);
|
|
222
|
+
}
|
|
223
|
+
function resolveConfigLayer(config, { cwd, configPath }) {
|
|
224
|
+
if (!config) {
|
|
225
|
+
return {};
|
|
226
|
+
}
|
|
227
|
+
const baseDirectory = configPath ? path.dirname(configPath) : cwd;
|
|
228
|
+
return {
|
|
229
|
+
localesRoot: resolveStringPath(config.localesRoot, baseDirectory),
|
|
230
|
+
repoRoot: resolveStringPath(config.repoRoot, baseDirectory),
|
|
231
|
+
baseLocale: config.baseLocale?.trim(),
|
|
232
|
+
targetLocales: config.targetLocales
|
|
233
|
+
? dedupeStrings(config.targetLocales)
|
|
234
|
+
: undefined,
|
|
235
|
+
doctor: {
|
|
236
|
+
excludedDirectories: config.doctor?.excludedDirectories
|
|
237
|
+
? dedupeStrings(config.doctor.excludedDirectories)
|
|
238
|
+
: undefined,
|
|
239
|
+
textFileExtensions: config.doctor?.textFileExtensions
|
|
240
|
+
? dedupeStrings(config.doctor.textFileExtensions)
|
|
241
|
+
: undefined,
|
|
242
|
+
excludedPathPrefixes: config.doctor?.excludedPathPrefixes
|
|
243
|
+
? dedupeStrings(config.doctor.excludedPathPrefixes)
|
|
244
|
+
: undefined,
|
|
245
|
+
allowlist: config.doctor?.allowlist
|
|
246
|
+
? Object.fromEntries(Object.entries(config.doctor.allowlist).map(([ruleId, filePaths]) => [
|
|
247
|
+
ruleId,
|
|
248
|
+
dedupeStrings(filePaths)
|
|
249
|
+
]))
|
|
250
|
+
: undefined,
|
|
251
|
+
scanRules: config.doctor?.scanRules
|
|
252
|
+
? compileScanRules(config.doctor.scanRules)
|
|
253
|
+
: undefined
|
|
254
|
+
}
|
|
255
|
+
};
|
|
256
|
+
}
|
|
257
|
+
function mergeAllowlists(baseAllowlist, overrideAllowlist) {
|
|
258
|
+
if (!overrideAllowlist) {
|
|
259
|
+
return { ...baseAllowlist };
|
|
260
|
+
}
|
|
261
|
+
const merged = { ...baseAllowlist };
|
|
262
|
+
for (const [ruleId, filePaths] of Object.entries(overrideAllowlist)) {
|
|
263
|
+
merged[ruleId] = dedupeStrings(filePaths);
|
|
264
|
+
}
|
|
265
|
+
return merged;
|
|
266
|
+
}
|
|
267
|
+
function mergeResolvedDoctorConfig(baseConfig, overrideConfig) {
|
|
268
|
+
if (!overrideConfig) {
|
|
269
|
+
return {
|
|
270
|
+
excludedDirectories: [...baseConfig.excludedDirectories],
|
|
271
|
+
textFileExtensions: [...baseConfig.textFileExtensions],
|
|
272
|
+
excludedPathPrefixes: [...baseConfig.excludedPathPrefixes],
|
|
273
|
+
allowlist: mergeAllowlists(baseConfig.allowlist),
|
|
274
|
+
scanRules: [...baseConfig.scanRules]
|
|
275
|
+
};
|
|
276
|
+
}
|
|
277
|
+
return {
|
|
278
|
+
excludedDirectories: overrideConfig.excludedDirectories
|
|
279
|
+
? [...overrideConfig.excludedDirectories]
|
|
280
|
+
: [...baseConfig.excludedDirectories],
|
|
281
|
+
textFileExtensions: overrideConfig.textFileExtensions
|
|
282
|
+
? [...overrideConfig.textFileExtensions]
|
|
283
|
+
: [...baseConfig.textFileExtensions],
|
|
284
|
+
excludedPathPrefixes: overrideConfig.excludedPathPrefixes
|
|
285
|
+
? [...overrideConfig.excludedPathPrefixes]
|
|
286
|
+
: [...baseConfig.excludedPathPrefixes],
|
|
287
|
+
allowlist: mergeAllowlists(baseConfig.allowlist, overrideConfig.allowlist),
|
|
288
|
+
scanRules: overrideConfig.scanRules
|
|
289
|
+
? [...overrideConfig.scanRules]
|
|
290
|
+
: [...baseConfig.scanRules]
|
|
291
|
+
};
|
|
292
|
+
}
|
|
293
|
+
function createDefaultResolvedConfig(cwd) {
|
|
294
|
+
return {
|
|
295
|
+
cwd,
|
|
296
|
+
configPath: null,
|
|
297
|
+
localesRoot: path.resolve(cwd, "src/locales"),
|
|
298
|
+
repoRoot: cwd,
|
|
299
|
+
baseLocale: DEFAULT_BASE_LOCALE,
|
|
300
|
+
targetLocales: [],
|
|
301
|
+
doctor: {
|
|
302
|
+
excludedDirectories: [...DEFAULT_DOCTOR_EXCLUDED_DIRECTORIES],
|
|
303
|
+
textFileExtensions: [...DEFAULT_DOCTOR_TEXT_FILE_EXTENSIONS],
|
|
304
|
+
excludedPathPrefixes: [...DEFAULT_DOCTOR_EXCLUDED_PATH_PREFIXES],
|
|
305
|
+
allowlist: { ...DEFAULT_DOCTOR_ALLOWLIST },
|
|
306
|
+
scanRules: compileScanRules(DEFAULT_DOCTOR_SCAN_RULES)
|
|
307
|
+
}
|
|
308
|
+
};
|
|
309
|
+
}
|
|
310
|
+
export async function resolveHagi18nConfig(options = {}) {
|
|
311
|
+
const cwd = path.resolve(options.cwd ?? process.cwd());
|
|
312
|
+
const loaded = await loadHagi18nConfig({
|
|
313
|
+
cwd,
|
|
314
|
+
configPath: options.configPath
|
|
315
|
+
});
|
|
316
|
+
const defaults = createDefaultResolvedConfig(cwd);
|
|
317
|
+
const fileLayer = resolveConfigLayer(loaded.config, loaded);
|
|
318
|
+
const overrideLayer = resolveConfigLayer({
|
|
319
|
+
localesRoot: options.localesRoot,
|
|
320
|
+
repoRoot: options.repoRoot,
|
|
321
|
+
baseLocale: options.baseLocale,
|
|
322
|
+
targetLocales: options.targetLocales,
|
|
323
|
+
doctor: options.doctor
|
|
324
|
+
}, {
|
|
325
|
+
cwd,
|
|
326
|
+
configPath: null
|
|
327
|
+
});
|
|
328
|
+
const mergedDoctor = mergeResolvedDoctorConfig(mergeResolvedDoctorConfig(defaults.doctor, fileLayer.doctor), overrideLayer.doctor);
|
|
329
|
+
return {
|
|
330
|
+
cwd,
|
|
331
|
+
configPath: loaded.configPath,
|
|
332
|
+
localesRoot: overrideLayer.localesRoot ?? fileLayer.localesRoot ?? defaults.localesRoot,
|
|
333
|
+
repoRoot: overrideLayer.repoRoot ?? fileLayer.repoRoot ?? defaults.repoRoot,
|
|
334
|
+
baseLocale: overrideLayer.baseLocale ?? fileLayer.baseLocale ?? defaults.baseLocale,
|
|
335
|
+
targetLocales: overrideLayer.targetLocales ??
|
|
336
|
+
fileLayer.targetLocales ??
|
|
337
|
+
defaults.targetLocales,
|
|
338
|
+
doctor: mergedDoctor
|
|
339
|
+
};
|
|
340
|
+
}
|
|
341
|
+
//# sourceMappingURL=config.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AACpD,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,IAAI,MAAM,SAAS,CAAC;AAE3B,MAAM,CAAC,MAAM,mBAAmB,GAAG,OAAO,CAAC;AAC3C,MAAM,CAAC,MAAM,yBAAyB,GAAG,CAAC,cAAc,EAAE,aAAa,CAAU,CAAC;AAClF,MAAM,CAAC,MAAM,mCAAmC,GAAG;IACjD,MAAM;IACN,UAAU;IACV,MAAM;IACN,gBAAgB;IAChB,cAAc;IACd,QAAQ;CACA,CAAC;AACX,MAAM,CAAC,MAAM,mC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AAa;YAC3B,SAAS,CAAC,aAAa;YACvB,QAAQ,CAAC,aAAa;QACxB,MAAM,EAAE,YAAY;KACrB,CAAC;AACJ,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export { DEFAULT_BASE_LOCALE, DEFAULT_CONFIG_FILE_NAMES, DEFAULT_DOCTOR_ALLOWLIST, DEFAULT_DOCTOR_EXCLUDED_DIRECTORIES, DEFAULT_DOCTOR_EXCLUDED_PATH_PREFIXES, DEFAULT_DOCTOR_SCAN_RULES, DEFAULT_DOCTOR_TEXT_FILE_EXTENSIONS, findHagi18nConfigPath, loadHagi18nConfig, resolveHagi18nConfig, type DoctorScanRuleConfig, type Hagi18nConfig, type Hagi18nDoctorConfig, type LoadHagi18nConfigOptions, type LoadHagi18nConfigResult, type ResolvedDoctorScanRule, type ResolvedHagi18nConfig, type ResolvedHagi18nDoctorConfig, type ResolveHagi18nConfigOptions } from "./config.js";
|
|
2
|
+
export { auditHasIssues, auditLocaleTree, collectPlaceholderDifferences, collectPlaceholders, collectScalarPaths, createAuditResult, difference, doctorLocaleTree, formatAuditSummary, formatDoctorSummary, formatMutationSummary, listLocaleDirectories, normalizeLocaleName, pruneLocaleTree, readYamlLocaleFile, syncLocaleTree, walkYamlFiles, type AuditLocaleResult, type AuditLocaleTreeSummary, type DoctorLocaleTreeSummary, type DoctorRuleIssue, type LocaleMutationParseError, type LocaleParseError, type LocalePathIssue, type LocalePlaceholderMismatch, type LocaleToolkitOptions, type MutationChangedFile, type MutationLocaleToolkitOptions, type MutationRemovedFile, type MutationSummary, type MutationTotals, type YamlLocaleDocument } from "./locale-toolkit.js";
|
|
3
|
+
export { getPackageMetadata, packageName, packageVersion, type PackageMetadata } from "./version.js";
|
|
4
|
+
export interface Hagi18nRuntimeInfo {
|
|
5
|
+
packageName: string;
|
|
6
|
+
version: string;
|
|
7
|
+
status: "foundation";
|
|
8
|
+
}
|
|
9
|
+
export declare function createRuntimeInfo(): Hagi18nRuntimeInfo;
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { packageName, packageVersion } from "./version.js";
|
|
2
|
+
export { DEFAULT_BASE_LOCALE, DEFAULT_CONFIG_FILE_NAMES, DEFAULT_DOCTOR_ALLOWLIST, DEFAULT_DOCTOR_EXCLUDED_DIRECTORIES, DEFAULT_DOCTOR_EXCLUDED_PATH_PREFIXES, DEFAULT_DOCTOR_SCAN_RULES, DEFAULT_DOCTOR_TEXT_FILE_EXTENSIONS, findHagi18nConfigPath, loadHagi18nConfig, resolveHagi18nConfig } from "./config.js";
|
|
3
|
+
export { auditHasIssues, auditLocaleTree, collectPlaceholderDifferences, collectPlaceholders, collectScalarPaths, createAuditResult, difference, doctorLocaleTree, formatAuditSummary, formatDoctorSummary, formatMutationSummary, listLocaleDirectories, normalizeLocaleName, pruneLocaleTree, readYamlLocaleFile, syncLocaleTree, walkYamlFiles } from "./locale-toolkit.js";
|
|
4
|
+
export { getPackageMetadata, packageName, packageVersion } from "./version.js";
|
|
5
|
+
export function createRuntimeInfo() {
|
|
6
|
+
return {
|
|
7
|
+
packageName,
|
|
8
|
+
version: packageVersion,
|
|
9
|
+
status: "foundation"
|
|
10
|
+
};
|
|
11
|
+
}
|
|
12
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAE3D,OAAO,EACL,mBAAmB,EACnB,yBAAyB,EACzB,wBAAwB,EACxB,mCAAmC,EACnC,qCAAqC,EACrC,yBAAyB,EACzB,mCAAmC,EACnC,qBAAqB,EACrB,iBAAiB,EACjB,oBAAoB,EAUrB,MAAM,aAAa,CAAC;AAErB,OAAO,EACL,cAAc,EACd,eAAe,EACf,6BAA6B,EAC7B,mBAAmB,EACnB,kBAAkB,EAClB,iBAAiB,EACjB,UAAU,EACV,gBAAgB,EAChB,kBAAkB,EAClB,mBAAmB,EACnB,qBAAqB,EACrB,qBAAqB,EACrB,mBAAmB,EACnB,eAAe,EACf,kBAAkB,EAClB,cAAc,EACd,aAAa,EAgBd,MAAM,qBAAqB,CAAC;AAE7B,OAAO,EACL,kBAAkB,EAClB,WAAW,EACX,cAAc,EAEf,MAAM,cAAc,CAAC;AAQtB,MAAM,UAAU,iBAAiB;IAC/B,OAAO;QACL,WAAW;QACX,OAAO,EAAE,cAAc;QACvB,MAAM,EAAE,YAAY;KACrB,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
import { type ResolveHagi18nConfigOptions } from "./config.js";
|
|
2
|
+
export interface YamlLocaleDocument {
|
|
3
|
+
absolutePath: string;
|
|
4
|
+
raw: string;
|
|
5
|
+
data: Record<string, unknown>;
|
|
6
|
+
}
|
|
7
|
+
export interface LocaleParseError {
|
|
8
|
+
file: string;
|
|
9
|
+
message: string;
|
|
10
|
+
}
|
|
11
|
+
export interface LocaleMutationParseError extends LocaleParseError {
|
|
12
|
+
locale: string;
|
|
13
|
+
}
|
|
14
|
+
export interface LocalePathIssue {
|
|
15
|
+
file: string;
|
|
16
|
+
path: string;
|
|
17
|
+
}
|
|
18
|
+
export interface LocalePlaceholderMismatch extends LocalePathIssue {
|
|
19
|
+
expected: string[];
|
|
20
|
+
actual: string[];
|
|
21
|
+
}
|
|
22
|
+
export interface AuditLocaleResult {
|
|
23
|
+
locale: string;
|
|
24
|
+
missingFiles: string[];
|
|
25
|
+
extraFiles: string[];
|
|
26
|
+
filesWithProtectedTokens: string[];
|
|
27
|
+
parseErrors: LocaleParseError[];
|
|
28
|
+
missingKeys: LocalePathIssue[];
|
|
29
|
+
extraKeys: LocalePathIssue[];
|
|
30
|
+
placeholderMismatches: LocalePlaceholderMismatch[];
|
|
31
|
+
}
|
|
32
|
+
export interface AuditLocaleTreeSummary {
|
|
33
|
+
localesRoot: string;
|
|
34
|
+
baseLocale: string;
|
|
35
|
+
locales: string[];
|
|
36
|
+
allLocales: string[];
|
|
37
|
+
baseFileCount: number;
|
|
38
|
+
results: AuditLocaleResult[];
|
|
39
|
+
hasIssues: boolean;
|
|
40
|
+
}
|
|
41
|
+
export interface MutationChangedFile {
|
|
42
|
+
locale: string;
|
|
43
|
+
file: string;
|
|
44
|
+
action: "create" | "update";
|
|
45
|
+
addedPaths?: string[];
|
|
46
|
+
removedPaths?: string[];
|
|
47
|
+
}
|
|
48
|
+
export interface MutationRemovedFile {
|
|
49
|
+
locale: string;
|
|
50
|
+
file: string;
|
|
51
|
+
action: "remove-file";
|
|
52
|
+
}
|
|
53
|
+
export interface MutationTotals {
|
|
54
|
+
createdFiles: number;
|
|
55
|
+
updatedFiles: number;
|
|
56
|
+
removedFiles: number;
|
|
57
|
+
addedPaths: number;
|
|
58
|
+
removedPaths: number;
|
|
59
|
+
}
|
|
60
|
+
export interface MutationSummary {
|
|
61
|
+
command: "sync" | "prune";
|
|
62
|
+
localesRoot: string;
|
|
63
|
+
baseLocale: string;
|
|
64
|
+
targetLocales: string[];
|
|
65
|
+
dryRun: boolean;
|
|
66
|
+
changedFiles: MutationChangedFile[];
|
|
67
|
+
removedFiles: MutationRemovedFile[];
|
|
68
|
+
parseErrors: LocaleMutationParseError[];
|
|
69
|
+
totals: MutationTotals;
|
|
70
|
+
hasIssues: boolean;
|
|
71
|
+
}
|
|
72
|
+
export interface DoctorRuleIssue {
|
|
73
|
+
ruleId: string;
|
|
74
|
+
file: string;
|
|
75
|
+
line: number;
|
|
76
|
+
message: string;
|
|
77
|
+
snippet: string;
|
|
78
|
+
}
|
|
79
|
+
export interface DoctorLocaleTreeSummary {
|
|
80
|
+
repoRoot: string;
|
|
81
|
+
localesRoot: string;
|
|
82
|
+
baseLocale: string;
|
|
83
|
+
locales: string[];
|
|
84
|
+
audit: AuditLocaleTreeSummary;
|
|
85
|
+
legacyReferenceIssues: DoctorRuleIssue[];
|
|
86
|
+
totals: {
|
|
87
|
+
legacyReferenceIssues: number;
|
|
88
|
+
affectedFiles: number;
|
|
89
|
+
};
|
|
90
|
+
hasIssues: boolean;
|
|
91
|
+
}
|
|
92
|
+
export interface LocaleToolkitOptions extends ResolveHagi18nConfigOptions {
|
|
93
|
+
}
|
|
94
|
+
export interface MutationLocaleToolkitOptions extends LocaleToolkitOptions {
|
|
95
|
+
dryRun?: boolean;
|
|
96
|
+
}
|
|
97
|
+
export declare function normalizeLocaleName(value: unknown): string | null;
|
|
98
|
+
export declare function listLocaleDirectories(localesRoot: string): Promise<string[]>;
|
|
99
|
+
export declare function walkYamlFiles(directory: string, prefix?: string): Promise<string[]>;
|
|
100
|
+
export declare function readYamlLocaleFile(localesRoot: string, locale: string, relativeFilePath: string): Promise<YamlLocaleDocument>;
|
|
101
|
+
export declare function collectScalarPaths(value: unknown, prefix?: string[], output?: string[]): string[];
|
|
102
|
+
export declare function collectPlaceholders(value: unknown, prefix?: string[], output?: Map<string, string[]>): Map<string, string[]>;
|
|
103
|
+
export declare function difference(source: string[], other: string[]): string[];
|
|
104
|
+
export declare function collectPlaceholderDifferences(basePlaceholders: Map<string, string[]>, currentPlaceholders: Map<string, string[]>): Array<Omit<LocalePlaceholderMismatch, "file">>;
|
|
105
|
+
export declare function createAuditResult(locale: string): AuditLocaleResult;
|
|
106
|
+
export declare function auditHasIssues(result: AuditLocaleResult): boolean;
|
|
107
|
+
export declare function auditLocaleTree(options?: LocaleToolkitOptions): Promise<AuditLocaleTreeSummary>;
|
|
108
|
+
export declare function syncLocaleTree(options?: MutationLocaleToolkitOptions): Promise<MutationSummary>;
|
|
109
|
+
export declare function pruneLocaleTree(options?: MutationLocaleToolkitOptions): Promise<MutationSummary>;
|
|
110
|
+
export declare function doctorLocaleTree(options?: LocaleToolkitOptions): Promise<DoctorLocaleTreeSummary>;
|
|
111
|
+
export declare function formatAuditSummary(summary: AuditLocaleTreeSummary): string;
|
|
112
|
+
export declare function formatMutationSummary(summary: MutationSummary): string;
|
|
113
|
+
export declare function formatDoctorSummary(summary: DoctorLocaleTreeSummary): string;
|