File tree Expand file tree Collapse file tree 2 files changed +16
-10
lines changed Expand file tree Collapse file tree 2 files changed +16
-10
lines changed Original file line number Diff line number Diff line change @@ -6,12 +6,16 @@ const fs = require('fs');
66const yaml = require ( 'yaml' ) ;
77
88function convert ( filename , date ) {
9- console . log ( filename ) ;
109 const s = fs . readFileSync ( filename , 'utf8' ) ;
1110 let obj ;
1211 try {
1312 obj = yaml . parse ( s , { prettyErrors : true } ) ;
14- //TODO: replace last segment in $id, id, and $ref with date
13+ // replace last segment of id, $id, and $ref value with date
14+ for ( const p of [ "id" , "$id" , "$ref" ] ) {
15+ if ( obj [ p ] ) {
16+ obj [ p ] = obj [ p ] . replace ( / \/ [ ^ \/ ] + $ / , '/' + date ) ;
17+ }
18+ }
1519 console . log ( JSON . stringify ( obj , null , 2 ) ) ;
1620 }
1721 catch ( ex ) {
Original file line number Diff line number Diff line change 66
77for filename in schemas/v3* /schema.yaml ; do
88 version=$( basename $( dirname " $filename " ) )
9- mkdir -p deploy/oas/$version
10-
119 lastCommitDate=$( git log -1 --format=" %ad" --date=format:" %Y%m%d" " $filename " )
1210
13- echo $filename $lastCommitDate $version
14- # TODO:
15- # - generate JSON file "deploy/oas/$version/schema/$lastCommitDate" from schema.yaml
16- # node scripts/schema-convert.js $filename $lastCommitDate > deploy/oas/$version/schema/$lastCommitDate.json
17- # - if schema-base.yaml exists, generate JSON file "deploy/oas/$version/schema-base/$lastCommitDate" from schema-base.yaml
18- # node scripts/schema-convert.js ... $lastCommitDate > deploy/oas/$version/schema-base/$lastCommitDate.json
11+ echo " $filename $lastCommitDate "
12+ mkdir -p deploy/oas/$version /schema
13+ node scripts/schema-convert.js " $filename " $lastCommitDate > deploy/oas/$version /schema/$lastCommitDate .json
14+
15+ filenameBase=$( dirname " $filename " ) /schema-base.yaml
16+ if [ -f " $filenameBase " ]; then
17+ echo " $filenameBase $lastCommitDate "
18+ mkdir -p deploy/oas/$version /schema-base
19+ node scripts/schema-convert.js " $filenameBase " $lastCommitDate > deploy/oas/$version /schema-base/$lastCommitDate .json
20+ fi
1921done
You can’t perform that action at this time.
0 commit comments