gt 2.14.30 → 2.14.31

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 (34) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/dist/api/collectUserEditDiffs.js +3 -1
  3. package/dist/bin/bin-main.js +1 -1
  4. package/dist/formats/files/aggregateFiles.js +2 -2
  5. package/dist/formats/json/flattenJson.js +1 -1
  6. package/dist/fs/clearLocaleDirs.js +1 -1
  7. package/dist/fs/config/loadConfig.js +1 -1
  8. package/dist/fs/determineFramework/matchSetupPyDependency.js +1 -1
  9. package/dist/fs/loadJSON.js +1 -1
  10. package/dist/generated/version.d.ts +1 -1
  11. package/dist/generated/version.js +1 -1
  12. package/dist/git/branches.d.ts +1 -1
  13. package/dist/git/branches.js +1 -1
  14. package/dist/hooks/postProcess.js +11 -5
  15. package/dist/react/config/createESBuildConfig.js +2 -2
  16. package/dist/react/jsx/utils/jsxParsing/addGTIdentifierToSyntaxTree.js +1 -2
  17. package/dist/react/jsx/utils/jsxParsing/multiplication/multiplyJsxTree.js +0 -1
  18. package/dist/react/jsx/utils/jsxParsing/parseJsx.js +0 -2
  19. package/dist/types/parsing.d.ts +1 -1
  20. package/dist/utils/addExplicitAnchorIds.js +1 -1
  21. package/dist/utils/credentials.js +4 -2
  22. package/dist/utils/fetch.d.ts +1 -1
  23. package/dist/utils/localizeRelativeAssets.js +1 -1
  24. package/dist/utils/localizeStaticUrls.js +1 -8
  25. package/dist/utils/packageInfo.js +1 -1
  26. package/dist/utils/packageJson.js +2 -2
  27. package/dist/utils/packageManager.js +6 -6
  28. package/dist/utils/processAnchorIds.js +2 -2
  29. package/dist/utils/sharedStaticAssets.js +11 -5
  30. package/dist/utils/validateMdx.d.ts +1 -1
  31. package/dist/utils/validateMdx.js +1 -1
  32. package/dist/utils/wrapPlainUrls.js +1 -1
  33. package/dist/workflows/steps/BranchStep.js +3 -1
  34. package/package.json +3 -3
package/CHANGELOG.md CHANGED
@@ -1,5 +1,13 @@
1
1
  # gtx-cli
2
2
 
