-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.sh
More file actions
executable file
·32 lines (25 loc) · 962 Bytes
/
script.sh
File metadata and controls
executable file
·32 lines (25 loc) · 962 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#!/bin/bash
targetVersion="v1.0" # change this to the version you want to update to
mainPath="./schema"
sourcePath="./src"
baseUrl="https://labimotion.github.io/schema/$targetVersion"
for file in $(find $directoryPath -name "*.json")
do
if jq -e '."$id"' $file > /dev/null; then
filename=$(basename -- "$file") # gets the filename from the file path
# filename="${filename#sch-}" # removes the sch- prefix
newId="$baseUrl/$filename"
jq --arg newId "$newId" '."$id" |= $newId' $file > temp.json && mv temp.json $file
echo "Updated \$id in $file to $newId"
fi
done
# chmod +x script.sh before running
# ./script.sh
targetDirectory="$mainPath/$targetVersion"
latestDirectory="$mainPath/latest"
# Create the target directory if it doesn't exist
mkdir -p "$targetDirectory"
mkdir -p "$latestDirectory"
# Copy the source directory to the target directory
cp -r "$sourcePath"/* "$targetDirectory"
cp -r "$sourcePath"/* "$latestDirectory"