gtx-cli 2.3.4 → 2.3.6-alpha.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.
Files changed (192) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/package.json +23 -18
  3. package/dist/api/checkFileTranslations.d.ts +0 -23
  4. package/dist/api/checkFileTranslations.js +0 -236
  5. package/dist/api/downloadFileBatch.d.ts +0 -20
  6. package/dist/api/downloadFileBatch.js +0 -113
  7. package/dist/api/sendFiles.d.ts +0 -17
  8. package/dist/api/sendFiles.js +0 -115
  9. package/dist/api/uploadFiles.d.ts +0 -27
  10. package/dist/api/uploadFiles.js +0 -40
  11. package/dist/cli/base.d.ts +0 -32
  12. package/dist/cli/base.js +0 -335
  13. package/dist/cli/commands/stage.d.ts +0 -5
  14. package/dist/cli/commands/stage.js +0 -100
  15. package/dist/cli/commands/translate.d.ts +0 -6
  16. package/dist/cli/commands/translate.js +0 -63
  17. package/dist/cli/flags.d.ts +0 -3
  18. package/dist/cli/flags.js +0 -38
  19. package/dist/cli/next.d.ts +0 -11
  20. package/dist/cli/next.js +0 -20
  21. package/dist/cli/react.d.ts +0 -18
  22. package/dist/cli/react.js +0 -175
  23. package/dist/config/generateSettings.d.ts +0 -9
  24. package/dist/config/generateSettings.js +0 -171
  25. package/dist/config/optionPresets.d.ts +0 -2
  26. package/dist/config/optionPresets.js +0 -56
  27. package/dist/config/resolveConfig.d.ts +0 -4
  28. package/dist/config/resolveConfig.js +0 -19
  29. package/dist/config/utils.d.ts +0 -2
  30. package/dist/config/utils.js +0 -4
  31. package/dist/config/validateSettings.d.ts +0 -3
  32. package/dist/config/validateSettings.js +0 -32
  33. package/dist/console/colors.d.ts +0 -5
  34. package/dist/console/colors.js +0 -16
  35. package/dist/console/index.d.ts +0 -21
  36. package/dist/console/index.js +0 -24
  37. package/dist/console/logging.d.ts +0 -53
  38. package/dist/console/logging.js +0 -185
  39. package/dist/formats/files/fileMapping.d.ts +0 -11
  40. package/dist/formats/files/fileMapping.js +0 -82
  41. package/dist/formats/files/save.d.ts +0 -5
  42. package/dist/formats/files/save.js +0 -17
  43. package/dist/formats/files/supportedFiles.d.ts +0 -10
  44. package/dist/formats/files/supportedFiles.js +0 -18
  45. package/dist/formats/files/translate.d.ts +0 -4
  46. package/dist/formats/files/translate.js +0 -119
  47. package/dist/formats/files/upload.d.ts +0 -13
  48. package/dist/formats/files/upload.js +0 -136
  49. package/dist/formats/gt/save.d.ts +0 -9
  50. package/dist/formats/gt/save.js +0 -26
  51. package/dist/formats/json/flattenJson.d.ts +0 -14
  52. package/dist/formats/json/flattenJson.js +0 -64
  53. package/dist/formats/json/mergeJson.d.ts +0 -13
  54. package/dist/formats/json/mergeJson.js +0 -257
  55. package/dist/formats/json/parseJson.d.ts +0 -2
  56. package/dist/formats/json/parseJson.js +0 -108
  57. package/dist/formats/json/utils.d.ts +0 -47
  58. package/dist/formats/json/utils.js +0 -149
  59. package/dist/formats/utils.d.ts +0 -2
  60. package/dist/formats/utils.js +0 -24
  61. package/dist/formats/yaml/mergeYaml.d.ts +0 -5
  62. package/dist/formats/yaml/mergeYaml.js +0 -55
  63. package/dist/formats/yaml/parseYaml.d.ts +0 -5
  64. package/dist/formats/yaml/parseYaml.js +0 -23
  65. package/dist/formats/yaml/utils.d.ts +0 -2
  66. package/dist/formats/yaml/utils.js +0 -22
  67. package/dist/fs/config/loadConfig.d.ts +0 -1
  68. package/dist/fs/config/loadConfig.js +0 -9
  69. package/dist/fs/config/parseFilesConfig.d.ts +0 -27
  70. package/dist/fs/config/parseFilesConfig.js +0 -126
  71. package/dist/fs/config/setupConfig.d.ts +0 -17
  72. package/dist/fs/config/setupConfig.js +0 -50
  73. package/dist/fs/config/updateConfig.d.ts +0 -10
  74. package/dist/fs/config/updateConfig.js +0 -36
  75. package/dist/fs/config/updateVersions.d.ts +0 -10
  76. package/dist/fs/config/updateVersions.js +0 -30
  77. package/dist/fs/copyFile.d.ts +0 -7
  78. package/dist/fs/copyFile.js +0 -39
  79. package/dist/fs/createLoadTranslationsFile.d.ts +0 -1
  80. package/dist/fs/createLoadTranslationsFile.js +0 -36
  81. package/dist/fs/determineFramework.d.ts +0 -5
  82. package/dist/fs/determineFramework.js +0 -46
  83. package/dist/fs/findFilepath.d.ts +0 -36
  84. package/dist/fs/findFilepath.js +0 -89
  85. package/dist/fs/getPackageResource.d.ts +0 -1
  86. package/dist/fs/getPackageResource.js +0 -6
  87. package/dist/fs/index.d.ts +0 -1
  88. package/dist/fs/index.js +0 -1
  89. package/dist/fs/loadJSON.d.ts +0 -6
  90. package/dist/fs/loadJSON.js +0 -17
  91. package/dist/fs/matchFiles.d.ts +0 -1
  92. package/dist/fs/matchFiles.js +0 -8
  93. package/dist/fs/saveJSON.d.ts +0 -1
  94. package/dist/fs/saveJSON.js +0 -7
  95. package/dist/fs/utils.d.ts +0 -1
  96. package/dist/fs/utils.js +0 -16
  97. package/dist/hooks/postProcess.d.ts +0 -4
  98. package/dist/hooks/postProcess.js +0 -110
  99. package/dist/index.d.ts +0 -4
  100. package/dist/index.js +0 -20
  101. package/dist/main.d.ts +0 -2
  102. package/dist/main.js +0 -9
  103. package/dist/next/config/parseNextConfig.d.ts +0 -10
  104. package/dist/next/config/parseNextConfig.js +0 -53
  105. package/dist/next/jsx/utils.d.ts +0 -7
  106. package/dist/next/jsx/utils.js +0 -42
  107. package/dist/next/parse/handleInitGT.d.ts +0 -7
  108. package/dist/next/parse/handleInitGT.js +0 -208
  109. package/dist/next/parse/wrapContent.d.ts +0 -11
  110. package/dist/next/parse/wrapContent.js +0 -163
  111. package/dist/react/config/createESBuildConfig.d.ts +0 -2
  112. package/dist/react/config/createESBuildConfig.js +0 -119
  113. package/dist/react/data-_gt/addGTIdentifierToSyntaxTree.d.ts +0 -8
  114. package/dist/react/data-_gt/addGTIdentifierToSyntaxTree.js +0 -111
  115. package/dist/react/jsx/evaluateJsx.d.ts +0 -17
  116. package/dist/react/jsx/evaluateJsx.js +0 -85
  117. package/dist/react/jsx/trimJsxStringChildren.d.ts +0 -7
  118. package/dist/react/jsx/trimJsxStringChildren.js +0 -95
  119. package/dist/react/jsx/utils/constants.d.ts +0 -10
  120. package/dist/react/jsx/utils/constants.js +0 -31
  121. package/dist/react/jsx/utils/parseAst.d.ts +0 -30
  122. package/dist/react/jsx/utils/parseAst.js +0 -277
  123. package/dist/react/jsx/utils/parseJsx.d.ts +0 -21
  124. package/dist/react/jsx/utils/parseJsx.js +0 -244
  125. package/dist/react/jsx/utils/parseStringFunction.d.ts +0 -16
  126. package/dist/react/jsx/utils/parseStringFunction.js +0 -411
  127. package/dist/react/jsx/utils/validateStringFunction.d.ts +0 -7
  128. package/dist/react/jsx/utils/validateStringFunction.js +0 -31
  129. package/dist/react/jsx/wrapJsx.d.ts +0 -51
  130. package/dist/react/jsx/wrapJsx.js +0 -387
  131. package/dist/react/parse/createDictionaryUpdates.d.ts +0 -3
  132. package/dist/react/parse/createDictionaryUpdates.js +0 -169
  133. package/dist/react/parse/createInlineUpdates.d.ts +0 -6
  134. package/dist/react/parse/createInlineUpdates.js +0 -122
  135. package/dist/react/parse/wrapContent.d.ts +0 -11
  136. package/dist/react/parse/wrapContent.js +0 -162
  137. package/dist/react/utils/flattenDictionary.d.ts +0 -20
  138. package/dist/react/utils/flattenDictionary.js +0 -75
  139. package/dist/react/utils/getEntryAndMetadata.d.ts +0 -5
  140. package/dist/react/utils/getEntryAndMetadata.js +0 -11
  141. package/dist/react/utils/getVariableName.d.ts +0 -25
  142. package/dist/react/utils/getVariableName.js +0 -37
  143. package/dist/setup/userInput.d.ts +0 -4
  144. package/dist/setup/userInput.js +0 -29
  145. package/dist/setup/wizard.d.ts +0 -2
  146. package/dist/setup/wizard.js +0 -127
  147. package/dist/translation/parse.d.ts +0 -15
  148. package/dist/translation/parse.js +0 -76
  149. package/dist/translation/stage.d.ts +0 -2
  150. package/dist/translation/stage.js +0 -44
  151. package/dist/translation/validate.d.ts +0 -2
  152. package/dist/translation/validate.js +0 -50
  153. package/dist/types/data/json.d.ts +0 -6
  154. package/dist/types/data/json.js +0 -1
  155. package/dist/types/data.d.ts +0 -30
  156. package/dist/types/data.js +0 -1
  157. package/dist/types/files.d.ts +0 -1
  158. package/dist/types/files.js +0 -1
  159. package/dist/types/index.d.ts +0 -173
  160. package/dist/types/index.js +0 -1
  161. package/dist/utils/addExplicitAnchorIds.d.ts +0 -24
  162. package/dist/utils/addExplicitAnchorIds.js +0 -260
  163. package/dist/utils/constants.d.ts +0 -2
  164. package/dist/utils/constants.js +0 -2
  165. package/dist/utils/credentials.d.ts +0 -12
  166. package/dist/utils/credentials.js +0 -119
  167. package/dist/utils/flattenJsonFiles.d.ts +0 -2
  168. package/dist/utils/flattenJsonFiles.js +0 -36
  169. package/dist/utils/gt.d.ts +0 -2
  170. package/dist/utils/gt.js +0 -2
  171. package/dist/utils/hash.d.ts +0 -6
  172. package/dist/utils/hash.js +0 -11
  173. package/dist/utils/headers.d.ts +0 -1
  174. package/dist/utils/headers.js +0 -14
  175. package/dist/utils/installPackage.d.ts +0 -3
  176. package/dist/utils/installPackage.js +0 -77
  177. package/dist/utils/localizeStaticImports.d.ts +0 -15
  178. package/dist/utils/localizeStaticImports.js +0 -341
  179. package/dist/utils/localizeStaticUrls.d.ts +0 -19
  180. package/dist/utils/localizeStaticUrls.js +0 -432
  181. package/dist/utils/packageInfo.d.ts +0 -3
  182. package/dist/utils/packageInfo.js +0 -17
  183. package/dist/utils/packageJson.d.ts +0 -6
  184. package/dist/utils/packageJson.js +0 -76
  185. package/dist/utils/packageManager.d.ts +0 -28
  186. package/dist/utils/packageManager.js +0 -269
  187. package/dist/utils/processAnchorIds.d.ts +0 -6
  188. package/dist/utils/processAnchorIds.js +0 -47
  189. package/dist/utils/sanitizeFileContent.d.ts +0 -6
  190. package/dist/utils/sanitizeFileContent.js +0 -29
  191. package/dist/utils/validateMdx.d.ts +0 -10
  192. package/dist/utils/validateMdx.js +0 -25
