lingo.dev 0.117.2 → 0.117.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 +40 -7
- package/build/cli.cjs.map +1 -1
- package/build/cli.mjs +40 -7
- package/build/cli.mjs.map +1 -1
- package/package.json +1 -1
package/build/cli.cjs
CHANGED
|
@@ -2097,14 +2097,15 @@ function createYamlLoader() {
|
|
|
2097
2097
|
}
|
|
2098
2098
|
try {
|
|
2099
2099
|
const sourceDoc = _yaml2.default.parseDocument(originalInput);
|
|
2100
|
-
const metadata = extractQuotingMetadata(sourceDoc);
|
|
2101
2100
|
const outputDoc = _yaml2.default.parseDocument(
|
|
2102
2101
|
_yaml2.default.stringify(payload, {
|
|
2103
2102
|
lineWidth: -1,
|
|
2104
2103
|
defaultKeyType: "PLAIN"
|
|
2105
2104
|
})
|
|
2106
2105
|
);
|
|
2107
|
-
|
|
2106
|
+
const isRootKeyFormat = detectRootKeyFormat(sourceDoc, outputDoc);
|
|
2107
|
+
const metadata = extractQuotingMetadata(sourceDoc, isRootKeyFormat);
|
|
2108
|
+
applyQuotingMetadata(outputDoc, metadata, isRootKeyFormat);
|
|
2108
2109
|
return outputDoc.toString({ lineWidth: -1 });
|
|
2109
2110
|
} catch (error) {
|
|
2110
2111
|
console.warn("Failed to preserve YAML formatting:", error);
|
|
@@ -2117,14 +2118,39 @@ function createYamlLoader() {
|
|
|
2117
2118
|
}
|
|
2118
2119
|
});
|
|
2119
2120
|
}
|
|
2120
|
-
function
|
|
2121
|
+
function detectRootKeyFormat(sourceDoc, outputDoc) {
|
|
2122
|
+
const sourceRoot = sourceDoc.contents;
|
|
2123
|
+
const outputRoot = outputDoc.contents;
|
|
2124
|
+
if (!isYAMLMap(sourceRoot) || !isYAMLMap(outputRoot)) {
|
|
2125
|
+
return false;
|
|
2126
|
+
}
|
|
2127
|
+
const sourceMap = sourceRoot;
|
|
2128
|
+
const outputMap = outputRoot;
|
|
2129
|
+
if (!sourceMap.items || sourceMap.items.length !== 1 || !outputMap.items || outputMap.items.length !== 1) {
|
|
2130
|
+
return false;
|
|
2131
|
+
}
|
|
2132
|
+
const sourceRootKey = getKeyValue(sourceMap.items[0].key);
|
|
2133
|
+
const outputRootKey = getKeyValue(outputMap.items[0].key);
|
|
2134
|
+
if (sourceRootKey !== outputRootKey && typeof sourceRootKey === "string" && typeof outputRootKey === "string") {
|
|
2135
|
+
return true;
|
|
2136
|
+
}
|
|
2137
|
+
return false;
|
|
2138
|
+
}
|
|
2139
|
+
function extractQuotingMetadata(doc, skipRootKey) {
|
|
2121
2140
|
const metadata = {
|
|
2122
2141
|
keys: /* @__PURE__ */ new Map(),
|
|
2123
2142
|
values: /* @__PURE__ */ new Map()
|
|
2124
2143
|
};
|
|
2125
2144
|
const root = doc.contents;
|
|
2126
2145
|
if (!root) return metadata;
|
|
2127
|
-
|
|
2146
|
+
let startNode = root;
|
|
2147
|
+
if (skipRootKey && isYAMLMap(root)) {
|
|
2148
|
+
const rootMap = root;
|
|
2149
|
+
if (rootMap.items && rootMap.items.length === 1) {
|
|
2150
|
+
startNode = rootMap.items[0].value;
|
|
2151
|
+
}
|
|
2152
|
+
}
|
|
2153
|
+
walkAndExtract(startNode, [], metadata);
|
|
2128
2154
|
return metadata;
|
|
2129
2155
|
}
|
|
2130
2156
|
function walkAndExtract(node, path19, metadata) {
|
|
@@ -2159,10 +2185,17 @@ function walkAndExtract(node, path19, metadata) {
|
|
|
2159
2185
|
}
|
|
2160
2186
|
}
|
|
2161
2187
|
}
|
|
2162
|
-
function applyQuotingMetadata(doc, metadata) {
|
|
2188
|
+
function applyQuotingMetadata(doc, metadata, skipRootKey) {
|
|
2163
2189
|
const root = doc.contents;
|
|
2164
2190
|
if (!root) return;
|
|
2165
|
-
|
|
2191
|
+
let startNode = root;
|
|
2192
|
+
if (skipRootKey && isYAMLMap(root)) {
|
|
2193
|
+
const rootMap = root;
|
|
2194
|
+
if (rootMap.items && rootMap.items.length === 1) {
|
|
2195
|
+
startNode = rootMap.items[0].value;
|
|
2196
|
+
}
|
|
2197
|
+
}
|
|
2198
|
+
walkAndApply(startNode, [], metadata);
|
|
2166
2199
|
}
|
|
2167
2200
|
function walkAndApply(node, path19, metadata) {
|
|
2168
2201
|
if (isScalar(node)) {
|
|
@@ -13619,7 +13652,7 @@ async function renderHero2() {
|
|
|
13619
13652
|
// package.json
|
|
13620
13653
|
var package_default = {
|
|
13621
13654
|
name: "lingo.dev",
|
|
13622
|
-
version: "0.117.
|
|
13655
|
+
version: "0.117.3",
|
|
13623
13656
|
description: "Lingo.dev CLI",
|
|
13624
13657
|
private: false,
|
|
13625
13658
|
publishConfig: {
|