diff --git a/CHANGELOG.md b/CHANGELOG.md index eb58d1ed..e888d6b9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,7 @@ ## 0.22.6 - New recognized example files in the `example/bin` directory. +- Add `has:executable` tag for packages with `bin/.dart` files. ## 0.22.5 diff --git a/lib/src/package_analyzer.dart b/lib/src/package_analyzer.dart index 2d6944a8..88f5f03c 100644 --- a/lib/src/package_analyzer.dart +++ b/lib/src/package_analyzer.dart @@ -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? processedScreenshots = []; final screenshotResults = await context.screenshots; for (final r in screenshotResults) { diff --git a/lib/src/package_context.dart b/lib/src/package_context.dart index c651f463..48126a02 100644 --- a/lib/src/package_context.dart +++ b/lib/src/package_context.dart @@ -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()) { + 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 { diff --git a/lib/src/tag/pana_tags.dart b/lib/src/tag/pana_tags.dart index 79357e37..6dfbe942 100644 --- a/lib/src/tag/pana_tags.dart +++ b/lib/src/tag/pana_tags.dart @@ -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'; diff --git a/lib/src/version.dart b/lib/src/version.dart index 866e2d8b..69bda6a0 100644 --- a/lib/src/version.dart +++ b/lib/src/version.dart @@ -1,2 +1,2 @@ // Generated code. Do not modify. -const packageVersion = '0.22.6-dev'; +const packageVersion = '0.22.6'; diff --git a/pubspec.yaml b/pubspec.yaml index cef79aac..f55717af 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -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 diff --git a/test/goldens/end2end/steward-0.3.1.json b/test/goldens/end2end/steward-0.3.1.json index edf56e73..adae55fb 100644 --- a/test/goldens/end2end/steward-0.3.1.json +++ b/test/goldens/end2end/steward-0.3.1.json @@ -69,7 +69,8 @@ "is:dart3-compatible", "license:mit", "license:fsf-libre", - "license:osi-approved" + "license:osi-approved", + "has:executable" ], "report": { "sections": [