lingo.dev 0.74.8 → 0.74.10
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 +34 -28
- package/build/cli.cjs.map +1 -1
- package/build/cli.mjs +52 -46
- package/build/cli.mjs.map +1 -1
- package/package.json +2 -2
package/build/cli.cjs
CHANGED
|
@@ -265,12 +265,13 @@ function _getConfigFilePath() {
|
|
|
265
265
|
// src/cli/cmd/init.ts
|
|
266
266
|
|
|
267
267
|
|
|
268
|
+
|
|
268
269
|
var _child_process = require('child_process');
|
|
269
270
|
|
|
270
271
|
var _prompts = require('@inquirer/prompts');
|
|
271
|
-
var openUrl = (
|
|
272
|
+
var openUrl = (path9) => {
|
|
272
273
|
const settings = getSettings(void 0);
|
|
273
|
-
_child_process.spawn.call(void 0, "open", [`${settings.auth.webUrl}${
|
|
274
|
+
_child_process.spawn.call(void 0, "open", [`${settings.auth.webUrl}${path9}`]);
|
|
274
275
|
};
|
|
275
276
|
var throwHelpError = (option, value) => {
|
|
276
277
|
if (value === "help") {
|
|
@@ -311,20 +312,22 @@ var init_default = new (0, _interactivecommander.InteractiveCommand)().command("
|
|
|
311
312
|
return value;
|
|
312
313
|
}).default("json")
|
|
313
314
|
).addOption(
|
|
314
|
-
new (0, _interactivecommander.InteractiveOption)("-p, --paths
|
|
315
|
+
new (0, _interactivecommander.InteractiveOption)("-p, --paths [path...]", "List of paths for the bucket").argParser((value) => {
|
|
316
|
+
if (!value || value.length === 0) return [];
|
|
315
317
|
const values = value.includes(",") ? value.split(",") : value.split(" ");
|
|
316
|
-
for (const
|
|
318
|
+
for (const p of values) {
|
|
317
319
|
try {
|
|
318
|
-
const
|
|
320
|
+
const dirPath = _path2.default.dirname(p);
|
|
321
|
+
const stats = _fs2.default.statSync(dirPath);
|
|
319
322
|
if (!stats.isDirectory()) {
|
|
320
|
-
throw new Error(`${
|
|
323
|
+
throw new Error(`${dirPath} is not a directory`);
|
|
321
324
|
}
|
|
322
325
|
} catch (err) {
|
|
323
|
-
throw new Error(`Invalid
|
|
326
|
+
throw new Error(`Invalid path: ${p}`);
|
|
324
327
|
}
|
|
325
328
|
}
|
|
326
329
|
return values;
|
|
327
|
-
}).default(
|
|
330
|
+
}).default([])
|
|
328
331
|
).action(async (options) => {
|
|
329
332
|
const settings = getSettings(void 0);
|
|
330
333
|
const spinner = _ora2.default.call(void 0, ).start("Initializing Lingo.dev project");
|
|
@@ -337,7 +340,9 @@ var init_default = new (0, _interactivecommander.InteractiveCommand)().command("
|
|
|
337
340
|
newConfig.locale.source = options.source;
|
|
338
341
|
newConfig.locale.targets = options.targets;
|
|
339
342
|
newConfig.buckets = {
|
|
340
|
-
[options.bucket]:
|
|
343
|
+
[options.bucket]: {
|
|
344
|
+
include: options.paths || []
|
|
345
|
+
}
|
|
341
346
|
};
|
|
342
347
|
await saveConfig(newConfig);
|
|
343
348
|
spinner.succeed("Lingo.dev project initialized");
|
|
@@ -550,8 +555,8 @@ var files_default = new (0, _interactivecommander.Command)().command("files").de
|
|
|
550
555
|
} else if (type.target) {
|
|
551
556
|
result.push(...targetPaths);
|
|
552
557
|
}
|
|
553
|
-
result.forEach((
|
|
554
|
-
console.log(
|
|
558
|
+
result.forEach((path9) => {
|
|
559
|
+
console.log(path9);
|
|
555
560
|
});
|
|
556
561
|
}
|
|
557
562
|
}
|
|
@@ -1008,9 +1013,9 @@ function createHtmlLoader() {
|
|
|
1008
1013
|
const bDepth = b.split("/").length;
|
|
1009
1014
|
return aDepth - bDepth;
|
|
1010
1015
|
});
|
|
1011
|
-
paths.forEach((
|
|
1012
|
-
const value = data[
|
|
1013
|
-
const [nodePath, attribute] =
|
|
1016
|
+
paths.forEach((path9) => {
|
|
1017
|
+
const value = data[path9];
|
|
1018
|
+
const [nodePath, attribute] = path9.split("#");
|
|
1014
1019
|
const [rootTag, ...indices] = nodePath.split("/");
|
|
1015
1020
|
let parent = rootTag === "head" ? document.head : document.body;
|
|
1016
1021
|
let current = parent;
|
|
@@ -2014,18 +2019,18 @@ function createRawDatoValue(parsedDatoValue, originalRawDatoValue, isClean = fal
|
|
|
2014
2019
|
}
|
|
2015
2020
|
function serializeStructuredText(rawStructuredText) {
|
|
2016
2021
|
return serializeStructuredTextNode(rawStructuredText);
|
|
2017
|
-
function serializeStructuredTextNode(node,
|
|
2022
|
+
function serializeStructuredTextNode(node, path9 = [], acc = {}) {
|
|
2018
2023
|
if ("document" in node) {
|
|
2019
|
-
return serializeStructuredTextNode(node.document, [...
|
|
2024
|
+
return serializeStructuredTextNode(node.document, [...path9, "document"], acc);
|
|
2020
2025
|
}
|
|
2021
2026
|
if (!_lodash2.default.isNil(node.value)) {
|
|
2022
|
-
acc[[...
|
|
2027
|
+
acc[[...path9, "value"].join(".")] = node.value;
|
|
2023
2028
|
} else if (_lodash2.default.get(node, "type") === "block") {
|
|
2024
|
-
acc[[...
|
|
2029
|
+
acc[[...path9, "item"].join(".")] = serializeBlock(node.item);
|
|
2025
2030
|
}
|
|
2026
2031
|
if (node.children) {
|
|
2027
2032
|
for (let i = 0; i < node.children.length; i++) {
|
|
2028
|
-
serializeStructuredTextNode(node.children[i], [...
|
|
2033
|
+
serializeStructuredTextNode(node.children[i], [...path9, i.toString()], acc);
|
|
2029
2034
|
}
|
|
2030
2035
|
}
|
|
2031
2036
|
return acc;
|
|
@@ -2084,8 +2089,8 @@ function deserializeBlockList(parsedBlockList, originalRawBlockList, isClean = f
|
|
|
2084
2089
|
}
|
|
2085
2090
|
function deserializeStructuredText(parsedStructuredText, originalRawStructuredText) {
|
|
2086
2091
|
const result = _lodash2.default.cloneDeep(originalRawStructuredText);
|
|
2087
|
-
for (const [
|
|
2088
|
-
const realPath = _lodash2.default.chain(
|
|
2092
|
+
for (const [path9, value] of _lodash2.default.entries(parsedStructuredText)) {
|
|
2093
|
+
const realPath = _lodash2.default.chain(path9.split(".")).flatMap((s) => !_lodash2.default.isNaN(_lodash2.default.toNumber(s)) ? ["children", s] : s).value();
|
|
2089
2094
|
const deserializedValue = createRawDatoValue(value, _lodash2.default.get(originalRawStructuredText, realPath), true);
|
|
2090
2095
|
_lodash2.default.set(result, realPath, deserializedValue);
|
|
2091
2096
|
}
|
|
@@ -2279,7 +2284,7 @@ ${currentIndent}}`;
|
|
|
2279
2284
|
const bIsWhitespace = /^\s*$/.test(b);
|
|
2280
2285
|
if (aIsWhitespace && !bIsWhitespace) return -1;
|
|
2281
2286
|
if (!aIsWhitespace && bIsWhitespace) return 1;
|
|
2282
|
-
return a.localeCompare(b, void 0, { numeric:
|
|
2287
|
+
return a.localeCompare(b, void 0, { numeric: true });
|
|
2283
2288
|
});
|
|
2284
2289
|
const items = sortedKeys.map((key) => {
|
|
2285
2290
|
const value = data[key];
|
|
@@ -2667,7 +2672,8 @@ var i18n_default = new (0, _interactivecommander.Command)().command("i18n").desc
|
|
|
2667
2672
|
for (const bucket of buckets) {
|
|
2668
2673
|
cacheOra.info(`Processing bucket: ${bucket.type}`);
|
|
2669
2674
|
for (const bucketConfig of bucket.config) {
|
|
2670
|
-
const bucketOra =
|
|
2675
|
+
const bucketOra = _ora2.default.call(void 0, { indent: 4 });
|
|
2676
|
+
bucketOra.info(`Processing path: ${bucketConfig.pathPattern}`);
|
|
2671
2677
|
const sourceLocale = __spec.resolveOverridenLocale.call(void 0, i18nConfig.locale.source, bucketConfig.delimiter);
|
|
2672
2678
|
const bucketLoader = createBucketLoader(bucket.type, bucketConfig.pathPattern);
|
|
2673
2679
|
bucketLoader.setDefaultLocale(sourceLocale);
|
|
@@ -2771,12 +2777,12 @@ var i18n_default = new (0, _interactivecommander.Command)().command("i18n").desc
|
|
|
2771
2777
|
cacheChunk(targetLocale, sourceChunk, processedChunk);
|
|
2772
2778
|
const progressLog = `[${sourceLocale} -> ${targetLocale}] [${Object.keys(processableData).length} entries] (${progress}%) AI localization in progress...`;
|
|
2773
2779
|
if (flags.verbose) {
|
|
2774
|
-
|
|
2775
|
-
|
|
2776
|
-
`Caching chunk ${JSON.stringify(sourceChunk, null, 2)} -> ${JSON.stringify(processedChunk, null, 2)}`
|
|
2780
|
+
bucketOra.info(progressLog);
|
|
2781
|
+
bucketOra.info(
|
|
2782
|
+
`(${progress}%) Caching chunk ${JSON.stringify(sourceChunk, null, 2)} -> ${JSON.stringify(processedChunk, null, 2)}`
|
|
2777
2783
|
);
|
|
2778
2784
|
} else {
|
|
2779
|
-
|
|
2785
|
+
bucketOra.text = progressLog;
|
|
2780
2786
|
}
|
|
2781
2787
|
}
|
|
2782
2788
|
);
|
|
@@ -3157,7 +3163,7 @@ function displaySummary(results) {
|
|
|
3157
3163
|
// package.json
|
|
3158
3164
|
var package_default = {
|
|
3159
3165
|
name: "lingo.dev",
|
|
3160
|
-
version: "0.74.
|
|
3166
|
+
version: "0.74.10",
|
|
3161
3167
|
description: "Lingo.dev CLI",
|
|
3162
3168
|
private: false,
|
|
3163
3169
|
publishConfig: {
|