Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions widget_driver_generator/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# CHANGELOG

## 1.3.6

- Fixes bug with code generation in child packages using dart 3.6.2

## 1.3.5

- Updating mocktail to 1.0.4
Expand All @@ -10,11 +14,11 @@

## 1.3.2

- fixes bug where the generator generates code for static fields/methods/accessors.
- Fixes bug where the generator generates code for static fields/methods/accessors.

## 1.3.1

- fixes bug where the "void" keyword was unnecessarily added to setters.
- Fixes bug where the "void" keyword was unnecessarily added to setters.

## 1.3.0

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,19 @@ class PackageInfoProvider {

/// Grabs the version string for widget_driver_generator from the pubspec.lock
Future<String> getPackageVersionString() async {
final pubspecLockString = await _fileReader.readFile('pubspec.lock');
late String pubspecLockString;
Directory workspaceDir = Directory('.').absolute;
File pubspecFile = File('${workspaceDir.path}/pubspec.yaml');

if (_hasWorkspace(pubspecFile)) {
while (!_isWorkSpaceRoot(pubspecFile)) {
workspaceDir = workspaceDir.parent.absolute;
pubspecFile = File('${workspaceDir.path}/pubspec.yaml');
}
pubspecLockString = await _fileReader.readFile('${workspaceDir.path}/pubspec.lock');
} else {
pubspecLockString = await _fileReader.readFile('pubspec.lock');
}

final packageStartIndex = pubspecLockString.indexOf('widget_driver_generator:');
if (packageStartIndex < 0) {
Expand All @@ -26,6 +38,22 @@ class PackageInfoProvider {
final versionNumberString = const LineSplitter().convert(stringToCheck).first;
return versionNumberString;
}

bool _isWorkSpaceRoot(File pubspec) {
if (!pubspec.existsSync()) {
return false;
}
return pubspec.readAsLinesSync().where((e) => e.startsWith('workspace:')).isNotEmpty;
}

bool _hasWorkspace(File pubspec) {
return pubspec
.readAsLinesSync()
.where(
(e) => e.startsWith('resolution:'),
)
.isNotEmpty;
}
}

class FileReader {
Expand Down
2 changes: 1 addition & 1 deletion widget_driver_generator/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: widget_driver_generator
description: This package provides generators for WidgetDriver to automate the creation of your TestDrivers and WidgetDriverProviders
version: 1.3.5
version: 1.3.6
repository: https://github.com/bmw-tech/widget_driver/tree/master/widget_driver_generator
issue_tracker: https://github.com/bmw-tech/widget_driver/issues

Expand Down