feat(analysis): add latest version persistence between script executions
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
Hugo Pointcheval 2023-02-23 18:53:03 +01:00
parent 0f8c5bb983
commit d098d9a6bf
Signed by: hugo
GPG Key ID: 3AAC487E131E00BC
4 changed files with 38 additions and 19 deletions

View File

@ -0,0 +1 @@
2.4.1

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2022 WYATT GROUP
* Copyright (C) 2023 WYATT GROUP
* Please see the AUTHORS file for details.
*
* This program is free software: you can redistribute it and/or modify

View File

@ -20,10 +20,18 @@
![SDK: Dart & Flutter](https://img.shields.io/badge/SDK-Dart%20%7C%20Flutter-blue?style=flat-square)
This package provides lint rules for Dart and Flutter which are used at [Wyatt](https://wyattapp.io) and [Wyatt Studio](https://wyatt-studio.fr). For more information, see the complete list of options in **lib/analysis_options.2.4.0.yaml**.
This package provides lint rules for Dart and Flutter which are used at [Wyatt](https://wyattapp.io) and [Wyatt Studio](https://wyatt-studio.fr). For more information, see the complete list of options in **lib/analysis_options.2.4.1.yaml**.
**Note**: This package was heavily inspired by [pedantic](https://github.com/dart-lang/pedantic), [Very Good Analysis](https://github.com/VeryGoodOpenSource/very_good_analysis) and the official [flutter_lints](https://pub.dev/packages/flutter_lints).
## Adding Wyatt Analysis to your project
Using CLI:
```sh
dart pub add wyatt_analysis:2.4.1 --dev --hosted-url=https://git.wyatt-studio.fr/api/packages/Wyatt-FOSS/pub/
```
## Usage
To use the lints, add a dependency in your `pubspec.yaml` :
@ -31,7 +39,7 @@ To use the lints, add a dependency in your `pubspec.yaml` :
```yaml
wyatt_analysis:
hosted: https://git.wyatt-studio.fr/api/packages/Wyatt-FOSS/pub/
version: 2.4.0
version: 2.4.1
```
Then, add an include in `analysis_options.yaml` :
@ -49,13 +57,13 @@ include: package:wyatt_analysis/analysis_options.flutter.yaml
If you wish to restrict the lint version, specify a version of `analysis_options.yaml` instead:
```yaml
include: package:wyatt_analysis/analysis_options.flutter.2.4.0.yaml
include: package:wyatt_analysis/analysis_options.flutter.2.4.1.yaml
```
If you just want **Dart** version:
```yaml
include: package:wyatt_analysis/analysis_options.2.4.0.yaml
include: package:wyatt_analysis/analysis_options.2.4.1.yaml
```
## Suppressing Lints
@ -109,10 +117,11 @@ To indicate your project is using `wyatt_analysis` → [![style: wyatt analysis]
When you want to create a new version of the plugin. Before any modification, execute the following command to create new files:
```sh
./new_version.sh <previous_version> <new_version>
./new_version.sh <new_version>
```
> Where `<previous_version>` is 2.4.0
The previous version is automatically detected thanks to the `.latest_version` file.
So `.latest_version` needs to be versioned!
## Notes

View File

@ -18,20 +18,12 @@
usage="
usage:
$(basename "$0") <previous_version> <new_version> -- create new analyzer files.
$(basename "$0") <new_version> -- create new analyzer files.
where:
previous_version: last version, for example \`2.3.0\`
new_version: new version, for example \`2.4.0\`"
old=$1
new=$2
if [ -z "$old" ]; then
echo "previous_version cannot be null"
echo "${usage}"
exit 1
fi
new=$1
if [ -z "$new" ]; then
echo "new_version cannot be null"
@ -43,6 +35,19 @@ 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"
@ -52,6 +57,7 @@ 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}"
@ -91,7 +97,7 @@ sed -e "s/${old}/${new}/g" "README.md" > tempfile.tmp
mv -f tempfile.tmp "README.md"
echo "
# Copyright (C) 2022 WYATT GROUP
# Copyright (C) 2023 WYATT GROUP
# Please see the AUTHORS file for details.
#
# This program is free software: you can redistribute it and/or modify
@ -111,7 +117,7 @@ include: package:wyatt_analysis/analysis_options.${new}.yaml
" > "${OPTIONS}"
echo "
# Copyright (C) 2022 WYATT GROUP
# Copyright (C) 2023 WYATT GROUP
# Please see the AUTHORS file for details.
#
# This program is free software: you can redistribute it and/or modify
@ -130,4 +136,7 @@ echo "
include: package:wyatt_analysis/analysis_options.flutter.${new}.yaml
" > "${OPTIONS_FLUTTER}"
# Update latest version
echo "${new}" > "$LATEST_VERSION"
exit 0