@translation-cms/sync 1.2.25 → 1.2.28
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 +62 -16
- package/package.json +3 -2
- package/dist/api.d.ts +0 -105
- package/dist/api.d.ts.map +0 -1
- package/dist/api.js +0 -208
- package/dist/api.js.map +0 -1
- package/dist/bin.d.ts +0 -25
- package/dist/bin.d.ts.map +0 -1
- package/dist/bin.js +0 -208
- package/dist/bin.js.map +0 -1
- package/dist/commands/init.d.ts +0 -10
- package/dist/commands/init.d.ts.map +0 -1
- package/dist/commands/init.js +0 -89
- package/dist/commands/init.js.map +0 -1
- package/dist/commands/pull.d.ts +0 -10
- package/dist/commands/pull.d.ts.map +0 -1
- package/dist/commands/pull.js +0 -35
- package/dist/commands/pull.js.map +0 -1
- package/dist/commands/status.d.ts +0 -15
- package/dist/commands/status.d.ts.map +0 -1
- package/dist/commands/status.js +0 -62
- package/dist/commands/status.js.map +0 -1
- package/dist/commands/sync.d.ts +0 -24
- package/dist/commands/sync.d.ts.map +0 -1
- package/dist/commands/sync.js +0 -131
- package/dist/commands/sync.js.map +0 -1
- package/dist/commands/watch.d.ts +0 -18
- package/dist/commands/watch.d.ts.map +0 -1
- package/dist/commands/watch.js +0 -71
- package/dist/commands/watch.js.map +0 -1
- package/dist/config/config-internals/args.d.ts +0 -11
- package/dist/config/config-internals/args.d.ts.map +0 -1
- package/dist/config/config-internals/args.js +0 -22
- package/dist/config/config-internals/args.js.map +0 -1
- package/dist/config/config-internals/env.d.ts +0 -10
- package/dist/config/config-internals/env.d.ts.map +0 -1
- package/dist/config/config-internals/env.js +0 -35
- package/dist/config/config-internals/env.js.map +0 -1
- package/dist/config/config-internals/file.d.ts +0 -11
- package/dist/config/config-internals/file.d.ts.map +0 -1
- package/dist/config/config-internals/file.js +0 -28
- package/dist/config/config-internals/file.js.map +0 -1
- package/dist/config/config-internals/resolve.d.ts +0 -21
- package/dist/config/config-internals/resolve.d.ts.map +0 -1
- package/dist/config/config-internals/resolve.js +0 -73
- package/dist/config/config-internals/resolve.js.map +0 -1
- package/dist/config/config-internals/root.d.ts +0 -9
- package/dist/config/config-internals/root.d.ts.map +0 -1
- package/dist/config/config-internals/root.js +0 -22
- package/dist/config/config-internals/root.js.map +0 -1
- package/dist/config/config-internals/types.d.ts +0 -91
- package/dist/config/config-internals/types.d.ts.map +0 -1
- package/dist/config/config-internals/types.js +0 -9
- package/dist/config/config-internals/types.js.map +0 -1
- package/dist/config/resolve-config.d.ts +0 -11
- package/dist/config/resolve-config.d.ts.map +0 -1
- package/dist/config/resolve-config.js +0 -10
- package/dist/config/resolve-config.js.map +0 -1
- package/dist/core/api-internals/helpers.d.ts +0 -9
- package/dist/core/api-internals/helpers.d.ts.map +0 -1
- package/dist/core/api-internals/helpers.js +0 -14
- package/dist/core/api-internals/helpers.js.map +0 -1
- package/dist/core/api-internals/pull.d.ts +0 -19
- package/dist/core/api-internals/pull.d.ts.map +0 -1
- package/dist/core/api-internals/pull.js +0 -269
- package/dist/core/api-internals/pull.js.map +0 -1
- package/dist/core/api-internals/route-config.d.ts +0 -13
- package/dist/core/api-internals/route-config.d.ts.map +0 -1
- package/dist/core/api-internals/route-config.js +0 -34
- package/dist/core/api-internals/route-config.js.map +0 -1
- package/dist/core/api-internals/sync.d.ts +0 -19
- package/dist/core/api-internals/sync.d.ts.map +0 -1
- package/dist/core/api-internals/sync.js +0 -139
- package/dist/core/api-internals/sync.js.map +0 -1
- package/dist/core/api-internals/types.d.ts +0 -33
- package/dist/core/api-internals/types.d.ts.map +0 -1
- package/dist/core/api-internals/types.js +0 -5
- package/dist/core/api-internals/types.js.map +0 -1
- package/dist/core/api.d.ts +0 -11
- package/dist/core/api.d.ts.map +0 -1
- package/dist/core/api.js +0 -11
- package/dist/core/api.js.map +0 -1
- package/dist/core/cache-internals/format.d.ts +0 -20
- package/dist/core/cache-internals/format.d.ts.map +0 -1
- package/dist/core/cache-internals/format.js +0 -33
- package/dist/core/cache-internals/format.js.map +0 -1
- package/dist/core/cache-internals/params.d.ts +0 -33
- package/dist/core/cache-internals/params.d.ts.map +0 -1
- package/dist/core/cache-internals/params.js +0 -155
- package/dist/core/cache-internals/params.js.map +0 -1
- package/dist/core/cache-internals/pull.d.ts +0 -17
- package/dist/core/cache-internals/pull.d.ts.map +0 -1
- package/dist/core/cache-internals/pull.js +0 -34
- package/dist/core/cache-internals/pull.js.map +0 -1
- package/dist/core/cache-internals/sync.d.ts +0 -29
- package/dist/core/cache-internals/sync.d.ts.map +0 -1
- package/dist/core/cache-internals/sync.js +0 -104
- package/dist/core/cache-internals/sync.js.map +0 -1
- package/dist/core/cache-internals/types.d.ts +0 -48
- package/dist/core/cache-internals/types.d.ts.map +0 -1
- package/dist/core/cache-internals/types.js +0 -2
- package/dist/core/cache-internals/types.js.map +0 -1
- package/dist/core/cache.d.ts +0 -13
- package/dist/core/cache.d.ts.map +0 -1
- package/dist/core/cache.js +0 -33
- package/dist/core/cache.js.map +0 -1
- package/dist/core/scanner-internals/ast.d.ts +0 -40
- package/dist/core/scanner-internals/ast.d.ts.map +0 -1
- package/dist/core/scanner-internals/ast.js +0 -100
- package/dist/core/scanner-internals/ast.js.map +0 -1
- package/dist/core/scanner-internals/file-walker.d.ts +0 -10
- package/dist/core/scanner-internals/file-walker.d.ts.map +0 -1
- package/dist/core/scanner-internals/file-walker.js +0 -23
- package/dist/core/scanner-internals/file-walker.js.map +0 -1
- package/dist/core/scanner-internals/import-resolver.d.ts +0 -21
- package/dist/core/scanner-internals/import-resolver.d.ts.map +0 -1
- package/dist/core/scanner-internals/import-resolver.js +0 -119
- package/dist/core/scanner-internals/import-resolver.js.map +0 -1
- package/dist/core/scanner-internals/key-extractor.d.ts +0 -20
- package/dist/core/scanner-internals/key-extractor.d.ts.map +0 -1
- package/dist/core/scanner-internals/key-extractor.js +0 -274
- package/dist/core/scanner-internals/key-extractor.js.map +0 -1
- package/dist/core/scanner-internals/nav-config-scanner.d.ts +0 -30
- package/dist/core/scanner-internals/nav-config-scanner.d.ts.map +0 -1
- package/dist/core/scanner-internals/nav-config-scanner.js +0 -170
- package/dist/core/scanner-internals/nav-config-scanner.js.map +0 -1
- package/dist/core/scanner-internals/route-detector.d.ts +0 -27
- package/dist/core/scanner-internals/route-detector.d.ts.map +0 -1
- package/dist/core/scanner-internals/route-detector.js +0 -78
- package/dist/core/scanner-internals/route-detector.js.map +0 -1
- package/dist/core/scanner-internals/types.d.ts +0 -60
- package/dist/core/scanner-internals/types.d.ts.map +0 -1
- package/dist/core/scanner-internals/types.js +0 -29
- package/dist/core/scanner-internals/types.js.map +0 -1
- package/dist/core/scanner.d.ts +0 -21
- package/dist/core/scanner.d.ts.map +0 -1
- package/dist/core/scanner.js +0 -162
- package/dist/core/scanner.js.map +0 -1
- package/dist/index.d.ts +0 -3
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js +0 -3
- package/dist/index.js.map +0 -1
- package/dist/next.d.ts +0 -33
- package/dist/next.d.ts.map +0 -1
- package/dist/next.js +0 -110
- package/dist/next.js.map +0 -1
- package/dist/preview/index.d.ts +0 -39
- package/dist/preview/index.d.ts.map +0 -1
- package/dist/preview/index.js +0 -123
- package/dist/preview/index.js.map +0 -1
- package/dist/preview/internals/highlight.d.ts +0 -31
- package/dist/preview/internals/highlight.d.ts.map +0 -1
- package/dist/preview/internals/highlight.js +0 -184
- package/dist/preview/internals/highlight.js.map +0 -1
- package/dist/preview/internals/interactions.d.ts +0 -15
- package/dist/preview/internals/interactions.d.ts.map +0 -1
- package/dist/preview/internals/interactions.js +0 -38
- package/dist/preview/internals/interactions.js.map +0 -1
- package/dist/preview/internals/interactive.d.ts +0 -14
- package/dist/preview/internals/interactive.d.ts.map +0 -1
- package/dist/preview/internals/interactive.js +0 -122
- package/dist/preview/internals/interactive.js.map +0 -1
- package/dist/preview/internals/locales.d.ts +0 -9
- package/dist/preview/internals/locales.d.ts.map +0 -1
- package/dist/preview/internals/locales.js +0 -24
- package/dist/preview/internals/locales.js.map +0 -1
- package/dist/preview/internals/state.d.ts +0 -37
- package/dist/preview/internals/state.d.ts.map +0 -1
- package/dist/preview/internals/state.js +0 -74
- package/dist/preview/internals/state.js.map +0 -1
- package/dist/preview/internals/styles.d.ts +0 -8
- package/dist/preview/internals/styles.d.ts.map +0 -1
- package/dist/preview/internals/styles.js +0 -28
- package/dist/preview/internals/styles.js.map +0 -1
- package/dist/preview/internals/types.d.ts +0 -74
- package/dist/preview/internals/types.d.ts.map +0 -1
- package/dist/preview/internals/types.js +0 -5
- package/dist/preview/internals/types.js.map +0 -1
- package/dist/preview/internals/ui-indicators.d.ts +0 -15
- package/dist/preview/internals/ui-indicators.d.ts.map +0 -1
- package/dist/preview/internals/ui-indicators.js +0 -92
- package/dist/preview/internals/ui-indicators.js.map +0 -1
- package/dist/scaffold/index.d.ts +0 -3
- package/dist/scaffold/index.d.ts.map +0 -1
- package/dist/scaffold/index.js +0 -3
- package/dist/scaffold/index.js.map +0 -1
- package/dist/scaffold/intenrals/scaffold.d.ts +0 -24
- package/dist/scaffold/intenrals/scaffold.d.ts.map +0 -1
- package/dist/scaffold/intenrals/scaffold.js +0 -53
- package/dist/scaffold/intenrals/scaffold.js.map +0 -1
- package/dist/scaffold/intenrals/templates.d.ts +0 -10
- package/dist/scaffold/intenrals/templates.d.ts.map +0 -1
- package/dist/scaffold/intenrals/templates.js +0 -344
- package/dist/scaffold/intenrals/templates.js.map +0 -1
- package/dist/scaffold/intenrals/types.d.ts +0 -14
- package/dist/scaffold/intenrals/types.d.ts.map +0 -1
- package/dist/scaffold/intenrals/types.js +0 -5
- package/dist/scaffold/intenrals/types.js.map +0 -1
|
@@ -1,100 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* AST parsing and traversal utilities.
|
|
3
|
-
*/
|
|
4
|
-
import { parse } from '@babel/parser';
|
|
5
|
-
import path from 'path';
|
|
6
|
-
/**
|
|
7
|
-
* Walk an AST node depth-first, calling visit() for every node encountered.
|
|
8
|
-
*
|
|
9
|
-
* Handles three cases:
|
|
10
|
-
* - Arrays → recurse into each element
|
|
11
|
-
* - AST nodes → call visit(), then recurse into all object-valued properties
|
|
12
|
-
* - Primitives → stop (nothing to traverse)
|
|
13
|
-
*/
|
|
14
|
-
export function walk(node, visit) {
|
|
15
|
-
if (!node || typeof node !== 'object')
|
|
16
|
-
return;
|
|
17
|
-
if (Array.isArray(node)) {
|
|
18
|
-
for (const item of node)
|
|
19
|
-
walk(item, visit);
|
|
20
|
-
return;
|
|
21
|
-
}
|
|
22
|
-
const n = node;
|
|
23
|
-
// Visit before recursing so parents are seen before their children
|
|
24
|
-
if (typeof n.type === 'string')
|
|
25
|
-
visit(n);
|
|
26
|
-
for (const value of Object.values(n)) {
|
|
27
|
-
if (value && typeof value === 'object')
|
|
28
|
-
walk(value, visit);
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
/**
|
|
32
|
-
* Parse source code into a Babel AST with the appropriate plugins for the
|
|
33
|
-
* file extension.
|
|
34
|
-
*
|
|
35
|
-
* - `.ts` → typescript
|
|
36
|
-
* - `.tsx`, `.jsx`, `.js` → typescript (if .tsx) + jsx
|
|
37
|
-
*
|
|
38
|
-
* `errorRecovery: true` lets the parser continue past syntax errors so a
|
|
39
|
-
* single broken file doesn't abort the entire scan.
|
|
40
|
-
*/
|
|
41
|
-
export function parseSource(filePath, source) {
|
|
42
|
-
const ext = path.extname(filePath);
|
|
43
|
-
const plugins = [];
|
|
44
|
-
if (ext === '.ts' || ext === '.tsx')
|
|
45
|
-
plugins.push('typescript');
|
|
46
|
-
if (ext !== '.ts')
|
|
47
|
-
plugins.push('jsx'); // .tsx, .jsx, .js
|
|
48
|
-
return parse(source, {
|
|
49
|
-
sourceType: 'module',
|
|
50
|
-
plugins,
|
|
51
|
-
errorRecovery: true,
|
|
52
|
-
});
|
|
53
|
-
}
|
|
54
|
-
/**
|
|
55
|
-
* Extract the static string value from a `StringLiteral` or a `TemplateLiteral`
|
|
56
|
-
* that contains no expressions (i.e. `` `plain string` ``).
|
|
57
|
-
* Returns null for dynamic expressions or any other node type.
|
|
58
|
-
*/
|
|
59
|
-
export function stringValue(node) {
|
|
60
|
-
if (!node || typeof node !== 'object')
|
|
61
|
-
return null;
|
|
62
|
-
const n = node;
|
|
63
|
-
if (n.type === 'StringLiteral' && typeof n.value === 'string')
|
|
64
|
-
return n.value;
|
|
65
|
-
if (n.type === 'TemplateLiteral') {
|
|
66
|
-
const exprs = n.expressions;
|
|
67
|
-
const quasis = n.quasis;
|
|
68
|
-
// Only static template literals (no ${…} expressions) can be resolved
|
|
69
|
-
if (exprs.length === 0 && quasis.length === 1) {
|
|
70
|
-
const quasi = quasis[0];
|
|
71
|
-
if (quasi?.value) {
|
|
72
|
-
return quasi.value.cooked ?? null;
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
return null;
|
|
77
|
-
}
|
|
78
|
-
/**
|
|
79
|
-
* Extract namespace string(s) from the first argument of a
|
|
80
|
-
* `useTranslation()` / `getTranslation()` call.
|
|
81
|
-
*
|
|
82
|
-
* Handles:
|
|
83
|
-
* - Single string: `useTranslation('sidebar')` → `['sidebar']`
|
|
84
|
-
* - Array of strings: `useTranslation(['common', 'nav'])` → `['common', 'nav']`
|
|
85
|
-
*/
|
|
86
|
-
export function namespacesFromArg(node) {
|
|
87
|
-
const single = stringValue(node);
|
|
88
|
-
if (single)
|
|
89
|
-
return [single];
|
|
90
|
-
if (!node || typeof node !== 'object')
|
|
91
|
-
return [];
|
|
92
|
-
const n = node;
|
|
93
|
-
if (n.type === 'ArrayExpression') {
|
|
94
|
-
return n.elements
|
|
95
|
-
.map(stringValue)
|
|
96
|
-
.filter((s) => s !== null);
|
|
97
|
-
}
|
|
98
|
-
return [];
|
|
99
|
-
}
|
|
100
|
-
//# sourceMappingURL=ast.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ast.js","sourceRoot":"","sources":["../../../src/core/scanner-internals/ast.ts"],"names":[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CAAC,CAAC,KAAK,IAAI,CAAC,CAAC;IAChD,CAAC;IACD,OAAO,EAAE,CAAC;AACd,CAAC"}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* File system traversal utilities.
|
|
3
|
-
*/
|
|
4
|
-
/**
|
|
5
|
-
* Recursively walk a directory, yielding paths of source files.
|
|
6
|
-
* Skips directories listed in `excludedDirs` and files whose extension
|
|
7
|
-
* is not in `sourceExtensions`.
|
|
8
|
-
*/
|
|
9
|
-
export declare function walkFiles(dir: string, excludedDirs: Set<string>, sourceExtensions: Set<string>): Generator<string>;
|
|
10
|
-
//# sourceMappingURL=file-walker.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"file-walker.d.ts","sourceRoot":"","sources":["../../../src/core/scanner-internals/file-walker.ts"],"names":[],"mappings":"AAAA;;GAEG;AAKH;;;;GAIG;AACH,wBAAiB,SAAS,CACtB,GAAG,EAAE,MAAM,EACX,YAAY,EAAE,GAAG,CAAC,MAAM,CAAC,EACzB,gBAAgB,EAAE,GAAG,CAAC,MAAM,CAAC,GAC9B,SAAS,CAAC,MAAM,CAAC,CAanB"}
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* File system traversal utilities.
|
|
3
|
-
*/
|
|
4
|
-
import fs from 'fs';
|
|
5
|
-
import path from 'path';
|
|
6
|
-
/**
|
|
7
|
-
* Recursively walk a directory, yielding paths of source files.
|
|
8
|
-
* Skips directories listed in `excludedDirs` and files whose extension
|
|
9
|
-
* is not in `sourceExtensions`.
|
|
10
|
-
*/
|
|
11
|
-
export function* walkFiles(dir, excludedDirs, sourceExtensions) {
|
|
12
|
-
for (const entry of fs.readdirSync(dir, { withFileTypes: true })) {
|
|
13
|
-
const fullPath = path.join(dir, entry.name);
|
|
14
|
-
if (entry.isDirectory()) {
|
|
15
|
-
if (!excludedDirs.has(entry.name))
|
|
16
|
-
yield* walkFiles(fullPath, excludedDirs, sourceExtensions);
|
|
17
|
-
continue;
|
|
18
|
-
}
|
|
19
|
-
if (entry.isFile() && sourceExtensions.has(path.extname(entry.name)))
|
|
20
|
-
yield fullPath;
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
//# sourceMappingURL=file-walker.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"file-walker.js","sourceRoot":"","sources":["../../../src/core/scanner-internals/file-walker.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,MAAM,IAAI,CAAC;AACpB,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB;;;;GAIG;AACH,MAAM,SAAS,CAAC,CAAC,SAAS,CACtB,GAAW,EACX,YAAyB,EACzB,gBAA6B;IAE7B,KAAK,MAAM,KAAK,IAAI,EAAE,CAAC,WAAW,CAAC,GAAG,EAAE,EAAE,aAAa,EAAE,IAAI,EAAE,CAAC,EAAE,CAAC;QAC/D,MAAM,QAAQ,GAAG,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,CAAC,CAAC;QAE5C,IAAI,KAAK,CAAC,WAAW,EAAE,EAAE,CAAC;YACtB,IAAI,CAAC,YAAY,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC;gBAC7B,KAAK,CAAC,CAAC,SAAS,CAAC,QAAQ,EAAE,YAAY,EAAE,gBAAgB,CAAC,CAAC;YAC/D,SAAS;QACb,CAAC;QAED,IAAI,KAAK,CAAC,MAAM,EAAE,IAAI,gBAAgB,CAAC,GAAG,CAAC,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;YAChE,MAAM,QAAQ,CAAC;IACvB,CAAC;AACL,CAAC"}
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Import path resolution and traversal.
|
|
3
|
-
* Handles aliased imports (@/path), relative imports (../path), and layout chains.
|
|
4
|
-
*/
|
|
5
|
-
/**
|
|
6
|
-
* Extract all local imports (relative and aliased) from a source file via AST.
|
|
7
|
-
*
|
|
8
|
-
* Handles `import`, `export { ... } from`, and `export * from` declarations.
|
|
9
|
-
* Silently skips files that cannot be read or parsed (errorRecovery in parser
|
|
10
|
-
* handles most syntax issues, but catastrophic parse failures are caught here).
|
|
11
|
-
*/
|
|
12
|
-
export declare function extractLocalImports(filePath: string, sourceExtensions: Set<string>, root?: string, pathMappings?: Record<string, string[]>): string[];
|
|
13
|
-
/**
|
|
14
|
-
* For a given page file, find all wrapping `layout.*` files walking upward
|
|
15
|
-
* through the directory tree until we reach the app root.
|
|
16
|
-
*
|
|
17
|
-
* The returned array is ordered from nearest to furthest layout, matching the
|
|
18
|
-
* order in which layouts wrap the page in Next.js App Router.
|
|
19
|
-
*/
|
|
20
|
-
export declare function getLayoutChain(root: string, pageFile: string, sourceExtensions: Set<string>): string[];
|
|
21
|
-
//# sourceMappingURL=import-resolver.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"import-resolver.d.ts","sourceRoot":"","sources":["../../../src/core/scanner-internals/import-resolver.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAkFH;;;;;;GAMG;AACH,wBAAgB,mBAAmB,CAC/B,QAAQ,EAAE,MAAM,EAChB,gBAAgB,EAAE,GAAG,CAAC,MAAM,CAAC,EAC7B,IAAI,CAAC,EAAE,MAAM,EACb,YAAY,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,GACxC,MAAM,EAAE,CAoCV;AAED;;;;;;GAMG;AACH,wBAAgB,cAAc,CAC1B,IAAI,EAAE,MAAM,EACZ,QAAQ,EAAE,MAAM,EAChB,gBAAgB,EAAE,GAAG,CAAC,MAAM,CAAC,GAC9B,MAAM,EAAE,CAaV"}
|
|
@@ -1,119 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Import path resolution and traversal.
|
|
3
|
-
* Handles aliased imports (@/path), relative imports (../path), and layout chains.
|
|
4
|
-
*/
|
|
5
|
-
import fs from 'fs';
|
|
6
|
-
import path from 'path';
|
|
7
|
-
import { parseSource, walk } from './ast.js';
|
|
8
|
-
/**
|
|
9
|
-
* Given a base path (without extension), resolve it to an existing file by:
|
|
10
|
-
* 1. Returning it as-is if it already carries a known source extension.
|
|
11
|
-
* 2. Probing `basePath + ext` for each known extension.
|
|
12
|
-
* 3. Probing `basePath/index + ext` (barrel / directory index files).
|
|
13
|
-
*
|
|
14
|
-
* Returns null when no matching file is found on disk.
|
|
15
|
-
*/
|
|
16
|
-
function resolveFilePath(basePath, sourceExtensions) {
|
|
17
|
-
// Already has a known extension — check directly
|
|
18
|
-
if (sourceExtensions.has(path.extname(basePath)))
|
|
19
|
-
return fs.existsSync(basePath) ? basePath : null;
|
|
20
|
-
// Try appending each source extension (e.g. basePath.tsx)
|
|
21
|
-
for (const ext of sourceExtensions) {
|
|
22
|
-
const candidate = basePath + ext;
|
|
23
|
-
if (fs.existsSync(candidate))
|
|
24
|
-
return candidate;
|
|
25
|
-
}
|
|
26
|
-
// Try directory index files (e.g. basePath/index.tsx)
|
|
27
|
-
for (const ext of sourceExtensions) {
|
|
28
|
-
const candidate = path.join(basePath, 'index' + ext);
|
|
29
|
-
if (fs.existsSync(candidate))
|
|
30
|
-
return candidate;
|
|
31
|
-
}
|
|
32
|
-
return null;
|
|
33
|
-
}
|
|
34
|
-
/**
|
|
35
|
-
* Resolve an aliased import path (e.g. `@/components/button`) to an absolute
|
|
36
|
-
* file path using the tsconfig path mappings provided.
|
|
37
|
-
*
|
|
38
|
-
* Each alias key may contain `*` as a wildcard (mirrors tsconfig `paths` syntax).
|
|
39
|
-
* Returns null when no mapping matches or no file is found on disk.
|
|
40
|
-
*/
|
|
41
|
-
function resolveAliasedImport(importPath, root, sourceExtensions, pathMappings) {
|
|
42
|
-
if (!pathMappings)
|
|
43
|
-
return null;
|
|
44
|
-
for (const [alias, targets] of Object.entries(pathMappings)) {
|
|
45
|
-
const match = importPath.match(new RegExp(`^${alias.replace(/\*/g, '(.*)')}$`));
|
|
46
|
-
if (!match)
|
|
47
|
-
continue;
|
|
48
|
-
const captured = match[1] ?? '';
|
|
49
|
-
for (const target of targets) {
|
|
50
|
-
const fullPath = path.join(root, target.replace(/\*/g, captured));
|
|
51
|
-
const resolved = resolveFilePath(fullPath, sourceExtensions);
|
|
52
|
-
if (resolved)
|
|
53
|
-
return resolved;
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
return null;
|
|
57
|
-
}
|
|
58
|
-
/**
|
|
59
|
-
* Resolve a relative import path (e.g. `../utils/helpers`) to an absolute
|
|
60
|
-
* file path. Delegates to `resolveFilePath` for extension probing.
|
|
61
|
-
*/
|
|
62
|
-
function resolveLocalImport(fromDir, importPath, sourceExtensions) {
|
|
63
|
-
return resolveFilePath(path.join(fromDir, importPath), sourceExtensions);
|
|
64
|
-
}
|
|
65
|
-
/**
|
|
66
|
-
* Extract all local imports (relative and aliased) from a source file via AST.
|
|
67
|
-
*
|
|
68
|
-
* Handles `import`, `export { ... } from`, and `export * from` declarations.
|
|
69
|
-
* Silently skips files that cannot be read or parsed (errorRecovery in parser
|
|
70
|
-
* handles most syntax issues, but catastrophic parse failures are caught here).
|
|
71
|
-
*/
|
|
72
|
-
export function extractLocalImports(filePath, sourceExtensions, root, pathMappings) {
|
|
73
|
-
let ast;
|
|
74
|
-
try {
|
|
75
|
-
ast = parseSource(filePath, fs.readFileSync(filePath, 'utf-8'));
|
|
76
|
-
}
|
|
77
|
-
catch {
|
|
78
|
-
return [];
|
|
79
|
-
}
|
|
80
|
-
const fromDir = path.dirname(filePath);
|
|
81
|
-
const results = [];
|
|
82
|
-
walk(ast, node => {
|
|
83
|
-
if (node.type !== 'ImportDeclaration' &&
|
|
84
|
-
node.type !== 'ExportNamedDeclaration' &&
|
|
85
|
-
node.type !== 'ExportAllDeclaration')
|
|
86
|
-
return;
|
|
87
|
-
const src = node.source;
|
|
88
|
-
if (!src || typeof src.value !== 'string')
|
|
89
|
-
return;
|
|
90
|
-
const importPath = src.value;
|
|
91
|
-
const resolved = importPath.startsWith('.')
|
|
92
|
-
? resolveLocalImport(fromDir, importPath, sourceExtensions)
|
|
93
|
-
: resolveAliasedImport(importPath, root ?? '', sourceExtensions, pathMappings);
|
|
94
|
-
if (resolved && !results.includes(resolved))
|
|
95
|
-
results.push(resolved);
|
|
96
|
-
});
|
|
97
|
-
return results;
|
|
98
|
-
}
|
|
99
|
-
/**
|
|
100
|
-
* For a given page file, find all wrapping `layout.*` files walking upward
|
|
101
|
-
* through the directory tree until we reach the app root.
|
|
102
|
-
*
|
|
103
|
-
* The returned array is ordered from nearest to furthest layout, matching the
|
|
104
|
-
* order in which layouts wrap the page in Next.js App Router.
|
|
105
|
-
*/
|
|
106
|
-
export function getLayoutChain(root, pageFile, sourceExtensions) {
|
|
107
|
-
const layouts = [];
|
|
108
|
-
let dir = path.dirname(pageFile);
|
|
109
|
-
while (dir.startsWith(root)) {
|
|
110
|
-
for (const ext of sourceExtensions) {
|
|
111
|
-
const candidate = path.join(dir, `layout${ext}`);
|
|
112
|
-
if (fs.existsSync(candidate))
|
|
113
|
-
layouts.push(candidate);
|
|
114
|
-
}
|
|
115
|
-
dir = path.dirname(dir);
|
|
116
|
-
}
|
|
117
|
-
return layouts;
|
|
118
|
-
}
|
|
119
|
-
//# sourceMappingURL=import-resolver.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"import-resolver.js","sourceRoot":"","sources":["../../../src/core/scanner-internals/import-resolver.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,MAAM,IAAI,CAAC;AACpB,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,WAAW,EAAE,IAAI,EAAE,MAAM,UAAU,CAAC;AAG7C;;;;;;;GAOG;AACH,SAAS,eAAe,CACpB,QAAgB,EAChB,gBAA6B;IAE7B,iDAAiD;IACjD,IAAI,gBAAgB,CAAC,GAAG,CAAC,IAAI,CAAC,OA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YACvC,CAAC,CAAC,kBAAkB,CAAC,OAAO,EAAE,UAAU,EAAE,gBAAgB,CAAC;YAC3D,CAAC,CAAC,oBAAoB,CAChB,UAAU,EACV,IAAI,IAAI,EAAE,EACV,gBAAgB,EAChB,YAAY,CACf,CAAC;QAER,IAAI,QAAQ,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAC;YAAE,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;IACxE,CAAC,CAAC,CAAC;IAEH,OAAO,OAAO,CAAC;AACnB,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,cAAc,CAC1B,IAAY,EACZ,QAAgB,EAChB,gBAA6B;IAE7B,MAAM,OAAO,GAAa,EAAE,CAAC;IAC7B,IAAI,GAAG,GAAG,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;IAEjC,OAAO,GAAG,CAAC,UAAU,CAAC,IAAI,CAAC,EAAE,CAAC;QAC1B,KAAK,MAAM,GAAG,IAAI,gBAAgB,EAAE,CAAC;YACjC,MAAM,SAAS,GAAG,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,SAAS,GAAG,EAAE,CAAC,CAAC;YACjD,IAAI,EAAE,CAAC,UAAU,CAAC,SAAS,CAAC;gBAAE,OAAO,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;QAC1D,CAAC;QACD,GAAG,GAAG,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;IAC5B,CAAC;IAED,OAAO,OAAO,CAAC;AACnB,CAAC"}
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Extraction of translation keys from source files.
|
|
3
|
-
*
|
|
4
|
-
* Five passes over the AST per file:
|
|
5
|
-
* 1. Collect `t`-binding declarations (useTranslation / getTranslation / getTranslations)
|
|
6
|
-
* 2. Extract keys from `t('namespace:key')` call expressions
|
|
7
|
-
* 3. Extract keys from `<Trans i18nKey="namespace:key">` JSX elements
|
|
8
|
-
* 4. Extract keys from `I18nKey`-typed string literals in config/data files
|
|
9
|
-
* 5. Extract keys from object properties whose name ends with `Key`
|
|
10
|
-
*/
|
|
11
|
-
import type { NamespaceMap } from './types.js';
|
|
12
|
-
/**
|
|
13
|
-
* Extract all translation keys from `filePath` and merge them into `result`.
|
|
14
|
-
*
|
|
15
|
-
* @param filePath Absolute path to the source file to scan.
|
|
16
|
-
* @param routes Preview routes associated with this file ([] for overlays).
|
|
17
|
-
* @param result Accumulator map updated in place.
|
|
18
|
-
*/
|
|
19
|
-
export declare function extractKeysFromFile(filePath: string, routes: string[], result: NamespaceMap): void;
|
|
20
|
-
//# sourceMappingURL=key-extractor.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"key-extractor.d.ts","sourceRoot":"","sources":["../../../src/core/scanner-internals/key-extractor.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAKH,OAAO,KAAK,EAAW,YAAY,EAAE,MAAM,YAAY,CAAC;AA6FxD;;;;;;GAMG;AACH,wBAAgB,mBAAmB,CAC/B,QAAQ,EAAE,MAAM,EAChB,MAAM,EAAE,MAAM,EAAE,EAChB,MAAM,EAAE,YAAY,GACrB,IAAI,CAiKN"}
|
|
@@ -1,274 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Extraction of translation keys from source files.
|
|
3
|
-
*
|
|
4
|
-
* Five passes over the AST per file:
|
|
5
|
-
* 1. Collect `t`-binding declarations (useTranslation / getTranslation / getTranslations)
|
|
6
|
-
* 2. Extract keys from `t('namespace:key')` call expressions
|
|
7
|
-
* 3. Extract keys from `<Trans i18nKey="namespace:key">` JSX elements
|
|
8
|
-
* 4. Extract keys from `I18nKey`-typed string literals in config/data files
|
|
9
|
-
* 5. Extract keys from object properties whose name ends with `Key`
|
|
10
|
-
*/
|
|
11
|
-
import fs from 'fs';
|
|
12
|
-
import path from 'path';
|
|
13
|
-
import { parseSource, walk, stringValue, namespacesFromArg } from './ast.js';
|
|
14
|
-
// ---------------------------------------------------------------------------
|
|
15
|
-
// Small helpers
|
|
16
|
-
// ---------------------------------------------------------------------------
|
|
17
|
-
/**
|
|
18
|
-
* Add a key to the namespace map with its associated routes.
|
|
19
|
-
* Skips keys that look like URL paths or are purely numeric (not translation keys).
|
|
20
|
-
* Merges routes with any previously registered set for the same key.
|
|
21
|
-
*/
|
|
22
|
-
function addKey(map, namespace, key, routes) {
|
|
23
|
-
if (key.startsWith('/') || key.startsWith('.') || /^\d+$/.test(key))
|
|
24
|
-
return;
|
|
25
|
-
if (!map[namespace])
|
|
26
|
-
map[namespace] = new Map();
|
|
27
|
-
const existing = map[namespace].get(key) ?? [];
|
|
28
|
-
if (routes.length > 0) {
|
|
29
|
-
// Union the new routes with whatever was already stored
|
|
30
|
-
const merged = new Set(existing);
|
|
31
|
-
for (const route of routes)
|
|
32
|
-
merged.add(route);
|
|
33
|
-
map[namespace].set(key, Array.from(merged));
|
|
34
|
-
}
|
|
35
|
-
else if (existing.length === 0) {
|
|
36
|
-
// Key seen with no routes yet — register it so it appears in the map
|
|
37
|
-
map[namespace].set(key, []);
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
/**
|
|
41
|
-
* Split a `"namespace:key"` string into its two parts.
|
|
42
|
-
* Returns null when the colon is absent or at position 0 (invalid).
|
|
43
|
-
*/
|
|
44
|
-
function splitI18nKey(keyStr) {
|
|
45
|
-
const colonIdx = keyStr.indexOf(':');
|
|
46
|
-
if (colonIdx <= 0)
|
|
47
|
-
return null;
|
|
48
|
-
return [keyStr.slice(0, colonIdx), keyStr.slice(colonIdx + 1)];
|
|
49
|
-
}
|
|
50
|
-
/**
|
|
51
|
-
* Extract the string value of a JSX attribute value node.
|
|
52
|
-
* Handles plain string literals (`i18nKey="ns:key"`) and expression containers
|
|
53
|
-
* (`i18nKey={"ns:key"}`). Returns null for dynamic expressions.
|
|
54
|
-
*/
|
|
55
|
-
function jsxAttrStringValue(value) {
|
|
56
|
-
if (!value)
|
|
57
|
-
return null;
|
|
58
|
-
if (value.type === 'StringLiteral')
|
|
59
|
-
return value.value;
|
|
60
|
-
if (value.type === 'JSXExpressionContainer')
|
|
61
|
-
return stringValue(value.expression);
|
|
62
|
-
return null;
|
|
63
|
-
}
|
|
64
|
-
/**
|
|
65
|
-
* Bind translation function aliases from a destructuring pattern.
|
|
66
|
-
*
|
|
67
|
-
* Handles both direct binding and renaming:
|
|
68
|
-
* `const { t } = useTranslation()` → binds `t`
|
|
69
|
-
* `const { t: myT } = useTranslation()` → binds `myT`
|
|
70
|
-
* `const { tDynamic } = getTranslation()` → binds `tDynamic`
|
|
71
|
-
*
|
|
72
|
-
* Only the standard accessor names (`t`, `tDynamic`) are recognised as
|
|
73
|
-
* source keys; any other destructured property is ignored.
|
|
74
|
-
*/
|
|
75
|
-
function bindFromObjectPattern(id, namespaces, tBindings) {
|
|
76
|
-
for (const prop of id.properties) {
|
|
77
|
-
if (prop.type !== 'ObjectProperty')
|
|
78
|
-
continue;
|
|
79
|
-
const keyNode = prop.key;
|
|
80
|
-
const origName = keyNode.type === 'Identifier' ? keyNode.name : null;
|
|
81
|
-
if (!origName || (origName !== 't' && origName !== 'tDynamic'))
|
|
82
|
-
continue;
|
|
83
|
-
// Use the aliased name if present: `{ t: myT }` → bind `myT`
|
|
84
|
-
const valNode = prop.value;
|
|
85
|
-
const boundName = valNode.type === 'Identifier' ? valNode.name : origName;
|
|
86
|
-
tBindings.set(boundName, namespaces);
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
// ---------------------------------------------------------------------------
|
|
90
|
-
// Main export
|
|
91
|
-
// ---------------------------------------------------------------------------
|
|
92
|
-
/**
|
|
93
|
-
* Extract all translation keys from `filePath` and merge them into `result`.
|
|
94
|
-
*
|
|
95
|
-
* @param filePath Absolute path to the source file to scan.
|
|
96
|
-
* @param routes Preview routes associated with this file ([] for overlays).
|
|
97
|
-
* @param result Accumulator map updated in place.
|
|
98
|
-
*/
|
|
99
|
-
export function extractKeysFromFile(filePath, routes, result) {
|
|
100
|
-
let ast;
|
|
101
|
-
try {
|
|
102
|
-
// Single try/catch covers both the file read and the parse step
|
|
103
|
-
ast = parseSource(filePath, fs.readFileSync(filePath, 'utf-8'));
|
|
104
|
-
}
|
|
105
|
-
catch {
|
|
106
|
-
return;
|
|
107
|
-
}
|
|
108
|
-
// --- Step 1: collect namespace bindings ---
|
|
109
|
-
// Maps each local variable name (e.g. `t`) to the namespace(s) it is bound to
|
|
110
|
-
// so that call-expression extraction in Step 2 can resolve the correct namespace.
|
|
111
|
-
const tBindings = new Map();
|
|
112
|
-
walk(ast, node => {
|
|
113
|
-
if (node.type !== 'VariableDeclaration')
|
|
114
|
-
return;
|
|
115
|
-
for (const decl of node.declarations) {
|
|
116
|
-
const init = decl.init;
|
|
117
|
-
if (!init)
|
|
118
|
-
continue;
|
|
119
|
-
// Unwrap `await` so `const t = await client.getTranslations(...)` works
|
|
120
|
-
const call = init.type === 'AwaitExpression'
|
|
121
|
-
? init.argument
|
|
122
|
-
: init;
|
|
123
|
-
if (!call || call.type !== 'CallExpression')
|
|
124
|
-
continue;
|
|
125
|
-
const callee = call.callee;
|
|
126
|
-
const args = call.arguments;
|
|
127
|
-
// useTranslation('ns') / getTranslation('ns')
|
|
128
|
-
const isHook = callee.type === 'Identifier' &&
|
|
129
|
-
(callee.name === 'useTranslation' ||
|
|
130
|
-
callee.name === 'getTranslation');
|
|
131
|
-
// client.getTranslations(locale, 'ns') / client.getT(locale, 'ns')
|
|
132
|
-
const isCmsStyle = callee.type === 'MemberExpression' &&
|
|
133
|
-
callee.property.type === 'Identifier' &&
|
|
134
|
-
/^getTranslations(?:WithFallback)?$|^getT$/.test(callee.property.name);
|
|
135
|
-
if (!isHook && !isCmsStyle)
|
|
136
|
-
continue;
|
|
137
|
-
// Namespace arg position differs: hook uses args[0], CMS style uses args[1]
|
|
138
|
-
const namespaces = isHook
|
|
139
|
-
? namespacesFromArg(args[0])
|
|
140
|
-
: namespacesFromArg(args[1]);
|
|
141
|
-
if (!namespaces.length)
|
|
142
|
-
continue;
|
|
143
|
-
const id = decl.id;
|
|
144
|
-
if (id.type === 'Identifier') {
|
|
145
|
-
// const t = useTranslation(...)
|
|
146
|
-
tBindings.set(id.name, namespaces);
|
|
147
|
-
}
|
|
148
|
-
else if (id.type === 'ObjectPattern') {
|
|
149
|
-
// const { t } = useTranslation(...) or const { t: myT } = ...
|
|
150
|
-
bindFromObjectPattern(id, namespaces, tBindings);
|
|
151
|
-
}
|
|
152
|
-
}
|
|
153
|
-
});
|
|
154
|
-
// --- Step 2: extract keys from t('…') call expressions ---
|
|
155
|
-
// Only variables explicitly bound in Step 1 are processed; unknown callee
|
|
156
|
-
// names are silently skipped to avoid false positives.
|
|
157
|
-
walk(ast, node => {
|
|
158
|
-
if (node.type !== 'CallExpression')
|
|
159
|
-
return;
|
|
160
|
-
const callee = node.callee;
|
|
161
|
-
if (callee.type !== 'Identifier')
|
|
162
|
-
return;
|
|
163
|
-
const varName = callee.name;
|
|
164
|
-
if (!tBindings.has(varName))
|
|
165
|
-
return;
|
|
166
|
-
const keyStr = stringValue(node.arguments[0]);
|
|
167
|
-
if (!keyStr)
|
|
168
|
-
return;
|
|
169
|
-
const parts = splitI18nKey(keyStr);
|
|
170
|
-
if (parts) {
|
|
171
|
-
// t('namespace:key') — namespace is explicit in the key string
|
|
172
|
-
addKey(result, parts[0], parts[1], routes);
|
|
173
|
-
}
|
|
174
|
-
else {
|
|
175
|
-
// Bare key: t('key') — namespace comes from the binding; emit a warning
|
|
176
|
-
console.warn(`[WARN] Bare key in ${path.relative(process.cwd(), filePath)}: ` +
|
|
177
|
-
`${varName}('${keyStr}') — use ${varName}('namespace:${keyStr}') instead`);
|
|
178
|
-
for (const ns of tBindings.get(varName))
|
|
179
|
-
addKey(result, ns, keyStr, routes);
|
|
180
|
-
}
|
|
181
|
-
});
|
|
182
|
-
// --- Step 3: <Trans i18nKey="namespace:key"> ---
|
|
183
|
-
// The Trans component is the JSX equivalent of t(); only fully-qualified
|
|
184
|
-
// "namespace:key" values are accepted (bare keys cannot be resolved here).
|
|
185
|
-
walk(ast, node => {
|
|
186
|
-
if (node.type !== 'JSXOpeningElement')
|
|
187
|
-
return;
|
|
188
|
-
const name = node.name;
|
|
189
|
-
if (name.type !== 'JSXIdentifier' || name.name !== 'Trans')
|
|
190
|
-
return;
|
|
191
|
-
for (const attr of node.attributes) {
|
|
192
|
-
if (attr.type !== 'JSXAttribute')
|
|
193
|
-
continue;
|
|
194
|
-
const attrName = attr.name;
|
|
195
|
-
if (attrName.type !== 'JSXIdentifier' ||
|
|
196
|
-
attrName.name !== 'i18nKey')
|
|
197
|
-
continue;
|
|
198
|
-
const keyStr = jsxAttrStringValue(attr.value);
|
|
199
|
-
if (!keyStr)
|
|
200
|
-
continue;
|
|
201
|
-
const parts = splitI18nKey(keyStr);
|
|
202
|
-
if (parts)
|
|
203
|
-
addKey(result, parts[0], parts[1], routes);
|
|
204
|
-
}
|
|
205
|
-
});
|
|
206
|
-
// --- Step 4: I18nKey string literals in config/data files ---
|
|
207
|
-
// When a file imports the `I18nKey` type it likely contains typed config
|
|
208
|
-
// objects (e.g. nav items with `label: 'sidebar:settings'`). Scan every
|
|
209
|
-
// string literal that matches "namespace:key" to catch these.
|
|
210
|
-
if (hasI18nKeyImport(ast)) {
|
|
211
|
-
walk(ast, node => {
|
|
212
|
-
if (node.type !== 'StringLiteral')
|
|
213
|
-
return;
|
|
214
|
-
const parts = splitI18nKey(node.value);
|
|
215
|
-
if (!parts)
|
|
216
|
-
return;
|
|
217
|
-
// Namespace and key must look like identifiers/dot-paths (no spaces, slashes…)
|
|
218
|
-
if (!/^\w[\w-]*$/.test(parts[0]) || !/^\w[\w.-]*$/.test(parts[1]))
|
|
219
|
-
return;
|
|
220
|
-
addKey(result, parts[0], parts[1], routes);
|
|
221
|
-
});
|
|
222
|
-
}
|
|
223
|
-
// --- Step 5: *Key object property string literals ---
|
|
224
|
-
// Catches translation keys passed as prop/config values where the property
|
|
225
|
-
// name ends with "Key" (e.g. `titleKey: 'subscription:expired'`).
|
|
226
|
-
// The naming convention is the only signal needed — no import sentinel required.
|
|
227
|
-
walk(ast, node => {
|
|
228
|
-
if (node.type !== 'ObjectProperty' && node.type !== 'Property')
|
|
229
|
-
return;
|
|
230
|
-
const keyNode = node.key;
|
|
231
|
-
const propName = keyNode.type === 'Identifier'
|
|
232
|
-
? keyNode.name
|
|
233
|
-
: keyNode.type === 'StringLiteral'
|
|
234
|
-
? keyNode.value
|
|
235
|
-
: null;
|
|
236
|
-
if (!propName?.endsWith('Key'))
|
|
237
|
-
return;
|
|
238
|
-
const val = stringValue(node.value);
|
|
239
|
-
if (!val)
|
|
240
|
-
return;
|
|
241
|
-
const parts = splitI18nKey(val);
|
|
242
|
-
if (!parts)
|
|
243
|
-
return;
|
|
244
|
-
if (!/^\w[\w-]*$/.test(parts[0]) || !/^\w[\w.-]*$/.test(parts[1]))
|
|
245
|
-
return;
|
|
246
|
-
addKey(result, parts[0], parts[1], routes);
|
|
247
|
-
});
|
|
248
|
-
}
|
|
249
|
-
// ---------------------------------------------------------------------------
|
|
250
|
-
// Internal helpers
|
|
251
|
-
// ---------------------------------------------------------------------------
|
|
252
|
-
/**
|
|
253
|
-
* Returns true if the AST contains an import of the `I18nKey` type.
|
|
254
|
-
* Used as a cheap sentinel to decide whether Step 4 should run for a file.
|
|
255
|
-
*
|
|
256
|
-
* The `found` flag pattern is necessary because `walk()` does not support
|
|
257
|
-
* early termination — we skip further work as soon as the import is spotted.
|
|
258
|
-
*/
|
|
259
|
-
function hasI18nKeyImport(ast) {
|
|
260
|
-
let found = false;
|
|
261
|
-
walk(ast, node => {
|
|
262
|
-
if (found || node.type !== 'ImportDeclaration')
|
|
263
|
-
return;
|
|
264
|
-
for (const spec of node.specifiers) {
|
|
265
|
-
if (spec.type === 'ImportSpecifier' &&
|
|
266
|
-
spec.imported?.name === 'I18nKey') {
|
|
267
|
-
found = true;
|
|
268
|
-
return;
|
|
269
|
-
}
|
|
270
|
-
}
|
|
271
|
-
});
|
|
272
|
-
return found;
|
|
273
|
-
}
|
|
274
|
-
//# sourceMappingURL=key-extractor.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"key-extractor.js","sourceRoot":"","sources":["../../../src/core/scanner-internals/key-extractor.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EAAE,MAAM,IAAI,CAAC;AACpB,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,WAAW,EAAE,IAAI,EAAE,WAAW,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAC;AAG7E,8EAA8E;AAC9E,gBAAgB;AAChB,8EAA8E;AAE9E;;;;GAIG;AACH,SAAS,MAAM,CACX,GAAiB,EACjB,SAAiB,EACjB,GAAW,EACX,MAAgB;IAEhB,IAAI,GAAG,CAAC,UAAU,CAAC,GAAG,CAAC,IAAI,GAAG,CAAC,UAAU,CAAC,GAAG,CAAC,IAAI,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC;QAAE,OAAO;IAC5E,IAAI,CAAC,GAAG,CAAC,SAAS,CAAC;QAAE,GAAG,CAAC,SAAS,CAAC,GAAG,IAAI,GAAG,EAAE,CAAC;IAChD,MAAM,QAAQ,GAAG,GAAG,CAAC,SAAS,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,IAAI,EAAE,CAAC;IAE/C,IAAI,MAAM,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACpB,wDAAwD;QACxD,MAAM,MAAM,GAAG,IAAI,GAAG,CAAC,QAAQ,CAAC,CAAC;QACjC,KAAK,MAAM,KAAK,IAAI,MAAM;YAAE,MAAM,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;QAC9C,GAAG,CAAC,SAAS,CAAC,CAAC,GAAG,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC;IAChD,CAAC;SAAM,IAAI,QAAQ,CAAC,MAAM,KAA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AAK,mBAAmB;YAAE,OAAO;QACvD,KAAK,MAAM,IAAI,IAAI,IAAI,CAAC,UAAuB,EAAE,CAAC;YAC9C,IACI,IAAI,CAAC,IAAI,KAAK,iBAAiB;gBAC9B,IAAI,CAAC,QAAoB,EAAE,IAAI,KAAK,SAAS,EAChD,CAAC;gBACC,KAAK,GAAG,IAAI,CAAC;gBACb,OAAO;YACX,CAAC;QACL,CAAC;IACL,CAAC,CAAC,CAAC;IACH,OAAO,KAAK,CAAC;AACjB,CAAC"}
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Navigation config scanner.
|
|
3
|
-
* Extracts href values from navigation configuration files and returns them
|
|
4
|
-
* as preview routes that can be merged into the translation key map.
|
|
5
|
-
*
|
|
6
|
-
* Looks for patterns like:
|
|
7
|
-
* href: `/projects/${id}/settings`
|
|
8
|
-
* href: '/admin/users'
|
|
9
|
-
* href: `/o/${orgId}/projects`
|
|
10
|
-
*/
|
|
11
|
-
/**
|
|
12
|
-
* Finds navigation config files in the project.
|
|
13
|
-
* Matches files with patterns like:
|
|
14
|
-
* - **/navigation.config.ts(x)
|
|
15
|
-
* - **/navigation*.ts(x) in config/ directories
|
|
16
|
-
* - **/routes.config.ts(x)
|
|
17
|
-
* - **/app-routes.ts(x)
|
|
18
|
-
*/
|
|
19
|
-
export declare function findNavConfigFiles(root: string, sourceExtensions: Set<string>): string[];
|
|
20
|
-
/**
|
|
21
|
-
* Extract href values from a navigation config file.
|
|
22
|
-
* Returns an array of href strings/routes found in the config.
|
|
23
|
-
*/
|
|
24
|
-
export declare function extractNavRoutes(filePath: string): string[];
|
|
25
|
-
/**
|
|
26
|
-
* Scan navigation config files and return preview routes for all hrefs found.
|
|
27
|
-
* Returns a map of route patterns to their string arrays.
|
|
28
|
-
*/
|
|
29
|
-
export declare function scanNavConfig(root: string, sourceExtensions: Set<string>): Record<string, string[]>;
|
|
30
|
-
//# sourceMappingURL=nav-config-scanner.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"nav-config-scanner.d.ts","sourceRoot":"","sources":["../../../src/core/scanner-internals/nav-config-scanner.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAOH;;;;;;;GAOG;AACH,wBAAgB,kBAAkB,CAC9B,IAAI,EAAE,MAAM,EACZ,gBAAgB,EAAE,GAAG,CAAC,MAAM,CAAC,GAC9B,MAAM,EAAE,CA4CV;AAED;;;GAGG;AACH,wBAAgB,gBAAgB,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,EAAE,CA6C3D;AA4CD;;;GAGG;AACH,wBAAgB,aAAa,CACzB,IAAI,EAAE,MAAM,EACZ,gBAAgB,EAAE,GAAG,CAAC,MAAM,CAAC,GAC9B,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,CA4B1B"}
|