lingo.dev 0.77.2 → 0.77.3
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 +54 -15
- package/build/cli.cjs.map +1 -1
- package/build/cli.mjs +97 -58
- package/build/cli.mjs.map +1 -1
- package/package.json +3 -3
package/build/cli.cjs
CHANGED
|
@@ -436,10 +436,47 @@ function getDefaultContent(ext, source) {
|
|
|
436
436
|
}
|
|
437
437
|
}
|
|
438
438
|
|
|
439
|
+
// src/cli/utils/update-gitignore.ts
|
|
440
|
+
|
|
441
|
+
|
|
442
|
+
function updateGitignore() {
|
|
443
|
+
const cacheFile = "i18n.cache";
|
|
444
|
+
const projectRoot = findCurrentProjectRoot();
|
|
445
|
+
if (!projectRoot) {
|
|
446
|
+
return;
|
|
447
|
+
}
|
|
448
|
+
const gitignorePath = _path2.default.join(projectRoot, ".gitignore");
|
|
449
|
+
const gitignore = _fs2.default.readFileSync(gitignorePath, "utf8").split("\n");
|
|
450
|
+
const cacheIsIgnored = gitignore.includes(cacheFile);
|
|
451
|
+
if (!cacheIsIgnored) {
|
|
452
|
+
let content = "";
|
|
453
|
+
if (_fs2.default.existsSync(gitignorePath)) {
|
|
454
|
+
content = _fs2.default.readFileSync(gitignorePath, "utf8");
|
|
455
|
+
if (content !== "" && !content.endsWith("\n")) {
|
|
456
|
+
content += "\n";
|
|
457
|
+
}
|
|
458
|
+
}
|
|
459
|
+
content += `${cacheFile}
|
|
460
|
+
`;
|
|
461
|
+
_fs2.default.writeFileSync(gitignorePath, content);
|
|
462
|
+
}
|
|
463
|
+
}
|
|
464
|
+
function findCurrentProjectRoot() {
|
|
465
|
+
let currentDir = process.cwd();
|
|
466
|
+
while (currentDir !== _path2.default.parse(currentDir).root) {
|
|
467
|
+
const gitDirPath = _path2.default.join(currentDir, ".git");
|
|
468
|
+
if (_fs2.default.existsSync(gitDirPath) && _fs2.default.lstatSync(gitDirPath).isDirectory()) {
|
|
469
|
+
return currentDir;
|
|
470
|
+
}
|
|
471
|
+
currentDir = _path2.default.dirname(currentDir);
|
|
472
|
+
}
|
|
473
|
+
return null;
|
|
474
|
+
}
|
|
475
|
+
|
|
439
476
|
// src/cli/cmd/init.ts
|
|
440
|
-
var openUrl = (
|
|
477
|
+
var openUrl = (path12) => {
|
|
441
478
|
const settings = getSettings(void 0);
|
|
442
|
-
_child_process.spawn.call(void 0, "open", [`${settings.auth.webUrl}${
|
|
479
|
+
_child_process.spawn.call(void 0, "open", [`${settings.auth.webUrl}${path12}`]);
|
|
443
480
|
};
|
|
444
481
|
var throwHelpError = (option, value) => {
|
|
445
482
|
if (value === "help") {
|
|
@@ -588,6 +625,7 @@ var init_default = new (0, _interactivecommander.InteractiveCommand)().command("
|
|
|
588
625
|
} else {
|
|
589
626
|
_ora2.default.call(void 0, ).succeed(`Authenticated as ${auth.email}`);
|
|
590
627
|
}
|
|
628
|
+
updateGitignore();
|
|
591
629
|
if (!isInteractive) {
|
|
592
630
|
_ora2.default.call(void 0, ).info("Please see https://docs.lingo.dev/");
|
|
593
631
|
}
|
|
@@ -760,8 +798,8 @@ var files_default = new (0, _interactivecommander.Command)().command("files").de
|
|
|
760
798
|
} else if (type.target) {
|
|
761
799
|
result.push(...targetPaths);
|
|
762
800
|
}
|
|
763
|
-
result.forEach((
|
|
764
|
-
console.log(
|
|
801
|
+
result.forEach((path12) => {
|
|
802
|
+
console.log(path12);
|
|
765
803
|
});
|
|
766
804
|
}
|
|
767
805
|
}
|
|
@@ -1301,9 +1339,9 @@ function createHtmlLoader() {
|
|
|
1301
1339
|
const bDepth = b.split("/").length;
|
|
1302
1340
|
return aDepth - bDepth;
|
|
1303
1341
|
});
|
|
1304
|
-
paths.forEach((
|
|
1305
|
-
const value = data[
|
|
1306
|
-
const [nodePath, attribute] =
|
|
1342
|
+
paths.forEach((path12) => {
|
|
1343
|
+
const value = data[path12];
|
|
1344
|
+
const [nodePath, attribute] = path12.split("#");
|
|
1307
1345
|
const [rootTag, ...indices] = nodePath.split("/");
|
|
1308
1346
|
let parent = rootTag === "head" ? document.head : document.body;
|
|
1309
1347
|
let current = parent;
|
|
@@ -2310,18 +2348,18 @@ function createRawDatoValue(parsedDatoValue, originalRawDatoValue, isClean = fal
|
|
|
2310
2348
|
}
|
|
2311
2349
|
function serializeStructuredText(rawStructuredText) {
|
|
2312
2350
|
return serializeStructuredTextNode(rawStructuredText);
|
|
2313
|
-
function serializeStructuredTextNode(node,
|
|
2351
|
+
function serializeStructuredTextNode(node, path12 = [], acc = {}) {
|
|
2314
2352
|
if ("document" in node) {
|
|
2315
|
-
return serializeStructuredTextNode(node.document, [...
|
|
2353
|
+
return serializeStructuredTextNode(node.document, [...path12, "document"], acc);
|
|
2316
2354
|
}
|
|
2317
2355
|
if (!_lodash2.default.isNil(node.value)) {
|
|
2318
|
-
acc[[...
|
|
2356
|
+
acc[[...path12, "value"].join(".")] = node.value;
|
|
2319
2357
|
} else if (_lodash2.default.get(node, "type") === "block") {
|
|
2320
|
-
acc[[...
|
|
2358
|
+
acc[[...path12, "item"].join(".")] = serializeBlock(node.item);
|
|
2321
2359
|
}
|
|
2322
2360
|
if (node.children) {
|
|
2323
2361
|
for (let i = 0; i < node.children.length; i++) {
|
|
2324
|
-
serializeStructuredTextNode(node.children[i], [...
|
|
2362
|
+
serializeStructuredTextNode(node.children[i], [...path12, i.toString()], acc);
|
|
2325
2363
|
}
|
|
2326
2364
|
}
|
|
2327
2365
|
return acc;
|
|
@@ -2380,8 +2418,8 @@ function deserializeBlockList(parsedBlockList, originalRawBlockList, isClean = f
|
|
|
2380
2418
|
}
|
|
2381
2419
|
function deserializeStructuredText(parsedStructuredText, originalRawStructuredText) {
|
|
2382
2420
|
const result = _lodash2.default.cloneDeep(originalRawStructuredText);
|
|
2383
|
-
for (const [
|
|
2384
|
-
const realPath = _lodash2.default.chain(
|
|
2421
|
+
for (const [path12, value] of _lodash2.default.entries(parsedStructuredText)) {
|
|
2422
|
+
const realPath = _lodash2.default.chain(path12.split(".")).flatMap((s) => !_lodash2.default.isNaN(_lodash2.default.toNumber(s)) ? ["children", s] : s).value();
|
|
2385
2423
|
const deserializedValue = createRawDatoValue(value, _lodash2.default.get(originalRawStructuredText, realPath), true);
|
|
2386
2424
|
_lodash2.default.set(result, realPath, deserializedValue);
|
|
2387
2425
|
}
|
|
@@ -2976,6 +3014,7 @@ function _tryParseJSON(line) {
|
|
|
2976
3014
|
|
|
2977
3015
|
// src/cli/cmd/i18n.ts
|
|
2978
3016
|
var i18n_default = new (0, _interactivecommander.Command)().command("i18n").description("Run Localization engine").helpOption("-h, --help", "Show help").option("--locale <locale>", "Locale to process", (val, prev) => prev ? [...prev, val] : [val]).option("--bucket <bucket>", "Bucket to process", (val, prev) => prev ? [...prev, val] : [val]).option("--key <key>", "Key to process").option("--frozen", `Don't update the translations and fail if an update is needed`).option("--force", "Ignore lockfile and process all keys").option("--verbose", "Show verbose output").option("--interactive", "Interactive mode").option("--api-key <api-key>", "Explicitly set the API key to use").option("--debug", "Debug mode").option("--strict", "Stop on first error").action(async function(options) {
|
|
3017
|
+
updateGitignore();
|
|
2979
3018
|
const ora = _ora2.default.call(void 0, );
|
|
2980
3019
|
const flags = parseFlags(options);
|
|
2981
3020
|
if (flags.debug) {
|
|
@@ -3579,7 +3618,7 @@ var mcp_default = new (0, _interactivecommander.Command)().command("mcp").descri
|
|
|
3579
3618
|
// package.json
|
|
3580
3619
|
var package_default = {
|
|
3581
3620
|
name: "lingo.dev",
|
|
3582
|
-
version: "0.77.
|
|
3621
|
+
version: "0.77.3",
|
|
3583
3622
|
description: "Lingo.dev CLI",
|
|
3584
3623
|
private: false,
|
|
3585
3624
|
publishConfig: {
|