Skip to content

Commit

Permalink
chore: update pkg
Browse files Browse the repository at this point in the history
  • Loading branch information
han2-n committed Dec 4, 2023
1 parent cd6300d commit c20377b
Show file tree
Hide file tree
Showing 6 changed files with 93 additions and 246 deletions.
67 changes: 16 additions & 51 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,30 +1,25 @@
# riverpod_rnd
# Erb flutter

A new Flutter project.
A Flutter template.

### Requirements

- Dart: 3.1.0
- Flutter SDK: 3.13.0
- Dart: 3.2.0
- Flutter SDK: 3.16.0

## Template: Getting Started

1. Setup:
1. Install [puro](https://puro.dev) Flutter Environment Manager
1. Install Flutter using Puro
1. Install [Melos](https://pub.dev/packages/melos) globally
1. Run `melos bootstrap` to install dependencies for all packages and generate env files.
1. Run `melos bootstrap` to install dependencies and `melos run generate` to generate for all packages.
1. Rename App: [Change App/Package Name](#change-apppackage-name)
1. Update Description: [pubspec.yaml](pubspec.yaml) and [README.md](README.md).
1. Add Environment Variables: [ENVied Environment Variables](#envied-environment-variables) section for details.
1. [Change App Icon: flutter_launcher_icons](https://pub.dev/packages/flutter_launcher_icons)
1. [Change Splash Screen: flutter_native_splash](https://pub.dev/packages/flutter_native_splash)
1. Setup the release build configuration, see the [Building](#building) section.
1. Setup Codecov for the repository, see the [Codecov documentation](https://docs.codecov.com/docs/quick-start).
1. Setup GitPod for the environment, see the [GitPod documentation](https://www.gitpod.io/docs/quickstart/flutter#flutter-quickstart).
1. (**Important!**) Update the [LICENSE](./LICENSE.md) file. I give permission to relicense any
code provided in this template, but the licenses of the packages must still be followed.
1. Delete this `Template: Getting Started` section from the README.

### Change App/Package Name

Expand Down Expand Up @@ -62,7 +57,7 @@ to change the flavor. The following flavors are supported:
## Architecture

This project uses the [Riverpod App Architecture](https://codewithandrea.com/articles/flutter-app-architecture-riverpod-introduction/)
in a feature-first manner where each feature is a separate package in the [lib/src/features/](./lib/src/features/) folder.
in a feature-first manner where each feature is a separate package in the [lib/features/](./lib/features/) folder.
Each feature has its own layers, which separate the business logic from the UI.

### Data Layer (Repositories)
Expand Down Expand Up @@ -115,9 +110,9 @@ defined for debug, profile, and release modes.
- Each key must be added to each `.env*` file, unless a non null default value is added
to the `@EnviedField` annotation.
- It is recommended to use an empty string for the default and use `Env`'s getter to access the value.
1. Update [src/env/app_env_fields.dart](packages/env/lib/src/env/app_env_fields.dart)
with the new environment variables for `AppEnvFieldsGenerated` and `AppEnvFieldsNullable`.
1. Add the new environment variables to the implementing `*Env` classes in the [src/env](packages/env/src/env/) directory.
1. Update [packages/env/lib/src/env/env_fields.dart](packages/env/lib/src/env/env_fields.dart)
with the new environment variables.
1. Add the new environment variables to the implementing `*Env` classes in the [src/env](packages/env/lib/src/env/impl/) directory.
- It must be done for *all* even if only one `.env` file is planned to be used
1. Enable `obfuscate` for API keys in the `@EnviedField` annotation. (Note: still assume it is not secure)
1. Optionally, add a `defaultValue` to the `@EnviedField` annotation for keys which are
Expand Down Expand Up @@ -145,21 +140,17 @@ Pub:
- `melos run pub` - Run `pub get` in all packages.
- `melos run dart:pkg` - Run `dart pub get` in the selected dart package.
- `melos run flutter:pkg` - Run `flutter pub get` in the selected flutter package.
- `melos run upgrade` - Run `pub upgrade` in all packages.
- `melos run upgrade:pkg` - Run `pub upgrade` in the selected package.
- `melos run pub-outdated` - Run `pub outdated` in all packages.
- `melos run pub-upgrade` - Run `pub upgrade` in the package.

Code Generation:

- `dart run build_runner watch -d` - Watch and generate code for the app, does not work with subpackages
- `melos run generate` - Run `build_runner build` in all packages that depend on `build_runner`.
- `melos run generate:pkg` - Run `build_runner build` for a specific package (except `envied` packages).
- `melos run watch:pkg` - Run `build_runner watch` for a specific package (except `envied` packages). It will not work if you choose "all" in the package selection prompt.
- `melos run assets` - Run `assets_gen build` in all packages that depend on `assets_gen`.
- `melos run assets:pkg` - Run `assets_gen build` for a specific package.
- `melos run env` - Run `build_runner` in all packages that depends on `envied`.
- `melos run env:pkg` - Run `build_runner` in a specific package that depends on `envied`.
- `melos run loc` - Run `flutter gen-l10n` in the localization package to generate
the localized strings from the arb files.
- `melos run generate` - Run `build_runner build` generate in all packages that depend on `build_runner` and i18n.
- `melos run generate:pkg` - Run `build_runner build` in all packages that depend on `build_runner`.
- `melos run generate:i18n` - Run `build_runner build` generate i18n.
- `melos run watch:pkg` - Run `build_runner watch` for a specific package. It will not work if you choose "all" in the package selection prompt.
- `melos run watch:i18n` - Run `build_runner watch` for i18n.

### Protip

Expand All @@ -186,29 +177,3 @@ dart run slang apply --outdir=i18n

dart run slang analyze --outdir=i18n # update analyzation result files
```

# Building from Source

- Sync dependencies

```bash
flutter pub get
```

- Run code generator

```bash
dart run build_runner build --delete-conflicting-outputs
```

- Generate translation

```bash
dart run slang
```

- Run the app with your favorite IDE/PDE. or from shell:

```bash
flutter run
```
6 changes: 3 additions & 3 deletions build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ targets:
enable_cached_builds: true

global_options:
json_serializable:
runs_before:
- retrofit_generator
# json_serializable:
# runs_before:
# - retrofit_generator
dart_mappable_builder:
options:
renameMethods:
Expand Down
182 changes: 32 additions & 150 deletions melos.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,122 +9,53 @@ command:
# It seems so that running "pub get" in parallel has some issues (like
# https://github.com/dart-lang/pub/issues/3404). Disabling this feature
# makes the CI much more stable.
# runPubGetInParallel: false
runPubGetInParallel: false

hooks:
pre: echo `bootstrap command is running...`

# Activate the coverage package globally so that it can be used in the
# `test` command.
#
# Generate environment files which should not be committed to the repository.
# Instead, they are generated during the CI process before checking
# if the rest of the package's code generation is up to date.
post: flutter pub get && dart pub global activate coverage ^1.6.4 && cd packages/env && dart pub get && dart run build_runner build -d && melos run i18n
# post:

# See https://github.com/firebase/flutterfire/blob/master/melos.yaml for more examples
scripts:
# Custom lint is only applied to the packages and not the root app because of a dependency conflict with `integration_test` and `melos`
pub:
run: |
dart pub get && \
melos run flutter:pkg --no-select
description: Run `dart pub get` in all packages.

flutter:pkg:
run: flutter pub get
exec:
failFast: true
# concurrency: 1
description: Run `flutter pub get` in the selected package.
packageFilters:
dependsOn: flutter
lint:
run: melos run analyze && melos run format
description: Run all static analysis checks.

# which use different versions of `path`.
analyze:
run: melos run analyze:pkg --no-select && melos run custom_lint
description: Run `dart analyze` in all packages.

analyze:pkg:
run: dart analyze --fatal-infos lib
exec:
failFast: true
# concurrency: 1
description: Run `dart analyze` on all packages.

custom_lint:
run: melos run custom_lint:pkg --no-select
description: Run `dart run custom_lint` in all packages with custom lints.

custom_lint:pkg:
run: dart run custom_lint
exec:
failFast: true
# concurrency: 1
description: Run `dart run custom_lint` in the selected package.
packageFilters:
dependsOn: custom_lint

upgrade:
run: |
dart pub upgrade
melos run upgrade:pkg --no-select
description: Run `dart pub upgrade` in all packages.

upgrade:pkg:
run: dart pub upgrade
exec:
failFast: true
description: Run `dart pub upgrade` in the selected package.

upgrade-major:
# We are setting the concurrency to 1 because a higher concurrency can crash
# the analysis server on low performance machines (like GitHub Actions).
run: |
dart pub upgrade
melos run upgrade:pkg --no-select
description: Run `dart pub upgrade --major-versions` in all packages.

upgrade-major:pkg:
run: dart pub upgrade --major-versions
exec:
failFast: true
description: Run `dart pub upgrade --major-versions` in the selected package.
melos exec -c 1 -- \
dart analyze . --fatal-infos
description: |
Run `dart analyze` in all packages.
- Note: you can also rely on your IDEs Dart Analysis / Issues window.
format:
exec: dart format .
description: Run `dart format` in all packages.
run: melos exec dart format . --set-exit-if-changed
description: Run `flutter format` checks for all packages.

fix:
exec: dart fix --apply
description: Run `dart fix --apply` in all packages.

verify_format:
run: dart format --output=none --set-exit-if-changed .
exec:
failFast: true
description: Verify formatting was applied.
format:fix:
run: melos exec dart format . --fix
description: Run `flutter format` for all packages.

generate:
run: |
melos run assets && \
melos run env --no-select && \
melos run generate:pkg --no-select && \
melos run i18n
description: Run `build_runner build` in all packages.
melos run generate:pkg && melos run generate:i18n
description: Run generate in all packages.

generate:pkg:
run: dart run build_runner build --delete-conflicting-outputs
exec:
# concurrency: 5
failFast: true
description: Run `build_runner build` in the selected packages.
packageFilters:
dependsOn: build_runner
noDependsOn: envied
# ignore: localization
run: |
melos exec -c 1 --depends-on=build_runner \
"dart run build_runner build --delete-conflicting-outputs"
description: run `build_runner` to generate code in all packages

i18n:
generate:i18n:
run: dart run slang
exec:
failFast: true
description: Run `dart run slang` generate dart file
packageFilters:
dirExists:
Expand All @@ -148,61 +79,12 @@ scripts:
packageFilters:
dependsOn: build_runner
noDependsOn: envied
# ignore: localization

watch_force:pkg:
run: dart run build_runner watch --delete-conflicting-outputs
exec:
# concurrency: 1
failFast: true
description: Run `build_runner watch` in the selected package. If all is selected, the command will only run in the first package.
packageFilters:
dependsOn: build_runner
noDependsOn: envied
# ignore: localization

env:
run: melos run env:pkg --no-select
description: Run `build_runner` in all packages that depends on `envied`.
pub-outdated:
run: melos exec dart pub outdated
description: Run `dart pub outdated` for all packages.

env:pkg:
run: dart run build_runner clean && dart run build_runner build --delete-conflicting-outputs
exec:
failFast: true
description: Run `build_runner` in a specific package that depends on `envied`.
packageFilters:
dependsOn: envied

assets:
run: melos run assets:pkg --no-select
description: Run `dart run flutter_gen_runner build` all packages with assets gen.

assets:pkg:
run: dart run flutter_gen_runner build
exec:
failFast: true
description: Run `dart run flutter_gen_runner build` in the selected package.
packageFilters:
dependsOn: assets_gen

dart_test:pkg:
run: dart pub global run coverage:test_with_coverage
exec:
failFast: true
# concurrency: 1
description: Run Dart tests for a specific package in this project.
packageFilters:
dirExists: test
dependsOn: test
noDependsOn: flutter

flutter_test:pkg:
run: flutter test --no-pub --coverage
exec:
failFast: true
# concurrency: 1
description: Run Flutter tests for a specific package in this project.
packageFilters:
flutter: true
dirExists: test
dependsOn: flutter_test
pub-upgrade:
# May fails until https://github.com/dart-lang/pub/pull/3920 is released
run: melos exec dart pub upgrade --major-versions
description: Run `dart pub upgrade --major-versions` for all packages.
2 changes: 1 addition & 1 deletion packages/assets/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ dev_dependencies:
flutter_test:
sdk: flutter
flutter_lints: ^2.0.1
build_runner: ^2.4.6
build_runner: ^2.4.7
flutter_gen_runner: ^5.3.2

flutter_gen:
Expand Down
Loading

0 comments on commit c20377b

Please sign in to comment.