3
+ ## 2.14.31
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies [[`fecaf93`](https://github.com/generaltranslation/gt/commit/fecaf93d1dcae65598b3f81b8eeabaeb35be13c6)]:
8
+ - generaltranslation@8.2.11
9
+ - @generaltranslation/python-extractor@0.2.17
10
+
3
11
  ## 2.14.30
4
12
 
5
13
  ### Patch Changes
@@ -113,7 +113,9 @@ export async function collectAndSendUserEditDiffs(files, settings) {
113
113
  try {
114
114
  await fs.promises.unlink(tempServerFile);
115
115
  }
116
- catch { }
116
+ catch {
117
+ // Ignore cleanup errors for temporary comparison files.
118
+ }
117
119
  if (diff && diff.trim().length > 0) {
118
120
  const rawLocalContent = await fs.promises.readFile(c.outputPath, 'utf8');
119
121
  // For JSON files with jsonSchema config, extract to composite format
@@ -45,7 +45,7 @@ function routeToBinary() {
45
45
  chmodSync(binaryPath, 0o755); // Make executable
46
46
  }
47
47
  }
48
- catch (error) {
48
+ catch {
49
49
  // If we can't check/fix permissions, continue anyway
50
50
  // The spawn might still work or give a more meaningful error
51
51
  }
@@ -70,7 +70,7 @@ export async function aggregateFiles(settings) {
70
70
  try {
71
71
  JSON.parse(content);
72
72
  }
73
- catch (e) {
73
+ catch {
74
74
  logger.warn(`Skipping ${relativePath}: JSON file is not parsable`);
75
75
  recordWarning('skipped_file', relativePath, 'JSON file is not parsable');
76
76
  return null;
@@ -156,7 +156,7 @@ export async function aggregateFiles(settings) {
156
156
  try {
157
157
  YAML.parse(content);
158
158
  }
159
- catch (e) {
159
+ catch {
160
160
  logger.warn(`Skipping ${relativePath}: YAML file is not parsable`);
161
161
  recordWarning('skipped_file', relativePath, 'YAML file is not parsable');
162
162
  return null;
@@ -24,7 +24,7 @@ export function flattenJson(json, jsonPaths) {
24
24
  extractedJson[result.pointer] = result.value;
25
25
  });
26
26
  }
27
- catch (error) {
27
+ catch {
28
28
  logger.error(`Error with JSONPath pattern: ${jsonPath}`);
29
29
  }
30
30
  }
@@ -120,7 +120,7 @@ async function cleanupEmptyDirs(dirPath) {
120
120
  await fs.rmdir(dirPath);
121
121
  }
122
122
  }
123
- catch (error) {
123
+ catch {
124
124
  // Ignore errors - directory might not exist or might not be empty
125
125
  }
126
126
  }
@@ -3,7 +3,7 @@ export function loadConfig(filepath) {
3
3
  try {
4
4
  return JSON.parse(fs.readFileSync(filepath, 'utf-8'));
5
5
  }
6
- catch (error) {
6
+ catch {
7
7
  return {};
8
8
  }
9
9
  }
@@ -16,7 +16,7 @@ export function matchSetupPyDependency(content) {
16
16
  continue;
17
17
  // Find the opening bracket after the keyword
18
18
  const afterKeyword = content.slice(keywordIndex + keyword.length);
19
- const bracketMatch = afterKeyword.match(/\s*=\s*[\[{]/);
19
+ const bracketMatch = afterKeyword.match(/\s*=\s*(?:\[|{)/);
20
20
  if (!bracketMatch)
21
21
  continue;
22
22
  const openBracket = afterKeyword[bracketMatch.index + bracketMatch[0].length - 1];
@@ -10,7 +10,7 @@ export default function loadJSON(filepath) {
10
10
  const data = fs.readFileSync(path.resolve(filepath), 'utf-8');
11
11
  return JSON.parse(data);
12
12
  }
13
- catch (error) {
13
+ catch {
14
14
  // Return null if the file is not found or JSON parsing fails
15
15
  return null;
16
16
  }
@@ -1 +1 @@
1
- export declare const PACKAGE_VERSION = "2.14.30";
1
+ export declare const PACKAGE_VERSION = "2.14.31";
@@ -1,2 +1,2 @@
1
1
  // This file is auto-generated. Do not edit manually.
2
- export const PACKAGE_VERSION = '2.14.30';
2
+ export const PACKAGE_VERSION = '2.14.31';
@@ -3,5 +3,5 @@ export declare function getCurrentBranch(remoteName: string): Promise<{
3
3
  defaultBranch: boolean;
4
4
  defaultBranchName: string;
5
5
  } | null>;
6
- export declare function getIncomingBranches(remoteName: string): Promise<string[]>;
6
+ export declare function getIncomingBranches(_remoteName: string): Promise<string[]>;
7
7
  export declare function getCheckedOutBranches(remoteName: string): Promise<string[]>;
@@ -21,7 +21,7 @@ export async function getCurrentBranch(remoteName) {
21
21
  return null;
22
22
  }
23
23
  }
24
- export async function getIncomingBranches(remoteName) {
24
+ export async function getIncomingBranches(_remoteName) {
25
25
  try {
26
26
  // Get merge commits into the current branch
27
27
  const { stdout } = await execAsync('git', [
@@ -8,16 +8,20 @@ export async function detectFormatter() {
8
8
  await import('prettier');
9
9
  return 'prettier';
10
10
  }
11
- catch { }
11
+ catch {
12
+ // Prettier is optional.
13
+ }
12
14
  // Try ESLint
13
15
  try {
14
16
  await import('eslint');
15
17
  return 'eslint';
16
18
  }
17
- catch { }
19
+ catch {
20
+ // ESLint is optional.
21
+ }
18
22
  // Try Biome
19
23
  try {
20
- return await new Promise((resolve, reject) => {
24
+ return await new Promise((resolve) => {
21
25
  const child = spawn('npx', ['@biomejs/biome', '--version'], {
22
26
  stdio: 'ignore',
23
27
  });
@@ -34,7 +38,9 @@ export async function detectFormatter() {
34
38
  });
35
39
  });
36
40
  }
37
- catch { }
41
+ catch {
42
+ // Biome is optional.
43
+ }
38
44
  return null;
39
45
  }
40
46
  export async function formatFiles(filesUpdated, formatter) {
@@ -63,7 +69,7 @@ export async function formatFiles(filesUpdated, formatter) {
63
69
  if (detectedFormatter === 'biome') {
64
70
  logger.message(chalk.dim('Cleaning up with biome...'));
65
71
  try {
66
- await new Promise((resolve, reject) => {
72
+ await new Promise((resolve) => {
67
73
  const args = [
68
74
  '@biomejs/biome',
69
75
  'format',
@@ -88,7 +88,7 @@ export default function createESBuildConfig(config = {}) {
88
88
  const realPath = fs.realpathSync(fullPath);
89
89
  return realPath;
90
90
  }
91
- catch (_) {
91
+ catch {
92
92
  continue;
93
93
  }
94
94
  }
@@ -98,7 +98,7 @@ export default function createESBuildConfig(config = {}) {
98
98
  const realPath = fs.realpathSync(resolvedPath);
99
99
  return { path: realPath };
100
100
  }
101
- catch (err) {
101
+ catch {
102
102
  const hasExtension = extensions.some((ext) => resolvedPath.endsWith(ext));
103
103
  if (!hasExtension) {
104
104
  const resolvedWithExt = resolveWithExtensions(resolvedPath);
@@ -33,8 +33,7 @@ function constructGTProp(type, props, id) {
33
33
  // Branch
34
34
  }
35
35
  else if (type === BRANCH_COMPONENT) {
36
- // eslint-disable-next-line @typescript-eslint/no-unused-vars, no-unused-vars
37
- const { children, branch, ...allBranches } = props;
36
+ const { children: _children, branch: _branch, ...allBranches } = props;
38
37
  // Filter out data-* attributes injected by build tools
39
38
  const branches = Object.fromEntries(Object.entries(allBranches).filter(([key]) => !key.startsWith(DATA_ATTR_PREFIX)));
40
39
  const resultBranches = Object.entries(branches).reduce((acc, [branchName, branch]) => {
@@ -58,7 +58,6 @@ function multiplyBranches(branches) {
58
58
  else {
59
59
  // Replace the multiplication node with the sub branch
60
60
  parent[key] = subBranch;
61
- // eslint-disable-next-line no-undef
62
61
  newBranch = structuredClone(branch);
63
62
  // Add the new branch to the list
64
63
  branchQueue.push(newBranch);
@@ -591,7 +591,6 @@ function parseJSXElement({ node, originalName, scopeNode, updates, config, state
591
591
  dataFormat: 'JSX',
592
592
  source: cleanedTree,
593
593
  metadata: {
594
- // eslint-disable-next-line no-undef
595
594
  ...structuredClone(metadata),
596
595
  context,
597
596
  staticId: temporaryDeriveId,
@@ -604,7 +603,6 @@ function parseJSXElement({ node, originalName, scopeNode, updates, config, state
604
603
  dataFormat: 'JSX',
605
604
  source: cleanedTree,
606
605
  metadata: {
607
- // eslint-disable-next-line no-undef
608
606
  ...structuredClone(metadata),
609
607
  ...(derivableTracker.isDerivable && { staticId: temporaryDeriveId }),
610
608
  },
@@ -1,4 +1,4 @@
1
- import { SupportedFileExtension } from './index.js';
1
+ import type { SupportedFileExtension } from './index.js';
2
2
  /**
3
3
  * For monorepo projects, checking for extra exports fields in resolved internal packages.
4
4
  * For instance, an exported path may be labeled as 'browser' or 'module' or 'default'.
@@ -91,7 +91,7 @@ function parseHeadingContent(text) {
91
91
  /**
92
92
  * Checks if a heading is already wrapped in a div with id
93
93
  */
94
- function hasExplicitId(heading, ast) {
94
+ function hasExplicitId(heading, _ast) {
95
95
  const lastChild = heading.children[heading.children.length - 1];
96
96
  if (lastChild?.type === 'text') {
97
97
  return /(\{#[^}]+\}|\\\{#[^}]+\\\}|\[[^\]]+\])\s*$/.test(lastChild.value);
@@ -15,11 +15,13 @@ export async function retrieveCredentials(settings, keyType) {
15
15
  logger.message(`${chalk.dim(`If the browser window didn't open automatically, please open the following link:`)}\n\n${chalk.cyan(urlToOpen)}`);
16
16
  const spinner = logger.createSpinner('dots');
17
17
  spinner.start('Waiting for response from dashboard...');
18
- const credentials = await new Promise(async (resolve, reject) => {
18
+ const credentials = await new Promise(async (resolve) => {
19
19
  const interval = setInterval(async () => {
20
20
  // Ping the dashboard to see if the credentials are set
21
21
  try {
22
- const res = await apiRequest(settings.baseUrl, `/cli/wizard/${sessionId}`, { method: 'GET' });
22
+ const res = await apiRequest(settings.baseUrl, `/cli/wizard/${sessionId}`, {
23
+ method: 'GET',
24
+ });
23
25
  if (res.status === 200) {
24
26
  const data = await res.json();
25
27
  resolve(data);
@@ -5,7 +5,7 @@
5
5
  *
6
6
  * Encapsulates URL construction, headers, and JSON parsing.
7
7
  */
8
- export default function apiRequest<T>(baseUrl: string, endpoint: string, options?: {
8
+ export default function apiRequest(baseUrl: string, endpoint: string, options?: {
9
9
  body?: unknown;
10
10
  method?: 'GET' | 'POST' | 'DELETE';
11
11
  }): Promise<Response>;
@@ -140,7 +140,7 @@ export default async function localizeRelativeAssets(settings, targetLocales, in
140
140
  const cwd = process.cwd();
141
141
  const processPromises = Object.entries(fileMapping)
142
142
  .filter(([locale]) => locales.includes(locale))
143
- .map(async ([locale, filesMap]) => {
143
+ .map(async ([, filesMap]) => {
144
144
  const reverseMap = new Map();
145
145
  for (const [sourcePath, targetPath] of Object.entries(filesMap)) {
146
146
  reverseMap.set(targetPath, sourcePath);
@@ -71,7 +71,7 @@ export default async function localizeStaticUrls(settings, targetLocales, includ
71
71
  }
72
72
  // Then process all other locales from fileMapping
73
73
  const mappingPromises = Object.entries(fileMapping)
74
- .filter(([locale, filesMap]) => locales.includes(locale)) // Filter by target locales
74
+ .filter(([locale]) => locales.includes(locale)) // Filter by target locales
75
75
  .map(async ([locale, filesMap]) => {
76
76
  // Get all files that are md or mdx
77
77
  const targetFiles = Object.values(filesMap).filter((p) => (p.endsWith('.md') || p.endsWith('.mdx')) &&
@@ -432,13 +432,6 @@ exclude = [], baseDomain) {
432
432
  // Use AST-based transformation for MDX files
433
433
  return transformMdxUrls(file, defaultLocale, targetLocale, hideDefaultLocale, pattern, exclude, baseDomain || '');
434
434
  }
435
- function cleanPath(path) {
436
- let cleanedPath = path.startsWith('/') ? path.slice(1) : path;
437
- cleanedPath = cleanedPath.endsWith('/')
438
- ? cleanedPath.slice(0, -1)
439
- : cleanedPath;
440
- return cleanedPath;
441
- }
442
435
  function checkIfPathMatchesPattern(originalUrlArray, patternHeadArray) {
443
436
  // check if the pattern head matches the original path
444
437
  for (let i = 0; i < patternHeadArray.length; i++) {
@@ -11,7 +11,7 @@ export async function getPackageInfo(packageName) {
11
11
  }
12
12
  return undefined;
13
13
  }
14
- catch (error) {
14
+ catch {
15
15
  return undefined;
16
16
  }
17
17
  }
@@ -15,7 +15,7 @@ export async function searchForPackageJson(cwd = process.cwd()) {
15
15
  try {
16
16
  return JSON.parse(await fs.promises.readFile(packageJsonPath, 'utf8'));
17
17
  }
18
- catch (error) {
18
+ catch {
19
19
  return null;
20
20
  }
21
21
  }
@@ -28,7 +28,7 @@ export async function getPackageJson(cwd = process.cwd()) {
28
28
  try {
29
29
  return JSON.parse(await fs.promises.readFile(packageJsonPath, 'utf8'));
30
30
  }
31
- catch (error) {
31
+ catch {
32
32
  return null;
33
33
  }
34
34
  }
@@ -24,7 +24,7 @@ export const BUN = {
24
24
  try {
25
25
  return fs.existsSync(path.join(cwd, lockFile));
26
26
  }
27
- catch (e) {
27
+ catch {
28
28
  return false;
29
29
  }
30
30
  }),
@@ -59,7 +59,7 @@ export const DENO = {
59
59
  try {
60
60
  return fs.existsSync(path.join(cwd, 'deno.lock'));
61
61
  }
62
- catch (e) {
62
+ catch {
63
63
  return false;
64
64
  }
65
65
  },
@@ -96,7 +96,7 @@ export const YARN_V1 = {
96
96
  .slice(0, 500)
97
97
  .includes('yarn lockfile v1');
98
98
  }
99
- catch (e) {
99
+ catch {
100
100
  return false;
101
101
  }
102
102
  },
@@ -134,7 +134,7 @@ export const YARN_V2 = {
134
134
  .slice(0, 500)
135
135
  .includes('__metadata');
136
136
  }
137
- catch (e) {
137
+ catch {
138
138
  return false;
139
139
  }
140
140
  },
@@ -168,7 +168,7 @@ export const PNPM = {
168
168
  try {
169
169
  return fs.existsSync(path.join(cwd, 'pnpm-lock.yaml'));
170
170
  }
171
- catch (e) {
171
+ catch {
172
172
  return false;
173
173
  }
174
174
  },
@@ -206,7 +206,7 @@ export const NPM = {
206
206
  try {
207
207
  return fs.existsSync(path.join(cwd, 'package-lock.json'));
208
208
  }
209
- catch (e) {
209
+ catch {
210
210
  return false;
211
211
  }
212
212
  },
@@ -24,8 +24,8 @@ export default async function processAnchorIds(settings, includeFiles) {
24
24
  }
25
25
  // Process each locale's translated files
26
26
  const processPromises = Object.entries(fileMapping)
27
- .filter(([locale, filesMap]) => locale !== settings.defaultLocale) // Skip default locale
28
- .map(async ([locale, filesMap]) => {
27
+ .filter(([locale]) => locale !== settings.defaultLocale) // Skip default locale
28
+ .map(async ([, filesMap]) => {
29
29
  // Get all translated files whose sources are md or mdx
30
30
  const mdFiles = Object.entries(filesMap).filter(([sourcePath, translatedPath]) => translatedPath &&
31
31
  sourceTypeByPath.has(sourcePath) &&
@@ -49,7 +49,9 @@ async function moveFile(src, dest) {
49
49
  try {
50
50
  await fs.promises.unlink(src);
51
51
  }
52
- catch { }
52
+ catch {
53
+ // Ignore cleanup errors for source files that were already moved.
54
+ }
53
55
  }
54
56
  else if (err && err.code === 'ENOENT') {
55
57
  // already moved or missing; ignore
@@ -118,7 +120,7 @@ function rewriteMdxContent(content, filePath, pathMap) {
118
120
  .use(remarkMdx);
119
121
  ast = processor.runSync(processor.parse(content));
120
122
  }
121
- catch (e) {
123
+ catch {
122
124
  return { content, changed: false };
123
125
  }
124
126
  const fileDir = path.dirname(filePath);
@@ -198,7 +200,7 @@ function rewriteMdxContent(content, filePath, pathMap) {
198
200
  out = '\n' + out;
199
201
  return { content: out, changed };
200
202
  }
201
- catch (e) {
203
+ catch {
202
204
  return { content, changed: false };
203
205
  }
204
206
  }
@@ -355,12 +357,16 @@ export default async function processSharedStaticAssets(settings) {
355
357
  const st = await fs.promises.stat(destAbs).catch(() => null);
356
358
  if (st && st.isFile()) {
357
359
  // Remove source if it still exists
358
- await fs.promises.unlink(abs).catch(() => { });
360
+ await fs.promises.unlink(abs).catch(() => {
361
+ // Ignore missing source files.
362
+ });
359
363
  await removeEmptyDirsUpwards(path.dirname(abs), cwd);
360
364
  continue;
361
365
  }
362
366
  }
363
- catch { }
367
+ catch {
368
+ // If stat/removal fails, fall through to the normal move path.
369
+ }
364
370
  await moveFile(abs, destAbs);
365
371
  await removeEmptyDirsUpwards(path.dirname(abs), cwd);
366
372
  }
@@ -4,7 +4,7 @@
4
4
  * @param filePath - The file path for error reporting
5
5
  * @returns object with isValid boolean and optional error message
6
6
  */
7
- export declare function isValidMdx(content: string, filePath: string): {
7
+ export declare function isValidMdx(content: string, _filePath: string): {
8
8
  isValid: boolean;
9
9
  error?: string;
10
10
  };
@@ -8,7 +8,7 @@ import remarkFrontmatter from 'remark-frontmatter';
8
8
  * @param filePath - The file path for error reporting
9
9
  * @returns object with isValid boolean and optional error message
10
10
  */
11
- export function isValidMdx(content, filePath) {
11
+ export function isValidMdx(content, _filePath) {
12
12
  try {
13
13
  const parseProcessor = unified()
14
14
  .use(remarkParse)
@@ -11,7 +11,7 @@ import { visit } from 'unist-util-visit';
11
11
  *
12
12
  */
13
13
  export default function wrapPlainUrls(content) {
14
- const URL_REGEX = /https?:\/\/[^\s<>\[\]]*[^\s<>\[\].,;:!?'"\]}>]/g;
14
+ const URL_REGEX = /https?:\/\/[^\s<>\u005b\u005d]*[^\s<>\u005b\u005d.,;:!?'"\u005d}>]/g;
15
15
  let ast;
16
16
  try {
17
17
  const processor = unified()
@@ -112,7 +112,9 @@ export class BranchStep extends WorkflowStep {
112
112
  });
113
113
  this.branchData.currentBranch = createBranchResult.branch;
114
114
  }
115
- catch { }
115
+ catch {
116
+ // The fallback branch may already exist.
117
+ }
116
118
  }
117
119
  }
118
120
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gt",
3
- "version": "2.14.30",
3
+ "version": "2.14.31",
4
4
  "main": "dist/index.js",
5
5
  "bin": "dist/main.js",
6
6
  "files": [
@@ -110,8 +110,8 @@
110
110
  "unified": "^11.0.5",
111
111
  "unist-util-visit": "^5.0.0",
112
112
  "yaml": "^2.8.0",
113
- "@generaltranslation/python-extractor": "0.2.16",
114
- "generaltranslation": "8.2.10",
113
+ "@generaltranslation/python-extractor": "0.2.17",
114
+ "generaltranslation": "8.2.11",
115
115
  "gt-remark": "1.0.7"
116
116
  },
117
117
  "devDependencies": {