File tree Expand file tree Collapse file tree 4 files changed +40
-3
lines changed
Expand file tree Collapse file tree 4 files changed +40
-3
lines changed Original file line number Diff line number Diff line change @@ -8,9 +8,11 @@ RUN apk update && apk upgrade
88COPY package.json .
99COPY package-lock.json .
1010COPY generateEsModulesFromJson.cjs .
11+ COPY updateVersionOpenApi.cjs .
12+ COPY openapi.yaml .
13+
1114RUN npm ci --omit=dev
1215
1316COPY src ./src
14- COPY openapi.yaml .
1517
1618CMD ["npm" , "start" ]
Original file line number Diff line number Diff line change 33 title : iExec market API
44 description : >-
55 iExec market API OpenAPI specification
6- version : 6.4 .1
6+ version : 7.1 .1
77 license :
88 name : Apache 2.0
99 url : http://www.apache.org/licenses/LICENSE-2.0.html
Original file line number Diff line number Diff line change 99 "npm" : " >=10.0.0"
1010 },
1111 "scripts" : {
12- "codegen" : " node generateEsModulesFromJson.cjs" ,
12+ "codegen" : " node generateEsModulesFromJson.cjs && node updateVersionOpenApi.cjs " ,
1313 "postinstall" : " npm run codegen" ,
1414 "format" : " prettier --write ." ,
1515 "check-format" : " prettier --check ." ,
Original file line number Diff line number Diff line change 1+ const path = require ( 'path' ) ;
2+ const { writeFile, readFile } = require ( 'fs/promises' ) ;
3+
4+ const OPEN_API_SPECIFICATION_FILE = 'openapi.yaml' ;
5+
6+ async function updateVersionOpenApi ( ) {
7+ const packagePath = path . join ( __dirname , 'package.json' ) ;
8+ const packageContent = await readFile ( packagePath , 'utf8' ) ;
9+ const packageJson = JSON . parse ( packageContent ) ;
10+ const packageVersion = packageJson . version ;
11+
12+ const openApiPath = path . join ( __dirname , OPEN_API_SPECIFICATION_FILE ) ;
13+ const openApiContent = await readFile ( openApiPath , 'utf8' ) ;
14+ const openApiVersionPattern = / v e r s i o n : \d + \. \d + \. \d + ( - \S + ) ? / ;
15+
16+ const [ match ] = openApiContent . match ( openApiVersionPattern ) ;
17+
18+ const currentVersion = match . split ( 'version: ' ) [ 1 ] ;
19+ if ( currentVersion === packageVersion ) {
20+ return ;
21+ }
22+ const updatedContent = openApiContent . replace (
23+ openApiVersionPattern ,
24+ `version: ${ packageVersion } ` ,
25+ ) ;
26+ await writeFile ( openApiPath , updatedContent , 'utf8' ) ;
27+ console . log (
28+ `version updated from ${ currentVersion } to ${ packageVersion } in ${ OPEN_API_SPECIFICATION_FILE } ` ,
29+ ) ;
30+ }
31+
32+ updateVersionOpenApi ( ) . catch ( ( error ) => {
33+ console . error ( 'Error updating OpenAPI version:' , error ) ;
34+ process . exit ( 1 ) ;
35+ } ) ;
You can’t perform that action at this time.
0 commit comments