lingo.dev 0.85.7 → 0.86.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/build/cli.cjs +48 -10
- package/build/cli.cjs.map +1 -1
- package/build/cli.mjs +48 -10
- package/build/cli.mjs.map +1 -1
- package/package.json +1 -1
package/build/cli.mjs
CHANGED
|
@@ -1641,25 +1641,41 @@ ${content}`;
|
|
|
1641
1641
|
import _9 from "lodash";
|
|
1642
1642
|
import { unified } from "unified";
|
|
1643
1643
|
import remarkParse from "remark-parse";
|
|
1644
|
-
import remarkMdx from "remark-mdx";
|
|
1645
1644
|
import remarkFrontmatter from "remark-frontmatter";
|
|
1646
1645
|
import remarkGfm from "remark-gfm";
|
|
1647
1646
|
import remarkStringify from "remark-stringify";
|
|
1648
|
-
import remarkMdxFrontmatter from "remark-mdx-frontmatter";
|
|
1649
1647
|
import { VFile } from "vfile";
|
|
1650
|
-
var parser = unified().use(remarkParse).use(
|
|
1651
|
-
var serializer = unified().use(remarkStringify).use(
|
|
1648
|
+
var parser = unified().use(remarkParse).use(remarkFrontmatter, ["yaml"]).use(remarkGfm);
|
|
1649
|
+
var serializer = unified().use(remarkStringify).use(remarkFrontmatter, ["yaml"]).use(remarkGfm);
|
|
1652
1650
|
function createMdxFormatLoader() {
|
|
1651
|
+
const skippedTypes = ["code", "inlineCode"];
|
|
1653
1652
|
return createLoader({
|
|
1654
1653
|
async pull(locale, input2) {
|
|
1655
1654
|
const file = new VFile(input2);
|
|
1656
1655
|
const ast = parser.parse(file);
|
|
1657
|
-
|
|
1656
|
+
const result = _9.cloneDeep(ast);
|
|
1657
|
+
traverseMdast(result, (node) => {
|
|
1658
|
+
if (skippedTypes.includes(node.type)) {
|
|
1659
|
+
if ("value" in node) {
|
|
1660
|
+
node.value = "";
|
|
1661
|
+
}
|
|
1662
|
+
}
|
|
1663
|
+
});
|
|
1664
|
+
return result;
|
|
1658
1665
|
},
|
|
1659
|
-
async push(locale, data) {
|
|
1660
|
-
const
|
|
1661
|
-
const
|
|
1662
|
-
|
|
1666
|
+
async push(locale, data, originalInput, originalLocale, pullInput, pullOutput) {
|
|
1667
|
+
const file = new VFile(originalInput);
|
|
1668
|
+
const ast = parser.parse(file);
|
|
1669
|
+
const result = _9.cloneDeep(ast);
|
|
1670
|
+
traverseMdast(result, (node, indexPath) => {
|
|
1671
|
+
if ("value" in node) {
|
|
1672
|
+
const incomingValue = findNodeByIndexPath(data, indexPath);
|
|
1673
|
+
if (incomingValue && "value" in incomingValue && !_9.isEmpty(incomingValue.value)) {
|
|
1674
|
+
node.value = incomingValue.value;
|
|
1675
|
+
}
|
|
1676
|
+
}
|
|
1677
|
+
});
|
|
1678
|
+
return String(serializer.stringify(result));
|
|
1663
1679
|
}
|
|
1664
1680
|
});
|
|
1665
1681
|
}
|
|
@@ -1688,6 +1704,28 @@ function createMdxStructureLoader() {
|
|
|
1688
1704
|
}
|
|
1689
1705
|
});
|
|
1690
1706
|
}
|
|
1707
|
+
function traverseMdast(ast, visitor, indexPath = []) {
|
|
1708
|
+
visitor(ast, indexPath);
|
|
1709
|
+
if ("children" in ast && Array.isArray(ast.children)) {
|
|
1710
|
+
for (let i = 0; i < ast.children.length; i++) {
|
|
1711
|
+
traverseMdast(ast.children[i], visitor, [...indexPath, i]);
|
|
1712
|
+
}
|
|
1713
|
+
}
|
|
1714
|
+
}
|
|
1715
|
+
function findNodeByIndexPath(ast, indexPath) {
|
|
1716
|
+
let result = null;
|
|
1717
|
+
const stringifiedIndexPath = indexPath.join(".");
|
|
1718
|
+
traverseMdast(ast, (node, path18) => {
|
|
1719
|
+
if (result) {
|
|
1720
|
+
return;
|
|
1721
|
+
}
|
|
1722
|
+
const currentStringifiedPath = path18.join(".");
|
|
1723
|
+
if (currentStringifiedPath === stringifiedIndexPath) {
|
|
1724
|
+
result = node;
|
|
1725
|
+
}
|
|
1726
|
+
});
|
|
1727
|
+
return result;
|
|
1728
|
+
}
|
|
1691
1729
|
|
|
1692
1730
|
// src/cli/loaders/properties.ts
|
|
1693
1731
|
function createPropertiesLoader() {
|
|
@@ -5485,7 +5523,7 @@ function validateParams2(i18nConfig, flags) {
|
|
|
5485
5523
|
// package.json
|
|
5486
5524
|
var package_default = {
|
|
5487
5525
|
name: "lingo.dev",
|
|
5488
|
-
version: "0.
|
|
5526
|
+
version: "0.86.0",
|
|
5489
5527
|
description: "Lingo.dev CLI",
|
|
5490
5528
|
private: false,
|
|
5491
5529
|
publishConfig: {
|