lingo.dev 0.87.0 → 0.87.1
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 +221 -550
- package/build/cli.cjs.map +1 -1
- package/build/cli.mjs +133 -462
- package/build/cli.mjs.map +1 -1
- package/package.json +3 -3
package/build/cli.cjs
CHANGED
|
@@ -14,9 +14,9 @@ var _promises = require('readline/promises'); var _promises2 = _interopRequireDe
|
|
|
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 path14 = _interopRequireWildcard(_path); var path12 = _interopRequireWildcard(_path); var path13 = _interopRequireWildcard(_path);
|
|
18
18
|
var _zod = require('zod'); var _zod2 = _interopRequireDefault(_zod);
|
|
19
|
-
var _fs = require('fs'); var
|
|
19
|
+
var _fs = require('fs'); var fs10 = _interopRequireWildcard(_fs);
|
|
20
20
|
var _ini = require('ini'); var _ini2 = _interopRequireDefault(_ini);
|
|
21
21
|
function getSettings(explicitApiKey) {
|
|
22
22
|
const env = _loadEnv();
|
|
@@ -26,9 +26,9 @@ function getSettings(explicitApiKey) {
|
|
|
26
26
|
_envVarsInfo();
|
|
27
27
|
return {
|
|
28
28
|
auth: {
|
|
29
|
-
apiKey: explicitApiKey || env.LINGODOTDEV_API_KEY || _optionalChain([systemFile, 'access',
|
|
30
|
-
apiUrl: env.LINGODOTDEV_API_URL || _optionalChain([systemFile, 'access',
|
|
31
|
-
webUrl: env.LINGODOTDEV_WEB_URL || _optionalChain([systemFile, 'access',
|
|
29
|
+
apiKey: explicitApiKey || env.LINGODOTDEV_API_KEY || _optionalChain([systemFile, 'access', _26 => _26.auth, 'optionalAccess', _27 => _27.apiKey]) || defaults.auth.apiKey,
|
|
30
|
+
apiUrl: env.LINGODOTDEV_API_URL || _optionalChain([systemFile, 'access', _28 => _28.auth, 'optionalAccess', _29 => _29.apiUrl]) || defaults.auth.apiUrl,
|
|
31
|
+
webUrl: env.LINGODOTDEV_WEB_URL || _optionalChain([systemFile, 'access', _30 => _30.auth, 'optionalAccess', _31 => _31.webUrl]) || defaults.auth.webUrl
|
|
32
32
|
}
|
|
33
33
|
};
|
|
34
34
|
}
|
|
@@ -60,7 +60,7 @@ function _loadEnv() {
|
|
|
60
60
|
}
|
|
61
61
|
function _loadSystemFile() {
|
|
62
62
|
const settingsFilePath = _getSettingsFilePath();
|
|
63
|
-
const content =
|
|
63
|
+
const content = fs10.default.existsSync(settingsFilePath) ? fs10.default.readFileSync(settingsFilePath, "utf-8") : "";
|
|
64
64
|
const data = _ini2.default.parse(content);
|
|
65
65
|
return _zod2.default.object({
|
|
66
66
|
auth: _zod2.default.object({
|
|
@@ -73,12 +73,12 @@ function _loadSystemFile() {
|
|
|
73
73
|
function _saveSystemFile(settings) {
|
|
74
74
|
const settingsFilePath = _getSettingsFilePath();
|
|
75
75
|
const content = _ini2.default.stringify(settings);
|
|
76
|
-
|
|
76
|
+
fs10.default.writeFileSync(settingsFilePath, content);
|
|
77
77
|
}
|
|
78
78
|
function _getSettingsFilePath() {
|
|
79
79
|
const settingsFile = ".lingodotdevrc";
|
|
80
80
|
const homedir = _os2.default.homedir();
|
|
81
|
-
const settingsFilePath =
|
|
81
|
+
const settingsFilePath = path14.default.join(homedir, settingsFile);
|
|
82
82
|
return settingsFilePath;
|
|
83
83
|
}
|
|
84
84
|
function _legacyEnvVarWarning() {
|
|
@@ -99,7 +99,7 @@ Please use LINGODOTDEV_API_KEY instead.
|
|
|
99
99
|
function _envVarsInfo() {
|
|
100
100
|
const env = _loadEnv();
|
|
101
101
|
const systemFile = _loadSystemFile();
|
|
102
|
-
if (env.LINGODOTDEV_API_KEY && _optionalChain([systemFile, 'access',
|
|
102
|
+
if (env.LINGODOTDEV_API_KEY && _optionalChain([systemFile, 'access', _32 => _32.auth, 'optionalAccess', _33 => _33.apiKey])) {
|
|
103
103
|
console.info(
|
|
104
104
|
"\x1B[36m%s\x1B[0m",
|
|
105
105
|
`\u2139\uFE0F Using LINGODOTDEV_API_KEY env var instead of credentials from login flow (saved in .lingodotdevrc)`
|
|
@@ -154,7 +154,7 @@ function createAuthenticator(params) {
|
|
|
154
154
|
});
|
|
155
155
|
if (res.ok) {
|
|
156
156
|
const payload = await res.json();
|
|
157
|
-
if (!_optionalChain([payload, 'optionalAccess',
|
|
157
|
+
if (!_optionalChain([payload, 'optionalAccess', _34 => _34.email])) {
|
|
158
158
|
return null;
|
|
159
159
|
}
|
|
160
160
|
return {
|
|
@@ -257,11 +257,11 @@ var _lodash = require('lodash'); var _lodash2 = _interopRequireDefault(_lodash);
|
|
|
257
257
|
var __spec = require('@lingo.dev/_spec');
|
|
258
258
|
function getConfig(resave = true) {
|
|
259
259
|
const configFilePath = _getConfigFilePath();
|
|
260
|
-
const configFileExists =
|
|
260
|
+
const configFileExists = fs10.default.existsSync(configFilePath);
|
|
261
261
|
if (!configFileExists) {
|
|
262
262
|
return null;
|
|
263
263
|
}
|
|
264
|
-
const fileContents =
|
|
264
|
+
const fileContents = fs10.default.readFileSync(configFilePath, "utf8");
|
|
265
265
|
const rawConfig = JSON.parse(fileContents);
|
|
266
266
|
const result = __spec.parseI18nConfig.call(void 0, rawConfig);
|
|
267
267
|
const didConfigChange = !_lodash2.default.isEqual(rawConfig, result);
|
|
@@ -273,11 +273,11 @@ function getConfig(resave = true) {
|
|
|
273
273
|
function saveConfig(config) {
|
|
274
274
|
const configFilePath = _getConfigFilePath();
|
|
275
275
|
const serialized = JSON.stringify(config, null, 2);
|
|
276
|
-
|
|
276
|
+
fs10.default.writeFileSync(configFilePath, serialized);
|
|
277
277
|
return config;
|
|
278
278
|
}
|
|
279
279
|
function _getConfigFilePath() {
|
|
280
|
-
return
|
|
280
|
+
return path14.default.join(process.cwd(), "i18n.json");
|
|
281
281
|
}
|
|
282
282
|
|
|
283
283
|
// src/cli/cmd/init.ts
|
|
@@ -362,7 +362,7 @@ function findLocaleFilesForFilename(fileName) {
|
|
|
362
362
|
});
|
|
363
363
|
const localeFilesAndPatterns = localeFiles.map((file) => ({
|
|
364
364
|
file,
|
|
365
|
-
pattern:
|
|
365
|
+
pattern: path14.default.join(path14.default.dirname(file), pattern)
|
|
366
366
|
}));
|
|
367
367
|
const grouppedFilesAndPatterns = _lodash2.default.groupBy(localeFilesAndPatterns, "pattern");
|
|
368
368
|
const patterns = Object.keys(grouppedFilesAndPatterns);
|
|
@@ -382,10 +382,10 @@ function ensurePatterns(patterns, source) {
|
|
|
382
382
|
}
|
|
383
383
|
patterns.forEach((pattern) => {
|
|
384
384
|
const filePath = pattern.replace("[locale]", source);
|
|
385
|
-
if (!
|
|
386
|
-
const defaultContent = getDefaultContent(
|
|
387
|
-
|
|
388
|
-
|
|
385
|
+
if (!fs10.default.existsSync(filePath)) {
|
|
386
|
+
const defaultContent = getDefaultContent(path14.default.extname(filePath), source);
|
|
387
|
+
fs10.default.mkdirSync(path14.default.dirname(filePath), { recursive: true });
|
|
388
|
+
fs10.default.writeFileSync(filePath, defaultContent);
|
|
389
389
|
}
|
|
390
390
|
});
|
|
391
391
|
}
|
|
@@ -464,31 +464,31 @@ function updateGitignore() {
|
|
|
464
464
|
if (!projectRoot) {
|
|
465
465
|
return;
|
|
466
466
|
}
|
|
467
|
-
const gitignorePath =
|
|
468
|
-
if (!
|
|
467
|
+
const gitignorePath = path14.default.join(projectRoot, ".gitignore");
|
|
468
|
+
if (!fs10.default.existsSync(gitignorePath)) {
|
|
469
469
|
return;
|
|
470
470
|
}
|
|
471
|
-
const gitignore =
|
|
471
|
+
const gitignore = fs10.default.readFileSync(gitignorePath, "utf8").split("\n");
|
|
472
472
|
const cacheIsIgnored = gitignore.includes(cacheFile);
|
|
473
473
|
if (!cacheIsIgnored) {
|
|
474
474
|
let content = "";
|
|
475
|
-
content =
|
|
475
|
+
content = fs10.default.readFileSync(gitignorePath, "utf8");
|
|
476
476
|
if (content !== "" && !content.endsWith("\n")) {
|
|
477
477
|
content += "\n";
|
|
478
478
|
}
|
|
479
479
|
content += `${cacheFile}
|
|
480
480
|
`;
|
|
481
|
-
|
|
481
|
+
fs10.default.writeFileSync(gitignorePath, content);
|
|
482
482
|
}
|
|
483
483
|
}
|
|
484
484
|
function findCurrentProjectRoot() {
|
|
485
485
|
let currentDir = process.cwd();
|
|
486
|
-
while (currentDir !==
|
|
487
|
-
const gitDirPath =
|
|
488
|
-
if (
|
|
486
|
+
while (currentDir !== path14.default.parse(currentDir).root) {
|
|
487
|
+
const gitDirPath = path14.default.join(currentDir, ".git");
|
|
488
|
+
if (fs10.default.existsSync(gitDirPath) && fs10.default.lstatSync(gitDirPath).isDirectory()) {
|
|
489
489
|
return currentDir;
|
|
490
490
|
}
|
|
491
|
-
currentDir =
|
|
491
|
+
currentDir = path14.default.dirname(currentDir);
|
|
492
492
|
}
|
|
493
493
|
return null;
|
|
494
494
|
}
|
|
@@ -530,24 +530,24 @@ function makePlatformInitializer(config, spinner) {
|
|
|
530
530
|
return {
|
|
531
531
|
name: config.name,
|
|
532
532
|
isEnabled: () => {
|
|
533
|
-
const filePath =
|
|
534
|
-
return
|
|
533
|
+
const filePath = path14.default.join(process.cwd(), config.checkPath);
|
|
534
|
+
return fs10.default.existsSync(filePath);
|
|
535
535
|
},
|
|
536
536
|
init: async () => {
|
|
537
|
-
const filePath =
|
|
538
|
-
const dirPath =
|
|
539
|
-
if (!
|
|
540
|
-
|
|
537
|
+
const filePath = path14.default.join(process.cwd(), config.ciConfigPath);
|
|
538
|
+
const dirPath = path14.default.dirname(filePath);
|
|
539
|
+
if (!fs10.default.existsSync(dirPath)) {
|
|
540
|
+
fs10.default.mkdirSync(dirPath, { recursive: true });
|
|
541
541
|
}
|
|
542
542
|
let canWrite = true;
|
|
543
|
-
if (
|
|
543
|
+
if (fs10.default.existsSync(filePath)) {
|
|
544
544
|
canWrite = await _prompts.confirm.call(void 0, {
|
|
545
545
|
message: `File ${filePath} already exists. Do you want to overwrite it?`,
|
|
546
546
|
default: false
|
|
547
547
|
});
|
|
548
548
|
}
|
|
549
549
|
if (canWrite) {
|
|
550
|
-
|
|
550
|
+
fs10.default.writeFileSync(filePath, config.ciConfigContent);
|
|
551
551
|
spinner.succeed(`CI/CD initialized for ${config.name}`);
|
|
552
552
|
} else {
|
|
553
553
|
spinner.warn(`CI/CD not initialized for ${config.name}`);
|
|
@@ -621,9 +621,9 @@ function makeGitlabInitializer(spinner) {
|
|
|
621
621
|
|
|
622
622
|
// src/cli/cmd/init.ts
|
|
623
623
|
|
|
624
|
-
var openUrl = (
|
|
624
|
+
var openUrl = (path17) => {
|
|
625
625
|
const settings = getSettings(void 0);
|
|
626
|
-
_open2.default.call(void 0, `${settings.auth.webUrl}${
|
|
626
|
+
_open2.default.call(void 0, `${settings.auth.webUrl}${path17}`, { wait: false });
|
|
627
627
|
};
|
|
628
628
|
var throwHelpError = (option, value) => {
|
|
629
629
|
if (value === "help") {
|
|
@@ -669,8 +669,8 @@ var init_default = new (0, _interactivecommander.InteractiveCommand)().command("
|
|
|
669
669
|
const values = value.includes(",") ? value.split(",") : value.split(" ");
|
|
670
670
|
for (const p of values) {
|
|
671
671
|
try {
|
|
672
|
-
const dirPath =
|
|
673
|
-
const stats =
|
|
672
|
+
const dirPath = path14.default.dirname(p);
|
|
673
|
+
const stats = fs10.default.statSync(dirPath);
|
|
674
674
|
if (!stats.isDirectory()) {
|
|
675
675
|
throw new Error(`${dirPath} is not a directory`);
|
|
676
676
|
}
|
|
@@ -774,7 +774,7 @@ var init_default = new (0, _interactivecommander.InteractiveCommand)().command("
|
|
|
774
774
|
});
|
|
775
775
|
const auth2 = await newAuthenticator.whoami();
|
|
776
776
|
if (auth2) {
|
|
777
|
-
_ora2.default.call(void 0, ).succeed(`Authenticated as ${_optionalChain([auth2, 'optionalAccess',
|
|
777
|
+
_ora2.default.call(void 0, ).succeed(`Authenticated as ${_optionalChain([auth2, 'optionalAccess', _35 => _35.email])}`);
|
|
778
778
|
} else {
|
|
779
779
|
_ora2.default.call(void 0, ).fail("Authentication failed.");
|
|
780
780
|
}
|
|
@@ -806,12 +806,12 @@ var config_default = new (0, _interactivecommander.Command)().command("config").
|
|
|
806
806
|
console.log(JSON.stringify(config, null, 2));
|
|
807
807
|
});
|
|
808
808
|
function loadReplexicaFileConfig() {
|
|
809
|
-
const replexicaConfigPath =
|
|
810
|
-
const fileExists =
|
|
809
|
+
const replexicaConfigPath = path14.default.resolve(process.cwd(), "i18n.json");
|
|
810
|
+
const fileExists = fs10.default.existsSync(replexicaConfigPath);
|
|
811
811
|
if (!fileExists) {
|
|
812
812
|
return void 0;
|
|
813
813
|
}
|
|
814
|
-
const fileContent =
|
|
814
|
+
const fileContent = fs10.default.readFileSync(replexicaConfigPath, "utf-8");
|
|
815
815
|
const replexicaFileConfig = JSON.parse(fileContent);
|
|
816
816
|
return replexicaFileConfig;
|
|
817
817
|
}
|
|
@@ -854,7 +854,7 @@ var locale_default = new (0, _interactivecommander.Command)().command("locale").
|
|
|
854
854
|
function getBuckets(i18nConfig) {
|
|
855
855
|
const result = Object.entries(i18nConfig.buckets).map(([bucketType, bucketEntry]) => {
|
|
856
856
|
const includeItems = bucketEntry.include.map((item) => resolveBucketItem(item));
|
|
857
|
-
const excludeItems = _optionalChain([bucketEntry, 'access',
|
|
857
|
+
const excludeItems = _optionalChain([bucketEntry, 'access', _36 => _36.exclude, 'optionalAccess', _37 => _37.map, 'call', _38 => _38((item) => resolveBucketItem(item))]);
|
|
858
858
|
const config = {
|
|
859
859
|
type: bucketType,
|
|
860
860
|
paths: extractPathPatterns(i18nConfig.locale.source, includeItems, excludeItems)
|
|
@@ -878,7 +878,7 @@ function extractPathPatterns(sourceLocale, include, exclude) {
|
|
|
878
878
|
})
|
|
879
879
|
)
|
|
880
880
|
);
|
|
881
|
-
const excludedPatterns = _optionalChain([exclude, 'optionalAccess',
|
|
881
|
+
const excludedPatterns = _optionalChain([exclude, 'optionalAccess', _39 => _39.flatMap, 'call', _40 => _40(
|
|
882
882
|
(pattern) => expandPlaceholderedGlob(pattern.path, __spec.resolveOverriddenLocale.call(void 0, sourceLocale, pattern.delimiter)).map(
|
|
883
883
|
(pathPattern) => ({
|
|
884
884
|
pathPattern,
|
|
@@ -890,9 +890,9 @@ function extractPathPatterns(sourceLocale, include, exclude) {
|
|
|
890
890
|
return result;
|
|
891
891
|
}
|
|
892
892
|
function expandPlaceholderedGlob(_pathPattern, sourceLocale) {
|
|
893
|
-
const absolutePathPattern =
|
|
894
|
-
const pathPattern =
|
|
895
|
-
if (
|
|
893
|
+
const absolutePathPattern = path14.default.resolve(_pathPattern);
|
|
894
|
+
const pathPattern = path14.default.relative(process.cwd(), absolutePathPattern);
|
|
895
|
+
if (path14.default.relative(process.cwd(), pathPattern).startsWith("..")) {
|
|
896
896
|
throw new CLIError({
|
|
897
897
|
message: `Invalid path pattern: ${pathPattern}. Path pattern must be within the current working directory.`,
|
|
898
898
|
docUrl: "invalidPathPattern"
|
|
@@ -904,7 +904,7 @@ function expandPlaceholderedGlob(_pathPattern, sourceLocale) {
|
|
|
904
904
|
docUrl: "invalidPathPattern"
|
|
905
905
|
});
|
|
906
906
|
}
|
|
907
|
-
const pathPatternChunks = pathPattern.split(
|
|
907
|
+
const pathPatternChunks = pathPattern.split(path14.default.sep);
|
|
908
908
|
const localeSegmentIndexes = pathPatternChunks.reduce((indexes, segment, index) => {
|
|
909
909
|
if (segment.includes("[locale]")) {
|
|
910
910
|
indexes.push(index);
|
|
@@ -912,9 +912,9 @@ function expandPlaceholderedGlob(_pathPattern, sourceLocale) {
|
|
|
912
912
|
return indexes;
|
|
913
913
|
}, []);
|
|
914
914
|
const sourcePathPattern = pathPattern.replaceAll(/\[locale\]/g, sourceLocale);
|
|
915
|
-
const sourcePaths = _glob.glob.sync(sourcePathPattern, { follow: true, withFileTypes: true }).filter((file) => file.isFile() || file.isSymbolicLink()).map((file) => file.fullpath()).map((fullpath) =>
|
|
915
|
+
const sourcePaths = _glob.glob.sync(sourcePathPattern, { follow: true, withFileTypes: true }).filter((file) => file.isFile() || file.isSymbolicLink()).map((file) => file.fullpath()).map((fullpath) => path14.default.relative(process.cwd(), fullpath));
|
|
916
916
|
const placeholderedPaths = sourcePaths.map((sourcePath) => {
|
|
917
|
-
const sourcePathChunks = sourcePath.split(
|
|
917
|
+
const sourcePathChunks = sourcePath.split(path14.default.sep);
|
|
918
918
|
localeSegmentIndexes.forEach((localeSegmentIndex) => {
|
|
919
919
|
const pathPatternChunk = pathPatternChunks[localeSegmentIndex];
|
|
920
920
|
const sourcePathChunk = sourcePathChunks[localeSegmentIndex];
|
|
@@ -928,7 +928,7 @@ function expandPlaceholderedGlob(_pathPattern, sourceLocale) {
|
|
|
928
928
|
sourcePathChunks[localeSegmentIndex] = placeholderedSegment;
|
|
929
929
|
}
|
|
930
930
|
});
|
|
931
|
-
const placeholderedPath = sourcePathChunks.join(
|
|
931
|
+
const placeholderedPath = sourcePathChunks.join(path14.default.sep);
|
|
932
932
|
return placeholderedPath;
|
|
933
933
|
});
|
|
934
934
|
return placeholderedPaths;
|
|
@@ -970,8 +970,8 @@ var files_default = new (0, _interactivecommander.Command)().command("files").de
|
|
|
970
970
|
} else if (type.target) {
|
|
971
971
|
result.push(...targetPaths);
|
|
972
972
|
}
|
|
973
|
-
result.forEach((
|
|
974
|
-
console.log(
|
|
973
|
+
result.forEach((path17) => {
|
|
974
|
+
console.log(path17);
|
|
975
975
|
});
|
|
976
976
|
}
|
|
977
977
|
}
|
|
@@ -1007,12 +1007,12 @@ function composeLoaders(...loaders) {
|
|
|
1007
1007
|
return {
|
|
1008
1008
|
init: async () => {
|
|
1009
1009
|
for (const loader of loaders) {
|
|
1010
|
-
await _optionalChain([loader, 'access',
|
|
1010
|
+
await _optionalChain([loader, 'access', _41 => _41.init, 'optionalCall', _42 => _42()]);
|
|
1011
1011
|
}
|
|
1012
1012
|
},
|
|
1013
1013
|
setDefaultLocale(locale) {
|
|
1014
1014
|
for (const loader of loaders) {
|
|
1015
|
-
_optionalChain([loader, 'access',
|
|
1015
|
+
_optionalChain([loader, 'access', _43 => _43.setDefaultLocale, 'optionalCall', _44 => _44(locale)]);
|
|
1016
1016
|
}
|
|
1017
1017
|
return this;
|
|
1018
1018
|
},
|
|
@@ -1045,7 +1045,7 @@ function createLoader(lDefinition) {
|
|
|
1045
1045
|
if (state.initCtx) {
|
|
1046
1046
|
return state.initCtx;
|
|
1047
1047
|
}
|
|
1048
|
-
state.initCtx = await _optionalChain([lDefinition, 'access',
|
|
1048
|
+
state.initCtx = await _optionalChain([lDefinition, 'access', _45 => _45.init, 'optionalCall', _46 => _46()]);
|
|
1049
1049
|
return state.initCtx;
|
|
1050
1050
|
},
|
|
1051
1051
|
setDefaultLocale(locale) {
|
|
@@ -1144,7 +1144,7 @@ function createNormalizeLoader() {
|
|
|
1144
1144
|
return normalized;
|
|
1145
1145
|
},
|
|
1146
1146
|
push: async (locale, data, originalInput) => {
|
|
1147
|
-
const keysMap = _nullishCoalesce(_optionalChain([originalInput, 'optionalAccess',
|
|
1147
|
+
const keysMap = _nullishCoalesce(_optionalChain([originalInput, 'optionalAccess', _47 => _47.keysMap]), () => ( {}));
|
|
1148
1148
|
const input2 = mapDenormalizedKeys(data, keysMap);
|
|
1149
1149
|
const denormalized = _flat.unflatten.call(void 0, input2, {
|
|
1150
1150
|
delimiter: "/",
|
|
@@ -1218,10 +1218,10 @@ function createTextFileLoader(pathPattern) {
|
|
|
1218
1218
|
const trimmedResult = result.trim();
|
|
1219
1219
|
return trimmedResult;
|
|
1220
1220
|
},
|
|
1221
|
-
async push(locale, data,
|
|
1221
|
+
async push(locale, data, _25, originalLocale) {
|
|
1222
1222
|
const draftPath = pathPattern.replaceAll("[locale]", locale);
|
|
1223
|
-
const finalPath =
|
|
1224
|
-
const dirPath =
|
|
1223
|
+
const finalPath = path14.default.resolve(draftPath);
|
|
1224
|
+
const dirPath = path14.default.dirname(finalPath);
|
|
1225
1225
|
await _promises4.default.mkdir(dirPath, { recursive: true });
|
|
1226
1226
|
const trimmedPayload = data.trim();
|
|
1227
1227
|
const trailingNewLine = await getTrailingNewLine(pathPattern, locale, originalLocale);
|
|
@@ -1235,7 +1235,7 @@ function createTextFileLoader(pathPattern) {
|
|
|
1235
1235
|
}
|
|
1236
1236
|
async function readFileForLocale(pathPattern, locale) {
|
|
1237
1237
|
const draftPath = pathPattern.replaceAll("[locale]", locale);
|
|
1238
|
-
const finalPath =
|
|
1238
|
+
const finalPath = path14.default.resolve(draftPath);
|
|
1239
1239
|
const exists = await _promises4.default.access(finalPath).then(() => true).catch(() => false);
|
|
1240
1240
|
if (!exists) {
|
|
1241
1241
|
return "";
|
|
@@ -1247,8 +1247,8 @@ async function getTrailingNewLine(pathPattern, locale, originalLocale) {
|
|
|
1247
1247
|
if (!templateData) {
|
|
1248
1248
|
templateData = await readFileForLocale(pathPattern, originalLocale);
|
|
1249
1249
|
}
|
|
1250
|
-
if (_optionalChain([templateData, 'optionalAccess',
|
|
1251
|
-
const ending = _optionalChain([templateData, 'optionalAccess',
|
|
1250
|
+
if (_optionalChain([templateData, 'optionalAccess', _48 => _48.match, 'call', _49 => _49(/[\r\n]$/)])) {
|
|
1251
|
+
const ending = _optionalChain([templateData, 'optionalAccess', _50 => _50.includes, 'call', _51 => _51("\r\n")]) ? "\r\n" : _optionalChain([templateData, 'optionalAccess', _52 => _52.includes, 'call', _53 => _53("\r")]) ? "\r" : "\n";
|
|
1252
1252
|
return ending;
|
|
1253
1253
|
}
|
|
1254
1254
|
return "";
|
|
@@ -1502,7 +1502,7 @@ function createHtmlLoader() {
|
|
|
1502
1502
|
break;
|
|
1503
1503
|
}
|
|
1504
1504
|
const siblings = Array.from(parent.childNodes).filter(
|
|
1505
|
-
(n) => n.nodeType === 1 || n.nodeType === 3 && _optionalChain([n, 'access',
|
|
1505
|
+
(n) => n.nodeType === 1 || n.nodeType === 3 && _optionalChain([n, 'access', _54 => _54.textContent, 'optionalAccess', _55 => _55.trim, 'call', _56 => _56()])
|
|
1506
1506
|
);
|
|
1507
1507
|
const index = siblings.indexOf(current);
|
|
1508
1508
|
if (index !== -1) {
|
|
@@ -1537,11 +1537,11 @@ function createHtmlLoader() {
|
|
|
1537
1537
|
result[getPath(element, attr)] = value;
|
|
1538
1538
|
}
|
|
1539
1539
|
});
|
|
1540
|
-
Array.from(element.childNodes).filter((n) => n.nodeType === 1 || n.nodeType === 3 && _optionalChain([n, 'access',
|
|
1540
|
+
Array.from(element.childNodes).filter((n) => n.nodeType === 1 || n.nodeType === 3 && _optionalChain([n, 'access', _57 => _57.textContent, 'optionalAccess', _58 => _58.trim, 'call', _59 => _59()])).forEach(processNode);
|
|
1541
1541
|
}
|
|
1542
1542
|
};
|
|
1543
|
-
Array.from(document.head.childNodes).filter((n) => n.nodeType === 1 || n.nodeType === 3 && _optionalChain([n, 'access',
|
|
1544
|
-
Array.from(document.body.childNodes).filter((n) => n.nodeType === 1 || n.nodeType === 3 && _optionalChain([n, 'access',
|
|
1543
|
+
Array.from(document.head.childNodes).filter((n) => n.nodeType === 1 || n.nodeType === 3 && _optionalChain([n, 'access', _60 => _60.textContent, 'optionalAccess', _61 => _61.trim, 'call', _62 => _62()])).forEach(processNode);
|
|
1544
|
+
Array.from(document.body.childNodes).filter((n) => n.nodeType === 1 || n.nodeType === 3 && _optionalChain([n, 'access', _63 => _63.textContent, 'optionalAccess', _64 => _64.trim, 'call', _65 => _65()])).forEach(processNode);
|
|
1545
1545
|
return result;
|
|
1546
1546
|
},
|
|
1547
1547
|
async push(locale, data, originalInput) {
|
|
@@ -1554,16 +1554,16 @@ function createHtmlLoader() {
|
|
|
1554
1554
|
const bDepth = b.split("/").length;
|
|
1555
1555
|
return aDepth - bDepth;
|
|
1556
1556
|
});
|
|
1557
|
-
paths.forEach((
|
|
1558
|
-
const value = data[
|
|
1559
|
-
const [nodePath, attribute] =
|
|
1557
|
+
paths.forEach((path17) => {
|
|
1558
|
+
const value = data[path17];
|
|
1559
|
+
const [nodePath, attribute] = path17.split("#");
|
|
1560
1560
|
const [rootTag, ...indices] = nodePath.split("/");
|
|
1561
1561
|
let parent = rootTag === "head" ? document.head : document.body;
|
|
1562
1562
|
let current = parent;
|
|
1563
1563
|
for (let i = 0; i < indices.length; i++) {
|
|
1564
1564
|
const index = parseInt(indices[i]);
|
|
1565
1565
|
const siblings = Array.from(parent.childNodes).filter(
|
|
1566
|
-
(n) => n.nodeType === 1 || n.nodeType === 3 && _optionalChain([n, 'access',
|
|
1566
|
+
(n) => n.nodeType === 1 || n.nodeType === 3 && _optionalChain([n, 'access', _66 => _66.textContent, 'optionalAccess', _67 => _67.trim, 'call', _68 => _68()])
|
|
1567
1567
|
);
|
|
1568
1568
|
if (index >= siblings.length) {
|
|
1569
1569
|
if (i === indices.length - 1) {
|
|
@@ -1614,7 +1614,7 @@ function createMarkdownLoader() {
|
|
|
1614
1614
|
yaml: yamlEngine
|
|
1615
1615
|
}
|
|
1616
1616
|
});
|
|
1617
|
-
const sections = content.split(SECTION_REGEX).map((section) => _nullishCoalesce(_optionalChain([section, 'optionalAccess',
|
|
1617
|
+
const sections = content.split(SECTION_REGEX).map((section) => _nullishCoalesce(_optionalChain([section, 'optionalAccess', _69 => _69.trim, 'call', _70 => _70()]), () => ( ""))).filter(Boolean);
|
|
1618
1618
|
return {
|
|
1619
1619
|
...Object.fromEntries(
|
|
1620
1620
|
sections.map((section, index) => [`${MD_SECTION_PREFIX}${index}`, section]).filter(([, section]) => Boolean(section))
|
|
@@ -1626,7 +1626,7 @@ function createMarkdownLoader() {
|
|
|
1626
1626
|
const frontmatter = Object.fromEntries(
|
|
1627
1627
|
Object.entries(data).filter(([key]) => key.startsWith(FM_ATTR_PREFIX)).map(([key, value]) => [key.replace(FM_ATTR_PREFIX, ""), value])
|
|
1628
1628
|
);
|
|
1629
|
-
let content = Object.entries(data).filter(([key]) => key.startsWith(MD_SECTION_PREFIX)).sort(([a], [b]) => Number(a.split("-").pop()) - Number(b.split("-").pop())).map(([, value]) => _nullishCoalesce(_optionalChain([value, 'optionalAccess',
|
|
1629
|
+
let content = Object.entries(data).filter(([key]) => key.startsWith(MD_SECTION_PREFIX)).sort(([a], [b]) => Number(a.split("-").pop()) - Number(b.split("-").pop())).map(([, value]) => _nullishCoalesce(_optionalChain([value, 'optionalAccess', _71 => _71.trim, 'call', _72 => _72()]), () => ( ""))).filter(Boolean).join("\n\n");
|
|
1630
1630
|
if (Object.keys(frontmatter).length > 0) {
|
|
1631
1631
|
content = `
|
|
1632
1632
|
${content}`;
|
|
@@ -1659,7 +1659,7 @@ function createPropertiesLoader() {
|
|
|
1659
1659
|
return result;
|
|
1660
1660
|
},
|
|
1661
1661
|
async push(locale, payload) {
|
|
1662
|
-
const result = Object.entries(payload).filter(([
|
|
1662
|
+
const result = Object.entries(payload).filter(([_25, value]) => value != null).map(([key, value]) => `${key}=${value}`).join("\n");
|
|
1663
1663
|
return result;
|
|
1664
1664
|
}
|
|
1665
1665
|
});
|
|
@@ -1670,7 +1670,7 @@ function isSkippableLine(line) {
|
|
|
1670
1670
|
function parsePropertyLine(line) {
|
|
1671
1671
|
const [key, ...valueParts] = line.split("=");
|
|
1672
1672
|
return {
|
|
1673
|
-
key: _optionalChain([key, 'optionalAccess',
|
|
1673
|
+
key: _optionalChain([key, 'optionalAccess', _73 => _73.trim, 'call', _74 => _74()]) || "",
|
|
1674
1674
|
value: valueParts.join("=").trim()
|
|
1675
1675
|
};
|
|
1676
1676
|
}
|
|
@@ -1756,7 +1756,7 @@ function createXcodeXcstringsLoader(defaultLocale) {
|
|
|
1756
1756
|
if (rootTranslationEntity.shouldTranslate === false) {
|
|
1757
1757
|
continue;
|
|
1758
1758
|
}
|
|
1759
|
-
const langTranslationEntity = _optionalChain([rootTranslationEntity, 'optionalAccess',
|
|
1759
|
+
const langTranslationEntity = _optionalChain([rootTranslationEntity, 'optionalAccess', _75 => _75.localizations, 'optionalAccess', _76 => _76[locale]]);
|
|
1760
1760
|
if (langTranslationEntity) {
|
|
1761
1761
|
if ("stringUnit" in langTranslationEntity) {
|
|
1762
1762
|
resultData[translationKey] = langTranslationEntity.stringUnit.value;
|
|
@@ -1765,7 +1765,7 @@ function createXcodeXcstringsLoader(defaultLocale) {
|
|
|
1765
1765
|
resultData[translationKey] = {};
|
|
1766
1766
|
const pluralForms = langTranslationEntity.variations.plural;
|
|
1767
1767
|
for (const form in pluralForms) {
|
|
1768
|
-
if (_optionalChain([pluralForms, 'access',
|
|
1768
|
+
if (_optionalChain([pluralForms, 'access', _77 => _77[form], 'optionalAccess', _78 => _78.stringUnit, 'optionalAccess', _79 => _79.value])) {
|
|
1769
1769
|
resultData[translationKey][form] = pluralForms[form].stringUnit.value;
|
|
1770
1770
|
}
|
|
1771
1771
|
}
|
|
@@ -1788,7 +1788,7 @@ function createXcodeXcstringsLoader(defaultLocale) {
|
|
|
1788
1788
|
const hasDoNotTranslateFlag = originalInput && originalInput.strings && originalInput.strings[key] && originalInput.strings[key].shouldTranslate === false;
|
|
1789
1789
|
if (typeof value === "string") {
|
|
1790
1790
|
langDataToMerge.strings[key] = {
|
|
1791
|
-
extractionState: _optionalChain([originalInput, 'optionalAccess',
|
|
1791
|
+
extractionState: _optionalChain([originalInput, 'optionalAccess', _80 => _80.strings, 'optionalAccess', _81 => _81[key], 'optionalAccess', _82 => _82.extractionState]),
|
|
1792
1792
|
localizations: {
|
|
1793
1793
|
[locale]: {
|
|
1794
1794
|
stringUnit: {
|
|
@@ -1836,21 +1836,28 @@ function createXcodeXcstringsLoader(defaultLocale) {
|
|
|
1836
1836
|
|
|
1837
1837
|
var _prettier = require('prettier'); var _prettier2 = _interopRequireDefault(_prettier);
|
|
1838
1838
|
function createPrettierLoader(options) {
|
|
1839
|
+
const stage = options.stage || "both";
|
|
1839
1840
|
return createLoader({
|
|
1840
1841
|
async pull(locale, data) {
|
|
1842
|
+
if (!["pull", "both"].includes(stage)) {
|
|
1843
|
+
return data;
|
|
1844
|
+
}
|
|
1841
1845
|
const draftPath = options.bucketPathPattern.replaceAll(
|
|
1842
1846
|
"[locale]",
|
|
1843
1847
|
locale
|
|
1844
1848
|
);
|
|
1845
|
-
const finalPath =
|
|
1849
|
+
const finalPath = path14.default.resolve(draftPath);
|
|
1846
1850
|
return await formatDataWithPrettier(data, finalPath, options);
|
|
1847
1851
|
},
|
|
1848
1852
|
async push(locale, data) {
|
|
1853
|
+
if (!["push", "both"].includes(stage)) {
|
|
1854
|
+
return data;
|
|
1855
|
+
}
|
|
1849
1856
|
const draftPath = options.bucketPathPattern.replaceAll(
|
|
1850
1857
|
"[locale]",
|
|
1851
1858
|
locale
|
|
1852
1859
|
);
|
|
1853
|
-
const finalPath =
|
|
1860
|
+
const finalPath = path14.default.resolve(draftPath);
|
|
1854
1861
|
return await formatDataWithPrettier(data, finalPath, options);
|
|
1855
1862
|
}
|
|
1856
1863
|
});
|
|
@@ -1919,10 +1926,10 @@ function createUnlocalizableLoader(isCacheRestore = false, returnUnlocalizedKeys
|
|
|
1919
1926
|
}
|
|
1920
1927
|
}
|
|
1921
1928
|
return false;
|
|
1922
|
-
}).map(([key,
|
|
1923
|
-
const result = _lodash2.default.omitBy(input2, (
|
|
1929
|
+
}).map(([key, _25]) => key);
|
|
1930
|
+
const result = _lodash2.default.omitBy(input2, (_25, key) => passthroughKeys.includes(key));
|
|
1924
1931
|
if (returnUnlocalizedKeys) {
|
|
1925
|
-
result.unlocalizable = _lodash2.default.omitBy(input2, (
|
|
1932
|
+
result.unlocalizable = _lodash2.default.omitBy(input2, (_25, key) => !passthroughKeys.includes(key));
|
|
1926
1933
|
}
|
|
1927
1934
|
return result;
|
|
1928
1935
|
},
|
|
@@ -1961,7 +1968,7 @@ function createPoDataLoader(params) {
|
|
|
1961
1968
|
Object.entries(entries).forEach(([msgid, entry]) => {
|
|
1962
1969
|
if (msgid && entry.msgid) {
|
|
1963
1970
|
const context = entry.msgctxt || "";
|
|
1964
|
-
const fullEntry = _optionalChain([parsedPo, 'access',
|
|
1971
|
+
const fullEntry = _optionalChain([parsedPo, 'access', _83 => _83.translations, 'access', _84 => _84[context], 'optionalAccess', _85 => _85[msgid]]);
|
|
1965
1972
|
if (fullEntry) {
|
|
1966
1973
|
result[msgid] = fullEntry;
|
|
1967
1974
|
}
|
|
@@ -1971,8 +1978,8 @@ function createPoDataLoader(params) {
|
|
|
1971
1978
|
return result;
|
|
1972
1979
|
},
|
|
1973
1980
|
async push(locale, data, originalInput, originalLocale, pullInput) {
|
|
1974
|
-
const currentSections = _optionalChain([pullInput, 'optionalAccess',
|
|
1975
|
-
const originalSections = _optionalChain([originalInput, 'optionalAccess',
|
|
1981
|
+
const currentSections = _optionalChain([pullInput, 'optionalAccess', _86 => _86.split, 'call', _87 => _87("\n\n"), 'access', _88 => _88.filter, 'call', _89 => _89(Boolean)]) || [];
|
|
1982
|
+
const originalSections = _optionalChain([originalInput, 'optionalAccess', _90 => _90.split, 'call', _91 => _91("\n\n"), 'access', _92 => _92.filter, 'call', _93 => _93(Boolean)]) || [];
|
|
1976
1983
|
const result = originalSections.map((section) => {
|
|
1977
1984
|
const sectionPo = _gettextparser2.default.po.parse(section);
|
|
1978
1985
|
const contextKey = _lodash2.default.keys(sectionPo.translations)[0];
|
|
@@ -2026,7 +2033,7 @@ function createPoContentLoader() {
|
|
|
2026
2033
|
entry.msgid,
|
|
2027
2034
|
{
|
|
2028
2035
|
...entry,
|
|
2029
|
-
msgstr: [_optionalChain([data, 'access',
|
|
2036
|
+
msgstr: [_optionalChain([data, 'access', _94 => _94[entry.msgid], 'optionalAccess', _95 => _95.singular]), _optionalChain([data, 'access', _96 => _96[entry.msgid], 'optionalAccess', _97 => _97.plural]) || null].filter(Boolean)
|
|
2030
2037
|
}
|
|
2031
2038
|
]).fromPairs().value();
|
|
2032
2039
|
return result;
|
|
@@ -2092,10 +2099,10 @@ function createXmlLoader() {
|
|
|
2092
2099
|
// src/cli/loaders/srt.ts
|
|
2093
2100
|
var _srtparser2 = require('srt-parser-2'); var _srtparser22 = _interopRequireDefault(_srtparser2);
|
|
2094
2101
|
function createSrtLoader() {
|
|
2095
|
-
const
|
|
2102
|
+
const parser = new (0, _srtparser22.default)();
|
|
2096
2103
|
return createLoader({
|
|
2097
2104
|
async pull(locale, input2) {
|
|
2098
|
-
const parsed =
|
|
2105
|
+
const parsed = parser.fromSrt(input2) || [];
|
|
2099
2106
|
const result = {};
|
|
2100
2107
|
parsed.forEach((entry) => {
|
|
2101
2108
|
const key = `${entry.id}#${entry.startTime}-${entry.endTime}`;
|
|
@@ -2116,7 +2123,7 @@ function createSrtLoader() {
|
|
|
2116
2123
|
text
|
|
2117
2124
|
};
|
|
2118
2125
|
});
|
|
2119
|
-
const srtContent =
|
|
2126
|
+
const srtContent = parser.toSrt(output).trim().replace(/\r?\n/g, "\n");
|
|
2120
2127
|
return srtContent;
|
|
2121
2128
|
}
|
|
2122
2129
|
});
|
|
@@ -2272,7 +2279,7 @@ function createDatoClient(params) {
|
|
|
2272
2279
|
only_valid: "true",
|
|
2273
2280
|
ids: !records.length ? void 0 : records.join(",")
|
|
2274
2281
|
}
|
|
2275
|
-
}).catch((error) => Promise.reject(_optionalChain([error, 'optionalAccess',
|
|
2282
|
+
}).catch((error) => Promise.reject(_optionalChain([error, 'optionalAccess', _98 => _98.response, 'optionalAccess', _99 => _99.body, 'optionalAccess', _100 => _100.data, 'optionalAccess', _101 => _101[0]]) || error));
|
|
2276
2283
|
},
|
|
2277
2284
|
findRecordsForModel: async (modelId, records) => {
|
|
2278
2285
|
try {
|
|
@@ -2282,9 +2289,9 @@ function createDatoClient(params) {
|
|
|
2282
2289
|
filter: {
|
|
2283
2290
|
type: modelId,
|
|
2284
2291
|
only_valid: "true",
|
|
2285
|
-
ids: !_optionalChain([records, 'optionalAccess',
|
|
2292
|
+
ids: !_optionalChain([records, 'optionalAccess', _102 => _102.length]) ? void 0 : records.join(",")
|
|
2286
2293
|
}
|
|
2287
|
-
}).catch((error) => Promise.reject(_optionalChain([error, 'optionalAccess',
|
|
2294
|
+
}).catch((error) => Promise.reject(_optionalChain([error, 'optionalAccess', _103 => _103.response, 'optionalAccess', _104 => _104.body, 'optionalAccess', _105 => _105.data, 'optionalAccess', _106 => _106[0]]) || error));
|
|
2288
2295
|
return result;
|
|
2289
2296
|
} catch (_error) {
|
|
2290
2297
|
throw new Error(
|
|
@@ -2298,9 +2305,9 @@ function createDatoClient(params) {
|
|
|
2298
2305
|
},
|
|
2299
2306
|
updateRecord: async (id, payload) => {
|
|
2300
2307
|
try {
|
|
2301
|
-
await dato.items.update(id, payload).catch((error) => Promise.reject(_optionalChain([error, 'optionalAccess',
|
|
2308
|
+
await dato.items.update(id, payload).catch((error) => Promise.reject(_optionalChain([error, 'optionalAccess', _107 => _107.response, 'optionalAccess', _108 => _108.body, 'optionalAccess', _109 => _109.data, 'optionalAccess', _110 => _110[0]]) || error));
|
|
2302
2309
|
} catch (_error) {
|
|
2303
|
-
if (_optionalChain([_error, 'optionalAccess',
|
|
2310
|
+
if (_optionalChain([_error, 'optionalAccess', _111 => _111.attributes, 'optionalAccess', _112 => _112.details, 'optionalAccess', _113 => _113.message])) {
|
|
2304
2311
|
throw new Error(
|
|
2305
2312
|
[
|
|
2306
2313
|
`${_error.attributes.details.message}`,
|
|
@@ -2321,9 +2328,9 @@ function createDatoClient(params) {
|
|
|
2321
2328
|
},
|
|
2322
2329
|
enableFieldLocalization: async (args) => {
|
|
2323
2330
|
try {
|
|
2324
|
-
await dato.fields.update(`${args.modelId}::${args.fieldId}`, { localized: true }).catch((error) => Promise.reject(_optionalChain([error, 'optionalAccess',
|
|
2331
|
+
await dato.fields.update(`${args.modelId}::${args.fieldId}`, { localized: true }).catch((error) => Promise.reject(_optionalChain([error, 'optionalAccess', _114 => _114.response, 'optionalAccess', _115 => _115.body, 'optionalAccess', _116 => _116.data, 'optionalAccess', _117 => _117[0]]) || error));
|
|
2325
2332
|
} catch (_error) {
|
|
2326
|
-
if (_optionalChain([_error, 'optionalAccess',
|
|
2333
|
+
if (_optionalChain([_error, 'optionalAccess', _118 => _118.attributes, 'optionalAccess', _119 => _119.code]) === "NOT_FOUND") {
|
|
2327
2334
|
throw new Error(
|
|
2328
2335
|
[
|
|
2329
2336
|
`Field "${args.fieldId}" not found in model "${args.modelId}".`,
|
|
@@ -2331,7 +2338,7 @@ function createDatoClient(params) {
|
|
|
2331
2338
|
].join("\n\n")
|
|
2332
2339
|
);
|
|
2333
2340
|
}
|
|
2334
|
-
if (_optionalChain([_error, 'optionalAccess',
|
|
2341
|
+
if (_optionalChain([_error, 'optionalAccess', _120 => _120.attributes, 'optionalAccess', _121 => _121.details, 'optionalAccess', _122 => _122.message])) {
|
|
2335
2342
|
throw new Error(
|
|
2336
2343
|
[`${_error.attributes.details.message}`, `Error: ${JSON.stringify(_error, null, 2)}`].join("\n\n")
|
|
2337
2344
|
);
|
|
@@ -2397,7 +2404,7 @@ function createDatoApiLoader(config, onConfigUpdate) {
|
|
|
2397
2404
|
}
|
|
2398
2405
|
}
|
|
2399
2406
|
const records = await dato.findRecordsForModel(modelId);
|
|
2400
|
-
const recordChoices = createRecordChoices(records, _optionalChain([config, 'access',
|
|
2407
|
+
const recordChoices = createRecordChoices(records, _optionalChain([config, 'access', _123 => _123.models, 'access', _124 => _124[modelId], 'optionalAccess', _125 => _125.records]) || [], project);
|
|
2401
2408
|
const selectedRecords = await promptRecordSelection(modelName, recordChoices);
|
|
2402
2409
|
result.models[modelId].records = records.filter((record) => selectedRecords.includes(record.id));
|
|
2403
2410
|
updatedConfig.models[modelId].records = selectedRecords;
|
|
@@ -2409,14 +2416,14 @@ function createDatoApiLoader(config, onConfigUpdate) {
|
|
|
2409
2416
|
},
|
|
2410
2417
|
async pull(locale, input2, initCtx) {
|
|
2411
2418
|
const result = {};
|
|
2412
|
-
for (const modelId of _lodash2.default.keys(_optionalChain([initCtx, 'optionalAccess',
|
|
2413
|
-
let records = _optionalChain([initCtx, 'optionalAccess',
|
|
2419
|
+
for (const modelId of _lodash2.default.keys(_optionalChain([initCtx, 'optionalAccess', _126 => _126.models]) || {})) {
|
|
2420
|
+
let records = _optionalChain([initCtx, 'optionalAccess', _127 => _127.models, 'access', _128 => _128[modelId], 'access', _129 => _129.records]) || [];
|
|
2414
2421
|
const recordIds = records.map((record) => record.id);
|
|
2415
2422
|
records = await dato.findRecords(recordIds);
|
|
2416
2423
|
console.log(`Fetched ${records.length} records for model ${modelId}`);
|
|
2417
2424
|
if (records.length > 0) {
|
|
2418
2425
|
result[modelId] = {
|
|
2419
|
-
fields: _optionalChain([initCtx, 'optionalAccess',
|
|
2426
|
+
fields: _optionalChain([initCtx, 'optionalAccess', _130 => _130.models, 'optionalAccess', _131 => _131[modelId], 'optionalAccess', _132 => _132.fields]) || [],
|
|
2420
2427
|
records
|
|
2421
2428
|
};
|
|
2422
2429
|
}
|
|
@@ -2475,7 +2482,7 @@ function createRecordChoices(records, selectedIds = [], project) {
|
|
|
2475
2482
|
return records.map((record) => ({
|
|
2476
2483
|
name: `${record.id} - https://${project.internal_domain}/editor/item_types/${record.item_type.id}/items/${record.id}`,
|
|
2477
2484
|
value: record.id,
|
|
2478
|
-
checked: _optionalChain([selectedIds, 'optionalAccess',
|
|
2485
|
+
checked: _optionalChain([selectedIds, 'optionalAccess', _133 => _133.includes, 'call', _134 => _134(record.id)])
|
|
2479
2486
|
}));
|
|
2480
2487
|
}
|
|
2481
2488
|
async function promptRecordSelection(modelName, choices) {
|
|
@@ -2626,18 +2633,18 @@ function createRawDatoValue(parsedDatoValue, originalRawDatoValue, isClean = fal
|
|
|
2626
2633
|
}
|
|
2627
2634
|
function serializeStructuredText(rawStructuredText) {
|
|
2628
2635
|
return serializeStructuredTextNode(rawStructuredText);
|
|
2629
|
-
function serializeStructuredTextNode(node,
|
|
2636
|
+
function serializeStructuredTextNode(node, path17 = [], acc = {}) {
|
|
2630
2637
|
if ("document" in node) {
|
|
2631
|
-
return serializeStructuredTextNode(node.document, [...
|
|
2638
|
+
return serializeStructuredTextNode(node.document, [...path17, "document"], acc);
|
|
2632
2639
|
}
|
|
2633
2640
|
if (!_lodash2.default.isNil(node.value)) {
|
|
2634
|
-
acc[[...
|
|
2641
|
+
acc[[...path17, "value"].join(".")] = node.value;
|
|
2635
2642
|
} else if (_lodash2.default.get(node, "type") === "block") {
|
|
2636
|
-
acc[[...
|
|
2643
|
+
acc[[...path17, "item"].join(".")] = serializeBlock(node.item);
|
|
2637
2644
|
}
|
|
2638
2645
|
if (node.children) {
|
|
2639
2646
|
for (let i = 0; i < node.children.length; i++) {
|
|
2640
|
-
serializeStructuredTextNode(node.children[i], [...
|
|
2647
|
+
serializeStructuredTextNode(node.children[i], [...path17, i.toString()], acc);
|
|
2641
2648
|
}
|
|
2642
2649
|
}
|
|
2643
2650
|
return acc;
|
|
@@ -2696,8 +2703,8 @@ function deserializeBlockList(parsedBlockList, originalRawBlockList, isClean = f
|
|
|
2696
2703
|
}
|
|
2697
2704
|
function deserializeStructuredText(parsedStructuredText, originalRawStructuredText) {
|
|
2698
2705
|
const result = _lodash2.default.cloneDeep(originalRawStructuredText);
|
|
2699
|
-
for (const [
|
|
2700
|
-
const realPath = _lodash2.default.chain(
|
|
2706
|
+
for (const [path17, value] of _lodash2.default.entries(parsedStructuredText)) {
|
|
2707
|
+
const realPath = _lodash2.default.chain(path17.split(".")).flatMap((s) => !_lodash2.default.isNaN(_lodash2.default.toNumber(s)) ? ["children", s] : s).value();
|
|
2701
2708
|
const deserializedValue = createRawDatoValue(value, _lodash2.default.get(originalRawStructuredText, realPath), true);
|
|
2702
2709
|
_lodash2.default.set(result, realPath, deserializedValue);
|
|
2703
2710
|
}
|
|
@@ -2722,12 +2729,12 @@ function _isVideo(rawDatoValue) {
|
|
|
2722
2729
|
// src/cli/loaders/dato/index.ts
|
|
2723
2730
|
function createDatoLoader(configFilePath) {
|
|
2724
2731
|
try {
|
|
2725
|
-
const configContent =
|
|
2732
|
+
const configContent = fs10.default.readFileSync(configFilePath, "utf-8");
|
|
2726
2733
|
const datoConfig = datoConfigSchema.parse(_json52.default.parse(configContent));
|
|
2727
2734
|
return composeLoaders(
|
|
2728
2735
|
createDatoApiLoader(
|
|
2729
2736
|
datoConfig,
|
|
2730
|
-
(updatedConfig) =>
|
|
2737
|
+
(updatedConfig) => fs10.default.writeFileSync(configFilePath, _json52.default.stringify(updatedConfig, null, 2))
|
|
2731
2738
|
),
|
|
2732
2739
|
createDatoFilterLoader(),
|
|
2733
2740
|
createDatoExtractLoader()
|
|
@@ -2742,7 +2749,7 @@ var _nodewebvtt = require('node-webvtt'); var _nodewebvtt2 = _interopRequireDefa
|
|
|
2742
2749
|
function createVttLoader() {
|
|
2743
2750
|
return createLoader({
|
|
2744
2751
|
async pull(locale, input2) {
|
|
2745
|
-
const vtt = _optionalChain([_nodewebvtt2.default, 'access',
|
|
2752
|
+
const vtt = _optionalChain([_nodewebvtt2.default, 'access', _135 => _135.parse, 'call', _136 => _136(input2), 'optionalAccess', _137 => _137.cues]);
|
|
2746
2753
|
if (Object.keys(vtt).length === 0) {
|
|
2747
2754
|
return {};
|
|
2748
2755
|
} else {
|
|
@@ -2795,7 +2802,7 @@ function variableExtractLoader(params) {
|
|
|
2795
2802
|
for (let i = 0; i < matches.length; i++) {
|
|
2796
2803
|
const match = matches[i];
|
|
2797
2804
|
const currentValue = result[key].value;
|
|
2798
|
-
const newValue = _optionalChain([currentValue, 'optionalAccess',
|
|
2805
|
+
const newValue = _optionalChain([currentValue, 'optionalAccess', _138 => _138.replace, 'call', _139 => _139(match, `{variable:${i}}`)]);
|
|
2799
2806
|
result[key].value = newValue;
|
|
2800
2807
|
result[key].variables[i] = match;
|
|
2801
2808
|
}
|
|
@@ -2809,7 +2816,7 @@ function variableExtractLoader(params) {
|
|
|
2809
2816
|
for (let i = 0; i < valueObj.variables.length; i++) {
|
|
2810
2817
|
const variable = valueObj.variables[i];
|
|
2811
2818
|
const currentValue = result[key];
|
|
2812
|
-
const newValue = _optionalChain([currentValue, 'optionalAccess',
|
|
2819
|
+
const newValue = _optionalChain([currentValue, 'optionalAccess', _140 => _140.replace, 'call', _141 => _141(`{variable:${i}}`, variable)]);
|
|
2813
2820
|
result[key] = newValue;
|
|
2814
2821
|
}
|
|
2815
2822
|
}
|
|
@@ -2990,7 +2997,7 @@ function createVueJsonLoader() {
|
|
|
2990
2997
|
return createLoader({
|
|
2991
2998
|
pull: async (locale, input2, ctx) => {
|
|
2992
2999
|
const parsed = parseVueFile(input2);
|
|
2993
|
-
return _nullishCoalesce(_optionalChain([parsed, 'optionalAccess',
|
|
3000
|
+
return _nullishCoalesce(_optionalChain([parsed, 'optionalAccess', _142 => _142.i18n, 'optionalAccess', _143 => _143[locale]]), () => ( {}));
|
|
2994
3001
|
},
|
|
2995
3002
|
push: async (locale, data, originalInput) => {
|
|
2996
3003
|
const parsed = parseVueFile(_nullishCoalesce(originalInput, () => ( "")));
|
|
@@ -3084,16 +3091,6 @@ function createMdxFrontmatterSplitLoader() {
|
|
|
3084
3091
|
});
|
|
3085
3092
|
}
|
|
3086
3093
|
|
|
3087
|
-
// src/cli/loaders/mdx2/_utils.ts
|
|
3088
|
-
function traverseMdast(ast, visitor) {
|
|
3089
|
-
visitor(ast);
|
|
3090
|
-
if ("children" in ast && Array.isArray(ast.children)) {
|
|
3091
|
-
for (const child of ast.children) {
|
|
3092
|
-
traverseMdast(child, visitor);
|
|
3093
|
-
}
|
|
3094
|
-
}
|
|
3095
|
-
}
|
|
3096
|
-
|
|
3097
3094
|
// src/cli/utils/md5.ts
|
|
3098
3095
|
var _objecthash = require('object-hash');
|
|
3099
3096
|
function md5(input2) {
|
|
@@ -3106,36 +3103,18 @@ var _remarkparse = require('remark-parse'); var _remarkparse2 = _interopRequireD
|
|
|
3106
3103
|
var _remarkgfm = require('remark-gfm'); var _remarkgfm2 = _interopRequireDefault(_remarkgfm);
|
|
3107
3104
|
var _vfile = require('vfile');
|
|
3108
3105
|
var _remarkmdx = require('remark-mdx'); var _remarkmdx2 = _interopRequireDefault(_remarkmdx);
|
|
3109
|
-
function parseMdast(content) {
|
|
3110
|
-
const file = new (0, _vfile.VFile)(content);
|
|
3111
|
-
const parser2 = _unified.unified.call(void 0, ).use(_remarkparse2.default).use(_remarkgfm2.default).use(_remarkmdx2.default);
|
|
3112
|
-
const result = parser2.parse(file);
|
|
3113
|
-
return result;
|
|
3114
|
-
}
|
|
3115
3106
|
function extractCodePlaceholders(content) {
|
|
3116
|
-
const ast = parseMdast(content);
|
|
3117
|
-
const placeholderableElements = [
|
|
3118
|
-
"code",
|
|
3119
|
-
"inlineCode"
|
|
3120
|
-
];
|
|
3121
3107
|
let finalContent = content;
|
|
3122
3108
|
const codePlaceholders = {};
|
|
3123
|
-
|
|
3124
|
-
|
|
3125
|
-
|
|
3126
|
-
|
|
3127
|
-
const
|
|
3128
|
-
const
|
|
3129
|
-
|
|
3130
|
-
|
|
3131
|
-
|
|
3132
|
-
const nodeContentEnd = _optionalChain([node, 'access', _146 => _146.position, 'optionalAccess', _147 => _147.end, 'access', _148 => _148.offset]);
|
|
3133
|
-
if (!nodeContentStart || !nodeContentEnd) {
|
|
3134
|
-
return;
|
|
3135
|
-
}
|
|
3136
|
-
codePlaceholders[placeholderId] = nodeContent;
|
|
3137
|
-
finalContent = finalContent.split(nodeContent).join(placeholderId);
|
|
3138
|
-
});
|
|
3109
|
+
const codeBlockRegex = /^```.*\n([\s\S]*?)^```$/gm;
|
|
3110
|
+
const codeBlockMatches = finalContent.matchAll(codeBlockRegex);
|
|
3111
|
+
for (const match of codeBlockMatches) {
|
|
3112
|
+
const codeBlock = match[0];
|
|
3113
|
+
const codeBlockHash = md5(codeBlock);
|
|
3114
|
+
const placeholderId = `---CODE_PLACEHOLDER_${codeBlockHash}---`;
|
|
3115
|
+
codePlaceholders[placeholderId] = codeBlock;
|
|
3116
|
+
finalContent = finalContent.replace(codeBlock, placeholderId);
|
|
3117
|
+
}
|
|
3139
3118
|
return {
|
|
3140
3119
|
content: finalContent,
|
|
3141
3120
|
codePlaceholders
|
|
@@ -3144,314 +3123,22 @@ function extractCodePlaceholders(content) {
|
|
|
3144
3123
|
function createMdxCodePlaceholderLoader() {
|
|
3145
3124
|
return createLoader({
|
|
3146
3125
|
async pull(locale, input2) {
|
|
3147
|
-
const
|
|
3148
|
-
|
|
3149
|
-
content: ""
|
|
3150
|
-
};
|
|
3151
|
-
const { content: resultContent, codePlaceholders } = extractCodePlaceholders(content);
|
|
3152
|
-
return {
|
|
3153
|
-
frontmatter,
|
|
3154
|
-
content: resultContent,
|
|
3155
|
-
codePlaceholders
|
|
3156
|
-
};
|
|
3126
|
+
const response = extractCodePlaceholders(input2);
|
|
3127
|
+
return response.content;
|
|
3157
3128
|
},
|
|
3158
3129
|
async push(locale, data, originalInput) {
|
|
3159
|
-
const
|
|
3160
|
-
|
|
3161
|
-
|
|
3162
|
-
|
|
3163
|
-
|
|
3164
|
-
|
|
3130
|
+
const response = extractCodePlaceholders(_nullishCoalesce(originalInput, () => ( "")));
|
|
3131
|
+
let result = data;
|
|
3132
|
+
for (const [placeholder, original] of Object.entries(
|
|
3133
|
+
response.codePlaceholders
|
|
3134
|
+
)) {
|
|
3135
|
+
result = result.replaceAll(placeholder, original);
|
|
3165
3136
|
}
|
|
3166
|
-
const result = {
|
|
3167
|
-
frontmatter: data.frontmatter,
|
|
3168
|
-
content: finalContent
|
|
3169
|
-
};
|
|
3170
3137
|
return result;
|
|
3171
3138
|
}
|
|
3172
3139
|
});
|
|
3173
3140
|
}
|
|
3174
3141
|
|
|
3175
|
-
// src/cli/loaders/mdx2/section-split.ts
|
|
3176
|
-
|
|
3177
|
-
|
|
3178
|
-
|
|
3179
|
-
|
|
3180
|
-
|
|
3181
|
-
var parser = _unified.unified.call(void 0, ).use(_remarkparse2.default).use(_remarkgfm2.default).use(_remarkmdx2.default);
|
|
3182
|
-
var SPACING_MATRIX = [
|
|
3183
|
-
// HEADING as previous type
|
|
3184
|
-
["\n\n", "\n\n", "\n\n", "\n\n", "\n\n", "\n\n"],
|
|
3185
|
-
// JSX_OPENING_TAG as previous type
|
|
3186
|
-
["\n\n", "\n", "\n", "\n", "\n", "\n\n"],
|
|
3187
|
-
// JSX_CLOSING_TAG as previous type
|
|
3188
|
-
["\n\n", "\n", "\n", "\n", "\n\n", "\n\n"],
|
|
3189
|
-
// JSX_SELF_CLOSING_TAG as previous type
|
|
3190
|
-
["\n\n", "\n", "\n", "\n", "\n", "\n\n"],
|
|
3191
|
-
// CONTENT as previous type
|
|
3192
|
-
["\n\n", "\n\n", "\n", "\n\n", "\n\n", "\n\n"],
|
|
3193
|
-
// UNKNOWN as previous type
|
|
3194
|
-
["\n\n", "\n\n", "\n\n", "\n\n", "\n\n", "\n\n"]
|
|
3195
|
-
];
|
|
3196
|
-
function createMdxSectionSplitLoader() {
|
|
3197
|
-
return createLoader({
|
|
3198
|
-
async pull(_locale, input2) {
|
|
3199
|
-
const {
|
|
3200
|
-
frontmatter = {},
|
|
3201
|
-
content = "",
|
|
3202
|
-
codePlaceholders = {}
|
|
3203
|
-
} = input2 || {
|
|
3204
|
-
frontmatter: {},
|
|
3205
|
-
content: "",
|
|
3206
|
-
codePlaceholders: {}
|
|
3207
|
-
};
|
|
3208
|
-
if (!content.trim()) {
|
|
3209
|
-
return {
|
|
3210
|
-
frontmatter,
|
|
3211
|
-
sections: {}
|
|
3212
|
-
};
|
|
3213
|
-
}
|
|
3214
|
-
const file = new (0, _vfile.VFile)(content);
|
|
3215
|
-
const ast = parser.parse(file);
|
|
3216
|
-
const boundaries = findSectionBoundaries(ast, content);
|
|
3217
|
-
const sections = createSectionsFromBoundaries(boundaries, content);
|
|
3218
|
-
return {
|
|
3219
|
-
frontmatter,
|
|
3220
|
-
sections
|
|
3221
|
-
};
|
|
3222
|
-
},
|
|
3223
|
-
async push(_locale, data, originalInput, _originalLocale) {
|
|
3224
|
-
const sectionsArray = Object.values(data.sections);
|
|
3225
|
-
if (sectionsArray.length === 0) {
|
|
3226
|
-
return {
|
|
3227
|
-
frontmatter: data.frontmatter,
|
|
3228
|
-
content: "",
|
|
3229
|
-
codePlaceholders: _nullishCoalesce(_optionalChain([originalInput, 'optionalAccess', _150 => _150.codePlaceholders]), () => ( {}))
|
|
3230
|
-
};
|
|
3231
|
-
}
|
|
3232
|
-
const resultParts = new Array(sectionsArray.length * 2 - 1);
|
|
3233
|
-
const sectionTypes = new Array(sectionsArray.length);
|
|
3234
|
-
for (let i = 0; i < sectionsArray.length; i++) {
|
|
3235
|
-
sectionTypes[i] = determineJsxSectionType(sectionsArray[i]);
|
|
3236
|
-
}
|
|
3237
|
-
resultParts[0] = sectionsArray[0];
|
|
3238
|
-
for (let i = 1, j = 1; i < sectionsArray.length; i++, j += 2) {
|
|
3239
|
-
const prevType = sectionTypes[i - 1];
|
|
3240
|
-
const currentType = sectionTypes[i];
|
|
3241
|
-
resultParts[j] = SPACING_MATRIX[prevType][currentType];
|
|
3242
|
-
resultParts[j + 1] = sectionsArray[i];
|
|
3243
|
-
}
|
|
3244
|
-
const content = resultParts.join("");
|
|
3245
|
-
return {
|
|
3246
|
-
frontmatter: data.frontmatter,
|
|
3247
|
-
content,
|
|
3248
|
-
codePlaceholders: _nullishCoalesce(_optionalChain([originalInput, 'optionalAccess', _151 => _151.codePlaceholders]), () => ( {}))
|
|
3249
|
-
};
|
|
3250
|
-
}
|
|
3251
|
-
});
|
|
3252
|
-
}
|
|
3253
|
-
function determineJsxSectionType(section) {
|
|
3254
|
-
section = section.trim();
|
|
3255
|
-
if (!section) return 5 /* UNKNOWN */;
|
|
3256
|
-
const firstChar = section.charAt(0);
|
|
3257
|
-
const lastChar = section.charAt(section.length - 1);
|
|
3258
|
-
if (firstChar === "#") {
|
|
3259
|
-
if (/^#{1,6}\s/.test(section)) {
|
|
3260
|
-
return 0 /* HEADING */;
|
|
3261
|
-
}
|
|
3262
|
-
}
|
|
3263
|
-
if (firstChar === "<") {
|
|
3264
|
-
if (section.endsWith("/>")) {
|
|
3265
|
-
return 3 /* JSX_SELF_CLOSING_TAG */;
|
|
3266
|
-
}
|
|
3267
|
-
if (section.startsWith("</")) {
|
|
3268
|
-
return 2 /* JSX_CLOSING_TAG */;
|
|
3269
|
-
}
|
|
3270
|
-
if (lastChar === ">") {
|
|
3271
|
-
return 1 /* JSX_OPENING_TAG */;
|
|
3272
|
-
}
|
|
3273
|
-
}
|
|
3274
|
-
return 4 /* CONTENT */;
|
|
3275
|
-
}
|
|
3276
|
-
function isJsxOrHtml(node) {
|
|
3277
|
-
return node.type === "mdxJsxFlowElement" || node.type === "mdxJsxTextElement" || node.type === "html";
|
|
3278
|
-
}
|
|
3279
|
-
function findOpeningTagEnd(text) {
|
|
3280
|
-
let depth = 0;
|
|
3281
|
-
let inQuotes = false;
|
|
3282
|
-
let quoteChar = "";
|
|
3283
|
-
for (let i = 0; i < text.length; i++) {
|
|
3284
|
-
const char = text[i];
|
|
3285
|
-
if ((char === '"' || char === "'") && (i === 0 || text[i - 1] !== "\\")) {
|
|
3286
|
-
if (!inQuotes) {
|
|
3287
|
-
inQuotes = true;
|
|
3288
|
-
quoteChar = char;
|
|
3289
|
-
} else if (char === quoteChar) {
|
|
3290
|
-
inQuotes = false;
|
|
3291
|
-
}
|
|
3292
|
-
}
|
|
3293
|
-
if (!inQuotes) {
|
|
3294
|
-
if (char === "<") depth++;
|
|
3295
|
-
if (char === ">") {
|
|
3296
|
-
depth--;
|
|
3297
|
-
if (depth === 0) return i + 1;
|
|
3298
|
-
}
|
|
3299
|
-
}
|
|
3300
|
-
}
|
|
3301
|
-
return -1;
|
|
3302
|
-
}
|
|
3303
|
-
function findClosingTagStart(text) {
|
|
3304
|
-
const openTagMatch = /<([^\s/>]+)/.exec(text);
|
|
3305
|
-
if (!openTagMatch) return -1;
|
|
3306
|
-
const tagName = openTagMatch[1];
|
|
3307
|
-
const closingTagRegex = new RegExp(`</${tagName}\\s*>`, "g");
|
|
3308
|
-
let lastMatch = null;
|
|
3309
|
-
let match;
|
|
3310
|
-
while ((match = closingTagRegex.exec(text)) !== null) {
|
|
3311
|
-
lastMatch = match;
|
|
3312
|
-
}
|
|
3313
|
-
return lastMatch ? lastMatch.index : -1;
|
|
3314
|
-
}
|
|
3315
|
-
function processJsxNode(node, content, boundaries) {
|
|
3316
|
-
if (!node.position || typeof node.position.start.offset !== "number" || typeof node.position.end.offset !== "number") {
|
|
3317
|
-
return;
|
|
3318
|
-
}
|
|
3319
|
-
const nodeStart = node.position.start.offset;
|
|
3320
|
-
const nodeEnd = node.position.end.offset;
|
|
3321
|
-
const nodeContent = content.slice(nodeStart, nodeEnd);
|
|
3322
|
-
if (node.type === "html") {
|
|
3323
|
-
extractHtmlTags(nodeStart, nodeContent, boundaries);
|
|
3324
|
-
return;
|
|
3325
|
-
}
|
|
3326
|
-
if (node.type === "mdxJsxFlowElement" || node.type === "mdxJsxTextElement") {
|
|
3327
|
-
const isSelfClosing = node.selfClosing === true;
|
|
3328
|
-
if (isSelfClosing) {
|
|
3329
|
-
boundaries.push({
|
|
3330
|
-
start: nodeStart,
|
|
3331
|
-
end: nodeEnd,
|
|
3332
|
-
isolateSelf: true
|
|
3333
|
-
});
|
|
3334
|
-
} else {
|
|
3335
|
-
extractJsxTags(node, nodeContent, boundaries);
|
|
3336
|
-
if (node.children) {
|
|
3337
|
-
for (const child of node.children) {
|
|
3338
|
-
if (isJsxOrHtml(child)) {
|
|
3339
|
-
processJsxNode(child, content, boundaries);
|
|
3340
|
-
}
|
|
3341
|
-
}
|
|
3342
|
-
}
|
|
3343
|
-
}
|
|
3344
|
-
}
|
|
3345
|
-
}
|
|
3346
|
-
function extractHtmlTags(nodeStart, nodeContent, boundaries) {
|
|
3347
|
-
const tagRegex = /<\/?[a-zA-Z][a-zA-Z0-9:._-]*(?:\s+[a-zA-Z:_][a-zA-Z0-9:._-]*(?:\s*=\s*(?:"[^"]*"|'[^']*'|[^'">\s]+))?)*\s*\/?>/g;
|
|
3348
|
-
let match;
|
|
3349
|
-
while ((match = tagRegex.exec(nodeContent)) !== null) {
|
|
3350
|
-
const tagStart = nodeStart + match.index;
|
|
3351
|
-
const tagEnd = tagStart + match[0].length;
|
|
3352
|
-
boundaries.push({
|
|
3353
|
-
start: tagStart,
|
|
3354
|
-
end: tagEnd,
|
|
3355
|
-
isolateSelf: true
|
|
3356
|
-
});
|
|
3357
|
-
}
|
|
3358
|
-
}
|
|
3359
|
-
function extractJsxTags(node, nodeContent, boundaries) {
|
|
3360
|
-
const nodeStart = node.position.start.offset;
|
|
3361
|
-
const nodeEnd = node.position.end.offset;
|
|
3362
|
-
if (!nodeStart || !nodeEnd) {
|
|
3363
|
-
return;
|
|
3364
|
-
}
|
|
3365
|
-
const openingTagEnd = findOpeningTagEnd(nodeContent);
|
|
3366
|
-
if (openingTagEnd > 0) {
|
|
3367
|
-
boundaries.push({
|
|
3368
|
-
start: nodeStart,
|
|
3369
|
-
end: nodeStart + openingTagEnd,
|
|
3370
|
-
isolateSelf: true
|
|
3371
|
-
});
|
|
3372
|
-
}
|
|
3373
|
-
const closingTagStart = findClosingTagStart(nodeContent);
|
|
3374
|
-
if (closingTagStart > 0 && closingTagStart < nodeContent.length) {
|
|
3375
|
-
boundaries.push({
|
|
3376
|
-
start: nodeStart + closingTagStart,
|
|
3377
|
-
end: nodeEnd,
|
|
3378
|
-
isolateSelf: true
|
|
3379
|
-
});
|
|
3380
|
-
}
|
|
3381
|
-
}
|
|
3382
|
-
function findSectionBoundaries(ast, content) {
|
|
3383
|
-
const boundaries = [];
|
|
3384
|
-
const nodePositions = /* @__PURE__ */ new Map();
|
|
3385
|
-
traverseMdast(ast, (node) => {
|
|
3386
|
-
if (node.position && typeof node.position.start.offset === "number" && typeof node.position.end.offset === "number") {
|
|
3387
|
-
nodePositions.set(node, {
|
|
3388
|
-
start: node.position.start.offset,
|
|
3389
|
-
end: node.position.end.offset
|
|
3390
|
-
});
|
|
3391
|
-
}
|
|
3392
|
-
});
|
|
3393
|
-
for (const child of ast.children) {
|
|
3394
|
-
const position = nodePositions.get(child);
|
|
3395
|
-
if (!position) continue;
|
|
3396
|
-
if (child.type === "heading") {
|
|
3397
|
-
boundaries.push({
|
|
3398
|
-
start: position.start,
|
|
3399
|
-
end: position.end,
|
|
3400
|
-
isolateSelf: false
|
|
3401
|
-
});
|
|
3402
|
-
} else if (isJsxOrHtml(child)) {
|
|
3403
|
-
processJsxNode(child, content, boundaries);
|
|
3404
|
-
}
|
|
3405
|
-
}
|
|
3406
|
-
return boundaries.sort((a, b) => a.start - b.start);
|
|
3407
|
-
}
|
|
3408
|
-
function createSectionsFromBoundaries(boundaries, content) {
|
|
3409
|
-
const sections = {};
|
|
3410
|
-
if (!content.trim() || boundaries.length === 0) {
|
|
3411
|
-
const trimmed = content.trim();
|
|
3412
|
-
if (trimmed) {
|
|
3413
|
-
sections["0"] = trimmed;
|
|
3414
|
-
}
|
|
3415
|
-
return sections;
|
|
3416
|
-
}
|
|
3417
|
-
let idx = 0;
|
|
3418
|
-
let lastEnd = 0;
|
|
3419
|
-
const sectionsArray = [];
|
|
3420
|
-
for (let i = 0; i < boundaries.length; i++) {
|
|
3421
|
-
const { start, end, isolateSelf } = boundaries[i];
|
|
3422
|
-
if (start > lastEnd) {
|
|
3423
|
-
const segment = content.slice(lastEnd, start).trim();
|
|
3424
|
-
if (segment) {
|
|
3425
|
-
sectionsArray.push(segment);
|
|
3426
|
-
}
|
|
3427
|
-
}
|
|
3428
|
-
if (isolateSelf) {
|
|
3429
|
-
const segment = content.slice(start, end).trim();
|
|
3430
|
-
if (segment) {
|
|
3431
|
-
sectionsArray.push(segment);
|
|
3432
|
-
}
|
|
3433
|
-
lastEnd = end;
|
|
3434
|
-
} else {
|
|
3435
|
-
const nextStart = i + 1 < boundaries.length ? boundaries[i + 1].start : content.length;
|
|
3436
|
-
const segment = content.slice(start, nextStart).trim();
|
|
3437
|
-
if (segment) {
|
|
3438
|
-
sectionsArray.push(segment);
|
|
3439
|
-
}
|
|
3440
|
-
lastEnd = nextStart;
|
|
3441
|
-
}
|
|
3442
|
-
}
|
|
3443
|
-
if (lastEnd < content.length) {
|
|
3444
|
-
const segment = content.slice(lastEnd).trim();
|
|
3445
|
-
if (segment) {
|
|
3446
|
-
sectionsArray.push(segment);
|
|
3447
|
-
}
|
|
3448
|
-
}
|
|
3449
|
-
sectionsArray.forEach((section, index) => {
|
|
3450
|
-
sections[index.toString()] = section;
|
|
3451
|
-
});
|
|
3452
|
-
return sections;
|
|
3453
|
-
}
|
|
3454
|
-
|
|
3455
3142
|
// src/cli/loaders/mdx2/localizable-document.ts
|
|
3456
3143
|
function createLocalizableMdxDocumentLoader() {
|
|
3457
3144
|
return createLoader({
|
|
@@ -3471,14 +3158,28 @@ function createLocalizableMdxDocumentLoader() {
|
|
|
3471
3158
|
});
|
|
3472
3159
|
}
|
|
3473
3160
|
|
|
3474
|
-
// src/cli/loaders/mdx2/
|
|
3475
|
-
|
|
3476
|
-
|
|
3477
|
-
|
|
3478
|
-
|
|
3479
|
-
|
|
3480
|
-
|
|
3481
|
-
|
|
3161
|
+
// src/cli/loaders/mdx2/sections-split-2.ts
|
|
3162
|
+
|
|
3163
|
+
function createMdxSectionsSplit2Loader() {
|
|
3164
|
+
return createLoader({
|
|
3165
|
+
async pull(locale, input2) {
|
|
3166
|
+
const sections = _lodash2.default.chain(input2.content).split("\n\n").filter(Boolean).map((section, index) => [index, section]).fromPairs().value();
|
|
3167
|
+
const result = {
|
|
3168
|
+
frontmatter: input2.frontmatter,
|
|
3169
|
+
sections
|
|
3170
|
+
};
|
|
3171
|
+
return result;
|
|
3172
|
+
},
|
|
3173
|
+
async push(locale, data, originalInput, _originalLocale, pullInput) {
|
|
3174
|
+
const content = _lodash2.default.chain(data.sections).values().join("\n\n").value();
|
|
3175
|
+
const result = {
|
|
3176
|
+
frontmatter: data.frontmatter,
|
|
3177
|
+
codePlaceholders: _optionalChain([pullInput, 'optionalAccess', _144 => _144.codePlaceholders]) || {},
|
|
3178
|
+
content
|
|
3179
|
+
};
|
|
3180
|
+
return result;
|
|
3181
|
+
}
|
|
3182
|
+
});
|
|
3482
3183
|
}
|
|
3483
3184
|
|
|
3484
3185
|
// src/cli/loaders/index.ts
|
|
@@ -3547,8 +3248,14 @@ function createBucketLoader(bucketType, bucketPathPattern, options, lockedKeys)
|
|
|
3547
3248
|
case "mdx":
|
|
3548
3249
|
return composeLoaders(
|
|
3549
3250
|
createTextFileLoader(bucketPathPattern),
|
|
3550
|
-
|
|
3551
|
-
|
|
3251
|
+
createMdxCodePlaceholderLoader(),
|
|
3252
|
+
createPrettierLoader({
|
|
3253
|
+
parser: "mdx",
|
|
3254
|
+
bucketPathPattern
|
|
3255
|
+
}),
|
|
3256
|
+
createMdxFrontmatterSplitLoader(),
|
|
3257
|
+
createMdxSectionsSplit2Loader(),
|
|
3258
|
+
createLocalizableMdxDocumentLoader(),
|
|
3552
3259
|
createFlatLoader(),
|
|
3553
3260
|
createSyncLoader(),
|
|
3554
3261
|
createUnlocalizableLoader(
|
|
@@ -3735,37 +3442,6 @@ var _diff = require('diff');
|
|
|
3735
3442
|
|
|
3736
3443
|
var _externaleditor = require('external-editor'); var _externaleditor2 = _interopRequireDefault(_externaleditor);
|
|
3737
3444
|
|
|
3738
|
-
// src/cli/utils/cache.ts
|
|
3739
|
-
|
|
3740
|
-
|
|
3741
|
-
var cacheChunk = (targetLocale, sourceChunk, processedChunk) => {
|
|
3742
|
-
const rows = Object.entries(sourceChunk).map(([key, source]) => ({
|
|
3743
|
-
targetLocale,
|
|
3744
|
-
key,
|
|
3745
|
-
source,
|
|
3746
|
-
processed: processedChunk[key]
|
|
3747
|
-
}));
|
|
3748
|
-
_appendToCache(rows);
|
|
3749
|
-
};
|
|
3750
|
-
function deleteCache() {
|
|
3751
|
-
const cacheFilePath = _getCacheFilePath();
|
|
3752
|
-
try {
|
|
3753
|
-
fs11.default.unlinkSync(cacheFilePath);
|
|
3754
|
-
} catch (e) {
|
|
3755
|
-
}
|
|
3756
|
-
}
|
|
3757
|
-
function _appendToCache(rows) {
|
|
3758
|
-
const cacheFilePath = _getCacheFilePath();
|
|
3759
|
-
const lines = _buildJSONLines(rows);
|
|
3760
|
-
fs11.default.appendFileSync(cacheFilePath, lines);
|
|
3761
|
-
}
|
|
3762
|
-
function _getCacheFilePath() {
|
|
3763
|
-
return path15.default.join(process.cwd(), "i18n.cache");
|
|
3764
|
-
}
|
|
3765
|
-
function _buildJSONLines(rows) {
|
|
3766
|
-
return rows.map((row) => JSON.stringify(row)).join("\n") + "\n";
|
|
3767
|
-
}
|
|
3768
|
-
|
|
3769
3445
|
// src/cli/processor/lingo.ts
|
|
3770
3446
|
var __sdk = require('@lingo.dev/_sdk');
|
|
3771
3447
|
function createLingoLocalizer(params) {
|
|
@@ -3844,7 +3520,7 @@ function createBasicTranslator(model, systemPrompt) {
|
|
|
3844
3520
|
]
|
|
3845
3521
|
});
|
|
3846
3522
|
const result = JSON.parse(response.text);
|
|
3847
|
-
return _optionalChain([result, 'optionalAccess',
|
|
3523
|
+
return _optionalChain([result, 'optionalAccess', _145 => _145.data]) || {};
|
|
3848
3524
|
};
|
|
3849
3525
|
}
|
|
3850
3526
|
|
|
@@ -3862,7 +3538,7 @@ function createProcessor(provider, params) {
|
|
|
3862
3538
|
}
|
|
3863
3539
|
}
|
|
3864
3540
|
function getPureModelProvider(provider) {
|
|
3865
|
-
switch (_optionalChain([provider, 'optionalAccess',
|
|
3541
|
+
switch (_optionalChain([provider, 'optionalAccess', _146 => _146.id])) {
|
|
3866
3542
|
case "openai":
|
|
3867
3543
|
if (!process.env.OPENAI_API_KEY) {
|
|
3868
3544
|
throw new Error("OPENAI_API_KEY is not set.");
|
|
@@ -3879,7 +3555,7 @@ function getPureModelProvider(provider) {
|
|
|
3879
3555
|
apiKey: process.env.ANTHROPIC_API_KEY
|
|
3880
3556
|
})(provider.model);
|
|
3881
3557
|
default:
|
|
3882
|
-
throw new Error(`Unsupported provider: ${_optionalChain([provider, 'optionalAccess',
|
|
3558
|
+
throw new Error(`Unsupported provider: ${_optionalChain([provider, 'optionalAccess', _147 => _147.id])}`);
|
|
3883
3559
|
}
|
|
3884
3560
|
}
|
|
3885
3561
|
|
|
@@ -3939,21 +3615,21 @@ async function trackEvent(distinctId, event, properties) {
|
|
|
3939
3615
|
|
|
3940
3616
|
function tryReadFile(filePath, defaultValue = null) {
|
|
3941
3617
|
try {
|
|
3942
|
-
const content =
|
|
3618
|
+
const content = fs10.readFileSync(filePath, "utf-8");
|
|
3943
3619
|
return content;
|
|
3944
3620
|
} catch (error) {
|
|
3945
3621
|
return defaultValue;
|
|
3946
3622
|
}
|
|
3947
3623
|
}
|
|
3948
3624
|
function writeFile(filePath, content) {
|
|
3949
|
-
const dir =
|
|
3950
|
-
if (!
|
|
3951
|
-
|
|
3625
|
+
const dir = path12.dirname(filePath);
|
|
3626
|
+
if (!fs10.existsSync(dir)) {
|
|
3627
|
+
fs10.mkdirSync(dir, { recursive: true });
|
|
3952
3628
|
}
|
|
3953
|
-
|
|
3629
|
+
fs10.writeFileSync(filePath, content);
|
|
3954
3630
|
}
|
|
3955
3631
|
function checkIfFileExists(filePath) {
|
|
3956
|
-
return
|
|
3632
|
+
return fs10.existsSync(filePath);
|
|
3957
3633
|
}
|
|
3958
3634
|
|
|
3959
3635
|
// src/cli/utils/delta.ts
|
|
@@ -3974,7 +3650,7 @@ var LockSchema = _zod2.default.object({
|
|
|
3974
3650
|
).default({})
|
|
3975
3651
|
});
|
|
3976
3652
|
function createDeltaProcessor(fileKey) {
|
|
3977
|
-
const lockfilePath =
|
|
3653
|
+
const lockfilePath = path13.join(process.cwd(), "i18n.lock");
|
|
3978
3654
|
return {
|
|
3979
3655
|
async checkIfLockExists() {
|
|
3980
3656
|
return checkIfFileExists(lockfilePath);
|
|
@@ -4106,16 +3782,16 @@ var i18n_default = new (0, _interactivecommander.Command)().command("i18n").desc
|
|
|
4106
3782
|
flags
|
|
4107
3783
|
});
|
|
4108
3784
|
let buckets = getBuckets(i18nConfig);
|
|
4109
|
-
if (_optionalChain([flags, 'access',
|
|
3785
|
+
if (_optionalChain([flags, 'access', _148 => _148.bucket, 'optionalAccess', _149 => _149.length])) {
|
|
4110
3786
|
buckets = buckets.filter(
|
|
4111
3787
|
(bucket) => flags.bucket.includes(bucket.type)
|
|
4112
3788
|
);
|
|
4113
3789
|
}
|
|
4114
3790
|
ora.succeed("Buckets retrieved");
|
|
4115
|
-
if (_optionalChain([flags, 'access',
|
|
3791
|
+
if (_optionalChain([flags, 'access', _150 => _150.file, 'optionalAccess', _151 => _151.length])) {
|
|
4116
3792
|
buckets = buckets.map((bucket) => {
|
|
4117
3793
|
const paths = bucket.paths.filter(
|
|
4118
|
-
(
|
|
3794
|
+
(path17) => flags.file.find((file) => _optionalChain([path17, 'access', _152 => _152.pathPattern, 'optionalAccess', _153 => _153.includes, 'call', _154 => _154(file)]))
|
|
4119
3795
|
);
|
|
4120
3796
|
return { ...bucket, paths };
|
|
4121
3797
|
}).filter((bucket) => bucket.paths.length > 0);
|
|
@@ -4128,13 +3804,13 @@ var i18n_default = new (0, _interactivecommander.Command)().command("i18n").desc
|
|
|
4128
3804
|
ora.info(`\x1B[36mProcessing only filtered buckets:\x1B[0m`);
|
|
4129
3805
|
buckets.map((bucket) => {
|
|
4130
3806
|
ora.info(` ${bucket.type}:`);
|
|
4131
|
-
bucket.paths.forEach((
|
|
4132
|
-
ora.info(` - ${
|
|
3807
|
+
bucket.paths.forEach((path17) => {
|
|
3808
|
+
ora.info(` - ${path17.pathPattern}`);
|
|
4133
3809
|
});
|
|
4134
3810
|
});
|
|
4135
3811
|
}
|
|
4136
3812
|
}
|
|
4137
|
-
const targetLocales = _optionalChain([flags, 'access',
|
|
3813
|
+
const targetLocales = _optionalChain([flags, 'access', _155 => _155.locale, 'optionalAccess', _156 => _156.length]) ? flags.locale : i18nConfig.locale.targets;
|
|
4138
3814
|
ora.start("Setting up localization cache...");
|
|
4139
3815
|
const checkLockfileProcessor = createDeltaProcessor("");
|
|
4140
3816
|
const lockfileExists = await checkLockfileProcessor.checkIfLockExists();
|
|
@@ -4181,7 +3857,7 @@ var i18n_default = new (0, _interactivecommander.Command)().command("i18n").desc
|
|
|
4181
3857
|
bucketPath.delimiter
|
|
4182
3858
|
);
|
|
4183
3859
|
const deltaProcessor = createDeltaProcessor(bucketPath.pathPattern);
|
|
4184
|
-
const sourcePath =
|
|
3860
|
+
const sourcePath = path14.join(
|
|
4185
3861
|
process.cwd(),
|
|
4186
3862
|
bucketPath.pathPattern.replace("[locale]", sourceLocale)
|
|
4187
3863
|
);
|
|
@@ -4198,7 +3874,7 @@ var i18n_default = new (0, _interactivecommander.Command)().command("i18n").desc
|
|
|
4198
3874
|
_targetLocale,
|
|
4199
3875
|
bucketPath.delimiter
|
|
4200
3876
|
);
|
|
4201
|
-
const targetPath =
|
|
3877
|
+
const targetPath = path14.join(
|
|
4202
3878
|
process.cwd(),
|
|
4203
3879
|
bucketPath.pathPattern.replace("[locale]", targetLocale)
|
|
4204
3880
|
);
|
|
@@ -4371,7 +4047,7 @@ var i18n_default = new (0, _interactivecommander.Command)().command("i18n").desc
|
|
|
4371
4047
|
if (flags.key) {
|
|
4372
4048
|
processableData = _lodash2.default.pickBy(
|
|
4373
4049
|
processableData,
|
|
4374
|
-
(
|
|
4050
|
+
(_25, key) => key === flags.key
|
|
4375
4051
|
);
|
|
4376
4052
|
}
|
|
4377
4053
|
if (flags.verbose) {
|
|
@@ -4398,7 +4074,6 @@ var i18n_default = new (0, _interactivecommander.Command)().command("i18n").desc
|
|
|
4398
4074
|
targetData
|
|
4399
4075
|
},
|
|
4400
4076
|
(progress, sourceChunk, processedChunk) => {
|
|
4401
|
-
cacheChunk(targetLocale, sourceChunk, processedChunk);
|
|
4402
4077
|
const progressLog = `[${sourceLocale} -> ${targetLocale}] [${Object.keys(processableData).length} entries] (${progress}%) AI localization in progress...`;
|
|
4403
4078
|
if (flags.verbose) {
|
|
4404
4079
|
bucketOra.info(progressLog);
|
|
@@ -4476,10 +4151,6 @@ var i18n_default = new (0, _interactivecommander.Command)().command("i18n").desc
|
|
|
4476
4151
|
console.log();
|
|
4477
4152
|
if (!hasErrors) {
|
|
4478
4153
|
ora.succeed("Localization completed.");
|
|
4479
|
-
deleteCache();
|
|
4480
|
-
if (flags.verbose) {
|
|
4481
|
-
ora.info("Cache file deleted.");
|
|
4482
|
-
}
|
|
4483
4154
|
trackEvent(auth.id, "cmd.i18n.success", {
|
|
4484
4155
|
i18nConfig,
|
|
4485
4156
|
flags
|
|
@@ -4542,12 +4213,12 @@ function validateParams(i18nConfig, flags) {
|
|
|
4542
4213
|
message: "No buckets found in i18n.json. Please add at least one bucket containing i18n content.",
|
|
4543
4214
|
docUrl: "bucketNotFound"
|
|
4544
4215
|
});
|
|
4545
|
-
} else if (_optionalChain([flags, 'access',
|
|
4216
|
+
} else if (_optionalChain([flags, 'access', _157 => _157.locale, 'optionalAccess', _158 => _158.some, 'call', _159 => _159((locale) => !i18nConfig.locale.targets.includes(locale))])) {
|
|
4546
4217
|
throw new CLIError({
|
|
4547
4218
|
message: `One or more specified locales do not exist in i18n.json locale.targets. Please add them to the list and try again.`,
|
|
4548
4219
|
docUrl: "localeTargetNotFound"
|
|
4549
4220
|
});
|
|
4550
|
-
} else if (_optionalChain([flags, 'access',
|
|
4221
|
+
} else if (_optionalChain([flags, 'access', _160 => _160.bucket, 'optionalAccess', _161 => _161.some, 'call', _162 => _162(
|
|
4551
4222
|
(bucket) => !i18nConfig.buckets[bucket]
|
|
4552
4223
|
)])) {
|
|
4553
4224
|
throw new CLIError({
|
|
@@ -4684,7 +4355,7 @@ function createLockfileHelper() {
|
|
|
4684
4355
|
return {
|
|
4685
4356
|
isLockfileExists: () => {
|
|
4686
4357
|
const lockfilePath = _getLockfilePath();
|
|
4687
|
-
return
|
|
4358
|
+
return fs10.default.existsSync(lockfilePath);
|
|
4688
4359
|
},
|
|
4689
4360
|
registerSourceData: (pathPattern, sourceData) => {
|
|
4690
4361
|
const lockfile = _loadLockfile();
|
|
@@ -4711,20 +4382,20 @@ function createLockfileHelper() {
|
|
|
4711
4382
|
};
|
|
4712
4383
|
function _loadLockfile() {
|
|
4713
4384
|
const lockfilePath = _getLockfilePath();
|
|
4714
|
-
if (!
|
|
4385
|
+
if (!fs10.default.existsSync(lockfilePath)) {
|
|
4715
4386
|
return LockfileSchema.parse({});
|
|
4716
4387
|
}
|
|
4717
|
-
const content =
|
|
4388
|
+
const content = fs10.default.readFileSync(lockfilePath, "utf-8");
|
|
4718
4389
|
const result = LockfileSchema.parse(_yaml2.default.parse(content));
|
|
4719
4390
|
return result;
|
|
4720
4391
|
}
|
|
4721
4392
|
function _saveLockfile(lockfile) {
|
|
4722
4393
|
const lockfilePath = _getLockfilePath();
|
|
4723
4394
|
const content = _yaml2.default.stringify(lockfile);
|
|
4724
|
-
|
|
4395
|
+
fs10.default.writeFileSync(lockfilePath, content);
|
|
4725
4396
|
}
|
|
4726
4397
|
function _getLockfilePath() {
|
|
4727
|
-
return
|
|
4398
|
+
return path14.default.join(process.cwd(), "i18n.lock");
|
|
4728
4399
|
}
|
|
4729
4400
|
}
|
|
4730
4401
|
var LockfileSchema = _zod2.default.object({
|
|
@@ -4875,7 +4546,7 @@ var _stdiojs = require('@modelcontextprotocol/sdk/server/stdio.js');
|
|
|
4875
4546
|
var _mcpjs = require('@modelcontextprotocol/sdk/server/mcp.js');
|
|
4876
4547
|
|
|
4877
4548
|
|
|
4878
|
-
var mcp_default = new (0, _interactivecommander.Command)().command("mcp").description("Use Lingo.dev model context provider with your AI agent").helpOption("-h, --help", "Show help").action(async (
|
|
4549
|
+
var mcp_default = new (0, _interactivecommander.Command)().command("mcp").description("Use Lingo.dev model context provider with your AI agent").helpOption("-h, --help", "Show help").action(async (_25, program) => {
|
|
4879
4550
|
const apiKey = program.args[0];
|
|
4880
4551
|
const settings = getSettings(apiKey);
|
|
4881
4552
|
if (!settings.auth.apiKey) {
|
|
@@ -4998,7 +4669,7 @@ var InBranchFlow = class extends IntegrationFlow {
|
|
|
4998
4669
|
_child_process.execSync.call(void 0, `git config --global safe.directory ${process.cwd()}`);
|
|
4999
4670
|
_child_process.execSync.call(void 0, `git config user.name "${gitConfig.userName}"`);
|
|
5000
4671
|
_child_process.execSync.call(void 0, `git config user.email "${gitConfig.userEmail}"`);
|
|
5001
|
-
_optionalChain([this, 'access',
|
|
4672
|
+
_optionalChain([this, 'access', _163 => _163.platformKit, 'optionalAccess', _164 => _164.gitConfig, 'call', _165 => _165()]);
|
|
5002
4673
|
_child_process.execSync.call(void 0, `git fetch origin ${baseBranchName}`, { stdio: "inherit" });
|
|
5003
4674
|
_child_process.execSync.call(void 0, `git checkout ${baseBranchName} --`, { stdio: "inherit" });
|
|
5004
4675
|
if (!processOwnCommits) {
|
|
@@ -5011,7 +4682,7 @@ var InBranchFlow = class extends IntegrationFlow {
|
|
|
5011
4682
|
return false;
|
|
5012
4683
|
}
|
|
5013
4684
|
}
|
|
5014
|
-
const workingDir =
|
|
4685
|
+
const workingDir = path14.default.resolve(process.cwd(), this.platformKit.config.workingDir);
|
|
5015
4686
|
if (workingDir !== process.cwd()) {
|
|
5016
4687
|
this.ora.info(`Changing to working directory: ${this.platformKit.config.workingDir}`);
|
|
5017
4688
|
process.chdir(workingDir);
|
|
@@ -5023,7 +4694,7 @@ var InBranchFlow = class extends IntegrationFlow {
|
|
|
5023
4694
|
// ../../action/src/flows/pull-request.ts
|
|
5024
4695
|
var PullRequestFlow = class extends InBranchFlow {
|
|
5025
4696
|
async preRun() {
|
|
5026
|
-
const canContinue = await _optionalChain([super.preRun.bind(this), 'optionalCall',
|
|
4697
|
+
const canContinue = await _optionalChain([super.preRun.bind(this), 'optionalCall', _166 => _166()]);
|
|
5027
4698
|
if (!canContinue) {
|
|
5028
4699
|
return false;
|
|
5029
4700
|
}
|
|
@@ -5241,10 +4912,10 @@ var BitbucketPlatformKit = class extends PlatformKit {
|
|
|
5241
4912
|
repo_slug: this.platformConfig.repositoryName,
|
|
5242
4913
|
state: "OPEN"
|
|
5243
4914
|
}).then(({ data: { values } }) => {
|
|
5244
|
-
return _optionalChain([values, 'optionalAccess',
|
|
5245
|
-
({ source, destination }) => _optionalChain([source, 'optionalAccess',
|
|
4915
|
+
return _optionalChain([values, 'optionalAccess', _167 => _167.find, 'call', _168 => _168(
|
|
4916
|
+
({ source, destination }) => _optionalChain([source, 'optionalAccess', _169 => _169.branch, 'optionalAccess', _170 => _170.name]) === branch && _optionalChain([destination, 'optionalAccess', _171 => _171.branch, 'optionalAccess', _172 => _172.name]) === this.platformConfig.baseBranchName
|
|
5246
4917
|
)]);
|
|
5247
|
-
}).then((pr) => _optionalChain([pr, 'optionalAccess',
|
|
4918
|
+
}).then((pr) => _optionalChain([pr, 'optionalAccess', _173 => _173.id]));
|
|
5248
4919
|
}
|
|
5249
4920
|
async closePullRequest({ pullRequestNumber }) {
|
|
5250
4921
|
await this.bb.repositories.declinePullRequest({
|
|
@@ -5330,7 +5001,7 @@ var GitHubPlatformKit = class extends PlatformKit {
|
|
|
5330
5001
|
repo: this.platformConfig.repositoryName,
|
|
5331
5002
|
base: this.platformConfig.baseBranchName,
|
|
5332
5003
|
state: "open"
|
|
5333
|
-
}).then(({ data }) => data[0]).then((pr) => _optionalChain([pr, 'optionalAccess',
|
|
5004
|
+
}).then(({ data }) => data[0]).then((pr) => _optionalChain([pr, 'optionalAccess', _174 => _174.number]));
|
|
5334
5005
|
}
|
|
5335
5006
|
async closePullRequest({ pullRequestNumber }) {
|
|
5336
5007
|
await this.octokit.rest.pulls.update({
|
|
@@ -5443,7 +5114,7 @@ var GitlabPlatformKit = class extends PlatformKit {
|
|
|
5443
5114
|
sourceBranch: branch,
|
|
5444
5115
|
state: "opened"
|
|
5445
5116
|
});
|
|
5446
|
-
return _optionalChain([mergeRequests, 'access',
|
|
5117
|
+
return _optionalChain([mergeRequests, 'access', _175 => _175[0], 'optionalAccess', _176 => _176.iid]);
|
|
5447
5118
|
}
|
|
5448
5119
|
async closePullRequest({ pullRequestNumber }) {
|
|
5449
5120
|
await this.gitlab.MergeRequests.edit(this.platformConfig.gitlabProjectId, pullRequestNumber, {
|
|
@@ -5496,7 +5167,7 @@ async function main() {
|
|
|
5496
5167
|
const { isPullRequestMode } = platformKit.config;
|
|
5497
5168
|
ora.info(`Pull request mode: ${isPullRequestMode ? "on" : "off"}`);
|
|
5498
5169
|
const flow = isPullRequestMode ? new PullRequestFlow(ora, platformKit) : new InBranchFlow(ora, platformKit);
|
|
5499
|
-
const canRun = await _optionalChain([flow, 'access',
|
|
5170
|
+
const canRun = await _optionalChain([flow, 'access', _177 => _177.preRun, 'optionalCall', _178 => _178()]);
|
|
5500
5171
|
if (canRun === false) {
|
|
5501
5172
|
return;
|
|
5502
5173
|
}
|
|
@@ -5504,7 +5175,7 @@ async function main() {
|
|
|
5504
5175
|
if (!hasChanges) {
|
|
5505
5176
|
return;
|
|
5506
5177
|
}
|
|
5507
|
-
await _optionalChain([flow, 'access',
|
|
5178
|
+
await _optionalChain([flow, 'access', _179 => _179.postRun, 'optionalCall', _180 => _180()]);
|
|
5508
5179
|
}
|
|
5509
5180
|
|
|
5510
5181
|
// src/cli/cmd/ci.ts
|
|
@@ -5526,7 +5197,7 @@ var ci_default = new (0, _interactivecommander.Command)().command("ci").descript
|
|
|
5526
5197
|
}
|
|
5527
5198
|
const env = {
|
|
5528
5199
|
LINGODOTDEV_API_KEY: settings.auth.apiKey,
|
|
5529
|
-
LINGODOTDEV_PULL_REQUEST: _optionalChain([options, 'access',
|
|
5200
|
+
LINGODOTDEV_PULL_REQUEST: _optionalChain([options, 'access', _181 => _181.pullRequest, 'optionalAccess', _182 => _182.toString, 'call', _183 => _183()]) || "false",
|
|
5530
5201
|
...options.commitMessage && { LINGODOTDEV_COMMIT_MESSAGE: options.commitMessage },
|
|
5531
5202
|
...options.pullRequestTitle && { LINGODOTDEV_PULL_REQUEST_TITLE: options.pullRequestTitle },
|
|
5532
5203
|
...options.workingDirectory && { LINGODOTDEV_WORKING_DIRECTORY: options.workingDirectory },
|
|
@@ -5577,13 +5248,13 @@ var status_default = new (0, _interactivecommander.Command)().command("status").
|
|
|
5577
5248
|
flags
|
|
5578
5249
|
});
|
|
5579
5250
|
let buckets = getBuckets(i18nConfig);
|
|
5580
|
-
if (_optionalChain([flags, 'access',
|
|
5251
|
+
if (_optionalChain([flags, 'access', _184 => _184.bucket, 'optionalAccess', _185 => _185.length])) {
|
|
5581
5252
|
buckets = buckets.filter((bucket) => flags.bucket.includes(bucket.type));
|
|
5582
5253
|
}
|
|
5583
5254
|
ora.succeed("Buckets retrieved");
|
|
5584
|
-
if (_optionalChain([flags, 'access',
|
|
5255
|
+
if (_optionalChain([flags, 'access', _186 => _186.file, 'optionalAccess', _187 => _187.length])) {
|
|
5585
5256
|
buckets = buckets.map((bucket) => {
|
|
5586
|
-
const paths = bucket.paths.filter((
|
|
5257
|
+
const paths = bucket.paths.filter((path17) => flags.file.find((file) => _optionalChain([path17, 'access', _188 => _188.pathPattern, 'optionalAccess', _189 => _189.match, 'call', _190 => _190(file)])));
|
|
5587
5258
|
return { ...bucket, paths };
|
|
5588
5259
|
}).filter((bucket) => bucket.paths.length > 0);
|
|
5589
5260
|
if (buckets.length === 0) {
|
|
@@ -5593,13 +5264,13 @@ var status_default = new (0, _interactivecommander.Command)().command("status").
|
|
|
5593
5264
|
ora.info(`\x1B[36mProcessing only filtered buckets:\x1B[0m`);
|
|
5594
5265
|
buckets.map((bucket) => {
|
|
5595
5266
|
ora.info(` ${bucket.type}:`);
|
|
5596
|
-
bucket.paths.forEach((
|
|
5597
|
-
ora.info(` - ${
|
|
5267
|
+
bucket.paths.forEach((path17) => {
|
|
5268
|
+
ora.info(` - ${path17.pathPattern}`);
|
|
5598
5269
|
});
|
|
5599
5270
|
});
|
|
5600
5271
|
}
|
|
5601
5272
|
}
|
|
5602
|
-
const targetLocales = _optionalChain([flags, 'access',
|
|
5273
|
+
const targetLocales = _optionalChain([flags, 'access', _191 => _191.locale, 'optionalAccess', _192 => _192.length]) ? flags.locale : i18nConfig.locale.targets;
|
|
5603
5274
|
let totalSourceKeyCount = 0;
|
|
5604
5275
|
let uniqueKeysToTranslate = 0;
|
|
5605
5276
|
let totalExistingTranslations = 0;
|
|
@@ -5823,10 +5494,10 @@ var status_default = new (0, _interactivecommander.Command)().command("status").
|
|
|
5823
5494
|
if (flags.confirm && Object.keys(fileStats).length > 0) {
|
|
5824
5495
|
console.log(_chalk2.default.bold(`
|
|
5825
5496
|
\u{1F4D1} BREAKDOWN BY FILE:`));
|
|
5826
|
-
Object.entries(fileStats).sort((a, b) => b[1].wordCount - a[1].wordCount).forEach(([
|
|
5497
|
+
Object.entries(fileStats).sort((a, b) => b[1].wordCount - a[1].wordCount).forEach(([path17, stats]) => {
|
|
5827
5498
|
if (stats.sourceKeys === 0) return;
|
|
5828
5499
|
console.log(_chalk2.default.bold(`
|
|
5829
|
-
\u2022 ${
|
|
5500
|
+
\u2022 ${path17}:`));
|
|
5830
5501
|
console.log(` ${stats.sourceKeys} source keys, ~${stats.wordCount.toLocaleString()} source words`);
|
|
5831
5502
|
const fileTable = new (0, _clitable32.default)({
|
|
5832
5503
|
head: ["Language", "Status", "Details"],
|
|
@@ -5940,12 +5611,12 @@ function validateParams2(i18nConfig, flags) {
|
|
|
5940
5611
|
message: "No buckets found in i18n.json. Please add at least one bucket containing i18n content.",
|
|
5941
5612
|
docUrl: "bucketNotFound"
|
|
5942
5613
|
});
|
|
5943
|
-
} else if (_optionalChain([flags, 'access',
|
|
5614
|
+
} else if (_optionalChain([flags, 'access', _193 => _193.locale, 'optionalAccess', _194 => _194.some, 'call', _195 => _195((locale) => !i18nConfig.locale.targets.includes(locale))])) {
|
|
5944
5615
|
throw new CLIError({
|
|
5945
5616
|
message: `One or more specified locales do not exist in i18n.json locale.targets. Please add them to the list and try again.`,
|
|
5946
5617
|
docUrl: "localeTargetNotFound"
|
|
5947
5618
|
});
|
|
5948
|
-
} else if (_optionalChain([flags, 'access',
|
|
5619
|
+
} else if (_optionalChain([flags, 'access', _196 => _196.bucket, 'optionalAccess', _197 => _197.some, 'call', _198 => _198((bucket) => !i18nConfig.buckets[bucket])])) {
|
|
5949
5620
|
throw new CLIError({
|
|
5950
5621
|
message: `One or more specified buckets do not exist in i18n.json. Please add them to the list and try again.`,
|
|
5951
5622
|
docUrl: "bucketNotFound"
|
|
@@ -5956,7 +5627,7 @@ function validateParams2(i18nConfig, flags) {
|
|
|
5956
5627
|
// package.json
|
|
5957
5628
|
var package_default = {
|
|
5958
5629
|
name: "lingo.dev",
|
|
5959
|
-
version: "0.87.
|
|
5630
|
+
version: "0.87.1",
|
|
5960
5631
|
description: "Lingo.dev CLI",
|
|
5961
5632
|
private: false,
|
|
5962
5633
|
publishConfig: {
|