125 lines
2.5 KiB
Bash
Executable File
125 lines
2.5 KiB
Bash
Executable File
#!/bin/bash
|
|
script_path=$(dirname "${0}")
|
|
. "${script_path}/lib/common"
|
|
|
|
arguments=(
|
|
"h|help#This help text."
|
|
"u:|user:#User ID to chown files to"
|
|
"g:|group:#Group ID to chown files to"
|
|
)
|
|
|
|
declare -i parse_error=0
|
|
declare project=""
|
|
declare -i group=1000
|
|
declare -i user=1000
|
|
|
|
#
|
|
# Parse command line arguments
|
|
#
|
|
if ! parse_arguments "${@}"; then
|
|
parse_error=1
|
|
fi
|
|
|
|
#
|
|
# Process command line options
|
|
#
|
|
eval set -- "${opts}"
|
|
remaining=$#
|
|
while (( $# > 0 )); do
|
|
if [[ ${remaining} == 0 ]]; then
|
|
fail "case statement is not shifting off values correctly."
|
|
fi
|
|
remaining=$((remaining-1))
|
|
# Uncomment to help debug case statement:
|
|
# echo "Processing: \$1='$1' \$2='$2'"
|
|
case "${1}" in
|
|
-h|--help) # Help / usage
|
|
usage_extra="[PROJECT]"
|
|
default_usage
|
|
exit 0
|
|
;;
|
|
-u|--user)
|
|
user=${1}
|
|
shift
|
|
;;
|
|
-g|--group)
|
|
group=${1}
|
|
shift
|
|
;;
|
|
--)
|
|
shift
|
|
break
|
|
;;
|
|
esac
|
|
shift
|
|
done
|
|
|
|
if (( ${#} > 0 )); then
|
|
project_type=$1
|
|
shift
|
|
fi
|
|
|
|
if (( ${#} > 0 )); then
|
|
project=$1
|
|
shift
|
|
fi
|
|
|
|
if [[ "${project_type}" == "" ]]; then
|
|
echo "PROJECT-TYPE must be supplied." >&2
|
|
exit 1
|
|
fi
|
|
|
|
if [[ "${project}" == "" ]]; then
|
|
echo "PROJECT must be supplied." >&2
|
|
exit 1
|
|
fi
|
|
|
|
if (( parse_error )); then
|
|
exit 1
|
|
fi
|
|
|
|
case "${project_type}" in
|
|
"expo")
|
|
if [[ -e "${project}/package.json" ]]; then
|
|
fail "${project} already exists."
|
|
fi
|
|
|
|
#
|
|
# 'npx expo init' was replaced with 'npx create-expo-app'
|
|
#
|
|
echo "Seeding expo project ${project} in $(pwd)/${project}..."
|
|
if ! npx create-expo-app "${project}"; then
|
|
fail "npx create-expo-app ${project}"
|
|
fi
|
|
|
|
cd "${project}"
|
|
|
|
if ! npx expo install react-native-web react-dom @expo/webpack-config; then
|
|
fail "npx expo install react-native-web react-dom @expo/webpack-config"
|
|
fi
|
|
|
|
echo "Installing node packages..."
|
|
if ! npm install; then
|
|
fail "npm install"
|
|
fi
|
|
|
|
if ! chown -R ${user}:${group} .; then
|
|
fail "chown -R ${user}:${group} ."
|
|
fi
|
|
;;
|
|
"flutter")
|
|
ls -altr /usr/bin/flutter
|
|
declare version="flutter_linux_3.22.2-stable.tar.xz"
|
|
if [[ ! -e "/usr/bin/flutter/${version}" ]]; then
|
|
if ! wget -O "/usr/bin/flutter/${version}" "https://storage.googleapis.com/flutter_infra_release/releases/stable/linux/${version}"; then
|
|
fail "wget ${version}"
|
|
fi
|
|
fi
|
|
if [[ ! -x "/usr/bin/flutter/flutter" ]]; then
|
|
if ! tar -xf "/usr/bin/flutter/${version}" -C /usr/bin/; then
|
|
fail "tar ${version}"
|
|
fi
|
|
fi
|
|
git config --global --add safe.directory /usr/bin/flutter
|
|
;;
|
|
esac |