@formatjs/cli-lib 7.4.3 → 8.0.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/{lib_esnext/index.d.ts → index.d.ts} +5 -5
- package/{lib_esnext/index.js → index.js} +2 -2
- package/{lib_esnext/main.d.ts → main.d.ts} +1 -0
- package/main.js +3 -0
- package/package.json +8 -7
- package/{lib_esnext/src → src}/cli.js +6 -5
- package/{lib_esnext/src → src}/compile.d.ts +1 -1
- package/{lib_esnext/src → src}/compile.js +5 -4
- package/{lib_esnext/src → src}/compile_folder.d.ts +1 -1
- package/{lib_esnext/src → src}/compile_folder.js +1 -1
- package/{lib_esnext/src → src}/console_utils.js +9 -10
- package/{lib_esnext/src → src}/extract.d.ts +1 -1
- package/{lib_esnext/src → src}/extract.js +7 -6
- package/{lib_esnext/src → src}/formatters/crowdin.d.ts +1 -1
- package/{lib_esnext/src → src}/formatters/index.d.ts +1 -1
- package/{lib_esnext/src → src}/formatters/index.js +6 -6
- package/{lib_esnext/src → src}/formatters/lokalise.d.ts +1 -1
- package/{lib_esnext/src → src}/formatters/simple.d.ts +1 -1
- package/{lib_esnext/src → src}/formatters/smartling.d.ts +1 -1
- package/{lib_esnext/src → src}/formatters/transifex.d.ts +1 -1
- package/{lib_esnext/src → src}/gts_extractor.js +2 -2
- package/{lib_esnext/src → src}/parse_script.js +2 -2
- package/src/verify/checkExtraKeys.d.ts +1 -0
- package/src/verify/checkExtraKeys.js +36 -0
- package/{lib_esnext/src → src}/verify/checkMissingKeys.js +5 -5
- package/{lib_esnext/src → src}/verify/checkStructuralEquality.js +7 -7
- package/{lib_esnext/src → src}/verify/index.d.ts +2 -1
- package/{lib_esnext/src → src}/verify/index.js +9 -4
- package/lib_esnext/main.js +0 -3
- /package/{lib_esnext/src → src}/cli.d.ts +0 -0
- /package/{lib_esnext/src → src}/console_utils.d.ts +0 -0
- /package/{lib_esnext/src → src}/formatters/crowdin.js +0 -0
- /package/{lib_esnext/src → src}/formatters/default.d.ts +0 -0
- /package/{lib_esnext/src → src}/formatters/default.js +0 -0
- /package/{lib_esnext/src → src}/formatters/lokalise.js +0 -0
- /package/{lib_esnext/src → src}/formatters/simple.js +0 -0
- /package/{lib_esnext/src → src}/formatters/smartling.js +0 -0
- /package/{lib_esnext/src → src}/formatters/transifex.js +0 -0
- /package/{lib_esnext/src → src}/gts_extractor.d.ts +0 -0
- /package/{lib_esnext/src → src}/hbs_extractor.d.ts +0 -0
- /package/{lib_esnext/src → src}/hbs_extractor.js +0 -0
- /package/{lib_esnext/src → src}/parse_script.d.ts +0 -0
- /package/{lib_esnext/src → src}/pseudo_locale.d.ts +0 -0
- /package/{lib_esnext/src → src}/pseudo_locale.js +0 -0
- /package/{lib_esnext/src → src}/verify/checkMissingKeys.d.ts +0 -0
- /package/{lib_esnext/src → src}/verify/checkStructuralEquality.d.ts +0 -0
- /package/{lib_esnext/src → src}/vue_extractor.d.ts +0 -0
- /package/{lib_esnext/src → src}/vue_extractor.js +0 -0
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
export { default as extractAndWrite, extract } from './src/extract';
|
|
2
|
-
export type { ExtractCLIOptions, ExtractOpts } from './src/extract';
|
|
1
|
+
export { default as extractAndWrite, extract } from './src/extract.js';
|
|
2
|
+
export type { ExtractCLIOptions, ExtractOpts } from './src/extract.js';
|
|
3
3
|
export type { MessageDescriptor } from '@formatjs/ts-transformer';
|
|
4
|
-
export type { FormatFn, CompileFn } from './src/formatters/default';
|
|
4
|
+
export type { FormatFn, CompileFn } from './src/formatters/default.js';
|
|
5
5
|
export type { Comparator } from 'json-stable-stringify';
|
|
6
|
-
export { default as compileAndWrite, compile } from './src/compile';
|
|
7
|
-
export type { CompileCLIOpts, Opts as CompileOpts } from './src/compile';
|
|
6
|
+
export { default as compileAndWrite, compile } from './src/compile.js';
|
|
7
|
+
export type { CompileCLIOpts, Opts as CompileOpts } from './src/compile.js';
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { default as extractAndWrite, extract } from './src/extract';
|
|
2
|
-
export { default as compileAndWrite, compile } from './src/compile';
|
|
1
|
+
export { default as extractAndWrite, extract } from './src/extract.js';
|
|
2
|
+
export { default as compileAndWrite, compile } from './src/compile.js';
|
package/main.js
ADDED
package/package.json
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@formatjs/cli-lib",
|
|
3
3
|
"description": "Lib for CLI for formatjs.",
|
|
4
|
-
"version": "
|
|
4
|
+
"version": "8.0.0",
|
|
5
5
|
"author": "Linjie Ding <linjie@airtable.com>",
|
|
6
6
|
"bugs": "https://github.com/formatjs/formatjs/issues",
|
|
7
7
|
"dependencies": {
|
|
8
|
-
"@formatjs/icu-messageformat-parser": "
|
|
9
|
-
"@formatjs/icu-skeleton-parser": "
|
|
10
|
-
"@formatjs/ts-transformer": "
|
|
8
|
+
"@formatjs/icu-messageformat-parser": "3.0.0",
|
|
9
|
+
"@formatjs/icu-skeleton-parser": "2.0.0",
|
|
10
|
+
"@formatjs/ts-transformer": "4.0.0",
|
|
11
11
|
"@types/estree": "^1.0.6",
|
|
12
12
|
"@types/fs-extra": "^11.0.4",
|
|
13
13
|
"@types/node": "^22.0.0",
|
|
@@ -45,10 +45,10 @@
|
|
|
45
45
|
"main": "index.js",
|
|
46
46
|
"peerDependencies": {
|
|
47
47
|
"@glimmer/syntax": "^0.95.0",
|
|
48
|
-
"@vue/compiler-core": "
|
|
48
|
+
"@vue/compiler-core": "3.5.13",
|
|
49
49
|
"content-tag": "^3.0.0",
|
|
50
50
|
"ember-template-recast": "^6.1.5",
|
|
51
|
-
"vue": "
|
|
51
|
+
"vue": "3.5.13"
|
|
52
52
|
},
|
|
53
53
|
"peerDependenciesMeta": {
|
|
54
54
|
"vue": {
|
|
@@ -76,5 +76,6 @@
|
|
|
76
76
|
"optional": true
|
|
77
77
|
}
|
|
78
78
|
},
|
|
79
|
-
"repository": "formatjs/formatjs.git"
|
|
79
|
+
"repository": "formatjs/formatjs.git",
|
|
80
|
+
"type": "module"
|
|
80
81
|
}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { program } from 'commander';
|
|
2
2
|
import { sync as globSync } from 'fast-glob';
|
|
3
3
|
import loudRejection from 'loud-rejection';
|
|
4
|
-
import compile from './compile';
|
|
5
|
-
import compileFolder from './compile_folder';
|
|
6
|
-
import { debug } from './console_utils';
|
|
7
|
-
import extract from './extract';
|
|
8
|
-
import { verify } from './verify';
|
|
4
|
+
import compile from './compile.js';
|
|
5
|
+
import compileFolder from './compile_folder.js';
|
|
6
|
+
import { debug } from './console_utils.js';
|
|
7
|
+
import extract from './extract.js';
|
|
8
|
+
import { verify } from './verify/index.js';
|
|
9
9
|
import { readFileSync } from 'fs-extra';
|
|
10
10
|
import { resolve } from 'path';
|
|
11
11
|
const KNOWN_COMMANDS = ['extract'];
|
|
@@ -167,6 +167,7 @@ This is especially useful to convert from a TMS-specific format back to react-in
|
|
|
167
167
|
.option('--ignore <files...>', 'List of glob paths to ignore')
|
|
168
168
|
.option('--missing-keys', `Whether to check for missing keys in target locale compared to source locale.
|
|
169
169
|
This basically guarantees that no messages are untranslated.`)
|
|
170
|
+
.option('--extra-keys', `Whether to check that target locales don't have extra keys not present in the source locale.`)
|
|
170
171
|
.option('--structural-equality', `Whether to check for structural equality of messages between source and target locale.
|
|
171
172
|
This makes sure translations are formattable and are not missing any tokens.`)
|
|
172
173
|
.action(async (filePatterns, opts) => {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Formatter } from './formatters';
|
|
1
|
+
import { Formatter } from './formatters/index.js';
|
|
2
2
|
export type CompileFn = (msgs: any) => Record<string, string>;
|
|
3
3
|
export type PseudoLocale = 'xx-LS' | 'xx-AC' | 'xx-HA' | 'en-XA' | 'en-XB';
|
|
4
4
|
export interface CompileCLIOpts extends Opts {
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { parse } from '@formatjs/icu-messageformat-parser';
|
|
2
2
|
import { outputFile, readJSON } from 'fs-extra';
|
|
3
|
-
import
|
|
4
|
-
import { debug, warn, writeStdout } from './console_utils';
|
|
5
|
-
import { resolveBuiltinFormatter } from './formatters';
|
|
6
|
-
import { generateENXA, generateENXB, generateXXAC, generateXXHA, generateXXLS, } from './pseudo_locale';
|
|
3
|
+
import * as stringifyNs from 'json-stable-stringify';
|
|
4
|
+
import { debug, warn, writeStdout } from './console_utils.js';
|
|
5
|
+
import { resolveBuiltinFormatter } from './formatters/index.js';
|
|
6
|
+
import { generateENXA, generateENXB, generateXXAC, generateXXHA, generateXXLS, } from './pseudo_locale.js';
|
|
7
|
+
const stringify = stringifyNs.default || stringifyNs;
|
|
7
8
|
/**
|
|
8
9
|
* Aggregate `inputFiles` into a single JSON blob and compile.
|
|
9
10
|
* Also checks for conflicting IDs.
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { Opts } from './compile';
|
|
1
|
+
import { Opts } from './compile.js';
|
|
2
2
|
export default function compileFolder(files: string[], outFolder: string, opts?: Opts): Promise<void[]>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { outputFile } from 'fs-extra';
|
|
2
2
|
import { basename, join } from 'path';
|
|
3
|
-
import { compile } from './compile';
|
|
3
|
+
import { compile } from './compile.js';
|
|
4
4
|
export default async function compileFolder(files, outFolder, opts = {}) {
|
|
5
5
|
const results = await Promise.all(files.map(f => compile([f], opts)));
|
|
6
6
|
const outFiles = files.map(f => join(outFolder, basename(f)));
|
|
@@ -1,15 +1,14 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
1
|
+
import * as chalkNs from 'chalk';
|
|
2
|
+
import { clearLine as nativeClearLine, cursorTo as nativeCursorTo, } from 'readline';
|
|
3
3
|
import { format, promisify } from 'util';
|
|
4
|
+
const chalk = chalkNs.default ?? chalkNs;
|
|
4
5
|
const CLEAR_WHOLE_LINE = 0;
|
|
5
6
|
export const writeStderr = promisify(process.stderr.write).bind(process.stderr);
|
|
6
7
|
export const writeStdout = promisify(process.stdout.write).bind(process.stdout);
|
|
7
|
-
const nativeClearLine = promisify(readline.clearLine).bind(readline);
|
|
8
|
-
const nativeCursorTo = promisify(readline.cursorTo).bind(readline);
|
|
9
8
|
// From:
|
|
10
9
|
// https://github.com/yarnpkg/yarn/blob/53d8004229f543f342833310d5af63a4b6e59c8a/src/reporters/console/util.js
|
|
11
10
|
export async function clearLine(terminal) {
|
|
12
|
-
if (!supportsColor) {
|
|
11
|
+
if (!chalk.supportsColor) {
|
|
13
12
|
if (terminal.isTTY) {
|
|
14
13
|
// terminal
|
|
15
14
|
if (terminal.columns > 0) {
|
|
@@ -20,14 +19,14 @@ export async function clearLine(terminal) {
|
|
|
20
19
|
// ignore piping to file
|
|
21
20
|
}
|
|
22
21
|
else {
|
|
23
|
-
|
|
24
|
-
|
|
22
|
+
nativeClearLine(terminal, CLEAR_WHOLE_LINE);
|
|
23
|
+
nativeCursorTo(terminal, 0, undefined);
|
|
25
24
|
}
|
|
26
25
|
}
|
|
27
26
|
const LEVEL_COLORS = {
|
|
28
|
-
debug: green,
|
|
29
|
-
warn: yellow,
|
|
30
|
-
error: red,
|
|
27
|
+
debug: chalk.green,
|
|
28
|
+
warn: chalk.yellow,
|
|
29
|
+
error: chalk.red,
|
|
31
30
|
};
|
|
32
31
|
function label(level, message) {
|
|
33
32
|
return `[@formatjs/cli] [${LEVEL_COLORS[level](level.toUpperCase())}] ${message}`;
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import { interpolateName, } from '@formatjs/ts-transformer';
|
|
2
2
|
import { outputFile, readFile } from 'fs-extra';
|
|
3
|
-
import { debug, getStdinAsString, warn, writeStdout } from './console_utils';
|
|
3
|
+
import { debug, getStdinAsString, warn, writeStdout } from './console_utils.js';
|
|
4
|
+
import * as stringifyNs from 'json-stable-stringify';
|
|
4
5
|
import { parse } from '@formatjs/icu-messageformat-parser';
|
|
5
|
-
import { hoistSelectors } from '@formatjs/icu-messageformat-parser/manipulator';
|
|
6
|
-
import { printAST } from '@formatjs/icu-messageformat-parser/printer';
|
|
7
|
-
import
|
|
8
|
-
import {
|
|
9
|
-
|
|
6
|
+
import { hoistSelectors } from '@formatjs/icu-messageformat-parser/manipulator.js';
|
|
7
|
+
import { printAST } from '@formatjs/icu-messageformat-parser/printer.js';
|
|
8
|
+
import { resolveBuiltinFormatter } from './formatters/index.js';
|
|
9
|
+
import { parseScript } from './parse_script.js';
|
|
10
|
+
const stringify = stringifyNs.default || stringifyNs;
|
|
10
11
|
function calculateLineColFromOffset(text, start) {
|
|
11
12
|
if (!start) {
|
|
12
13
|
return { line: 1, col: 1 };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Comparator } from 'json-stable-stringify';
|
|
2
|
-
import { CompileFn, FormatFn, SerializeFn } from './default';
|
|
2
|
+
import { CompileFn, FormatFn, SerializeFn } from './default.js';
|
|
3
3
|
export interface Formatter<T> {
|
|
4
4
|
serialize?: SerializeFn<T>;
|
|
5
5
|
format: FormatFn<T>;
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { resolve } from 'path';
|
|
2
2
|
import { pathToFileURL } from 'url';
|
|
3
|
-
import * as crowdin from './crowdin';
|
|
4
|
-
import * as defaultFormatter from './default';
|
|
5
|
-
import * as lokalise from './lokalise';
|
|
6
|
-
import * as simple from './simple';
|
|
7
|
-
import * as smartling from './smartling';
|
|
8
|
-
import * as transifex from './transifex';
|
|
3
|
+
import * as crowdin from './crowdin.js';
|
|
4
|
+
import * as defaultFormatter from './default.js';
|
|
5
|
+
import * as lokalise from './lokalise.js';
|
|
6
|
+
import * as simple from './simple.js';
|
|
7
|
+
import * as smartling from './smartling.js';
|
|
8
|
+
import * as transifex from './transifex.js';
|
|
9
9
|
export async function resolveBuiltinFormatter(format) {
|
|
10
10
|
if (!format) {
|
|
11
11
|
return defaultFormatter;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Preprocessor } from 'content-tag';
|
|
2
|
-
import { parseFile as parseHbsFile } from './hbs_extractor';
|
|
3
|
-
import { parseScript } from './parse_script';
|
|
2
|
+
import { parseFile as parseHbsFile } from './hbs_extractor.js';
|
|
3
|
+
import { parseScript } from './parse_script.js';
|
|
4
4
|
let p = new Preprocessor();
|
|
5
5
|
export function parseFile(source, fileName, options) {
|
|
6
6
|
const scriptParseFn = parseScript(options, fileName);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { transformWithTs } from '@formatjs/ts-transformer';
|
|
2
|
-
import ts from 'typescript';
|
|
3
|
-
import { debug } from './console_utils';
|
|
2
|
+
import * as ts from 'typescript';
|
|
3
|
+
import { debug } from './console_utils.js';
|
|
4
4
|
/**
|
|
5
5
|
* Invoid TypeScript module transpilation with our TS transformer
|
|
6
6
|
* @param opts Formatjs TS Transformer opt
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function checkExtraKeys(translationFilesContents: Record<string, any>, sourceLocale: string): Promise<boolean>;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { debug, writeStderr } from '../console_utils.js';
|
|
2
|
+
/**
|
|
3
|
+
* Flatten nested obj into list of keys, delimited by `.`
|
|
4
|
+
* @param obj
|
|
5
|
+
* @param parentKey
|
|
6
|
+
* @returns
|
|
7
|
+
*/
|
|
8
|
+
function extractKeys(obj, parentKey = '') {
|
|
9
|
+
if (!obj || typeof obj !== 'object' || Array.isArray(obj)) {
|
|
10
|
+
return [];
|
|
11
|
+
}
|
|
12
|
+
return Object.keys(obj)
|
|
13
|
+
.map(k => [parentKey ? `${parentKey}.${k}` : k, ...extractKeys(obj[k], k)])
|
|
14
|
+
.flat();
|
|
15
|
+
}
|
|
16
|
+
export async function checkExtraKeys(translationFilesContents, sourceLocale) {
|
|
17
|
+
debug('Checking translation files:');
|
|
18
|
+
const sourceContent = translationFilesContents[sourceLocale];
|
|
19
|
+
if (!sourceContent) {
|
|
20
|
+
throw new Error(`Missing source ${sourceLocale}.json file`);
|
|
21
|
+
}
|
|
22
|
+
const sourceKeys = extractKeys(sourceContent);
|
|
23
|
+
return Object.entries(translationFilesContents)
|
|
24
|
+
.filter(([locale]) => locale !== sourceLocale)
|
|
25
|
+
.reduce((result, [locale, content]) => {
|
|
26
|
+
const localeKeys = new Set(extractKeys(content));
|
|
27
|
+
const extraKeys = new Set(Array.from(localeKeys).filter(k => !sourceKeys.includes(k)));
|
|
28
|
+
if (!extraKeys.size) {
|
|
29
|
+
return result;
|
|
30
|
+
}
|
|
31
|
+
writeStderr('---------------------------------\n');
|
|
32
|
+
writeStderr(`Extra translation keys for locale ${locale}:\n`);
|
|
33
|
+
extraKeys.forEach(r => writeStderr(`${r}\n`));
|
|
34
|
+
return false;
|
|
35
|
+
}, true);
|
|
36
|
+
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { debug, writeStderr } from '../console_utils';
|
|
1
|
+
import { debug, writeStderr } from '../console_utils.js';
|
|
2
2
|
/**
|
|
3
3
|
* Flatten nested obj into list of keys, delimited by `.`
|
|
4
4
|
* @param obj
|
|
@@ -15,16 +15,16 @@ function extractKeys(obj, parentKey = '') {
|
|
|
15
15
|
}
|
|
16
16
|
export async function checkMissingKeys(translationFilesContents, sourceLocale) {
|
|
17
17
|
debug('Checking translation files:');
|
|
18
|
-
const
|
|
19
|
-
if (!
|
|
18
|
+
const sourceContent = translationFilesContents[sourceLocale];
|
|
19
|
+
if (!sourceContent) {
|
|
20
20
|
throw new Error(`Missing source ${sourceLocale}.json file`);
|
|
21
21
|
}
|
|
22
|
-
const
|
|
22
|
+
const sourceKeys = extractKeys(sourceContent);
|
|
23
23
|
return Object.entries(translationFilesContents)
|
|
24
24
|
.filter(([locale]) => locale !== sourceLocale)
|
|
25
25
|
.reduce((result, [locale, content]) => {
|
|
26
26
|
const localeKeys = new Set(extractKeys(content));
|
|
27
|
-
const missingKeys = new Set(
|
|
27
|
+
const missingKeys = new Set(sourceKeys.filter(r => !localeKeys.has(r)));
|
|
28
28
|
// We're being lenient here since only missing keys are currently considered breaking
|
|
29
29
|
if (!missingKeys.size) {
|
|
30
30
|
return result;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { isStructurallySame, parse, } from '@formatjs/icu-messageformat-parser';
|
|
2
|
-
import { debug, writeStderr } from '../console_utils';
|
|
2
|
+
import { debug, writeStderr } from '../console_utils.js';
|
|
3
3
|
import { error } from 'console';
|
|
4
4
|
/**
|
|
5
5
|
* Flatten nested obj into list of keys, delimited by `.`
|
|
@@ -25,11 +25,11 @@ function flatten(obj, parentKey = '') {
|
|
|
25
25
|
}
|
|
26
26
|
export async function checkStructuralEquality(translationFilesContents, sourceLocale) {
|
|
27
27
|
debug('Checking translation files:');
|
|
28
|
-
const
|
|
29
|
-
if (!
|
|
28
|
+
const sourceContent = translationFilesContents[sourceLocale];
|
|
29
|
+
if (!sourceContent) {
|
|
30
30
|
throw new Error(`Missing source ${sourceLocale}.json file`);
|
|
31
31
|
}
|
|
32
|
-
const
|
|
32
|
+
const sourceMessages = Object.entries(flatten(sourceContent)).reduce((all, [key, value]) => {
|
|
33
33
|
try {
|
|
34
34
|
all[key] = parse(value);
|
|
35
35
|
}
|
|
@@ -42,17 +42,17 @@ export async function checkStructuralEquality(translationFilesContents, sourceLo
|
|
|
42
42
|
.filter(([locale]) => locale !== sourceLocale)
|
|
43
43
|
.reduce((result, [locale, content]) => {
|
|
44
44
|
const localeMessages = flatten(content);
|
|
45
|
-
const problematicKeys = Object.keys(
|
|
45
|
+
const problematicKeys = Object.keys(sourceMessages)
|
|
46
46
|
.map(k => {
|
|
47
47
|
if (!localeMessages[k]) {
|
|
48
48
|
return { key: k, success: true };
|
|
49
49
|
}
|
|
50
|
-
const
|
|
50
|
+
const sourceMessage = sourceMessages[k];
|
|
51
51
|
try {
|
|
52
52
|
const localeMessage = parse(localeMessages[k]);
|
|
53
53
|
return {
|
|
54
54
|
key: k,
|
|
55
|
-
...isStructurallySame(
|
|
55
|
+
...isStructurallySame(sourceMessage, localeMessage),
|
|
56
56
|
};
|
|
57
57
|
}
|
|
58
58
|
catch (e) {
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
export interface VerifyOpts {
|
|
2
2
|
sourceLocale: string;
|
|
3
3
|
missingKeys: boolean;
|
|
4
|
+
extraKeys: boolean;
|
|
4
5
|
structuralEquality: boolean;
|
|
5
6
|
ignore?: string[];
|
|
6
7
|
}
|
|
7
|
-
export declare function verify(files: string[], { sourceLocale, missingKeys, structuralEquality }: VerifyOpts): Promise<void>;
|
|
8
|
+
export declare function verify(files: string[], { sourceLocale, missingKeys, extraKeys, structuralEquality }: VerifyOpts): Promise<void>;
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { basename } from 'path';
|
|
2
|
-
import { debug } from '../console_utils';
|
|
3
|
-
import { checkMissingKeys } from './checkMissingKeys';
|
|
2
|
+
import { debug } from '../console_utils.js';
|
|
3
|
+
import { checkMissingKeys } from './checkMissingKeys.js';
|
|
4
|
+
import { checkExtraKeys } from './checkExtraKeys.js';
|
|
4
5
|
import { readJSON } from 'fs-extra';
|
|
5
|
-
import { checkStructuralEquality } from './checkStructuralEquality';
|
|
6
|
-
export async function verify(files, { sourceLocale, missingKeys, structuralEquality }) {
|
|
6
|
+
import { checkStructuralEquality } from './checkStructuralEquality.js';
|
|
7
|
+
export async function verify(files, { sourceLocale, missingKeys, extraKeys, structuralEquality }) {
|
|
7
8
|
debug('Checking translation files:');
|
|
8
9
|
files.forEach(fn => debug(fn));
|
|
9
10
|
const translationFilesContents = (await Promise.all(files.map(async (fn) => [basename(fn, '.json'), await readJSON(fn)]))).reduce((all, [locale, content]) => {
|
|
@@ -16,6 +17,10 @@ export async function verify(files, { sourceLocale, missingKeys, structuralEqual
|
|
|
16
17
|
!(await checkMissingKeys(translationFilesContents, sourceLocale))) {
|
|
17
18
|
exitCode = 1;
|
|
18
19
|
}
|
|
20
|
+
if (extraKeys &&
|
|
21
|
+
!(await checkExtraKeys(translationFilesContents, sourceLocale))) {
|
|
22
|
+
exitCode = 1;
|
|
23
|
+
}
|
|
19
24
|
if (structuralEquality &&
|
|
20
25
|
!(await checkStructuralEquality(translationFilesContents, sourceLocale))) {
|
|
21
26
|
exitCode = 1;
|
package/lib_esnext/main.js
DELETED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|