Skip to content

Commit

Permalink
makefile added, test error removed
Browse files Browse the repository at this point in the history
  • Loading branch information
Sadmansamee committed Oct 29, 2021
1 parent b0a767b commit 0a9533d
Show file tree
Hide file tree
Showing 10 changed files with 106 additions and 114 deletions.
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,9 @@ $ open coverage/index.html

---

## Avoid writing scripts with Derry
## Avoid writing scripts with MakeFile / Derry

You can run all these scripts manually or could use [Derry](https://pub.dev/packages/derry) and maintain a yaml file, where you can define all those scripts and run with derry in a very convinient way. All the scripts for this project is defined [here](https://github.com/SimpleBoilerplates/Flutter/blob/master/derry.yaml)
You can run all these scripts manually or could use [MakeFile](https://github.com/SimpleBoilerplates/Flutter/blob/master/makefile) / [Derry](https://pub.dev/packages/derry) and maintain a file, where you can define all those scripts and run in a very convinient way. All the scripts for this project is defined here [derry scripts](https://github.com/SimpleBoilerplates/Flutter/blob/master/derry.yaml) and [makefile scripts](https://github.com/SimpleBoilerplates/Flutter/blob/master/makefile)

Example:

Expand All @@ -80,9 +80,9 @@ instead of running
```sh
flutter pub run build_runner watch --delete-conflicting-outputs
```
you could simply use `derry watch`
you could simply use `make watch` or `derry watch`

or use `build_apk_dev` instead of
or use `derry build_apk_dev` or `make build_apk_dev` instead of

```sh
flutter build apk --flavor development -t lib/main_development.dart
Expand Down
10 changes: 0 additions & 10 deletions derry.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,16 +26,6 @@ build_apk_prod:
- flutter pub get
- flutter build apk --flavor production -t lib/main_production.dart

build_ios_staging:
- flutter clean
- flutter pub get
- flutter build ipa --export-options-plist --flavor staging -t lib/main_staging.dart

build_ios_production:
- flutter clean
- flutter pub get
- flutter build ipa --flavor staging -t lib/main_staging.dart

start_ios:
- xcrun simctl list
- open /Applications/Xcode.app/Contents/Developer/Applications/Simulator.app/
Expand Down
1 change: 1 addition & 0 deletions lib/shared/constants/app_theme.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

7 changes: 5 additions & 2 deletions lib/shared/http/api_provider.dart
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,9 @@ final apiProvider = Provider<ApiProvider>(
class ApiProvider {
ApiProvider(this._reader) {
_dio = Dio();
_dio.options.connectTimeout = 180000;
_dio.options.receiveTimeout = 180000;
_dio.options.sendTimeout = 30000;
_dio.options.connectTimeout = 30000;
_dio.options.receiveTimeout = 30000;
_dio.interceptors.add(
RetryOnConnectionChangeInterceptor(
requestRetrier: DioConnectivityRequestRetrier(
Expand All @@ -34,6 +35,8 @@ class ApiProvider {
),
);

_dio.httpClientAdapter = DefaultHttpClientAdapter();

(_dio.httpClientAdapter as DefaultHttpClientAdapter).onHttpClientCreate =
(HttpClient client) {
client.badCertificateCallback =
Expand Down
91 changes: 91 additions & 0 deletions makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
.PHONY: all run_dev_web run_dev_mobile run_unit clean upgrade lint format build_dev_mobile help

all: lint format run_dev_mobile

# Adding a help file: https://gist.github.com/prwhite/8168133#gistcomment-1313022
help: ## This help dialog.
@IFS=$$'\n' ; \
help_lines=(`fgrep -h "##" $(MAKEFILE_LIST) | fgrep -v fgrep | sed -e 's/\\$$//'`); \
for help_line in $${help_lines[@]}; do \
IFS=$$'#' ; \
help_split=($$help_line) ; \
help_command=`echo $${help_split[0]} | sed -e 's/^ *//' -e 's/ *$$//'` ; \
help_info=`echo $${help_split[2]} | sed -e 's/^ *//' -e 's/ *$$//'` ; \
printf "%-30s %s\n" $$help_command $$help_info ; \
done

run_unit: ## Runs unit tests
@echo "╠ Running the tests"
@flutter test || (echo "Error while running tests"; exit 1)

clean: ## Cleans the environment
@echo "╠ Cleaning the project..."
@rm -rf pubspec.lock
@flutter clean
@flutter pub get

watch: ## Watches the files for changes
@echo "╠ Watching the project..."
@flutter pub run build_runner watch --delete-conflicting-outputs

gen: ## Generates the assets
@echo "╠ Generating the assets..."
@flutter pub get
@flutter packages pub run build_runner build

format: ## Formats the code
@echo "╠ Formatting the code"
@dart format lib .
@flutter pub run import_sorter:main
@flutter format lib

lint: ## Lints the code
@echo "╠ Verifying code..."
@dart analyze . || (echo "Error in project"; exit 1)

upgrade: clean ## Upgrades dependencies
@echo "╠ Upgrading dependencies..."
@flutter pub upgrade

commit: format lint run_unit
@echo "╠ Committing..."
git add .
git commit

run_dev_web: ## Runs the web application in dev
@echo "╠ Running the app"
@flutter run -d chrome --dart-define=ENVIRONMENT=dev

run_dev_mobile: ## Runs the mobile application in dev
@echo "╠ Running the app"
@flutter run --flavor development -t lib/main_development.dart

run_stg_mobile: ## Runs the mobile application in dev
@echo "╠ Running the app"
@flutter run --flavor staging -t lib/main_staging.dart

run_prd_mobile: ## Runs the mobile application in dev
@echo "╠ Running the app"
@flutter run --flavor production -t lib/main_production.dart

build_apk_dev: ## Runs the mobile application in dev
@flutter clean
@flutter pub get
@flutter build apk --flavor development -t lib/main_development.dart

build_apk_stg: ## Runs the mobile application in staging
@flutter clean
@flutter pub get
@flutter build apk --flavor staging -t lib/main_staging.dart

build_apk_prod: ## Runs the mobile application in prod
@flutter clean
@flutter pub get
@flutter build apk --flavor production -t lib/main_production.dart

purge: ## Purges the Flutter
@pod deintegrate
@flutter clean
@flutter pub get


2 changes: 0 additions & 2 deletions pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ environment:
sdk: ">=2.13.0 <3.0.0"

dependencies:

flutter:
sdk: flutter
flutter_localizations:
Expand Down Expand Up @@ -43,7 +42,6 @@ dev_dependencies:
import_sorter: ^4.6.0
flutter_lints: ^1.0.4


## Install derry from https://pub.dev/packages/derry and run derry build, derry watch, derry gen
scripts: derry.yaml

Expand Down
5 changes: 2 additions & 3 deletions test/app/view/app_test.dart
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
import 'package:flutter_boilerplate/app/app.dart';
import 'package:flutter_boilerplate/counter/counter.dart';
import 'package:flutter_test/flutter_test.dart';

import 'package:flutter_boilerplate/app/app.dart';

void main() {
group('App', () {
testWidgets('renders CounterPage', (tester) async {
await tester.pumpWidget(App());
expect(find.byType(CounterPage), findsOneWidget);
});
});
}
25 changes: 0 additions & 25 deletions test/counter/cubit/counter_cubit_test.dart

This file was deleted.

67 changes: 0 additions & 67 deletions test/counter/view/counter_page_test.dart

This file was deleted.

4 changes: 3 additions & 1 deletion test/helpers/pump_app.dart
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import 'package:flutter/material.dart';
import 'package:flutter/widgets.dart';
import 'package:flutter_boilerplate/l10n/l10n.dart';

import 'package:flutter_localizations/flutter_localizations.dart';
import 'package:flutter_test/flutter_test.dart';

import 'package:flutter_boilerplate/l10n/l10n.dart';

extension PumpApp on WidgetTester {
Future<void> pumpApp(Widget widget) {
return pumpWidget(
Expand Down

0 comments on commit 0a9533d

Please sign in to comment.