@@ -1,269 +0,0 @@
1
- // This file is MIT licensed and was adapted from https://github.com/getsentry/sentry-wizard/blob/master/src/utils/package-manager.ts and https://github.com/getsentry/sentry-wizard/blob/master/src/utils/clack/index.ts
2
- import * as fs from 'fs';
3
- import * as path from 'path';
4
- import { getPackageJson, updatePackageJson } from './packageJson.js';
5
- import { promptSelect } from '../console/logging.js';
6
- export class NoPackageManagerError extends Error {
7
- constructor(message) {
8
- super(message);
9
- this.name = 'NoPackageManagerError';
10
- }
11
- }
12
- export const BUN = {
13
- id: 'bun',
14
- name: 'bun',
15
- label: 'Bun',
16
- installCommand: 'add',
17
- installAllCommand: 'bun install',
18
- buildCommand: 'bun run build',
19
- runScriptCommand: 'bun run',
20
- flags: '',
21
- forceInstallFlag: '--force',
22
- devDependencyFlag: '--dev',
23
- detect: (cwd) => ['bun.lockb', 'bun.lock'].some((lockFile) => {
24
- try {
25
- return fs.existsSync(path.join(cwd, lockFile));
26
- }
27
- catch (e) {
28
- return false;
29
- }
30
- }),
31
- addOverride: async (pkgName, pkgVersion) => {
32
- const packageDotJson = await getPackageJson();
33
- if (!packageDotJson) {
34
- return;
35
- }
36
- const overrides = packageDotJson.overrides || {};
37
- await updatePackageJson({
38
- ...packageDotJson,
39
- overrides: {
40
- ...overrides,
41
- [pkgName]: pkgVersion,
42
- },
43
- });
44
- },
45
- };
46
- export const DENO = {
47
- id: 'deno',
48
- name: 'deno',
49
- label: 'Deno',
50
- installCommand: 'install',
51
- installAllCommand: 'deno install',
52
- buildCommand: 'deno task build',
53
- runScriptCommand: 'deno task',
54
- flags: '',
55
- forceInstallFlag: '--force',
56
- devDependencyFlag: '--dev',
57
- registry: 'npm',
58
- detect: (cwd) => {
59
- try {
60
- return fs.existsSync(path.join(cwd, 'deno.lock'));
61
- }
62
- catch (e) {
63
- return false;
64
- }
65
- },
66
- addOverride: async (pkgName, pkgVersion) => {
67
- const packageDotJson = await getPackageJson();
68
- if (!packageDotJson) {
69
- return;
70
- }
71
- const overrides = packageDotJson.overrides || {};
72
- await updatePackageJson({
73
- ...packageDotJson,
74
- overrides: {
75
- ...overrides,
76
- [pkgName]: pkgVersion,
77
- },
78
- });
79
- },
80
- };
81
- export const YARN_V1 = {
82
- id: 'yarn_v1',
83
- name: 'yarn',
84
- label: 'Yarn V1',
85
- installCommand: 'add',
86
- installAllCommand: 'yarn install',
87
- buildCommand: 'yarn build',
88
- runScriptCommand: 'yarn',
89
- flags: '--ignore-workspace-root-check',
90
- forceInstallFlag: '--force',
91
- devDependencyFlag: '--dev',
92
- detect: (cwd) => {
93
- try {
94
- return fs
95
- .readFileSync(path.join(cwd, 'yarn.lock'), 'utf-8')
96
- .slice(0, 500)
97
- .includes('yarn lockfile v1');
98
- }
99
- catch (e) {
100
- return false;
101
- }
102
- },
103
- addOverride: async (pkgName, pkgVersion) => {
104
- const packageDotJson = await getPackageJson();
105
- if (!packageDotJson) {
106
- return;
107
- }
108
- const resolutions = packageDotJson.resolutions || {};
109
- await updatePackageJson({
110
- ...packageDotJson,
111
- resolutions: {
112
- ...resolutions,
113
- [pkgName]: pkgVersion,
114
- },
115
- });
116
- },
117
- };
118
- /** YARN V2/3/4 */
119
- export const YARN_V2 = {
120
- id: 'yarn_v2',
121
- name: 'yarn',
122
- label: 'Yarn V2/3/4',
123
- installCommand: 'add',
124
- installAllCommand: 'yarn install',
125
- buildCommand: 'yarn build',
126
- runScriptCommand: 'yarn',
127
- flags: '',
128
- forceInstallFlag: '--force',
129
- devDependencyFlag: '--dev',
130
- detect: (cwd) => {
131
- try {
132
- return fs
133
- .readFileSync(path.join(cwd, 'yarn.lock'), 'utf-8')
134
- .slice(0, 500)
135
- .includes('__metadata');
136
- }
137
- catch (e) {
138
- return false;
139
- }
140
- },
141
- addOverride: async (pkgName, pkgVersion) => {
142
- const packageDotJson = await getPackageJson();
143
- if (!packageDotJson) {
144
- return;
145
- }
146
- const resolutions = packageDotJson.resolutions || {};
147
- await updatePackageJson({
148
- ...packageDotJson,
149
- resolutions: {
150
- ...resolutions,
151
- [pkgName]: pkgVersion,
152
- },
153
- });
154
- },
155
- };
156
- export const PNPM = {
157
- id: 'pnpm',
158
- name: 'pnpm',
159
- label: 'PNPM',
160
- installCommand: 'add',
161
- installAllCommand: 'pnpm install',
162
- buildCommand: 'pnpm build',
163
- runScriptCommand: 'pnpm',
164
- flags: '--ignore-workspace-root-check',
165
- forceInstallFlag: '--force',
166
- devDependencyFlag: '--save-dev',
167
- detect: (cwd) => {
168
- try {
169
- return fs.existsSync(path.join(cwd, 'pnpm-lock.yaml'));
170
- }
171
- catch (e) {
172
- return false;
173
- }
174
- },
175
- addOverride: async (pkgName, pkgVersion) => {
176
- const packageDotJson = await getPackageJson();
177
- if (!packageDotJson) {
178
- return;
179
- }
180
- const pnpm = packageDotJson.pnpm || {};
181
- const overrides = pnpm.overrides || {};
182
- await updatePackageJson({
183
- ...packageDotJson,
184
- pnpm: {
185
- ...pnpm,
186
- overrides: {
187
- ...overrides,
188
- [pkgName]: pkgVersion,
189
- },
190
- },
191
- });
192
- },
193
- };
194
- export const NPM = {
195
- id: 'npm',
196
- name: 'npm',
197
- label: 'NPM',
198
- installCommand: 'install',
199
- installAllCommand: 'npm ci',
200
- buildCommand: 'npm run build',
201
- runScriptCommand: 'npm run',
202
- flags: '',
203
- forceInstallFlag: '--force',
204
- devDependencyFlag: '--save-dev',
205
- detect: (cwd) => {
206
- try {
207
- return fs.existsSync(path.join(cwd, 'package-lock.json'));
208
- }
209
- catch (e) {
210
- return false;
211
- }
212
- },
213
- addOverride: async (pkgName, pkgVersion) => {
214
- const packageDotJson = await getPackageJson();
215
- if (!packageDotJson) {
216
- return;
217
- }
218
- const overrides = packageDotJson.overrides || {};
219
- await updatePackageJson({
220
- ...packageDotJson,
221
- overrides: {
222
- ...overrides,
223
- [pkgName]: pkgVersion,
224
- },
225
- });
226
- },
227
- };
228
- export const packageManagers = [NPM, YARN_V1, YARN_V2, PNPM, BUN, DENO];
229
- export function _detectPackageManger(cwd) {
230
- const foundPackageMangers = packageManagers.filter((packageManager) => packageManager.detect(cwd));
231
- // Only consider a package manager detected if we found exactly one.
232
- // If we find more than one, we should not make any assumptions.
233
- if (foundPackageMangers.length === 1) {
234
- return foundPackageMangers[0];
235
- }
236
- return null;
237
- }
238
- // Get the package manager for the current project
239
- // Uses a global cache to avoid prompting the user multiple times
240
- export async function getPackageManager(cwd = process.cwd(), specifiedPackageManager, errorIfNotFound = false) {
241
- const globalWizard = global;
242
- if (globalWizard._gt_wizard_cached_package_manager) {
243
- return globalWizard._gt_wizard_cached_package_manager;
244
- }
245
- if (specifiedPackageManager) {
246
- const packageManager = packageManagers.find((packageManager) => packageManager.id === specifiedPackageManager);
247
- if (packageManager) {
248
- globalWizard._gt_wizard_cached_package_manager = packageManager;
249
- return packageManager;
250
- }
251
- }
252
- const detectedPackageManager = _detectPackageManger(cwd);
253
- if (detectedPackageManager) {
254
- globalWizard._gt_wizard_cached_package_manager = detectedPackageManager;
255
- return detectedPackageManager;
256
- }
257
- if (errorIfNotFound) {
258
- throw new NoPackageManagerError('No package manager found');
259
- }
260
- const selectedPackageManager = await promptSelect({
261
- message: 'Please select your package manager.',
262
- options: packageManagers.map((packageManager) => ({
263
- value: packageManager,
264
- label: packageManager.label,
265
- })),
266
- });
267
- globalWizard._gt_wizard_cached_package_manager = selectedPackageManager;
268
- return selectedPackageManager;
269
- }
@@ -1,6 +0,0 @@
1
- import { Settings } from '../types/index.js';
2
- /**
3
- * Processes all translated MD/MDX files to add explicit anchor IDs
4
- * This preserves navigation links when headings are translated
5
- */
6
- export default function processAnchorIds(settings: Settings): Promise<void>;
@@ -1,47 +0,0 @@
1
- import { addExplicitAnchorIds, extractHeadingInfo, } from './addExplicitAnchorIds.js';
2
- import { readFile } from '../fs/findFilepath.js';
3
- import { createFileMapping } from '../formats/files/fileMapping.js';
4
- import * as fs from 'fs';
5
- /**
6
- * Processes all translated MD/MDX files to add explicit anchor IDs
7
- * This preserves navigation links when headings are translated
8
- */
9
- export default async function processAnchorIds(settings) {
10
- if (!settings.files)
11
- return;
12
- const { resolvedPaths, placeholderPaths, transformPaths } = settings.files;
13
- const fileMapping = createFileMapping(resolvedPaths, placeholderPaths, transformPaths, settings.locales, settings.defaultLocale);
14
- // Process each locale's translated files
15
- const processPromises = Object.entries(fileMapping)
16
- .filter(([locale, filesMap]) => locale !== settings.defaultLocale) // Skip default locale
17
- .map(async ([locale, filesMap]) => {
18
- // Get all translated files that are md or mdx
19
- const translatedFiles = Object.values(filesMap).filter((path) => path && (path.endsWith('.md') || path.endsWith('.mdx')));
20
- for (const translatedPath of translatedFiles) {
21
- try {
22
- // Check if translated file exists before processing
23
- if (!fs.existsSync(translatedPath)) {
24
- continue;
25
- }
26
- // Find the corresponding source file
27
- const sourcePath = Object.keys(filesMap).find((key) => filesMap[key] === translatedPath);
28
- if (!sourcePath) {
29
- continue;
30
- }
31
- // Extract heading info from source file
32
- const sourceContent = readFile(sourcePath);
33
- const sourceHeadingMap = extractHeadingInfo(sourceContent);
34
- // Read translated file and apply anchor IDs
35
- const translatedContent = readFile(translatedPath);
36
- const result = addExplicitAnchorIds(translatedContent, sourceHeadingMap, settings, sourcePath, translatedPath);
37
- if (result.hasChanges) {
38
- fs.writeFileSync(translatedPath, result.content, 'utf8');
39
- }
40
- }
41
- catch (error) {
42
- console.warn(`Failed to process IDs for ${translatedPath}: ${error instanceof Error ? error.message : String(error)}`);
43
- }
44
- }
45
- });
46
- await Promise.all(processPromises);
47
- }
@@ -1,6 +0,0 @@
1
- /**
2
- * Processes content to escape curl commands within tick marks and existing escape strings
3
- * @param content - The content to process
4
- * @returns the processed content with escaped curl commands
5
- */
6
- export default function sanitizeFileContent(content: string): string;
@@ -1,29 +0,0 @@
1
- /**
2
- * Processes content to escape curl commands within tick marks and existing escape strings
3
- * @param content - The content to process
4
- * @returns the processed content with escaped curl commands
5
- */
6
- export default function sanitizeFileContent(content) {
7
- const ESCAPE_STRING = '_GT_INTERNAL_ESCAPE';
8
- const allTickMarkRegex = /`([^`]*)`/g;
9
- let processedContent = content;
10
- // First, escape any existing tick marks followed by _GT_INTERNAL_ESCAPE
11
- // This protects pre-existing escapes
12
- processedContent = processedContent.replace(new RegExp('`' + ESCAPE_STRING, 'g'), '`' + ESCAPE_STRING + ESCAPE_STRING);
13
- // Then find ALL tick mark pairs and process them individually
14
- // This approach is more reliable than negative lookahead with modified content
15
- processedContent = processedContent.replace(allTickMarkRegex, (match, innerContent) => {
16
- // Skip if this already starts with our escape string (protected or already processed)
17
- if (innerContent.startsWith(ESCAPE_STRING)) {
18
- return match;
19
- }
20
- // Check if the content contains a curl command
21
- if (/\bcurl\b/i.test(innerContent)) {
22
- // Insert escape string after opening tick
23
- return '`' + ESCAPE_STRING + innerContent + '`';
24
- }
25
- // Return original match if no curl command found
26
- return match;
27
- });
28
- return processedContent;
29
- }
@@ -1,10 +0,0 @@
1
- /**
2
- * Validates if an MDX file content can be parsed as a valid AST
3
- * @param content - The MDX file content to validate
4
- * @param filePath - The file path for error reporting
5
- * @returns object with isValid boolean and optional error message
6
- */
7
- export declare function isValidMdx(content: string, filePath: string): {
8
- isValid: boolean;
9
- error?: string;
10
- };
@@ -1,25 +0,0 @@
1
- import { unified } from 'unified';
2
- import remarkParse from 'remark-parse';
3
- import remarkMdx from 'remark-mdx';
4
- import remarkFrontmatter from 'remark-frontmatter';
5
- /**
6
- * Validates if an MDX file content can be parsed as a valid AST
7
- * @param content - The MDX file content to validate
8
- * @param filePath - The file path for error reporting
9
- * @returns object with isValid boolean and optional error message
10
- */
11
- export function isValidMdx(content, filePath) {
12
- try {
13
- const parseProcessor = unified()
14
- .use(remarkParse)
15
- .use(remarkFrontmatter, ['yaml', 'toml'])
16
- .use(remarkMdx);
17
- const ast = parseProcessor.parse(content);
18
- parseProcessor.runSync(ast);
19
- return { isValid: true };
20
- }
21
- catch (error) {
22
- const errorMessage = error instanceof Error ? error.message : String(error);
23
- return { isValid: false, error: errorMessage };
24
- }
25
- }