Migrate mentions of `flutter pub run`

This commit is contained in:
Simon Binder 2023-06-19 16:09:47 +02:00
parent 5fe28cbf37
commit 81315c3d69
No known key found for this signature in database
GPG Key ID: 7891917E4147B8C0
11 changed files with 20 additions and 29 deletions

View File

@ -13,10 +13,8 @@ The drift cli tool is experimental at the moment. Please report all issues you c
## Usage
If your app depends on `drift_dev`, you're ready to use the CLI tool.
In this article, we'll use `pub run ...` to start the tool.
If you're using Flutter, you need to run `flutter pub run ...`.
In either case, the tool should be run from the same folder where you keep your
`pubspec.yaml`.
In this article, we'll use `dart run drift_dev` to start the tool.
The tool should be run from the same folder where you keep your `pubspec.yaml`.
## Analyze

View File

@ -61,9 +61,9 @@ examples. Otherwise, the generator won't be able to know what's going on.
## Generating the code
Drift integrates with Dart's `build` system, so you can generate all the code needed with
`flutter pub run build_runner build`. If you want to continuously rebuild the generated code
where you change your code, run `flutter pub run build_runner watch` instead.
Drift integrates with Dart's `build` system, so you can generate all the code needed with
`dart run build_runner build`. If you want to continuously rebuild the generated code
where you change your code, run `dart run build_runner watch` instead.
After running either command once, drift's generator will have created a class for your
database and data classes for your entities. To use it, change the `MyDatabase` class
defined in the earlier snippet as follows:

View File

@ -78,7 +78,7 @@ in the previous step.
{% include "blocks/snippet" snippets = dart_snippets name = '(full)' %}
To generate the `database.g.dart` file which contains the `_$AppDb`
superclass, run `flutter pub run build_runner build` on the command
superclass, run `dart run build_runner build` on the command
line.
## What drift generates

View File

@ -414,13 +414,13 @@ Nowm, run the compiler and copy the compiled worker JS files to `web/`:
```shell
#Debug mode
flutter pub run build_runner build --delete-conflicting-outputs -o web:build/web/
dart run build_runner build --delete-conflicting-outputs -o web:build/web/
cp -f build/web/worker.dart.js web/worker.dart.js
```
```shell
#Release mode
flutter pub run build_runner build --release --delete-conflicting-outputs -o web:build/web/
dart run build_runner build --release --delete-conflicting-outputs -o web:build/web/
cp -f build/web/worker.dart.js web/worker.dart.min.js
```

View File

@ -34,7 +34,7 @@ We can now declare tables and queries in the drift file:
{% include "blocks/snippet" snippets = drift_tables %}
After running the build runner with `flutter pub run build_runner build`,
After running the build runner with `dart run build_runner build`,
drift will write the `database.g.dart`
file which contains the `_$MyDb` superclass. Let's take a look at
what we got:

View File

@ -102,15 +102,14 @@ Also, please __create a backup of your project's files__ before running the migr
your sources without further confirmation. When using git, it is sufficient to ensure that you have a clean state.
To apply the migration, run `dart run moor_generator migrate` in your project's directory.
When using Flutter, run `flutter pub run moor_generator migrate` instead.
The migration tool will transform your pubspec, `build.yaml` files and Dart source files. It will also rename `.moor` files to
`.drift` and patch imports as needed.
After running the migration, please verify the changes to ensure that they match what you expect.
Also, you may have to
- Format your sources again: Run `dart format .` or `flutter format .`
- Re-run the build: Run `dart run build_runner build` or `flutter pub run build_runner build --delete-conflicting-outputs`, respectively.
- Format your sources again: Run `dart format .`.
- Re-run the build: Run `dart run build_runner build -d`.
- If you have been using generated [migration test files]({{ 'Advanced Features/migrations.md#exporting-the-schema' | pageUrl }}),
re-generate them as well with `dart run drift_dev schema generate drift_schemas/ test/generated_migrations/`
(you may have to adapt the command to the directories you use for schemas).

View File

@ -44,10 +44,8 @@ class MigrateCommand extends MoorCommand {
final isRunningFlutter = Platform.executable == 'flutter';
final formatCommand =
isRunningFlutter ? 'flutter format .' : 'dart format .';
final pubGetCommand = isRunningFlutter ? 'flutter pub get' : 'dart pub get';
final buildCommand = isRunningFlutter
? 'flutter pub run build_runner build --delete-conflicting-outputs'
: 'dart run build_runner build';
final pubGetCommand = 'dart pub get';
final buildCommand = 'dart run build_runner build -d';
print('${green.wrap('Done!')} Next steps:');
print(' - Please check changed files for correctness');

View File

@ -22,7 +22,7 @@ for more details on this.
## Development
As this app uses drift, it depends on code-generation.
Use `flutter pub run build_runner build` to automatically build the generated
Use `dart run build_runner build` to automatically build the generated
code.
### Testing
@ -47,14 +47,14 @@ incrementing your schema version. It will export the current schema of the
database as a JSON file. You should check those generated files into source control.
```
flutter pub run drift_dev schema dump lib/database/database.dart drift_schemas/
dart run drift_dev schema dump lib/database/database.dart drift_schemas/
```
Then, run the following command to automatically generate test utilities which
you can use to write unit tests for schema migrations:
```
flutter pub run drift_dev schema generate drift_schemas/ test/generated_migrations/
dart run drift_dev schema generate drift_schemas/ test/generated_migrations/
```
An example for a schema test is in `test/migration_test.dart`.

View File

@ -1,8 +1,8 @@
rm -f web/worker.dart.js
rm -f web/worker.dart.min.js
flutter pub run build_runner build --delete-conflicting-outputs -o web:build/web/
dart run build_runner build --delete-conflicting-outputs -o web:build/web/
cp -f build/web/worker.dart.js web/worker.dart.js
rm -rf build/web
flutter pub run build_runner build --release --delete-conflicting-outputs -o web:build/web/
dart run build_runner build --release --delete-conflicting-outputs -o web:build/web/
cp -f build/web/worker.dart.js web/worker.dart.min.js
rm -rf build/web

View File

@ -13,10 +13,6 @@ dependencies:
dev_dependencies:
build_runner: ^2.1.4
build_web_compilers: ^3.2.1
build_web_compilers: ^4.0.3
flutter_lints: ^1.0.4
drift_dev:
dependency_overrides:
# Flutter's test packages don't support the latest analyzer yet.
test_api: ^0.4.16

View File

@ -24,7 +24,7 @@ scripts:
exec: {concurrency: 1}
build:
run: flutter pub run build_runner build --delete-conflicting-outputs
run: dart run build_runner build --delete-conflicting-outputs
exec: {concurrency: 1}
packageFilters:
dependsOn: build_runner