File tree Expand file tree Collapse file tree 3 files changed +21
-11
lines changed
javascript/frameworks/cap/lib/advanced_security/javascript/frameworks/cap Expand file tree Collapse file tree 3 files changed +21
-11
lines changed Original file line number Diff line number Diff line change @@ -96,10 +96,26 @@ jobs:
9696 for cds_file in $(find . -type f \( -iname '*.cds' \) -print)
9797 do
9898 echo "I am compiling $cds_file"
99+ _out_path="${cds_file}.json"
99100 cds compile $cds_file \
100- -2 json \
101101 --locations \
102- > "$cds_file.json" 2> "$cds_file.err"
102+ --to json \
103+ --dest "$_out_path" \
104+ 2> "$cds_file.err"
105+ # Check if the output is a regular file or a (sub)directory, where
106+ # files generated in an output directory will need to have the file
107+ # extension changed from '.json' to '.cds.json', but we don't need
108+ # to rename anything if the cds compiler just generated a single
109+ # '.cds.json' file.
110+ if [ -d "$_out_path" ]
111+ then
112+ for json_file in $(find "$_out_path" -type f \( -iname '*.json' \) -print)
113+ do
114+ _new_path="${json_file%.json}.cds.json"
115+ echo "Renaming CDS compiler generated JSON file $json_file to $_new_path"
116+ mv "$json_file" "$_new_path"
117+ done
118+ fi
103119 done
104120 popd
105121 done
Original file line number Diff line number Diff line change @@ -165,8 +165,8 @@ class CdlService extends CdlElement {
165165 CdlService ( ) { kind = CdlServiceKind ( this .getPropStringValue ( "kind" ) ) }
166166
167167 UserDefinedApplicationService getImplementation ( ) {
168- this .getFile ( ) .getStem ( ) = result . getFile ( ) . getStem ( ) + ".cds" and
169- this . getFile ( ) . getParentContainer ( ) = this .getFile ( ) .getParentContainer ( )
168+ result .getFile ( ) .getRelativePath ( ) . regexpReplaceAll ( "\\.[^.]+$" , ".cds.json" ) =
169+ this .getFile ( ) .getRelativePath ( )
170170 }
171171
172172 /**
Original file line number Diff line number Diff line change @@ -442,13 +442,7 @@ abstract class UserDefinedApplicationService extends UserDefinedService {
442442 /**
443443 * Gets the CDS definition of this service.
444444 */
445- CdlService getCdsDeclaration ( ) {
446- exists ( CdsFile cdsFile |
447- cdsFile .getStem ( ) = this .getFile ( ) .getStem ( ) + ".cds" and
448- cdsFile .getParentContainer ( ) = this .getFile ( ) .getParentContainer ( ) and
449- result .getFile ( ) = cdsFile
450- )
451- }
445+ CdlService getCdsDeclaration ( ) { result .getImplementation ( ) = this }
452446
453447 /**
454448 * Gets the name of this service.
You can’t perform that action at this time.
0 commit comments