@babelize/cli 1.0.13 → 1.1.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/LICENSE +200 -4
- package/README.md +44 -15
- package/dist/commands/check.d.ts +22 -0
- package/dist/commands/check.d.ts.map +1 -0
- package/dist/commands/check.js +134 -0
- package/dist/commands/check.js.map +1 -0
- package/dist/commands/glossary.d.ts.map +1 -1
- package/dist/commands/glossary.js +2 -1
- package/dist/commands/glossary.js.map +1 -1
- package/dist/commands/init.d.ts.map +1 -1
- package/dist/commands/init.js +52 -52
- package/dist/commands/init.js.map +1 -1
- package/dist/commands/tm.d.ts.map +1 -1
- package/dist/commands/tm.js +29 -11
- package/dist/commands/tm.js.map +1 -1
- package/dist/commands/translate.d.ts +24 -0
- package/dist/commands/translate.d.ts.map +1 -0
- package/dist/commands/translate.js +415 -0
- package/dist/commands/translate.js.map +1 -0
- package/dist/local/formatter.d.ts +27 -0
- package/dist/local/formatter.d.ts.map +1 -0
- package/dist/local/formatter.js +69 -0
- package/dist/local/formatter.js.map +1 -0
- package/dist/local/git.d.ts +16 -0
- package/dist/local/git.d.ts.map +1 -0
- package/dist/local/git.js +52 -0
- package/dist/local/git.js.map +1 -0
- package/dist/local/provider.d.ts +41 -0
- package/dist/local/provider.d.ts.map +1 -0
- package/dist/local/provider.js +87 -0
- package/dist/local/provider.js.map +1 -0
- package/dist/local/translate-core.d.ts +188 -0
- package/dist/local/translate-core.d.ts.map +1 -0
- package/dist/local/translate-core.js +401 -0
- package/dist/local/translate-core.js.map +1 -0
- package/dist/local/workspace-copy.d.ts +75 -0
- package/dist/local/workspace-copy.d.ts.map +1 -0
- package/dist/local/workspace-copy.js +263 -0
- package/dist/local/workspace-copy.js.map +1 -0
- package/dist/program.d.ts.map +1 -1
- package/dist/program.js +6 -0
- package/dist/program.js.map +1 -1
- package/dist/tui/repl.d.ts.map +1 -1
- package/dist/tui/repl.js +2 -0
- package/dist/tui/repl.js.map +1 -1
- package/dist/utils/zip-upload.d.ts +81 -0
- package/dist/utils/zip-upload.d.ts.map +1 -0
- package/dist/utils/zip-upload.js +277 -0
- package/dist/utils/zip-upload.js.map +1 -0
- package/package.json +6 -2
|
@@ -0,0 +1,401 @@
|
|
|
1
|
+
import { execFile } from 'node:child_process';
|
|
2
|
+
import { mkdir, readdir, readFile, writeFile } from 'node:fs/promises';
|
|
3
|
+
import * as path from 'node:path';
|
|
4
|
+
import { promisify } from 'node:util';
|
|
5
|
+
import { isSupported, removeLocaleFromLockfile, runEngineV2, setEngineLogger, validateWorkspace, } from '@babelize/engine';
|
|
6
|
+
import { PROVIDER_DEFINITIONS } from '@babelize/types';
|
|
7
|
+
import { assertCleanTree, assertGitRepo, GitError } from './git.js';
|
|
8
|
+
import { formatChangedFiles } from './formatter.js';
|
|
9
|
+
import { ApplyError, applyChanges, changeCount, findConflicts, createTempCopy, diffSnapshots, renderUnifiedDiff, snapshot, } from './workspace-copy.js';
|
|
10
|
+
const execFileAsync = promisify(execFile);
|
|
11
|
+
/** Lockfile scope for local runs: `.babelize/local/babelize-lock.json` in the project root. */
|
|
12
|
+
export const LOCAL_PROJECT_ID = 'local';
|
|
13
|
+
export const LOCAL_LOCKFILE = `.babelize/${LOCAL_PROJECT_ID}/babelize-lock.json`;
|
|
14
|
+
export const SUPPORTED_LOCAL_FRAMEWORKS = ['react', 'nextjs'];
|
|
15
|
+
export const BETA_LOCAL_FRAMEWORKS = ['vue', 'static'];
|
|
16
|
+
export class LocalTranslateError extends Error {
|
|
17
|
+
code;
|
|
18
|
+
changedFiles;
|
|
19
|
+
constructor(message, code,
|
|
20
|
+
/** Files left changed in the project (only for a failed, un-rolled-back apply). */
|
|
21
|
+
changedFiles = []) {
|
|
22
|
+
super(message);
|
|
23
|
+
this.code = code;
|
|
24
|
+
this.changedFiles = changedFiles;
|
|
25
|
+
this.name = 'LocalTranslateError';
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
/** Normalise `--to fr,de , ja` into a deduped list without the source locale. */
|
|
29
|
+
export function parseLocales(raw, sourceLocale) {
|
|
30
|
+
const parts = (Array.isArray(raw) ? raw : (raw ?? '').split(','))
|
|
31
|
+
.flatMap((p) => p.split(','))
|
|
32
|
+
.map((p) => p.trim())
|
|
33
|
+
.filter(Boolean);
|
|
34
|
+
return [...new Set(parts)].filter((l) => l !== sourceLocale);
|
|
35
|
+
}
|
|
36
|
+
export function validateLocales(sourceLocale, targetLocales) {
|
|
37
|
+
const bad = [sourceLocale, ...targetLocales].filter((l) => !isSupported(l));
|
|
38
|
+
if (bad.length > 0) {
|
|
39
|
+
throw new LocalTranslateError(`Unsupported locale code${bad.length > 1 ? 's' : ''}: ${bad.join(', ')}. Use ISO codes like fr, de, ja, pt-BR, zh-CN.`, 'invalid_locale');
|
|
40
|
+
}
|
|
41
|
+
if (targetLocales.length === 0) {
|
|
42
|
+
throw new LocalTranslateError('No target locales given. Pass --to, e.g. --to fr,de.', 'invalid_locale');
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
/** Tracked + untracked-but-not-ignored files under `dir`, relative to it. */
|
|
46
|
+
async function listProjectFiles(dir) {
|
|
47
|
+
const { stdout } = await execFileAsync('git', ['ls-files', '-z', '--cached', '--others', '--exclude-standard', '--', '.'], { cwd: dir, maxBuffer: 256 * 1024 * 1024 });
|
|
48
|
+
return stdout.split('\0').filter(Boolean);
|
|
49
|
+
}
|
|
50
|
+
/** Locales this project was already translated into: locale files plus lockfile entries. */
|
|
51
|
+
async function existingTargetLocales(workspaceDir, publicDir, localeFormat, sourceLocale) {
|
|
52
|
+
const found = new Set();
|
|
53
|
+
if (localeFormat !== 'po') {
|
|
54
|
+
const ext = localeFormat === 'arb' ? '.arb' : '.json';
|
|
55
|
+
for (const entry of await readdir(path.join(workspaceDir, publicDir, 'locales')).catch(() => [])) {
|
|
56
|
+
if (entry.endsWith(ext))
|
|
57
|
+
found.add(entry.slice(0, -ext.length));
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
try {
|
|
61
|
+
const lock = JSON.parse(await readFile(path.join(workspaceDir, LOCAL_LOCKFILE), 'utf8'));
|
|
62
|
+
for (const entry of Object.values(lock.keys ?? {})) {
|
|
63
|
+
for (const locale of Object.keys(entry.languages ?? {}))
|
|
64
|
+
found.add(locale);
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
catch {
|
|
68
|
+
// No lockfile yet.
|
|
69
|
+
}
|
|
70
|
+
found.delete(sourceLocale);
|
|
71
|
+
return [...found].filter((l) => isSupported(l)).sort();
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Engine log lines that are wrong or redundant for a local run: the
|
|
75
|
+
* TRANSLATOR_URL check doesn't know about BYOK/injected providers, and the
|
|
76
|
+
* "run your install" hint is already a finalization note in the summary.
|
|
77
|
+
*/
|
|
78
|
+
/** `msg` as one sentence: trailing dots/spaces trimmed, exactly one period added. */
|
|
79
|
+
export function sentence(msg) {
|
|
80
|
+
const trimmed = msg.trim().replace(/[.\s]+$/, '');
|
|
81
|
+
return /[!?]$/.test(trimmed) ? trimmed : `${trimmed}.`;
|
|
82
|
+
}
|
|
83
|
+
const ENGINE_LOG_NOISE = [
|
|
84
|
+
/TRANSLATOR_URL environment variable is not set/,
|
|
85
|
+
/TRANSLATOR_URL not configured/,
|
|
86
|
+
/^New dependencies added\. Please run your package manager install/,
|
|
87
|
+
// Reported in full in the summary (failures / not-wired strings).
|
|
88
|
+
/^Some strings could not be translated/,
|
|
89
|
+
/^Extracted strings not wired into code/,
|
|
90
|
+
];
|
|
91
|
+
export function isEngineLogNoise(message) {
|
|
92
|
+
return ENGINE_LOG_NOISE.some((re) => re.test(message));
|
|
93
|
+
}
|
|
94
|
+
async function readJsonIfExists(file) {
|
|
95
|
+
try {
|
|
96
|
+
return JSON.parse(await readFile(file, 'utf8'));
|
|
97
|
+
}
|
|
98
|
+
catch {
|
|
99
|
+
return null;
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
function flattenData(data, prefix = '', out = {}) {
|
|
103
|
+
if (data && typeof data === 'object') {
|
|
104
|
+
for (const [k, v] of Object.entries(data)) {
|
|
105
|
+
const key = prefix ? `${prefix}.${k}` : k;
|
|
106
|
+
if (v && typeof v === 'object')
|
|
107
|
+
flattenData(v, key, out);
|
|
108
|
+
else if (typeof v === 'string')
|
|
109
|
+
out[key] = v;
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
return out;
|
|
113
|
+
}
|
|
114
|
+
function sortKeysDeep(value) {
|
|
115
|
+
if (!value || typeof value !== 'object' || Array.isArray(value))
|
|
116
|
+
return value;
|
|
117
|
+
return Object.fromEntries(Object.keys(value)
|
|
118
|
+
.sort()
|
|
119
|
+
.map((k) => [k, sortKeysDeep(value[k])]));
|
|
120
|
+
}
|
|
121
|
+
async function isGitIgnored(dir, rel) {
|
|
122
|
+
try {
|
|
123
|
+
await execFileAsync('git', ['check-ignore', '-q', '--', rel], { cwd: dir });
|
|
124
|
+
return true; // exit 0 = ignored
|
|
125
|
+
}
|
|
126
|
+
catch {
|
|
127
|
+
return false;
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
function frameworkStatusOf(framework) {
|
|
131
|
+
if (SUPPORTED_LOCAL_FRAMEWORKS.includes(framework))
|
|
132
|
+
return 'supported';
|
|
133
|
+
if (BETA_LOCAL_FRAMEWORKS.includes(framework))
|
|
134
|
+
return 'beta';
|
|
135
|
+
return null;
|
|
136
|
+
}
|
|
137
|
+
function stripMeta(flat) {
|
|
138
|
+
const out = {};
|
|
139
|
+
for (const [k, v] of Object.entries(flat ?? {})) {
|
|
140
|
+
if (k === '_meta' || k.startsWith('_meta.'))
|
|
141
|
+
continue;
|
|
142
|
+
out[k] = v;
|
|
143
|
+
}
|
|
144
|
+
return out;
|
|
145
|
+
}
|
|
146
|
+
/** Text that is only digits, symbols or whitespace is legitimately identical in every locale. */
|
|
147
|
+
function hasLetters(text) {
|
|
148
|
+
return /\p{L}/u.test(text);
|
|
149
|
+
}
|
|
150
|
+
export function buildLocaleReports(targetLocales, source, targets, failures = [], metadata = {}) {
|
|
151
|
+
const src = stripMeta(source);
|
|
152
|
+
const keys = Object.keys(src);
|
|
153
|
+
return targetLocales.map((locale) => {
|
|
154
|
+
const target = stripMeta(targets[locale]);
|
|
155
|
+
const missing = [];
|
|
156
|
+
const sameAsSource = [];
|
|
157
|
+
let translated = 0;
|
|
158
|
+
for (const key of keys) {
|
|
159
|
+
const value = target[key];
|
|
160
|
+
if (value === undefined || value === '') {
|
|
161
|
+
missing.push(key);
|
|
162
|
+
continue;
|
|
163
|
+
}
|
|
164
|
+
translated++;
|
|
165
|
+
if (value === src[key] && hasLetters(src[key]))
|
|
166
|
+
sameAsSource.push(key);
|
|
167
|
+
}
|
|
168
|
+
const failed = failures
|
|
169
|
+
.filter((f) => f.locale === locale)
|
|
170
|
+
.map((f) => ({ key: f.key, reason: f.reason, message: f.message, retryable: f.retryable }));
|
|
171
|
+
const qa = [];
|
|
172
|
+
for (const [key, meta] of Object.entries(metadata[locale] ?? {})) {
|
|
173
|
+
const warnings = meta?.qa;
|
|
174
|
+
if (Array.isArray(warnings) && warnings.length > 0)
|
|
175
|
+
qa.push({ key, warnings: warnings.map(String) });
|
|
176
|
+
}
|
|
177
|
+
return { locale, total: keys.length, translated, missing, failed, qa, sameAsSource };
|
|
178
|
+
});
|
|
179
|
+
}
|
|
180
|
+
function describeEngineFailure(error, byok) {
|
|
181
|
+
if (byok && /translator service (is )?(unavailable|not responding)/i.test(error)) {
|
|
182
|
+
const name = PROVIDER_DEFINITIONS[byok.provider].name;
|
|
183
|
+
return new LocalTranslateError(`Could not reach ${name} with your API key (invalid key, no access, or network error). Nothing was changed.`, 'translator_unreachable');
|
|
184
|
+
}
|
|
185
|
+
return new LocalTranslateError(`Translation failed: ${sentence(error)} Nothing was changed.`, 'engine_failed');
|
|
186
|
+
}
|
|
187
|
+
/**
|
|
188
|
+
* Run the Babelize engine on a temp copy of `projectDir` and, unless
|
|
189
|
+
* `dryRun`, apply the result back to the working tree. The project is never
|
|
190
|
+
* touched until the engine has finished successfully and every target locale
|
|
191
|
+
* has translations.
|
|
192
|
+
*/
|
|
193
|
+
export async function runLocalTranslate(opts, deps = {}) {
|
|
194
|
+
const startedAt = Date.now();
|
|
195
|
+
const projectDir = path.resolve(opts.projectDir);
|
|
196
|
+
try {
|
|
197
|
+
await assertGitRepo(projectDir);
|
|
198
|
+
// A dry run writes nothing, so it is safe on a dirty tree.
|
|
199
|
+
if (!opts.dryRun)
|
|
200
|
+
await assertCleanTree(projectDir, opts.force);
|
|
201
|
+
}
|
|
202
|
+
catch (err) {
|
|
203
|
+
if (err instanceof GitError)
|
|
204
|
+
throw new LocalTranslateError(err.message, err.code);
|
|
205
|
+
throw err;
|
|
206
|
+
}
|
|
207
|
+
validateLocales(opts.sourceLocale, opts.targetLocales);
|
|
208
|
+
if (!opts.byok && !deps.translator) {
|
|
209
|
+
throw new LocalTranslateError('No translation provider configured.', 'no_translator');
|
|
210
|
+
}
|
|
211
|
+
const files = await listProjectFiles(projectDir);
|
|
212
|
+
const temp = await createTempCopy(projectDir, { files, tmpRoot: deps.tmpRoot });
|
|
213
|
+
const previousDataDir = process.env.BABELIZE_DATA_DIR;
|
|
214
|
+
try {
|
|
215
|
+
// Framework detection runs on the copy (it creates .babelize/ as a side effect).
|
|
216
|
+
let framework;
|
|
217
|
+
let publicDir = 'public';
|
|
218
|
+
let localeFormat = 'json';
|
|
219
|
+
try {
|
|
220
|
+
const { workspace } = await validateWorkspace({
|
|
221
|
+
workspacePath: temp.dir,
|
|
222
|
+
inputType: 'zip',
|
|
223
|
+
sourceLocale: opts.sourceLocale,
|
|
224
|
+
targetLocales: opts.targetLocales,
|
|
225
|
+
confidenceThreshold: 80,
|
|
226
|
+
dryRun: true,
|
|
227
|
+
});
|
|
228
|
+
framework = workspace.framework;
|
|
229
|
+
publicDir = workspace.publicDir;
|
|
230
|
+
localeFormat = workspace.localeFormat;
|
|
231
|
+
}
|
|
232
|
+
catch (err) {
|
|
233
|
+
throw new LocalTranslateError(err.message, 'unsupported_framework');
|
|
234
|
+
}
|
|
235
|
+
const frameworkStatus = frameworkStatusOf(framework);
|
|
236
|
+
if (!frameworkStatus) {
|
|
237
|
+
throw new LocalTranslateError(`Detected framework "${framework}", which \`babelize translate\` does not support. Supported: React and Next.js (Vue and static HTML in beta).`, 'unsupported_framework');
|
|
238
|
+
}
|
|
239
|
+
deps.onFramework?.(framework, frameworkStatus);
|
|
240
|
+
// The engine deletes locale files that aren't in its target list, so
|
|
241
|
+
// `--to ja` after `--to fr,de` would silently drop fr and de. Unless the
|
|
242
|
+
// user asked to replace the set, earlier locales stay in it; their
|
|
243
|
+
// translations come from the lockfile, so only new strings cost tokens.
|
|
244
|
+
const earlier = await existingTargetLocales(temp.dir, publicDir, localeFormat, opts.sourceLocale);
|
|
245
|
+
const keptLocales = opts.replace ? [] : earlier.filter((l) => !opts.targetLocales.includes(l));
|
|
246
|
+
const droppedLocales = opts.replace ? earlier.filter((l) => !opts.targetLocales.includes(l)) : [];
|
|
247
|
+
const targetLocales = [...opts.targetLocales, ...keptLocales];
|
|
248
|
+
const before = await snapshot(temp.dir);
|
|
249
|
+
const engineLog = [];
|
|
250
|
+
const log = (level) => (message) => {
|
|
251
|
+
if (!isEngineLogNoise(message))
|
|
252
|
+
engineLog.push({ level, message });
|
|
253
|
+
};
|
|
254
|
+
setEngineLogger({ debug: () => { }, info: () => { }, warn: log('warn'), error: log('error') });
|
|
255
|
+
// The lockfile lives at $BABELIZE_DATA_DIR/.babelize/local/. Pointing it at
|
|
256
|
+
// the copy means the project's committed lockfile is read (it was copied)
|
|
257
|
+
// and the updated one comes back with the other changes — only on success.
|
|
258
|
+
process.env.BABELIZE_DATA_DIR = temp.dir;
|
|
259
|
+
const runEngine = deps.runEngine ?? runEngineV2;
|
|
260
|
+
const result = await runEngine({
|
|
261
|
+
workspacePath: temp.dir,
|
|
262
|
+
inputType: 'zip',
|
|
263
|
+
framework: framework,
|
|
264
|
+
sourceLocale: opts.sourceLocale,
|
|
265
|
+
targetLocales: [...targetLocales],
|
|
266
|
+
confidenceThreshold: 80,
|
|
267
|
+
dryRun: false,
|
|
268
|
+
projectId: LOCAL_PROJECT_ID,
|
|
269
|
+
byok: deps.translator ? undefined : opts.byok,
|
|
270
|
+
providers: deps.translator ? { translator: deps.translator } : undefined,
|
|
271
|
+
installDependencies: false,
|
|
272
|
+
onProgress: (message, step, status) => deps.onProgress?.(message, step, status),
|
|
273
|
+
});
|
|
274
|
+
if (!result.success) {
|
|
275
|
+
throw describeEngineFailure(result.error ?? 'unknown engine error', deps.translator ? undefined : opts.byok);
|
|
276
|
+
}
|
|
277
|
+
// --replace: forget dropped locales in the lockfile too, or a later run
|
|
278
|
+
// would rebuild their files from it.
|
|
279
|
+
for (const locale of droppedLocales)
|
|
280
|
+
await removeLocaleFromLockfile(LOCAL_PROJECT_ID, locale);
|
|
281
|
+
const source = stripMeta(result.results?.source);
|
|
282
|
+
const targets = result.results?.targets ?? {};
|
|
283
|
+
const translationFailures = result.translationFailures ?? [];
|
|
284
|
+
const metadata = (result.results?.metadata ?? {});
|
|
285
|
+
const locales = buildLocaleReports(targetLocales, source, targets, translationFailures, metadata);
|
|
286
|
+
// A locale with source keys but zero translations (nothing, or only copies
|
|
287
|
+
// of the source text) is a failed run, not a partial one: refuse to write
|
|
288
|
+
// it rather than ship an untranslated language as if it were done.
|
|
289
|
+
const empty = locales.filter((l) => l.total > 0 && l.translated - l.sameAsSource.length === 0);
|
|
290
|
+
if (empty.length > 0) {
|
|
291
|
+
throw new LocalTranslateError(`No translations were produced for ${empty.map((l) => l.locale).join(', ')}. Nothing was changed.`, 'incomplete_translation');
|
|
292
|
+
}
|
|
293
|
+
// The engine's result carries each target locale's complete data (fresh
|
|
294
|
+
// translations merged with lockfile-cached ones); its on-disk files can
|
|
295
|
+
// hold only this run's new keys. Write the complete data, exactly as the
|
|
296
|
+
// cloud backend stages locale files for a PR.
|
|
297
|
+
const lost = [];
|
|
298
|
+
for (const locale of result.locales) {
|
|
299
|
+
if (locale.locale === opts.sourceLocale)
|
|
300
|
+
continue;
|
|
301
|
+
const rel = locale.path.split(path.sep).join('/');
|
|
302
|
+
const previous = await readJsonIfExists(path.join(projectDir, rel));
|
|
303
|
+
const next = flattenData(locale.data);
|
|
304
|
+
const failedHere = new Set(translationFailures.filter((f) => f.locale === locale.locale).map((f) => f.key));
|
|
305
|
+
for (const [key, value] of Object.entries(flattenData(previous ?? {}))) {
|
|
306
|
+
// A key whose re-translation failed is reported as a failure instead.
|
|
307
|
+
if (key.startsWith('_meta') || !value || failedHere.has(key))
|
|
308
|
+
continue;
|
|
309
|
+
if (!next[key])
|
|
310
|
+
lost.push(`${locale.locale}: ${key}`);
|
|
311
|
+
}
|
|
312
|
+
const abs = path.resolve(temp.dir, rel);
|
|
313
|
+
if (path.relative(temp.dir, abs).startsWith('..'))
|
|
314
|
+
continue;
|
|
315
|
+
await mkdir(path.dirname(abs), { recursive: true });
|
|
316
|
+
await writeFile(abs, `${JSON.stringify(sortKeysDeep(locale.data), null, 2)}\n`);
|
|
317
|
+
}
|
|
318
|
+
// Never ship a run that would delete translations the project already has.
|
|
319
|
+
if (lost.length > 0) {
|
|
320
|
+
throw new LocalTranslateError(`This run would remove ${lost.length} existing translation(s) (${lost.slice(0, 5).join(', ')}${lost.length > 5 ? ', …' : ''}). Nothing was changed.`, 'incomplete_translation');
|
|
321
|
+
}
|
|
322
|
+
let changes = diffSnapshots(before, await snapshot(temp.dir));
|
|
323
|
+
const formatter = (await formatChangedFiles(projectDir, temp.dir, [...changes.added, ...changes.modified])) ?? undefined;
|
|
324
|
+
if (formatter?.ok)
|
|
325
|
+
changes = diffSnapshots(before, await snapshot(temp.dir));
|
|
326
|
+
const diff = opts.dryRun ? await renderUnifiedDiff(changes, projectDir, temp.dir) : undefined;
|
|
327
|
+
if (!opts.dryRun && changeCount(changes) > 0) {
|
|
328
|
+
const conflicts = await findConflicts(changes, before, projectDir);
|
|
329
|
+
if (conflicts.length > 0) {
|
|
330
|
+
throw new LocalTranslateError(`These files changed in your project while translate was running (or exist but weren't part of the copy), so nothing was applied:\n` +
|
|
331
|
+
conflicts.map((f) => ` ${f}`).join('\n') +
|
|
332
|
+
'\nCommit or discard those edits, then run translate again.', 'project_changed');
|
|
333
|
+
}
|
|
334
|
+
try {
|
|
335
|
+
await applyChanges(changes, temp.dir, projectDir, deps.applyIo);
|
|
336
|
+
}
|
|
337
|
+
catch (err) {
|
|
338
|
+
if (!(err instanceof ApplyError))
|
|
339
|
+
throw err;
|
|
340
|
+
if (err.rolledBack) {
|
|
341
|
+
throw new LocalTranslateError(`${sentence(err.message)} Nothing was changed.`, 'apply_failed');
|
|
342
|
+
}
|
|
343
|
+
throw new LocalTranslateError(`${err.message} These files are still changed:\n` +
|
|
344
|
+
err.changedFiles.map((f) => ` ${f}`).join('\n') +
|
|
345
|
+
`\nRestore them with: git checkout -- ${err.changedFiles.join(' ')} (and delete any of them that are new).`, 'apply_failed', err.changedFiles);
|
|
346
|
+
}
|
|
347
|
+
}
|
|
348
|
+
const s = result.stats;
|
|
349
|
+
const provider = !deps.translator && opts.byok
|
|
350
|
+
? {
|
|
351
|
+
provider: opts.byok.provider,
|
|
352
|
+
name: PROVIDER_DEFINITIONS[opts.byok.provider].name,
|
|
353
|
+
model: opts.byok.model ?? PROVIDER_DEFINITIONS[opts.byok.provider].defaultModel,
|
|
354
|
+
}
|
|
355
|
+
: undefined;
|
|
356
|
+
return {
|
|
357
|
+
framework,
|
|
358
|
+
frameworkStatus,
|
|
359
|
+
provider,
|
|
360
|
+
sourceLocale: opts.sourceLocale,
|
|
361
|
+
targetLocales,
|
|
362
|
+
keptLocales,
|
|
363
|
+
droppedLocales,
|
|
364
|
+
unusedKeys: result.keyUsage?.unused ?? [],
|
|
365
|
+
notInjected: result.notInjected ?? [],
|
|
366
|
+
dynamicKeyFiles: result.keyUsage?.dynamicFiles ?? [],
|
|
367
|
+
dryRun: opts.dryRun,
|
|
368
|
+
applied: !opts.dryRun && changeCount(changes) > 0,
|
|
369
|
+
changes,
|
|
370
|
+
diff,
|
|
371
|
+
stats: {
|
|
372
|
+
filesScanned: s.filesScanned,
|
|
373
|
+
stringsExtracted: s.stringsExtracted,
|
|
374
|
+
keysExtracted: s.keysGenerated,
|
|
375
|
+
injectionsApplied: s.injectionsApplied,
|
|
376
|
+
keysFromLockfile: s.translationsFromLockfile ?? 0,
|
|
377
|
+
keysSentToTranslator: s.lockfileKeysTranslated ?? 0,
|
|
378
|
+
translatedThisRun: s.translatedThisRun,
|
|
379
|
+
},
|
|
380
|
+
locales,
|
|
381
|
+
translationFailures,
|
|
382
|
+
warnings: result.warnings.map((w) => ({ type: w.type, file: w.file, line: w.line, message: w.message })),
|
|
383
|
+
notes: result.notes ?? [],
|
|
384
|
+
formatter,
|
|
385
|
+
engineLog,
|
|
386
|
+
lockfile: LOCAL_LOCKFILE,
|
|
387
|
+
lockfileIgnored: await isGitIgnored(projectDir, LOCAL_LOCKFILE),
|
|
388
|
+
metadata,
|
|
389
|
+
results: { source, targets: Object.fromEntries(Object.entries(targets).map(([l, t]) => [l, stripMeta(t)])) },
|
|
390
|
+
durationMs: Date.now() - startedAt,
|
|
391
|
+
};
|
|
392
|
+
}
|
|
393
|
+
finally {
|
|
394
|
+
if (previousDataDir === undefined)
|
|
395
|
+
delete process.env.BABELIZE_DATA_DIR;
|
|
396
|
+
else
|
|
397
|
+
process.env.BABELIZE_DATA_DIR = previousDataDir;
|
|
398
|
+
await temp.cleanup();
|
|
399
|
+
}
|
|
400
|
+
}
|
|
401
|
+
//# sourceMappingURL=translate-core.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"translate-core.js","sourceRoot":"","sources":["../../src/local/translate-core.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAC9C,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE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SAAS;YACT,SAAS;YACT,QAAQ,EAAE,cAAc;YACxB,eAAe,EAAE,MAAM,YAAY,CAAC,UAAU,EAAE,cAAc,CAAC;YAC/D,QAAQ;YACR,OAAO,EAAE,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,CAAC,WAAW,CAAC,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE;YAC5G,UAAU,EAAE,IAAI,CAAC,GAAG,EAAE,GAAG,SAAS;SACnC,CAAC;IACJ,CAAC;YAAS,CAAC;QACT,IAAI,eAAe,KAAK,SAAS;YAAE,OAAO,OAAO,CAAC,GAAG,CAAC,iBAAiB,CAAC;;YACnE,OAAO,CAAC,GAAG,CAAC,iBAAiB,GAAG,eAAe,CAAC;QACrD,MAAM,IAAI,CAAC,OAAO,EAAE,CAAC;IACvB,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Directories never copied into the temp workspace and never diffed back.
|
|
3
|
+
* Dependencies and VCS/tool caches are skipped at any depth.
|
|
4
|
+
*/
|
|
5
|
+
export declare const EXCLUDED_DIRS_ANY_DEPTH: ReadonlySet<string>;
|
|
6
|
+
/**
|
|
7
|
+
* Build output, skipped only at the project root: the same names deeper down
|
|
8
|
+
* are often real source (a Next.js route like `app/build/page.tsx`).
|
|
9
|
+
*/
|
|
10
|
+
export declare const EXCLUDED_DIRS_AT_ROOT: ReadonlySet<string>;
|
|
11
|
+
/** Always copied, even when gitignored: it holds the lockfile that makes reruns incremental. */
|
|
12
|
+
export declare const BABELIZE_DIR = ".babelize";
|
|
13
|
+
export declare function isExcluded(rel: string): boolean;
|
|
14
|
+
/** Regular files under `root/dir`, relative to `root`. Symlinks are never followed. */
|
|
15
|
+
export declare function walk(root: string, dir?: string, out?: string[]): Promise<string[]>;
|
|
16
|
+
export interface TempWorkspace {
|
|
17
|
+
dir: string;
|
|
18
|
+
cleanup(): Promise<void>;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Copy the project into a fresh private temp dir. `files` (paths relative to
|
|
22
|
+
* `projectDir`, e.g. from `git ls-files`) limits the copy; without it the
|
|
23
|
+
* whole tree is walked. `.babelize/` is always included (it is often
|
|
24
|
+
* gitignored, but the lockfile in it is what keeps reruns incremental).
|
|
25
|
+
*/
|
|
26
|
+
export declare function createTempCopy(projectDir: string, opts?: {
|
|
27
|
+
files?: string[];
|
|
28
|
+
tmpRoot?: string;
|
|
29
|
+
}): Promise<TempWorkspace>;
|
|
30
|
+
/** Relative path → sha256 for every regular file under `root` (excluded dirs skipped). */
|
|
31
|
+
export declare function snapshot(root: string): Promise<Map<string, string>>;
|
|
32
|
+
export interface WorkspaceChanges {
|
|
33
|
+
added: string[];
|
|
34
|
+
modified: string[];
|
|
35
|
+
deleted: string[];
|
|
36
|
+
}
|
|
37
|
+
export declare function diffSnapshots(before: Map<string, string>, after: Map<string, string>): WorkspaceChanges;
|
|
38
|
+
export declare function changeCount(changes: WorkspaceChanges): number;
|
|
39
|
+
/**
|
|
40
|
+
* Project files that no longer match what the run started from: a file the
|
|
41
|
+
* run would overwrite or delete was edited (or removed) meanwhile, or a file
|
|
42
|
+
* it would create now exists (created during the run, or never copied
|
|
43
|
+
* because it is gitignored). Applying over those would lose the user's work.
|
|
44
|
+
*/
|
|
45
|
+
export declare function findConflicts(changes: WorkspaceChanges, baseline: Map<string, string>, projectDir: string): Promise<string[]>;
|
|
46
|
+
/** File operations used by applyChanges; injectable so tests can simulate a failing disk. */
|
|
47
|
+
export interface ApplyIo {
|
|
48
|
+
copyFile(src: string, dest: string): Promise<void>;
|
|
49
|
+
rename(from: string, to: string): Promise<void>;
|
|
50
|
+
unlink(file: string): Promise<void>;
|
|
51
|
+
/** Used to restore originals on rollback. */
|
|
52
|
+
writeFile(file: string, data: Buffer): Promise<void>;
|
|
53
|
+
/** Used to remove new files on rollback. */
|
|
54
|
+
remove(file: string): Promise<void>;
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* applyChanges failed. When `rolledBack` is true the project is exactly as it
|
|
58
|
+
* was before; otherwise `changedFiles` lists what is still different.
|
|
59
|
+
*/
|
|
60
|
+
export declare class ApplyError extends Error {
|
|
61
|
+
readonly cause: unknown;
|
|
62
|
+
readonly rolledBack: boolean;
|
|
63
|
+
readonly changedFiles: string[];
|
|
64
|
+
constructor(message: string, cause: unknown, rolledBack: boolean, changedFiles: string[]);
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Apply the engine's changes from the temp copy to the project, as one
|
|
68
|
+
* transaction: originals of every file about to be overwritten or deleted are
|
|
69
|
+
* read into memory first, each write goes through temp file + rename, and on
|
|
70
|
+
* any failure every file already touched is restored (new files removed).
|
|
71
|
+
*/
|
|
72
|
+
export declare function applyChanges(changes: WorkspaceChanges, fromDir: string, toDir: string, io?: ApplyIo): Promise<void>;
|
|
73
|
+
/** Unified diff (git-style a/ b/ headers) of what applyChanges would do. */
|
|
74
|
+
export declare function renderUnifiedDiff(changes: WorkspaceChanges, beforeDir: string, afterDir: string): Promise<string>;
|
|
75
|
+
//# sourceMappingURL=workspace-copy.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"workspace-copy.d.ts","sourceRoot":"","sources":["../../src/local/workspace-copy.ts"],"names":[],"mappings":"AAMA;;;GAGG;AACH,eAAO,MAAM,uBAAuB,EAAE,WAAW,CAAC,MAAM,CAAwD,CAAC;AAEjH;;;GAGG;AACH,eAAO,MAAM,qBAAqB,EAAE,WAAW,CAAC,MAAM,CAA0C,CAAC;AAEjG,gGAAgG;AAChG,eAAO,MAAM,YAAY,cAAc,CAAC;AAYxC,wBAAgB,UAAU,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAI/C;AAYD,uFAAuF;AACvF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