@tandem-language-exchange/content-store 1.2.3 → 1.2.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/client/fetch-merged-translation-bundles.js +11 -2
- package/dist/client/fetch-merged-translation-bundles.js.map +1 -1
- package/dist/client/fetch-translation-bundles.js +11 -2
- package/dist/client/fetch-translation-bundles.js.map +1 -1
- package/dist/client/list-resources.js +31 -5
- package/dist/client/list-resources.js.map +1 -1
- package/package.json +1 -1
|
@@ -10,7 +10,9 @@ import "../chunk-4DE47ZJD.js";
|
|
|
10
10
|
import {
|
|
11
11
|
ContentStore
|
|
12
12
|
} from "../chunk-5WQPK6GZ.js";
|
|
13
|
-
import
|
|
13
|
+
import {
|
|
14
|
+
allProjects
|
|
15
|
+
} from "../chunk-HXG3MIJG.js";
|
|
14
16
|
|
|
15
17
|
// src/client/fetch-merged-translation-bundles.ts
|
|
16
18
|
import fs from "fs";
|
|
@@ -33,7 +35,14 @@ program.name("fetch-merged-translation-bundles").description(
|
|
|
33
35
|
const store = new ContentStore(config.s3);
|
|
34
36
|
try {
|
|
35
37
|
const files = await fetchMergedTranslationBundles(store, opts.output, filterConfig);
|
|
36
|
-
console.log("
|
|
38
|
+
console.log("\nSynced translations from:");
|
|
39
|
+
for (const [project, resourceFilter] of Object.entries(filterConfig.projects)) {
|
|
40
|
+
const all = allProjects[project];
|
|
41
|
+
if (!all?.length) continue;
|
|
42
|
+
const names = resourceFilter.length ? resourceFilter.filter((r) => all.some((a) => a.resource === r)) : all.map((a) => a.resource);
|
|
43
|
+
console.log(` - ${project}: (${names.join(", ")})`);
|
|
44
|
+
}
|
|
45
|
+
console.log("\nWrote merged translation files:");
|
|
37
46
|
for (const [locale, filePath] of Object.entries(files)) {
|
|
38
47
|
console.log(` ${locale}.json -> ${filePath}`);
|
|
39
48
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/client/fetch-merged-translation-bundles.ts"],"sourcesContent":["import fs from 'node:fs';\nimport { Command } from 'commander';\nimport { config } from './config';\nimport { ContentStore } from '../shared/s3';\nimport { fetchMergedTranslationBundles, type TranslationFilterConfig } from '../shared/bundles';\n\nconst program = new Command();\n\nprogram\n .name('fetch-merged-translation-bundles')\n .description(\n 'Download translation bundles from S3 and write one merged {locale}.json per locale.\\n\\n' +\n 'Accepts a JSON config file that specifies projects, resources, and locales.\\n' +\n 'Example config:\\n' +\n ' { \"projects\": { \"tandem\": [], \"tandem-(website)\": [\"main\",\"ai\"] }, \"locales\": [\"en\",\"de\"] }',\n )\n .requiredOption(\n '--config <filepath>',\n 'Path to a JSON config file defining projects, resources, and locales',\n )\n .option('--output <directory>', 'Output directory', './content-cache')\n .action(\n async (opts: { config: string; output: string }) => {\n let filterConfig: TranslationFilterConfig;\n try {\n filterConfig = JSON.parse(fs.readFileSync(opts.config, 'utf-8'));\n } catch (err) {\n console.error(`Failed to read config file \"${opts.config}\":`, err);\n process.exit(1);\n }\n\n const store = new ContentStore(config.s3);\n\n try {\n const files = await fetchMergedTranslationBundles(store, opts.output, filterConfig);\n\n console.log('
|
|
1
|
+
{"version":3,"sources":["../../src/client/fetch-merged-translation-bundles.ts"],"sourcesContent":["import fs from 'node:fs';\nimport { Command } from 'commander';\nimport { config } from './config';\nimport { ContentStore } from '../shared/s3';\nimport { fetchMergedTranslationBundles, type TranslationFilterConfig } from '../shared/bundles';\nimport { allProjects } from '../shared/lingohub';\n\nconst program = new Command();\n\nprogram\n .name('fetch-merged-translation-bundles')\n .description(\n 'Download translation bundles from S3 and write one merged {locale}.json per locale.\\n\\n' +\n 'Accepts a JSON config file that specifies projects, resources, and locales.\\n' +\n 'Example config:\\n' +\n ' { \"projects\": { \"tandem\": [], \"tandem-(website)\": [\"main\",\"ai\"] }, \"locales\": [\"en\",\"de\"] }',\n )\n .requiredOption(\n '--config <filepath>',\n 'Path to a JSON config file defining projects, resources, and locales',\n )\n .option('--output <directory>', 'Output directory', './content-cache')\n .action(\n async (opts: { config: string; output: string }) => {\n let filterConfig: TranslationFilterConfig;\n try {\n filterConfig = JSON.parse(fs.readFileSync(opts.config, 'utf-8'));\n } catch (err) {\n console.error(`Failed to read config file \"${opts.config}\":`, err);\n process.exit(1);\n }\n\n const store = new ContentStore(config.s3);\n\n try {\n const files = await fetchMergedTranslationBundles(store, opts.output, filterConfig);\n\n console.log('\\nSynced translations from:');\n for (const [project, resourceFilter] of Object.entries(filterConfig.projects)) {\n const all = allProjects[project];\n if (!all?.length) continue;\n const names = resourceFilter.length\n ? resourceFilter.filter((r) => all.some((a) => a.resource === r))\n : all.map((a) => a.resource);\n console.log(` - ${project}: (${names.join(', ')})`);\n }\n\n console.log('\\nWrote merged translation files:');\n for (const [locale, filePath] of Object.entries(files)) {\n console.log(` ${locale}.json -> ${filePath}`);\n }\n } catch (err) {\n console.error('Fetch failed:', err);\n process.exit(1);\n }\n },\n );\n\nprogram.parse();\n"],"mappings":";;;;;;;;;;;;;;;;;AAAA,OAAO,QAAQ;AACf,SAAS,eAAe;AAMxB,IAAM,UAAU,IAAI,QAAQ;AAE5B,QACG,KAAK,kCAAkC,EACvC;AAAA,EACC;AAIF,EACC;AAAA,EACC;AAAA,EACA;AACF,EACC,OAAO,wBAAwB,oBAAoB,iBAAiB,EACpE;AAAA,EACC,OAAO,SAA6C;AAClD,QAAI;AACJ,QAAI;AACF,qBAAe,KAAK,MAAM,GAAG,aAAa,KAAK,QAAQ,OAAO,CAAC;AAAA,IACjE,SAAS,KAAK;AACZ,cAAQ,MAAM,+BAA+B,KAAK,MAAM,MAAM,GAAG;AACjE,cAAQ,KAAK,CAAC;AAAA,IAChB;AAEA,UAAM,QAAQ,IAAI,aAAa,OAAO,EAAE;AAExC,QAAI;AACF,YAAM,QAAQ,MAAM,8BAA8B,OAAO,KAAK,QAAQ,YAAY;AAElF,cAAQ,IAAI,6BAA6B;AACzC,iBAAW,CAAC,SAAS,cAAc,KAAK,OAAO,QAAQ,aAAa,QAAQ,GAAG;AAC7E,cAAM,MAAM,YAAY,OAAO;AAC/B,YAAI,CAAC,KAAK,OAAQ;AAClB,cAAM,QAAQ,eAAe,SACvB,eAAe,OAAO,CAAC,MAAM,IAAI,KAAK,CAAC,MAAM,EAAE,aAAa,CAAC,CAAC,IAC9D,IAAI,IAAI,CAAC,MAAM,EAAE,QAAQ;AAC/B,gBAAQ,IAAI,OAAO,OAAO,MAAM,MAAM,KAAK,IAAI,CAAC,GAAG;AAAA,MACrD;AAEA,cAAQ,IAAI,mCAAmC;AAC/C,iBAAW,CAAC,QAAQ,QAAQ,KAAK,OAAO,QAAQ,KAAK,GAAG;AACtD,gBAAQ,IAAI,KAAK,MAAM,YAAY,QAAQ,EAAE;AAAA,MAC/C;AAAA,IACF,SAAS,KAAK;AACZ,cAAQ,MAAM,iBAAiB,GAAG;AAClC,cAAQ,KAAK,CAAC;AAAA,IAChB;AAAA,EACF;AACF;AAEF,QAAQ,MAAM;","names":[]}
|
|
@@ -10,7 +10,9 @@ import "../chunk-4DE47ZJD.js";
|
|
|
10
10
|
import {
|
|
11
11
|
ContentStore
|
|
12
12
|
} from "../chunk-5WQPK6GZ.js";
|
|
13
|
-
import
|
|
13
|
+
import {
|
|
14
|
+
allProjects
|
|
15
|
+
} from "../chunk-HXG3MIJG.js";
|
|
14
16
|
|
|
15
17
|
// src/client/fetch-translation-bundles.ts
|
|
16
18
|
import fs from "fs";
|
|
@@ -32,7 +34,14 @@ program.name("fetch-translation-bundles").description(
|
|
|
32
34
|
const store = new ContentStore(config.s3);
|
|
33
35
|
try {
|
|
34
36
|
const files = await fetchTranslationBundles(store, opts.output, filterConfig);
|
|
35
|
-
console.log("
|
|
37
|
+
console.log("\nSynced translations from:");
|
|
38
|
+
for (const [project, resourceFilter] of Object.entries(filterConfig.projects)) {
|
|
39
|
+
const all = allProjects[project];
|
|
40
|
+
if (!all?.length) continue;
|
|
41
|
+
const names = resourceFilter.length ? resourceFilter.filter((r) => all.some((a) => a.resource === r)) : all.map((a) => a.resource);
|
|
42
|
+
console.log(` - ${project}: (${names.join(", ")})`);
|
|
43
|
+
}
|
|
44
|
+
console.log("\nFetched bundles:");
|
|
36
45
|
for (const [project, pathsByKey] of Object.entries(files)) {
|
|
37
46
|
console.log(` ${project}:`);
|
|
38
47
|
for (const [objectKey, filePath] of Object.entries(pathsByKey)) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/client/fetch-translation-bundles.ts"],"sourcesContent":["import fs from 'node:fs';\nimport { Command } from 'commander';\nimport { config } from './config';\nimport { ContentStore } from '../shared/s3';\nimport { fetchTranslationBundles, type TranslationFilterConfig } from '../shared/bundles';\n\nconst program = new Command();\n\nprogram\n .name('fetch-translation-bundles')\n .description(\n 'Download latest translation bundles from S3 to the local filesystem.\\n\\n' +\n 'Accepts a JSON config file that specifies projects, resources, and locales.\\n' +\n 'Example config:\\n' +\n ' { \"projects\": { \"tandem\": [], \"tandem-(website)\": [\"main\",\"ai\"] }, \"locales\": [\"en\",\"de\"] }',\n )\n .requiredOption(\n '--config <filepath>',\n 'Path to a JSON config file defining projects, resources, and locales',\n )\n .option('--output <directory>', 'Output directory', './content-cache')\n .action(async (opts: { config: string; output: string }) => {\n let filterConfig: TranslationFilterConfig;\n try {\n filterConfig = JSON.parse(fs.readFileSync(opts.config, 'utf-8'));\n } catch (err) {\n console.error(`Failed to read config file \"${opts.config}\":`, err);\n process.exit(1);\n }\n\n const store = new ContentStore(config.s3);\n\n try {\n const files = await fetchTranslationBundles(store, opts.output, filterConfig);\n\n console.log('
|
|
1
|
+
{"version":3,"sources":["../../src/client/fetch-translation-bundles.ts"],"sourcesContent":["import fs from 'node:fs';\nimport { Command } from 'commander';\nimport { config } from './config';\nimport { ContentStore } from '../shared/s3';\nimport { fetchTranslationBundles, type TranslationFilterConfig } from '../shared/bundles';\nimport { allProjects } from '../shared/lingohub';\n\nconst program = new Command();\n\nprogram\n .name('fetch-translation-bundles')\n .description(\n 'Download latest translation bundles from S3 to the local filesystem.\\n\\n' +\n 'Accepts a JSON config file that specifies projects, resources, and locales.\\n' +\n 'Example config:\\n' +\n ' { \"projects\": { \"tandem\": [], \"tandem-(website)\": [\"main\",\"ai\"] }, \"locales\": [\"en\",\"de\"] }',\n )\n .requiredOption(\n '--config <filepath>',\n 'Path to a JSON config file defining projects, resources, and locales',\n )\n .option('--output <directory>', 'Output directory', './content-cache')\n .action(async (opts: { config: string; output: string }) => {\n let filterConfig: TranslationFilterConfig;\n try {\n filterConfig = JSON.parse(fs.readFileSync(opts.config, 'utf-8'));\n } catch (err) {\n console.error(`Failed to read config file \"${opts.config}\":`, err);\n process.exit(1);\n }\n\n const store = new ContentStore(config.s3);\n\n try {\n const files = await fetchTranslationBundles(store, opts.output, filterConfig);\n\n console.log('\\nSynced translations from:');\n for (const [project, resourceFilter] of Object.entries(filterConfig.projects)) {\n const all = allProjects[project];\n if (!all?.length) continue;\n const names = resourceFilter.length\n ? resourceFilter.filter((r) => all.some((a) => a.resource === r))\n : all.map((a) => a.resource);\n console.log(` - ${project}: (${names.join(', ')})`);\n }\n\n console.log('\\nFetched bundles:');\n for (const [project, pathsByKey] of Object.entries(files)) {\n console.log(` ${project}:`);\n for (const [objectKey, filePath] of Object.entries(pathsByKey)) {\n console.log(` ${objectKey} -> ${filePath}`);\n }\n }\n } catch (err) {\n console.error('Fetch failed:', err);\n process.exit(1);\n }\n });\n\nprogram.parse();"],"mappings":";;;;;;;;;;;;;;;;;AAAA,OAAO,QAAQ;AACf,SAAS,eAAe;AAMxB,IAAM,UAAU,IAAI,QAAQ;AAE5B,QACK,KAAK,2BAA2B,EAChC;AAAA,EACC;AAIF,EACC;AAAA,EACC;AAAA,EACA;AACF,EACC,OAAO,wBAAwB,oBAAoB,iBAAiB,EACpE,OAAO,OAAO,SAA6C;AACxD,MAAI;AACJ,MAAI;AACA,mBAAe,KAAK,MAAM,GAAG,aAAa,KAAK,QAAQ,OAAO,CAAC;AAAA,EACnE,SAAS,KAAK;AACV,YAAQ,MAAM,+BAA+B,KAAK,MAAM,MAAM,GAAG;AACjE,YAAQ,KAAK,CAAC;AAAA,EAClB;AAEA,QAAM,QAAQ,IAAI,aAAa,OAAO,EAAE;AAExC,MAAI;AACA,UAAM,QAAQ,MAAM,wBAAwB,OAAO,KAAK,QAAQ,YAAY;AAE5E,YAAQ,IAAI,6BAA6B;AACzC,eAAW,CAAC,SAAS,cAAc,KAAK,OAAO,QAAQ,aAAa,QAAQ,GAAG;AAC3E,YAAM,MAAM,YAAY,OAAO;AAC/B,UAAI,CAAC,KAAK,OAAQ;AAClB,YAAM,QAAQ,eAAe,SACvB,eAAe,OAAO,CAAC,MAAM,IAAI,KAAK,CAAC,MAAM,EAAE,aAAa,CAAC,CAAC,IAC9D,IAAI,IAAI,CAAC,MAAM,EAAE,QAAQ;AAC/B,cAAQ,IAAI,OAAO,OAAO,MAAM,MAAM,KAAK,IAAI,CAAC,GAAG;AAAA,IACvD;AAEA,YAAQ,IAAI,oBAAoB;AAChC,eAAW,CAAC,SAAS,UAAU,KAAK,OAAO,QAAQ,KAAK,GAAG;AACvD,cAAQ,IAAI,KAAK,OAAO,GAAG;AAC3B,iBAAW,CAAC,WAAW,QAAQ,KAAK,OAAO,QAAQ,UAAU,GAAG;AAC5D,gBAAQ,IAAI,OAAO,SAAS,OAAO,QAAQ,EAAE;AAAA,MACjD;AAAA,IACJ;AAAA,EACJ,SAAS,KAAK;AACV,YAAQ,MAAM,iBAAiB,GAAG;AAClC,YAAQ,KAAK,CAAC;AAAA,EAClB;AACJ,CAAC;AAEL,QAAQ,MAAM;","names":[]}
|
|
@@ -4,17 +4,43 @@ import {
|
|
|
4
4
|
} from "../chunk-HXG3MIJG.js";
|
|
5
5
|
|
|
6
6
|
// src/client/list-resources.ts
|
|
7
|
+
import { createInterface } from "readline/promises";
|
|
7
8
|
import { Command } from "commander";
|
|
8
|
-
var
|
|
9
|
-
|
|
9
|
+
var projectNames = Object.keys(allProjects);
|
|
10
|
+
function printResources(project) {
|
|
10
11
|
const resources = allProjects[project];
|
|
11
12
|
if (!resources) {
|
|
12
|
-
|
|
13
|
-
console.error(`Unknown project "${project}". Available projects: ${available}`);
|
|
13
|
+
console.error(`Unknown project "${project}".`);
|
|
14
14
|
process.exit(1);
|
|
15
15
|
}
|
|
16
|
+
console.log(`
|
|
17
|
+
Resources for "${project}":
|
|
18
|
+
`);
|
|
16
19
|
for (const r of resources) {
|
|
17
|
-
console.log(r.resource);
|
|
20
|
+
console.log(` ${r.resource}`);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
async function promptForProject() {
|
|
24
|
+
console.log("Available projects:\n");
|
|
25
|
+
for (let i = 0; i < projectNames.length; i++) {
|
|
26
|
+
console.log(` ${i + 1}. ${projectNames[i]}`);
|
|
27
|
+
}
|
|
28
|
+
const rl = createInterface({ input: process.stdin, output: process.stdout });
|
|
29
|
+
const answer = await rl.question("\nSelect a project number: ");
|
|
30
|
+
rl.close();
|
|
31
|
+
const idx = parseInt(answer, 10) - 1;
|
|
32
|
+
if (isNaN(idx) || idx < 0 || idx >= projectNames.length) {
|
|
33
|
+
console.error(`Invalid selection "${answer}". Enter a number between 1 and ${projectNames.length}.`);
|
|
34
|
+
process.exit(1);
|
|
35
|
+
}
|
|
36
|
+
printResources(projectNames[idx]);
|
|
37
|
+
}
|
|
38
|
+
var program = new Command();
|
|
39
|
+
program.name("list-resources").description("List all resource names for a given Lingohub project").argument("[project]", "Lingohub project name (omit for interactive selection)").action(async (project) => {
|
|
40
|
+
if (project) {
|
|
41
|
+
printResources(project);
|
|
42
|
+
} else {
|
|
43
|
+
await promptForProject();
|
|
18
44
|
}
|
|
19
45
|
});
|
|
20
46
|
program.parse();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/client/list-resources.ts"],"sourcesContent":["import { Command } from 'commander';\nimport { allProjects } from '../shared/lingohub';\n\nconst
|
|
1
|
+
{"version":3,"sources":["../../src/client/list-resources.ts"],"sourcesContent":["import { createInterface } from 'node:readline/promises';\nimport { Command } from 'commander';\nimport { allProjects } from '../shared/lingohub';\n\nconst projectNames = Object.keys(allProjects);\n\nfunction printResources(project: string): void {\n const resources = allProjects[project];\n if (!resources) {\n console.error(`Unknown project \"${project}\".`);\n process.exit(1);\n }\n console.log(`\\nResources for \"${project}\":\\n`);\n for (const r of resources) {\n console.log(` ${r.resource}`);\n }\n}\n\nasync function promptForProject(): Promise<void> {\n console.log('Available projects:\\n');\n for (let i = 0; i < projectNames.length; i++) {\n console.log(` ${i + 1}. ${projectNames[i]}`);\n }\n\n const rl = createInterface({ input: process.stdin, output: process.stdout });\n const answer = await rl.question('\\nSelect a project number: ');\n rl.close();\n\n const idx = parseInt(answer, 10) - 1;\n if (isNaN(idx) || idx < 0 || idx >= projectNames.length) {\n console.error(`Invalid selection \"${answer}\". Enter a number between 1 and ${projectNames.length}.`);\n process.exit(1);\n }\n\n printResources(projectNames[idx]!);\n}\n\nconst program = new Command();\n\nprogram\n .name('list-resources')\n .description('List all resource names for a given Lingohub project')\n .argument('[project]', 'Lingohub project name (omit for interactive selection)')\n .action(async (project?: string) => {\n if (project) {\n printResources(project);\n } else {\n await promptForProject();\n }\n });\n\nprogram.parse();\n"],"mappings":";;;;;;AAAA,SAAS,uBAAuB;AAChC,SAAS,eAAe;AAGxB,IAAM,eAAe,OAAO,KAAK,WAAW;AAE5C,SAAS,eAAe,SAAuB;AAC3C,QAAM,YAAY,YAAY,OAAO;AACrC,MAAI,CAAC,WAAW;AACZ,YAAQ,MAAM,oBAAoB,OAAO,IAAI;AAC7C,YAAQ,KAAK,CAAC;AAAA,EAClB;AACA,UAAQ,IAAI;AAAA,iBAAoB,OAAO;AAAA,CAAM;AAC7C,aAAW,KAAK,WAAW;AACvB,YAAQ,IAAI,KAAK,EAAE,QAAQ,EAAE;AAAA,EACjC;AACJ;AAEA,eAAe,mBAAkC;AAC7C,UAAQ,IAAI,uBAAuB;AACnC,WAAS,IAAI,GAAG,IAAI,aAAa,QAAQ,KAAK;AAC1C,YAAQ,IAAI,KAAK,IAAI,CAAC,KAAK,aAAa,CAAC,CAAC,EAAE;AAAA,EAChD;AAEA,QAAM,KAAK,gBAAgB,EAAE,OAAO,QAAQ,OAAO,QAAQ,QAAQ,OAAO,CAAC;AAC3E,QAAM,SAAS,MAAM,GAAG,SAAS,6BAA6B;AAC9D,KAAG,MAAM;AAET,QAAM,MAAM,SAAS,QAAQ,EAAE,IAAI;AACnC,MAAI,MAAM,GAAG,KAAK,MAAM,KAAK,OAAO,aAAa,QAAQ;AACrD,YAAQ,MAAM,sBAAsB,MAAM,mCAAmC,aAAa,MAAM,GAAG;AACnG,YAAQ,KAAK,CAAC;AAAA,EAClB;AAEA,iBAAe,aAAa,GAAG,CAAE;AACrC;AAEA,IAAM,UAAU,IAAI,QAAQ;AAE5B,QACK,KAAK,gBAAgB,EACrB,YAAY,sDAAsD,EAClE,SAAS,aAAa,wDAAwD,EAC9E,OAAO,OAAO,YAAqB;AAChC,MAAI,SAAS;AACT,mBAAe,OAAO;AAAA,EAC1B,OAAO;AACH,UAAM,iBAAiB;AAAA,EAC3B;AACJ,CAAC;AAEL,QAAQ,MAAM;","names":[]}
|