Skip to content

Commit

Permalink
fix: the dependencies feature is didn't work
Browse files Browse the repository at this point in the history
fix: you have to provide type for getIt
  • Loading branch information
nathan.pham committed Mar 14, 2024
1 parent b6f6cb4 commit 41d2ae7
Show file tree
Hide file tree
Showing 7 changed files with 49 additions and 75 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -75,3 +75,4 @@ build/
!**/ios/**/default.pbxuser
!**/ios/**/default.perspectivev3
!/packages/flutter_tools/test/data/dart_dependencies_test/**/.packages
injectable/pubspec.lock
45 changes: 0 additions & 45 deletions injectable/pubspec.lock

This file was deleted.

2 changes: 1 addition & 1 deletion injectable/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ environment:

dependencies:
get_it: ">=7.2.0 <8.0.0"
meta: ^1.12.0
meta: ^1.11.0

dev_dependencies:
lints: ^3.0.0
8 changes: 4 additions & 4 deletions injectable_generator/lib/code_builder/builder_utils.dart
Original file line number Diff line number Diff line change
Expand Up @@ -111,10 +111,10 @@ void _sortByDependents(
return true;
}
// if dep is already in sorted return true
if (lookupDependencyWithNoEnvOrHasAny(iDep, sorted, dep.environments) !=
null) {
return true;
}
// if (lookupDependencyWithNoEnvOrHasAny(iDep, sorted, dep.environments) !=
// null) {
// return true;
// }
// if dep is in unSorted we skip it in this iteration, if not we include it
return lookupDependencyWithNoEnvOrHasAny(
iDep, unSorted, dep.environments) ==
Expand Down
34 changes: 17 additions & 17 deletions injectable_generator/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -69,18 +69,18 @@ packages:
dependency: transitive
description:
name: build_resolvers
sha256: "6c4dd11d05d056e76320b828a1db0fc01ccd376922526f8e9d6c796a5adbac20"
sha256: "339086358431fa15d7eca8b6a36e5d783728cf025e559b834f4609a1fcfb7b0a"
url: "https://pub.dev"
source: hosted
version: "2.2.1"
version: "2.4.2"
build_runner:
dependency: "direct dev"
description:
name: build_runner
sha256: "10c6bcdbf9d049a0b666702cf1cee4ddfdc38f02a19d35ae392863b47519848b"
sha256: "581bacf68f89ec8792f5e5a0b2c4decd1c948e97ce659dc783688c8a88fbec21"
url: "https://pub.dev"
source: hosted
version: "2.4.6"
version: "2.4.8"
build_runner_core:
dependency: transitive
description:
Expand All @@ -93,10 +93,10 @@ packages:
dependency: "direct dev"
description:
name: build_test
sha256: "927ef98b58c5603ec58923c0bb943a74743e58149732665885bb1eb92983befe"
sha256: "260dbba934f41b0a42935e9cae1f5731b94f0c3e489dc97bcf8e281265aaa5ae"
url: "https://pub.dev"
source: hosted
version: "2.1.7"
version: "2.2.2"
built_collection:
dependency: transitive
description:
Expand Down Expand Up @@ -255,7 +255,7 @@ packages:
path: "../injectable"
relative: true
source: path
version: "2.3.5"
version: "2.4.0"
io:
dependency: transitive
description:
Expand Down Expand Up @@ -284,10 +284,10 @@ packages:
dependency: "direct dev"
description:
name: lints
sha256: "6b0206b0bf4f04961fc5438198ccb3a885685cd67d4d4a32cc20ad7f8adbe015"
sha256: cbf8d4b858bb0134ef3ef87841abdf8d63bfc255c266b7bf6b39daa1085c4290
url: "https://pub.dev"
source: hosted
version: "2.1.0"
version: "3.0.0"
logging:
dependency: transitive
description:
Expand All @@ -300,10 +300,10 @@ packages:
dependency: transitive
description:
name: matcher
sha256: "1803e76e6653768d64ed8ff2e1e67bea3ad4b923eb5c56a295c3e634bad5960e"
sha256: d2323aa2060500f906aa31a895b4030b6da3ebdcc5619d14ce1aada65cd161cb
url: "https://pub.dev"
source: hosted
version: "0.12.16"
version: "0.12.16+1"
meta:
dependency: "direct main"
description:
Expand Down Expand Up @@ -484,26 +484,26 @@ packages:
dependency: "direct dev"
description:
name: test
sha256: b9a384c4b9c4966dbf7215e7c033a78db1da7e5dcaf8da9232c5f24735f65652
sha256: "7ee446762c2c50b3bd4ea96fe13ffac69919352bd3b4b17bac3f3465edc58073"
url: "https://pub.dev"
source: hosted
version: "1.24.5"
version: "1.25.2"
test_api:
dependency: transitive
description:
name: test_api
sha256: "5c2f730018264d276c20e4f1503fd1308dfbbae39ec8ee63c5236311ac06954b"
sha256: "9955ae474176f7ac8ee4e989dadfb411a58c30415bcfb648fa04b2b8a03afa7f"
url: "https://pub.dev"
source: hosted
version: "0.6.1"
version: "0.7.0"
test_core:
dependency: transitive
description:
name: test_core
sha256: c6a536288535efef8526eea8adfa4e25fdd2849fa7f457ecb2a52099998ce8f7
sha256: "2bc4b4ecddd75309300d8096f781c0e3280ca1ef85beda558d33fcbedc2eead4"
url: "https://pub.dev"
source: hosted
version: "0.5.5"
version: "0.6.0"
timing:
dependency: transitive
description:
Expand Down
16 changes: 8 additions & 8 deletions injectable_generator/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@ dependencies:
code_builder: ^4.10.0
dart_style: ^2.0.3
injectable:
^2.4.0
# path: ../injectable
collection: ^1.17.1
# ^2.4.0
path: ../injectable
collection: ^1.18.0
recase: ^4.1.0
meta: ^1.9.1
meta: ^1.11.0
dev_dependencies:
build_runner: ^2.3.3
build_test: ^2.1.3
test: ^1.17.12
lints: ^2.0.0
build_runner: ^2.4.8
build_test: ^2.2.2
test: ^1.25.2
lints: ^3.0.0
18 changes: 18 additions & 0 deletions injectable_generator/test/code_builder/builder_utils_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,24 @@ void main() {
expect(sortDependencies(deps).toList(), expectedResult);
});

test(
'Sorting with environments in mind, should sort as [B{prd},C,B{dev}},A{dev}]',
() {
final deps = [
DependencyConfig.factory('A', deps: ['B'], envs: ['dev', 'prod']),
DependencyConfig.factory('B', envs: ['prod']),
DependencyConfig.factory('B', envs: ['dev'], deps: ['C']),
DependencyConfig.factory('C'),
];
final expectedResult = [
DependencyConfig.factory('B', envs: ['prod']),
DependencyConfig.factory('C'),
DependencyConfig.factory('B', envs: ['dev'], deps: ['C']),
DependencyConfig.factory('A', deps: ['B'], envs: ['dev', 'prod']),
];
expect(sortDependencies(deps).toList(), expectedResult);
});

test('should sort as [A,B]', () {
final deps = [
DependencyConfig.factory('AppServiceUser', deps: ['Service']),
Expand Down

0 comments on commit 41d2ae7

Please sign in to comment.