Skip to content

Commit d5bc0b0

Browse files
authored
feat(cli): warn on every run that lingo.dev is replaced by @lingo.dev/cli (#2272)
* feat(cli): warn on every run that lingo.dev is replaced by @lingo.dev/cli Every run prints, to stderr, that lingo.dev is replaced by @lingo.dev/cli, that support ends at the end of 2026, the migrate command and the migration guide link. Under GitHub Actions the same text is also emitted once as a ::warning:: annotation so it shows in pull request checks. Commands that clear the screen print the notice again after clearing in a terminal. * chore: rerun pull request checks
1 parent b3fba7d commit d5bc0b0

5 files changed

Lines changed: 77 additions & 0 deletions

File tree

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"lingo.dev": patch
3+
---
4+
5+
Print a notice on every run that `lingo.dev` is replaced by `@lingo.dev/cli`, that support for this package ends at the end of 2026, and how to migrate (`npx @lingo.dev/cli migrate` and https://lingo.dev/docs/devtools/cli/migration). The notice goes to stderr, so machine-readable stdout stays clean. Under GitHub Actions it is also added as a warning annotation, so it shows in pull request checks.

‎packages/cli/src/cli/index.ts‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
import { loadDotenv } from "./utils/env";
2+
import { announceReplacement } from "./utils/replacement-notice";
23
loadDotenv();
4+
announceReplacement();
35

46
import { InteractiveCommand } from "interactive-commander";
57
import figlet from "figlet";
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
import { afterEach, describe, expect, it, vi } from "vitest";
2+
import { announceReplacement } from "./replacement-notice";
3+
4+
function runAnnouncement(githubActions: string) {
5+
vi.stubEnv("GITHUB_ACTIONS", githubActions);
6+
const stdoutWrite = vi
7+
.spyOn(process.stdout, "write")
8+
.mockImplementation(() => true);
9+
const log = vi.spyOn(console, "log").mockImplementation(() => {});
10+
const info = vi.spyOn(console, "info").mockImplementation(() => {});
11+
const warn = vi.spyOn(console, "warn").mockImplementation(() => {});
12+
13+
announceReplacement();
14+
15+
return {
16+
stdoutCalls:
17+
stdoutWrite.mock.calls.length +
18+
log.mock.calls.length +
19+
info.mock.calls.length,
20+
stderrCalls: warn.mock.calls.length,
21+
annotations: warn.mock.calls
22+
.flat()
23+
.map(String)
24+
.filter((line) => line.startsWith("::warning::")),
25+
};
26+
}
27+
28+
describe("announceReplacement", () => {
29+
afterEach(() => {
30+
vi.restoreAllMocks();
31+
vi.unstubAllEnvs();
32+
});
33+
34+
it("keeps stdout clean and adds one single-line annotation under GitHub Actions", () => {
35+
const { stdoutCalls, annotations } = runAnnouncement("true");
36+
37+
expect(stdoutCalls).toBe(0);
38+
expect(annotations).toHaveLength(1);
39+
expect(annotations[0]).not.toContain("\n");
40+
});
41+
42+
it("writes only to stderr and adds no annotation outside GitHub Actions", () => {
43+
const { stdoutCalls, stderrCalls, annotations } = runAnnouncement("");
44+
45+
expect(stdoutCalls).toBe(0);
46+
expect(stderrCalls).toBeGreaterThan(0);
47+
expect(annotations).toHaveLength(0);
48+
});
49+
});
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
const replacementNotice = [
2+
"lingo.dev is replaced by @lingo.dev/cli. Support for this package ends at the end of 2026.",
3+
"Convert your i18n.json with npx @lingo.dev/cli migrate, then follow the migration guide:",
4+
"https://lingo.dev/docs/devtools/cli/migration",
5+
];
6+
7+
export function renderReplacementNotice() {
8+
console.warn("\x1b[33m%s\x1b[0m", `\n⚠️ ${replacementNotice.join("\n")}\n`);
9+
}
10+
11+
export function announceReplacement() {
12+
renderReplacementNotice();
13+
14+
if (process.env.GITHUB_ACTIONS === "true") {
15+
console.warn(`::warning::${replacementNotice.join(" ")}`);
16+
}
17+
}

‎packages/cli/src/cli/utils/ui.ts‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import figlet from "figlet";
33
import { vice } from "gradient-string";
44
import readline from "readline";
55
import { colors } from "../constants";
6+
import { renderReplacementNotice } from "./replacement-notice";
67
import fs from "fs"; // <-- ADD THIS IMPORT
78

89
function isCI(): boolean {
@@ -11,6 +12,9 @@ function isCI(): boolean {
1112

1213
export async function renderClear() {
1314
process.stdout.write("\x1b[2J\x1b[H");
15+
if (process.stdout.isTTY && process.stderr.isTTY) {
16+
renderReplacementNotice();
17+
}
1418
}
1519

1620
export async function renderSpacer() {

0 commit comments

Comments
 (0)