lingo.dev 0.75.1 → 0.77.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/cli.cjs +74 -20
- package/build/cli.cjs.map +1 -1
- package/build/cli.mjs +74 -20
- package/build/cli.mjs.map +1 -1
- package/package.json +2 -1
package/build/cli.cjs
CHANGED
|
@@ -325,8 +325,7 @@ function findLocaleFilesWithExtension(ext) {
|
|
|
325
325
|
return { file, locale: null };
|
|
326
326
|
}).filter(({ locale }) => locale !== null);
|
|
327
327
|
const localeFilesAndPatterns = potantialLocaleFilesAndPatterns.map(({ file, locale }) => {
|
|
328
|
-
const
|
|
329
|
-
const pattern = localeInDir ? file.replace(`/${locale}/`, `/[locale]/`) : _path2.default.join(_path2.default.dirname(file), `[locale]${ext}`);
|
|
328
|
+
const pattern = file.replaceAll(new RegExp(`/${locale}${ext}`, "g"), `/[locale]${ext}`).replaceAll(new RegExp(`/${locale}/`, "g"), `/[locale]/`).replaceAll(new RegExp(`/${locale}/`, "g"), `/[locale]/`);
|
|
330
329
|
return { pattern, file };
|
|
331
330
|
});
|
|
332
331
|
const grouppedFilesAndPatterns = _lodash2.default.groupBy(localeFilesAndPatterns, "pattern");
|
|
@@ -698,24 +697,25 @@ function expandPlaceholderedGlob(_pathPattern, sourceLocale) {
|
|
|
698
697
|
docUrl: "invalidPathPattern"
|
|
699
698
|
});
|
|
700
699
|
}
|
|
701
|
-
if (pathPattern.split("[locale]").length > 2) {
|
|
702
|
-
throw new CLIError({
|
|
703
|
-
message: `Invalid path pattern: ${pathPattern}. Path pattern must contain at most one "[locale]" placeholder.`,
|
|
704
|
-
docUrl: "invalidPathPattern"
|
|
705
|
-
});
|
|
706
|
-
}
|
|
707
700
|
const pathPatternChunks = pathPattern.split(_path2.default.sep);
|
|
708
|
-
const
|
|
709
|
-
|
|
710
|
-
|
|
701
|
+
const localeSegmentIndexes = pathPatternChunks.reduce((indexes, segment, index) => {
|
|
702
|
+
if (segment.includes("[locale]")) {
|
|
703
|
+
indexes.push(index);
|
|
704
|
+
}
|
|
705
|
+
return indexes;
|
|
706
|
+
}, []);
|
|
707
|
+
const sourcePathPattern = pathPattern.replaceAll(/\[locale\]/g, sourceLocale);
|
|
711
708
|
const sourcePaths = glob2.sync(sourcePathPattern, { follow: true, withFileTypes: true }).filter((file) => file.isFile() || file.isSymbolicLink()).map((file) => file.fullpath()).map((fullpath) => _path2.default.relative(process.cwd(), fullpath));
|
|
712
709
|
const placeholderedPaths = sourcePaths.map((sourcePath) => {
|
|
713
710
|
const sourcePathChunks = sourcePath.split(_path2.default.sep);
|
|
714
|
-
|
|
715
|
-
const
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
711
|
+
localeSegmentIndexes.forEach((localeSegmentIndex) => {
|
|
712
|
+
const localePlaceholderIndex = _nullishCoalesce(_optionalChain([pathPatternChunks, 'access', _35 => _35[localeSegmentIndex], 'optionalAccess', _36 => _36.indexOf, 'call', _37 => _37("[locale]")]), () => ( -1));
|
|
713
|
+
if (localeSegmentIndex >= 0 && localePlaceholderIndex >= 0) {
|
|
714
|
+
const placeholderedPathChunk = sourcePathChunks[localeSegmentIndex];
|
|
715
|
+
const placeholderedSegment = placeholderedPathChunk.substring(0, localePlaceholderIndex) + "[locale]" + placeholderedPathChunk.substring(localePlaceholderIndex + sourceLocale.length);
|
|
716
|
+
sourcePathChunks[localeSegmentIndex] = placeholderedSegment;
|
|
717
|
+
}
|
|
718
|
+
});
|
|
719
719
|
const placeholderedPath = sourcePathChunks.join(_path2.default.sep);
|
|
720
720
|
return placeholderedPath;
|
|
721
721
|
});
|
|
@@ -991,7 +991,7 @@ function createTextFileLoader(pathPattern) {
|
|
|
991
991
|
return trimmedResult;
|
|
992
992
|
},
|
|
993
993
|
async push(locale, data, _21, originalLocale) {
|
|
994
|
-
const draftPath = pathPattern.
|
|
994
|
+
const draftPath = pathPattern.replaceAll("[locale]", locale);
|
|
995
995
|
const finalPath = _path2.default.resolve(draftPath);
|
|
996
996
|
const dirPath = _path2.default.dirname(finalPath);
|
|
997
997
|
await _promises4.default.mkdir(dirPath, { recursive: true });
|
|
@@ -1006,7 +1006,7 @@ function createTextFileLoader(pathPattern) {
|
|
|
1006
1006
|
});
|
|
1007
1007
|
}
|
|
1008
1008
|
async function readFileForLocale(pathPattern, locale) {
|
|
1009
|
-
const draftPath = pathPattern.
|
|
1009
|
+
const draftPath = pathPattern.replaceAll("[locale]", locale);
|
|
1010
1010
|
const finalPath = _path2.default.resolve(draftPath);
|
|
1011
1011
|
const exists = await _promises4.default.access(finalPath).then(() => true).catch(() => false);
|
|
1012
1012
|
if (!exists) {
|
|
@@ -3517,10 +3517,63 @@ function displaySummary(results) {
|
|
|
3517
3517
|
});
|
|
3518
3518
|
}
|
|
3519
3519
|
|
|
3520
|
+
// src/cli/cmd/mcp.ts
|
|
3521
|
+
|
|
3522
|
+
var _stdiojs = require('@modelcontextprotocol/sdk/server/stdio.js');
|
|
3523
|
+
var _mcpjs = require('@modelcontextprotocol/sdk/server/mcp.js');
|
|
3524
|
+
|
|
3525
|
+
|
|
3526
|
+
var mcp_default = new (0, _interactivecommander.Command)().command("mcp").description("Use Lingo.dev model context provider with your AI agent").helpOption("-h, --help", "Show help").action(async (_21, program) => {
|
|
3527
|
+
const apiKey = program.args[0];
|
|
3528
|
+
const settings = getSettings(apiKey);
|
|
3529
|
+
if (!settings.auth.apiKey) {
|
|
3530
|
+
console.error("No API key provided");
|
|
3531
|
+
return;
|
|
3532
|
+
}
|
|
3533
|
+
const authenticator = createAuthenticator({
|
|
3534
|
+
apiUrl: settings.auth.apiUrl,
|
|
3535
|
+
apiKey: settings.auth.apiKey
|
|
3536
|
+
});
|
|
3537
|
+
const auth = await authenticator.whoami();
|
|
3538
|
+
if (!auth) {
|
|
3539
|
+
console.error("Not authenticated");
|
|
3540
|
+
return;
|
|
3541
|
+
} else {
|
|
3542
|
+
console.log(`Authenticated as ${auth.email}`);
|
|
3543
|
+
}
|
|
3544
|
+
const replexicaEngine = new (0, __sdk.ReplexicaEngine)({
|
|
3545
|
+
apiKey: settings.auth.apiKey,
|
|
3546
|
+
apiUrl: settings.auth.apiUrl
|
|
3547
|
+
});
|
|
3548
|
+
const server = new (0, _mcpjs.McpServer)({
|
|
3549
|
+
name: "Lingo.dev",
|
|
3550
|
+
version: "1.0.0"
|
|
3551
|
+
});
|
|
3552
|
+
server.tool(
|
|
3553
|
+
"translate",
|
|
3554
|
+
"Detect language and translate text with Lingo.dev.",
|
|
3555
|
+
{
|
|
3556
|
+
text: _zod2.default.string(),
|
|
3557
|
+
targetLocale: _zod2.default.string().regex(/^[a-z]{2}(-[A-Z]{2})?$/)
|
|
3558
|
+
},
|
|
3559
|
+
async ({ text, targetLocale }) => {
|
|
3560
|
+
const sourceLocale = await replexicaEngine.recognizeLocale(text);
|
|
3561
|
+
const data = await replexicaEngine.localizeText(text, {
|
|
3562
|
+
sourceLocale,
|
|
3563
|
+
targetLocale
|
|
3564
|
+
});
|
|
3565
|
+
return { content: [{ type: "text", text: data }] };
|
|
3566
|
+
}
|
|
3567
|
+
);
|
|
3568
|
+
const transport = new (0, _stdiojs.StdioServerTransport)();
|
|
3569
|
+
await server.connect(transport);
|
|
3570
|
+
console.log("Lingo.dev MCP Server running on stdio");
|
|
3571
|
+
});
|
|
3572
|
+
|
|
3520
3573
|
// package.json
|
|
3521
3574
|
var package_default = {
|
|
3522
3575
|
name: "lingo.dev",
|
|
3523
|
-
version: "0.
|
|
3576
|
+
version: "0.77.0",
|
|
3524
3577
|
description: "Lingo.dev CLI",
|
|
3525
3578
|
private: false,
|
|
3526
3579
|
publishConfig: {
|
|
@@ -3568,6 +3621,7 @@ var package_default = {
|
|
|
3568
3621
|
"@inquirer/prompts": "^7.2.3",
|
|
3569
3622
|
"@lingo.dev/_sdk": "workspace:*",
|
|
3570
3623
|
"@lingo.dev/_spec": "workspace:*",
|
|
3624
|
+
"@modelcontextprotocol/sdk": "^1.5.0",
|
|
3571
3625
|
"@paralleldrive/cuid2": "^2.2.2",
|
|
3572
3626
|
chalk: "^5.4.1",
|
|
3573
3627
|
cors: "^2.8.5",
|
|
@@ -3657,7 +3711,7 @@ ${_gradientstring.vice.call(void 0,
|
|
|
3657
3711
|
|
|
3658
3712
|
Website: https://lingo.dev
|
|
3659
3713
|
`
|
|
3660
|
-
).version(`v${package_default.version}`, "-v, --version", "Show version").addCommand(init_default).interactive("-y, --no-interactive", "Disable interactive mode").addCommand(i18n_default).addCommand(auth_default).addCommand(show_default).addCommand(lockfile_default).addCommand(cleanup_default).exitOverride((err) => {
|
|
3714
|
+
).version(`v${package_default.version}`, "-v, --version", "Show version").addCommand(init_default).interactive("-y, --no-interactive", "Disable interactive mode").addCommand(i18n_default).addCommand(auth_default).addCommand(show_default).addCommand(lockfile_default).addCommand(cleanup_default).addCommand(mcp_default).exitOverride((err) => {
|
|
3661
3715
|
if (err.code === "commander.helpDisplayed" || err.code === "commander.version" || err.code === "commander.help") {
|
|
3662
3716
|
process.exit(0);
|
|
3663
3717
|
}
|