@prettifystudio/lyngo-cli 0.2.0 → 0.2.1
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/bin/lyngo +15 -4
- package/package.json +1 -1
package/bin/lyngo
CHANGED
|
@@ -28,7 +28,10 @@ const TOKEN_DIR = path.join(os.homedir(), '.config', 'lyngo');
|
|
|
28
28
|
const TOKEN_FILE = path.join(TOKEN_DIR, 'token');
|
|
29
29
|
// Milliseconds per protocol second. Tests shrink it; people never set it.
|
|
30
30
|
const TICK = Number(process.env.LYNGO_TICK_MS) > 0 ? Number(process.env.LYNGO_TICK_MS) : 1000;
|
|
31
|
-
|
|
31
|
+
// The Stop hook says so when the CLI is not on PATH, instead of a "command not
|
|
32
|
+
// found" that scrolls past unread (corp1 setup, 2026-10-18).
|
|
33
|
+
const HOOK_COMMAND = 'if command -v lyngo >/dev/null 2>&1; then lyngo localize 2>&1 | tail -20; else echo "lyngo: the CLI is not on PATH. Install it: npm i -g @prettifystudio/lyngo-cli"; fi';
|
|
34
|
+
const OLD_HOOK_COMMANDS = ['lyngo localize 2>&1 | tail -20'];
|
|
32
35
|
const SRC = /\.(blade\.php|php|tsx|jsx|ts|js|vue|svelte)$/;
|
|
33
36
|
const SKIP = /(^|\/)(vendor|node_modules|tests?|database|storage|bootstrap|public|config|\.git)\//;
|
|
34
37
|
|
|
@@ -340,9 +343,15 @@ function setUpClaudeCode(top, remote) {
|
|
|
340
343
|
settings.hooks = settings.hooks || {};
|
|
341
344
|
const stop = Array.isArray(settings.hooks.Stop) ? settings.hooks.Stop : [];
|
|
342
345
|
const has = stop.some((group) => (group.hooks || []).some((h) => typeof h.command === 'string' && /\blyngo\b[^|]*\blocalize\b/.test(h.command)));
|
|
346
|
+
let upgraded = false;
|
|
347
|
+
for (const group of stop) for (const h of group.hooks || []) {
|
|
348
|
+
if (OLD_HOOK_COMMANDS.includes(h.command)) { h.command = HOOK_COMMAND; upgraded = true; }
|
|
349
|
+
}
|
|
343
350
|
if (!has) {
|
|
344
351
|
stop.push({ hooks: [{ type: 'command', command: HOOK_COMMAND }] });
|
|
345
352
|
settings.hooks.Stop = stop;
|
|
353
|
+
}
|
|
354
|
+
if (!has || upgraded) {
|
|
346
355
|
fs.mkdirSync(dir, { recursive: true });
|
|
347
356
|
fs.writeFileSync(file, JSON.stringify(settings, null, 2) + '\n');
|
|
348
357
|
}
|
|
@@ -384,9 +393,11 @@ async function init(opts) {
|
|
|
384
393
|
console.log(`Detected: ${detected.summary || 'no i18n setup found'}`);
|
|
385
394
|
if (detected.i18n) project = { ...project, i18n: detected.i18n };
|
|
386
395
|
|
|
396
|
+
// The agent setup comes before the language question: a run that stops
|
|
397
|
+
// there still leaves the hook and the MCP server in place (corp1, 2026-10-18).
|
|
398
|
+
setUpClaudeCode(top, remote);
|
|
387
399
|
project = await chooseLanguages(project, opts);
|
|
388
400
|
await scaffold(project);
|
|
389
|
-
setUpClaudeCode(top, remote);
|
|
390
401
|
await fillMissingCatalogs(project, opts);
|
|
391
402
|
console.log('Done. Build as usual; lyngo localize runs when your agent finishes, or run it yourself before committing.');
|
|
392
403
|
}
|
|
@@ -452,10 +463,10 @@ async function translateLanguage(code, project) {
|
|
|
452
463
|
fs.writeFileSync(targetPath, out.content);
|
|
453
464
|
const l = (r.report && r.report.languages && r.report.languages[code]) || {};
|
|
454
465
|
translated += l.translated || 0; memory += l.from_memory || 0; flagged.push(...(l.flagged || []));
|
|
455
|
-
process.stdout.write(`\r${code}: ${Math.min(i + 100, missing.length)}/${missing.length}`);
|
|
466
|
+
if (process.stdout.isTTY) process.stdout.write(`\r${code}: ${Math.min(i + 100, missing.length)}/${missing.length}`);
|
|
456
467
|
}
|
|
457
468
|
const flaggedText = flagged.length ? `; ${flagged.length} flagged for review: ${flagged.slice(0, 3).map((x) => JSON.stringify(x.key || x)).join(', ')}` : '';
|
|
458
|
-
console.log(
|
|
469
|
+
console.log(`${process.stdout.isTTY ? '\r' : ''}${code}: ${translated} translated, ${memory} from memory${flaggedText} -> ${targetPath}`);
|
|
459
470
|
}
|
|
460
471
|
|
|
461
472
|
// ── onboard: the "copy this into your agent" path ──────────────────────────
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@prettifystudio/lyngo-cli",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.1",
|
|
4
4
|
"description": "Localization for Laravel applications, from the terminal: Lyngo wraps user-facing text with your framework's i18n call, reuses your project's keys, translates and verifies the catalogs. Blade, Livewire, PHP, and Inertia with React, Vue or Svelte.",
|
|
5
5
|
"bin": {
|
|
6
6
|
"lyngo": "bin/lyngo"
|