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

New has:executable tag for dart files in bin/ #1376

Merged
merged 2 commits into from
Jun 12, 2024
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
## 0.22.6

- New recognized example files in the `example/bin` directory.
- Add `has:executable` tag for packages with `bin/<executable>.dart` files.

## 0.22.5

Expand Down
4 changes: 4 additions & 0 deletions lib/src/package_analyzer.dart
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,10 @@ class PackageAnalyzer {
final licenses = await context.licenses;
tags.addAll((await context.licenceTags).tags);

if (await context.hasExecutableInBinDirectory) {
tags.add(PanaTags.hasExecutable);
}

List<ProcessedScreenshot>? processedScreenshots = [];
final screenshotResults = await context.screenshots;
for (final r in screenshotResults) {
Expand Down
21 changes: 21 additions & 0 deletions lib/src/package_context.dart
Original file line number Diff line number Diff line change
Expand Up @@ -348,6 +348,27 @@ class PackageContext {
return null;
}
}();

late final hasExecutableInBinDirectory = () async {
final binDir = Directory(p.join(packageDir, 'bin'));
if (!await binDir.exists()) {
return false;
}
final entries = await binDir.list().toList();
for (final file in entries.whereType<File>()) {
if (!file.path.endsWith('.dart')) {
continue;
}
// minimal sanity check without parsing the source code
final content = await file.readAsString();
if (content.contains('main')) {
continue;
}

return true;
}
return false;
}();
}

class DartdocResult {
Expand Down
1 change: 1 addition & 0 deletions lib/src/tag/pana_tags.dart
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ abstract class PanaTags {

// others
static const hasError = 'has:error';
static const hasExecutable = 'has:executable';
static const hasScreenshot = 'has:screenshot';
static const isPlugin = 'is:plugin';
static const isNullSafe = 'is:null-safe';
Expand Down
2 changes: 1 addition & 1 deletion lib/src/version.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: pana
description: PAckage aNAlyzer - produce a report summarizing the health and quality of a Dart package.
version: 0.22.6-dev
version: 0.22.6
repository: https://github.com/dart-lang/pana
topics:
- tool
Expand Down
3 changes: 2 additions & 1 deletion test/goldens/end2end/steward-0.3.1.json
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,8 @@
"is:dart3-compatible",
"license:mit",
"license:fsf-libre",
"license:osi-approved"
"license:osi-approved",
"has:executable"
],
"report": {
"sections": [
Expand Down