Skip to content

Commit e0a1bb3

Browse files
cherkanovartclaude
andauthored
fix(cli): add dev.usePseudotranslator to config schema (v1.14) (#2019)
* fix(cli): add dev.usePseudotranslator to config schema and respect it in setup The setup.ts changes from PR #1984 correctly check dev.usePseudotranslator, but the I18nConfig schema (v1.13) has no dev field — Zod strips it during parsing, making the check always undefined. This extends the schema to v1.14 with a dev.usePseudotranslator option so the config value actually reaches the CLI runtime. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * chore: add changeset for dev.usePseudotranslator Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 3f0d52f commit e0a1bb3

File tree

4 files changed

+63
-3
lines changed

4 files changed

+63
-3
lines changed

.changeset/pseudo-config-schema.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
"@lingo.dev/_spec": patch
3+
"lingo.dev": patch
4+
---
5+
6+
fix(cli): add dev.usePseudotranslator to config schema and respect it in CLI setup

packages/cli/src/cli/cmd/run/setup.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,8 @@ export default async function setup(input: CmdRunContext) {
5050
{
5151
title: "Selecting localization provider",
5252
task: async (ctx, task) => {
53-
const provider = ctx.flags.pseudo ? "pseudo" : ctx.config?.provider;
53+
const isPseudo = ctx.flags.pseudo || ctx.config?.dev?.usePseudotranslator;
54+
const provider = isPseudo ? "pseudo" : ctx.config?.provider;
5455
const vNext = ctx.config?.vNext;
5556
ctx.localizer = createLocalizer(provider, ctx.flags.apiKey, vNext);
5657
if (!ctx.localizer) {
@@ -72,7 +73,8 @@ export default async function setup(input: CmdRunContext) {
7273
enabled: (ctx) =>
7374
(ctx.localizer?.id === "Lingo.dev" ||
7475
ctx.localizer?.id === "Lingo.dev vNext") &&
75-
!ctx.flags.pseudo,
76+
!ctx.flags.pseudo &&
77+
!ctx.config?.dev?.usePseudotranslator,
7678
task: async (ctx, task) => {
7779
const authStatus = await ctx.localizer!.checkAuth();
7880
if (!authStatus.authenticated) {

packages/spec/src/config.spec.ts

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,30 @@ describe("I18n Config Parser", () => {
115115
expect(result).toEqual(createV1_4Config());
116116
});
117117

118+
it("should parse config with dev.usePseudotranslator", () => {
119+
const configWithDev = {
120+
...createV1_4Config(),
121+
version: "1.14",
122+
dev: {
123+
usePseudotranslator: true,
124+
},
125+
};
126+
const result = parseI18nConfig(configWithDev);
127+
128+
expect(result.dev?.usePseudotranslator).toBe(true);
129+
expect(result.version).toBe("1.14");
130+
});
131+
132+
it("should parse config without dev field", () => {
133+
const configWithoutDev = {
134+
...createV1_4Config(),
135+
version: "1.14",
136+
};
137+
const result = parseI18nConfig(configWithoutDev);
138+
139+
expect(result.dev).toBeUndefined();
140+
});
141+
118142
it("should throw an error for unsupported locales", () => {
119143
const invalidLocaleConfig = createInvalidLocaleConfig();
120144
expect(() => parseI18nConfig(invalidLocaleConfig)).toThrow(

packages/spec/src/config.ts

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -574,8 +574,36 @@ export const configV1_13Definition = extendConfigDefinition(
574574
},
575575
);
576576

577+
// v1.13 -> v1.14
578+
// Changes: Add "dev" field for development-specific settings
579+
const devSettingsSchema = Z.object({
580+
usePseudotranslator: Z.boolean()
581+
.optional()
582+
.describe(
583+
"Use pseudotranslator instead of real translation provider. Useful for testing i18n without API calls.",
584+
),
585+
}).describe("Development-specific settings.");
586+
587+
export const configV1_14Definition = extendConfigDefinition(
588+
configV1_13Definition,
589+
{
590+
createSchema: (baseSchema) =>
591+
baseSchema.extend({
592+
dev: devSettingsSchema.optional(),
593+
}),
594+
createDefaultValue: (baseDefaultValue) => ({
595+
...baseDefaultValue,
596+
version: "1.14",
597+
}),
598+
createUpgrader: (oldConfig) => ({
599+
...oldConfig,
600+
version: "1.14",
601+
}),
602+
},
603+
);
604+
577605
// exports
578-
export const LATEST_CONFIG_DEFINITION = configV1_13Definition;
606+
export const LATEST_CONFIG_DEFINITION = configV1_14Definition;
579607

580608
export type I18nConfig = Z.infer<(typeof LATEST_CONFIG_DEFINITION)["schema"]>;
581609

0 commit comments

Comments
 (0)