gtx-cli 2.5.40 → 2.5.41

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.5.41
4
+
5
+ ### Patch Changes
6
+
7
+ - [#929](https://github.com/generaltranslation/gt/pull/929) [`ca7b778`](https://github.com/generaltranslation/gt/commit/ca7b7785cc28817c154900933ac7be2098a10faf) Thanks [@fernando-aviles](https://github.com/fernando-aviles)! - Auto-update OpenAPI spec paths when specs are modified
8
+
3
9
  ## 2.5.40
4
10
 
5
11
  ### Patch Changes
@@ -1 +1 @@
1
- export declare const PACKAGE_VERSION = "2.5.40";
1
+ export declare const PACKAGE_VERSION = "2.5.41";
@@ -1,2 +1,2 @@
1
1
  // This file is auto-generated. Do not edit manually.
2
- export const PACKAGE_VERSION = '2.5.40';
2
+ export const PACKAGE_VERSION = '2.5.41';
@@ -323,8 +323,24 @@ function resolveSpec(explicitPath, specs, filePath, configDir, warnings, refDesc
323
323
  const normalizedSpecPath = normalizeSlashes(spec.absPath);
324
324
  return candidates.some((candidate) => samePath(candidate, normalizedSpecPath));
325
325
  });
326
- if (foundSpec)
327
- return foundSpec;
326
+ if (foundSpec) {
327
+ if (specHasMatch(foundSpec, match)) {
328
+ return foundSpec;
329
+ }
330
+ const alternatives = specs.filter((spec) => spec !== foundSpec && specHasMatch(spec, match));
331
+ if (alternatives.length === 1) {
332
+ warnings.add(`OpenAPI reference ${refDescription} in ${filePath} points to ${foundSpec.configPath}, but the entry was not found there. Using ${alternatives[0].configPath} instead.`);
333
+ return alternatives[0];
334
+ }
335
+ if (alternatives.length > 1) {
336
+ warnings.add(`OpenAPI reference ${refDescription} in ${filePath} points to ${foundSpec.configPath}, but the entry was not found there and matches multiple specs (${alternatives
337
+ .map((spec) => spec.configPath)
338
+ .join(', ')}). Skipping localization for this reference.`);
339
+ return null;
340
+ }
341
+ warnings.add(`OpenAPI reference ${refDescription} in ${filePath} points to ${foundSpec.configPath}, but the entry was not found in any configured spec. Skipping localization for this reference.`);
342
+ return null;
343
+ }
328
344
  const explicitWithoutExt = stripExtension(normalizedExplicit);
329
345
  const explicitBase = path.basename(normalizedExplicit);
330
346
  const explicitBaseWithoutExt = stripExtension(explicitBase);
@@ -369,6 +385,15 @@ function resolveSpec(explicitPath, specs, filePath, configDir, warnings, refDesc
369
385
  warnings.add(`OpenAPI reference ${refDescription} in ${filePath} was not found in any configured spec. Skipping localization for this reference.`);
370
386
  return null;
371
387
  }
388
+ function specHasMatch(spec, match) {
389
+ if (match.type === 'schema') {
390
+ return spec.schemas.has(match.key);
391
+ }
392
+ if (match.type === 'webhook') {
393
+ return spec.webhooks.has(match.key);
394
+ }
395
+ return spec.operations.has(match.key);
396
+ }
372
397
  /**
373
398
  * Map a spec to the locale-specific file path when available and normalize it
374
399
  * for frontmatter. Falls back to the source spec when the locale copy does
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gtx-cli",
3
- "version": "2.5.40",
3
+ "version": "2.5.41",
4
4
  "main": "dist/index.js",
5
5
  "bin": "dist/main.js",
6
6
  "files": [