All checks were successful
continuous-integration/drone/push Build is passing
143 lines
4.4 KiB
Bash
Executable File
143 lines
4.4 KiB
Bash
Executable File
#!/usr/bin/env sh
|
|
|
|
# Copyright (C) 2022 WYATT GROUP
|
|
# Please see the AUTHORS file for details.
|
|
#
|
|
# This program is free software: you can redistribute it and/or modify
|
|
# it under the terms of the GNU General Public License as published by
|
|
# the Free Software Foundation, either version 3 of the License, or
|
|
# any later version.
|
|
#
|
|
# This program is distributed in the hope that it will be useful,
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
# GNU General Public License for more details.
|
|
#
|
|
# You should have received a copy of the GNU General Public License
|
|
# along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
|
|
usage="
|
|
usage:
|
|
$(basename "$0") <new_version> -- create new analyzer files.
|
|
|
|
where:
|
|
new_version: new version, for example \`2.4.0\`"
|
|
|
|
new=$1
|
|
|
|
if [ -z "$new" ]; then
|
|
echo "new_version cannot be null"
|
|
echo "${usage}"
|
|
exit 1
|
|
fi
|
|
|
|
SCRIPT_PATH="${BASH_SOURCE:-$0}"
|
|
ABS_SCRIPT_PATH="$(realpath "${SCRIPT_PATH}")"
|
|
ABS_DIRECTORY="$(dirname "${ABS_SCRIPT_PATH}")"
|
|
|
|
LATEST_VERSION="${ABS_DIRECTORY}/.latest_version"
|
|
|
|
# Read latest version
|
|
if [ -e "$LATEST_VERSION" ]; then
|
|
old=$(cat "$LATEST_VERSION")
|
|
echo "> latest package version is: $old"
|
|
echo "> new package version is: $new"
|
|
else
|
|
echo "latest version is not set"
|
|
echo "create a file named \`.latest_version\` in the root of the project"
|
|
exit 1
|
|
fi
|
|
|
|
LIB="${ABS_DIRECTORY}/lib/wyatt_analysis.dart"
|
|
OPTIONS="${ABS_DIRECTORY}/lib/analysis_options.yaml"
|
|
OLD_OPTIONS="${ABS_DIRECTORY}/lib/analysis_options.${old}.yaml"
|
|
NEW_OPTIONS="${ABS_DIRECTORY}/lib/analysis_options.${new}.yaml"
|
|
|
|
OPTIONS_FLUTTER="${ABS_DIRECTORY}/lib/analysis_options.flutter.yaml"
|
|
OLD_OPTIONS_FLUTTER="${ABS_DIRECTORY}/lib/analysis_options.flutter.${old}.yaml"
|
|
NEW_OPTIONS_FLUTTER="${ABS_DIRECTORY}/lib/analysis_options.flutter.${new}.yaml"
|
|
|
|
|
|
if [ ! -e "$OLD_OPTIONS" ]; then
|
|
echo "analysis_options.${old}.yaml doesn't exists"
|
|
echo "${usage}"
|
|
exit 1
|
|
fi
|
|
|
|
if [ ! -e "$OLD_OPTIONS_FLUTTER" ]; then
|
|
echo "analysis_options.flutter.${old}.yaml doesn't exists"
|
|
echo "${usage}"
|
|
exit 1
|
|
fi
|
|
|
|
if [ -e "$NEW_OPTIONS" ]; then
|
|
echo "analysis_options.${new}.yaml already exists"
|
|
echo "${usage}"
|
|
exit 1
|
|
fi
|
|
|
|
if [ -e "$NEW_OPTIONS_FLUTTER" ]; then
|
|
echo "analysis_options.flutter.${old}.yaml already exists"
|
|
echo "${usage}"
|
|
exit 1
|
|
fi
|
|
|
|
# Copy previous version files
|
|
cp "${OLD_OPTIONS}" "${NEW_OPTIONS}"
|
|
cp "${OLD_OPTIONS_FLUTTER}" "${NEW_OPTIONS_FLUTTER}"
|
|
|
|
# Search and replace old version string occurences in new files
|
|
sed -e "s/${old}/${new}/g" "${NEW_OPTIONS_FLUTTER}" > tempfile.tmp
|
|
mv -f tempfile.tmp "${NEW_OPTIONS_FLUTTER}"
|
|
|
|
sed -e "s/${old}/${new}/g" "${LIB}" > tempfile.tmp
|
|
mv -f tempfile.tmp "${LIB}"
|
|
|
|
sed -e "s/${old}/${new}/g" "README.md" > tempfile.tmp
|
|
mv -f tempfile.tmp "README.md"
|
|
|
|
echo "
|
|
# Copyright (C) 2023 WYATT GROUP
|
|
# Please see the AUTHORS file for details.
|
|
#
|
|
# This program is free software: you can redistribute it and/or modify
|
|
# it under the terms of the GNU General Public License as published by
|
|
# the Free Software Foundation, either version 3 of the License, or
|
|
# any later version.
|
|
#
|
|
# This program is distributed in the hope that it will be useful,
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
# GNU General Public License for more details.
|
|
#
|
|
# You should have received a copy of the GNU General Public License
|
|
# along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
|
|
include: package:wyatt_analysis/analysis_options.${new}.yaml
|
|
" > "${OPTIONS}"
|
|
|
|
echo "
|
|
# Copyright (C) 2023 WYATT GROUP
|
|
# Please see the AUTHORS file for details.
|
|
#
|
|
# This program is free software: you can redistribute it and/or modify
|
|
# it under the terms of the GNU General Public License as published by
|
|
# the Free Software Foundation, either version 3 of the License, or
|
|
# any later version.
|
|
#
|
|
# This program is distributed in the hope that it will be useful,
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
# GNU General Public License for more details.
|
|
#
|
|
# You should have received a copy of the GNU General Public License
|
|
# along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
|
|
include: package:wyatt_analysis/analysis_options.flutter.${new}.yaml
|
|
" > "${OPTIONS_FLUTTER}"
|
|
|
|
# Update latest version
|
|
echo "${new}" > "$LATEST_VERSION"
|
|
|
|
exit 0
|