@translation-cms/sync 1.2.9 → 1.2.12
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 +304 -151
- package/dist/api.d.ts +79 -0
- package/dist/api.d.ts.map +1 -0
- package/dist/api.js +151 -0
- package/dist/api.js.map +1 -0
- package/dist/bin.js +51 -17
- package/dist/bin.js.map +1 -1
- package/dist/commands/init.d.ts +8 -0
- package/dist/commands/init.d.ts.map +1 -1
- package/dist/commands/init.js +18 -0
- package/dist/commands/init.js.map +1 -1
- package/dist/commands/pull.d.ts +7 -0
- package/dist/commands/pull.d.ts.map +1 -1
- package/dist/commands/pull.js +15 -2
- package/dist/commands/pull.js.map +1 -1
- package/dist/commands/status.d.ts +12 -0
- package/dist/commands/status.d.ts.map +1 -1
- package/dist/commands/status.js +16 -0
- package/dist/commands/status.js.map +1 -1
- package/dist/commands/sync.d.ts +10 -0
- package/dist/commands/sync.d.ts.map +1 -1
- package/dist/commands/sync.js +23 -4
- package/dist/commands/sync.js.map +1 -1
- package/dist/commands/watch.d.ts +14 -0
- package/dist/commands/watch.d.ts.map +1 -1
- package/dist/commands/watch.js +23 -3
- package/dist/commands/watch.js.map +1 -1
- package/dist/config/config-internals/args.d.ts +11 -0
- package/dist/config/config-internals/args.d.ts.map +1 -0
- package/dist/config/config-internals/args.js +22 -0
- package/dist/config/config-internals/args.js.map +1 -0
- package/dist/config/config-internals/env.d.ts +10 -0
- package/dist/config/config-internals/env.d.ts.map +1 -0
- package/dist/config/config-internals/env.js +35 -0
- package/dist/config/config-internals/env.js.map +1 -0
- package/dist/config/config-internals/file.d.ts +11 -0
- package/dist/config/config-internals/file.d.ts.map +1 -0
- package/dist/config/config-internals/file.js +28 -0
- package/dist/config/config-internals/file.js.map +1 -0
- package/dist/config/config-internals/resolve.d.ts +21 -0
- package/dist/config/config-internals/resolve.d.ts.map +1 -0
- package/dist/config/config-internals/resolve.js +73 -0
- package/dist/config/config-internals/resolve.js.map +1 -0
- package/dist/config/config-internals/root.d.ts +9 -0
- package/dist/config/config-internals/root.d.ts.map +1 -0
- package/dist/config/config-internals/root.js +22 -0
- package/dist/config/config-internals/root.js.map +1 -0
- package/dist/config/config-internals/types.d.ts +83 -0
- package/dist/config/config-internals/types.d.ts.map +1 -0
- package/dist/config/config-internals/types.js +9 -0
- package/dist/config/config-internals/types.js.map +1 -0
- package/dist/config/resolve-config.d.ts +9 -90
- package/dist/config/resolve-config.d.ts.map +1 -1
- package/dist/config/resolve-config.js +7 -123
- package/dist/config/resolve-config.js.map +1 -1
- package/dist/core/api-internals/pull.d.ts +9 -1
- package/dist/core/api-internals/pull.d.ts.map +1 -1
- package/dist/core/api-internals/pull.js +41 -28
- package/dist/core/api-internals/pull.js.map +1 -1
- package/dist/core/api-internals/sync.d.ts +9 -2
- package/dist/core/api-internals/sync.d.ts.map +1 -1
- package/dist/core/api-internals/sync.js +18 -2
- package/dist/core/api-internals/sync.js.map +1 -1
- package/dist/core/cache-internals/format.d.ts +16 -0
- package/dist/core/cache-internals/format.d.ts.map +1 -1
- package/dist/core/cache-internals/format.js +17 -0
- package/dist/core/cache-internals/format.js.map +1 -1
- package/dist/core/cache-internals/params.d.ts.map +1 -1
- package/dist/core/cache-internals/params.js +24 -24
- package/dist/core/cache-internals/params.js.map +1 -1
- package/dist/core/cache-internals/pull.d.ts +12 -0
- package/dist/core/cache-internals/pull.d.ts.map +1 -1
- package/dist/core/cache-internals/pull.js +13 -0
- package/dist/core/cache-internals/pull.js.map +1 -1
- package/dist/core/cache-internals/sync.d.ts +23 -0
- package/dist/core/cache-internals/sync.d.ts.map +1 -1
- package/dist/core/cache-internals/sync.js +33 -0
- package/dist/core/cache-internals/sync.js.map +1 -1
- package/dist/core/cache-internals/types.d.ts +20 -0
- package/dist/core/cache-internals/types.d.ts.map +1 -1
- package/dist/core/scanner-internals/ast.d.ts +23 -5
- package/dist/core/scanner-internals/ast.d.ts.map +1 -1
- package/dist/core/scanner-internals/ast.js +25 -5
- package/dist/core/scanner-internals/ast.js.map +1 -1
- package/dist/core/scanner-internals/file-walker.d.ts +3 -2
- package/dist/core/scanner-internals/file-walker.d.ts.map +1 -1
- package/dist/core/scanner-internals/file-walker.js +10 -12
- package/dist/core/scanner-internals/file-walker.js.map +1 -1
- package/dist/core/scanner-internals/import-resolver.d.ts +9 -1
- package/dist/core/scanner-internals/import-resolver.d.ts.map +1 -1
- package/dist/core/scanner-internals/import-resolver.js +58 -63
- package/dist/core/scanner-internals/import-resolver.js.map +1 -1
- package/dist/core/scanner-internals/key-extractor.d.ts +12 -8
- package/dist/core/scanner-internals/key-extractor.d.ts.map +1 -1
- package/dist/core/scanner-internals/key-extractor.js +125 -97
- package/dist/core/scanner-internals/key-extractor.js.map +1 -1
- package/dist/core/scanner-internals/route-detector.d.ts +16 -8
- package/dist/core/scanner-internals/route-detector.d.ts.map +1 -1
- package/dist/core/scanner-internals/route-detector.js +37 -33
- package/dist/core/scanner-internals/route-detector.js.map +1 -1
- package/dist/core/scanner.d.ts.map +1 -1
- package/dist/core/scanner.js +25 -8
- package/dist/core/scanner.js.map +1 -1
- package/dist/next.d.ts +28 -0
- package/dist/next.d.ts.map +1 -0
- package/dist/next.js +65 -0
- package/dist/next.js.map +1 -0
- package/dist/preview/internals/highlight.d.ts +16 -7
- package/dist/preview/internals/highlight.d.ts.map +1 -1
- package/dist/preview/internals/highlight.js +71 -60
- package/dist/preview/internals/highlight.js.map +1 -1
- package/dist/scaffold/intenrals/scaffold.d.ts +17 -0
- package/dist/scaffold/intenrals/scaffold.d.ts.map +1 -1
- package/dist/scaffold/intenrals/scaffold.js +19 -0
- package/dist/scaffold/intenrals/scaffold.js.map +1 -1
- package/package.json +16 -3
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared types and constants for config resolution.
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* Project-level configuration for sync-translations.
|
|
6
|
+
* Can be placed in .translationsrc.json or translations.config.json
|
|
7
|
+
* at the project root. Values are merged with env vars — CLI args take
|
|
8
|
+
* highest priority, followed by env vars, then this file.
|
|
9
|
+
*/
|
|
10
|
+
export interface TranslationsConfig {
|
|
11
|
+
/**
|
|
12
|
+
* CMS URL — overrides NEXT_PUBLIC_CMS_URL env var.
|
|
13
|
+
* @example "https://cms.example.com"
|
|
14
|
+
*/
|
|
15
|
+
cmsUrl?: string;
|
|
16
|
+
/**
|
|
17
|
+
* Project ID — overrides NEXT_PUBLIC_CMS_PROJECT_ID env var.
|
|
18
|
+
*/
|
|
19
|
+
projectId?: string;
|
|
20
|
+
/**
|
|
21
|
+
* API key — overrides NEXT_PUBLIC_CMS_ANON_KEY env var.
|
|
22
|
+
*/
|
|
23
|
+
apiKey?: string;
|
|
24
|
+
/**
|
|
25
|
+
* Additional directories to exclude when scanning for translation keys.
|
|
26
|
+
* Merged with built-in defaults:
|
|
27
|
+
* node_modules, .next, dist, .git, out, .turbo, scripts, packages, .storybook, coverage
|
|
28
|
+
* @example ["e2e", "fixtures", "mocks"]
|
|
29
|
+
*/
|
|
30
|
+
excludedDirs?: string[];
|
|
31
|
+
/**
|
|
32
|
+
* File extensions to scan. When set, *replaces* the default list.
|
|
33
|
+
* @default [".ts", ".tsx", ".js", ".jsx"]
|
|
34
|
+
* @example [".ts", ".tsx", ".js", ".jsx", ".vue"]
|
|
35
|
+
*/
|
|
36
|
+
sourceExtensions?: string[];
|
|
37
|
+
/**
|
|
38
|
+
* Default output directory for the pull command.
|
|
39
|
+
* @default "./public/dictionaries"
|
|
40
|
+
* @example "./src/dictionaries"
|
|
41
|
+
*/
|
|
42
|
+
outputDir?: string;
|
|
43
|
+
/**
|
|
44
|
+
* TTL in milliseconds for the pull cache (.last-pulled).
|
|
45
|
+
* @default 300000 (5 minutes)
|
|
46
|
+
* @example 600000
|
|
47
|
+
*/
|
|
48
|
+
pullTtlMs?: number;
|
|
49
|
+
/**
|
|
50
|
+
* Mock params for dynamic route segments.
|
|
51
|
+
* Keys are route patterns (e.g. "/[locale]/blog/[slug]"), values are the
|
|
52
|
+
* params to fill in when generating preview URLs for that route.
|
|
53
|
+
*
|
|
54
|
+
* @example
|
|
55
|
+
* {
|
|
56
|
+
* "/[locale]/blog/[slug]": { "slug": "first-post" },
|
|
57
|
+
* "/[locale]/products/[slug]": { "slug": "product-a" }
|
|
58
|
+
* }
|
|
59
|
+
*/
|
|
60
|
+
routeParams?: Record<string, Record<string, string>>;
|
|
61
|
+
/**
|
|
62
|
+
* Output path for the generated mock-params TypeScript file.
|
|
63
|
+
* When set, sync writes a `cmsRouteParams` constant here so you can
|
|
64
|
+
* import it in context files, generateStaticParams, tests, etc.
|
|
65
|
+
*
|
|
66
|
+
* Path is relative to the project root.
|
|
67
|
+
*
|
|
68
|
+
* @example "./src/lib/cms-mock-params.ts"
|
|
69
|
+
*/
|
|
70
|
+
mockDataPath?: string;
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Resolved runtime config passed to all CLI operations.
|
|
74
|
+
* All fields are required — resolveConfig() exits early if any are missing.
|
|
75
|
+
*/
|
|
76
|
+
export interface Config {
|
|
77
|
+
projectId: string;
|
|
78
|
+
apiKey: string;
|
|
79
|
+
cmsUrl: string;
|
|
80
|
+
}
|
|
81
|
+
/** Config filenames searched in order — first match wins. */
|
|
82
|
+
export declare const CONFIG_FILENAMES: readonly [".translationsrc.json", "translations.config.json"];
|
|
83
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/config/config-internals/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH;;;;;GAKG;AACH,MAAM,WAAW,kBAAkB;IAC/B;;;OAGG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;IAEhB;;OAEG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IAEnB;;OAEG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;IAEhB;;;;;OAKG;IACH,YAAY,CAAC,EAAE,MAAM,EAAE,CAAC;IAExB;;;;OAIG;IACH,gBAAgB,CAAC,EAAE,MAAM,EAAE,CAAC;IAE5B;;;;OAIG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IAEnB;;;;OAIG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IAEnB;;;;;;;;;;OAUG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;IAErD;;;;;;;;OAQG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC;CACzB;AAED;;;GAGG;AACH,MAAM,WAAW,MAAM;IACnB,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;CAClB;AAED,6DAA6D;AAC7D,eAAO,MAAM,gBAAgB,+DAGnB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/config/config-internals/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AAyFH,6DAA6D;AAC7D,MAAM,CAAC,MAAM,gBAAgB,GAAG;IAC5B,sBAAsB;IACtB,0BAA0B;CACpB,CAAC"}
|
|
@@ -1,92 +1,11 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
3
|
-
*
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
export
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
*/
|
|
12
|
-
cmsUrl?: string;
|
|
13
|
-
/**
|
|
14
|
-
* Project ID — overrides NEXT_PUBLIC_CMS_PROJECT_ID env var.
|
|
15
|
-
*/
|
|
16
|
-
projectId?: string;
|
|
17
|
-
/**
|
|
18
|
-
* API key — overrides NEXT_PUBLIC_CMS_ANON_KEY env var.
|
|
19
|
-
*/
|
|
20
|
-
apiKey?: string;
|
|
21
|
-
/**
|
|
22
|
-
* Additional directories to exclude when scanning for translation keys.
|
|
23
|
-
* Merged with built-in defaults:
|
|
24
|
-
* node_modules, .next, dist, .git, out, .turbo, scripts, packages, .storybook, coverage
|
|
25
|
-
* @example ["e2e", "fixtures", "mocks"]
|
|
26
|
-
*/
|
|
27
|
-
excludedDirs?: string[];
|
|
28
|
-
/**
|
|
29
|
-
* File extensions to scan. When set, *replaces* the default list.
|
|
30
|
-
* @default [".ts", ".tsx", ".js", ".jsx"]
|
|
31
|
-
* @example [".ts", ".tsx", ".js", ".jsx", ".vue"]
|
|
32
|
-
*/
|
|
33
|
-
sourceExtensions?: string[];
|
|
34
|
-
/**
|
|
35
|
-
* Default output directory for the pull command.
|
|
36
|
-
* @default "./public/dictionaries"
|
|
37
|
-
* @example "./src/dictionaries"
|
|
38
|
-
*/
|
|
39
|
-
outputDir?: string;
|
|
40
|
-
/**
|
|
41
|
-
* TTL in milliseconds for the pull cache (.last-pulled).
|
|
42
|
-
* @default 300000 (5 minutes)
|
|
43
|
-
* @example 600000
|
|
44
|
-
*/
|
|
45
|
-
pullTtlMs?: number;
|
|
46
|
-
/**
|
|
47
|
-
* Mock params for dynamic route segments.
|
|
48
|
-
* Keys are route patterns (e.g. "/[locale]/blog/[slug]"), values are the
|
|
49
|
-
* params to fill in when generating preview URLs for that route.
|
|
50
|
-
*
|
|
51
|
-
* @example
|
|
52
|
-
* {
|
|
53
|
-
* "/[locale]/blog/[slug]": { "slug": "first-post" },
|
|
54
|
-
* "/[locale]/products/[slug]": { "slug": "product-a" }
|
|
55
|
-
* }
|
|
56
|
-
*/
|
|
57
|
-
routeParams?: Record<string, Record<string, string>>;
|
|
58
|
-
/**
|
|
59
|
-
* Output path for the generated mock-params TypeScript file.
|
|
60
|
-
* When set, sync writes a `cmsRouteParams` constant here so you can
|
|
61
|
-
* import it in context files, generateStaticParams, tests, etc.
|
|
62
|
-
*
|
|
63
|
-
* Path is relative to the project root.
|
|
64
|
-
*
|
|
65
|
-
* @example "./src/lib/cms-mock-params.ts"
|
|
66
|
-
*/
|
|
67
|
-
mockDataPath?: string;
|
|
68
|
-
}
|
|
69
|
-
/**
|
|
70
|
-
* Load project-level config from .translationsrc.json or translations.config.json.
|
|
71
|
-
* Returns an empty object when no config file is found — never throws.
|
|
72
|
-
*/
|
|
73
|
-
export declare function loadConfigFile(root: string): TranslationsConfig;
|
|
74
|
-
/**
|
|
75
|
-
* Resolved runtime config passed to all CLI operations.
|
|
76
|
-
*/
|
|
77
|
-
export interface Config {
|
|
78
|
-
projectId: string;
|
|
79
|
-
apiKey: string;
|
|
80
|
-
cmsUrl: string;
|
|
81
|
-
}
|
|
82
|
-
export declare function loadEnvLocal(root: string): Record<string, string>;
|
|
83
|
-
export declare function parseArgs(): Partial<Config>;
|
|
84
|
-
export declare function findProjectRoot(): string;
|
|
85
|
-
export declare function resolveConfig(cwd?: string, fileConfig?: TranslationsConfig): Config;
|
|
86
|
-
/**
|
|
87
|
-
* Resolve route params for scanner.
|
|
88
|
-
* Merges auto-generated params from cache with user's manual config.
|
|
89
|
-
* User config takes precedence.
|
|
90
|
-
*/
|
|
91
|
-
export declare function resolveRouteParams(cwd?: string, fileConfig?: TranslationsConfig): Record<string, Record<string, string>>;
|
|
2
|
+
* Public API for config resolution.
|
|
3
|
+
* Implementation lives in config-internals/ — import from here, not from internals directly.
|
|
4
|
+
*/
|
|
5
|
+
export type { TranslationsConfig, Config } from './config-internals/types.js';
|
|
6
|
+
export { loadConfigFile } from './config-internals/file.js';
|
|
7
|
+
export { loadEnvLocal } from './config-internals/env.js';
|
|
8
|
+
export { parseArgs } from './config-internals/args.js';
|
|
9
|
+
export { findProjectRoot } from './config-internals/root.js';
|
|
10
|
+
export { resolveConfig, resolveRouteParams } from './config-internals/resolve.js';
|
|
92
11
|
//# sourceMappingURL=resolve-config.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resolve-config.d.ts","sourceRoot":"","sources":["../../src/config/resolve-config.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"resolve-config.d.ts","sourceRoot":"","sources":["../../src/config/resolve-config.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,YAAY,EAAE,kBAAkB,EAAE,MAAM,EAAE,MAAM,6BAA6B,CAAC;AAC9E,OAAO,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AAC5D,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AACzD,OAAO,EAAE,SAAS,EAAE,MAAM,4BAA4B,CAAC;AACvD,OAAO,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAC7D,OAAO,EAAE,aAAa,EAAE,kBAAkB,EAAE,MAAM,+BAA+B,CAAC"}
|
|
@@ -1,126 +1,10 @@
|
|
|
1
|
-
import fs from 'fs';
|
|
2
|
-
import path from 'path';
|
|
3
|
-
import { loadRouteParamsCache } from '../core/cache.js';
|
|
4
|
-
const CONFIG_FILENAMES = ['.translationsrc.json', 'translations.config.json'];
|
|
5
1
|
/**
|
|
6
|
-
*
|
|
7
|
-
*
|
|
2
|
+
* Public API for config resolution.
|
|
3
|
+
* Implementation lives in config-internals/ — import from here, not from internals directly.
|
|
8
4
|
*/
|
|
9
|
-
export
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
try {
|
|
15
|
-
const parsed = JSON.parse(fs.readFileSync(filePath, 'utf-8'));
|
|
16
|
-
console.log(`[config] Loaded config from ${filename}`);
|
|
17
|
-
return parsed;
|
|
18
|
-
}
|
|
19
|
-
catch (err) {
|
|
20
|
-
console.warn(`[config] Failed to parse ${filename}: ${err instanceof Error ? err.message : String(err)}`);
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
return {};
|
|
24
|
-
}
|
|
25
|
-
export function loadEnvLocal(root) {
|
|
26
|
-
const envPath = path.join(root, '.env.local');
|
|
27
|
-
if (!fs.existsSync(envPath))
|
|
28
|
-
return {};
|
|
29
|
-
const vars = {};
|
|
30
|
-
const lines = fs.readFileSync(envPath, 'utf-8').split('\n');
|
|
31
|
-
for (const line of lines) {
|
|
32
|
-
const trimmed = line.trim();
|
|
33
|
-
if (!trimmed || trimmed.startsWith('#'))
|
|
34
|
-
continue;
|
|
35
|
-
const eq = trimmed.indexOf('=');
|
|
36
|
-
if (eq === -1)
|
|
37
|
-
continue;
|
|
38
|
-
const key = trimmed.slice(0, eq).trim();
|
|
39
|
-
const value = trimmed
|
|
40
|
-
.slice(eq + 1)
|
|
41
|
-
.trim()
|
|
42
|
-
.replace(/^["']|["']$/g, '');
|
|
43
|
-
vars[key] = value;
|
|
44
|
-
}
|
|
45
|
-
return vars;
|
|
46
|
-
}
|
|
47
|
-
export function parseArgs() {
|
|
48
|
-
const args = process.argv.slice(2);
|
|
49
|
-
const result = {};
|
|
50
|
-
for (let i = 0; i < args.length; i++) {
|
|
51
|
-
if (args[i] === '--project-id' && args[i + 1])
|
|
52
|
-
result.projectId = args[++i];
|
|
53
|
-
if (args[i] === '--api-key' && args[i + 1])
|
|
54
|
-
result.apiKey = args[++i];
|
|
55
|
-
if (args[i] === '--cms-url' && args[i + 1])
|
|
56
|
-
result.cmsUrl = args[++i];
|
|
57
|
-
}
|
|
58
|
-
return result;
|
|
59
|
-
}
|
|
60
|
-
export function findProjectRoot() {
|
|
61
|
-
let current = process.cwd();
|
|
62
|
-
while (current !== '/') {
|
|
63
|
-
if (fs.existsSync(path.join(current, 'package.json')) ||
|
|
64
|
-
fs.existsSync(path.join(current, 'src')) ||
|
|
65
|
-
fs.existsSync(path.join(current, '.git'))) {
|
|
66
|
-
return current;
|
|
67
|
-
}
|
|
68
|
-
current = path.dirname(current);
|
|
69
|
-
}
|
|
70
|
-
return process.cwd();
|
|
71
|
-
}
|
|
72
|
-
export function resolveConfig(cwd, fileConfig) {
|
|
73
|
-
const root = cwd ?? findProjectRoot();
|
|
74
|
-
// Load root .env.local first, then apps/web/.env.local as fallback
|
|
75
|
-
// for NEXT_PUBLIC_* vars already configured there.
|
|
76
|
-
const rootEnv = loadEnvLocal(root);
|
|
77
|
-
const webEnv = loadEnvLocal(path.join(root, 'apps', 'web'));
|
|
78
|
-
const cliArgs = parseArgs();
|
|
79
|
-
const projectId = cliArgs.projectId ??
|
|
80
|
-
rootEnv['NEXT_PUBLIC_CMS_PROJECT_ID'] ??
|
|
81
|
-
webEnv['NEXT_PUBLIC_CMS_PROJECT_ID'] ??
|
|
82
|
-
fileConfig?.projectId ??
|
|
83
|
-
'';
|
|
84
|
-
const apiKey = cliArgs.apiKey ??
|
|
85
|
-
rootEnv['CMS_SYNC_API_KEY'] ??
|
|
86
|
-
rootEnv['NEXT_PUBLIC_CMS_ANON_KEY'] ??
|
|
87
|
-
webEnv['CMS_SYNC_API_KEY'] ??
|
|
88
|
-
webEnv['NEXT_PUBLIC_CMS_ANON_KEY'] ??
|
|
89
|
-
fileConfig?.apiKey ??
|
|
90
|
-
'';
|
|
91
|
-
const cmsUrl = cliArgs.cmsUrl ??
|
|
92
|
-
rootEnv['NEXT_PUBLIC_CMS_URL'] ??
|
|
93
|
-
webEnv['NEXT_PUBLIC_CMS_URL'] ??
|
|
94
|
-
fileConfig?.cmsUrl ??
|
|
95
|
-
'';
|
|
96
|
-
const missing = [];
|
|
97
|
-
if (!projectId)
|
|
98
|
-
missing.push('--project-id / NEXT_PUBLIC_CMS_PROJECT_ID');
|
|
99
|
-
if (!apiKey)
|
|
100
|
-
missing.push('--api-key / NEXT_PUBLIC_CMS_ANON_KEY');
|
|
101
|
-
if (!cmsUrl)
|
|
102
|
-
missing.push('--cms-url / NEXT_PUBLIC_CMS_URL');
|
|
103
|
-
if (missing.length > 0) {
|
|
104
|
-
console.error('Missing required config:');
|
|
105
|
-
for (const m of missing)
|
|
106
|
-
console.error(` ${m}`);
|
|
107
|
-
process.exit(1);
|
|
108
|
-
}
|
|
109
|
-
return { projectId, apiKey, cmsUrl };
|
|
110
|
-
}
|
|
111
|
-
/**
|
|
112
|
-
* Resolve route params for scanner.
|
|
113
|
-
* Merges auto-generated params from cache with user's manual config.
|
|
114
|
-
* User config takes precedence.
|
|
115
|
-
*/
|
|
116
|
-
export function resolveRouteParams(cwd, fileConfig) {
|
|
117
|
-
const root = cwd ?? findProjectRoot();
|
|
118
|
-
// Load auto-generated params from cache
|
|
119
|
-
const cached = loadRouteParamsCache(root);
|
|
120
|
-
const autoParams = cached?.generated ?? {};
|
|
121
|
-
// User's manual config overrides cache
|
|
122
|
-
const userParams = fileConfig?.routeParams ?? {};
|
|
123
|
-
// Merge: auto-generated first, then user overrides
|
|
124
|
-
return { ...autoParams, ...userParams };
|
|
125
|
-
}
|
|
5
|
+
export { loadConfigFile } from './config-internals/file.js';
|
|
6
|
+
export { loadEnvLocal } from './config-internals/env.js';
|
|
7
|
+
export { parseArgs } from './config-internals/args.js';
|
|
8
|
+
export { findProjectRoot } from './config-internals/root.js';
|
|
9
|
+
export { resolveConfig, resolveRouteParams } from './config-internals/resolve.js';
|
|
126
10
|
//# sourceMappingURL=resolve-config.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resolve-config.js","sourceRoot":"","sources":["../../src/config/resolve-config.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"resolve-config.js","sourceRoot":"","sources":["../../src/config/resolve-config.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AAC5D,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AACzD,OAAO,EAAE,SAAS,EAAE,MAAM,4BAA4B,CAAC;AACvD,OAAO,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAC7D,OAAO,EAAE,aAAa,EAAE,kBAAkB,EAAE,MAAM,+BAA+B,CAAC"}
|
|
@@ -5,7 +5,15 @@ import type { Config } from '../../config/resolve-config.js';
|
|
|
5
5
|
import type { PullOptions } from './types.js';
|
|
6
6
|
/**
|
|
7
7
|
* Fetch published translations from the CMS and write them to local JSON files.
|
|
8
|
-
*
|
|
8
|
+
*
|
|
9
|
+
* Output format per locale: `{outputDir}/{locale}.json`
|
|
10
|
+
* Structure: `{ namespace: { key: value } }` — compatible with i18next-resources-to-backend.
|
|
11
|
+
*
|
|
12
|
+
* TTL cache: skips the network request if translations were pulled recently
|
|
13
|
+
* (configurable via opts.ttlMs). Bypassed when opts.force is true.
|
|
14
|
+
*
|
|
15
|
+
* Stale files: locale files that no longer exist in the CMS are emptied to `{}`
|
|
16
|
+
* rather than deleted, so static imports in the consuming app don't break.
|
|
9
17
|
*/
|
|
10
18
|
export declare function pullTranslations(config: Config, opts: PullOptions): Promise<void>;
|
|
11
19
|
//# sourceMappingURL=pull.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pull.d.ts","sourceRoot":"","sources":["../../../src/core/api-internals/pull.ts"],"names":[],"mappings":"AAAA;;GAEG;AAIH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,gCAAgC,CAAC;AAC7D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"pull.d.ts","sourceRoot":"","sources":["../../../src/core/api-internals/pull.ts"],"names":[],"mappings":"AAAA;;GAEG;AAIH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,gCAAgC,CAAC;AAC7D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAmI9C;;;;;;;;;;;GAWG;AACH,wBAAsB,gBAAgB,CAClC,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,WAAW,GAClB,OAAO,CAAC,IAAI,CAAC,CAmMf"}
|
|
@@ -5,7 +5,8 @@ import fs from 'fs';
|
|
|
5
5
|
import path from 'path';
|
|
6
6
|
import { getLastPulledTime, saveLastPulledTime, PULL_META_FILE, DEFAULT_PULL_TTL_MS, } from '../cache.js';
|
|
7
7
|
/**
|
|
8
|
-
*
|
|
8
|
+
* Returns an error message string if any required config field is missing,
|
|
9
|
+
* or null when all fields are present.
|
|
9
10
|
*/
|
|
10
11
|
function validateConfig(config) {
|
|
11
12
|
if (!config.cmsUrl?.trim())
|
|
@@ -17,7 +18,9 @@ function validateConfig(config) {
|
|
|
17
18
|
return null;
|
|
18
19
|
}
|
|
19
20
|
/**
|
|
20
|
-
* Build API URL
|
|
21
|
+
* Build the API URL for fetching translations.
|
|
22
|
+
* Uses the URL constructor to correctly handle base URLs with path prefixes.
|
|
23
|
+
* Appends ?env=<env> when a specific environment is requested.
|
|
21
24
|
*/
|
|
22
25
|
function buildFetchUrl(config, opts) {
|
|
23
26
|
try {
|
|
@@ -33,7 +36,9 @@ function buildFetchUrl(config, opts) {
|
|
|
33
36
|
}
|
|
34
37
|
}
|
|
35
38
|
/**
|
|
36
|
-
*
|
|
39
|
+
* Fetch the URL with up to `maxRetries` attempts.
|
|
40
|
+
* Uses exponential backoff capped at 5 s: 0 ms, 1 s, 2 s, 4 s, 5 s, …
|
|
41
|
+
* Each attempt has a 30 s abort timeout to prevent hanging indefinitely.
|
|
37
42
|
*/
|
|
38
43
|
async function fetchWithRetry(url, apiKey, maxRetries = 3) {
|
|
39
44
|
let lastError = null;
|
|
@@ -55,6 +60,7 @@ async function fetchWithRetry(url, apiKey, maxRetries = 3) {
|
|
|
55
60
|
catch (err) {
|
|
56
61
|
lastError = err instanceof Error ? err : new Error(String(err));
|
|
57
62
|
if (attempt < maxRetries) {
|
|
63
|
+
// Exponential backoff: 1 s, 2 s, 4 s, … capped at 5 s
|
|
58
64
|
const backoff = Math.min(1000 * Math.pow(2, attempt - 1), 5000);
|
|
59
65
|
console.log(`[CMS] ⟳ Retry ${attempt}/${maxRetries} after ${backoff}ms...`);
|
|
60
66
|
await new Promise(resolve => setTimeout(resolve, backoff));
|
|
@@ -66,13 +72,16 @@ async function fetchWithRetry(url, apiKey, maxRetries = 3) {
|
|
|
66
72
|
/**
|
|
67
73
|
* Converts a flat `{ "namespace:key": value }` object into
|
|
68
74
|
* `{ namespace: { key: value } }`, with dot-notation key support.
|
|
75
|
+
*
|
|
76
|
+
* Keys that don't contain a colon, or have an empty namespace/key segment,
|
|
77
|
+
* are skipped to avoid creating malformed output.
|
|
69
78
|
*/
|
|
70
79
|
function nestTranslationKeys(flat) {
|
|
71
80
|
const nested = {};
|
|
72
81
|
for (const [key, value] of Object.entries(flat)) {
|
|
73
82
|
const colonIdx = key.indexOf(':');
|
|
83
|
+
// Skip invalid keys: no colon, empty namespace, or empty key after colon
|
|
74
84
|
if (colonIdx === -1 || colonIdx === 0 || colonIdx === key.length - 1) {
|
|
75
|
-
// Skip invalid keys (no colon, empty namespace, or empty key)
|
|
76
85
|
continue;
|
|
77
86
|
}
|
|
78
87
|
const namespace = key.slice(0, colonIdx);
|
|
@@ -80,7 +89,7 @@ function nestTranslationKeys(flat) {
|
|
|
80
89
|
if (!nested[namespace]) {
|
|
81
90
|
nested[namespace] = {};
|
|
82
91
|
}
|
|
83
|
-
//
|
|
92
|
+
// Walk the dot-notation segments, creating intermediate objects as needed
|
|
84
93
|
const parts = keyPath.split('.');
|
|
85
94
|
const obj = nested[namespace];
|
|
86
95
|
const lastPart = parts[parts.length - 1];
|
|
@@ -97,10 +106,17 @@ function nestTranslationKeys(flat) {
|
|
|
97
106
|
}
|
|
98
107
|
/**
|
|
99
108
|
* Fetch published translations from the CMS and write them to local JSON files.
|
|
100
|
-
*
|
|
109
|
+
*
|
|
110
|
+
* Output format per locale: `{outputDir}/{locale}.json`
|
|
111
|
+
* Structure: `{ namespace: { key: value } }` — compatible with i18next-resources-to-backend.
|
|
112
|
+
*
|
|
113
|
+
* TTL cache: skips the network request if translations were pulled recently
|
|
114
|
+
* (configurable via opts.ttlMs). Bypassed when opts.force is true.
|
|
115
|
+
*
|
|
116
|
+
* Stale files: locale files that no longer exist in the CMS are emptied to `{}`
|
|
117
|
+
* rather than deleted, so static imports in the consuming app don't break.
|
|
101
118
|
*/
|
|
102
119
|
export async function pullTranslations(config, opts) {
|
|
103
|
-
// Validate configuration
|
|
104
120
|
const validationError = validateConfig(config);
|
|
105
121
|
if (validationError) {
|
|
106
122
|
console.error(`[CMS] ✗ Validation error: ${validationError}`);
|
|
@@ -108,10 +124,16 @@ export async function pullTranslations(config, opts) {
|
|
|
108
124
|
}
|
|
109
125
|
const ttl = opts.ttlMs ?? DEFAULT_PULL_TTL_MS;
|
|
110
126
|
console.log(`[CMS] Checking for ${PULL_META_FILE}...`);
|
|
111
|
-
//
|
|
112
|
-
if (
|
|
127
|
+
// TTL cache check — skip fetch if translations are still fresh
|
|
128
|
+
if (opts.force) {
|
|
129
|
+
console.log(`[CMS] --force flag detected, refreshing...`);
|
|
130
|
+
}
|
|
131
|
+
else {
|
|
113
132
|
const lastPulled = getLastPulledTime(opts.outputDir);
|
|
114
|
-
if (lastPulled
|
|
133
|
+
if (lastPulled === null) {
|
|
134
|
+
console.log(`[CMS] ${PULL_META_FILE} not found, will refresh`);
|
|
135
|
+
}
|
|
136
|
+
else {
|
|
115
137
|
const age = Date.now() - lastPulled;
|
|
116
138
|
const ageS = Math.round(age / 1000);
|
|
117
139
|
const ttlS = Math.round(ttl / 1000);
|
|
@@ -122,14 +144,7 @@ export async function pullTranslations(config, opts) {
|
|
|
122
144
|
}
|
|
123
145
|
console.log(`[CMS] ⟳ Translations stale (age: ${ageS}s ≥ TTL: ${ttlS}s) — refreshing...`);
|
|
124
146
|
}
|
|
125
|
-
else {
|
|
126
|
-
console.log(`[CMS] ${PULL_META_FILE} not found, will refresh`);
|
|
127
|
-
}
|
|
128
|
-
}
|
|
129
|
-
else {
|
|
130
|
-
console.log(`[CMS] --force flag detected, refreshing...`);
|
|
131
147
|
}
|
|
132
|
-
// Build and log URL
|
|
133
148
|
let url;
|
|
134
149
|
try {
|
|
135
150
|
url = buildFetchUrl(config, opts);
|
|
@@ -142,7 +157,6 @@ export async function pullTranslations(config, opts) {
|
|
|
142
157
|
console.log(`[CMS] Environment: ${opts.env}`);
|
|
143
158
|
}
|
|
144
159
|
console.log(`[CMS] Fetching from: ${url}`);
|
|
145
|
-
// Fetch with retries
|
|
146
160
|
let response;
|
|
147
161
|
try {
|
|
148
162
|
response = await fetchWithRetry(url, config.apiKey);
|
|
@@ -151,7 +165,6 @@ export async function pullTranslations(config, opts) {
|
|
|
151
165
|
console.error(`[CMS] ✗ Pull failed after retries: ${err instanceof Error ? err.message : String(err)}`);
|
|
152
166
|
process.exit(1);
|
|
153
167
|
}
|
|
154
|
-
// Parse response
|
|
155
168
|
let data;
|
|
156
169
|
try {
|
|
157
170
|
data = (await response.json());
|
|
@@ -160,9 +173,10 @@ export async function pullTranslations(config, opts) {
|
|
|
160
173
|
console.error(`[CMS] ✗ Invalid JSON response: ${err instanceof Error ? err.message : String(err)}`);
|
|
161
174
|
process.exit(1);
|
|
162
175
|
}
|
|
163
|
-
// Log raw response for debugging
|
|
164
176
|
console.log(`[CMS] API returned ${Object.keys(data).length} locale keys`);
|
|
165
|
-
//
|
|
177
|
+
// Normalise each locale's payload to `{ namespace: { key: value } }`.
|
|
178
|
+
// The API may return either the nested form directly, or a flat
|
|
179
|
+
// `{ "namespace:key": value }` form — detect by inspecting the first value.
|
|
166
180
|
const processed = {};
|
|
167
181
|
for (const [locale, content] of Object.entries(data)) {
|
|
168
182
|
if (typeof content !== 'object' || content === null) {
|
|
@@ -175,6 +189,7 @@ export async function pullTranslations(config, opts) {
|
|
|
175
189
|
processed[locale] = {};
|
|
176
190
|
continue;
|
|
177
191
|
}
|
|
192
|
+
// If the first value is a string, the payload is flat and needs nesting
|
|
178
193
|
const firstVal = Object.values(obj)[0];
|
|
179
194
|
processed[locale] =
|
|
180
195
|
typeof firstVal === 'string'
|
|
@@ -193,7 +208,6 @@ export async function pullTranslations(config, opts) {
|
|
|
193
208
|
` 3. Then run: pnpm sync-translations pull`);
|
|
194
209
|
process.exit(1);
|
|
195
210
|
}
|
|
196
|
-
// Create output directory
|
|
197
211
|
try {
|
|
198
212
|
fs.mkdirSync(opts.outputDir, { recursive: true });
|
|
199
213
|
}
|
|
@@ -201,11 +215,9 @@ export async function pullTranslations(config, opts) {
|
|
|
201
215
|
console.error(`[CMS] ✗ Failed to create output directory: ${err instanceof Error ? err.message : String(err)}`);
|
|
202
216
|
process.exit(1);
|
|
203
217
|
}
|
|
218
|
+
// Write one JSON file per locale
|
|
204
219
|
const writtenFiles = new Set();
|
|
205
220
|
let fileCount = 0;
|
|
206
|
-
// Write one file per locale: {outputDir}/{locale}.json
|
|
207
|
-
// Structure: { namespace: { key: value } }
|
|
208
|
-
// Compatible with i18next-resources-to-backend
|
|
209
221
|
for (const [locale, namespaces] of Object.entries(processed)) {
|
|
210
222
|
const filePath = path.join(opts.outputDir, `${locale}.json`);
|
|
211
223
|
try {
|
|
@@ -217,7 +229,9 @@ export async function pullTranslations(config, opts) {
|
|
|
217
229
|
console.error(`[CMS] ✗ Failed to write ${locale}.json: ${err instanceof Error ? err.message : String(err)}`);
|
|
218
230
|
}
|
|
219
231
|
}
|
|
220
|
-
// Empty locale files that no longer
|
|
232
|
+
// Empty locale files that are no longer returned by the CMS.
|
|
233
|
+
// We write `{}` instead of deleting so static imports in the consuming app
|
|
234
|
+
// don't break at build time.
|
|
221
235
|
let emptied = 0;
|
|
222
236
|
try {
|
|
223
237
|
for (const entry of fs.readdirSync(opts.outputDir, {
|
|
@@ -238,14 +252,13 @@ export async function pullTranslations(config, opts) {
|
|
|
238
252
|
catch (err) {
|
|
239
253
|
console.warn(`[CMS] ⚠ Failed to clean up stale files: ${err instanceof Error ? err.message : String(err)}`);
|
|
240
254
|
}
|
|
241
|
-
//
|
|
255
|
+
// Update the pull timestamp so the TTL cache is valid on next run
|
|
242
256
|
try {
|
|
243
257
|
saveLastPulledTime(opts.outputDir);
|
|
244
258
|
}
|
|
245
259
|
catch (err) {
|
|
246
260
|
console.warn(`[CMS] ⚠ Failed to save cache metadata: ${err instanceof Error ? err.message : String(err)}`);
|
|
247
261
|
}
|
|
248
|
-
// Summary
|
|
249
262
|
if (emptied > 0) {
|
|
250
263
|
console.log(`[CMS] ✓ Refresh complete: wrote ${fileCount} files, emptied ${emptied} stale files`);
|
|
251
264
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pull.js","sourceRoot":"","sources":["../../../src/core/api-internals/pull.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,MAAM,IAAI,CAAC;AACpB,OAAO,IAAI,MAAM,MAAM,CAAC;AAGxB,OAAO,EACH,iBAAiB,EACjB,kBAAkB,EAClB,cAAc,EACd,mBAAmB,GACtB,MAAM,aAAa,CAAC;AAErB
|
|
1
|
+
{"version":3,"file":"pull.js","sourceRoot":"","sources":["../../../src/core/api-internals/pull.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,MAAM,IAAI,CAAC;AACpB,OAAO,IAAI,MAAM,MAAM,CAAC;AAGxB,OAAO,EACH,iBAAiB,EACjB,kBAAkB,EAClB,cAAc,EACd,mBAAmB,GACtB,MAAM,aAAa,CAAC;AAErB;;;GAGG;AACH,SAAS,cAAc,CAAC,MAAc;IAClC,IAAI,CAAC,MAAM,CAAC,MAAM,EAAE,IAAI,EAAE;QAAE,OAAO,oBAAoB,CAAC;IACxD,IAAI,CAAC,MAAM,CAAC,MAAM,EAAE,IAAI,EAAE;QAAE,OAAO,oBAAoB,CAAC;IACxD,IAAI,CAAC,MAAM,CAAC,SAAS,EAAE,IAAI,EAAE;QAAE,OAAO,uBAAuB,CAAC;IAC9D,OAAO,IAAI,CAAC;AAChB,CAAC;AAED;;;;GAIG;AACH,SAAS,aAAa,CAAC,MAAc,EAAE,IAAiB;IACpD,IAAI,CAAC;QACD,MAAM,OAAO,GAAG,IAAI,GAAG,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;QACvC,OAAO,CAAC,QAAQ,GAAG,qBAAqB,kBAAkB,CAAC,MAAM,CAAC,SAAS,CAAC,EAAE,CAAC;QAC/E,IAAI,IAAI,CAAC,GAAG,EAAE,CAAC;YACX,OAAO,CAAC,YAAY,CAAC,GAAG,CAA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|
|
6
6
|
import type { PostToSyncOptions } from './types.js';
|
|
7
7
|
/**
|
|
8
|
-
* Push translation keys to the CMS
|
|
9
|
-
*
|
|
8
|
+
* Push discovered translation keys to the CMS sync endpoint.
|
|
9
|
+
*
|
|
10
|
+
* Three possible outcomes:
|
|
11
|
+
* 1. **Dry-run** (`opts.dryRun`) — prints a diff against the last cache and
|
|
12
|
+
* optionally writes a report, but never POSTs to the CMS.
|
|
13
|
+
* 2. **No changes** — skips the POST when the serialized keys are identical
|
|
14
|
+
* to the last cache and `--force` was not passed.
|
|
15
|
+
* 3. **Sync** — POSTs the full namespace map; on success saves the new cache
|
|
16
|
+
* and optionally writes a report.
|
|
10
17
|
*/
|
|
11
18
|
export declare function postToSync(config: Config, namespaces: NamespaceMap, opts?: PostToSyncOptions): Promise<void>;
|
|
12
19
|
//# sourceMappingURL=sync.d.ts.map
|