lingo.dev 0.118.0 → 0.120.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/agents.md +12 -0
- package/build/cli.cjs +354 -231
- package/build/cli.cjs.map +1 -1
- package/build/cli.mjs +344 -221
- package/build/cli.mjs.map +1 -1
- package/package.json +8 -7
package/build/cli.cjs
CHANGED
|
@@ -14,9 +14,9 @@ var _ora = require('ora'); var _ora2 = _interopRequireDefault(_ora);
|
|
|
14
14
|
|
|
15
15
|
// src/cli/utils/settings.ts
|
|
16
16
|
var _os = require('os'); var _os2 = _interopRequireDefault(_os);
|
|
17
|
-
var _path = require('path'); var
|
|
17
|
+
var _path = require('path'); var path15 = _interopRequireWildcard(_path); var path16 = _interopRequireWildcard(_path);
|
|
18
18
|
var _zod = require('zod'); var _zod2 = _interopRequireDefault(_zod);
|
|
19
|
-
var _fs = require('fs'); var
|
|
19
|
+
var _fs = require('fs'); var fs13 = _interopRequireWildcard(_fs);
|
|
20
20
|
var _ini = require('ini'); var _ini2 = _interopRequireDefault(_ini);
|
|
21
21
|
function getSettings(explicitApiKey) {
|
|
22
22
|
const env = _loadEnv();
|
|
@@ -105,7 +105,7 @@ function _loadEnv() {
|
|
|
105
105
|
}
|
|
106
106
|
function _loadSystemFile() {
|
|
107
107
|
const settingsFilePath = _getSettingsFilePath();
|
|
108
|
-
const content =
|
|
108
|
+
const content = fs13.default.existsSync(settingsFilePath) ? fs13.default.readFileSync(settingsFilePath, "utf-8") : "";
|
|
109
109
|
const data = _ini2.default.parse(content);
|
|
110
110
|
return _zod2.default.object({
|
|
111
111
|
auth: _zod2.default.object({
|
|
@@ -129,12 +129,12 @@ function _loadSystemFile() {
|
|
|
129
129
|
function _saveSystemFile(settings) {
|
|
130
130
|
const settingsFilePath = _getSettingsFilePath();
|
|
131
131
|
const content = _ini2.default.stringify(settings);
|
|
132
|
-
|
|
132
|
+
fs13.default.writeFileSync(settingsFilePath, content);
|
|
133
133
|
}
|
|
134
134
|
function _getSettingsFilePath() {
|
|
135
135
|
const settingsFile = ".lingodotdevrc";
|
|
136
136
|
const homedir = _os2.default.homedir();
|
|
137
|
-
const settingsFilePath =
|
|
137
|
+
const settingsFilePath = path15.default.join(homedir, settingsFile);
|
|
138
138
|
return settingsFilePath;
|
|
139
139
|
}
|
|
140
140
|
function _legacyEnvVarWarning() {
|
|
@@ -533,7 +533,7 @@ var colors = {
|
|
|
533
533
|
// src/cli/utils/ui.ts
|
|
534
534
|
|
|
535
535
|
function isCI() {
|
|
536
|
-
return Boolean(process.env.CI) ||
|
|
536
|
+
return Boolean(process.env.CI) || fs13.default.existsSync("/.dockerenv");
|
|
537
537
|
}
|
|
538
538
|
async function renderClear() {
|
|
539
539
|
console.log("\x1Bc");
|
|
@@ -739,11 +739,11 @@ var _lodash = require('lodash'); var _lodash2 = _interopRequireDefault(_lodash);
|
|
|
739
739
|
var __spec = require('@lingo.dev/_spec');
|
|
740
740
|
function getConfig(resave = true) {
|
|
741
741
|
const configFilePath = _getConfigFilePath();
|
|
742
|
-
const configFileExists =
|
|
742
|
+
const configFileExists = fs13.default.existsSync(configFilePath);
|
|
743
743
|
if (!configFileExists) {
|
|
744
744
|
return null;
|
|
745
745
|
}
|
|
746
|
-
const fileContents =
|
|
746
|
+
const fileContents = fs13.default.readFileSync(configFilePath, "utf8");
|
|
747
747
|
const rawConfig = JSON.parse(fileContents);
|
|
748
748
|
const result = __spec.parseI18nConfig.call(void 0, rawConfig);
|
|
749
749
|
const didConfigChange = !_lodash2.default.isEqual(rawConfig, result);
|
|
@@ -755,11 +755,11 @@ function getConfig(resave = true) {
|
|
|
755
755
|
function saveConfig(config) {
|
|
756
756
|
const configFilePath = _getConfigFilePath();
|
|
757
757
|
const serialized = JSON.stringify(config, null, 2);
|
|
758
|
-
|
|
758
|
+
fs13.default.writeFileSync(configFilePath, serialized);
|
|
759
759
|
return config;
|
|
760
760
|
}
|
|
761
761
|
function _getConfigFilePath() {
|
|
762
|
-
return
|
|
762
|
+
return path15.default.join(process.cwd(), "i18n.json");
|
|
763
763
|
}
|
|
764
764
|
|
|
765
765
|
// src/cli/cmd/init.ts
|
|
@@ -854,7 +854,7 @@ function findLocaleFilesForFilename(fileName) {
|
|
|
854
854
|
});
|
|
855
855
|
const localeFilesAndPatterns = localeFiles.map((file) => ({
|
|
856
856
|
file,
|
|
857
|
-
pattern:
|
|
857
|
+
pattern: path15.default.join(path15.default.dirname(file), pattern)
|
|
858
858
|
}));
|
|
859
859
|
const grouppedFilesAndPatterns = _lodash2.default.groupBy(localeFilesAndPatterns, "pattern");
|
|
860
860
|
const patterns = Object.keys(grouppedFilesAndPatterns);
|
|
@@ -874,10 +874,10 @@ function ensurePatterns(patterns, source) {
|
|
|
874
874
|
}
|
|
875
875
|
patterns.forEach((pattern) => {
|
|
876
876
|
const filePath = pattern.replace("[locale]", source);
|
|
877
|
-
if (!
|
|
878
|
-
const defaultContent = getDefaultContent(
|
|
879
|
-
|
|
880
|
-
|
|
877
|
+
if (!fs13.default.existsSync(filePath)) {
|
|
878
|
+
const defaultContent = getDefaultContent(path15.default.extname(filePath), source);
|
|
879
|
+
fs13.default.mkdirSync(path15.default.dirname(filePath), { recursive: true });
|
|
880
|
+
fs13.default.writeFileSync(filePath, defaultContent);
|
|
881
881
|
}
|
|
882
882
|
});
|
|
883
883
|
}
|
|
@@ -956,31 +956,31 @@ function updateGitignore() {
|
|
|
956
956
|
if (!projectRoot) {
|
|
957
957
|
return;
|
|
958
958
|
}
|
|
959
|
-
const gitignorePath =
|
|
960
|
-
if (!
|
|
959
|
+
const gitignorePath = path15.default.join(projectRoot, ".gitignore");
|
|
960
|
+
if (!fs13.default.existsSync(gitignorePath)) {
|
|
961
961
|
return;
|
|
962
962
|
}
|
|
963
|
-
const gitignore =
|
|
963
|
+
const gitignore = fs13.default.readFileSync(gitignorePath, "utf8").split("\n");
|
|
964
964
|
const cacheIsIgnored = gitignore.includes(cacheFile);
|
|
965
965
|
if (!cacheIsIgnored) {
|
|
966
966
|
let content = "";
|
|
967
|
-
content =
|
|
967
|
+
content = fs13.default.readFileSync(gitignorePath, "utf8");
|
|
968
968
|
if (content !== "" && !content.endsWith("\n")) {
|
|
969
969
|
content += "\n";
|
|
970
970
|
}
|
|
971
971
|
content += `${cacheFile}
|
|
972
972
|
`;
|
|
973
|
-
|
|
973
|
+
fs13.default.writeFileSync(gitignorePath, content);
|
|
974
974
|
}
|
|
975
975
|
}
|
|
976
976
|
function findCurrentProjectRoot() {
|
|
977
977
|
let currentDir = process.cwd();
|
|
978
|
-
while (currentDir !==
|
|
979
|
-
const gitDirPath =
|
|
980
|
-
if (
|
|
978
|
+
while (currentDir !== path15.default.parse(currentDir).root) {
|
|
979
|
+
const gitDirPath = path15.default.join(currentDir, ".git");
|
|
980
|
+
if (fs13.default.existsSync(gitDirPath) && fs13.default.lstatSync(gitDirPath).isDirectory()) {
|
|
981
981
|
return currentDir;
|
|
982
982
|
}
|
|
983
|
-
currentDir =
|
|
983
|
+
currentDir = path15.default.dirname(currentDir);
|
|
984
984
|
}
|
|
985
985
|
return null;
|
|
986
986
|
}
|
|
@@ -1024,24 +1024,24 @@ function makePlatformInitializer(config, spinner) {
|
|
|
1024
1024
|
return {
|
|
1025
1025
|
name: config.name,
|
|
1026
1026
|
isEnabled: () => {
|
|
1027
|
-
const filePath =
|
|
1028
|
-
return
|
|
1027
|
+
const filePath = path15.default.join(process.cwd(), config.checkPath);
|
|
1028
|
+
return fs13.default.existsSync(filePath);
|
|
1029
1029
|
},
|
|
1030
1030
|
init: async () => {
|
|
1031
|
-
const filePath =
|
|
1032
|
-
const dirPath =
|
|
1033
|
-
if (!
|
|
1034
|
-
|
|
1031
|
+
const filePath = path15.default.join(process.cwd(), config.ciConfigPath);
|
|
1032
|
+
const dirPath = path15.default.dirname(filePath);
|
|
1033
|
+
if (!fs13.default.existsSync(dirPath)) {
|
|
1034
|
+
fs13.default.mkdirSync(dirPath, { recursive: true });
|
|
1035
1035
|
}
|
|
1036
1036
|
let canWrite = true;
|
|
1037
|
-
if (
|
|
1037
|
+
if (fs13.default.existsSync(filePath)) {
|
|
1038
1038
|
canWrite = await _prompts.confirm.call(void 0, {
|
|
1039
1039
|
message: `File ${filePath} already exists. Do you want to overwrite it?`,
|
|
1040
1040
|
default: false
|
|
1041
1041
|
});
|
|
1042
1042
|
}
|
|
1043
1043
|
if (canWrite) {
|
|
1044
|
-
|
|
1044
|
+
fs13.default.writeFileSync(filePath, config.ciConfigContent);
|
|
1045
1045
|
spinner.succeed(`CI/CD initialized for ${config.name}`);
|
|
1046
1046
|
} else {
|
|
1047
1047
|
spinner.warn(`CI/CD not initialized for ${config.name}`);
|
|
@@ -1115,9 +1115,56 @@ function makeGitlabInitializer(spinner) {
|
|
|
1115
1115
|
|
|
1116
1116
|
// src/cli/cmd/init.ts
|
|
1117
1117
|
|
|
1118
|
-
|
|
1118
|
+
|
|
1119
|
+
// src/cli/cmd/init/cursor.ts
|
|
1120
|
+
|
|
1121
|
+
|
|
1122
|
+
|
|
1123
|
+
|
|
1124
|
+
var _url = require('url');
|
|
1125
|
+
|
|
1126
|
+
var __filename = _url.fileURLToPath.call(void 0, _chunkEHIR4A2Gcjs.importMetaUrl);
|
|
1127
|
+
var __dirname = path15.default.dirname(__filename);
|
|
1128
|
+
var AGENTS_MD = fs13.default.existsSync(path15.default.resolve(__dirname, "../agents.md")) ? path15.default.resolve(__dirname, "../agents.md") : path15.default.resolve(__dirname, "../../../../agents.md");
|
|
1129
|
+
var CURSORRULES = path15.default.resolve(process.cwd(), ".cursorrules");
|
|
1130
|
+
var cursor_default = new (0, _interactivecommander.InteractiveCommand)().command("cursor").description("Initialize .cursorrules with i18n-specific instructions for Cursor AI.").addOption(
|
|
1131
|
+
new (0, _interactivecommander.InteractiveOption)("-f, --force", "Overwrite .cursorrules without prompt.").default(false)
|
|
1132
|
+
).action(async (options) => {
|
|
1133
|
+
const spinner = _ora2.default.call(void 0, );
|
|
1134
|
+
let template;
|
|
1135
|
+
try {
|
|
1136
|
+
template = fs13.default.readFileSync(AGENTS_MD, "utf-8");
|
|
1137
|
+
} catch (err) {
|
|
1138
|
+
spinner.fail("Template file agents.md not found. Please reinstall the package.");
|
|
1139
|
+
return process.exit(1);
|
|
1140
|
+
}
|
|
1141
|
+
const exists = fs13.default.existsSync(CURSORRULES);
|
|
1142
|
+
let shouldWrite;
|
|
1143
|
+
if (exists && !options.force) {
|
|
1144
|
+
shouldWrite = await _prompts.confirm.call(void 0, {
|
|
1145
|
+
message: ".cursorrules already exists. Overwrite?"
|
|
1146
|
+
});
|
|
1147
|
+
if (!shouldWrite) {
|
|
1148
|
+
spinner.info("Skipped: .cursorrules left unchanged.");
|
|
1149
|
+
return;
|
|
1150
|
+
}
|
|
1151
|
+
}
|
|
1152
|
+
try {
|
|
1153
|
+
fs13.default.writeFileSync(CURSORRULES, template);
|
|
1154
|
+
spinner.succeed("Created .cursorrules");
|
|
1155
|
+
spinner.info(
|
|
1156
|
+
".cursorrules has been created with i18n-specific instructions for Cursor AI."
|
|
1157
|
+
);
|
|
1158
|
+
} catch (err) {
|
|
1159
|
+
spinner.fail(`Failed to write .cursorrules: ${err}`);
|
|
1160
|
+
process.exit(1);
|
|
1161
|
+
}
|
|
1162
|
+
});
|
|
1163
|
+
|
|
1164
|
+
// src/cli/cmd/init.ts
|
|
1165
|
+
var openUrl = (path20) => {
|
|
1119
1166
|
const settings = getSettings(void 0);
|
|
1120
|
-
_open2.default.call(void 0, `${settings.auth.webUrl}${
|
|
1167
|
+
_open2.default.call(void 0, `${settings.auth.webUrl}${path20}`, { wait: false });
|
|
1121
1168
|
};
|
|
1122
1169
|
var throwHelpError = (option, value) => {
|
|
1123
1170
|
if (value === "help") {
|
|
@@ -1180,8 +1227,8 @@ var init_default = new (0, _interactivecommander.InteractiveCommand)().command("
|
|
|
1180
1227
|
const values = value.includes(",") ? value.split(",") : value.split(" ");
|
|
1181
1228
|
for (const p of values) {
|
|
1182
1229
|
try {
|
|
1183
|
-
const dirPath =
|
|
1184
|
-
const stats =
|
|
1230
|
+
const dirPath = path15.default.dirname(p);
|
|
1231
|
+
const stats = fs13.default.statSync(dirPath);
|
|
1185
1232
|
if (!stats.isDirectory()) {
|
|
1186
1233
|
throw new Error(`${dirPath} is not a directory`);
|
|
1187
1234
|
}
|
|
@@ -1306,7 +1353,7 @@ var init_default = new (0, _interactivecommander.InteractiveCommand)().command("
|
|
|
1306
1353
|
if (!isInteractive) {
|
|
1307
1354
|
_ora2.default.call(void 0, ).info("Please see https://lingo.dev/cli");
|
|
1308
1355
|
}
|
|
1309
|
-
});
|
|
1356
|
+
}).addCommand(cursor_default);
|
|
1310
1357
|
|
|
1311
1358
|
// src/cli/cmd/show/index.ts
|
|
1312
1359
|
|
|
@@ -1323,12 +1370,12 @@ var config_default = new (0, _interactivecommander.Command)().command("config").
|
|
|
1323
1370
|
console.log(JSON.stringify(config, null, 2));
|
|
1324
1371
|
});
|
|
1325
1372
|
function loadReplexicaFileConfig() {
|
|
1326
|
-
const replexicaConfigPath =
|
|
1327
|
-
const fileExists =
|
|
1373
|
+
const replexicaConfigPath = path15.default.resolve(process.cwd(), "i18n.json");
|
|
1374
|
+
const fileExists = fs13.default.existsSync(replexicaConfigPath);
|
|
1328
1375
|
if (!fileExists) {
|
|
1329
1376
|
return void 0;
|
|
1330
1377
|
}
|
|
1331
|
-
const fileContent =
|
|
1378
|
+
const fileContent = fs13.default.readFileSync(replexicaConfigPath, "utf-8");
|
|
1332
1379
|
const replexicaFileConfig = JSON.parse(fileContent);
|
|
1333
1380
|
return replexicaFileConfig;
|
|
1334
1381
|
}
|
|
@@ -1434,13 +1481,13 @@ function extractPathPatterns(sourceLocale, include, exclude) {
|
|
|
1434
1481
|
return result;
|
|
1435
1482
|
}
|
|
1436
1483
|
function normalizePath(filepath) {
|
|
1437
|
-
const normalized =
|
|
1484
|
+
const normalized = path15.default.normalize(filepath);
|
|
1438
1485
|
return process.platform === "win32" ? normalized.toLowerCase() : normalized;
|
|
1439
1486
|
}
|
|
1440
1487
|
function expandPlaceholderedGlob(_pathPattern, sourceLocale) {
|
|
1441
|
-
const absolutePathPattern =
|
|
1488
|
+
const absolutePathPattern = path15.default.resolve(_pathPattern);
|
|
1442
1489
|
const pathPattern = normalizePath(
|
|
1443
|
-
|
|
1490
|
+
path15.default.relative(process.cwd(), absolutePathPattern)
|
|
1444
1491
|
);
|
|
1445
1492
|
if (pathPattern.startsWith("..")) {
|
|
1446
1493
|
throw new CLIError({
|
|
@@ -1454,7 +1501,7 @@ function expandPlaceholderedGlob(_pathPattern, sourceLocale) {
|
|
|
1454
1501
|
docUrl: "invalidPathPattern"
|
|
1455
1502
|
});
|
|
1456
1503
|
}
|
|
1457
|
-
const pathPatternChunks = pathPattern.split(
|
|
1504
|
+
const pathPatternChunks = pathPattern.split(path15.default.sep);
|
|
1458
1505
|
const localeSegmentIndexes = pathPatternChunks.reduce(
|
|
1459
1506
|
(indexes, segment, index) => {
|
|
1460
1507
|
if (segment.includes("[locale]")) {
|
|
@@ -1471,12 +1518,12 @@ function expandPlaceholderedGlob(_pathPattern, sourceLocale) {
|
|
|
1471
1518
|
withFileTypes: true,
|
|
1472
1519
|
windowsPathsNoEscape: true
|
|
1473
1520
|
// Windows path support
|
|
1474
|
-
}).filter((file) => file.isFile() || file.isSymbolicLink()).map((file) => file.fullpath()).map((fullpath) => normalizePath(
|
|
1521
|
+
}).filter((file) => file.isFile() || file.isSymbolicLink()).map((file) => file.fullpath()).map((fullpath) => normalizePath(path15.default.relative(process.cwd(), fullpath)));
|
|
1475
1522
|
const placeholderedPaths = sourcePaths.map((sourcePath) => {
|
|
1476
1523
|
const normalizedSourcePath = normalizePath(
|
|
1477
|
-
sourcePath.replace(/\//g,
|
|
1524
|
+
sourcePath.replace(/\//g, path15.default.sep)
|
|
1478
1525
|
);
|
|
1479
|
-
const sourcePathChunks = normalizedSourcePath.split(
|
|
1526
|
+
const sourcePathChunks = normalizedSourcePath.split(path15.default.sep);
|
|
1480
1527
|
localeSegmentIndexes.forEach((localeSegmentIndex) => {
|
|
1481
1528
|
const pathPatternChunk = pathPatternChunks[localeSegmentIndex];
|
|
1482
1529
|
const sourcePathChunk = sourcePathChunks[localeSegmentIndex];
|
|
@@ -1490,7 +1537,7 @@ function expandPlaceholderedGlob(_pathPattern, sourceLocale) {
|
|
|
1490
1537
|
sourcePathChunks[localeSegmentIndex] = placeholderedSegment;
|
|
1491
1538
|
}
|
|
1492
1539
|
});
|
|
1493
|
-
const placeholderedPath = sourcePathChunks.join(
|
|
1540
|
+
const placeholderedPath = sourcePathChunks.join(path15.default.sep);
|
|
1494
1541
|
return placeholderedPath;
|
|
1495
1542
|
});
|
|
1496
1543
|
return placeholderedPaths;
|
|
@@ -1554,8 +1601,8 @@ var files_default = new (0, _interactivecommander.Command)().command("files").de
|
|
|
1554
1601
|
} else if (type.target) {
|
|
1555
1602
|
result.push(...targetPaths);
|
|
1556
1603
|
}
|
|
1557
|
-
result.forEach((
|
|
1558
|
-
console.log(
|
|
1604
|
+
result.forEach((path20) => {
|
|
1605
|
+
console.log(path20);
|
|
1559
1606
|
});
|
|
1560
1607
|
}
|
|
1561
1608
|
}
|
|
@@ -1752,8 +1799,8 @@ function extractCommentsFromJsonc(jsoncString) {
|
|
|
1752
1799
|
const keyMatch = line.match(/^\s*["']?([^"':,\s]+)["']?\s*:/);
|
|
1753
1800
|
if (keyMatch) {
|
|
1754
1801
|
const key = keyMatch[1];
|
|
1755
|
-
const
|
|
1756
|
-
keyInfo = { key, path:
|
|
1802
|
+
const path20 = contextStack.map((ctx) => ctx.arrayIndex !== void 0 ? String(ctx.arrayIndex) : ctx.key).filter(Boolean);
|
|
1803
|
+
keyInfo = { key, path: path20 };
|
|
1757
1804
|
}
|
|
1758
1805
|
} else {
|
|
1759
1806
|
keyInfo = findAssociatedKey(lines, commentData.lineIndex, contextStack, arrayObjectCount);
|
|
@@ -1845,9 +1892,9 @@ function findAssociatedKey(lines, commentLineIndex, contextStack, arrayObjectCou
|
|
|
1845
1892
|
const keyMatch2 = innerLine.match(/^\s*["']?([^"':,\s]+)["']?\s*:/);
|
|
1846
1893
|
if (keyMatch2) {
|
|
1847
1894
|
const key = keyMatch2[1];
|
|
1848
|
-
const
|
|
1849
|
-
|
|
1850
|
-
return { key, path:
|
|
1895
|
+
const path20 = contextStack.map((ctx) => ctx.arrayIndex !== void 0 ? String(ctx.arrayIndex) : ctx.key).filter(Boolean);
|
|
1896
|
+
path20.push(String(arrayIndex));
|
|
1897
|
+
return { key, path: path20 };
|
|
1851
1898
|
}
|
|
1852
1899
|
if (innerLine === "}") break;
|
|
1853
1900
|
}
|
|
@@ -1859,8 +1906,8 @@ function findAssociatedKey(lines, commentLineIndex, contextStack, arrayObjectCou
|
|
|
1859
1906
|
const keyMatch = line.match(/^\s*["']?([^"':,\s]+)["']?\s*:/);
|
|
1860
1907
|
if (keyMatch) {
|
|
1861
1908
|
const key = keyMatch[1];
|
|
1862
|
-
const
|
|
1863
|
-
return { key, path:
|
|
1909
|
+
const path20 = contextStack.map((ctx) => ctx.arrayIndex !== void 0 ? String(ctx.arrayIndex) : ctx.key).filter(Boolean);
|
|
1910
|
+
return { key, path: path20 };
|
|
1864
1911
|
}
|
|
1865
1912
|
}
|
|
1866
1913
|
return { key: null, path: [] };
|
|
@@ -1907,9 +1954,9 @@ function updateContext(contextStack, line, parsedJson, arrayObjectCount) {
|
|
|
1907
1954
|
}
|
|
1908
1955
|
}
|
|
1909
1956
|
}
|
|
1910
|
-
function setCommentAtPath(comments,
|
|
1957
|
+
function setCommentAtPath(comments, path20, key, hint) {
|
|
1911
1958
|
let current = comments;
|
|
1912
|
-
for (const pathKey of
|
|
1959
|
+
for (const pathKey of path20) {
|
|
1913
1960
|
if (!current[pathKey]) {
|
|
1914
1961
|
current[pathKey] = {};
|
|
1915
1962
|
}
|
|
@@ -2119,8 +2166,8 @@ function createTextFileLoader(pathPattern) {
|
|
|
2119
2166
|
},
|
|
2120
2167
|
async push(locale, data, _37, originalLocale) {
|
|
2121
2168
|
const draftPath = pathPattern.replaceAll("[locale]", locale);
|
|
2122
|
-
const finalPath =
|
|
2123
|
-
const dirPath =
|
|
2169
|
+
const finalPath = path15.default.resolve(draftPath);
|
|
2170
|
+
const dirPath = path15.default.dirname(finalPath);
|
|
2124
2171
|
await _promises4.default.mkdir(dirPath, { recursive: true });
|
|
2125
2172
|
const trimmedPayload = data.trim();
|
|
2126
2173
|
const trailingNewLine = await getTrailingNewLine(
|
|
@@ -2138,7 +2185,7 @@ function createTextFileLoader(pathPattern) {
|
|
|
2138
2185
|
}
|
|
2139
2186
|
async function readFileForLocale(pathPattern, locale) {
|
|
2140
2187
|
const draftPath = pathPattern.replaceAll("[locale]", locale);
|
|
2141
|
-
const finalPath =
|
|
2188
|
+
const finalPath = path15.default.resolve(draftPath);
|
|
2142
2189
|
const exists = await _promises4.default.access(finalPath).then(() => true).catch(() => false);
|
|
2143
2190
|
if (!exists) {
|
|
2144
2191
|
return "";
|
|
@@ -2230,10 +2277,10 @@ function extractQuotingMetadata(doc, skipRootKey) {
|
|
|
2230
2277
|
walkAndExtract(startNode, [], metadata);
|
|
2231
2278
|
return metadata;
|
|
2232
2279
|
}
|
|
2233
|
-
function walkAndExtract(node,
|
|
2280
|
+
function walkAndExtract(node, path20, metadata) {
|
|
2234
2281
|
if (isScalar(node)) {
|
|
2235
2282
|
if (node.type && node.type !== "PLAIN") {
|
|
2236
|
-
metadata.values.set(
|
|
2283
|
+
metadata.values.set(path20.join("."), node.type);
|
|
2237
2284
|
}
|
|
2238
2285
|
} else if (isYAMLMap(node)) {
|
|
2239
2286
|
if (node.items && Array.isArray(node.items)) {
|
|
@@ -2241,12 +2288,12 @@ function walkAndExtract(node, path19, metadata) {
|
|
|
2241
2288
|
if (pair && pair.key) {
|
|
2242
2289
|
const key = getKeyValue(pair.key);
|
|
2243
2290
|
if (key !== null && key !== void 0) {
|
|
2244
|
-
const keyPath = [...
|
|
2291
|
+
const keyPath = [...path20, String(key)].join(".");
|
|
2245
2292
|
if (pair.key.type && pair.key.type !== "PLAIN") {
|
|
2246
2293
|
metadata.keys.set(keyPath, pair.key.type);
|
|
2247
2294
|
}
|
|
2248
2295
|
if (pair.value) {
|
|
2249
|
-
walkAndExtract(pair.value, [...
|
|
2296
|
+
walkAndExtract(pair.value, [...path20, String(key)], metadata);
|
|
2250
2297
|
}
|
|
2251
2298
|
}
|
|
2252
2299
|
}
|
|
@@ -2256,7 +2303,7 @@ function walkAndExtract(node, path19, metadata) {
|
|
|
2256
2303
|
if (node.items && Array.isArray(node.items)) {
|
|
2257
2304
|
for (let i = 0; i < node.items.length; i++) {
|
|
2258
2305
|
if (node.items[i]) {
|
|
2259
|
-
walkAndExtract(node.items[i], [...
|
|
2306
|
+
walkAndExtract(node.items[i], [...path20, String(i)], metadata);
|
|
2260
2307
|
}
|
|
2261
2308
|
}
|
|
2262
2309
|
}
|
|
@@ -2274,9 +2321,9 @@ function applyQuotingMetadata(doc, metadata, skipRootKey) {
|
|
|
2274
2321
|
}
|
|
2275
2322
|
walkAndApply(startNode, [], metadata);
|
|
2276
2323
|
}
|
|
2277
|
-
function walkAndApply(node,
|
|
2324
|
+
function walkAndApply(node, path20, metadata) {
|
|
2278
2325
|
if (isScalar(node)) {
|
|
2279
|
-
const pathKey =
|
|
2326
|
+
const pathKey = path20.join(".");
|
|
2280
2327
|
const quoteType = metadata.values.get(pathKey);
|
|
2281
2328
|
if (quoteType) {
|
|
2282
2329
|
node.type = quoteType;
|
|
@@ -2287,13 +2334,13 @@ function walkAndApply(node, path19, metadata) {
|
|
|
2287
2334
|
if (pair && pair.key) {
|
|
2288
2335
|
const key = getKeyValue(pair.key);
|
|
2289
2336
|
if (key !== null && key !== void 0) {
|
|
2290
|
-
const keyPath = [...
|
|
2337
|
+
const keyPath = [...path20, String(key)].join(".");
|
|
2291
2338
|
const keyQuoteType = metadata.keys.get(keyPath);
|
|
2292
2339
|
if (keyQuoteType) {
|
|
2293
2340
|
pair.key.type = keyQuoteType;
|
|
2294
2341
|
}
|
|
2295
2342
|
if (pair.value) {
|
|
2296
|
-
walkAndApply(pair.value, [...
|
|
2343
|
+
walkAndApply(pair.value, [...path20, String(key)], metadata);
|
|
2297
2344
|
}
|
|
2298
2345
|
}
|
|
2299
2346
|
}
|
|
@@ -2303,7 +2350,7 @@ function walkAndApply(node, path19, metadata) {
|
|
|
2303
2350
|
if (node.items && Array.isArray(node.items)) {
|
|
2304
2351
|
for (let i = 0; i < node.items.length; i++) {
|
|
2305
2352
|
if (node.items[i]) {
|
|
2306
|
-
walkAndApply(node.items[i], [...
|
|
2353
|
+
walkAndApply(node.items[i], [...path20, String(i)], metadata);
|
|
2307
2354
|
}
|
|
2308
2355
|
}
|
|
2309
2356
|
}
|
|
@@ -3838,35 +3885,35 @@ function createHtmlLoader() {
|
|
|
3838
3885
|
function getInnerHTML2(element) {
|
|
3839
3886
|
return element.children.map((child) => DomSerializer.default(child, { encodeEntities: false })).join("");
|
|
3840
3887
|
}
|
|
3841
|
-
function extractAttributes(element,
|
|
3888
|
+
function extractAttributes(element, path20) {
|
|
3842
3889
|
const tagName = element.name.toLowerCase();
|
|
3843
3890
|
const attrs = LOCALIZABLE_ATTRIBUTES2[tagName];
|
|
3844
3891
|
if (!attrs) return;
|
|
3845
3892
|
for (const attr of attrs) {
|
|
3846
3893
|
const value = _optionalChain([element, 'access', _160 => _160.attribs, 'optionalAccess', _161 => _161[attr]]);
|
|
3847
3894
|
if (value && value.trim()) {
|
|
3848
|
-
result[`${
|
|
3895
|
+
result[`${path20}#${attr}`] = value.trim();
|
|
3849
3896
|
}
|
|
3850
3897
|
}
|
|
3851
3898
|
}
|
|
3852
3899
|
function extractFromElement(element, pathParts) {
|
|
3853
|
-
const
|
|
3900
|
+
const path20 = pathParts.join("/");
|
|
3854
3901
|
if (isInsideUnlocalizableTag(element)) {
|
|
3855
3902
|
return;
|
|
3856
3903
|
}
|
|
3857
|
-
extractAttributes(element,
|
|
3904
|
+
extractAttributes(element, path20);
|
|
3858
3905
|
const tagName = element.name.toLowerCase();
|
|
3859
3906
|
if (BLOCK_ELEMENTS.has(tagName) && isLeafBlock(element)) {
|
|
3860
3907
|
const content = getInnerHTML2(element).trim();
|
|
3861
3908
|
if (content) {
|
|
3862
|
-
result[
|
|
3909
|
+
result[path20] = content;
|
|
3863
3910
|
}
|
|
3864
3911
|
return;
|
|
3865
3912
|
}
|
|
3866
3913
|
if (PHRASING_ELEMENTS.has(tagName) && hasTranslatableContent(element)) {
|
|
3867
3914
|
const content = getInnerHTML2(element).trim();
|
|
3868
3915
|
if (content) {
|
|
3869
|
-
result[
|
|
3916
|
+
result[path20] = content;
|
|
3870
3917
|
}
|
|
3871
3918
|
return;
|
|
3872
3919
|
}
|
|
@@ -3958,8 +4005,8 @@ function createHtmlLoader() {
|
|
|
3958
4005
|
}
|
|
3959
4006
|
return current;
|
|
3960
4007
|
}
|
|
3961
|
-
function resolvePathToElement(
|
|
3962
|
-
const parts =
|
|
4008
|
+
function resolvePathToElement(path20) {
|
|
4009
|
+
const parts = path20.split("/");
|
|
3963
4010
|
const [rootTag, ...indices] = parts;
|
|
3964
4011
|
let current = null;
|
|
3965
4012
|
if (html) {
|
|
@@ -3990,8 +4037,8 @@ function createHtmlLoader() {
|
|
|
3990
4037
|
return traverseByIndices(current, indices);
|
|
3991
4038
|
}
|
|
3992
4039
|
}
|
|
3993
|
-
for (const [
|
|
3994
|
-
const [nodePath, attribute] =
|
|
4040
|
+
for (const [path20, value] of Object.entries(data)) {
|
|
4041
|
+
const [nodePath, attribute] = path20.split("#");
|
|
3995
4042
|
const element = resolvePathToElement(nodePath);
|
|
3996
4043
|
if (!element) {
|
|
3997
4044
|
console.warn(`Path not found in original HTML: ${nodePath}`);
|
|
@@ -4116,7 +4163,7 @@ function getSemanticNodeType(node) {
|
|
|
4116
4163
|
if (node.type === "tag") return node.tag || "tag";
|
|
4117
4164
|
return node.type;
|
|
4118
4165
|
}
|
|
4119
|
-
function traverseAndExtract(node,
|
|
4166
|
+
function traverseAndExtract(node, path20, result, counters, parentType) {
|
|
4120
4167
|
if (!node || typeof node !== "object") {
|
|
4121
4168
|
return;
|
|
4122
4169
|
}
|
|
@@ -4138,12 +4185,12 @@ function traverseAndExtract(node, path19, result, counters, parentType) {
|
|
|
4138
4185
|
}
|
|
4139
4186
|
if (Array.isArray(node.children)) {
|
|
4140
4187
|
node.children.forEach((child, index) => {
|
|
4141
|
-
const childPath =
|
|
4188
|
+
const childPath = path20 ? `${path20}/children/${index}` : `children/${index}`;
|
|
4142
4189
|
traverseAndExtract(child, childPath, result, counters, semanticType);
|
|
4143
4190
|
});
|
|
4144
4191
|
}
|
|
4145
4192
|
}
|
|
4146
|
-
function buildPathMap(node,
|
|
4193
|
+
function buildPathMap(node, path20, counters, pathMap, parentType) {
|
|
4147
4194
|
if (!node || typeof node !== "object") {
|
|
4148
4195
|
return;
|
|
4149
4196
|
}
|
|
@@ -4159,26 +4206,26 @@ function buildPathMap(node, path19, counters, pathMap, parentType) {
|
|
|
4159
4206
|
const index = counters[semanticType] || 0;
|
|
4160
4207
|
counters[semanticType] = index + 1;
|
|
4161
4208
|
const semanticKey = `${semanticType}-${index}`;
|
|
4162
|
-
const contentPath =
|
|
4209
|
+
const contentPath = path20 ? `${path20}/attributes/content` : "attributes/content";
|
|
4163
4210
|
pathMap[semanticKey] = contentPath;
|
|
4164
4211
|
}
|
|
4165
4212
|
}
|
|
4166
4213
|
}
|
|
4167
4214
|
if (Array.isArray(node.children)) {
|
|
4168
4215
|
node.children.forEach((child, index) => {
|
|
4169
|
-
const childPath =
|
|
4216
|
+
const childPath = path20 ? `${path20}/children/${index}` : `children/${index}`;
|
|
4170
4217
|
buildPathMap(child, childPath, counters, pathMap, semanticType);
|
|
4171
4218
|
});
|
|
4172
4219
|
}
|
|
4173
4220
|
}
|
|
4174
|
-
function applyTranslations(node,
|
|
4221
|
+
function applyTranslations(node, path20, data, pathMap) {
|
|
4175
4222
|
if (!node || typeof node !== "object") {
|
|
4176
4223
|
return;
|
|
4177
4224
|
}
|
|
4178
4225
|
if (node.type === "text" && _optionalChain([node, 'access', _172 => _172.attributes, 'optionalAccess', _173 => _173.content])) {
|
|
4179
4226
|
const content = node.attributes.content;
|
|
4180
4227
|
if (typeof content === "string") {
|
|
4181
|
-
const contentPath =
|
|
4228
|
+
const contentPath = path20 ? `${path20}/attributes/content` : "attributes/content";
|
|
4182
4229
|
const semanticKey = Object.keys(pathMap).find(
|
|
4183
4230
|
(key) => pathMap[key] === contentPath
|
|
4184
4231
|
);
|
|
@@ -4189,7 +4236,7 @@ function applyTranslations(node, path19, data, pathMap) {
|
|
|
4189
4236
|
}
|
|
4190
4237
|
if (Array.isArray(node.children)) {
|
|
4191
4238
|
node.children.forEach((child, index) => {
|
|
4192
|
-
const childPath =
|
|
4239
|
+
const childPath = path20 ? `${path20}/children/${index}` : `children/${index}`;
|
|
4193
4240
|
applyTranslations(child, childPath, data, pathMap);
|
|
4194
4241
|
});
|
|
4195
4242
|
}
|
|
@@ -4250,21 +4297,21 @@ function createMjmlLoader() {
|
|
|
4250
4297
|
const rootKey = Object.keys(parsed).find((key) => !key.startsWith("_") && !key.startsWith("$"));
|
|
4251
4298
|
const rootNode = rootKey ? parsed[rootKey] : parsed;
|
|
4252
4299
|
const rootPath = rootNode["#name"] || rootKey || "";
|
|
4253
|
-
traverse(rootNode, (node,
|
|
4300
|
+
traverse(rootNode, (node, path20, componentName) => {
|
|
4254
4301
|
if (typeof node !== "object") return;
|
|
4255
4302
|
const localizableAttrs = LOCALIZABLE_ATTRIBUTES[componentName];
|
|
4256
4303
|
if (localizableAttrs && node.$) {
|
|
4257
4304
|
localizableAttrs.forEach((attr) => {
|
|
4258
4305
|
const attrValue = node.$[attr];
|
|
4259
4306
|
if (attrValue) {
|
|
4260
|
-
result[`${
|
|
4307
|
+
result[`${path20}#${attr}`] = attrValue;
|
|
4261
4308
|
}
|
|
4262
4309
|
});
|
|
4263
4310
|
}
|
|
4264
4311
|
if (LOCALIZABLE_COMPONENTS.includes(componentName)) {
|
|
4265
4312
|
const innerHTML = getInnerHTML(node);
|
|
4266
4313
|
if (innerHTML) {
|
|
4267
|
-
result[
|
|
4314
|
+
result[path20] = innerHTML;
|
|
4268
4315
|
return "SKIP_CHILDREN";
|
|
4269
4316
|
}
|
|
4270
4317
|
}
|
|
@@ -4299,19 +4346,19 @@ function createMjmlLoader() {
|
|
|
4299
4346
|
const rootKey = Object.keys(parsed).find((key) => !key.startsWith("_") && !key.startsWith("$"));
|
|
4300
4347
|
const rootNode = rootKey ? parsed[rootKey] : parsed;
|
|
4301
4348
|
const rootPath = rootNode["#name"] || rootKey || "";
|
|
4302
|
-
traverse(rootNode, (node,
|
|
4349
|
+
traverse(rootNode, (node, path20, componentName) => {
|
|
4303
4350
|
if (typeof node !== "object") return;
|
|
4304
4351
|
const localizableAttrs = LOCALIZABLE_ATTRIBUTES[componentName];
|
|
4305
4352
|
if (localizableAttrs && node.$) {
|
|
4306
4353
|
localizableAttrs.forEach((attr) => {
|
|
4307
|
-
const attrKey = `${
|
|
4354
|
+
const attrKey = `${path20}#${attr}`;
|
|
4308
4355
|
if (data[attrKey] !== void 0) {
|
|
4309
4356
|
node.$[attr] = data[attrKey];
|
|
4310
4357
|
}
|
|
4311
4358
|
});
|
|
4312
4359
|
}
|
|
4313
|
-
if (LOCALIZABLE_COMPONENTS.includes(componentName) && data[
|
|
4314
|
-
setInnerHTML(node, data[
|
|
4360
|
+
if (LOCALIZABLE_COMPONENTS.includes(componentName) && data[path20]) {
|
|
4361
|
+
setInnerHTML(node, data[path20]);
|
|
4315
4362
|
return "SKIP_CHILDREN";
|
|
4316
4363
|
}
|
|
4317
4364
|
return void 0;
|
|
@@ -4324,7 +4371,7 @@ function createMjmlLoader() {
|
|
|
4324
4371
|
}
|
|
4325
4372
|
});
|
|
4326
4373
|
}
|
|
4327
|
-
function traverse(node, visitor,
|
|
4374
|
+
function traverse(node, visitor, path20 = "") {
|
|
4328
4375
|
if (!node || typeof node !== "object") {
|
|
4329
4376
|
return;
|
|
4330
4377
|
}
|
|
@@ -4340,7 +4387,7 @@ function traverse(node, visitor, path19 = "") {
|
|
|
4340
4387
|
}
|
|
4341
4388
|
const currentIndex = elementCounts.get(elementName) || 0;
|
|
4342
4389
|
elementCounts.set(elementName, currentIndex + 1);
|
|
4343
|
-
const currentPath =
|
|
4390
|
+
const currentPath = path20 ? `${path20}/${elementName}/${currentIndex}` : `${elementName}/${currentIndex}`;
|
|
4344
4391
|
const result = visitor(child, currentPath, elementName);
|
|
4345
4392
|
if (result !== "SKIP_CHILDREN") {
|
|
4346
4393
|
traverse(child, visitor, currentPath);
|
|
@@ -5362,7 +5409,7 @@ function createBaseFormatterLoader(options, formatFn) {
|
|
|
5362
5409
|
const stage = options.stage || "both";
|
|
5363
5410
|
const formatData = async (locale, data) => {
|
|
5364
5411
|
const draftPath = options.bucketPathPattern.replaceAll("[locale]", locale);
|
|
5365
|
-
const finalPath =
|
|
5412
|
+
const finalPath = path15.default.resolve(draftPath);
|
|
5366
5413
|
return await formatFn(data, finalPath);
|
|
5367
5414
|
};
|
|
5368
5415
|
return createLoader({
|
|
@@ -5440,18 +5487,18 @@ function createBiomeLoader(options) {
|
|
|
5440
5487
|
});
|
|
5441
5488
|
}
|
|
5442
5489
|
async function findBiomeConfig(startPath) {
|
|
5443
|
-
let currentDir =
|
|
5444
|
-
const root =
|
|
5490
|
+
let currentDir = path15.default.dirname(startPath);
|
|
5491
|
+
const root = path15.default.parse(currentDir).root;
|
|
5445
5492
|
while (currentDir !== root) {
|
|
5446
5493
|
for (const configName of ["biome.json", "biome.jsonc"]) {
|
|
5447
|
-
const configPath =
|
|
5494
|
+
const configPath = path15.default.join(currentDir, configName);
|
|
5448
5495
|
try {
|
|
5449
5496
|
await _promises4.default.access(configPath);
|
|
5450
5497
|
return configPath;
|
|
5451
5498
|
} catch (e2) {
|
|
5452
5499
|
}
|
|
5453
5500
|
}
|
|
5454
|
-
const parentDir =
|
|
5501
|
+
const parentDir = path15.default.dirname(currentDir);
|
|
5455
5502
|
if (parentDir === currentDir) break;
|
|
5456
5503
|
currentDir = parentDir;
|
|
5457
5504
|
}
|
|
@@ -5469,7 +5516,7 @@ async function formatDataWithBiome(data, filePath, options) {
|
|
|
5469
5516
|
if (!configPath && !options.alwaysFormat) {
|
|
5470
5517
|
console.log();
|
|
5471
5518
|
console.log(
|
|
5472
|
-
`\u26A0\uFE0F Biome config not found for ${
|
|
5519
|
+
`\u26A0\uFE0F Biome config not found for ${path15.default.basename(filePath)} - skipping formatting`
|
|
5473
5520
|
);
|
|
5474
5521
|
return data;
|
|
5475
5522
|
}
|
|
@@ -5493,7 +5540,7 @@ async function formatDataWithBiome(data, filePath, options) {
|
|
|
5493
5540
|
const errorMessage = error instanceof Error ? error.message || _optionalChain([error, 'access', _215 => _215.stackTrace, 'optionalAccess', _216 => _216.toString, 'call', _217 => _217(), 'access', _218 => _218.split, 'call', _219 => _219("\n"), 'access', _220 => _220[0]]) : "";
|
|
5494
5541
|
if (_optionalChain([errorMessage, 'optionalAccess', _221 => _221.includes, 'call', _222 => _222("does not exist in the workspace")])) {
|
|
5495
5542
|
} else {
|
|
5496
|
-
console.log(`\u26A0\uFE0F Biome skipped ${
|
|
5543
|
+
console.log(`\u26A0\uFE0F Biome skipped ${path15.default.basename(filePath)}`);
|
|
5497
5544
|
if (errorMessage) {
|
|
5498
5545
|
console.log(` ${errorMessage}`);
|
|
5499
5546
|
}
|
|
@@ -6701,24 +6748,24 @@ function createRawDatoValue(parsedDatoValue, originalRawDatoValue, isClean = fal
|
|
|
6701
6748
|
}
|
|
6702
6749
|
function serializeStructuredText(rawStructuredText) {
|
|
6703
6750
|
return serializeStructuredTextNode(rawStructuredText);
|
|
6704
|
-
function serializeStructuredTextNode(node,
|
|
6751
|
+
function serializeStructuredTextNode(node, path20 = [], acc = {}) {
|
|
6705
6752
|
if ("document" in node) {
|
|
6706
6753
|
return serializeStructuredTextNode(
|
|
6707
6754
|
node.document,
|
|
6708
|
-
[...
|
|
6755
|
+
[...path20, "document"],
|
|
6709
6756
|
acc
|
|
6710
6757
|
);
|
|
6711
6758
|
}
|
|
6712
6759
|
if (!_lodash2.default.isNil(node.value)) {
|
|
6713
|
-
acc[[...
|
|
6760
|
+
acc[[...path20, "value"].join(".")] = node.value;
|
|
6714
6761
|
} else if (_lodash2.default.get(node, "type") === "block") {
|
|
6715
|
-
acc[[...
|
|
6762
|
+
acc[[...path20, "item"].join(".")] = serializeBlock(node.item);
|
|
6716
6763
|
}
|
|
6717
6764
|
if (node.children) {
|
|
6718
6765
|
for (let i = 0; i < node.children.length; i++) {
|
|
6719
6766
|
serializeStructuredTextNode(
|
|
6720
6767
|
node.children[i],
|
|
6721
|
-
[...
|
|
6768
|
+
[...path20, i.toString()],
|
|
6722
6769
|
acc
|
|
6723
6770
|
);
|
|
6724
6771
|
}
|
|
@@ -6785,8 +6832,8 @@ function deserializeBlockList(parsedBlockList, originalRawBlockList, isClean = f
|
|
|
6785
6832
|
}
|
|
6786
6833
|
function deserializeStructuredText(parsedStructuredText, originalRawStructuredText) {
|
|
6787
6834
|
const result = _lodash2.default.cloneDeep(originalRawStructuredText);
|
|
6788
|
-
for (const [
|
|
6789
|
-
const realPath = _lodash2.default.chain(
|
|
6835
|
+
for (const [path20, value] of _lodash2.default.entries(parsedStructuredText)) {
|
|
6836
|
+
const realPath = _lodash2.default.chain(path20.split(".")).flatMap((s) => !_lodash2.default.isNaN(_lodash2.default.toNumber(s)) ? ["children", s] : s).value();
|
|
6790
6837
|
const deserializedValue = createRawDatoValue(
|
|
6791
6838
|
value,
|
|
6792
6839
|
_lodash2.default.get(originalRawStructuredText, realPath),
|
|
@@ -6823,12 +6870,12 @@ function _isVideo(rawDatoValue) {
|
|
|
6823
6870
|
// src/cli/loaders/dato/index.ts
|
|
6824
6871
|
function createDatoLoader(configFilePath) {
|
|
6825
6872
|
try {
|
|
6826
|
-
const configContent =
|
|
6873
|
+
const configContent = fs13.default.readFileSync(configFilePath, "utf-8");
|
|
6827
6874
|
const datoConfig = datoConfigSchema.parse(_json52.default.parse(configContent));
|
|
6828
6875
|
return composeLoaders(
|
|
6829
6876
|
createDatoApiLoader(
|
|
6830
6877
|
datoConfig,
|
|
6831
|
-
(updatedConfig) =>
|
|
6878
|
+
(updatedConfig) => fs13.default.writeFileSync(
|
|
6832
6879
|
configFilePath,
|
|
6833
6880
|
_json52.default.stringify(updatedConfig, null, 2)
|
|
6834
6881
|
)
|
|
@@ -7217,15 +7264,15 @@ function parseTypeScript(input2) {
|
|
|
7217
7264
|
function extractStringsFromDefaultExport(ast) {
|
|
7218
7265
|
let extracted = {};
|
|
7219
7266
|
traverse2(ast, {
|
|
7220
|
-
ExportDefaultDeclaration(
|
|
7221
|
-
const { declaration } =
|
|
7267
|
+
ExportDefaultDeclaration(path20) {
|
|
7268
|
+
const { declaration } = path20.node;
|
|
7222
7269
|
const decl = unwrapTSAsExpression(declaration);
|
|
7223
7270
|
if (t.isObjectExpression(decl)) {
|
|
7224
7271
|
extracted = objectExpressionToObject(decl);
|
|
7225
7272
|
} else if (t.isArrayExpression(decl)) {
|
|
7226
7273
|
extracted = arrayExpressionToArray(decl);
|
|
7227
7274
|
} else if (t.isIdentifier(decl)) {
|
|
7228
|
-
const binding =
|
|
7275
|
+
const binding = path20.scope.bindings[decl.name];
|
|
7229
7276
|
if (binding && t.isVariableDeclarator(binding.path.node) && binding.path.node.init) {
|
|
7230
7277
|
const initRaw = binding.path.node.init;
|
|
7231
7278
|
const init = initRaw ? unwrapTSAsExpression(initRaw) : initRaw;
|
|
@@ -7290,8 +7337,8 @@ function arrayExpressionToArray(arrayExpression) {
|
|
|
7290
7337
|
function updateStringsInDefaultExport(ast, data) {
|
|
7291
7338
|
let modified = false;
|
|
7292
7339
|
traverse2(ast, {
|
|
7293
|
-
ExportDefaultDeclaration(
|
|
7294
|
-
const { declaration } =
|
|
7340
|
+
ExportDefaultDeclaration(path20) {
|
|
7341
|
+
const { declaration } = path20.node;
|
|
7295
7342
|
const decl = unwrapTSAsExpression(declaration);
|
|
7296
7343
|
if (t.isObjectExpression(decl)) {
|
|
7297
7344
|
modified = updateStringsInObjectExpression(decl, data) || modified;
|
|
@@ -7300,7 +7347,7 @@ function updateStringsInDefaultExport(ast, data) {
|
|
|
7300
7347
|
modified = updateStringsInArrayExpression(decl, data) || modified;
|
|
7301
7348
|
}
|
|
7302
7349
|
} else if (t.isIdentifier(decl)) {
|
|
7303
|
-
modified = updateStringsInExportedIdentifier(
|
|
7350
|
+
modified = updateStringsInExportedIdentifier(path20, data) || modified;
|
|
7304
7351
|
}
|
|
7305
7352
|
}
|
|
7306
7353
|
});
|
|
@@ -7371,9 +7418,9 @@ function updateStringsInArrayExpression(arrayExpression, incoming) {
|
|
|
7371
7418
|
});
|
|
7372
7419
|
return modified;
|
|
7373
7420
|
}
|
|
7374
|
-
function updateStringsInExportedIdentifier(
|
|
7375
|
-
const exportName =
|
|
7376
|
-
const binding =
|
|
7421
|
+
function updateStringsInExportedIdentifier(path20, data) {
|
|
7422
|
+
const exportName = path20.node.declaration.name;
|
|
7423
|
+
const binding = path20.scope.bindings[exportName];
|
|
7377
7424
|
if (!binding || !binding.path.node) return false;
|
|
7378
7425
|
if (t.isVariableDeclarator(binding.path.node) && binding.path.node.init) {
|
|
7379
7426
|
const initRaw = binding.path.node.init;
|
|
@@ -8282,11 +8329,11 @@ var qmarksTestNoExtDot = ([$0]) => {
|
|
|
8282
8329
|
return (f) => f.length === len && f !== "." && f !== "..";
|
|
8283
8330
|
};
|
|
8284
8331
|
var defaultPlatform = typeof process === "object" && process ? typeof process.env === "object" && process.env && process.env.__MINIMATCH_TESTING_PLATFORM__ || process.platform : "posix";
|
|
8285
|
-
var
|
|
8332
|
+
var path14 = {
|
|
8286
8333
|
win32: { sep: "\\" },
|
|
8287
8334
|
posix: { sep: "/" }
|
|
8288
8335
|
};
|
|
8289
|
-
var sep = defaultPlatform === "win32" ?
|
|
8336
|
+
var sep = defaultPlatform === "win32" ? path14.win32.sep : path14.posix.sep;
|
|
8290
8337
|
minimatch.sep = sep;
|
|
8291
8338
|
var GLOBSTAR = /* @__PURE__ */ Symbol("globstar **");
|
|
8292
8339
|
minimatch.GLOBSTAR = GLOBSTAR;
|
|
@@ -8989,11 +9036,11 @@ function _getAllKeys(obj, prefix = "") {
|
|
|
8989
9036
|
let keys = [];
|
|
8990
9037
|
for (const key in obj) {
|
|
8991
9038
|
if (!Object.prototype.hasOwnProperty.call(obj, key)) continue;
|
|
8992
|
-
const
|
|
9039
|
+
const path20 = prefix ? `${prefix}.${key}` : key;
|
|
8993
9040
|
if (typeof obj[key] === "object" && obj[key] !== null && !Array.isArray(obj[key])) {
|
|
8994
|
-
keys = keys.concat(_getAllKeys(obj[key],
|
|
9041
|
+
keys = keys.concat(_getAllKeys(obj[key], path20));
|
|
8995
9042
|
} else {
|
|
8996
|
-
keys.push(
|
|
9043
|
+
keys.push(path20);
|
|
8997
9044
|
}
|
|
8998
9045
|
}
|
|
8999
9046
|
return keys;
|
|
@@ -9606,7 +9653,7 @@ function createTwigLoader() {
|
|
|
9606
9653
|
const html2 = element.children.map((child) => DomSerializer2.default(child, { encodeEntities: false })).join("");
|
|
9607
9654
|
return postprocessTwig(html2, twigBlocks);
|
|
9608
9655
|
}
|
|
9609
|
-
function extractAttributes(element,
|
|
9656
|
+
function extractAttributes(element, path20) {
|
|
9610
9657
|
const tagName = element.name.toLowerCase();
|
|
9611
9658
|
const attrs = LOCALIZABLE_ATTRIBUTES2[tagName];
|
|
9612
9659
|
if (!attrs) return;
|
|
@@ -9614,28 +9661,28 @@ function createTwigLoader() {
|
|
|
9614
9661
|
const value = _optionalChain([element, 'access', _342 => _342.attribs, 'optionalAccess', _343 => _343[attr]]);
|
|
9615
9662
|
if (value && value.trim()) {
|
|
9616
9663
|
const restoredValue = postprocessTwig(value.trim(), twigBlocks);
|
|
9617
|
-
result[`${
|
|
9664
|
+
result[`${path20}#${attr}`] = restoredValue;
|
|
9618
9665
|
}
|
|
9619
9666
|
}
|
|
9620
9667
|
}
|
|
9621
9668
|
function extractFromElement(element, pathParts) {
|
|
9622
|
-
const
|
|
9669
|
+
const path20 = pathParts.join("/");
|
|
9623
9670
|
if (isInsideUnlocalizableTag(element)) {
|
|
9624
9671
|
return;
|
|
9625
9672
|
}
|
|
9626
|
-
extractAttributes(element,
|
|
9673
|
+
extractAttributes(element, path20);
|
|
9627
9674
|
const tagName = element.name.toLowerCase();
|
|
9628
9675
|
if (BLOCK_ELEMENTS.has(tagName) && isLeafBlock(element)) {
|
|
9629
9676
|
const content = getInnerHTML2(element).trim();
|
|
9630
9677
|
if (content) {
|
|
9631
|
-
result[
|
|
9678
|
+
result[path20] = content;
|
|
9632
9679
|
}
|
|
9633
9680
|
return;
|
|
9634
9681
|
}
|
|
9635
9682
|
if (PHRASING_ELEMENTS.has(tagName) && hasTranslatableContent(element)) {
|
|
9636
9683
|
const content = getInnerHTML2(element).trim();
|
|
9637
9684
|
if (content) {
|
|
9638
|
-
result[
|
|
9685
|
+
result[path20] = content;
|
|
9639
9686
|
}
|
|
9640
9687
|
return;
|
|
9641
9688
|
}
|
|
@@ -9726,8 +9773,8 @@ function createTwigLoader() {
|
|
|
9726
9773
|
}
|
|
9727
9774
|
return current;
|
|
9728
9775
|
}
|
|
9729
|
-
function resolvePathToElement(
|
|
9730
|
-
const parts =
|
|
9776
|
+
function resolvePathToElement(path20) {
|
|
9777
|
+
const parts = path20.split("/");
|
|
9731
9778
|
const [rootTag, ...indices] = parts;
|
|
9732
9779
|
let current = null;
|
|
9733
9780
|
if (html) {
|
|
@@ -9758,8 +9805,8 @@ function createTwigLoader() {
|
|
|
9758
9805
|
return traverseByIndices(current, indices);
|
|
9759
9806
|
}
|
|
9760
9807
|
}
|
|
9761
|
-
for (const [
|
|
9762
|
-
const [nodePath, attribute] =
|
|
9808
|
+
for (const [path20, value] of Object.entries(data)) {
|
|
9809
|
+
const [nodePath, attribute] = path20.split("#");
|
|
9763
9810
|
const element = resolvePathToElement(nodePath);
|
|
9764
9811
|
if (!element) {
|
|
9765
9812
|
console.warn(`Path not found in original template: ${nodePath}`);
|
|
@@ -9875,19 +9922,19 @@ function createJsonDictionaryLoader() {
|
|
|
9875
9922
|
);
|
|
9876
9923
|
return input2;
|
|
9877
9924
|
}
|
|
9878
|
-
function walk(obj, dataNode,
|
|
9925
|
+
function walk(obj, dataNode, path20 = []) {
|
|
9879
9926
|
if (Array.isArray(obj) && Array.isArray(dataNode)) {
|
|
9880
9927
|
obj.forEach(
|
|
9881
|
-
(item, idx) => walk(item, dataNode[idx], [...
|
|
9928
|
+
(item, idx) => walk(item, dataNode[idx], [...path20, String(idx)])
|
|
9882
9929
|
);
|
|
9883
9930
|
} else if (obj && typeof obj === "object" && dataNode && typeof dataNode === "object" && !Array.isArray(dataNode)) {
|
|
9884
9931
|
for (const key of Object.keys(obj)) {
|
|
9885
9932
|
if (dataNode.hasOwnProperty(key)) {
|
|
9886
|
-
walk(obj[key], dataNode[key], [...
|
|
9933
|
+
walk(obj[key], dataNode[key], [...path20, key]);
|
|
9887
9934
|
}
|
|
9888
9935
|
}
|
|
9889
9936
|
} else if (obj && typeof obj === "object" && !Array.isArray(obj) && typeof dataNode === "string") {
|
|
9890
|
-
setNestedLocale(input2,
|
|
9937
|
+
setNestedLocale(input2, path20, locale, dataNode, originalLocale);
|
|
9891
9938
|
}
|
|
9892
9939
|
}
|
|
9893
9940
|
walk(input2, data);
|
|
@@ -9915,14 +9962,14 @@ function extractTranslatables(obj, locale) {
|
|
|
9915
9962
|
function isTranslatableObject(obj, locale) {
|
|
9916
9963
|
return obj && typeof obj === "object" && !Array.isArray(obj) && Object.prototype.hasOwnProperty.call(obj, locale);
|
|
9917
9964
|
}
|
|
9918
|
-
function setNestedLocale(obj,
|
|
9965
|
+
function setNestedLocale(obj, path20, locale, value, originalLocale) {
|
|
9919
9966
|
let curr = obj;
|
|
9920
|
-
for (let i = 0; i <
|
|
9921
|
-
const key =
|
|
9967
|
+
for (let i = 0; i < path20.length - 1; i++) {
|
|
9968
|
+
const key = path20[i];
|
|
9922
9969
|
if (!(key in curr)) curr[key] = {};
|
|
9923
9970
|
curr = curr[key];
|
|
9924
9971
|
}
|
|
9925
|
-
const last =
|
|
9972
|
+
const last = path20[path20.length - 1];
|
|
9926
9973
|
if (curr[last] && typeof curr[last] === "object") {
|
|
9927
9974
|
curr[last][locale] = value;
|
|
9928
9975
|
if (originalLocale && curr[last][originalLocale]) {
|
|
@@ -9939,10 +9986,67 @@ function setNestedLocale(obj, path19, locale, value, originalLocale) {
|
|
|
9939
9986
|
}
|
|
9940
9987
|
}
|
|
9941
9988
|
|
|
9989
|
+
// src/cli/loaders/csv-per-locale.ts
|
|
9990
|
+
|
|
9991
|
+
|
|
9992
|
+
function dedupeHeaders(headers) {
|
|
9993
|
+
const seen = /* @__PURE__ */ new Map();
|
|
9994
|
+
return headers.map((h) => {
|
|
9995
|
+
const count = _nullishCoalesce(seen.get(h), () => ( 0));
|
|
9996
|
+
seen.set(h, count + 1);
|
|
9997
|
+
return count === 0 ? h : `${h}__${count + 1}`;
|
|
9998
|
+
});
|
|
9999
|
+
}
|
|
10000
|
+
function createCsvPerLocaleLoader() {
|
|
10001
|
+
return createLoader({
|
|
10002
|
+
async pull(_locale, input2) {
|
|
10003
|
+
if (!_optionalChain([input2, 'optionalAccess', _344 => _344.trim, 'call', _345 => _345()])) return {};
|
|
10004
|
+
const parsed = _sync.parse.call(void 0, input2, {
|
|
10005
|
+
skip_empty_lines: true,
|
|
10006
|
+
columns: (headers) => {
|
|
10007
|
+
const dedupedHeaders = dedupeHeaders(headers);
|
|
10008
|
+
return dedupedHeaders;
|
|
10009
|
+
}
|
|
10010
|
+
});
|
|
10011
|
+
if (parsed.length === 0) return {};
|
|
10012
|
+
return parsed;
|
|
10013
|
+
},
|
|
10014
|
+
async push(_locale, data, originalInput) {
|
|
10015
|
+
const rawRows = _sync.parse.call(void 0, originalInput || "", {
|
|
10016
|
+
skip_empty_lines: true
|
|
10017
|
+
});
|
|
10018
|
+
const originalHeaders = rawRows[0];
|
|
10019
|
+
const dedupedHeaders = dedupeHeaders(originalHeaders);
|
|
10020
|
+
const columns = originalHeaders.map((header, i) => ({
|
|
10021
|
+
key: dedupedHeaders[i],
|
|
10022
|
+
header
|
|
10023
|
+
}));
|
|
10024
|
+
const rows = Object.values(data).filter(
|
|
10025
|
+
(row) => row && Object.values(row).some(
|
|
10026
|
+
(v) => v !== void 0 && v !== null
|
|
10027
|
+
)
|
|
10028
|
+
);
|
|
10029
|
+
const output = _sync3.stringify.call(void 0, rows, {
|
|
10030
|
+
header: true,
|
|
10031
|
+
columns
|
|
10032
|
+
}).trimEnd();
|
|
10033
|
+
return output;
|
|
10034
|
+
}
|
|
10035
|
+
});
|
|
10036
|
+
}
|
|
10037
|
+
|
|
9942
10038
|
// src/cli/loaders/index.ts
|
|
9943
10039
|
function encodeKeys(keys) {
|
|
9944
10040
|
return keys.map((key) => encodeURIComponent(key));
|
|
9945
10041
|
}
|
|
10042
|
+
function normalizeCsvPatterns(patterns) {
|
|
10043
|
+
return patterns.map((pattern) => {
|
|
10044
|
+
if (pattern.includes("/") || pattern.startsWith("*/")) {
|
|
10045
|
+
return pattern;
|
|
10046
|
+
}
|
|
10047
|
+
return `*/${pattern}`;
|
|
10048
|
+
});
|
|
10049
|
+
}
|
|
9946
10050
|
function createBucketLoader(bucketType, bucketPathPattern, options, lockedKeys, lockedPatterns, ignoredKeys) {
|
|
9947
10051
|
switch (bucketType) {
|
|
9948
10052
|
default:
|
|
@@ -9983,6 +10087,18 @@ function createBucketLoader(bucketType, bucketPathPattern, options, lockedKeys,
|
|
|
9983
10087
|
createSyncLoader(),
|
|
9984
10088
|
createUnlocalizableLoader(options.returnUnlocalizedKeys)
|
|
9985
10089
|
);
|
|
10090
|
+
case "csv-per-locale":
|
|
10091
|
+
return composeLoaders(
|
|
10092
|
+
createTextFileLoader(bucketPathPattern),
|
|
10093
|
+
createLockedPatternsLoader(lockedPatterns),
|
|
10094
|
+
createCsvPerLocaleLoader(),
|
|
10095
|
+
createEnsureKeyOrderLoader(),
|
|
10096
|
+
createFlatLoader(),
|
|
10097
|
+
createLockedKeysLoader(normalizeCsvPatterns(lockedKeys || [])),
|
|
10098
|
+
createIgnoredKeysLoader(normalizeCsvPatterns(ignoredKeys || [])),
|
|
10099
|
+
createSyncLoader(),
|
|
10100
|
+
createUnlocalizableLoader(options.returnUnlocalizedKeys)
|
|
10101
|
+
);
|
|
9986
10102
|
case "html":
|
|
9987
10103
|
return composeLoaders(
|
|
9988
10104
|
createTextFileLoader(bucketPathPattern),
|
|
@@ -10714,7 +10830,7 @@ function createBasicTranslator(model, systemPrompt, settings = {}) {
|
|
|
10714
10830
|
]
|
|
10715
10831
|
});
|
|
10716
10832
|
const result = JSON.parse(response.text);
|
|
10717
|
-
return _optionalChain([result, 'optionalAccess',
|
|
10833
|
+
return _optionalChain([result, 'optionalAccess', _346 => _346.data]) || {};
|
|
10718
10834
|
}
|
|
10719
10835
|
}
|
|
10720
10836
|
function extractPayloadChunks(payload) {
|
|
@@ -10797,7 +10913,7 @@ function getPureModelProvider(provider) {
|
|
|
10797
10913
|
|
|
10798
10914
|
${_chalk2.default.hex(colors.blue)("Docs: https://lingo.dev/go/docs")}
|
|
10799
10915
|
`;
|
|
10800
|
-
switch (_optionalChain([provider, 'optionalAccess',
|
|
10916
|
+
switch (_optionalChain([provider, 'optionalAccess', _347 => _347.id])) {
|
|
10801
10917
|
case "openai": {
|
|
10802
10918
|
if (!process.env.OPENAI_API_KEY) {
|
|
10803
10919
|
throw new Error(
|
|
@@ -10855,7 +10971,7 @@ function getPureModelProvider(provider) {
|
|
|
10855
10971
|
})(provider.model);
|
|
10856
10972
|
}
|
|
10857
10973
|
default: {
|
|
10858
|
-
throw new Error(createUnsupportedProviderErrorMessage(_optionalChain([provider, 'optionalAccess',
|
|
10974
|
+
throw new Error(createUnsupportedProviderErrorMessage(_optionalChain([provider, 'optionalAccess', _348 => _348.id])));
|
|
10859
10975
|
}
|
|
10860
10976
|
}
|
|
10861
10977
|
}
|
|
@@ -10947,7 +11063,7 @@ function parseGitUrl(url) {
|
|
|
10947
11063
|
}
|
|
10948
11064
|
const sshMatch = cleanUrl.match(/[@:]([^:/@]+\/[^:/@]+)$/);
|
|
10949
11065
|
const httpsMatch = cleanUrl.match(/\/([^/]+\/[^/]+)$/);
|
|
10950
|
-
const repoPath = _optionalChain([sshMatch, 'optionalAccess',
|
|
11066
|
+
const repoPath = _optionalChain([sshMatch, 'optionalAccess', _349 => _349[1]]) || _optionalChain([httpsMatch, 'optionalAccess', _350 => _350[1]]);
|
|
10951
11067
|
if (!repoPath) return null;
|
|
10952
11068
|
const hashedPath = hashProjectName(repoPath);
|
|
10953
11069
|
if (platform) {
|
|
@@ -11065,21 +11181,21 @@ function trackEvent(email, event, properties) {
|
|
|
11065
11181
|
|
|
11066
11182
|
function tryReadFile(filePath, defaultValue = null) {
|
|
11067
11183
|
try {
|
|
11068
|
-
const content =
|
|
11184
|
+
const content = fs13.readFileSync(filePath, "utf-8");
|
|
11069
11185
|
return content;
|
|
11070
11186
|
} catch (error) {
|
|
11071
11187
|
return defaultValue;
|
|
11072
11188
|
}
|
|
11073
11189
|
}
|
|
11074
11190
|
function writeFile(filePath, content) {
|
|
11075
|
-
const dir =
|
|
11076
|
-
if (!
|
|
11077
|
-
|
|
11191
|
+
const dir = path15.dirname(filePath);
|
|
11192
|
+
if (!fs13.existsSync(dir)) {
|
|
11193
|
+
fs13.mkdirSync(dir, { recursive: true });
|
|
11078
11194
|
}
|
|
11079
|
-
|
|
11195
|
+
fs13.writeFileSync(filePath, content);
|
|
11080
11196
|
}
|
|
11081
11197
|
function checkIfFileExists(filePath) {
|
|
11082
|
-
return
|
|
11198
|
+
return fs13.existsSync(filePath);
|
|
11083
11199
|
}
|
|
11084
11200
|
|
|
11085
11201
|
// src/cli/utils/delta.ts
|
|
@@ -11100,7 +11216,7 @@ var LockSchema = _zod2.default.object({
|
|
|
11100
11216
|
).default({})
|
|
11101
11217
|
});
|
|
11102
11218
|
function createDeltaProcessor(fileKey) {
|
|
11103
|
-
const lockfilePath =
|
|
11219
|
+
const lockfilePath = path16.join(process.cwd(), "i18n.lock");
|
|
11104
11220
|
return {
|
|
11105
11221
|
async checkIfLockExists() {
|
|
11106
11222
|
return checkIfFileExists(lockfilePath);
|
|
@@ -11257,7 +11373,7 @@ var i18n_default = new (0, _interactivecommander.Command)().command("i18n").desc
|
|
|
11257
11373
|
validateParams(i18nConfig, flags);
|
|
11258
11374
|
ora.succeed("Localization configuration is valid");
|
|
11259
11375
|
ora.start("Connecting to Lingo.dev Localization Engine...");
|
|
11260
|
-
const isByokMode = !!_optionalChain([i18nConfig, 'optionalAccess',
|
|
11376
|
+
const isByokMode = !!_optionalChain([i18nConfig, 'optionalAccess', _351 => _351.provider]);
|
|
11261
11377
|
if (isByokMode) {
|
|
11262
11378
|
email = null;
|
|
11263
11379
|
ora.succeed("Using external provider (BYOK mode)");
|
|
@@ -11271,16 +11387,16 @@ var i18n_default = new (0, _interactivecommander.Command)().command("i18n").desc
|
|
|
11271
11387
|
flags
|
|
11272
11388
|
});
|
|
11273
11389
|
let buckets = getBuckets(i18nConfig);
|
|
11274
|
-
if (_optionalChain([flags, 'access',
|
|
11390
|
+
if (_optionalChain([flags, 'access', _352 => _352.bucket, 'optionalAccess', _353 => _353.length])) {
|
|
11275
11391
|
buckets = buckets.filter(
|
|
11276
11392
|
(bucket) => flags.bucket.includes(bucket.type)
|
|
11277
11393
|
);
|
|
11278
11394
|
}
|
|
11279
11395
|
ora.succeed("Buckets retrieved");
|
|
11280
|
-
if (_optionalChain([flags, 'access',
|
|
11396
|
+
if (_optionalChain([flags, 'access', _354 => _354.file, 'optionalAccess', _355 => _355.length])) {
|
|
11281
11397
|
buckets = buckets.map((bucket) => {
|
|
11282
11398
|
const paths = bucket.paths.filter(
|
|
11283
|
-
(
|
|
11399
|
+
(path20) => flags.file.find((file) => _optionalChain([path20, 'access', _356 => _356.pathPattern, 'optionalAccess', _357 => _357.includes, 'call', _358 => _358(file)]))
|
|
11284
11400
|
);
|
|
11285
11401
|
return { ...bucket, paths };
|
|
11286
11402
|
}).filter((bucket) => bucket.paths.length > 0);
|
|
@@ -11295,13 +11411,13 @@ var i18n_default = new (0, _interactivecommander.Command)().command("i18n").desc
|
|
|
11295
11411
|
ora.info(`\x1B[36mProcessing only filtered buckets:\x1B[0m`);
|
|
11296
11412
|
buckets.map((bucket) => {
|
|
11297
11413
|
ora.info(` ${bucket.type}:`);
|
|
11298
|
-
bucket.paths.forEach((
|
|
11299
|
-
ora.info(` - ${
|
|
11414
|
+
bucket.paths.forEach((path20) => {
|
|
11415
|
+
ora.info(` - ${path20.pathPattern}`);
|
|
11300
11416
|
});
|
|
11301
11417
|
});
|
|
11302
11418
|
}
|
|
11303
11419
|
}
|
|
11304
|
-
const targetLocales = _optionalChain([flags, 'access',
|
|
11420
|
+
const targetLocales = _optionalChain([flags, 'access', _359 => _359.locale, 'optionalAccess', _360 => _360.length]) ? flags.locale : i18nConfig.locale.targets;
|
|
11305
11421
|
ora.start("Setting up localization cache...");
|
|
11306
11422
|
const checkLockfileProcessor = createDeltaProcessor("");
|
|
11307
11423
|
const lockfileExists = await checkLockfileProcessor.checkIfLockExists();
|
|
@@ -11586,7 +11702,7 @@ var i18n_default = new (0, _interactivecommander.Command)().command("i18n").desc
|
|
|
11586
11702
|
}
|
|
11587
11703
|
const deltaProcessor = createDeltaProcessor(bucketPath.pathPattern);
|
|
11588
11704
|
const checksums = await deltaProcessor.createChecksums(sourceData);
|
|
11589
|
-
if (!_optionalChain([flags, 'access',
|
|
11705
|
+
if (!_optionalChain([flags, 'access', _361 => _361.locale, 'optionalAccess', _362 => _362.length])) {
|
|
11590
11706
|
await deltaProcessor.saveChecksums(checksums);
|
|
11591
11707
|
}
|
|
11592
11708
|
}
|
|
@@ -11713,12 +11829,12 @@ function validateParams(i18nConfig, flags) {
|
|
|
11713
11829
|
message: "No buckets found in i18n.json. Please add at least one bucket containing i18n content.",
|
|
11714
11830
|
docUrl: "bucketNotFound"
|
|
11715
11831
|
});
|
|
11716
|
-
} else if (_optionalChain([flags, 'access',
|
|
11832
|
+
} else if (_optionalChain([flags, 'access', _363 => _363.locale, 'optionalAccess', _364 => _364.some, 'call', _365 => _365((locale) => !i18nConfig.locale.targets.includes(locale))])) {
|
|
11717
11833
|
throw new ValidationError({
|
|
11718
11834
|
message: `One or more specified locales do not exist in i18n.json locale.targets. Please add them to the list and try again.`,
|
|
11719
11835
|
docUrl: "localeTargetNotFound"
|
|
11720
11836
|
});
|
|
11721
|
-
} else if (_optionalChain([flags, 'access',
|
|
11837
|
+
} else if (_optionalChain([flags, 'access', _366 => _366.bucket, 'optionalAccess', _367 => _367.some, 'call', _368 => _368(
|
|
11722
11838
|
(bucket) => !i18nConfig.buckets[bucket]
|
|
11723
11839
|
)])) {
|
|
11724
11840
|
throw new ValidationError({
|
|
@@ -11859,7 +11975,7 @@ function createLockfileHelper() {
|
|
|
11859
11975
|
return {
|
|
11860
11976
|
isLockfileExists: () => {
|
|
11861
11977
|
const lockfilePath = _getLockfilePath();
|
|
11862
|
-
return
|
|
11978
|
+
return fs13.default.existsSync(lockfilePath);
|
|
11863
11979
|
},
|
|
11864
11980
|
registerSourceData: (pathPattern, sourceData) => {
|
|
11865
11981
|
const lockfile = _loadLockfile();
|
|
@@ -11896,20 +12012,20 @@ function createLockfileHelper() {
|
|
|
11896
12012
|
};
|
|
11897
12013
|
function _loadLockfile() {
|
|
11898
12014
|
const lockfilePath = _getLockfilePath();
|
|
11899
|
-
if (!
|
|
12015
|
+
if (!fs13.default.existsSync(lockfilePath)) {
|
|
11900
12016
|
return LockfileSchema.parse({});
|
|
11901
12017
|
}
|
|
11902
|
-
const content =
|
|
12018
|
+
const content = fs13.default.readFileSync(lockfilePath, "utf-8");
|
|
11903
12019
|
const result = LockfileSchema.parse(_yaml2.default.parse(content));
|
|
11904
12020
|
return result;
|
|
11905
12021
|
}
|
|
11906
12022
|
function _saveLockfile(lockfile) {
|
|
11907
12023
|
const lockfilePath = _getLockfilePath();
|
|
11908
12024
|
const content = _yaml2.default.stringify(lockfile);
|
|
11909
|
-
|
|
12025
|
+
fs13.default.writeFileSync(lockfilePath, content);
|
|
11910
12026
|
}
|
|
11911
12027
|
function _getLockfilePath() {
|
|
11912
|
-
return
|
|
12028
|
+
return path15.default.join(process.cwd(), "i18n.lock");
|
|
11913
12029
|
}
|
|
11914
12030
|
}
|
|
11915
12031
|
var LockfileSchema = _zod2.default.object({
|
|
@@ -12202,7 +12318,7 @@ function escapeShellArg(arg) {
|
|
|
12202
12318
|
|
|
12203
12319
|
|
|
12204
12320
|
|
|
12205
|
-
|
|
12321
|
+
|
|
12206
12322
|
|
|
12207
12323
|
|
|
12208
12324
|
// src/cli/cmd/run/setup.ts
|
|
@@ -12252,7 +12368,7 @@ function createLingoDotDevLocalizer(explicitApiKey) {
|
|
|
12252
12368
|
const response = await engine.whoami();
|
|
12253
12369
|
return {
|
|
12254
12370
|
authenticated: !!response,
|
|
12255
|
-
username: _optionalChain([response, 'optionalAccess',
|
|
12371
|
+
username: _optionalChain([response, 'optionalAccess', _369 => _369.email])
|
|
12256
12372
|
};
|
|
12257
12373
|
} catch (error) {
|
|
12258
12374
|
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
@@ -12394,7 +12510,7 @@ function countWordsInRecord2(payload) {
|
|
|
12394
12510
|
}
|
|
12395
12511
|
function createLingoDotDevVNextLocalizer(processId) {
|
|
12396
12512
|
const settings = getSettings(void 0);
|
|
12397
|
-
const apiKey = process.env.LINGO_API_KEY || _optionalChain([settings, 'access',
|
|
12513
|
+
const apiKey = process.env.LINGO_API_KEY || _optionalChain([settings, 'access', _370 => _370.auth, 'access', _371 => _371.vnext, 'optionalAccess', _372 => _372.apiKey]);
|
|
12398
12514
|
if (!apiKey) {
|
|
12399
12515
|
throw new Error(
|
|
12400
12516
|
_dedent2.default`
|
|
@@ -12421,7 +12537,7 @@ function createLingoDotDevVNextLocalizer(processId) {
|
|
|
12421
12537
|
const response = await engine.whoami();
|
|
12422
12538
|
return {
|
|
12423
12539
|
authenticated: !!response,
|
|
12424
|
-
username: _optionalChain([response, 'optionalAccess',
|
|
12540
|
+
username: _optionalChain([response, 'optionalAccess', _373 => _373.email])
|
|
12425
12541
|
};
|
|
12426
12542
|
} catch (error) {
|
|
12427
12543
|
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
@@ -12537,8 +12653,8 @@ function createExplicitLocalizer(provider) {
|
|
|
12537
12653
|
}
|
|
12538
12654
|
function createAiSdkLocalizer(params) {
|
|
12539
12655
|
const skipAuth = params.skipAuth === true;
|
|
12540
|
-
const apiKey = process.env[_nullishCoalesce(_optionalChain([params, 'optionalAccess',
|
|
12541
|
-
if (!skipAuth && !apiKey || !params.apiKeyName) {
|
|
12656
|
+
const apiKey = process.env[_nullishCoalesce(_optionalChain([params, 'optionalAccess', _374 => _374.apiKeyName]), () => ( ""))];
|
|
12657
|
+
if (!skipAuth && (!apiKey || !params.apiKeyName)) {
|
|
12542
12658
|
throw new Error(
|
|
12543
12659
|
_dedent2.default`
|
|
12544
12660
|
You're trying to use raw ${_chalk2.default.dim(params.id)} API for translation. ${params.apiKeyName ? `However, ${_chalk2.default.dim(
|
|
@@ -12796,8 +12912,8 @@ async function setup(input2) {
|
|
|
12796
12912
|
throw new Error(
|
|
12797
12913
|
"No buckets found in i18n.json. Please add at least one bucket containing i18n content."
|
|
12798
12914
|
);
|
|
12799
|
-
} else if (_optionalChain([ctx, 'access',
|
|
12800
|
-
(bucket) => !_optionalChain([ctx, 'access',
|
|
12915
|
+
} else if (_optionalChain([ctx, 'access', _375 => _375.flags, 'access', _376 => _376.bucket, 'optionalAccess', _377 => _377.some, 'call', _378 => _378(
|
|
12916
|
+
(bucket) => !_optionalChain([ctx, 'access', _379 => _379.config, 'optionalAccess', _380 => _380.buckets, 'access', _381 => _381[bucket]])
|
|
12801
12917
|
)])) {
|
|
12802
12918
|
throw new Error(
|
|
12803
12919
|
`One or more specified buckets do not exist in i18n.json. Please add them to the list first and try again.`
|
|
@@ -12809,8 +12925,8 @@ async function setup(input2) {
|
|
|
12809
12925
|
{
|
|
12810
12926
|
title: "Selecting localization provider",
|
|
12811
12927
|
task: async (ctx, task) => {
|
|
12812
|
-
const provider = ctx.flags.pseudo ? "pseudo" : _optionalChain([ctx, 'access',
|
|
12813
|
-
const vNext = _optionalChain([ctx, 'access',
|
|
12928
|
+
const provider = ctx.flags.pseudo ? "pseudo" : _optionalChain([ctx, 'access', _382 => _382.config, 'optionalAccess', _383 => _383.provider]);
|
|
12929
|
+
const vNext = _optionalChain([ctx, 'access', _384 => _384.config, 'optionalAccess', _385 => _385.vNext]);
|
|
12814
12930
|
ctx.localizer = createLocalizer(provider, ctx.flags.apiKey, vNext);
|
|
12815
12931
|
if (!ctx.localizer) {
|
|
12816
12932
|
throw new Error(
|
|
@@ -12822,7 +12938,7 @@ async function setup(input2) {
|
|
|
12822
12938
|
},
|
|
12823
12939
|
{
|
|
12824
12940
|
title: "Checking authentication",
|
|
12825
|
-
enabled: (ctx) => (_optionalChain([ctx, 'access',
|
|
12941
|
+
enabled: (ctx) => (_optionalChain([ctx, 'access', _386 => _386.localizer, 'optionalAccess', _387 => _387.id]) === "Lingo.dev" || _optionalChain([ctx, 'access', _388 => _388.localizer, 'optionalAccess', _389 => _389.id]) === "Lingo.dev vNext") && !ctx.flags.pseudo,
|
|
12826
12942
|
task: async (ctx, task) => {
|
|
12827
12943
|
const authStatus = await ctx.localizer.checkAuth();
|
|
12828
12944
|
if (!authStatus.authenticated) {
|
|
@@ -12835,7 +12951,7 @@ async function setup(input2) {
|
|
|
12835
12951
|
},
|
|
12836
12952
|
{
|
|
12837
12953
|
title: "Validating configuration",
|
|
12838
|
-
enabled: (ctx) => _optionalChain([ctx, 'access',
|
|
12954
|
+
enabled: (ctx) => _optionalChain([ctx, 'access', _390 => _390.localizer, 'optionalAccess', _391 => _391.id]) !== "Lingo.dev" && _optionalChain([ctx, 'access', _392 => _392.localizer, 'optionalAccess', _393 => _393.id]) !== "Lingo.dev vNext",
|
|
12839
12955
|
task: async (ctx, task) => {
|
|
12840
12956
|
const validationStatus = await ctx.localizer.validateSettings();
|
|
12841
12957
|
if (!validationStatus.valid) {
|
|
@@ -13008,13 +13124,19 @@ async function plan(input2) {
|
|
|
13008
13124
|
|
|
13009
13125
|
var _plimit = require('p-limit'); var _plimit2 = _interopRequireDefault(_plimit);
|
|
13010
13126
|
|
|
13011
|
-
var
|
|
13127
|
+
var WARN_CONCURRENCY_COUNT = 30;
|
|
13012
13128
|
async function execute(input2) {
|
|
13013
13129
|
const effectiveConcurrency = Math.min(
|
|
13014
13130
|
input2.flags.concurrency,
|
|
13015
|
-
input2.tasks.length
|
|
13016
|
-
MAX_WORKER_COUNT
|
|
13131
|
+
input2.tasks.length
|
|
13017
13132
|
);
|
|
13133
|
+
if (effectiveConcurrency >= WARN_CONCURRENCY_COUNT) {
|
|
13134
|
+
console.warn(
|
|
13135
|
+
_chalk2.default.yellow(
|
|
13136
|
+
`\u26A0\uFE0F High concurrency (${effectiveConcurrency}) may cause failures in some environments.`
|
|
13137
|
+
)
|
|
13138
|
+
);
|
|
13139
|
+
}
|
|
13018
13140
|
console.log(_chalk2.default.hex(colors.orange)(`[Localization]`));
|
|
13019
13141
|
return new (0, _listr2.Listr)(
|
|
13020
13142
|
[
|
|
@@ -13172,7 +13294,7 @@ function createWorkerTask(args) {
|
|
|
13172
13294
|
const processableData = _lodash2.default.chain(sourceData).entries().filter(
|
|
13173
13295
|
([key, value]) => delta.added.includes(key) || delta.updated.includes(key) || !!args.ctx.flags.force
|
|
13174
13296
|
).filter(
|
|
13175
|
-
([key]) => !assignedTask.onlyKeys.length || _optionalChain([assignedTask, 'access',
|
|
13297
|
+
([key]) => !assignedTask.onlyKeys.length || _optionalChain([assignedTask, 'access', _394 => _394.onlyKeys, 'optionalAccess', _395 => _395.some, 'call', _396 => _396(
|
|
13176
13298
|
(pattern) => minimatch(key, pattern)
|
|
13177
13299
|
)])
|
|
13178
13300
|
).fromPairs().value();
|
|
@@ -13240,7 +13362,7 @@ function createWorkerTask(args) {
|
|
|
13240
13362
|
finalRenamedTargetData
|
|
13241
13363
|
);
|
|
13242
13364
|
const checksums = await deltaProcessor.createChecksums(sourceData);
|
|
13243
|
-
if (!_optionalChain([args, 'access',
|
|
13365
|
+
if (!_optionalChain([args, 'access', _397 => _397.ctx, 'access', _398 => _398.flags, 'access', _399 => _399.targetLocale, 'optionalAccess', _400 => _400.length])) {
|
|
13244
13366
|
await deltaProcessor.saveChecksums(checksums);
|
|
13245
13367
|
}
|
|
13246
13368
|
});
|
|
@@ -13314,14 +13436,14 @@ async function watch2(ctx) {
|
|
|
13314
13436
|
pollInterval: 100
|
|
13315
13437
|
}
|
|
13316
13438
|
});
|
|
13317
|
-
watcher.on("change", (
|
|
13318
|
-
handleFileChange(
|
|
13439
|
+
watcher.on("change", (path20) => {
|
|
13440
|
+
handleFileChange(path20, state, ctx);
|
|
13319
13441
|
});
|
|
13320
|
-
watcher.on("add", (
|
|
13321
|
-
handleFileChange(
|
|
13442
|
+
watcher.on("add", (path20) => {
|
|
13443
|
+
handleFileChange(path20, state, ctx);
|
|
13322
13444
|
});
|
|
13323
|
-
watcher.on("unlink", (
|
|
13324
|
-
handleFileChange(
|
|
13445
|
+
watcher.on("unlink", (path20) => {
|
|
13446
|
+
handleFileChange(path20, state, ctx);
|
|
13325
13447
|
});
|
|
13326
13448
|
watcher.on("error", (error) => {
|
|
13327
13449
|
console.error(
|
|
@@ -13446,10 +13568,10 @@ var flagsSchema2 = _zod.z.object({
|
|
|
13446
13568
|
async function frozen(input2) {
|
|
13447
13569
|
console.log(_chalk2.default.hex(colors.orange)("[Frozen]"));
|
|
13448
13570
|
let buckets = getBuckets(input2.config);
|
|
13449
|
-
if (_optionalChain([input2, 'access',
|
|
13571
|
+
if (_optionalChain([input2, 'access', _401 => _401.flags, 'access', _402 => _402.bucket, 'optionalAccess', _403 => _403.length])) {
|
|
13450
13572
|
buckets = buckets.filter((b) => input2.flags.bucket.includes(b.type));
|
|
13451
13573
|
}
|
|
13452
|
-
if (_optionalChain([input2, 'access',
|
|
13574
|
+
if (_optionalChain([input2, 'access', _404 => _404.flags, 'access', _405 => _405.file, 'optionalAccess', _406 => _406.length])) {
|
|
13453
13575
|
buckets = buckets.map((bucket) => {
|
|
13454
13576
|
const paths = bucket.paths.filter(
|
|
13455
13577
|
(p) => input2.flags.file.some(
|
|
@@ -13586,13 +13708,13 @@ async function frozen(input2) {
|
|
|
13586
13708
|
|
|
13587
13709
|
// src/cli/cmd/run/_utils.ts
|
|
13588
13710
|
async function determineEmail(ctx) {
|
|
13589
|
-
const isByokMode = !!_optionalChain([ctx, 'access',
|
|
13711
|
+
const isByokMode = !!_optionalChain([ctx, 'access', _407 => _407.config, 'optionalAccess', _408 => _408.provider]);
|
|
13590
13712
|
if (isByokMode) {
|
|
13591
13713
|
return null;
|
|
13592
13714
|
} else {
|
|
13593
13715
|
try {
|
|
13594
|
-
const authStatus = await _optionalChain([ctx, 'access',
|
|
13595
|
-
return _optionalChain([authStatus, 'optionalAccess',
|
|
13716
|
+
const authStatus = await _optionalChain([ctx, 'access', _409 => _409.localizer, 'optionalAccess', _410 => _410.checkAuth, 'call', _411 => _411()]);
|
|
13717
|
+
return _optionalChain([authStatus, 'optionalAccess', _412 => _412.username]) || null;
|
|
13596
13718
|
} catch (e4) {
|
|
13597
13719
|
return null;
|
|
13598
13720
|
}
|
|
@@ -13600,12 +13722,12 @@ async function determineEmail(ctx) {
|
|
|
13600
13722
|
}
|
|
13601
13723
|
|
|
13602
13724
|
// src/cli/cmd/run/index.ts
|
|
13603
|
-
var
|
|
13725
|
+
var __dirname2 = path15.default.dirname(_url.fileURLToPath.call(void 0, _chunkEHIR4A2Gcjs.importMetaUrl));
|
|
13604
13726
|
function playSound(type) {
|
|
13605
13727
|
const platform = _os2.default.platform();
|
|
13606
13728
|
return new Promise((resolve) => {
|
|
13607
|
-
const assetDir =
|
|
13608
|
-
const soundFiles = [
|
|
13729
|
+
const assetDir = path15.default.join(__dirname2, "../assets");
|
|
13730
|
+
const soundFiles = [path15.default.join(assetDir, `${type}.mp3`)];
|
|
13609
13731
|
let command = "";
|
|
13610
13732
|
if (platform === "linux") {
|
|
13611
13733
|
command = soundFiles.map(
|
|
@@ -13799,7 +13921,7 @@ var InBranchFlow = class extends IntegrationFlow {
|
|
|
13799
13921
|
_child_process.execSync.call(void 0, `git config --global safe.directory ${process.cwd()}`);
|
|
13800
13922
|
_child_process.execSync.call(void 0, `git config user.name "${gitConfig.userName}"`);
|
|
13801
13923
|
_child_process.execSync.call(void 0, `git config user.email "${gitConfig.userEmail}"`);
|
|
13802
|
-
_optionalChain([this, 'access',
|
|
13924
|
+
_optionalChain([this, 'access', _413 => _413.platformKit, 'optionalAccess', _414 => _414.gitConfig, 'call', _415 => _415()]);
|
|
13803
13925
|
_child_process.execSync.call(void 0, `git fetch origin ${baseBranchName}`, { stdio: "inherit" });
|
|
13804
13926
|
_child_process.execSync.call(void 0, `git checkout ${baseBranchName} --`, { stdio: "inherit" });
|
|
13805
13927
|
if (!processOwnCommits) {
|
|
@@ -13814,7 +13936,7 @@ var InBranchFlow = class extends IntegrationFlow {
|
|
|
13814
13936
|
return false;
|
|
13815
13937
|
}
|
|
13816
13938
|
}
|
|
13817
|
-
const workingDir =
|
|
13939
|
+
const workingDir = path15.default.resolve(
|
|
13818
13940
|
process.cwd(),
|
|
13819
13941
|
this.platformKit.config.workingDir
|
|
13820
13942
|
);
|
|
@@ -13831,7 +13953,7 @@ var InBranchFlow = class extends IntegrationFlow {
|
|
|
13831
13953
|
// src/cli/cmd/ci/flows/pull-request.ts
|
|
13832
13954
|
var PullRequestFlow = class extends InBranchFlow {
|
|
13833
13955
|
async preRun() {
|
|
13834
|
-
const canContinue = await _optionalChain([super.preRun.bind(this), 'optionalCall',
|
|
13956
|
+
const canContinue = await _optionalChain([super.preRun.bind(this), 'optionalCall', _416 => _416()]);
|
|
13835
13957
|
if (!canContinue) {
|
|
13836
13958
|
return false;
|
|
13837
13959
|
}
|
|
@@ -14098,10 +14220,10 @@ var BitbucketPlatformKit = class extends PlatformKit {
|
|
|
14098
14220
|
repo_slug: this.platformConfig.repositoryName,
|
|
14099
14221
|
state: "OPEN"
|
|
14100
14222
|
}).then(({ data: { values } }) => {
|
|
14101
|
-
return _optionalChain([values, 'optionalAccess',
|
|
14102
|
-
({ source, destination }) => _optionalChain([source, 'optionalAccess',
|
|
14223
|
+
return _optionalChain([values, 'optionalAccess', _417 => _417.find, 'call', _418 => _418(
|
|
14224
|
+
({ source, destination }) => _optionalChain([source, 'optionalAccess', _419 => _419.branch, 'optionalAccess', _420 => _420.name]) === branch && _optionalChain([destination, 'optionalAccess', _421 => _421.branch, 'optionalAccess', _422 => _422.name]) === this.platformConfig.baseBranchName
|
|
14103
14225
|
)]);
|
|
14104
|
-
}).then((pr) => _optionalChain([pr, 'optionalAccess',
|
|
14226
|
+
}).then((pr) => _optionalChain([pr, 'optionalAccess', _423 => _423.id]));
|
|
14105
14227
|
}
|
|
14106
14228
|
async closePullRequest({ pullRequestNumber }) {
|
|
14107
14229
|
await this.bb.repositories.declinePullRequest({
|
|
@@ -14197,7 +14319,7 @@ var GitHubPlatformKit = class extends PlatformKit {
|
|
|
14197
14319
|
repo: this.platformConfig.repositoryName,
|
|
14198
14320
|
base: this.platformConfig.baseBranchName,
|
|
14199
14321
|
state: "open"
|
|
14200
|
-
}).then(({ data }) => data[0]).then((pr) => _optionalChain([pr, 'optionalAccess',
|
|
14322
|
+
}).then(({ data }) => data[0]).then((pr) => _optionalChain([pr, 'optionalAccess', _424 => _424.number]));
|
|
14201
14323
|
}
|
|
14202
14324
|
async closePullRequest({ pullRequestNumber }) {
|
|
14203
14325
|
await this.octokit.rest.pulls.update({
|
|
@@ -14324,7 +14446,7 @@ var GitlabPlatformKit = class extends PlatformKit {
|
|
|
14324
14446
|
sourceBranch: branch,
|
|
14325
14447
|
state: "opened"
|
|
14326
14448
|
});
|
|
14327
|
-
return _optionalChain([mergeRequests, 'access',
|
|
14449
|
+
return _optionalChain([mergeRequests, 'access', _425 => _425[0], 'optionalAccess', _426 => _426.iid]);
|
|
14328
14450
|
}
|
|
14329
14451
|
async closePullRequest({
|
|
14330
14452
|
pullRequestNumber
|
|
@@ -14436,7 +14558,7 @@ var ci_default = new (0, _interactivecommander.Command)().command("ci").descript
|
|
|
14436
14558
|
}
|
|
14437
14559
|
const env = {
|
|
14438
14560
|
LINGODOTDEV_API_KEY: settings.auth.apiKey,
|
|
14439
|
-
LINGODOTDEV_PULL_REQUEST: _optionalChain([options, 'access',
|
|
14561
|
+
LINGODOTDEV_PULL_REQUEST: _optionalChain([options, 'access', _427 => _427.pullRequest, 'optionalAccess', _428 => _428.toString, 'call', _429 => _429()]) || "false",
|
|
14440
14562
|
...options.commitMessage && {
|
|
14441
14563
|
LINGODOTDEV_COMMIT_MESSAGE: options.commitMessage
|
|
14442
14564
|
},
|
|
@@ -14462,7 +14584,7 @@ var ci_default = new (0, _interactivecommander.Command)().command("ci").descript
|
|
|
14462
14584
|
const { isPullRequestMode } = platformKit.config;
|
|
14463
14585
|
ora.info(`Pull request mode: ${isPullRequestMode ? "on" : "off"}`);
|
|
14464
14586
|
const flow = isPullRequestMode ? new PullRequestFlow(ora, platformKit) : new InBranchFlow(ora, platformKit);
|
|
14465
|
-
const canRun = await _optionalChain([flow, 'access',
|
|
14587
|
+
const canRun = await _optionalChain([flow, 'access', _430 => _430.preRun, 'optionalCall', _431 => _431()]);
|
|
14466
14588
|
if (canRun === false) {
|
|
14467
14589
|
return;
|
|
14468
14590
|
}
|
|
@@ -14472,7 +14594,7 @@ var ci_default = new (0, _interactivecommander.Command)().command("ci").descript
|
|
|
14472
14594
|
if (!hasChanges) {
|
|
14473
14595
|
return;
|
|
14474
14596
|
}
|
|
14475
|
-
await _optionalChain([flow, 'access',
|
|
14597
|
+
await _optionalChain([flow, 'access', _432 => _432.postRun, 'optionalCall', _433 => _433()]);
|
|
14476
14598
|
});
|
|
14477
14599
|
function parseBooleanArg(val) {
|
|
14478
14600
|
if (val === true) return true;
|
|
@@ -14509,8 +14631,8 @@ function exitGracefully(elapsedMs = 0) {
|
|
|
14509
14631
|
}
|
|
14510
14632
|
}
|
|
14511
14633
|
function checkForPendingOperations() {
|
|
14512
|
-
const activeHandles = _optionalChain([process, 'access',
|
|
14513
|
-
const activeRequests = _optionalChain([process, 'access',
|
|
14634
|
+
const activeHandles = _optionalChain([process, 'access', _434 => _434._getActiveHandles, 'optionalCall', _435 => _435()]) || [];
|
|
14635
|
+
const activeRequests = _optionalChain([process, 'access', _436 => _436._getActiveRequests, 'optionalCall', _437 => _437()]) || [];
|
|
14514
14636
|
const nonStandardHandles = activeHandles.filter((handle) => {
|
|
14515
14637
|
if (handle === process.stdin || handle === process.stdout || handle === process.stderr) {
|
|
14516
14638
|
return false;
|
|
@@ -14580,17 +14702,17 @@ var status_default = new (0, _interactivecommander.Command)().command("status").
|
|
|
14580
14702
|
});
|
|
14581
14703
|
await new Promise((resolve) => setTimeout(resolve, 50));
|
|
14582
14704
|
let buckets = getBuckets(i18nConfig);
|
|
14583
|
-
if (_optionalChain([flags, 'access',
|
|
14705
|
+
if (_optionalChain([flags, 'access', _438 => _438.bucket, 'optionalAccess', _439 => _439.length])) {
|
|
14584
14706
|
buckets = buckets.filter(
|
|
14585
14707
|
(bucket) => flags.bucket.includes(bucket.type)
|
|
14586
14708
|
);
|
|
14587
14709
|
}
|
|
14588
14710
|
ora.succeed("Buckets retrieved");
|
|
14589
|
-
if (_optionalChain([flags, 'access',
|
|
14711
|
+
if (_optionalChain([flags, 'access', _440 => _440.file, 'optionalAccess', _441 => _441.length])) {
|
|
14590
14712
|
buckets = buckets.map((bucket) => {
|
|
14591
14713
|
const paths = bucket.paths.filter(
|
|
14592
|
-
(
|
|
14593
|
-
(file) => _optionalChain([
|
|
14714
|
+
(path20) => flags.file.find(
|
|
14715
|
+
(file) => _optionalChain([path20, 'access', _442 => _442.pathPattern, 'optionalAccess', _443 => _443.includes, 'call', _444 => _444(file)]) || _optionalChain([path20, 'access', _445 => _445.pathPattern, 'optionalAccess', _446 => _446.match, 'call', _447 => _447(file)]) || minimatch(path20.pathPattern, file)
|
|
14594
14716
|
)
|
|
14595
14717
|
);
|
|
14596
14718
|
return { ...bucket, paths };
|
|
@@ -14604,13 +14726,13 @@ var status_default = new (0, _interactivecommander.Command)().command("status").
|
|
|
14604
14726
|
ora.info(`\x1B[36mProcessing only filtered buckets:\x1B[0m`);
|
|
14605
14727
|
buckets.map((bucket) => {
|
|
14606
14728
|
ora.info(` ${bucket.type}:`);
|
|
14607
|
-
bucket.paths.forEach((
|
|
14608
|
-
ora.info(` - ${
|
|
14729
|
+
bucket.paths.forEach((path20) => {
|
|
14730
|
+
ora.info(` - ${path20.pathPattern}`);
|
|
14609
14731
|
});
|
|
14610
14732
|
});
|
|
14611
14733
|
}
|
|
14612
14734
|
}
|
|
14613
|
-
const targetLocales = _optionalChain([flags, 'access',
|
|
14735
|
+
const targetLocales = _optionalChain([flags, 'access', _448 => _448.locale, 'optionalAccess', _449 => _449.length]) ? flags.locale : i18nConfig.locale.targets;
|
|
14614
14736
|
let totalSourceKeyCount = 0;
|
|
14615
14737
|
let uniqueKeysToTranslate = 0;
|
|
14616
14738
|
let totalExistingTranslations = 0;
|
|
@@ -14892,10 +15014,10 @@ var status_default = new (0, _interactivecommander.Command)().command("status").
|
|
|
14892
15014
|
if (flags.confirm && Object.keys(fileStats).length > 0) {
|
|
14893
15015
|
console.log(_chalk2.default.bold(`
|
|
14894
15016
|
\u{1F4D1} BREAKDOWN BY FILE:`));
|
|
14895
|
-
Object.entries(fileStats).sort((a, b) => b[1].wordCount - a[1].wordCount).forEach(([
|
|
15017
|
+
Object.entries(fileStats).sort((a, b) => b[1].wordCount - a[1].wordCount).forEach(([path20, stats]) => {
|
|
14896
15018
|
if (stats.sourceKeys === 0) return;
|
|
14897
15019
|
console.log(_chalk2.default.bold(`
|
|
14898
|
-
\u2022 ${
|
|
15020
|
+
\u2022 ${path20}:`));
|
|
14899
15021
|
console.log(
|
|
14900
15022
|
` ${stats.sourceKeys} source keys, ~${stats.wordCount.toLocaleString()} source words`
|
|
14901
15023
|
);
|
|
@@ -15020,12 +15142,12 @@ function validateParams2(i18nConfig, flags) {
|
|
|
15020
15142
|
message: "No buckets found in i18n.json. Please add at least one bucket containing i18n content.",
|
|
15021
15143
|
docUrl: "bucketNotFound"
|
|
15022
15144
|
});
|
|
15023
|
-
} else if (_optionalChain([flags, 'access',
|
|
15145
|
+
} else if (_optionalChain([flags, 'access', _450 => _450.locale, 'optionalAccess', _451 => _451.some, 'call', _452 => _452((locale) => !i18nConfig.locale.targets.includes(locale))])) {
|
|
15024
15146
|
throw new CLIError({
|
|
15025
15147
|
message: `One or more specified locales do not exist in i18n.json locale.targets. Please add them to the list and try again.`,
|
|
15026
15148
|
docUrl: "localeTargetNotFound"
|
|
15027
15149
|
});
|
|
15028
|
-
} else if (_optionalChain([flags, 'access',
|
|
15150
|
+
} else if (_optionalChain([flags, 'access', _453 => _453.bucket, 'optionalAccess', _454 => _454.some, 'call', _455 => _455(
|
|
15029
15151
|
(bucket) => !i18nConfig.buckets[bucket]
|
|
15030
15152
|
)])) {
|
|
15031
15153
|
throw new CLIError({
|
|
@@ -15117,7 +15239,7 @@ async function renderHero2() {
|
|
|
15117
15239
|
// package.json
|
|
15118
15240
|
var package_default = {
|
|
15119
15241
|
name: "lingo.dev",
|
|
15120
|
-
version: "0.
|
|
15242
|
+
version: "0.120.0",
|
|
15121
15243
|
description: "Lingo.dev CLI",
|
|
15122
15244
|
private: false,
|
|
15123
15245
|
repository: {
|
|
@@ -15230,7 +15352,8 @@ var package_default = {
|
|
|
15230
15352
|
files: [
|
|
15231
15353
|
"bin",
|
|
15232
15354
|
"build",
|
|
15233
|
-
"assets"
|
|
15355
|
+
"assets",
|
|
15356
|
+
"agents.md"
|
|
15234
15357
|
],
|
|
15235
15358
|
scripts: {
|
|
15236
15359
|
"lingo.dev": "node --inspect=9229 ./bin/cli.mjs",
|
|
@@ -15419,7 +15542,7 @@ var purge_default = new (0, _interactivecommander.Command)().command("purge").de
|
|
|
15419
15542
|
if (options.file && options.file.length) {
|
|
15420
15543
|
buckets = buckets.map((bucket) => {
|
|
15421
15544
|
const paths = bucket.paths.filter(
|
|
15422
|
-
(bucketPath) => _optionalChain([options, 'access',
|
|
15545
|
+
(bucketPath) => _optionalChain([options, 'access', _456 => _456.file, 'optionalAccess', _457 => _457.some, 'call', _458 => _458((f) => bucketPath.pathPattern.includes(f))])
|
|
15423
15546
|
);
|
|
15424
15547
|
return { ...bucket, paths };
|
|
15425
15548
|
}).filter((bucket) => bucket.paths.length > 0);
|