Skip to content

Commit 28b64f8

Browse files
committed
Sync open source content 🐝 (from 014748c8e69b9024e2db13ca90e0b1ba721186cf)
1 parent 97f70cc commit 28b64f8

File tree

1 file changed

+69
-0
lines changed

1 file changed

+69
-0
lines changed

docs/speakeasy-reference/generation/ts-config.mdx

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,75 @@ typescript:
7575
]}
7676
/>
7777

78+
## Additional scripts
79+
80+
```yml
81+
typescript:
82+
additionalScripts:
83+
format: "prettier --write src"
84+
docs: "typedoc --out docs src"
85+
custom-test: "vitest run --coverage"
86+
```
87+
88+
<Table
89+
data={[
90+
{ name: "additionalScripts", required: "false", default: "{}", description: "Custom npm scripts to add to the `package.json` file. Scripts with the same name as default scripts will override them." }
91+
]}
92+
columns={[
93+
{ key: "name", header: "Name" },
94+
{ key: "required", header: "Required" },
95+
{ key: "default", header: "Default Value" },
96+
{ key: "description", header: "Description" }
97+
]}
98+
/>
99+
100+
### How scripts are merged
101+
102+
The feature uses an override strategy where additional scripts take precedence over default scripts:
103+
104+
1. **Default scripts** are generated automatically based on SDK configuration:
105+
106+
```json
107+
{
108+
"lint": "eslint --cache --max-warnings=0 src",
109+
"build": "tsc",
110+
"prepublishOnly": "npm run build"
111+
}
112+
```
113+
114+
2. **Test scripts** are added if tests are enabled:
115+
116+
```json
117+
{
118+
"test": "vitest run src --reporter=junit --outputFile=.speakeasy/reports/tests.xml --reporter=default",
119+
"check": "npm run test && npm run lint"
120+
}
121+
```
122+
123+
3. **Additional scripts** override defaults if they have the same name:
124+
125+
```yml
126+
typescript:
127+
additionalScripts:
128+
build: "custom-build-command" # Replaces default "tsc" build
129+
deploy: "npm publish" # Adds new script
130+
```
131+
132+
4. **Result** in `package.json`:
133+
134+
```json
135+
{
136+
"scripts": {
137+
"build": "custom-build-command", // Overridden
138+
"check": "npm run test && npm run lint",
139+
"deploy": "npm publish", // Added
140+
"lint": "eslint --cache --max-warnings=0 src",
141+
"prepublishOnly": "npm run build",
142+
"test": "vitest run src --reporter=junit --outputFile=.speakeasy/reports/tests.xml --reporter=default"
143+
}
144+
}
145+
```
146+
78147
## Method and parameter management
79148

80149
```yml

0 commit comments

Comments
 (0)