gtx-cli 2.5.21 → 2.5.23
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 +13 -0
- package/dist/utils/processOpenApi.js +18 -17
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,18 @@
|
|
|
1
1
|
# gtx-cli
|
|
2
2
|
|
|
3
|
+
## 2.5.23
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies [[`3e8ceb4`](https://github.com/generaltranslation/gt/commit/3e8ceb4526530d38eae469b05e8bf273d5ca05ac)]:
|
|
8
|
+
- generaltranslation@8.1.0
|
|
9
|
+
|
|
10
|
+
## 2.5.22
|
|
11
|
+
|
|
12
|
+
### Patch Changes
|
|
13
|
+
|
|
14
|
+
- [#870](https://github.com/generaltranslation/gt/pull/870) [`4291258`](https://github.com/generaltranslation/gt/commit/42912587a51da045c0b578ac71699fda4a8fcc26) Thanks [@fernando-aviles](https://github.com/fernando-aviles)! - Persist style of YAML frontmatter when applying Mintlify OpenAPI postprocessing
|
|
15
|
+
|
|
3
16
|
## 2.5.21
|
|
4
17
|
|
|
5
18
|
### Patch Changes
|
|
@@ -3,7 +3,7 @@ import path from 'node:path';
|
|
|
3
3
|
import { unified } from 'unified';
|
|
4
4
|
import remarkParse from 'remark-parse';
|
|
5
5
|
import remarkFrontmatter from 'remark-frontmatter';
|
|
6
|
-
import YAML from 'yaml';
|
|
6
|
+
import YAML, { isMap, isScalar } from 'yaml';
|
|
7
7
|
import { logger } from '../console/logger.js';
|
|
8
8
|
import { createFileMapping } from '../formats/files/fileMapping.js';
|
|
9
9
|
const HTTP_METHODS = new Set([
|
|
@@ -184,18 +184,18 @@ function rewriteFrontmatter(content, filePath, locale, specs, fileMapping, warni
|
|
|
184
184
|
const start = yamlNode.position.start.offset;
|
|
185
185
|
const end = yamlNode.position.end.offset;
|
|
186
186
|
const frontmatterRaw = yamlNode.value || '';
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
}
|
|
191
|
-
|
|
187
|
+
const doc = YAML.parseDocument(frontmatterRaw, {
|
|
188
|
+
prettyErrors: false,
|
|
189
|
+
keepSourceTokens: true,
|
|
190
|
+
});
|
|
191
|
+
if (doc.errors?.length)
|
|
192
192
|
return null;
|
|
193
|
-
|
|
194
|
-
if (!parsed || typeof parsed !== 'object')
|
|
193
|
+
if (!isMap(doc.contents))
|
|
195
194
|
return null;
|
|
196
195
|
let changed = false;
|
|
197
|
-
|
|
198
|
-
|
|
196
|
+
const openapiNode = doc.get('openapi', true);
|
|
197
|
+
if (isScalar(openapiNode) && typeof openapiNode.value === 'string') {
|
|
198
|
+
const parsedValue = parseOpenApiValue(openapiNode.value);
|
|
199
199
|
if (parsedValue) {
|
|
200
200
|
const matchKey = parsedValue.kind === 'operation'
|
|
201
201
|
? {
|
|
@@ -208,22 +208,23 @@ function rewriteFrontmatter(content, filePath, locale, specs, fileMapping, warni
|
|
|
208
208
|
const descriptor = formatOpenApiDescriptor(parsedValue);
|
|
209
209
|
const localizedSpecPath = resolveLocalizedSpecPath(spec, locale, fileMapping, configDir, parsedValue.specPath || spec.configPath);
|
|
210
210
|
const newValue = `${localizedSpecPath} ${descriptor}`.trim();
|
|
211
|
-
if (newValue !==
|
|
212
|
-
|
|
211
|
+
if (newValue !== openapiNode.value) {
|
|
212
|
+
doc.set('openapi', newValue);
|
|
213
213
|
changed = true;
|
|
214
214
|
}
|
|
215
215
|
}
|
|
216
216
|
}
|
|
217
217
|
}
|
|
218
|
-
|
|
219
|
-
|
|
218
|
+
const schemaNode = doc.get('openapi-schema', true);
|
|
219
|
+
if (isScalar(schemaNode) && typeof schemaNode.value === 'string') {
|
|
220
|
+
const parsedValue = parseSchemaValue(schemaNode.value);
|
|
220
221
|
if (parsedValue) {
|
|
221
222
|
const spec = resolveSpec(parsedValue.specPath, specs, filePath, configDir, warnings, `schema "${parsedValue.schemaName}"`, { type: 'schema', key: parsedValue.schemaName });
|
|
222
223
|
if (spec) {
|
|
223
224
|
const localizedSpecPath = resolveLocalizedSpecPath(spec, locale, fileMapping, configDir, parsedValue.specPath || spec.configPath);
|
|
224
225
|
const newValue = `${localizedSpecPath} ${parsedValue.schemaName}`.trim();
|
|
225
|
-
if (newValue !==
|
|
226
|
-
|
|
226
|
+
if (newValue !== schemaNode.value) {
|
|
227
|
+
doc.set('openapi-schema', newValue);
|
|
227
228
|
changed = true;
|
|
228
229
|
}
|
|
229
230
|
}
|
|
@@ -231,7 +232,7 @@ function rewriteFrontmatter(content, filePath, locale, specs, fileMapping, warni
|
|
|
231
232
|
}
|
|
232
233
|
if (!changed)
|
|
233
234
|
return null;
|
|
234
|
-
const fmString =
|
|
235
|
+
const fmString = doc.toString().trimEnd();
|
|
235
236
|
const rebuilt = `${content.slice(0, start)}---\n${fmString}\n---${content.slice(end)}`;
|
|
236
237
|
return { changed, content: rebuilt };
|
|
237
238
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "gtx-cli",
|
|
3
|
-
"version": "2.5.
|
|
3
|
+
"version": "2.5.23",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"bin": "dist/main.js",
|
|
6
6
|
"files": [
|
|
@@ -104,7 +104,7 @@
|
|
|
104
104
|
"unified": "^11.0.5",
|
|
105
105
|
"unist-util-visit": "^5.0.0",
|
|
106
106
|
"yaml": "^2.8.0",
|
|
107
|
-
"generaltranslation": "8.0
|
|
107
|
+
"generaltranslation": "8.1.0"
|
|
108
108
|
},
|
|
109
109
|
"devDependencies": {
|
|
110
110
|
"@babel/types": "^7.28.4",
|