lingo.dev 0.75.1 → 0.76.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 +19 -19
- package/build/cli.cjs.map +1 -1
- package/build/cli.mjs +19 -19
- package/build/cli.mjs.map +1 -1
- package/package.json +3 -3
package/build/cli.cjs
CHANGED
|
@@ -325,8 +325,7 @@ function findLocaleFilesWithExtension(ext) {
|
|
|
325
325
|
return { file, locale: null };
|
|
326
326
|
}).filter(({ locale }) => locale !== null);
|
|
327
327
|
const localeFilesAndPatterns = potantialLocaleFilesAndPatterns.map(({ file, locale }) => {
|
|
328
|
-
const
|
|
329
|
-
const pattern = localeInDir ? file.replace(`/${locale}/`, `/[locale]/`) : _path2.default.join(_path2.default.dirname(file), `[locale]${ext}`);
|
|
328
|
+
const pattern = file.replaceAll(new RegExp(`/${locale}${ext}`, "g"), `/[locale]${ext}`).replaceAll(new RegExp(`/${locale}/`, "g"), `/[locale]/`).replaceAll(new RegExp(`/${locale}/`, "g"), `/[locale]/`);
|
|
330
329
|
return { pattern, file };
|
|
331
330
|
});
|
|
332
331
|
const grouppedFilesAndPatterns = _lodash2.default.groupBy(localeFilesAndPatterns, "pattern");
|
|
@@ -698,24 +697,25 @@ function expandPlaceholderedGlob(_pathPattern, sourceLocale) {
|
|
|
698
697
|
docUrl: "invalidPathPattern"
|
|
699
698
|
});
|
|
700
699
|
}
|
|
701
|
-
if (pathPattern.split("[locale]").length > 2) {
|
|
702
|
-
throw new CLIError({
|
|
703
|
-
message: `Invalid path pattern: ${pathPattern}. Path pattern must contain at most one "[locale]" placeholder.`,
|
|
704
|
-
docUrl: "invalidPathPattern"
|
|
705
|
-
});
|
|
706
|
-
}
|
|
707
700
|
const pathPatternChunks = pathPattern.split(_path2.default.sep);
|
|
708
|
-
const
|
|
709
|
-
|
|
710
|
-
|
|
701
|
+
const localeSegmentIndexes = pathPatternChunks.reduce((indexes, segment, index) => {
|
|
702
|
+
if (segment.includes("[locale]")) {
|
|
703
|
+
indexes.push(index);
|
|
704
|
+
}
|
|
705
|
+
return indexes;
|
|
706
|
+
}, []);
|
|
707
|
+
const sourcePathPattern = pathPattern.replaceAll(/\[locale\]/g, sourceLocale);
|
|
711
708
|
const sourcePaths = glob2.sync(sourcePathPattern, { follow: true, withFileTypes: true }).filter((file) => file.isFile() || file.isSymbolicLink()).map((file) => file.fullpath()).map((fullpath) => _path2.default.relative(process.cwd(), fullpath));
|
|
712
709
|
const placeholderedPaths = sourcePaths.map((sourcePath) => {
|
|
713
710
|
const sourcePathChunks = sourcePath.split(_path2.default.sep);
|
|
714
|
-
|
|
715
|
-
const
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
711
|
+
localeSegmentIndexes.forEach((localeSegmentIndex) => {
|
|
712
|
+
const localePlaceholderIndex = _nullishCoalesce(_optionalChain([pathPatternChunks, 'access', _35 => _35[localeSegmentIndex], 'optionalAccess', _36 => _36.indexOf, 'call', _37 => _37("[locale]")]), () => ( -1));
|
|
713
|
+
if (localeSegmentIndex >= 0 && localePlaceholderIndex >= 0) {
|
|
714
|
+
const placeholderedPathChunk = sourcePathChunks[localeSegmentIndex];
|
|
715
|
+
const placeholderedSegment = placeholderedPathChunk.substring(0, localePlaceholderIndex) + "[locale]" + placeholderedPathChunk.substring(localePlaceholderIndex + sourceLocale.length);
|
|
716
|
+
sourcePathChunks[localeSegmentIndex] = placeholderedSegment;
|
|
717
|
+
}
|
|
718
|
+
});
|
|
719
719
|
const placeholderedPath = sourcePathChunks.join(_path2.default.sep);
|
|
720
720
|
return placeholderedPath;
|
|
721
721
|
});
|
|
@@ -991,7 +991,7 @@ function createTextFileLoader(pathPattern) {
|
|
|
991
991
|
return trimmedResult;
|
|
992
992
|
},
|
|
993
993
|
async push(locale, data, _21, originalLocale) {
|
|
994
|
-
const draftPath = pathPattern.
|
|
994
|
+
const draftPath = pathPattern.replaceAll("[locale]", locale);
|
|
995
995
|
const finalPath = _path2.default.resolve(draftPath);
|
|
996
996
|
const dirPath = _path2.default.dirname(finalPath);
|
|
997
997
|
await _promises4.default.mkdir(dirPath, { recursive: true });
|
|
@@ -1006,7 +1006,7 @@ function createTextFileLoader(pathPattern) {
|
|
|
1006
1006
|
});
|
|
1007
1007
|
}
|
|
1008
1008
|
async function readFileForLocale(pathPattern, locale) {
|
|
1009
|
-
const draftPath = pathPattern.
|
|
1009
|
+
const draftPath = pathPattern.replaceAll("[locale]", locale);
|
|
1010
1010
|
const finalPath = _path2.default.resolve(draftPath);
|
|
1011
1011
|
const exists = await _promises4.default.access(finalPath).then(() => true).catch(() => false);
|
|
1012
1012
|
if (!exists) {
|
|
@@ -3520,7 +3520,7 @@ function displaySummary(results) {
|
|
|
3520
3520
|
// package.json
|
|
3521
3521
|
var package_default = {
|
|
3522
3522
|
name: "lingo.dev",
|
|
3523
|
-
version: "0.
|
|
3523
|
+
version: "0.76.0",
|
|
3524
3524
|
description: "Lingo.dev CLI",
|
|
3525
3525
|
private: false,
|
|
3526
3526
|
publishConfig: {
|