gtx-cli 2.6.2 → 2.6.3

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 CHANGED
@@ -1,5 +1,11 @@
1
1
  # gtx-cli
2
2
 
3
+ ## 2.6.3
4
+
5
+ ### Patch Changes
6
+
7
+ - [#967](https://github.com/generaltranslation/gt/pull/967) [`bc52a1d`](https://github.com/generaltranslation/gt/commit/bc52a1ddc8ef11540681215b8a9b0ab54e1b3bca) Thanks [@fernando-aviles](https://github.com/fernando-aviles)! - Reverting Mintlify-specific `docs.json` file filtering
8
+
3
9
  ## 2.6.2
4
10
 
5
11
  ### Patch Changes
@@ -12,7 +12,6 @@ import chalk from 'chalk';
12
12
  import { resolveConfig } from './resolveConfig.js';
13
13
  import { gt } from '../utils/gt.js';
14
14
  import { generatePreset } from './optionPresets.js';
15
- import { applyMintlifyDocsJsonFilter } from '../utils/mintlifyDocsJson.js';
16
15
  export const DEFAULT_SRC_PATTERNS = [
17
16
  'src/**/*.{js,jsx,ts,tsx}',
18
17
  'app/**/*.{js,jsx,ts,tsx}',
@@ -119,11 +118,6 @@ export async function generateSettings(flags, cwd = process.cwd()) {
119
118
  : { resolvedPaths: {}, placeholderPaths: {}, transformPaths: {} };
120
119
  mergedOptions.options = {
121
120
  ...(mergedOptions.options || {}),
122
- mintlify: {
123
- ...(mergedOptions.options?.mintlify || {}),
124
- useDocsJsonNavigation: gtConfig.options?.mintlify?.useDocsJsonNavigation ||
125
- mergedOptions.options?.mintlify?.useDocsJsonNavigation,
126
- },
127
121
  experimentalLocalizeStaticImports: gtConfig.options?.experimentalLocalizeStaticImports ||
128
122
  flags.experimentalLocalizeStaticImports,
129
123
  experimentalLocalizeStaticUrls: gtConfig.options?.experimentalLocalizeStaticUrls ||
@@ -136,7 +130,6 @@ export async function generateSettings(flags, cwd = process.cwd()) {
136
130
  flags.experimentalClearLocaleDirs,
137
131
  clearLocaleDirsExclude: gtConfig.options?.clearLocaleDirsExclude || flags.clearLocaleDirsExclude,
138
132
  };
139
- applyMintlifyDocsJsonFilter(mergedOptions, cwd);
140
133
  // Add additional options if provided
141
134
  if (mergedOptions.options) {
142
135
  if (mergedOptions.options.jsonSchema) {
@@ -1 +1 @@
1
- export declare const PACKAGE_VERSION = "2.6.2";
1
+ export declare const PACKAGE_VERSION = "2.6.3";
@@ -1,2 +1,2 @@
1
1
  // This file is auto-generated. Do not edit manually.
2
- export const PACKAGE_VERSION = '2.6.2';
2
+ export const PACKAGE_VERSION = '2.6.3';
@@ -36,7 +36,6 @@ export type OpenApiConfig = {
36
36
  };
37
37
  export type MintlifyOptions = {
38
38
  openapi?: OpenApiConfig;
39
- useDocsJsonNavigation?: boolean;
40
39
  };
41
40
  export type SharedFlags = {
42
41
  config?: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gtx-cli",
3
- "version": "2.6.2",
3
+ "version": "2.6.3",
4
4
  "main": "dist/index.js",
5
5
  "bin": "dist/main.js",
6
6
  "files": [
@@ -1,2 +0,0 @@
1
- import { Settings } from '../types/index.js';
2
- export declare function applyMintlifyDocsJsonFilter(settings: Settings, cwd: string): void;
@@ -1,134 +0,0 @@
1
- import fs from 'node:fs';
2
- import path from 'node:path';
3
- import { logger } from '../console/logger.js';
4
- export function applyMintlifyDocsJsonFilter(settings, cwd) {
5
- if (!settings.options?.mintlify?.useDocsJsonNavigation)
6
- return;
7
- if (!settings.files)
8
- return;
9
- const docsJsonPath = resolveDocsJsonPath(cwd);
10
- if (!docsJsonPath) {
11
- logger.warn('Mintlify docs.json not found. Skipping docs.json navigation filtering.');
12
- return;
13
- }
14
- const pages = readDocsJsonPages(docsJsonPath, settings.defaultLocale);
15
- if (pages.size === 0) {
16
- logger.warn('No pages found in docs.json navigation. Skipping docs.json navigation filtering.');
17
- return;
18
- }
19
- const pageList = Array.from(pages);
20
- const matchedPages = new Set();
21
- const filterByPages = (filePaths, placeholderPaths) => {
22
- if (!filePaths || !placeholderPaths) {
23
- return { filePaths, placeholderPaths };
24
- }
25
- const nextFiles = [];
26
- const nextPlaceholders = [];
27
- for (let i = 0; i < filePaths.length; i++) {
28
- const filePath = filePaths[i];
29
- const relativeNoExt = stripExtension(toPosix(path.relative(cwd, filePath)));
30
- const matches = pageList.some((page) => {
31
- const match = relativeNoExt === page;
32
- if (match) {
33
- matchedPages.add(page);
34
- }
35
- return match;
36
- });
37
- if (matches) {
38
- nextFiles.push(filePath);
39
- nextPlaceholders.push(placeholderPaths[i]);
40
- }
41
- }
42
- return { filePaths: nextFiles, placeholderPaths: nextPlaceholders };
43
- };
44
- const filteredMdx = filterByPages(settings.files.resolvedPaths.mdx, settings.files.placeholderPaths.mdx);
45
- const filteredMd = filterByPages(settings.files.resolvedPaths.md, settings.files.placeholderPaths.md);
46
- settings.files.resolvedPaths.mdx = filteredMdx.filePaths;
47
- settings.files.placeholderPaths.mdx = filteredMdx.placeholderPaths;
48
- settings.files.resolvedPaths.md = filteredMd.filePaths;
49
- settings.files.placeholderPaths.md = filteredMd.placeholderPaths;
50
- const missingPages = pageList.filter((page) => !matchedPages.has(page));
51
- if (missingPages.length > 0) {
52
- logger.warn(`Some docs.json pages were not found in your files config: ${missingPages
53
- .slice(0, 5)
54
- .join(', ')}${missingPages.length > 5 ? '...' : ''}`);
55
- }
56
- }
57
- function resolveDocsJsonPath(cwd) {
58
- const docsJsonPath = path.join(cwd, 'docs.json');
59
- if (fs.existsSync(docsJsonPath))
60
- return docsJsonPath;
61
- const mintJsonPath = path.join(cwd, 'mint.json');
62
- if (fs.existsSync(mintJsonPath))
63
- return mintJsonPath;
64
- return null;
65
- }
66
- function readDocsJsonPages(filePath, defaultLocale) {
67
- let parsed;
68
- try {
69
- parsed = JSON.parse(fs.readFileSync(filePath, 'utf8'));
70
- }
71
- catch {
72
- return new Set();
73
- }
74
- if (!isRecord(parsed))
75
- return new Set();
76
- const navigation = parsed.navigation;
77
- if (!isRecord(navigation))
78
- return new Set();
79
- const navigationRoot = selectNavigationRoot(navigation, defaultLocale);
80
- if (!navigationRoot)
81
- return new Set();
82
- const pages = new Set();
83
- collectPages(navigationRoot, pages);
84
- return pages;
85
- }
86
- function selectNavigationRoot(navigation, defaultLocale) {
87
- const languages = navigation.languages;
88
- if (Array.isArray(languages)) {
89
- const byLocale = languages.find((entry) => isRecord(entry) &&
90
- typeof entry.language === 'string' &&
91
- entry.language === defaultLocale);
92
- return byLocale ?? languages[0] ?? null;
93
- }
94
- return navigation;
95
- }
96
- function collectPages(node, pages) {
97
- if (typeof node === 'string') {
98
- const normalized = normalizePage(node);
99
- if (normalized)
100
- pages.add(normalized);
101
- return;
102
- }
103
- if (Array.isArray(node)) {
104
- node.forEach((item) => collectPages(item, pages));
105
- return;
106
- }
107
- if (!isRecord(node))
108
- return;
109
- for (const [key, value] of Object.entries(node)) {
110
- if (key === 'pages' && Array.isArray(value)) {
111
- value.forEach((item) => collectPages(item, pages));
112
- continue;
113
- }
114
- collectPages(value, pages);
115
- }
116
- }
117
- function normalizePage(page) {
118
- let normalized = page.trim();
119
- if (!normalized)
120
- return null;
121
- normalized = normalized.split('#')[0]?.split('?')[0] ?? normalized;
122
- normalized = normalized.replace(/^\.\//, '').replace(/^\/+/, '');
123
- normalized = normalized.replace(/\.(mdx|md)$/i, '');
124
- return normalized || null;
125
- }
126
- function stripExtension(filePath) {
127
- return filePath.replace(/\.[^/.]+$/, '');
128
- }
129
- function toPosix(filePath) {
130
- return filePath.split(path.sep).join(path.posix.sep);
131
- }
132
- function isRecord(value) {
133
- return typeof value === 'object' && value !== null;
134
- }