@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
package/dist/commands/watch.d.ts
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import type { Config } from '../config/resolve-config.js';
|
|
2
|
-
import { type ScanOptions } from '../core/scanner.js';
|
|
3
|
-
/**
|
|
4
|
-
* `watch` command — runs a full sync on startup, then re-syncs automatically
|
|
5
|
-
* whenever a source file changes.
|
|
6
|
-
*
|
|
7
|
-
* Flow on each change:
|
|
8
|
-
* 1. Debounce 500 ms to coalesce rapid saves (e.g. editor auto-format).
|
|
9
|
-
* 2. Scan the project for translation keys.
|
|
10
|
-
* 3. POST discovered keys to the CMS (force — bypass TTL cache).
|
|
11
|
-
* 4. Pull the latest translations back to disk (force).
|
|
12
|
-
*
|
|
13
|
-
* Concurrent syncs are prevented by the `running` guard — if a sync is
|
|
14
|
-
* already in progress when a new change fires, the new event is dropped.
|
|
15
|
-
* Ctrl+C closes the watcher cleanly before exiting.
|
|
16
|
-
*/
|
|
17
|
-
export declare function runWatch(root: string, config: Config, outputDir: string, scanOpts: ScanOptions): Promise<void>;
|
|
18
|
-
//# sourceMappingURL=watch.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"watch.d.ts","sourceRoot":"","sources":["../../src/commands/watch.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,6BAA6B,CAAC;AAC1D,OAAO,EAAe,KAAK,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAGnE;;;;;;;;;;;;;GAaG;AACH,wBAAsB,QAAQ,CAC1B,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,MAAM,EACd,SAAS,EAAE,MAAM,EACjB,QAAQ,EAAE,WAAW,GACtB,OAAO,CAAC,IAAI,CAAC,CA0Df"}
|
package/dist/commands/watch.js
DELETED
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
import path from 'path';
|
|
2
|
-
import fs from 'fs';
|
|
3
|
-
import { scanProject } from '../core/scanner.js';
|
|
4
|
-
import { postToSync, pullTranslations } from '../core/api.js';
|
|
5
|
-
/**
|
|
6
|
-
* `watch` command — runs a full sync on startup, then re-syncs automatically
|
|
7
|
-
* whenever a source file changes.
|
|
8
|
-
*
|
|
9
|
-
* Flow on each change:
|
|
10
|
-
* 1. Debounce 500 ms to coalesce rapid saves (e.g. editor auto-format).
|
|
11
|
-
* 2. Scan the project for translation keys.
|
|
12
|
-
* 3. POST discovered keys to the CMS (force — bypass TTL cache).
|
|
13
|
-
* 4. Pull the latest translations back to disk (force).
|
|
14
|
-
*
|
|
15
|
-
* Concurrent syncs are prevented by the `running` guard — if a sync is
|
|
16
|
-
* already in progress when a new change fires, the new event is dropped.
|
|
17
|
-
* Ctrl+C closes the watcher cleanly before exiting.
|
|
18
|
-
*/
|
|
19
|
-
export async function runWatch(root, config, outputDir, scanOpts) {
|
|
20
|
-
console.log(`[watch] Watching ${root} for changes...`);
|
|
21
|
-
console.log('[watch] Press Ctrl+C to stop.\n');
|
|
22
|
-
// Only react to source files — ignore CSS, JSON, lock files, etc.
|
|
23
|
-
const sourceExtensions = new Set(scanOpts.sourceExtensions ?? ['.ts', '.tsx', '.js', '.jsx']);
|
|
24
|
-
let debounce = null;
|
|
25
|
-
// Prevents overlapping syncs if a change fires while a sync is still running
|
|
26
|
-
let running = false;
|
|
27
|
-
const runSync = async () => {
|
|
28
|
-
if (running)
|
|
29
|
-
return;
|
|
30
|
-
running = true;
|
|
31
|
-
try {
|
|
32
|
-
const namespaces = scanProject(root, scanOpts);
|
|
33
|
-
// force: true bypasses the TTL cache so changes are always pushed/pulled
|
|
34
|
-
await postToSync(config, namespaces, { root, force: true });
|
|
35
|
-
await pullTranslations(config, { outputDir, force: true });
|
|
36
|
-
}
|
|
37
|
-
catch (err) {
|
|
38
|
-
// Log errors without crashing the watcher process
|
|
39
|
-
console.error('[watch] Sync error:', err instanceof Error ? err.message : String(err));
|
|
40
|
-
}
|
|
41
|
-
finally {
|
|
42
|
-
running = false;
|
|
43
|
-
}
|
|
44
|
-
};
|
|
45
|
-
// Run an initial sync so the local dictionaries are up-to-date before watching
|
|
46
|
-
await runSync();
|
|
47
|
-
// fs.watch with recursive:true covers the entire tree in one watcher instance
|
|
48
|
-
const watcher = fs.watch(root, { recursive: true }, (_evt, filename) => {
|
|
49
|
-
if (!filename)
|
|
50
|
-
return;
|
|
51
|
-
const ext = path.extname(filename);
|
|
52
|
-
if (!sourceExtensions.has(ext))
|
|
53
|
-
return;
|
|
54
|
-
// Coalesce rapid saves within 500 ms into a single sync run
|
|
55
|
-
if (debounce)
|
|
56
|
-
clearTimeout(debounce);
|
|
57
|
-
debounce = setTimeout(() => {
|
|
58
|
-
console.log(`[watch] Change detected: ${filename}`);
|
|
59
|
-
void runSync();
|
|
60
|
-
}, 500);
|
|
61
|
-
});
|
|
62
|
-
// Clean up the watcher before exiting on Ctrl+C
|
|
63
|
-
process.on('SIGINT', () => {
|
|
64
|
-
watcher.close();
|
|
65
|
-
console.log('\n[watch] Stopped.');
|
|
66
|
-
process.exit(0);
|
|
67
|
-
});
|
|
68
|
-
// Hold the event loop open indefinitely — the watcher keeps us alive until SIGINT
|
|
69
|
-
await new Promise(() => undefined);
|
|
70
|
-
}
|
|
71
|
-
//# sourceMappingURL=watch.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"watch.js","sourceRoot":"","sources":["../../src/commands/watch.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,MAAM,IAAI,CAAC;AAEpB,OAAO,EAAE,WAAW,EAAoB,MAAM,oBAAoB,CAAC;AACnE,OAAO,EAAE,UAAU,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAE9D;;;;;;;;;;;;;GAaG;AACH,MAAM,CAAC,KAAK,UAAU,QAAQ,CAC1B,IAAY,EACZ,MAAc,EACd,SAAiB,EACjB,QAAqB;IAErB,OAAO,CAAC,GAAG,CAAC,oBAAoB,IAAI,iBAAiB,CAAC,CAAC;IACvD,OAAO,CAAC,GAAG,CAAC,iCAAiC,CAAC,CAAC;IAE/C,kEAAkE;IAClE,MAAM,gBAAgB,GAAG,IAAI,GAAG,CAC5B,QAAQ,CAAC,gBAAgB,IAAI,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,CAAC,CAC9D,CAAC;IAEF,IAAI,QAAQ,GAAyC,IAAI,CAAC;IAC1D,6EAA6E;IAC7E,IAAI,OAAO,GAAG,KAAK,CAAC;IAEpB,MAAM,OAAO,GAAG,KAAK,IAAmB,EAAE;QACtC,IAAI,OAAO;YAAE,OAAO;QACpB,OAAO,GAAG,IAAI,CAAC;QACf,IAAI,CAAC;YACD,MAAM,UAAU,GAAG,WAAW,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC;YAC/C,yEAAyE;YACzE,MAAM,UAAU,CAAC,MAAM,EAAE,UAAU,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;YAC5D,MAAM,gBAAgB,CAAC,MAAM,EAAE,EAAE,SAAS,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;QAC/D,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACX,kDAAkD;YAClD,OAAO,CAAC,KAAK,CACT,qBAAqB,EACrB,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,CACnD,CAAC;QACN,CAAC;gBAAS,CAAC;YACP,OAAO,GAAG,KAAK,CAAC;QACpB,CAAC;IACL,CAAC,CAAC;IAEF,+EAA+E;IAC/E,MAAM,OAAO,EAAE,CAAC;IAEhB,8EAA8E;IAC9E,MAAM,OAAO,GAAG,EAAE,CAAC,KAAK,CAAC,IAAI,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,EAAE,CAAC,IAAI,EAAE,QAAQ,EAAE,EAAE;QACnE,IAAI,CAAC,QAAQ;YAAE,OAAO;QACtB,MAAM,GAAG,GAAG,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;QACnC,IAAI,CAAC,gBAAgB,CAAC,GAAG,CAAC,GAAG,CAAC;YAAE,OAAO;QAEvC,4DAA4D;QAC5D,IAAI,QAAQ;YAAE,YAAY,CAAC,QAAQ,CAAC,CAAC;QACrC,QAAQ,GAAG,UAAU,CAAC,GAAG,EAAE;YACvB,OAAO,CAAC,GAAG,CAAC,4BAA4B,QAAQ,EAAE,CAAC,CAAC;YACpD,KAAK,OAAO,EAAE,CAAC;QACnB,CAAC,EAAE,GAAG,CAAC,CAAC;IACZ,CAAC,CAAC,CAAC;IAEH,gDAAgD;IAChD,OAAO,CAAC,EAAE,CAAC,QAAQ,EAAE,GAAG,EAAE;QACtB,OAAO,CAAC,KAAK,EAAE,CAAC;QAChB,OAAO,CAAC,GAAG,CAAC,oBAAoB,CAAC,CAAC;QAClC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IACpB,CAAC,CAAC,CAAC;IAEH,kFAAkF;IAClF,MAAM,IAAI,OAAO,CAAQ,GAAG,EAAE,CAAC,SAAS,CAAC,CAAC;AAC9C,CAAC"}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Parses CLI arguments that override resolved config values.
|
|
3
|
-
*/
|
|
4
|
-
import type { Config } from './types.js';
|
|
5
|
-
/**
|
|
6
|
-
* Scan process.argv for --project-id, --api-key, and --cms-url flags.
|
|
7
|
-
* Returns only the fields that were explicitly provided — missing flags are
|
|
8
|
-
* omitted so they can be overridden by lower-priority sources (env vars, file).
|
|
9
|
-
*/
|
|
10
|
-
export declare function parseArgs(): Partial<Config>;
|
|
11
|
-
//# sourceMappingURL=args.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"args.d.ts","sourceRoot":"","sources":["../../../src/config/config-internals/args.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,YAAY,CAAC;AAEzC;;;;GAIG;AACH,wBAAgB,SAAS,IAAI,OAAO,CAAC,MAAM,CAAC,CAU3C"}
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Parses CLI arguments that override resolved config values.
|
|
3
|
-
*/
|
|
4
|
-
/**
|
|
5
|
-
* Scan process.argv for --project-id, --api-key, and --cms-url flags.
|
|
6
|
-
* Returns only the fields that were explicitly provided — missing flags are
|
|
7
|
-
* omitted so they can be overridden by lower-priority sources (env vars, file).
|
|
8
|
-
*/
|
|
9
|
-
export function parseArgs() {
|
|
10
|
-
const args = process.argv.slice(2);
|
|
11
|
-
const result = {};
|
|
12
|
-
for (let i = 0; i < args.length; i++) {
|
|
13
|
-
if (args[i] === '--project-id' && args[i + 1])
|
|
14
|
-
result.projectId = args[++i];
|
|
15
|
-
if (args[i] === '--api-key' && args[i + 1])
|
|
16
|
-
result.apiKey = args[++i];
|
|
17
|
-
if (args[i] === '--cms-url' && args[i + 1])
|
|
18
|
-
result.cmsUrl = args[++i];
|
|
19
|
-
}
|
|
20
|
-
return result;
|
|
21
|
-
}
|
|
22
|
-
//# sourceMappingURL=args.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"args.js","sourceRoot":"","sources":["../../../src/config/config-internals/args.ts"],"names":[],"mappings":"AAAA;;GAEG;AAIH;;;;GAIG;AACH,MAAM,UAAU,SAAS;IACrB,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;IACnC,MAAM,MAAM,GAAoB,EAAE,CAAC;IACnC,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;QACnC,IAAI,IAAI,CAAC,CAAC,CAAC,KAAK,cAAc,IAAI,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC;YACzC,MAAM,CAAC,SAAS,GAAG,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC;QACjC,IAAI,IAAI,CAAC,CAAC,CAAC,KAAK,WAAW,IAAI,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC;YAAE,MAAM,CAAC,MAAM,GAAG,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC;QACtE,IAAI,IAAI,CAAC,CAAC,CAAC,KAAK,WAAW,IAAI,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC;YAAE,MAAM,CAAC,MAAM,GAAG,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC;IAC1E,CAAC;IACD,OAAO,MAAM,CAAC;AAClB,CAAC"}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Reads .env.local files and parses them into a key/value map.
|
|
3
|
-
*/
|
|
4
|
-
/**
|
|
5
|
-
* Parse a .env.local file at the given root into a plain key/value map.
|
|
6
|
-
* Skips blank lines and comments. Strips surrounding quotes from values.
|
|
7
|
-
* Returns an empty object when the file does not exist — never throws.
|
|
8
|
-
*/
|
|
9
|
-
export declare function loadEnvLocal(root: string): Record<string, string>;
|
|
10
|
-
//# sourceMappingURL=env.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"env.d.ts","sourceRoot":"","sources":["../../../src/config/config-internals/env.ts"],"names":[],"mappings":"AAAA;;GAEG;AAKH;;;;GAIG;AACH,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAqBjE"}
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Reads .env.local files and parses them into a key/value map.
|
|
3
|
-
*/
|
|
4
|
-
import fs from 'fs';
|
|
5
|
-
import path from 'path';
|
|
6
|
-
/**
|
|
7
|
-
* Parse a .env.local file at the given root into a plain key/value map.
|
|
8
|
-
* Skips blank lines and comments. Strips surrounding quotes from values.
|
|
9
|
-
* Returns an empty object when the file does not exist — never throws.
|
|
10
|
-
*/
|
|
11
|
-
export function loadEnvLocal(root) {
|
|
12
|
-
const envPath = path.join(root, '.env.local');
|
|
13
|
-
if (!fs.existsSync(envPath))
|
|
14
|
-
return {};
|
|
15
|
-
const vars = {};
|
|
16
|
-
const lines = fs.readFileSync(envPath, 'utf-8').split('\n');
|
|
17
|
-
for (const line of lines) {
|
|
18
|
-
const trimmed = line.trim();
|
|
19
|
-
// Skip blank lines and comments
|
|
20
|
-
if (!trimmed || trimmed.startsWith('#'))
|
|
21
|
-
continue;
|
|
22
|
-
const eq = trimmed.indexOf('=');
|
|
23
|
-
if (eq === -1)
|
|
24
|
-
continue;
|
|
25
|
-
const key = trimmed.slice(0, eq).trim();
|
|
26
|
-
// Strip surrounding single or double quotes from the value
|
|
27
|
-
const value = trimmed
|
|
28
|
-
.slice(eq + 1)
|
|
29
|
-
.trim()
|
|
30
|
-
.replace(/^["']|["']$/g, '');
|
|
31
|
-
vars[key] = value;
|
|
32
|
-
}
|
|
33
|
-
return vars;
|
|
34
|
-
}
|
|
35
|
-
//# sourceMappingURL=env.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"env.js","sourceRoot":"","sources":["../../../src/config/config-internals/env.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,MAAM,IAAI,CAAC;AACpB,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB;;;;GAIG;AACH,MAAM,UAAU,YAAY,CAAC,IAAY;IACrC,MAAM,OAAO,GAAG,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,YAAY,CAAC,CAAC;IAC9C,IAAI,CAAC,EAAE,CAAC,UAAU,CAAC,OAAO,CAAC;QAAE,OAAO,EAAE,CAAC;IAEvC,MAAM,IAAI,GAA2B,EAAE,CAAC;IACxC,MAAM,KAAK,GAAG,EAAE,CAAC,YAAY,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IAC5D,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;QACvB,MAAM,OAAO,GAAG,IAAI,CAAC,IAAI,EAAE,CAAC;QAC5B,gCAAgC;QAChC,IAAI,CAAC,OAAO,IAAI,OAAO,CAAC,UAAU,CAAC,GAAG,CAAC;YAAE,SAAS;QAClD,MAAM,EAAE,GAAG,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;QAChC,IAAI,EAAE,KAAK,CAAC,CAAC;YAAE,SAAS;QACxB,MAAM,GAAG,GAAG,OAAO,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC;QACxC,2DAA2D;QAC3D,MAAM,KAAK,GAAG,OAAO;aAChB,KAAK,CAAC,EAAE,GAAG,CAAC,CAAC;aACb,IAAI,EAAE;aACN,OAAO,CAAC,cAAc,EAAE,EAAE,CAAC,CAAC;QACjC,IAAI,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC;IACtB,CAAC;IACD,OAAO,IAAI,CAAC;AAChB,CAAC"}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Loads the project-level config file (.translationsrc.json / translations.config.json).
|
|
3
|
-
*/
|
|
4
|
-
import { type TranslationsConfig } from './types.js';
|
|
5
|
-
/**
|
|
6
|
-
* Load project-level config from .translationsrc.json or translations.config.json.
|
|
7
|
-
* Searches the given root directory and returns the first file found.
|
|
8
|
-
* Returns an empty object when no config file is found — never throws.
|
|
9
|
-
*/
|
|
10
|
-
export declare function loadConfigFile(root: string): TranslationsConfig;
|
|
11
|
-
//# sourceMappingURL=file.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"file.d.ts","sourceRoot":"","sources":["../../../src/config/config-internals/file.ts"],"names":[],"mappings":"AAAA;;GAEG;AAIH,OAAO,EAAoB,KAAK,kBAAkB,EAAE,MAAM,YAAY,CAAC;AAEvE;;;;GAIG;AACH,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,GAAG,kBAAkB,CAqB/D"}
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Loads the project-level config file (.translationsrc.json / translations.config.json).
|
|
3
|
-
*/
|
|
4
|
-
import fs from 'fs';
|
|
5
|
-
import path from 'path';
|
|
6
|
-
import { CONFIG_FILENAMES } from './types.js';
|
|
7
|
-
/**
|
|
8
|
-
* Load project-level config from .translationsrc.json or translations.config.json.
|
|
9
|
-
* Searches the given root directory and returns the first file found.
|
|
10
|
-
* Returns an empty object when no config file is found — never throws.
|
|
11
|
-
*/
|
|
12
|
-
export function loadConfigFile(root) {
|
|
13
|
-
for (const filename of CONFIG_FILENAMES) {
|
|
14
|
-
const filePath = path.join(root, filename);
|
|
15
|
-
if (!fs.existsSync(filePath))
|
|
16
|
-
continue;
|
|
17
|
-
try {
|
|
18
|
-
const parsed = JSON.parse(fs.readFileSync(filePath, 'utf-8'));
|
|
19
|
-
console.log(`[config] Loaded config from ${filename}`);
|
|
20
|
-
return parsed;
|
|
21
|
-
}
|
|
22
|
-
catch (err) {
|
|
23
|
-
console.warn(`[config] Failed to parse ${filename}: ${err instanceof Error ? err.message : String(err)}`);
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
return {};
|
|
27
|
-
}
|
|
28
|
-
//# sourceMappingURL=file.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"file.js","sourceRoot":"","sources":["../../../src/config/config-internals/file.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,MAAM,IAAI,CAAC;AACpB,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,gBAAgB,EAA2B,MAAM,YAAY,CAAC;AAEvE;;;;GAIG;AACH,MAAM,UAAU,cAAc,CAAC,IAAY;IACvC,KAAK,MAAM,QAAQ,IAAI,gBAAgB,EAAE,CAAC;QACtC,MAAM,QAAQ,GAAG,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC;QAC3C,IAAI,CAAC,EAAE,CAAC,UAAU,CAAC,QAAQ,CAAC;YAAE,SAAS;QAEvC,IAAI,CAAC;YACD,MAAM,MAAM,GAAG,IAAI,CAAC,KAAK,CACrB,EAAE,CAAC,YAAY,CAAC,QAAQ,EAAE,OAAO,CAAC,CACf,CAAC;YACxB,OAAO,CAAC,GAAG,CAAC,+BAA+B,QAAQ,EAAE,CAAC,CAAC;YACvD,OAAO,MAAM,CAAC;QAClB,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACX,OAAO,CAAC,IAAI,CACR,4BAA4B,QAAQ,KAChC,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CACnD,EAAE,CACL,CAAC;QACN,CAAC;IACL,CAAC;IAED,OAAO,EAAE,CAAC;AACd,CAAC"}
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Resolves the final runtime Config and route params by merging all sources.
|
|
3
|
-
*
|
|
4
|
-
* Priority order (highest → lowest):
|
|
5
|
-
* CLI args > env vars > config file
|
|
6
|
-
*/
|
|
7
|
-
import type { Config, TranslationsConfig } from './types.js';
|
|
8
|
-
/**
|
|
9
|
-
* Resolve the runtime Config from CLI args, env vars, and the file-based config.
|
|
10
|
-
* Reads both root .env.local and apps/web/.env.local (for monorepo setups where
|
|
11
|
-
* NEXT_PUBLIC_* vars are defined next to the Next.js app).
|
|
12
|
-
* Exits the process with an error message if any required value is missing.
|
|
13
|
-
*/
|
|
14
|
-
export declare function resolveConfig(cwd?: string, fileConfig?: TranslationsConfig): Config;
|
|
15
|
-
/**
|
|
16
|
-
* Resolve route params for the scanner by merging auto-generated params
|
|
17
|
-
* (from the cache written by the last sync) with user-configured params.
|
|
18
|
-
* User config takes precedence on conflict.
|
|
19
|
-
*/
|
|
20
|
-
export declare function resolveRouteParams(cwd?: string, fileConfig?: TranslationsConfig): Record<string, Record<string, string>>;
|
|
21
|
-
//# sourceMappingURL=resolve.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"resolve.d.ts","sourceRoot":"","sources":["../../../src/config/config-internals/resolve.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAOH,OAAO,KAAK,EAAE,MAAM,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AAE7D;;;;;GAKG;AACH,wBAAgB,aAAa,CACzB,GAAG,CAAC,EAAE,MAAM,EACZ,UAAU,CAAC,EAAE,kBAAkB,GAChC,MAAM,CA8CR;AAED;;;;GAIG;AACH,wBAAgB,kBAAkB,CAC9B,GAAG,CAAC,EAAE,MAAM,EACZ,UAAU,CAAC,EAAE,kBAAkB,GAChC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAWxC"}
|
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Resolves the final runtime Config and route params by merging all sources.
|
|
3
|
-
*
|
|
4
|
-
* Priority order (highest → lowest):
|
|
5
|
-
* CLI args > env vars > config file
|
|
6
|
-
*/
|
|
7
|
-
import path from 'path';
|
|
8
|
-
import { loadRouteParamsCache } from '../../core/cache.js';
|
|
9
|
-
import { loadEnvLocal } from './env.js';
|
|
10
|
-
import { parseArgs } from './args.js';
|
|
11
|
-
import { findProjectRoot } from './root.js';
|
|
12
|
-
/**
|
|
13
|
-
* Resolve the runtime Config from CLI args, env vars, and the file-based config.
|
|
14
|
-
* Reads both root .env.local and apps/web/.env.local (for monorepo setups where
|
|
15
|
-
* NEXT_PUBLIC_* vars are defined next to the Next.js app).
|
|
16
|
-
* Exits the process with an error message if any required value is missing.
|
|
17
|
-
*/
|
|
18
|
-
export function resolveConfig(cwd, fileConfig) {
|
|
19
|
-
const root = cwd ?? findProjectRoot();
|
|
20
|
-
// Load root .env.local first, then apps/web/.env.local as fallback
|
|
21
|
-
// for NEXT_PUBLIC_* vars already configured there (monorepo support).
|
|
22
|
-
const rootEnv = loadEnvLocal(root);
|
|
23
|
-
const webEnv = loadEnvLocal(path.join(root, 'apps', 'web'));
|
|
24
|
-
const cliArgs = parseArgs();
|
|
25
|
-
const projectId = cliArgs.projectId ??
|
|
26
|
-
rootEnv['NEXT_PUBLIC_CMS_PROJECT_ID'] ??
|
|
27
|
-
webEnv['NEXT_PUBLIC_CMS_PROJECT_ID'] ??
|
|
28
|
-
fileConfig?.projectId ??
|
|
29
|
-
'';
|
|
30
|
-
// CMS_SYNC_API_KEY is preferred over the public anon key for CLI use
|
|
31
|
-
const apiKey = cliArgs.apiKey ??
|
|
32
|
-
rootEnv['CMS_SYNC_API_KEY'] ??
|
|
33
|
-
rootEnv['NEXT_PUBLIC_CMS_ANON_KEY'] ??
|
|
34
|
-
webEnv['CMS_SYNC_API_KEY'] ??
|
|
35
|
-
webEnv['NEXT_PUBLIC_CMS_ANON_KEY'] ??
|
|
36
|
-
fileConfig?.apiKey ??
|
|
37
|
-
'';
|
|
38
|
-
const cmsUrl = cliArgs.cmsUrl ??
|
|
39
|
-
rootEnv['NEXT_PUBLIC_CMS_URL'] ??
|
|
40
|
-
webEnv['NEXT_PUBLIC_CMS_URL'] ??
|
|
41
|
-
fileConfig?.cmsUrl ??
|
|
42
|
-
'';
|
|
43
|
-
// Collect all missing required values and fail with a clear error message
|
|
44
|
-
const missing = [];
|
|
45
|
-
if (!projectId)
|
|
46
|
-
missing.push('--project-id / NEXT_PUBLIC_CMS_PROJECT_ID');
|
|
47
|
-
if (!apiKey)
|
|
48
|
-
missing.push('--api-key / NEXT_PUBLIC_CMS_ANON_KEY');
|
|
49
|
-
if (!cmsUrl)
|
|
50
|
-
missing.push('--cms-url / NEXT_PUBLIC_CMS_URL');
|
|
51
|
-
if (missing.length > 0) {
|
|
52
|
-
console.error('Missing required config:');
|
|
53
|
-
for (const m of missing)
|
|
54
|
-
console.error(` ${m}`);
|
|
55
|
-
process.exit(1);
|
|
56
|
-
}
|
|
57
|
-
return { projectId, apiKey, cmsUrl };
|
|
58
|
-
}
|
|
59
|
-
/**
|
|
60
|
-
* Resolve route params for the scanner by merging auto-generated params
|
|
61
|
-
* (from the cache written by the last sync) with user-configured params.
|
|
62
|
-
* User config takes precedence on conflict.
|
|
63
|
-
*/
|
|
64
|
-
export function resolveRouteParams(cwd, fileConfig) {
|
|
65
|
-
const root = cwd ?? findProjectRoot();
|
|
66
|
-
// Auto-generated params are written to cache by the sync command
|
|
67
|
-
const cached = loadRouteParamsCache(root);
|
|
68
|
-
const autoParams = cached?.generated ?? {};
|
|
69
|
-
// User's manual config overrides auto-generated values
|
|
70
|
-
const userParams = fileConfig?.routeParams ?? {};
|
|
71
|
-
return { ...autoParams, ...userParams };
|
|
72
|
-
}
|
|
73
|
-
//# sourceMappingURL=resolve.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"resolve.js","sourceRoot":"","sources":["../../../src/config/config-internals/resolve.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAC3D,OAAO,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AACxC,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AACtC,OAAO,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AAG5C;;;;;GAKG;AACH,MAAM,UAAU,aAAa,CACzB,GAAY,EACZ,UAA+B;IAE/B,MAAM,IAAI,GAAG,GAAG,IAAI,eAAe,EAAE,CAAC;IAEtC,mEAAmE;IACnE,sEAAsE;IACtE,MAAM,OAAO,GAAG,YAAY,CAAC,IAAI,CAAC,CAAC;IACnC,MAAM,MAAM,GAAG,YAAY,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,CAAC,CAAC,CAAC;IAC5D,MAAM,OAAO,GAAG,SAAS,EAAE,CAAC;IAE5B,MAAM,SAAS,GACX,OAAO,CAAC,SAAS;QACjB,OAAO,CAAC,4BAA4B,CAAC;QACrC,MAAM,CAAC,4BAA4B,CAAC;QACpC,UAAU,EAAE,SAAS;QACrB,EAAE,CAAC;IAEP,qEAAqE;IACrE,MAAM,MAAM,GACR,OAAO,CAAC,MAAM;QACd,OAAO,CAAC,kBAAkB,CAAC;QAC3B,OAAO,CAAC,0BAA0B,CAAC;QACnC,MAAM,CAAC,kBAAkB,CAAC;QAC1B,MAAM,CAAC,0BAA0B,CAAC;QAClC,UAAU,EAAE,MAAM;QAClB,EAAE,CAAC;IAEP,MAAM,MAAM,GACR,OAAO,CAAC,MAAM;QACd,OAAO,CAAC,qBAAqB,CAAC;QAC9B,MAAM,CAAC,qBAAqB,CAAC;QAC7B,UAAU,EAAE,MAAM;QAClB,EAAE,CAAC;IAEP,0EAA0E;IAC1E,MAAM,OAAO,GAAa,EAAE,CAAC;IAC7B,IAAI,CAAC,SAAS;QAAE,OAAO,CAAC,IAAI,CAAC,2CAA2C,CAAC,CAAC;IAC1E,IAAI,CAAC,MAAM;QAAE,OAAO,CAAC,IAAI,CAAC,sCAAsC,CAAC,CAAC;IAClE,IAAI,CAAC,MAAM;QAAE,OAAO,CAAC,IAAI,CAAC,iCAAiC,CAAC,CAAC;IAE7D,IAAI,OAAO,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACrB,OAAO,CAAC,KAAK,CAAC,0BAA0B,CAAC,CAAC;QAC1C,KAAK,MAAM,CAAC,IAAI,OAAO;YAAE,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;QACjD,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IACpB,CAAC;IAED,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC;AACzC,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,kBAAkB,CAC9B,GAAY,EACZ,UAA+B;IAE/B,MAAM,IAAI,GAAG,GAAG,IAAI,eAAe,EAAE,CAAC;IAEtC,iEAAiE;IACjE,MAAM,MAAM,GAAG,oBAAoB,CAAC,IAAI,CAAC,CAAC;IAC1C,MAAM,UAAU,GAAG,MAAM,EAAE,SAAS,IAAI,EAAE,CAAC;IAE3C,uDAAuD;IACvD,MAAM,UAAU,GAAG,UAAU,EAAE,WAAW,IAAI,EAAE,CAAC;IAEjD,OAAO,EAAE,GAAG,UAAU,EAAE,GAAG,UAAU,EAAE,CAAC;AAC5C,CAAC"}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Locates the project root by walking up the directory tree.
|
|
3
|
-
*/
|
|
4
|
-
/**
|
|
5
|
-
* Walk up from cwd until a directory containing package.json, src/, or .git is found.
|
|
6
|
-
* Falls back to cwd when no such directory exists (e.g. in isolated test environments).
|
|
7
|
-
*/
|
|
8
|
-
export declare function findProjectRoot(): string;
|
|
9
|
-
//# sourceMappingURL=root.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"root.d.ts","sourceRoot":"","sources":["../../../src/config/config-internals/root.ts"],"names":[],"mappings":"AAAA;;GAEG;AAKH;;;GAGG;AACH,wBAAgB,eAAe,IAAI,MAAM,CAaxC"}
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Locates the project root by walking up the directory tree.
|
|
3
|
-
*/
|
|
4
|
-
import fs from 'fs';
|
|
5
|
-
import path from 'path';
|
|
6
|
-
/**
|
|
7
|
-
* Walk up from cwd until a directory containing package.json, src/, or .git is found.
|
|
8
|
-
* Falls back to cwd when no such directory exists (e.g. in isolated test environments).
|
|
9
|
-
*/
|
|
10
|
-
export function findProjectRoot() {
|
|
11
|
-
let current = process.cwd();
|
|
12
|
-
while (current !== '/') {
|
|
13
|
-
if (fs.existsSync(path.join(current, 'package.json')) ||
|
|
14
|
-
fs.existsSync(path.join(current, 'src')) ||
|
|
15
|
-
fs.existsSync(path.join(current, '.git'))) {
|
|
16
|
-
return current;
|
|
17
|
-
}
|
|
18
|
-
current = path.dirname(current);
|
|
19
|
-
}
|
|
20
|
-
return process.cwd();
|
|
21
|
-
}
|
|
22
|
-
//# sourceMappingURL=root.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"root.js","sourceRoot":"","sources":["../../../src/config/config-internals/root.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,MAAM,IAAI,CAAC;AACpB,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB;;;GAGG;AACH,MAAM,UAAU,eAAe;IAC3B,IAAI,OAAO,GAAG,OAAO,CAAC,GAAG,EAAE,CAAC;IAC5B,OAAO,OAAO,KAAK,GAAG,EAAE,CAAC;QACrB,IACI,EAAE,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,cAAc,CAAC,CAAC;YACjD,EAAE,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;YACxC,EAAE,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC,EAC3C,CAAC;YACC,OAAO,OAAO,CAAC;QACnB,CAAC;QACD,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;IACpC,CAAC;IACD,OAAO,OAAO,CAAC,GAAG,EAAE,CAAC;AACzB,CAAC"}
|
|
@@ -1,91 +0,0 @@
|
|
|
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
|
-
* Scan navigation config files (e.g. navigation.config.ts) for href values
|
|
73
|
-
* and automatically add them as preview routes for translation keys.
|
|
74
|
-
* This is useful for ensuring all app routes are available for previewing
|
|
75
|
-
* translations, especially for keys without explicit preview routes.
|
|
76
|
-
* @default false
|
|
77
|
-
*/
|
|
78
|
-
includeNavRoutes?: boolean;
|
|
79
|
-
}
|
|
80
|
-
/**
|
|
81
|
-
* Resolved runtime config passed to all CLI operations.
|
|
82
|
-
* All fields are required — resolveConfig() exits early if any are missing.
|
|
83
|
-
*/
|
|
84
|
-
export interface Config {
|
|
85
|
-
projectId: string;
|
|
86
|
-
apiKey: string;
|
|
87
|
-
cmsUrl: string;
|
|
88
|
-
}
|
|
89
|
-
/** Config filenames searched in order — first match wins. */
|
|
90
|
-
export declare const CONFIG_FILENAMES: readonly [".translationsrc.json", "translations.config.json"];
|
|
91
|
-
//# sourceMappingURL=types.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
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;IAEtB;;;;;;OAMG;IACH,gBAAgB,CAAC,EAAE,OAAO,CAAC;CAC9B;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"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/config/config-internals/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AAkGH,6DAA6D;AAC7D,MAAM,CAAC,MAAM,gBAAgB,GAAG;IAC5B,sBAAsB;IACtB,0BAA0B;CACpB,CAAC"}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
/**
|
|
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';
|
|
11
|
-
//# sourceMappingURL=resolve-config.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
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,EACH,aAAa,EACb,kBAAkB,GACrB,MAAM,+BAA+B,CAAC"}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Public API for config resolution.
|
|
3
|
-
* Implementation lives in config-internals/ — import from here, not from internals directly.
|
|
4
|
-
*/
|
|
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';
|
|
10
|
-
//# sourceMappingURL=resolve-config.js.map
|
|
@@ -1 +0,0 @@
|
|
|
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,EACH,aAAa,EACb,kBAAkB,GACrB,MAAM,+BAA+B,CAAC"}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Utility helper functions for API operations.
|
|
3
|
-
*/
|
|
4
|
-
/**
|
|
5
|
-
* Resolve a report path to an absolute path.
|
|
6
|
-
* If already absolute, returns as-is. Otherwise, resolves relative to root.
|
|
7
|
-
*/
|
|
8
|
-
export declare function resolveReportPath(root: string, reportPath: string): string;
|
|
9
|
-
//# sourceMappingURL=helpers.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"helpers.d.ts","sourceRoot":"","sources":["../../../src/core/api-internals/helpers.ts"],"names":[],"mappings":"AAAA;;GAEG;AAIH;;;GAGG;AACH,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,MAAM,CAI1E"}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Utility helper functions for API operations.
|
|
3
|
-
*/
|
|
4
|
-
import path from 'path';
|
|
5
|
-
/**
|
|
6
|
-
* Resolve a report path to an absolute path.
|
|
7
|
-
* If already absolute, returns as-is. Otherwise, resolves relative to root.
|
|
8
|
-
*/
|
|
9
|
-
export function resolveReportPath(root, reportPath) {
|
|
10
|
-
return path.isAbsolute(reportPath)
|
|
11
|
-
? reportPath
|
|
12
|
-
: path.join(root, reportPath);
|
|
13
|
-
}
|
|
14
|
-
//# sourceMappingURL=helpers.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"helpers.js","sourceRoot":"","sources":["../../../src/core/api-internals/helpers.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB;;;GAGG;AACH,MAAM,UAAU,iBAAiB,CAAC,IAAY,EAAE,UAAkB;IAC9D,OAAO,IAAI,CAAC,UAAU,CAAC,UAAU,CAAC;QAC9B,CAAC,CAAC,UAAU;QACZ,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,UAAU,CAAC,CAAC;AACtC,CAAC"}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Pull (fetch) published translations from CMS to local JSON files.
|
|
3
|
-
*/
|
|
4
|
-
import type { Config } from '../../config/resolve-config.js';
|
|
5
|
-
import type { PullOptions } from './types.js';
|
|
6
|
-
/**
|
|
7
|
-
* Fetch published translations from the CMS and write them to local JSON files.
|
|
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.
|
|
17
|
-
*/
|
|
18
|
-
export declare function pullTranslations(config: Config, opts: PullOptions): Promise<void>;
|
|
19
|
-
//# sourceMappingURL=pull.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
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"}
|