@@ -56,51 +56,50 @@ 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 )
73
74
. filter ( ( gen ) => gen . language === 'javascript' )
74
75
. forEach ( ( gen ) => {
75
- const additionalProperties = gen . additionalProperties ;
76
+ const { additionalProperties } = gen ;
76
77
const newVersion = semver . inc (
77
78
additionalProperties . packageVersion ,
78
79
jsVersion . releaseType
79
80
) ;
81
+ const packageName = `${ clientsConfig . javascript . npmNamespace } /${ additionalProperties . packageName } ` ;
80
82
81
83
if ( ! newVersion ) {
82
84
throw new Error (
83
- `Failed to bump version ${ additionalProperties . packageVersion } by ${ jsVersion . releaseType } .`
85
+ `Failed to bump ' ${ packageName } ' by ' ${ jsVersion . releaseType } ' .`
84
86
) ;
85
87
}
86
88
87
89
additionalProperties . packageVersion = newVersion ;
88
90
89
- if ( ! additionalProperties . packageName ) {
91
+ if ( ! packageName ) {
90
92
throw new Error (
91
- `Package name is missing for JavaScript - ${ gen . client } .`
93
+ `Package name is missing for JavaScript - ${ packageName } .`
92
94
) ;
93
95
}
94
96
95
- if ( nodePgPackageFile . dependencies [ additionalProperties . packageName ] ) {
96
- nodePgPackageFile . dependencies [ additionalProperties . packageName ] =
97
- newVersion ;
98
- }
99
-
100
- if ( browserPgPackageFile . dependencies [ additionalProperties . packageName ] ) {
101
- browserPgPackageFile . dependencies [ additionalProperties . packageName ] =
102
- newVersion ;
103
- }
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
+ } ) ;
104
103
105
104
// We don't want this field to be in the final file, it only exists
106
105
// in the scripts.
@@ -110,14 +109,12 @@ async function updateVersionForJavascript(
110
109
CLIENTS_JS_UTILS . forEach ( ( util ) => {
111
110
const utilPackageName = `${ clientsConfig . javascript . npmNamespace } /${ util } ` ;
112
111
113
- if ( nodePgPackageFile . dependencies [ utilPackageName ] ) {
114
- nodePgPackageFile . dependencies [ utilPackageName ] = nextUtilsPackageVersion ;
115
- }
116
-
117
- if ( browserPgPackageFile . dependencies [ utilPackageName ] ) {
118
- browserPgPackageFile . dependencies [ utilPackageName ] =
119
- nextUtilsPackageVersion ;
120
- }
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
+ } ) ;
121
118
} ) ;
122
119
123
120
// update `openapitools.json` config file
@@ -129,13 +126,19 @@ async function updateVersionForJavascript(
129
126
// update `package.json` node playground file
130
127
await writeJsonFile (
131
128
toAbsolutePath ( 'playground/javascript/node/package.json' ) ,
132
- nodePgPackageFile
129
+ pkgFiles . node
133
130
) ;
134
131
135
132
// update `package.json` browser playground file
136
133
await writeJsonFile (
137
134
toAbsolutePath ( 'playground/javascript/browser/package.json' ) ,
138
- 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
139
142
) ;
140
143
141
144
// update `clients.config.json` file for the utils version
0 commit comments