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

extension_discovery: add findPackageConfig() #590

Merged
merged 6 commits into from
Sep 27, 2024

Conversation

sigurdm
Copy link
Contributor

@sigurdm sigurdm commented Sep 27, 2024

This will make it easier to use from a pub workspace.

Copy link

github-actions bot commented Sep 27, 2024

PR Health

Breaking changes ✔️
Package Change Current Version New Version Needed Version Looking good?
extension_discovery Non-Breaking 2.0.1-wip 2.0.1-wip 2.0.1-wip ✔️
Changelog Entry ✔️
Package Changed Files

Changes to files need to be accounted for in their respective changelogs.

Coverage ✔️
File Coverage
pkgs/extension_discovery/lib/extension_discovery.dart 💚 81 %
pkgs/extension_discovery/lib/src/package_config.dart 💚 78 %

This check for test coverage is informational (issues shown here will not fail the PR).

API leaks ✔️

The following packages contain symbols visible in the public API, but not exported by the library. Export these symbols or remove them from your publicly visible API.

Package Leaked API symbols
License Headers ✔️
// Copyright (c) 2024, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
Files
no missing headers

All source files should start with a license header.

Package publish validation ✔️
Package Version Status
package:cli_config 0.2.1-wip WIP (no publish necessary)
package:coverage 1.9.2 already published at pub.dev
package:extension_discovery 2.0.1-wip WIP (no publish necessary)
package:graphs 2.3.3-wip WIP (no publish necessary)
package:mime 2.0.0-wip WIP (no publish necessary)
package:oauth2 2.0.4-wip WIP (no publish necessary)
package:source_map_stack_trace 2.1.3-wip WIP (no publish necessary)
package:unified_analytics 6.1.4-wip WIP (no publish necessary)

Documentation at https://github.com/dart-lang/ecosystem/wiki/Publishing-automation.

///
/// Alternatively a [packageRootDir] can be provided. That is a file uri the the
/// directory containing the `pubspec.yaml` of [targetPackage]. In that case the
/// package_config will be searched by looking in all parent directories.
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
/// package_config will be searched by looking in all parent directories.
/// [packageConfig] will be searched by looking in all parent directories.

pkgs/extension_discovery/lib/extension_discovery.dart Outdated Show resolved Hide resolved
pkgs/extension_discovery/lib/extension_discovery.dart Outdated Show resolved Hide resolved
pkgs/extension_discovery/CHANGELOG.md Outdated Show resolved Hide resolved
pkgs/extension_discovery/lib/extension_discovery.dart Outdated Show resolved Hide resolved
@sigurdm sigurdm changed the title Allow calling findExtensions() with packageDir extension_discovery: add findPackageConfig() Sep 27, 2024
@sigurdm sigurdm force-pushed the findExtensions_packageDir_parameter branch from 1c03d97 to b311c55 Compare September 27, 2024 13:02
@sigurdm sigurdm merged commit 6cda88c into dart-lang:main Sep 27, 2024
14 checks passed
}
while (true) {
final packageConfigCandidate =
packageDir.resolve('.dart_tool/package_config.json');
Copy link
Contributor

Choose a reason for hiding this comment

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

this logic is assuming / is the separator, which won't be true for Windows. Should we be using the path package instead to support Windows paths?

CC @DanTup since you have resolved many windows path issues in the past.

Copy link
Contributor Author

@sigurdm sigurdm Sep 30, 2024

Choose a reason for hiding this comment

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

Good point - I think we are good here though.

These are file urls not file paths. Urls always use / as a separator.

Eg. this program:

import 'dart:io';

void main(List<String> args) {
  print(Uri.file('c:\\abc\\def\\', windows: true));
}

Prints:

file:///c:/abc/def/

Copy link
Contributor

Choose a reason for hiding this comment

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

Yep, this looks reasonable to me.

The things that usually cause issues are reading .path from a File URI, assuming it's correct for Windows (it's not, but it is correct for non-Windows), and going to/from Windows paths when running in the browser (because Dart always treats web as non-Windows even if the file:/// URI is a Windows path).

I note the code below is doing File.fromUri() which will call toFilePath() but since it's calling existsSync() I assume that this code only runs on the host machine (not in a browser) and therefore I don't think any of those gotchas apply here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I assume that this code only runs on the host machine (not in a browser)

Yes, this is running on the host.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants