@dialexjs/cli 0.5.2 → 0.7.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/README.md +4 -0
- package/dist/api.d.mts +27 -1
- package/dist/api.d.mts.map +1 -1
- package/dist/api.mjs +2 -2
- package/dist/index.mjs +3 -15
- package/dist/index.mjs.map +1 -1
- package/dist/{project-BJYmnKiU.mjs → project-DBVeKLa3.mjs} +265 -56
- package/dist/project-DBVeKLa3.mjs.map +1 -0
- package/package.json +3 -2
- package/dist/project-BJYmnKiU.mjs.map +0 -1
package/README.md
CHANGED
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
<p align="center">
|
|
2
|
+
<img src="https://raw.githubusercontent.com/awaiden/dialex/main/assets/logo.png" alt="Dialex" width="96" height="96" />
|
|
3
|
+
</p>
|
|
4
|
+
|
|
1
5
|
# @dialexjs/cli
|
|
2
6
|
|
|
3
7
|
> High-performance CLI tool for Dialex internationalization (codegen, scaffolding, CI parity checking).
|
package/dist/api.d.mts
CHANGED
|
@@ -120,6 +120,7 @@ interface AnalysisConfig {
|
|
|
120
120
|
defaultLocale?: string;
|
|
121
121
|
locales?: string[];
|
|
122
122
|
include?: string | string[];
|
|
123
|
+
exclude?: string[];
|
|
123
124
|
}
|
|
124
125
|
interface AnalysisOptions {
|
|
125
126
|
root: string;
|
|
@@ -174,6 +175,30 @@ export declare function analyzeProject(options: AnalysisOptions): Promise<Analys
|
|
|
174
175
|
/** Project root-relative path with forward slashes, for display. */
|
|
175
176
|
export declare function relativeFile(root: string, file: string): string;
|
|
176
177
|
//#endregion
|
|
178
|
+
//#region src/utils/files.d.ts
|
|
179
|
+
/** Folders that never hold project dictionaries or sources, in every scanner. */
|
|
180
|
+
export declare const BUILTIN_IGNORE: string[];
|
|
181
|
+
/** What the source scan skips on top: other tools' output, declarations, generated and config files. */
|
|
182
|
+
export declare const SOURCE_BUILTIN_IGNORE: string[];
|
|
183
|
+
/**
|
|
184
|
+
* A function that says whether an absolute path is ignored by Git. It reads the `.gitignore`
|
|
185
|
+
* files of the project folder, of every folder above it up to the repository root (monorepo
|
|
186
|
+
* packages inherit the root's rules), and of nested folders.
|
|
187
|
+
*/
|
|
188
|
+
export declare function createGitignoreFilter(root: string): (absolutePath: string) => boolean;
|
|
189
|
+
interface ScanOptions {
|
|
190
|
+
/** Which built-in ignore list applies. @default "dictionary" */
|
|
191
|
+
kind?: "dictionary" | "source";
|
|
192
|
+
/** `exclude` from the config: extra globs, relative to `root`. */
|
|
193
|
+
exclude?: string[];
|
|
194
|
+
/** More ignore globs, relative to `root` (nested projects, for example). */
|
|
195
|
+
ignore?: string[];
|
|
196
|
+
/** Skip what `.gitignore` files ignore. @default true */
|
|
197
|
+
gitignore?: boolean;
|
|
198
|
+
}
|
|
199
|
+
/** Finds files under `root`, skipping build output, configured excludes and Git-ignored paths. */
|
|
200
|
+
export declare function scanFiles(root: string, patterns: string | string[], options?: ScanOptions): string[];
|
|
201
|
+
//#endregion
|
|
177
202
|
//#region src/utils/lockfile.d.ts
|
|
178
203
|
export declare const LOCK_FILE = "dialex.lock.json";
|
|
179
204
|
/**
|
|
@@ -214,6 +239,7 @@ interface StaticConfig {
|
|
|
214
239
|
defaultLocale: string;
|
|
215
240
|
locales: string[];
|
|
216
241
|
include: string | string[];
|
|
242
|
+
exclude: string[];
|
|
217
243
|
fallbacks: Record<string, string[]>;
|
|
218
244
|
prefixDefault: boolean;
|
|
219
245
|
lazy: boolean | "locale";
|
|
@@ -308,5 +334,5 @@ export declare function generateDictionaries(root: string, options?: GenerateOpt
|
|
|
308
334
|
notes: string[];
|
|
309
335
|
};
|
|
310
336
|
//#endregion
|
|
311
|
-
export type { AnalysisConfig, AnalysisIssue, AnalysisOptions, AnalysisResult, AnalyzedDictionary, DictionaryFile, GenerateOptions, IssueCode, IssueLevel, Leaf, LeafInfo, LeafKind, Lockfile, Project, ProjectDictionary, Reference, RenderedGenerate, SourceRange, StaticConfig, StaticConfigResult };
|
|
337
|
+
export type { AnalysisConfig, AnalysisIssue, AnalysisOptions, AnalysisResult, AnalyzedDictionary, DictionaryFile, GenerateOptions, IssueCode, IssueLevel, Leaf, LeafInfo, LeafKind, Lockfile, Project, ProjectDictionary, Reference, RenderedGenerate, ScanOptions, SourceRange, StaticConfig, StaticConfigResult };
|
|
312
338
|
//# sourceMappingURL=api.d.mts.map
|
package/dist/api.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"api.d.mts","names":[],"sources":["../src/utils/dictionary-edit.ts","../src/analysis.ts","../src/utils/lockfile.ts","../src/utils/static-config.ts","../src/utils/project.ts","../src/commands/generate.ts"],"mappings":";;;;;;;;;;;;;;;KAiBK;EAAS;GAAe;;qBAEhB;UAII;EACf;;EAEA;EACA,KAAK,QAAQ,kBAAkB;;EAE/B,YAAY;;EAEZ;;;;;;EAMA;;;UAIe;EACf;IAAS;IAAc;;EACvB;IAAO;IAAc;;;KAGX;UAEK;EACf;EACA,MAAM;;EAEN;;;;;;wBAgIc,oBAAoB,cAAc,eAAe;;wBAoB3C,mBAAmB,eAAe,QAAQ;;wBAKhD,qBAAqB,IAAI;wBAKnB,mBAAmB,IAAI,iBAAiB;wBAQ9C,YAAY,IAAI;;wBAahB,WAAW,IAAI,gBAAgB,iBAAiB;wBAoChD,QAAQ,IAAI,gBAAgB,gBAAgB;wBAI5C,UAAU,IAAI,gBAAgB,gBAAgB;KA+BlD;;;;;wBAMI,UACd,IAAI,gBACJ,gBACA,gBACA,gBACC;;;;;;wBAsBa,SACd,IAAI,gBACJ,oBACA,kBACA,gBACA,aAAa;;;;;wBAwCC,WACd,IAAI,gBACJ,gBACA,kBACC;;wBAMa,mBAAmB,IAAI,iBAAiB;;wBAKxC,cACd,IAAI,gBACJ,gBACA;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"api.d.mts","names":[],"sources":["../src/utils/dictionary-edit.ts","../src/analysis.ts","../src/utils/files.ts","../src/utils/lockfile.ts","../src/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oCrC;;EAEf;;EAEA;;EAEA;;EAEA;;;wBAIc,UACd,cACA,6BACA,UAAS;;;qBCzGE;;;;;;;;;;;;UAaI;EACf;EACA;EACA,SAAS,eAAe;;;wBAYV,WAAW;;wBAKX,SAAS,eAAe;;wBAiBxB,UAAU,cAAc,MAAM;;;;;wBA2B9B,QAAQ,MAAM,UAAU,gBAAgB,aAAa;;;;;;;;UC/DpD;EACf;EACA;EACA;EACA;EACA,WAAW;EACX;EACA;;UAGe;EACf,QAAQ;;EAER;;EAEA;;qBAMW,uBAAuB;;wBAmFpB,kBAAkB,cAAc,gBAA4B;;wBA+C5D,iBAAiB,cAAc,sBAAsB;;;UChKpD;;EAEf;EACA;EACA,IAAI;;UAGW;EACf;EACA,QAAQ;EACR,cAAc;;EAEd;;EAEA;;;;;;wBA4BoB,YAAY,cAAc,sBAAsB,QAAQ;;;;;wBASxD,kBAAkB,cAAc,sBAAsB,QAAQ;;qBAMvE,QAAK,oBAAsB;;;UCnDvB;EACf;EACA;EACA;EACA;EACA;;;;;EAKA;;UAGe;;EAEf;;EAEA;EACA;;EAEA;EACA;;EAEA;;EAEA;IAAc;IAAc;;;EAE5B;;;;;;;;;wBAcc,gBAAgB,cAAc,UAAS,kBAAuB;wBA8J9D,qBACd,cACA,UAAS;EAET;EACA;EACA;EACA;EACA"}
|
package/dist/api.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { A as
|
|
2
|
-
export { DEFAULT_SOURCE_GLOB, DEFAULT_STATIC_CONFIG, LOCK_FILE, TODO_PREFIX, analyzeProject, copyLeaf, dictionaryLocation, generateDictionaries, getLeafSource, getString, hasPath, hashSource, isStale, listLeaves, listLocales, loadDictionaryFile, loadProject, loadStaticProject, locationOf, parseDictionaryText, parseStaticConfig, readLock, readStaticConfig, relativeFile, renderDictionaryFile, renderGenerated, saveDictionaryFile, scanReferences, setString, toKey, writeLock };
|
|
1
|
+
import { A as dictionaryLocation, B as saveDictionaryFile, C as writeLock, D as scanFiles, E as createGitignoreFilter, F as listLocales, I as loadDictionaryFile, L as locationOf, M as getString, N as hasPath, O as TODO_PREFIX, P as listLeaves, R as parseDictionaryText, T as SOURCE_BUILTIN_IGNORE, V as setString, _ as hashSource, a as renderGenerated, c as parseStaticConfig, f as DEFAULT_SOURCE_GLOB, g as LOCK_FILE, h as scanReferences, i as generateDictionaries, j as getLeafSource, k as copyLeaf, l as readStaticConfig, m as relativeFile, n as loadStaticProject, p as analyzeProject, r as toKey, s as DEFAULT_STATIC_CONFIG, t as loadProject, v as isStale, w as BUILTIN_IGNORE, x as readLock, z as renderDictionaryFile } from "./project-DBVeKLa3.mjs";
|
|
2
|
+
export { BUILTIN_IGNORE, DEFAULT_SOURCE_GLOB, DEFAULT_STATIC_CONFIG, LOCK_FILE, SOURCE_BUILTIN_IGNORE, TODO_PREFIX, analyzeProject, copyLeaf, createGitignoreFilter, dictionaryLocation, generateDictionaries, getLeafSource, getString, hasPath, hashSource, isStale, listLeaves, listLocales, loadDictionaryFile, loadProject, loadStaticProject, locationOf, parseDictionaryText, parseStaticConfig, readLock, readStaticConfig, relativeFile, renderDictionaryFile, renderGenerated, saveDictionaryFile, scanFiles, scanReferences, setString, toKey, writeLock };
|
package/dist/index.mjs
CHANGED
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import {
|
|
2
|
+
import { B as saveDictionaryFile, C as writeLock, D as scanFiles, F as listLocales, I as loadDictionaryFile, M as getString, N as hasPath, O as TODO_PREFIX, P as listLeaves, S as record, V as setString, a as renderGenerated, b as lockPath, d as logger, g as LOCK_FILE, i as generateDictionaries, k as copyLeaf, o as runGenerate, p as analyzeProject, r as toKey, t as loadProject, u as resolveDialexConfig, v as isStale, x as readLock, y as lockFor } from "./project-DBVeKLa3.mjs";
|
|
3
3
|
import { Command } from "commander";
|
|
4
4
|
import fs from "node:fs";
|
|
5
5
|
import path from "node:path";
|
|
6
|
-
import { resolveDialexConfig } from "dialexjs/scanner";
|
|
7
|
-
import fg from "fast-glob";
|
|
8
6
|
import pc from "picocolors";
|
|
9
7
|
import { fileURLToPath } from "node:url";
|
|
10
8
|
import { loadFile, parseModule, writeFile } from "magicast";
|
|
@@ -12,15 +10,9 @@ import { argumentSignature, getArguments, isIcuStructured, parseMessage } from "
|
|
|
12
10
|
import * as p from "@clack/prompts";
|
|
13
11
|
import { addNuxtModule } from "magicast/helpers";
|
|
14
12
|
//#region package.json
|
|
15
|
-
var version = "0.
|
|
13
|
+
var version = "0.7.0";
|
|
16
14
|
//#endregion
|
|
17
15
|
//#region src/commands/check.ts
|
|
18
|
-
const DICTIONARY_IGNORE = [
|
|
19
|
-
"**/node_modules/**",
|
|
20
|
-
"**/dist/**",
|
|
21
|
-
"**/.next/**",
|
|
22
|
-
"**/dialex.locales/**"
|
|
23
|
-
];
|
|
24
16
|
function addIssue(diag, issue) {
|
|
25
17
|
const level = issue.level === "error" ? "error" : "warning";
|
|
26
18
|
(level === "error" ? diag.errors : diag.warnings).push(issue.message);
|
|
@@ -124,11 +116,7 @@ async function runCheck(options = {}) {
|
|
|
124
116
|
const include = config.include || "**/*.content.ts";
|
|
125
117
|
const configuredLocales = config.locales || [];
|
|
126
118
|
const defaultLocale = config.defaultLocale || "en";
|
|
127
|
-
const files =
|
|
128
|
-
cwd: root,
|
|
129
|
-
absolute: true,
|
|
130
|
-
ignore: DICTIONARY_IGNORE
|
|
131
|
-
});
|
|
119
|
+
const files = scanFiles(root, include, { exclude: config.exclude });
|
|
132
120
|
if (files.length === 0) {
|
|
133
121
|
if (!quiet) {
|
|
134
122
|
const patternStr = Array.isArray(include) ? include.join(", ") : include;
|