localeguard 0.1.0 → 0.2.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/src/commands/check.d.ts +8 -1
- package/dist/src/commands/check.d.ts.map +1 -1
- package/dist/src/commands/check.js +69 -4
- package/dist/src/commands/check.js.map +1 -1
- package/dist/src/git-changed.d.ts +21 -0
- package/dist/src/git-changed.d.ts.map +1 -0
- package/dist/src/git-changed.js +118 -0
- package/dist/src/git-changed.js.map +1 -0
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +23 -6
- package/dist/src/index.js.map +1 -1
- package/package.json +3 -3
|
@@ -2,13 +2,20 @@
|
|
|
2
2
|
* `localeguard check` — run the locale-parity and source-code checks, merge the
|
|
3
3
|
* results, and report them.
|
|
4
4
|
*/
|
|
5
|
+
export type Reporter = "text" | "json" | "markdown" | "sarif";
|
|
5
6
|
export interface CheckArgs {
|
|
6
7
|
cwd: string;
|
|
7
8
|
configPath?: string;
|
|
8
|
-
reporter:
|
|
9
|
+
reporter: Reporter;
|
|
9
10
|
color: boolean;
|
|
10
11
|
/** Run source-code analysis (hardcoded text). Defaults to true. */
|
|
11
12
|
code: boolean;
|
|
13
|
+
/** Write the report to this file instead of stdout. */
|
|
14
|
+
output?: string;
|
|
15
|
+
/** Tool version, shown in markdown/sarif output. */
|
|
16
|
+
toolVersion: string;
|
|
17
|
+
/** When set, only report issues touching files changed vs this git ref. */
|
|
18
|
+
changedBase?: string;
|
|
12
19
|
}
|
|
13
20
|
/** Returns the process exit code. */
|
|
14
21
|
export declare function runCheckCommand(args: CheckArgs): number;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"check.d.ts","sourceRoot":"","sources":["../../../src/commands/check.ts"],"names":[],"mappings":"AAAA;;;GAGG;
|
|
1
|
+
{"version":3,"file":"check.d.ts","sourceRoot":"","sources":["../../../src/commands/check.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAqBH,MAAM,MAAM,QAAQ,GAAG,MAAM,GAAG,MAAM,GAAG,UAAU,GAAG,OAAO,CAAC;AAE9D,MAAM,WAAW,SAAS;IACxB,GAAG,EAAE,MAAM,CAAC;IACZ,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,QAAQ,EAAE,QAAQ,CAAC;IACnB,KAAK,EAAE,OAAO,CAAC;IACf,mEAAmE;IACnE,IAAI,EAAE,OAAO,CAAC;IACd,uDAAuD;IACvD,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,oDAAoD;IACpD,WAAW,EAAE,MAAM,CAAC;IACpB,2EAA2E;IAC3E,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED,qCAAqC;AACrC,wBAAgB,eAAe,CAAC,IAAI,EAAE,SAAS,GAAG,MAAM,CAwEvD"}
|
|
@@ -3,11 +3,47 @@
|
|
|
3
3
|
* `localeguard check` — run the locale-parity and source-code checks, merge the
|
|
4
4
|
* results, and report them.
|
|
5
5
|
*/
|
|
6
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
7
|
+
if (k2 === undefined) k2 = k;
|
|
8
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
9
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
10
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
11
|
+
}
|
|
12
|
+
Object.defineProperty(o, k2, desc);
|
|
13
|
+
}) : (function(o, m, k, k2) {
|
|
14
|
+
if (k2 === undefined) k2 = k;
|
|
15
|
+
o[k2] = m[k];
|
|
16
|
+
}));
|
|
17
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
18
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
19
|
+
}) : function(o, v) {
|
|
20
|
+
o["default"] = v;
|
|
21
|
+
});
|
|
22
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
23
|
+
var ownKeys = function(o) {
|
|
24
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
25
|
+
var ar = [];
|
|
26
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
27
|
+
return ar;
|
|
28
|
+
};
|
|
29
|
+
return ownKeys(o);
|
|
30
|
+
};
|
|
31
|
+
return function (mod) {
|
|
32
|
+
if (mod && mod.__esModule) return mod;
|
|
33
|
+
var result = {};
|
|
34
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
35
|
+
__setModuleDefault(result, mod);
|
|
36
|
+
return result;
|
|
37
|
+
};
|
|
38
|
+
})();
|
|
6
39
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
40
|
exports.runCheckCommand = runCheckCommand;
|
|
41
|
+
const fs = __importStar(require("node:fs"));
|
|
42
|
+
const path = __importStar(require("node:path"));
|
|
8
43
|
const core_1 = require("@localeguard/core");
|
|
9
44
|
const react_analyzer_1 = require("@localeguard/react-analyzer");
|
|
10
45
|
const config_1 = require("../config");
|
|
46
|
+
const git_changed_1 = require("../git-changed");
|
|
11
47
|
/** Returns the process exit code. */
|
|
12
48
|
function runCheckCommand(args) {
|
|
13
49
|
let loaded;
|
|
@@ -40,7 +76,21 @@ function runCheckCommand(args) {
|
|
|
40
76
|
translationComponents: config.translationComponents,
|
|
41
77
|
}, { rootDir })
|
|
42
78
|
: [];
|
|
43
|
-
|
|
79
|
+
let issues = [...localeResult.issues, ...codeIssues];
|
|
80
|
+
if (args.changedBase !== undefined) {
|
|
81
|
+
let changed;
|
|
82
|
+
try {
|
|
83
|
+
changed = (0, git_changed_1.getChangedFiles)(rootDir, args.changedBase);
|
|
84
|
+
}
|
|
85
|
+
catch (err) {
|
|
86
|
+
if (err instanceof git_changed_1.GitError) {
|
|
87
|
+
process.stderr.write(`localeguard: ${err.message}\n`);
|
|
88
|
+
return 1;
|
|
89
|
+
}
|
|
90
|
+
throw err;
|
|
91
|
+
}
|
|
92
|
+
issues = (0, git_changed_1.filterIssuesToChanged)(issues, changed, config.localesPath);
|
|
93
|
+
}
|
|
44
94
|
(0, core_1.sortIssues)(issues);
|
|
45
95
|
const stats = (0, core_1.summarizeIssues)(issues, {
|
|
46
96
|
sourceLocale: config.sourceLocale,
|
|
@@ -49,12 +99,27 @@ function runCheckCommand(args) {
|
|
|
49
99
|
blockOn: config.blockOn,
|
|
50
100
|
});
|
|
51
101
|
const result = { issues, stats, missingLocales: localeResult.missingLocales };
|
|
52
|
-
|
|
53
|
-
|
|
102
|
+
const report = render(result, args);
|
|
103
|
+
if (args.output) {
|
|
104
|
+
const outPath = path.resolve(args.cwd, args.output);
|
|
105
|
+
fs.writeFileSync(outPath, report + "\n", "utf8");
|
|
106
|
+
process.stderr.write(`localeguard: wrote ${args.reporter} report to ${outPath}\n`);
|
|
54
107
|
}
|
|
55
108
|
else {
|
|
56
|
-
process.stdout.write(
|
|
109
|
+
process.stdout.write(report + "\n");
|
|
57
110
|
}
|
|
58
111
|
return result.stats.failed ? 1 : 0;
|
|
59
112
|
}
|
|
113
|
+
function render(result, args) {
|
|
114
|
+
switch (args.reporter) {
|
|
115
|
+
case "json":
|
|
116
|
+
return (0, core_1.formatJson)(result);
|
|
117
|
+
case "markdown":
|
|
118
|
+
return (0, core_1.formatMarkdown)(result, { toolVersion: args.toolVersion });
|
|
119
|
+
case "sarif":
|
|
120
|
+
return (0, core_1.formatSarif)(result, { toolVersion: args.toolVersion });
|
|
121
|
+
default:
|
|
122
|
+
return (0, core_1.formatText)(result, { color: args.color });
|
|
123
|
+
}
|
|
124
|
+
}
|
|
60
125
|
//# sourceMappingURL=check.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"check.js","sourceRoot":"","sources":["../../../src/commands/check.ts"],"names":[],"mappings":";AAAA;;;GAGG
|
|
1
|
+
{"version":3,"file":"check.js","sourceRoot":"","sources":["../../../src/commands/check.ts"],"names":[],"mappings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AAI,CAAC,MAAM,CAAC,CAAC;QACpD,EAAE,CAAC,aAAa,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,EAAE,MAAM,CAAC,CAAC;QACjD,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,sBAAsB,IAAI,CAAC,QAAQ,cAAc,OAAO,IAAI,CAAC,CAAC;IACrF,CAAC;SAAM,CAAC;QACN,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,MAAM,GAAG,IAAI,CAAC,CAAC;IACtC,CAAC;IAED,OAAO,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AACrC,CAAC;AAED,SAAS,MAAM,CAAC,MAAmB,EAAE,IAAe;IAClD,QAAQ,IAAI,CAAC,QAAQ,EAAE,CAAC;QACtB,KAAK,MAAM;YACT,OAAO,IAAA,iBAAU,EAAC,MAAM,CAAC,CAAC;QAC5B,KAAK,UAAU;YACb,OAAO,IAAA,qBAAc,EAAC,MAAM,EAAE,EAAE,WAAW,EAAE,IAAI,CAAC,WAAW,EAAE,CAAC,CAAC;QACnE,KAAK,OAAO;YACV,OAAO,IAAA,kBAAW,EAAC,MAAM,EAAE,EAAE,WAAW,EAAE,IAAI,CAAC,WAAW,EAAE,CAAC,CAAC;QAChE;YACE,OAAO,IAAA,iBAAU,EAAC,MAAM,EAAE,EAAE,KAAK,EAAE,IAAI,CAAC,KAAK,EAAE,CAAC,CAAC;IACrD,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Changed-files-only support: limit reported issues to files affected by the
|
|
3
|
+
* current change set (e.g. a pull request), for fast, focused CI feedback.
|
|
4
|
+
*/
|
|
5
|
+
import type { Issue } from "@localeguard/core";
|
|
6
|
+
export declare class GitError extends Error {
|
|
7
|
+
constructor(message: string);
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Return the set of files changed relative to `base`, as paths relative to
|
|
11
|
+
* `rootDir` (POSIX-separated). Throws GitError if not in a git repo or the
|
|
12
|
+
* base ref cannot be resolved.
|
|
13
|
+
*/
|
|
14
|
+
export declare function getChangedFiles(rootDir: string, base: string): Set<string>;
|
|
15
|
+
/**
|
|
16
|
+
* Keep an issue when its own file changed, or — for locale-parity issues, which
|
|
17
|
+
* may be reported against the source file — when any of the target locale's
|
|
18
|
+
* files changed.
|
|
19
|
+
*/
|
|
20
|
+
export declare function filterIssuesToChanged(issues: Issue[], changed: Set<string>, localesPath: string): Issue[];
|
|
21
|
+
//# sourceMappingURL=git-changed.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"git-changed.d.ts","sourceRoot":"","sources":["../../src/git-changed.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAMH,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAE/C,qBAAa,QAAS,SAAQ,KAAK;gBACrB,OAAO,EAAE,MAAM;CAI5B;AAED;;;;GAIG;AACH,wBAAgB,eAAe,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,GAAG,CAAC,MAAM,CAAC,CA6B1E;AAED;;;;GAIG;AACH,wBAAgB,qBAAqB,CACnC,MAAM,EAAE,KAAK,EAAE,EACf,OAAO,EAAE,GAAG,CAAC,MAAM,CAAC,EACpB,WAAW,EAAE,MAAM,GAClB,KAAK,EAAE,CAOT"}
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Changed-files-only support: limit reported issues to files affected by the
|
|
4
|
+
* current change set (e.g. a pull request), for fast, focused CI feedback.
|
|
5
|
+
*/
|
|
6
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
7
|
+
if (k2 === undefined) k2 = k;
|
|
8
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
9
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
10
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
11
|
+
}
|
|
12
|
+
Object.defineProperty(o, k2, desc);
|
|
13
|
+
}) : (function(o, m, k, k2) {
|
|
14
|
+
if (k2 === undefined) k2 = k;
|
|
15
|
+
o[k2] = m[k];
|
|
16
|
+
}));
|
|
17
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
18
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
19
|
+
}) : function(o, v) {
|
|
20
|
+
o["default"] = v;
|
|
21
|
+
});
|
|
22
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
23
|
+
var ownKeys = function(o) {
|
|
24
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
25
|
+
var ar = [];
|
|
26
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
27
|
+
return ar;
|
|
28
|
+
};
|
|
29
|
+
return ownKeys(o);
|
|
30
|
+
};
|
|
31
|
+
return function (mod) {
|
|
32
|
+
if (mod && mod.__esModule) return mod;
|
|
33
|
+
var result = {};
|
|
34
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
35
|
+
__setModuleDefault(result, mod);
|
|
36
|
+
return result;
|
|
37
|
+
};
|
|
38
|
+
})();
|
|
39
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
40
|
+
exports.GitError = void 0;
|
|
41
|
+
exports.getChangedFiles = getChangedFiles;
|
|
42
|
+
exports.filterIssuesToChanged = filterIssuesToChanged;
|
|
43
|
+
const node_child_process_1 = require("node:child_process");
|
|
44
|
+
const fs = __importStar(require("node:fs"));
|
|
45
|
+
const path = __importStar(require("node:path"));
|
|
46
|
+
class GitError extends Error {
|
|
47
|
+
constructor(message) {
|
|
48
|
+
super(message);
|
|
49
|
+
this.name = "GitError";
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
exports.GitError = GitError;
|
|
53
|
+
/**
|
|
54
|
+
* Return the set of files changed relative to `base`, as paths relative to
|
|
55
|
+
* `rootDir` (POSIX-separated). Throws GitError if not in a git repo or the
|
|
56
|
+
* base ref cannot be resolved.
|
|
57
|
+
*/
|
|
58
|
+
function getChangedFiles(rootDir, base) {
|
|
59
|
+
let gitRoot;
|
|
60
|
+
try {
|
|
61
|
+
gitRoot = run(rootDir, ["rev-parse", "--show-toplevel"]).trim();
|
|
62
|
+
}
|
|
63
|
+
catch {
|
|
64
|
+
throw new GitError("not a git repository — cannot use --changed");
|
|
65
|
+
}
|
|
66
|
+
let output;
|
|
67
|
+
try {
|
|
68
|
+
output = run(rootDir, ["diff", "--name-only", "--diff-filter=d", base]);
|
|
69
|
+
}
|
|
70
|
+
catch (err) {
|
|
71
|
+
const first = err.message.split("\n")[0] ?? "";
|
|
72
|
+
throw new GitError(`could not diff against "${base}": ${first}`);
|
|
73
|
+
}
|
|
74
|
+
// `git rev-parse --show-toplevel` returns a canonical path (e.g. /private/var
|
|
75
|
+
// on macOS), so canonicalize rootDir too before relativizing — otherwise
|
|
76
|
+
// symlinked roots produce mismatched paths.
|
|
77
|
+
const realRoot = fs.realpathSync(rootDir);
|
|
78
|
+
const changed = new Set();
|
|
79
|
+
for (const line of output.split("\n")) {
|
|
80
|
+
const file = line.trim();
|
|
81
|
+
if (!file)
|
|
82
|
+
continue;
|
|
83
|
+
const abs = path.resolve(gitRoot, file);
|
|
84
|
+
changed.add(path.relative(realRoot, abs).split(path.sep).join("/"));
|
|
85
|
+
}
|
|
86
|
+
return changed;
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* Keep an issue when its own file changed, or — for locale-parity issues, which
|
|
90
|
+
* may be reported against the source file — when any of the target locale's
|
|
91
|
+
* files changed.
|
|
92
|
+
*/
|
|
93
|
+
function filterIssuesToChanged(issues, changed, localesPath) {
|
|
94
|
+
const lp = localesPath.replace(/\/+$/, "");
|
|
95
|
+
return issues.filter((issue) => {
|
|
96
|
+
if (changed.has(issue.file))
|
|
97
|
+
return true;
|
|
98
|
+
if (issue.locale && localeFilesChanged(changed, lp, issue.locale))
|
|
99
|
+
return true;
|
|
100
|
+
return false;
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
function localeFilesChanged(changed, localesPath, locale) {
|
|
104
|
+
const singleFile = `${localesPath}/${locale}.json`;
|
|
105
|
+
const dirPrefix = `${localesPath}/${locale}/`;
|
|
106
|
+
for (const file of changed) {
|
|
107
|
+
if (file === singleFile || file.startsWith(dirPrefix))
|
|
108
|
+
return true;
|
|
109
|
+
}
|
|
110
|
+
return false;
|
|
111
|
+
}
|
|
112
|
+
function run(cwd, args) {
|
|
113
|
+
return (0, node_child_process_1.execFileSync)("git", ["-C", cwd, ...args], {
|
|
114
|
+
encoding: "utf8",
|
|
115
|
+
stdio: ["ignore", "pipe", "pipe"],
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
//# sourceMappingURL=git-changed.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"git-changed.js","sourceRoot":"","sources":["../../src/git-changed.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAoBH,0CA6BC;AAOD,sDAWC;AAjED,2DAAkD;AAClD,4CAA8B;AAC9B,gDAAkC;AAIlC,MAAa,QAAS,SAAQ,KAAK;IACjC,YAAY,OAAe;QACzB,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,UAAU,CAAC;IACzB,CAAC;CACF;AALD,4BAKC;AAED;;;;GAIG;AACH,SAAgB,eAAe,CAAC,OAAe,EAAE,IAAY;IAC3D,IAAI,OAAe,CAAC;IACpB,IAAI,CAAC;QACH,OAAO,GAAG,GAAG,CAAC,OAAO,EAAE,CAAC,WAAW,EAAE,iBAAiB,CAAC,CAAC,CAAC,IAAI,E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C,MAAM,EAAE,EAAE,CAAC,CAAC;IAC3C,OAAO,MAAM,CAAC,MAAM,CAAC,CAAC,KAAK,EAAE,EAAE;QAC7B,IAAI,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC;YAAE,OAAO,IAAI,CAAC;QACzC,IAAI,KAAK,CAAC,MAAM,IAAI,kBAAkB,CAAC,OAAO,EAAE,EAAE,EAAE,KAAK,CAAC,MAAM,CAAC;YAAE,OAAO,IAAI,CAAC;QAC/E,OAAO,KAAK,CAAC;IACf,CAAC,CAAC,CAAC;AACL,CAAC;AAED,SAAS,kBAAkB,CAAC,OAAoB,EAAE,WAAmB,EAAE,MAAc;IACnF,MAAM,UAAU,GAAG,GAAG,WAAW,IAAI,MAAM,OAAO,CAAC;IACnD,MAAM,SAAS,GAAG,GAAG,WAAW,IAAI,MAAM,GAAG,CAAC;IAC9C,KAAK,MAAM,IAAI,IAAI,OAAO,EAAE,CAAC;QAC3B,IAAI,IAAI,KAAK,UAAU,IAAI,IAAI,CAAC,UAAU,CAAC,SAAS,CAAC;YAAE,OAAO,IAAI,CAAC;IACrE,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC;AAED,SAAS,GAAG,CAAC,GAAW,EAAE,IAAc;IACtC,OAAO,IAAA,iCAAY,EAAC,KAAK,EAAE,CAAC,IAAI,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC,EAAE;QAC/C,QAAQ,EAAE,MAAM;QAChB,KAAK,EAAE,CAAC,QAAQ,EAAE,MAAM,EAAE,MAAM,CAAC;KAClC,CAAC,CAAC;AACL,CAAC"}
|
package/dist/src/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";AACA;;GAEG;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";AACA;;GAEG;AAwCH,wBAAgB,IAAI,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,MAAM,CAuE3C"}
|
package/dist/src/index.js
CHANGED
|
@@ -8,7 +8,8 @@ exports.main = main;
|
|
|
8
8
|
const node_util_1 = require("node:util");
|
|
9
9
|
const check_1 = require("./commands/check");
|
|
10
10
|
const init_1 = require("./commands/init");
|
|
11
|
-
const VERSION = "0.
|
|
11
|
+
const VERSION = "0.2.0";
|
|
12
|
+
const REPORTERS = ["text", "json", "markdown", "sarif"];
|
|
12
13
|
const HELP = `LocaleGuard ${VERSION}
|
|
13
14
|
Localization quality gate for React and TypeScript projects.
|
|
14
15
|
|
|
@@ -22,7 +23,10 @@ Commands:
|
|
|
22
23
|
|
|
23
24
|
Options:
|
|
24
25
|
-c, --config <path> Path to a config file
|
|
25
|
-
-r, --reporter <type> Output format: text (default)
|
|
26
|
+
-r, --reporter <type> Output format: text (default), json, markdown, sarif
|
|
27
|
+
-o, --output <file> Write the report to a file instead of stdout
|
|
28
|
+
--changed Only report issues in files changed vs --base
|
|
29
|
+
--base <ref> Git ref to diff against for --changed (default: HEAD)
|
|
26
30
|
--cwd <dir> Run as if from this directory
|
|
27
31
|
--no-code Skip source-code analysis (locale files only)
|
|
28
32
|
--no-color Disable colored output
|
|
@@ -43,6 +47,9 @@ function main(argv) {
|
|
|
43
47
|
options: {
|
|
44
48
|
config: { type: "string", short: "c" },
|
|
45
49
|
reporter: { type: "string", short: "r" },
|
|
50
|
+
output: { type: "string", short: "o" },
|
|
51
|
+
changed: { type: "boolean" },
|
|
52
|
+
base: { type: "string" },
|
|
46
53
|
cwd: { type: "string" },
|
|
47
54
|
color: { type: "boolean" },
|
|
48
55
|
"no-color": { type: "boolean" },
|
|
@@ -70,14 +77,24 @@ function main(argv) {
|
|
|
70
77
|
const cwd = values.cwd ? values.cwd : process.cwd();
|
|
71
78
|
switch (command) {
|
|
72
79
|
case "check": {
|
|
73
|
-
const reporter = values.reporter
|
|
74
|
-
if (
|
|
75
|
-
process.stderr.write(`localeguard: unknown reporter "${values.reporter}"\n`);
|
|
80
|
+
const reporter = (values.reporter ?? "text");
|
|
81
|
+
if (!REPORTERS.includes(reporter)) {
|
|
82
|
+
process.stderr.write(`localeguard: unknown reporter "${values.reporter}" (expected ${REPORTERS.join(", ")})\n`);
|
|
76
83
|
return 1;
|
|
77
84
|
}
|
|
78
85
|
const color = resolveColor(values.color, values["no-color"]);
|
|
79
86
|
const code = !values["no-code"];
|
|
80
|
-
|
|
87
|
+
const changedBase = values.changed ? (values.base ?? "HEAD") : undefined;
|
|
88
|
+
return (0, check_1.runCheckCommand)({
|
|
89
|
+
cwd,
|
|
90
|
+
configPath: values.config,
|
|
91
|
+
reporter,
|
|
92
|
+
output: values.output,
|
|
93
|
+
color,
|
|
94
|
+
code,
|
|
95
|
+
toolVersion: VERSION,
|
|
96
|
+
changedBase,
|
|
97
|
+
});
|
|
81
98
|
}
|
|
82
99
|
case "init":
|
|
83
100
|
return (0, init_1.runInitCommand)({ cwd });
|
package/dist/src/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;AACA;;GAEG;;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;AACA;;GAEG;;AAwCH,oBAuEC;AA7GD,yCAAsC;AAEtC,4CAAmD;AAEnD,0CAAiD;AAEjD,MAAM,OAAO,GAAG,OAAO,CAAC;AACxB,MAAM,SAAS,GAAe,CAAC,MAAM,EAAE,MAAM,EAAE,UAAU,EAAE,OAAO,CAAC,CAAC;AAEpE,MAAM,IAAI,GAAG,eAAe,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;CA2BlC,CAAC;AAEF,SAAgB,IAAI,CAAC,IAAc;IACjC,IAAI,MAAM,CAAC;IACX,IAAI,CAAC;QACH,MAAM,GAAG,IAAA,qBAAS,EAAC;YACjB,IAAI,EAAE,IAAI;YACV,gBAAgB,EAAE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KAAK;gBACL,IAAI;gBACJ,WAAW,EAAE,OAAO;gBACpB,WAAW;aACZ,CAAC,CAAC;QACL,CAAC;QACD,KAAK,MAAM;YACT,OAAO,IAAA,qBAAc,EAAC,EAAE,GAAG,EAAE,CAAC,CAAC;QACjC;YACE,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,iCAAiC,OAAO,QAAQ,IAAI,EAAE,CAAC,CAAC;YAC7E,OAAO,CAAC,CAAC;IACb,CAAC;AACH,CAAC;AAED,SAAS,YAAY,CAAC,KAAe,EAAE,OAAiB;IACtD,IAAI,OAAO;QAAE,OAAO,KAAK,CAAC;IAC1B,IAAI,KAAK;QAAE,OAAO,IAAI,CAAC;IACvB,OAAO,OAAO,CAAC,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC;AAChE,CAAC;AAED,0DAA0D;AAC1D,IAAI,OAAO,CAAC,IAAI,KAAK,MAAM,EAAE,CAAC;IAC5B,OAAO,CAAC,QAAQ,GAAG,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;AACjD,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "localeguard",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"description": "Open-source localization quality gate for React and TypeScript projects. Detects missing keys, broken interpolation, and invalid locale files before merge.",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"author": "isamrish",
|
|
@@ -28,8 +28,8 @@
|
|
|
28
28
|
"prepublishOnly": "tsc -b"
|
|
29
29
|
},
|
|
30
30
|
"dependencies": {
|
|
31
|
-
"@localeguard/core": "0.
|
|
32
|
-
"@localeguard/react-analyzer": "0.
|
|
31
|
+
"@localeguard/core": "0.2.0",
|
|
32
|
+
"@localeguard/react-analyzer": "0.2.0"
|
|
33
33
|
},
|
|
34
34
|
"publishConfig": {
|
|
35
35
|
"access": "public"
|