Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: remove dependency_overrides from temporary pubspec.yaml #199

Merged
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
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# Changelog

## Version 0.20.1
- fix: remove dependency overrides from the pubspec.yaml file of the package to analyze as those might point to relative paths that are not resolvable in the context of the package to analyze

## Version 0.20.0
- update analyzer's lower boundary to avoid the 'withNullability' required param (it is required on lower versions)

Expand Down
20 changes: 20 additions & 0 deletions lib/src/cli/commands/command_mixin.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import 'package:args/args.dart';
import 'package:dart_apitool/api_tool.dart';
import 'package:dart_apitool/src/cli/source_item.dart';
import 'package:path/path.dart' as p;
import 'package:pubspec_manager/pubspec_manager.dart';

import '../package_ref.dart';
import '../prepared_package_ref.dart';
Expand Down Expand Up @@ -175,6 +176,25 @@ OBSOLETE: Has no effect anymore.
await Directory(exampleDirPath).delete(recursive: true);
}

// remove any dependency overrides from the pubspec.yaml
final pubspecFile = File(p.join(packagePath, 'pubspec.yaml'));
if (pubspecFile.existsSync()) {
try {
final pubSpec = PubSpec.load(directory: packagePath);
// removeAll of dependencyOverrides has an issue in the current version of pubspec_manager
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// removeAll of dependencyOverrides has an issue in the current version of pubspec_manager
// removeAll of dependencyOverrides, there's an issue in the current version of pubspec_manager

// as it doesn't remove the section part of the dependency overrides and therefore are not removed
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// as it doesn't remove the section part of the dependency overrides and therefore are not removed
// as it doesn't remove the section part of the dependency overrides and therefore it is not removed

// in the saved version of the pubspec.yaml file
// workaround: remove all dependency overrides manually
for (final depOverride in pubSpec.dependencyOverrides.list) {
pubSpec.dependencyOverrides.remove(depOverride.name);
}
pubSpec.save();
} catch (e) {
await stdoutSession.writeln(
'Error removing dependency overrides from pubspec.yaml: $e');
}
}

// Check if the package_config.json is already present from the preparation step
final packageConfig = File(_getPackageConfigPathForPackage(packagePath));
if (!packageConfig.existsSync()) {
Expand Down
1 change: 1 addition & 0 deletions pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ dependencies:
path: ^1.9.0
plist_parser: ^0.0.9
pub_semver: ^2.1.4
pubspec_manager: ^1.0.0
pubspec_parse: ^1.2.0
stack: ^0.2.1
tuple: ^2.0.0
Expand Down
11 changes: 11 additions & 0 deletions test/integration_tests/cli/extract_command_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -240,5 +240,16 @@ void main() {
},
timeout: integrationTestTimeout,
);
test('Can handle ffigen dependency overrides correctly', () async {
final packageName = 'ffigen';
final packageVersion = '16.0.0';

final exitCode = await runner.run([
'extract',
'--input',
'pub://$packageName/$packageVersion',
]);
expect(exitCode, 0);
});
});
}
Loading