gtx-cli 2.1.5-alpha.6 → 2.1.5-alpha.8
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/dist/cli/base.js
CHANGED
|
@@ -17,7 +17,6 @@ import { upload } from '../formats/files/upload.js';
|
|
|
17
17
|
import { attachTranslateFlags } from './flags.js';
|
|
18
18
|
import { handleStage } from './commands/stage.js';
|
|
19
19
|
import { handleDownload, handleTranslate, postProcessTranslations, } from './commands/translate.js';
|
|
20
|
-
import localizeStaticUrls from '../utils/localizeStaticUrls.js';
|
|
21
20
|
import updateConfig from '../fs/config/updateConfig.js';
|
|
22
21
|
export class BaseCLI {
|
|
23
22
|
library;
|
|
@@ -79,19 +78,11 @@ export class BaseCLI {
|
|
|
79
78
|
const settings = await generateSettings(initOptions);
|
|
80
79
|
if (!settings.stageTranslations) {
|
|
81
80
|
const results = await handleStage(initOptions, settings, this.library, false);
|
|
82
|
-
// Process default locale static URLs first, before translations
|
|
83
|
-
if (settings.options?.experimentalLocalizeStaticUrls) {
|
|
84
|
-
await localizeStaticUrls(settings, [settings.defaultLocale]);
|
|
85
|
-
}
|
|
86
81
|
if (results) {
|
|
87
82
|
await handleTranslate(initOptions, settings, results);
|
|
88
83
|
}
|
|
89
84
|
}
|
|
90
85
|
else {
|
|
91
|
-
// Process default locale static URLs first, before downloading translations
|
|
92
|
-
if (settings.options?.experimentalLocalizeStaticUrls) {
|
|
93
|
-
await localizeStaticUrls(settings, [settings.defaultLocale]);
|
|
94
|
-
}
|
|
95
86
|
await handleDownload(initOptions, settings);
|
|
96
87
|
}
|
|
97
88
|
await postProcessTranslations(settings);
|
|
@@ -3,7 +3,6 @@ import { createFileMapping } from '../../formats/files/fileMapping.js';
|
|
|
3
3
|
import { logError } from '../../console/logging.js';
|
|
4
4
|
import { getStagedVersions } from '../../fs/config/updateVersions.js';
|
|
5
5
|
import copyFile from '../../fs/copyFile.js';
|
|
6
|
-
import localizeStaticImports from '../../utils/localizeStaticImports.js';
|
|
7
6
|
import flattenJsonFiles from '../../utils/flattenJsonFiles.js';
|
|
8
7
|
import localizeStaticUrls from '../../utils/localizeStaticUrls.js';
|
|
9
8
|
import { noFilesError, noVersionIdError } from '../../console/index.js';
|
|
@@ -38,15 +37,11 @@ export async function postProcessTranslations(settings) {
|
|
|
38
37
|
// Localize static urls (/docs -> /[locale]/docs) for non-default locales only
|
|
39
38
|
// Default locale is processed earlier in the flow in base.ts
|
|
40
39
|
if (settings.options?.experimentalLocalizeStaticUrls) {
|
|
41
|
-
const nonDefaultLocales = settings.locales.filter(locale => locale !== settings.defaultLocale);
|
|
40
|
+
const nonDefaultLocales = settings.locales.filter((locale) => locale !== settings.defaultLocale);
|
|
42
41
|
if (nonDefaultLocales.length > 0) {
|
|
43
42
|
await localizeStaticUrls(settings, nonDefaultLocales);
|
|
44
43
|
}
|
|
45
44
|
}
|
|
46
|
-
// Localize static imports (/docs -> /[locale]/docs)
|
|
47
|
-
if (settings.options?.experimentalLocalizeStaticImports) {
|
|
48
|
-
await localizeStaticImports(settings);
|
|
49
|
-
}
|
|
50
45
|
// Flatten json files into a single file
|
|
51
46
|
if (settings.options?.experimentalFlattenJsonFiles) {
|
|
52
47
|
await flattenJsonFiles(settings);
|
|
@@ -235,7 +235,7 @@ function transformMdxUrls(mdxContent, defaultLocale, targetLocale, hideDefaultLo
|
|
|
235
235
|
return {
|
|
236
236
|
content: mdxContent,
|
|
237
237
|
hasChanges: false,
|
|
238
|
-
transformedUrls
|
|
238
|
+
transformedUrls,
|
|
239
239
|
};
|
|
240
240
|
}
|
|
241
241
|
// Helper function to transform URL based on pattern
|
|
@@ -249,6 +249,14 @@ function transformMdxUrls(mdxContent, defaultLocale, targetLocale, hideDefaultLo
|
|
|
249
249
|
// Get everything after the base domain
|
|
250
250
|
const afterDomain = originalUrl.substring(baseDomain.length);
|
|
251
251
|
const transformedPath = transformUrlPath(afterDomain, patternHead, targetLocale, defaultLocale, hideDefaultLocale);
|
|
252
|
+
if (!transformedPath) {
|
|
253
|
+
return null;
|
|
254
|
+
}
|
|
255
|
+
transformedUrls.push({
|
|
256
|
+
originalPath: originalUrl,
|
|
257
|
+
newPath: transformedPath,
|
|
258
|
+
type: linkType,
|
|
259
|
+
});
|
|
252
260
|
return transformedPath ? baseDomain + transformedPath : null;
|
|
253
261
|
}
|
|
254
262
|
// Exclude colon-prefixed URLs (http://, https://, //, etc.)
|