gt 2.14.39 → 2.14.40
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/CHANGELOG.md +6 -0
- package/dist/generated/version.d.ts +1 -1
- package/dist/generated/version.js +1 -1
- package/dist/generated/version.js.map +1 -1
- package/dist/utils/localizeMintlifyFrontmatterUrls.js +3 -2
- package/dist/utils/localizeMintlifyFrontmatterUrls.js.map +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
# gtx-cli
|
|
2
2
|
|
|
3
|
+
## 2.14.40
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#1456](https://github.com/generaltranslation/gt/pull/1456) [`8094012`](https://github.com/generaltranslation/gt/commit/8094012f9827f3a35e053776946bea67492da9db) Thanks [@fernando-aviles](https://github.com/fernando-aviles)! - Handling slash in Mint `url` fields
|
|
8
|
+
|
|
3
9
|
## 2.14.39
|
|
4
10
|
|
|
5
11
|
### Patch Changes
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const PACKAGE_VERSION = "2.14.
|
|
1
|
+
export declare const PACKAGE_VERSION = "2.14.40";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"version.js","names":[],"sources":["../../src/generated/version.ts"],"sourcesContent":["// This file is auto-generated. Do not edit manually.\nexport const PACKAGE_VERSION = '2.14.
|
|
1
|
+
{"version":3,"file":"version.js","names":[],"sources":["../../src/generated/version.ts"],"sourcesContent":["// This file is auto-generated. Do not edit manually.\nexport const PACKAGE_VERSION = '2.14.40';\n"],"mappings":";AACA,MAAa,kBAAkB"}
|
|
@@ -23,14 +23,15 @@ function normalizeMintlifyFrontmatterUrl(url, targetLocale, knownLocales) {
|
|
|
23
23
|
if (!trimmed || SKIPPABLE_URL_REGEX.test(trimmed)) return null;
|
|
24
24
|
const leadingWhitespace = url.match(/^\s*/)?.[0] ?? "";
|
|
25
25
|
const trailingWhitespace = url.match(/\s*$/)?.[0] ?? "";
|
|
26
|
+
const leadingSlash = trimmed.startsWith("/") ? "/" : "";
|
|
26
27
|
const pathBody = trimmed.replace(/^\/+/, "");
|
|
27
28
|
const [firstSegment, ...restSegments] = pathBody.split("/");
|
|
28
29
|
if (firstSegment === targetLocale) {
|
|
29
|
-
const normalized = `${leadingWhitespace}${pathBody}${trailingWhitespace}`;
|
|
30
|
+
const normalized = `${leadingWhitespace}${leadingSlash}${pathBody}${trailingWhitespace}`;
|
|
30
31
|
return normalized === url ? null : normalized;
|
|
31
32
|
}
|
|
32
33
|
const unprefixedPath = knownLocales.has(firstSegment) ? restSegments.join("/") : pathBody;
|
|
33
|
-
const normalized = `${leadingWhitespace}${unprefixedPath ? `${targetLocale}/${unprefixedPath}` : `${targetLocale}/`}${trailingWhitespace}`;
|
|
34
|
+
const normalized = `${leadingWhitespace}${leadingSlash}${unprefixedPath ? `${targetLocale}/${unprefixedPath}` : `${targetLocale}/`}${trailingWhitespace}`;
|
|
34
35
|
return normalized === url ? null : normalized;
|
|
35
36
|
}
|
|
36
37
|
function localizeMintlifyFrontmatterUrlForContent(content, targetLocale, knownLocaleValues) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"localizeMintlifyFrontmatterUrls.js","names":[],"sources":["../../src/utils/localizeMintlifyFrontmatterUrls.ts"],"sourcesContent":["import fs from 'node:fs';\nimport path from 'node:path';\nimport { unified } from 'unified';\nimport remarkParse from 'remark-parse';\nimport remarkFrontmatter from 'remark-frontmatter';\nimport YAML, { isMap, isScalar } from 'yaml';\nimport type { Content, Root, Yaml } from 'mdast';\nimport { createFileMapping } from '../formats/files/fileMapping.js';\nimport type { Settings } from '../types/index.js';\n\nconst SKIPPABLE_URL_REGEX = /^(?:[a-z][a-z0-9+.-]*:|\\/\\/|#|\\.\\/|\\.\\.\\/)/i;\n\nfunction getYamlFrontmatter(content: string): Yaml | null {\n let tree: Root;\n try {\n tree = unified()\n .use(remarkParse)\n .use(remarkFrontmatter, ['yaml'])\n .parse(content) as Root;\n } catch {\n return null;\n }\n\n const yamlNode = (tree.children as Content[]).find(\n (node): node is Yaml => (node as Yaml).type === 'yaml'\n );\n if (\n !yamlNode ||\n !yamlNode.position ||\n yamlNode.position.start?.offset === undefined ||\n yamlNode.position.end?.offset === undefined\n ) {\n return null;\n }\n return yamlNode;\n}\n\nfunction normalizeMintlifyFrontmatterUrl(\n url: string,\n targetLocale: string,\n knownLocales: Set<string>\n): string | null {\n const trimmed = url.trim();\n if (!trimmed || SKIPPABLE_URL_REGEX.test(trimmed)) {\n return null;\n }\n\n const leadingWhitespace = url.match(/^\\s*/)?.[0] ?? '';\n const trailingWhitespace = url.match(/\\s*$/)?.[0] ?? '';\n const pathBody = trimmed.replace(/^\\/+/, '');\n const [firstSegment, ...restSegments] = pathBody.split('/');\n\n if (firstSegment === targetLocale) {\n const normalized = `${leadingWhitespace}${pathBody}${trailingWhitespace}`;\n return normalized === url ? null : normalized;\n }\n\n const unprefixedPath = knownLocales.has(firstSegment)\n ? restSegments.join('/')\n : pathBody;\n const localizedPath = unprefixedPath\n ? `${targetLocale}/${unprefixedPath}`\n : `${targetLocale}/`;\n const normalized = `${leadingWhitespace}${localizedPath}${trailingWhitespace}`;\n\n return normalized === url ? null : normalized;\n}\n\nexport function localizeMintlifyFrontmatterUrlForContent(\n content: string,\n targetLocale: string,\n knownLocaleValues: string[]\n): { content: string; changed: boolean } {\n const yamlNode = getYamlFrontmatter(content);\n if (!yamlNode) {\n return { content, changed: false };\n }\n\n const frontmatterRaw: string = yamlNode.value || '';\n const doc = YAML.parseDocument(frontmatterRaw, {\n prettyErrors: false,\n keepSourceTokens: true,\n });\n if (doc.errors?.length || !isMap(doc.contents)) {\n return { content, changed: false };\n }\n\n const urlNode = doc.get('url', true);\n if (!isScalar(urlNode) || typeof urlNode.value !== 'string') {\n return { content, changed: false };\n }\n\n const localizedUrl = normalizeMintlifyFrontmatterUrl(\n urlNode.value,\n targetLocale,\n new Set(knownLocaleValues)\n );\n if (!localizedUrl) {\n return { content, changed: false };\n }\n\n urlNode.value = localizedUrl;\n\n const start = yamlNode.position!.start.offset as number;\n const end = yamlNode.position!.end.offset as number;\n const newline = content.includes('\\r\\n') ? '\\r\\n' : '\\n';\n const frontmatter = doc.toString().trimEnd().replace(/\\n/g, newline);\n return {\n content: `${content.slice(0, start)}---${newline}${frontmatter}${newline}---${content.slice(end)}`,\n changed: true,\n };\n}\n\nfunction shouldProcessFile(filePath: string, includeFiles?: Set<string>) {\n if (!includeFiles) return true;\n return includeFiles.has(filePath) || includeFiles.has(path.resolve(filePath));\n}\n\nexport default async function localizeMintlifyFrontmatterUrls(\n settings: Settings,\n includeFiles?: Set<string>\n) {\n if (settings.framework !== 'mintlify' || !settings.files) return;\n\n const fileMapping = createFileMapping(\n settings.files.resolvedPaths,\n settings.files.placeholderPaths,\n settings.files.transformPaths ?? {},\n settings.files.transformFormats ?? {},\n settings.locales,\n settings.defaultLocale\n );\n const knownLocaleValues = [settings.defaultLocale, ...settings.locales];\n\n for (const [locale, filesMap] of Object.entries(fileMapping)) {\n const targetFiles = Object.values(filesMap).filter(\n (filePath) =>\n (filePath.endsWith('.md') || filePath.endsWith('.mdx')) &&\n shouldProcessFile(filePath, includeFiles)\n );\n\n await Promise.all(\n targetFiles.map(async (filePath) => {\n if (!fs.existsSync(filePath)) return;\n\n const content = await fs.promises.readFile(filePath, 'utf8');\n const result = localizeMintlifyFrontmatterUrlForContent(\n content,\n locale,\n knownLocaleValues\n );\n if (result.changed) {\n await fs.promises.writeFile(filePath, result.content, 'utf8');\n }\n })\n );\n }\n}\n"],"mappings":";;;;;;;;AAUA,MAAM,sBAAsB;AAE5B,SAAS,mBAAmB,SAA8B;CACxD,IAAI;AACJ,KAAI;AACF,SAAO,SAAS,CACb,IAAI,YAAY,CAChB,IAAI,mBAAmB,CAAC,OAAO,CAAC,CAChC,MAAM,QAAQ;SACX;AACN,SAAO;;CAGT,MAAM,WAAY,KAAK,SAAuB,MAC3C,SAAwB,KAAc,SAAS,OACjD;AACD,KACE,CAAC,YACD,CAAC,SAAS,YACV,SAAS,SAAS,OAAO,WAAW,KAAA,KACpC,SAAS,SAAS,KAAK,WAAW,KAAA,EAElC,QAAO;AAET,QAAO;;AAGT,SAAS,gCACP,KACA,cACA,cACe;CACf,MAAM,UAAU,IAAI,MAAM;AAC1B,KAAI,CAAC,WAAW,oBAAoB,KAAK,QAAQ,CAC/C,QAAO;CAGT,MAAM,oBAAoB,IAAI,MAAM,OAAO,GAAG,MAAM;CACpD,MAAM,qBAAqB,IAAI,MAAM,OAAO,GAAG,MAAM;CACrD,MAAM,WAAW,QAAQ,QAAQ,QAAQ,GAAG;CAC5C,MAAM,CAAC,cAAc,GAAG,gBAAgB,SAAS,MAAM,IAAI;AAE3D,KAAI,iBAAiB,cAAc;EACjC,MAAM,aAAa,GAAG,oBAAoB,WAAW;
|
|
1
|
+
{"version":3,"file":"localizeMintlifyFrontmatterUrls.js","names":[],"sources":["../../src/utils/localizeMintlifyFrontmatterUrls.ts"],"sourcesContent":["import fs from 'node:fs';\nimport path from 'node:path';\nimport { unified } from 'unified';\nimport remarkParse from 'remark-parse';\nimport remarkFrontmatter from 'remark-frontmatter';\nimport YAML, { isMap, isScalar } from 'yaml';\nimport type { Content, Root, Yaml } from 'mdast';\nimport { createFileMapping } from '../formats/files/fileMapping.js';\nimport type { Settings } from '../types/index.js';\n\nconst SKIPPABLE_URL_REGEX = /^(?:[a-z][a-z0-9+.-]*:|\\/\\/|#|\\.\\/|\\.\\.\\/)/i;\n\nfunction getYamlFrontmatter(content: string): Yaml | null {\n let tree: Root;\n try {\n tree = unified()\n .use(remarkParse)\n .use(remarkFrontmatter, ['yaml'])\n .parse(content) as Root;\n } catch {\n return null;\n }\n\n const yamlNode = (tree.children as Content[]).find(\n (node): node is Yaml => (node as Yaml).type === 'yaml'\n );\n if (\n !yamlNode ||\n !yamlNode.position ||\n yamlNode.position.start?.offset === undefined ||\n yamlNode.position.end?.offset === undefined\n ) {\n return null;\n }\n return yamlNode;\n}\n\nfunction normalizeMintlifyFrontmatterUrl(\n url: string,\n targetLocale: string,\n knownLocales: Set<string>\n): string | null {\n const trimmed = url.trim();\n if (!trimmed || SKIPPABLE_URL_REGEX.test(trimmed)) {\n return null;\n }\n\n const leadingWhitespace = url.match(/^\\s*/)?.[0] ?? '';\n const trailingWhitespace = url.match(/\\s*$/)?.[0] ?? '';\n const leadingSlash = trimmed.startsWith('/') ? '/' : '';\n const pathBody = trimmed.replace(/^\\/+/, '');\n const [firstSegment, ...restSegments] = pathBody.split('/');\n\n if (firstSegment === targetLocale) {\n const normalized = `${leadingWhitespace}${leadingSlash}${pathBody}${trailingWhitespace}`;\n return normalized === url ? null : normalized;\n }\n\n const unprefixedPath = knownLocales.has(firstSegment)\n ? restSegments.join('/')\n : pathBody;\n const localizedPath = unprefixedPath\n ? `${targetLocale}/${unprefixedPath}`\n : `${targetLocale}/`;\n const normalized = `${leadingWhitespace}${leadingSlash}${localizedPath}${trailingWhitespace}`;\n\n return normalized === url ? null : normalized;\n}\n\nexport function localizeMintlifyFrontmatterUrlForContent(\n content: string,\n targetLocale: string,\n knownLocaleValues: string[]\n): { content: string; changed: boolean } {\n const yamlNode = getYamlFrontmatter(content);\n if (!yamlNode) {\n return { content, changed: false };\n }\n\n const frontmatterRaw: string = yamlNode.value || '';\n const doc = YAML.parseDocument(frontmatterRaw, {\n prettyErrors: false,\n keepSourceTokens: true,\n });\n if (doc.errors?.length || !isMap(doc.contents)) {\n return { content, changed: false };\n }\n\n const urlNode = doc.get('url', true);\n if (!isScalar(urlNode) || typeof urlNode.value !== 'string') {\n return { content, changed: false };\n }\n\n const localizedUrl = normalizeMintlifyFrontmatterUrl(\n urlNode.value,\n targetLocale,\n new Set(knownLocaleValues)\n );\n if (!localizedUrl) {\n return { content, changed: false };\n }\n\n urlNode.value = localizedUrl;\n\n const start = yamlNode.position!.start.offset as number;\n const end = yamlNode.position!.end.offset as number;\n const newline = content.includes('\\r\\n') ? '\\r\\n' : '\\n';\n const frontmatter = doc.toString().trimEnd().replace(/\\n/g, newline);\n return {\n content: `${content.slice(0, start)}---${newline}${frontmatter}${newline}---${content.slice(end)}`,\n changed: true,\n };\n}\n\nfunction shouldProcessFile(filePath: string, includeFiles?: Set<string>) {\n if (!includeFiles) return true;\n return includeFiles.has(filePath) || includeFiles.has(path.resolve(filePath));\n}\n\nexport default async function localizeMintlifyFrontmatterUrls(\n settings: Settings,\n includeFiles?: Set<string>\n) {\n if (settings.framework !== 'mintlify' || !settings.files) return;\n\n const fileMapping = createFileMapping(\n settings.files.resolvedPaths,\n settings.files.placeholderPaths,\n settings.files.transformPaths ?? {},\n settings.files.transformFormats ?? {},\n settings.locales,\n settings.defaultLocale\n );\n const knownLocaleValues = [settings.defaultLocale, ...settings.locales];\n\n for (const [locale, filesMap] of Object.entries(fileMapping)) {\n const targetFiles = Object.values(filesMap).filter(\n (filePath) =>\n (filePath.endsWith('.md') || filePath.endsWith('.mdx')) &&\n shouldProcessFile(filePath, includeFiles)\n );\n\n await Promise.all(\n targetFiles.map(async (filePath) => {\n if (!fs.existsSync(filePath)) return;\n\n const content = await fs.promises.readFile(filePath, 'utf8');\n const result = localizeMintlifyFrontmatterUrlForContent(\n content,\n locale,\n knownLocaleValues\n );\n if (result.changed) {\n await fs.promises.writeFile(filePath, result.content, 'utf8');\n }\n })\n );\n }\n}\n"],"mappings":";;;;;;;;AAUA,MAAM,sBAAsB;AAE5B,SAAS,mBAAmB,SAA8B;CACxD,IAAI;AACJ,KAAI;AACF,SAAO,SAAS,CACb,IAAI,YAAY,CAChB,IAAI,mBAAmB,CAAC,OAAO,CAAC,CAChC,MAAM,QAAQ;SACX;AACN,SAAO;;CAGT,MAAM,WAAY,KAAK,SAAuB,MAC3C,SAAwB,KAAc,SAAS,OACjD;AACD,KACE,CAAC,YACD,CAAC,SAAS,YACV,SAAS,SAAS,OAAO,WAAW,KAAA,KACpC,SAAS,SAAS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