docs-util: fixes following packages reorg (#9326)
- Typescript config aren't picked up properly anymore since they're moved to `_tsconfig.base.json` in the root. So, we now read the config from the config file. - Update Typescript version in the `utils` monorepo to match that of the root monorepo
This commit is contained in:
@@ -28,7 +28,7 @@
|
||||
"pluralize": "^8.0.0",
|
||||
"prettier": "^3.2.4",
|
||||
"ts-node": "^10.9.1",
|
||||
"typescript": "5.5",
|
||||
"typescript": "^5.6.2",
|
||||
"utils": "*",
|
||||
"yaml": "^2.3.4"
|
||||
},
|
||||
|
||||
@@ -6,6 +6,7 @@ import { CommonCliOptions } from "../../types/index.js"
|
||||
import { existsSync, readdirSync, statSync } from "node:fs"
|
||||
import path from "node:path"
|
||||
import getBasePath from "../../utils/get-base-path.js"
|
||||
import getMonorepoRoot from "../../utils/get-monorepo-root.js"
|
||||
|
||||
export type Options = {
|
||||
paths: string[]
|
||||
@@ -50,7 +51,7 @@ abstract class AbstractGenerator {
|
||||
)
|
||||
})
|
||||
|
||||
this.program = ts.createProgram(files, {})
|
||||
this.program = ts.createProgram(files, this.getBaseCompilerOptions())
|
||||
|
||||
this.checker = this.program.getTypeChecker()
|
||||
|
||||
@@ -90,6 +91,23 @@ abstract class AbstractGenerator {
|
||||
this.program = undefined
|
||||
this.checker = undefined
|
||||
}
|
||||
|
||||
getBaseCompilerOptions(): ts.CompilerOptions {
|
||||
const monorepoPath = getMonorepoRoot()
|
||||
const tsconfigBasePath = path.join(monorepoPath, "_tsconfig.base.json")
|
||||
|
||||
const configStr = ts.sys.readFile(tsconfigBasePath)
|
||||
|
||||
if (!configStr) {
|
||||
return {}
|
||||
}
|
||||
|
||||
return ts.parseJsonConfigFileContent(
|
||||
JSON.parse(configStr),
|
||||
ts.sys,
|
||||
monorepoPath
|
||||
).options
|
||||
}
|
||||
}
|
||||
|
||||
export default AbstractGenerator
|
||||
|
||||
@@ -37,6 +37,34 @@ class SchemaFactory {
|
||||
BigNumberValue: {
|
||||
type: "number",
|
||||
},
|
||||
expand: {
|
||||
type: "string",
|
||||
title: "expand",
|
||||
description:
|
||||
"Comma-separated relations that should be expanded in the returned data.",
|
||||
},
|
||||
fields: {
|
||||
type: "string",
|
||||
title: "fields",
|
||||
description:
|
||||
"Comma-separated fields that should be included in the returned data. if a field is prefixed with `+` it will be added to the default fields, using `-` will remove it from the default fields. without prefix it will replace the entire default fields.",
|
||||
},
|
||||
offset: {
|
||||
type: "number",
|
||||
title: "offset",
|
||||
description: "The number of items to skip when retrieving a list.",
|
||||
},
|
||||
limit: {
|
||||
type: "number",
|
||||
title: "limit",
|
||||
description: "Limit the number of items returned in the list.",
|
||||
},
|
||||
order: {
|
||||
type: "string",
|
||||
title: "order",
|
||||
description:
|
||||
"The field to sort the data by. By default, the sort order is ascending. To change the order to descending, prefix the field name with `-`.",
|
||||
},
|
||||
File: {
|
||||
type: "object",
|
||||
description: "A File to upload.",
|
||||
|
||||
@@ -35,7 +35,11 @@ export default class TypesHelper {
|
||||
}
|
||||
|
||||
cleanUpTypes(types: ts.Type[]): ts.Type[] {
|
||||
let cleanedUpTypes = this.removeStringRegExpTypeOverlaps(types)
|
||||
let cleanedUpTypes = this.removeUndefinedNullTypes(types)
|
||||
|
||||
cleanedUpTypes = this.removeExtraBoolean(cleanedUpTypes)
|
||||
|
||||
cleanedUpTypes = this.removeStringRegExpTypeOverlaps(cleanedUpTypes)
|
||||
|
||||
cleanedUpTypes = this.joinDateAndString(cleanedUpTypes)
|
||||
|
||||
@@ -80,4 +84,28 @@ export default class TypesHelper {
|
||||
|
||||
return dateType && hasStringType ? [dateType] : types
|
||||
}
|
||||
|
||||
private removeUndefinedNullTypes(types: ts.Type[]): ts.Type[] {
|
||||
return types.filter(
|
||||
(type) =>
|
||||
type.flags !== ts.TypeFlags.Undefined &&
|
||||
type.flags !== ts.TypeFlags.Null
|
||||
)
|
||||
}
|
||||
|
||||
private removeExtraBoolean(types: ts.Type[]): ts.Type[] {
|
||||
let found = false
|
||||
return types.filter((tsType) => {
|
||||
if (tsType.flags !== ts.TypeFlags.BooleanLiteral) {
|
||||
return true
|
||||
}
|
||||
|
||||
if (!found) {
|
||||
found = true
|
||||
return true
|
||||
}
|
||||
|
||||
return false
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1356,7 +1356,9 @@ class OasKindGenerator extends FunctionKindGenerator {
|
||||
name: title,
|
||||
}),
|
||||
}
|
||||
case "intrinsicName" in itemType && itemType.intrinsicName === "boolean":
|
||||
case ("intrinsicName" in itemType &&
|
||||
itemType.intrinsicName === "boolean") ||
|
||||
itemType.flags === ts.TypeFlags.BooleanLiteral:
|
||||
return {
|
||||
type: "boolean",
|
||||
title: title || typeAsString,
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
"ts-node": "^10.9.1",
|
||||
"typedoc": "^0.26.2",
|
||||
"typedoc-plugin-custom": "*",
|
||||
"typescript": "5.5",
|
||||
"typescript": "^5.6.2",
|
||||
"utils": "*"
|
||||
},
|
||||
"devDependencies": {
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
"glob": "^10.3.10",
|
||||
"randomcolor": "^0.6.2",
|
||||
"ts-node": "^10.9.1",
|
||||
"typescript": "5.5"
|
||||
"typescript": "^5.6.2"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/node": "^20.12.10",
|
||||
|
||||
@@ -29,7 +29,7 @@
|
||||
"typedoc-plugin-rename-defaults": "^0.7.0",
|
||||
"typedoc-plugin-workflows": "*",
|
||||
"types": "*",
|
||||
"typescript": "5.5",
|
||||
"typescript": "^5.6.2",
|
||||
"utils": "*",
|
||||
"yaml": "^2.3.4"
|
||||
},
|
||||
|
||||
@@ -25,7 +25,7 @@
|
||||
"@types/eslint": "^8.56.6",
|
||||
"@types/node": "^20.12.10",
|
||||
"types": "*",
|
||||
"typescript": "5.5"
|
||||
"typescript": "^5.6.2"
|
||||
},
|
||||
"keywords": [
|
||||
"typedocplugin",
|
||||
|
||||
@@ -25,7 +25,7 @@
|
||||
"copyfiles": "^2.4.1",
|
||||
"typedoc": "^0.26.2",
|
||||
"types": "*",
|
||||
"typescript": "5.5"
|
||||
"typescript": "^5.6.2"
|
||||
},
|
||||
"keywords": [
|
||||
"typedocplugin",
|
||||
|
||||
@@ -25,7 +25,7 @@
|
||||
"@types/eslint": "^8.56.6",
|
||||
"@types/node": "^20.12.10",
|
||||
"types": "*",
|
||||
"typescript": "5.5"
|
||||
"typescript": "^5.6.2"
|
||||
},
|
||||
"keywords": [
|
||||
"typedocplugin",
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
"typedoc": "0.26.x"
|
||||
},
|
||||
"devDependencies": {
|
||||
"typescript": "5.5"
|
||||
"typescript": "^5.6.2"
|
||||
},
|
||||
"version": "0.0.0",
|
||||
"main": "./lib/index.js",
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/node": "^20.12.10",
|
||||
"typescript": "5.5"
|
||||
"typescript": "^5.6.2"
|
||||
},
|
||||
"dependencies": {
|
||||
"octokit": "^3.1.2",
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
"@mermaid-js/mermaid-cli": "^10.6.1",
|
||||
"commander": "^11.1.0",
|
||||
"ts-node": "^10.9.1",
|
||||
"typescript": "5.5"
|
||||
"typescript": "^5.6.2"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/node": "^20.12.10"
|
||||
|
||||
@@ -2387,7 +2387,7 @@ __metadata:
|
||||
prettier: ^3.2.4
|
||||
ts-node: ^10.9.1
|
||||
types: "*"
|
||||
typescript: 5.5
|
||||
typescript: ^5.6.2
|
||||
utils: "*"
|
||||
yaml: ^2.3.4
|
||||
languageName: unknown
|
||||
@@ -4651,7 +4651,7 @@ __metadata:
|
||||
ts-node: ^10.9.1
|
||||
typedoc: ^0.26.2
|
||||
typedoc-plugin-custom: "*"
|
||||
typescript: 5.5
|
||||
typescript: ^5.6.2
|
||||
utils: "*"
|
||||
peerDependencies:
|
||||
typedoc: 0.25.x
|
||||
@@ -4855,7 +4855,7 @@ __metadata:
|
||||
glob: ^10.3.10
|
||||
randomcolor: ^0.6.2
|
||||
ts-node: ^10.9.1
|
||||
typescript: 5.5
|
||||
typescript: ^5.6.2
|
||||
languageName: unknown
|
||||
linkType: soft
|
||||
|
||||
@@ -5369,7 +5369,7 @@ __metadata:
|
||||
typedoc-plugin-rename-defaults: ^0.7.0
|
||||
typedoc-plugin-workflows: "*"
|
||||
types: "*"
|
||||
typescript: 5.5
|
||||
typescript: ^5.6.2
|
||||
utils: "*"
|
||||
yaml: ^2.3.4
|
||||
peerDependencies:
|
||||
@@ -5387,7 +5387,7 @@ __metadata:
|
||||
glob: ^10.3.10
|
||||
minimatch: ^10.0.1
|
||||
types: "*"
|
||||
typescript: 5.5
|
||||
typescript: ^5.6.2
|
||||
utils: "*"
|
||||
yaml: ^2.3.3
|
||||
peerDependencies:
|
||||
@@ -5404,7 +5404,7 @@ __metadata:
|
||||
handlebars: ^4.7.8
|
||||
typedoc: ^0.26.2
|
||||
types: "*"
|
||||
typescript: 5.5
|
||||
typescript: ^5.6.2
|
||||
utils: "*"
|
||||
peerDependencies:
|
||||
typedoc: 0.26.x
|
||||
@@ -5433,7 +5433,7 @@ __metadata:
|
||||
eslint: ^8.53.0
|
||||
glob: ^10.3.10
|
||||
types: "*"
|
||||
typescript: 5.5
|
||||
typescript: ^5.6.2
|
||||
utils: "*"
|
||||
yaml: ^2.3.3
|
||||
peerDependencies:
|
||||
@@ -5462,29 +5462,29 @@ __metadata:
|
||||
version: 0.0.0-use.local
|
||||
resolution: "types@workspace:packages/types"
|
||||
dependencies:
|
||||
typescript: 5.5
|
||||
typescript: ^5.6.2
|
||||
peerDependencies:
|
||||
typedoc: 0.26.x
|
||||
languageName: unknown
|
||||
linkType: soft
|
||||
|
||||
"typescript@npm:5.5":
|
||||
version: 5.5.2
|
||||
resolution: "typescript@npm:5.5.2"
|
||||
"typescript@npm:^5.6.2":
|
||||
version: 5.6.2
|
||||
resolution: "typescript@npm:5.6.2"
|
||||
bin:
|
||||
tsc: bin/tsc
|
||||
tsserver: bin/tsserver
|
||||
checksum: 8ca39b27b5f9bd7f32db795045933ab5247897660627251e8254180b792a395bf061ea7231947d5d7ffa5cb4cc771970fd4ef543275f9b559f08c9325cccfce3
|
||||
checksum: 3ed8297a8c7c56b7fec282532503d1ac795239d06e7c4966b42d4330c6cf433a170b53bcf93a130a7f14ccc5235de5560df4f1045eb7f3550b46ebed16d3c5e5
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"typescript@patch:typescript@5.5#~builtin<compat/typescript>":
|
||||
version: 5.5.2
|
||||
resolution: "typescript@patch:typescript@npm%3A5.5.2#~builtin<compat/typescript>::version=5.5.2&hash=7ad353"
|
||||
"typescript@patch:typescript@^5.6.2#~builtin<compat/typescript>":
|
||||
version: 5.6.2
|
||||
resolution: "typescript@patch:typescript@npm%3A5.6.2#~builtin<compat/typescript>::version=5.6.2&hash=7ad353"
|
||||
bin:
|
||||
tsc: bin/tsc
|
||||
tsserver: bin/tsserver
|
||||
checksum: 6721ac8933a70c252d7b640b345792e103d881811ff660355617c1836526dbb71c2044e2e77a8823fb3570b469f33276875a4cab6d3c4de4ae7d7ee1c3074ae4
|
||||
checksum: e6c1662e4852e22fe4bbdca471dca3e3edc74f6f1df043135c44a18a7902037023ccb0abdfb754595ca9028df8920f2f8492c00fc3cbb4309079aae8b7de71cd
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
@@ -5635,7 +5635,7 @@ __metadata:
|
||||
"@types/node": ^20.12.10
|
||||
octokit: ^3.1.2
|
||||
rimraf: ^5.0.5
|
||||
typescript: 5.5
|
||||
typescript: ^5.6.2
|
||||
peerDependencies:
|
||||
typedoc: 0.26.x
|
||||
languageName: unknown
|
||||
@@ -5722,7 +5722,7 @@ __metadata:
|
||||
"@types/node": ^20.12.10
|
||||
commander: ^11.1.0
|
||||
ts-node: ^10.9.1
|
||||
typescript: 5.5
|
||||
typescript: ^5.6.2
|
||||
bin:
|
||||
workflow-diagrams-generator: dist/index.js
|
||||
languageName: unknown
|
||||
|
||||
Reference in New Issue
Block a user