From d65be4a83bd66a2182c057386e7ef1390986098f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Istv=C3=A1n=20So=C3=B3s?= Date: Mon, 12 Feb 2024 09:32:35 +0100 Subject: [PATCH] Fix ambigious dartdoc version value when unspecified. (#1343) --- CHANGELOG.md | 5 +++++ README.md | 2 +- bin/pana.dart | 3 ++- lib/src/sdk_env.dart | 27 ++++++++++++--------------- lib/src/version.dart | 2 +- pubspec.yaml | 2 +- test/goldens/help.txt | 2 +- 7 files changed, 23 insertions(+), 20 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0fdb48051..f8f00aea1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,8 @@ +## 0.22.1 + +- Fix: unspecified `--dartdoc-version` will use the latest version in an isolated + environment. To use the SDK's `dartdoc`, set the value to `sdk`. + ## 0.22.0 - `ToolEnvironment`: diff --git a/README.md b/README.md index f662b728b..5b8ce13cf 100644 --- a/README.md +++ b/README.md @@ -40,5 +40,5 @@ Options: --hosted Download and analyze a hosted package (from https://pub.dev). --[no-]dartdoc Run dartdoc and score the package on documentation coverage. (defaults to on) - --dartdoc-version The dartdoc version to use (otherwise the latest stable). + --dartdoc-version The dartdoc version to use: `sdk`, `latest` (default) or ``. ``` diff --git a/bin/pana.dart b/bin/pana.dart index aef587af2..1e7723aa4 100755 --- a/bin/pana.dart +++ b/bin/pana.dart @@ -72,7 +72,8 @@ final _parser = ArgParser() ) ..addOption( 'dartdoc-version', - help: 'The dartdoc version to use (otherwise the latest stable).', + help: + 'The dartdoc version to use: `sdk`, `latest` (default) or ``.', ) ..addOption( 'resources-output', diff --git a/lib/src/sdk_env.dart b/lib/src/sdk_env.dart index b284bde25..dcd7dbe88 100644 --- a/lib/src/sdk_env.dart +++ b/lib/src/sdk_env.dart @@ -453,9 +453,16 @@ class ToolEnvironment { if (sdkDir != null) ...['--sdk-dir', sdkDir], ]; - PanaProcessResult pr; - - if (_dartdocVersion != null) { + if (_dartdocVersion == 'sdk') { + final command = + usesFlutter ? _flutterSdk._dartSdk.dartCmd : _dartSdk.dartCmd; + return await runConstrained( + [...command, 'doc', ...args], + workingDirectory: packageDir, + environment: _dartSdk.environment, + timeout: timeout, + ); + } else { if (!_globalDartdocActivated) { await runConstrained( [ @@ -464,7 +471,7 @@ class ToolEnvironment { 'global', 'activate', 'dartdoc', - _dartdocVersion!, + if (_dartdocVersion != null) _dartdocVersion!, ], environment: { ..._dartSdk.environment, @@ -475,24 +482,14 @@ class ToolEnvironment { _globalDartdocActivated = true; } final command = usesFlutter ? _flutterSdk.flutterCmd : _dartSdk.dartCmd; - pr = await runConstrained( + return await runConstrained( [...command, 'pub', 'global', 'run', 'dartdoc', ...args], workingDirectory: packageDir, environment: usesFlutter ? _flutterSdk.environment : _dartSdk.environment, timeout: timeout, ); - } else { - final command = - usesFlutter ? _flutterSdk._dartSdk.dartCmd : _dartSdk.dartCmd; - pr = await runConstrained( - [...command, 'doc', ...args], - workingDirectory: packageDir, - environment: _dartSdk.environment, - timeout: timeout, - ); } - return pr; } /// Removes the `dev_dependencies` from the `pubspec.yaml`, diff --git a/lib/src/version.dart b/lib/src/version.dart index f0ca228f3..b6cafbe4f 100644 --- a/lib/src/version.dart +++ b/lib/src/version.dart @@ -1,2 +1,2 @@ // Generated code. Do not modify. -const packageVersion = '0.22.0'; +const packageVersion = '0.22.1'; diff --git a/pubspec.yaml b/pubspec.yaml index c06f588cf..2076fd969 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.0 +version: 0.22.1 repository: https://github.com/dart-lang/pana topics: - tool diff --git a/test/goldens/help.txt b/test/goldens/help.txt index 7e0dd1e81..f2987f71d 100644 --- a/test/goldens/help.txt +++ b/test/goldens/help.txt @@ -12,4 +12,4 @@ Options: --hosted Download and analyze a hosted package (from https://pub.dev). --[no-]dartdoc Run dartdoc and score the package on documentation coverage. (defaults to on) - --dartdoc-version The dartdoc version to use (otherwise the latest stable). \ No newline at end of file + --dartdoc-version The dartdoc version to use: `sdk`, `latest` (default) or ``. \ No newline at end of file