@@ -56,17 +56,18 @@ async function updateVersionForJavascript(
56
56
57
57
clientsConfig . javascript . utilsPackageVersion = nextUtilsPackageVersion ;
58
58
59
- // update local playground deps
60
- const nodePgPackageFile = await readJsonFile (
61
- toAbsolutePath ( 'playground/javascript/node/package.json' )
62
- ) ;
63
- const browserPgPackageFile = await readJsonFile (
64
- toAbsolutePath ( 'playground/javascript/browser/package.json' )
65
- ) ;
66
-
67
- if ( ! nodePgPackageFile || ! browserPgPackageFile ) {
68
- throw new Error ( 'Failed to read playground package files' ) ;
69
- }
59
+ // update local `package.json` files
60
+ const pkgFiles = {
61
+ node : await readJsonFile (
62
+ toAbsolutePath ( 'playground/javascript/node/package.json' )
63
+ ) ,
64
+ browser : await readJsonFile (
65
+ toAbsolutePath ( 'playground/javascript/browser/package.json' )
66
+ ) ,
67
+ cts : await readJsonFile (
68
+ toAbsolutePath ( 'tests/output/javascript/package.json' )
69
+ ) ,
70
+ } ;
70
71
71
72
// Sets the new version of the JavaScript client
72
73
Object . values ( GENERATORS )
@@ -93,13 +94,12 @@ async function updateVersionForJavascript(
93
94
) ;
94
95
}
95
96
96
- if ( nodePgPackageFile . dependencies [ packageName ] ) {
97
- nodePgPackageFile . dependencies [ packageName ] = newVersion ;
98
- }
99
-
100
- if ( browserPgPackageFile . dependencies [ packageName ] ) {
101
- browserPgPackageFile . dependencies [ packageName ] = newVersion ;
102
- }
97
+ Object . values ( pkgFiles ) . forEach ( ( pkgFile ) => {
98
+ if ( pkgFile . dependencies [ packageName ] ) {
99
+ // eslint-disable-next-line no-param-reassign
100
+ pkgFile . dependencies [ packageName ] = newVersion ;
101
+ }
102
+ } ) ;
103
103
104
104
// We don't want this field to be in the final file, it only exists
105
105
// in the scripts.
@@ -109,14 +109,12 @@ async function updateVersionForJavascript(
109
109
CLIENTS_JS_UTILS . forEach ( ( util ) => {
110
110
const utilPackageName = `${ clientsConfig . javascript . npmNamespace } /${ util } ` ;
111
111
112
- if ( nodePgPackageFile . dependencies [ utilPackageName ] ) {
113
- nodePgPackageFile . dependencies [ utilPackageName ] = nextUtilsPackageVersion ;
114
- }
115
-
116
- if ( browserPgPackageFile . dependencies [ utilPackageName ] ) {
117
- browserPgPackageFile . dependencies [ utilPackageName ] =
118
- nextUtilsPackageVersion ;
119
- }
112
+ Object . values ( pkgFiles ) . forEach ( ( pkgFile ) => {
113
+ if ( pkgFile . dependencies [ utilPackageName ] ) {
114
+ // eslint-disable-next-line no-param-reassign
115
+ pkgFile . dependencies [ utilPackageName ] = nextUtilsPackageVersion ;
116
+ }
117
+ } ) ;
120
118
} ) ;
121
119
122
120
// update `openapitools.json` config file
@@ -128,13 +126,19 @@ async function updateVersionForJavascript(
128
126
// update `package.json` node playground file
129
127
await writeJsonFile (
130
128
toAbsolutePath ( 'playground/javascript/node/package.json' ) ,
131
- nodePgPackageFile
129
+ pkgFiles . node
132
130
) ;
133
131
134
132
// update `package.json` browser playground file
135
133
await writeJsonFile (
136
134
toAbsolutePath ( 'playground/javascript/browser/package.json' ) ,
137
- browserPgPackageFile
135
+ pkgFiles . browser
136
+ ) ;
137
+
138
+ // update `package.json` node cts file
139
+ await writeJsonFile (
140
+ toAbsolutePath ( 'tests/output/javascript/package.json' ) ,
141
+ pkgFiles . cts
138
142
) ;
139
143
140
144
// update `clients.config.json` file for the utils version
0 commit comments