Initial commit

This commit is contained in:
Aditya Gupta
2026-06-29 19:29:19 +05:30
committed by GitHub
commit aabb8986aa
292 changed files with 17976 additions and 0 deletions

8
bash-scripts/copy_env.sh Normal file
View File

@@ -0,0 +1,8 @@
#!/bin/bash
# Check if .env does not exist and .example.env exists
if [ ! -f ".env" ] && [ -f ".example.env" ]; then
# Copy .example.env to .env
cp .example.env .env
echo ".example.env has been copied to .env"
fi

View File

@@ -0,0 +1,91 @@
#!/bin/bash
# Default values
CLI_CEB_DEV=false
CLI_CEB_FIREFOX=false
validate_is_boolean() {
if [[ "$1" != "true" && "$1" != "false" ]]; then
echo "Invalid value for <$2>. Please use 'true' or 'false'."
exit 1
fi
}
# Validate if a key starts with CLI_CEB_ or CEB_
validate_key() {
local key="$1"
local is_editable_section="${2:-false}"
if [[ -n "$key" && ! "$key" =~ ^# ]]; then
if [[ "$is_editable_section" == true && ! "$key" =~ ^CEB_ ]]; then
echo "Invalid key: <$key>. All keys in the editable section must start with 'CEB_'."
exit 1
elif [[ "$is_editable_section" == false && ! "$key" =~ ^CLI_CEB_ ]]; then
echo "Invalid key: <$key>. All CLI keys must start with 'CLI_CEB_'."
exit 1
fi
fi
}
parse_arguments() {
for arg in "$@"
do
key="${arg%%=*}"
value="${arg#*=}"
validate_key "$key"
case $key in
CLI_CEB_DEV)
CLI_CEB_DEV="$value"
validate_is_boolean "$CLI_CEB_DEV" "CLI_CEB_DEV"
;;
CLI_CEB_FIREFOX)
CLI_CEB_FIREFOX="$value"
validate_is_boolean "$CLI_CEB_FIREFOX" "CLI_CEB_FIREFOX"
;;
*)
cli_values+=("$key=$value")
;;
esac
done
}
# Validate keys in .env file
validate_env_keys() {
editable_section_starts=false
while IFS= read -r line; do
key="${line%%=*}"
if [[ "$key" =~ ^CLI_CEB_ ]]; then
editable_section_starts=true
elif $editable_section_starts; then
validate_key "$key" true
fi
done < .env
}
create_new_file() {
temp_file=$(mktemp)
{
echo "# THOSE VALUES ARE EDITABLE ONLY VIA CLI"
echo "CLI_CEB_DEV=$CLI_CEB_DEV"
echo "CLI_CEB_FIREFOX=$CLI_CEB_FIREFOX"
for value in "${cli_values[@]}"; do
echo "$value"
done
echo ""
echo "# THOSE VALUES ARE EDITABLE"
# Copy existing env values, without CLI section
grep -E '^CEB_' .env
} > "$temp_file"
mv "$temp_file" .env
}
# Main script execution
parse_arguments "$@"
validate_env_keys
create_new_file

View File

@@ -0,0 +1,17 @@
#!/bin/bash
# Usage: ./update_version.sh <new_version>
# FORMAT IS <0.0.0>
if [[ "$1" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
find . -name 'package.json' -not -path '*/node_modules/*' -exec bash -c '
# Parse the version from package.json
current_version=$(grep -o "\"version\": \"[^\"]*" "$0" | cut -d"\"" -f4)
# Update the version
perl -i -pe"s/$current_version/'$1'/" "$0"
' {} \;
echo "Updated versions to $1";
else
echo "Version format <$1> isn't correct, proper format is <0.0.0>";
fi