Skip to content

Commit 17399fa

Browse files
committed
feat: allow customTypesVersionsJson
1 parent 56a3fca commit 17399fa

File tree

1 file changed

+25
-20
lines changed

1 file changed

+25
-20
lines changed

src/main/kotlin/me/commandblock2/tsGenerator/NPMPackageGenerator.kt

Lines changed: 25 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -33,29 +33,34 @@ class NPMPackageGenerator(
3333
val version: String = "1.0.0",
3434
extraFiles: String = "",
3535
extraTypesVersion: String = "",
36-
otherExtras: String = ""
36+
otherExtras: String = "",
37+
// New parameter to directly inject the typesVersions JSON content
38+
customTypesVersionsJson: String? = null
3739
) {
38-
3940
val typesFolder = "types"
40-
4141
val packageJson = """
42-
{
43-
"name": "$packageName",
44-
"version": "$version",
45-
"files": [
46-
"$typesFolder/**/*.d.ts"
47-
${if (extraFiles.isNotEmpty()) ",\n$extraFiles" else ""}
48-
],
49-
"typesVersions": {
50-
"*": {
51-
"*": [
52-
"./$typesFolder/*"
53-
${if (extraTypesVersion.isNotEmpty()) ",\n$extraTypesVersion" else ""}
54-
]
55-
}
56-
}
57-
${if (otherExtras.isNotEmpty()) ",\n$otherExtras" else ""}
58-
}
42+
{
43+
"name": "$packageName",
44+
"version": "$version",
45+
"files": [
46+
"$typesFolder/**/*.d.ts"
47+
${if (extraFiles.isNotEmpty()) ",\n$extraFiles" else ""}
48+
],
49+
"typesVersions": ${
50+
// If custom JSON is provided, use it directly (assume it's valid JSON for typesVersions)
51+
customTypesVersionsJson
52+
?: // Otherwise, generate the default typesVersions block
53+
"""{
54+
"*": {
55+
"*": [
56+
"./$typesFolder/*"
57+
${if (extraTypesVersion.isNotEmpty()) ",\n$extraTypesVersion" else ""}
58+
]
59+
}
60+
}"""
61+
}
62+
${if (otherExtras.isNotEmpty()) ",\n$otherExtras" else ""}
63+
}
5964
""".trimIndent()
6065

6166
val tsConfig = """

0 commit comments

Comments
 (0)