Skip to content

Commit a6ffffc

Browse files
committed
Added a script to upgrade the version.
Signed-off-by: Youssef Ben <youssef.benhessou@gmail.com>
1 parent ec1e0bf commit a6ffffc

File tree

4 files changed

+77
-5
lines changed

4 files changed

+77
-5
lines changed

scripts/bump-version.sh

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
#!/bin/bash
2+
3+
# Define colors using ANSI escape codes
4+
RED='\033[0;31m'
5+
GREEN='\033[0;32m'
6+
MAGENTA='\033[0;35m'
7+
YELLOW='\033[0;33m'
8+
NC='\033[0m' # No Color
9+
10+
update_version_fields() {
11+
local file="$1"
12+
local version="$2"
13+
local release_date="$(date +"%Y-%m-%d")"
14+
15+
echo "-------------------------------------------------------------"
16+
echo -e "${GREEN}[INF] - Starting the script for ($file)!${NC}"
17+
18+
# Get the original content of the JSON file
19+
original_content=$(<"$file")
20+
21+
# Update the fields in the JSON file
22+
echo -e "${GREEN}[INF] - Updating the version in the file ...${NC}"
23+
sed -i "s/\"version\": \".*\"/\"version\": \"$version\"/" "$file"
24+
sed -i "s/\"releaseDate\": \".*\"/\"releaseDate\": \"$release_date\"/" "$file"
25+
26+
# Get the updated content of the JSON file
27+
updated_content=$(<"$file")
28+
29+
# Display only the differences between the original and updated content
30+
if [ "$original_content" != "$updated_content" ]
31+
then
32+
echo -e "${GREEN}[INF] - The following are the changes made to the file:${NC}"
33+
diff --color --palette=':ad=\033[0;35:de=\033[0;31:ln=\033[0' <(echo "$original_content") <(echo "$updated_content")
34+
else
35+
echo -e "${YELLOW}[WRN] - Nothing to do, the file is up to date!${NC}"
36+
fi
37+
38+
echo -e "${GREEN}[INF] - Done.${NC}"
39+
echo -e "-------------------------------------------------------------\n"
40+
}
41+
42+
# BEGINING
43+
#----------------------------------
44+
if [ $# -ne 1 ]
45+
then
46+
echo -e "${RED}[ERR] - Usage: $0 <version>${NC}"
47+
exit 1
48+
fi
49+
50+
VERSION="$1"
51+
BASE_FOLDER=.
52+
53+
if find "$PWD" -maxdepth 1 -type f -name "*.sh" | read; then
54+
echo -e "${YELLOW}[WRN] - Adjusting the files path!${NC}"
55+
BASE_FOLDER=..
56+
fi
57+
58+
SERVER_FILE_PATH=$BASE_FOLDER/src/server/package.json
59+
WEB_FILE_PATH=$BASE_FOLDER/src/clients/web/package.json
60+
MOBILE_FILE_PATH=$BASE_FOLDER/src/clients/mobile/package.json
61+
62+
# Check if JSON file exists
63+
if [[ ! -f "$SERVER_FILE_PATH" || ! -f "$WEB_FILE_PATH" || ! -f "$MOBILE_FILE_PATH" ]]
64+
then
65+
echo -e "${RED}[ERR] - All of the following files are required \n[\n "$SERVER_FILE_PATH",\n "$WEB_FILE_PATH",\n "$MOBILE_FILE_PATH"\n]${NC}"
66+
exit 1
67+
fi
68+
69+
update_version_fields $SERVER_FILE_PATH $VERSION
70+
update_version_fields $WEB_FILE_PATH $VERSION
71+
update_version_fields $MOBILE_FILE_PATH $VERSION

src/clients/mobile/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "vytc",
3-
"version": "1.0.0",
4-
"releaseDate": "2021-10-30",
3+
"version": "1.0.6",
4+
"releaseDate": "2024-02-15",
55
"productName": "vytc - Videos youtube converter",
66
"homepage": "https://github.com/Youssef-ben/video-converter/#readme",
77
"description": "Converts youtube videos or other MP4 videos MP3 format.",

src/clients/web/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
{
22
"name": "vytc-client",
3-
"version": "1.0.0",
3+
"version": "1.0.6",
4+
"releaseDate": "2024-02-15",
45
"productName": "vytc - Client for videos and youtube converter",
56
"description": "vytc - Client for videos and youtube converter.",
67
"license": "MIT",

src/server/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "vytc",
3-
"version": "1.0.0",
4-
"releaseDate": "2021-10-30",
3+
"version": "1.0.6",
4+
"releaseDate": "2024-02-15",
55
"productName": "vytc - Videos youtube converter",
66
"homepage": "https://github.com/Youssef-ben/video-converter/#readme",
77
"description": "Converts youtube videos or other MP4 videos MP3 format.",

0 commit comments

Comments
 (0)