mirror of
https://github.com/flutter/flutter.git
synced 2026-02-06 03:39:05 +08:00
[flutter_tools] forward all args to pub (#69784)
Change forwarding command to pass through all args, even -h - this allows flutter to support all of the pub flags without needing to declare them.
This commit is contained in:
parent
1be922c353
commit
ed1189259e
@ -2,6 +2,8 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
import 'package:args/args.dart';
|
||||
|
||||
import '../base/common.dart';
|
||||
import '../base/os.dart';
|
||||
import '../build_info.dart';
|
||||
@ -19,7 +21,7 @@ class PackagesCommand extends FlutterCommand {
|
||||
addSubcommand(PackagesGetCommand('get', false));
|
||||
addSubcommand(PackagesGetCommand('upgrade', true));
|
||||
addSubcommand(PackagesTestCommand());
|
||||
addSubcommand(PackagesPublishCommand());
|
||||
addSubcommand(PackagesForwardCommand('publish', 'Publish the current package to pub.dartlang.org', requiresPubspec: true));
|
||||
addSubcommand(PackagesForwardCommand('downgrade', 'Downgrade packages in a Flutter project', requiresPubspec: true));
|
||||
addSubcommand(PackagesForwardCommand('deps', 'Print package dependencies', requiresPubspec: true));
|
||||
addSubcommand(PackagesForwardCommand('run', 'Run an executable from a package', requiresPubspec: true));
|
||||
@ -115,7 +117,7 @@ class PackagesGetCommand extends FlutterCommand {
|
||||
await pub.get(
|
||||
context: PubContext.pubGet,
|
||||
directory: directory,
|
||||
upgrade: upgrade ,
|
||||
upgrade: upgrade,
|
||||
offline: boolArg('offline'),
|
||||
generateSyntheticPackage: flutterProject.manifest.generateSyntheticPackage,
|
||||
);
|
||||
@ -189,52 +191,16 @@ class PackagesTestCommand extends FlutterCommand {
|
||||
}
|
||||
}
|
||||
|
||||
class PackagesPublishCommand extends FlutterCommand {
|
||||
PackagesPublishCommand() {
|
||||
requiresPubspecYaml();
|
||||
argParser.addFlag('dry-run',
|
||||
abbr: 'n',
|
||||
negatable: false,
|
||||
help: 'Validate but do not publish the package.',
|
||||
);
|
||||
argParser.addFlag('force',
|
||||
abbr: 'f',
|
||||
negatable: false,
|
||||
help: 'Publish without confirmation if there are no errors.',
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
String get name => 'publish';
|
||||
|
||||
@override
|
||||
String get description {
|
||||
return 'Publish the current package to pub.dev';
|
||||
}
|
||||
|
||||
@override
|
||||
String get invocation {
|
||||
return '${runner.executableName} pub publish [--dry-run]';
|
||||
}
|
||||
|
||||
@override
|
||||
Future<FlutterCommandResult> runCommand() async {
|
||||
final List<String> args = <String>[
|
||||
...argResults.rest,
|
||||
if (boolArg('dry-run')) '--dry-run',
|
||||
if (boolArg('force')) '--force',
|
||||
];
|
||||
await pub.interactively(<String>['publish', ...args], stdio: globals.stdio);
|
||||
return FlutterCommandResult.success();
|
||||
}
|
||||
}
|
||||
|
||||
class PackagesForwardCommand extends FlutterCommand {
|
||||
PackagesForwardCommand(this._commandName, this._description, {bool requiresPubspec = false}) {
|
||||
if (requiresPubspec) {
|
||||
requiresPubspecYaml();
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
ArgParser argParser = ArgParser.allowAnything();
|
||||
|
||||
final String _commandName;
|
||||
final String _description;
|
||||
|
||||
@ -257,7 +223,6 @@ class PackagesForwardCommand extends FlutterCommand {
|
||||
await pub.interactively(<String>[_commandName, ...argResults.rest], stdio: globals.stdio);
|
||||
return FlutterCommandResult.success();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
class PackagesPassthroughCommand extends FlutterCommand {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user